private void ensureOverviewHoverManagerInstalled() changed to
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / views / PHPConsole.java
index 40e2fce..a858f5c 100644 (file)
@@ -14,29 +14,27 @@ Contributors:
 
 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.action.Action;
+import org.eclipse.jface.resource.JFaceResources;
 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.custom.StyledText;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchActionConstants;
 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
@@ -64,6 +62,29 @@ public class PHPConsole extends ViewPart {
     GridData viewerData = new GridData(GridData.FILL_BOTH);
     viewer.getControl().setLayoutData(viewerData);
     viewer.setEditable(false);
+
+    StyledText widget = viewer.getTextWidget();
+    widget.setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT));
+    Action cutAction = new Action() {
+      public void run() {
+        viewer.getTextWidget().cut();
+      }
+    };
+    Action copyAction = new Action() {
+      public void run() {
+        viewer.getTextWidget().copy();
+      }
+    };
+    Action pasteAction = new Action() {
+      public void run() {
+        viewer.getTextWidget().paste();
+      }
+    };
+
+    IActionBars bars = this.getViewSite().getActionBars();
+    bars.setGlobalActionHandler(IWorkbenchActionConstants.CUT, cutAction);
+    bars.setGlobalActionHandler(IWorkbenchActionConstants.COPY, copyAction);
+    bars.setGlobalActionHandler(IWorkbenchActionConstants.PASTE, pasteAction);
   }
 
   /**
@@ -93,31 +114,36 @@ public class PHPConsole extends ViewPart {
     //  viewer.setDocument(document);
   }
 
-  /**
-   * Prints out the string represented by the string buffer
-   */
-  public static void write(String output) {
-    try {
-      IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
-      PHPConsole console = (PHPConsole) page.findView(PHPConsole.CONSOLE_ID);
+  public static PHPConsole getInstance() {
+    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) {
+    if (PHPeclipsePlugin.getDefault().getPreferenceStore().getBoolean(PHPeclipsePlugin.SHOW_OUTPUT_IN_CONSOLE) == true) {
+
+      try {
         page.showView(PHPConsole.CONSOLE_ID);
-        console = (PHPConsole) page.findView(PHPConsole.CONSOLE_ID);
-        console.setOutputText(output);
+        if (console == null) {
+          console = (PHPConsole) page.findView(PHPConsole.CONSOLE_ID);
+        }
+      } catch (PartInitException e) {
+        PHPeclipsePlugin.getDefault().getLog().log(
+          new Status(
+            IStatus.ERROR,
+            PHPeclipsePlugin.getPluginId(),
+            0,
+            PHPActionMessages.getString("PHPStartApacheAction.consoleViewOpeningProblem"),
+            e));
       }
-    } catch (PartInitException e) {
-      PHPeclipsePlugin.getDefault().getLog().log(
-        new Status(
-          IStatus.ERROR,
-          PHPeclipsePlugin.getPluginId(),
-          0,
-          PHPActionMessages.getString("PHPStartApacheAction.consoleViewOpeningProblem"),
-          e));
+
     }
+    return console;
+  }
 
+  /**
+   * Prints out the string represented by the string buffer
+   */
+  public synchronized void write(String output) {
+    appendOutputText(output);
   }
 
   /**