imporved php parser
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / views / PHPConsole.java
index ad72992..40e2fce 100644 (file)
@@ -44,70 +44,78 @@ import sun.security.krb5.internal.crypto.e;
  */
 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 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 {
+      if (document == null) {
+        document = new Document(text);
+        viewer.setDocument(document);
+      }
       document.replace(document.getLength(), 0, text);
     } catch (BadLocationException e) {
     }
-  //  viewer.setDocument(document);
+    //  viewer.setDocument(document);
   }
-  
+
   /**
    * Prints out the string represented by the string buffer
    */
-  static public void write(String output) {
+  public static 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) {
+      } 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));
+        new Status(
+          IStatus.ERROR,
+          PHPeclipsePlugin.getPluginId(),
+          0,
+          PHPActionMessages.getString("PHPStartApacheAction.consoleViewOpeningProblem"),
+          e));
     }
 
   }
@@ -115,7 +123,7 @@ public class PHPConsole extends ViewPart {
   /**
    * Creates a string buffer from the given input stream
    */
-  static public String getStringFromStream(InputStream stream) throws IOException {
+  public static String getStringFromStream(InputStream stream) throws IOException {
     StringBuffer buffer = new StringBuffer();
     byte[] b = new byte[100];
     int finished = 0;
@@ -129,7 +137,4 @@ public class PHPConsole extends ViewPart {
     return buffer.toString();
   }
 
-
-
-
 }