--- /dev/null
+package net.sourceforge.phpeclipse.views;
+
+/**********************************************************************
+Copyright (c) 2000, 2002 IBM Corp. and others.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Common Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/cpl-v10.html
+
+Contributors:
+ IBM Corporation - Initial implementation
+ Klaus Hartlage - www.eclipseproject.de
+**********************************************************************/
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.MessageFormat;
+
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+import net.sourceforge.phpeclipse.actions.PHPActionMessages;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.TextViewer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.ViewPart;
+import sun.security.krb5.internal.crypto.e;
+
+/**
+ * The PHPConsole is used to display the output if you start MySQL/Apache
+ * @see ViewPart
+ */
+public class PHPConsole extends ViewPart {
+
+ public static final String CONSOLE_ID = "net.sourceforge.phpeclipse.views.phpconsoleview";
+
+ private TextViewer viewer = null;
+ private Document document = null;
+
+ /**
+ * The constructor.
+ */
+ public PHPConsole() {
+ }
+
+ /**
+ * Insert the method's description here.
+ * @see ViewPart#createPartControl
+ */
+ public void createPartControl(Composite parent) {
+ viewer = new TextViewer(parent, SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL);
+ GridData viewerData = new GridData(GridData.FILL_BOTH);
+ viewer.getControl().setLayoutData(viewerData);
+ viewer.setEditable(false);
+ }
+
+ /**
+ * Insert the method's description here.
+ * @see ViewPart#setFocus
+ */
+ public void setFocus() {
+ }
+
+ /**
+ * Set the text for the viewer
+ */
+ public void setOutputText(String text) {
+ document = new Document(text);
+ viewer.setDocument(document);
+ }
+
+ public void appendOutputText(String text) {
+ try {
+ document.replace(document.getLength(), 0, text);
+ } catch (BadLocationException e) {
+ }
+ // viewer.setDocument(document);
+ }
+
+ /**
+ * Prints out the string represented by the string buffer
+ */
+ static public void write(String output) {
+ try {
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ PHPConsole console = (PHPConsole) page.findView(PHPConsole.CONSOLE_ID);
+
+ if (console != null) {
+ console.appendOutputText(output);
+ } else if (
+ PHPeclipsePlugin.getDefault().getPreferenceStore().getBoolean(PHPeclipsePlugin.SHOW_OUTPUT_IN_CONSOLE) == true) {
+ page.showView(PHPConsole.CONSOLE_ID);
+ console = (PHPConsole) page.findView(PHPConsole.CONSOLE_ID);
+ console.setOutputText(output);
+ }
+ } catch (PartInitException e) {
+ PHPeclipsePlugin.getDefault().getLog().log(
+ new Status(IStatus.ERROR, PHPeclipsePlugin.getPluginId(), 0, PHPActionMessages.getString("PHPStartApacheAction.consoleViewOpeningProblem"), e));
+ }
+
+ }
+
+ /**
+ * Creates a string buffer from the given input stream
+ */
+ static public String getStringFromStream(InputStream stream) throws IOException {
+ StringBuffer buffer = new StringBuffer();
+ byte[] b = new byte[100];
+ int finished = 0;
+ while (finished != -1) {
+ finished = stream.read(b);
+ if (finished != -1) {
+ String current = new String(b, 0, finished);
+ buffer.append(current);
+ }
+ }
+ return buffer.toString();
+ }
+
+
+
+
+}