replaced a lot of deprecated code; if someone runs into a commit conflict afterwards...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / PHPUnitEditor.java
index 9c99864..aacb78d 100644 (file)
@@ -90,11 +90,11 @@ import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IFileEditorInput;
 import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.actions.ActionContext;
 import org.eclipse.ui.actions.ActionGroup;
 import org.eclipse.ui.dialogs.SaveAsDialog;
 import org.eclipse.ui.editors.text.IStorageDocumentProvider;
-import org.eclipse.ui.help.WorkbenchHelp;
 import org.eclipse.ui.part.FileEditorInput;
 import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
 import org.eclipse.ui.texteditor.ContentAssistAction;
@@ -107,8 +107,8 @@ import org.eclipse.ui.texteditor.TextOperationAction;
  * 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 
+ *
+ * Contributors: IBM Corporation - Initial implementation
  * www.phpeclipse.de
  ******************************************************************************/
 /**
@@ -377,23 +377,27 @@ public class PHPUnitEditor extends PHPEditor { //implements
     }
 
     /*
-     * @see IWidgetTokenOwner#requestWidgetToken(IWidgetTokenKeeper)
-     */
-    public boolean requestWidgetToken(IWidgetTokenKeeper requester) {
-      if (WorkbenchHelp.isContextHelpDisplayed())
-        return false;
-      return super.requestWidgetToken(requester);
-    }
+        * @see IWidgetTokenOwner#requestWidgetToken(IWidgetTokenKeeper)
+        */
+               public boolean requestWidgetToken(IWidgetTokenKeeper requester) {
+                       if (PlatformUI.getWorkbench().getHelpSystem()
+                                       .isContextHelpDisplayed())
+                               return false;
+                       return super.requestWidgetToken(requester);
+               }
 
     /*
-     * @see IWidgetTokenOwnerExtension#requestWidgetToken(IWidgetTokenKeeper, int)
-     * @since 3.0
-     */
-    public boolean requestWidgetToken(IWidgetTokenKeeper requester, int priority) {
-      if (WorkbenchHelp.isContextHelpDisplayed())
-        return false;
-      return super.requestWidgetToken(requester, priority);
-    }
+        * @see IWidgetTokenOwnerExtension#requestWidgetToken(IWidgetTokenKeeper,
+        *      int)
+        * @since 3.0
+        */
+               public boolean requestWidgetToken(IWidgetTokenKeeper requester,
+                               int priority) {
+                       if (PlatformUI.getWorkbench().getHelpSystem()
+                                       .isContextHelpDisplayed())
+                               return false;
+                       return super.requestWidgetToken(requester, priority);
+               }
 
     /*
      * @see org.eclipse.jface.text.source.ISourceViewer#configure(org.eclipse.jface.text.source.SourceViewerConfiguration)
@@ -406,6 +410,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
       prependAutoEditStrategy(smartSemi, IDocument.DEFAULT_CONTENT_TYPE);
       prependAutoEditStrategy(smartSemi, IPHPPartitions.PHP_STRING_DQ);
       prependAutoEditStrategy(smartSemi, IPHPPartitions.PHP_STRING_SQ);
+      prependAutoEditStrategy(smartSemi, IPHPPartitions.PHP_STRING_HEREDOC);
     }
 
     /*
@@ -432,7 +437,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
 
   /**
    * Remembers data related to the current selection to be able to restore it later.
-   * 
+   *
    * @since 3.0
    */
   private class RememberedSelection {
@@ -542,7 +547,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
 
   /**
    * Remembers additional data for a given offset to be able restore it later.
-   * 
+   *
    * @since 3.0
    */
   private class RememberedOffset {
@@ -560,7 +565,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
 
     /**
      * Store visual properties of the given offset.
-     * 
+     *
      * @param offset
      *          Offset in the document
      */
@@ -592,7 +597,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
 
     /**
      * Return offset recomputed from stored visual properties.
-     * 
+     *
      * @return Offset in the document
      */
     public int getOffset() {
@@ -608,7 +613,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
 
     /**
      * Return offset recomputed from stored visual properties.
-     * 
+     *
      * @param newElement
      *          Enclosing element
      * @return Offset in the document
@@ -657,7 +662,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
 
     /**
      * Returns the offset used to reveal the given element based on the given selection offset.
-     * 
+     *
      * @param element
      *          the element
      * @param offset
@@ -683,7 +688,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
 
     /**
      * Return Java element recomputed from stored visual properties.
-     * 
+     *
      * @return Java element
      */
     public IJavaElement getElement() {
@@ -705,7 +710,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
 
     /**
      * Does the given Java element contain the given offset?
-     * 
+     *
      * @param element
      *          Java element
      * @param offset
@@ -721,7 +726,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
 
     /**
      * Returns the offset of the given Java element.
-     * 
+     *
      * @param element
      *          Java element
      * @return Offset of the given Java element
@@ -741,7 +746,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
 
     /**
      * Returns the length of the given Java element.
-     * 
+     *
      * @param element
      *          Java element
      * @return Length of the given Java element
@@ -761,7 +766,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
 
     /**
      * Returns the updated java element for the old java element.
-     * 
+     *
      * @param element
      *          Old Java element
      * @return Updated Java element
@@ -1186,7 +1191,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
 
   /**
    * The remembered selection.
-   * 
+   *
    * @since 3.0
    */
   private RememberedSelection fRememberedSelection = new RememberedSelection();
@@ -1383,7 +1388,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
 
   /**
    * Reconciling listeners.
-   * 
+   *
    * @since 3.0
    */
   private ListenerList fReconcilingListeners = new ListenerList();
@@ -1472,7 +1477,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
     action.setActionDefinitionId(PHPEditorActionDefinitionIds.FORMAT);
     setAction("Format", action); //$NON-NLS-1$
     markAsStateDependentAction("Format", true); //$NON-NLS-1$
-    markAsSelectionDependentAction("Format", true); //$NON-NLS-1$              
+    markAsSelectionDependentAction("Format", true); //$NON-NLS-1$
     //         WorkbenchHelp.setHelp(action, IJavaHelpContextIds.FORMAT_ACTION);
 
     //    action = new AddBlockCommentAction(PHPEditorMessages.getResourceBundle(),
@@ -1500,26 +1505,26 @@ public class PHPUnitEditor extends PHPEditor { //implements
     //         markAsStateDependentAction("Indent", true); //$NON-NLS-1$
     //         markAsSelectionDependentAction("Indent", true); //$NON-NLS-1$
     //// WorkbenchHelp.setHelp(action, IJavaHelpContextIds.INDENT_ACTION);
-    //         
+    //
     //         action= new IndentAction(PHPEditorMessages.getResourceBundle(),
     // "Indent.", this, true); //$NON-NLS-1$
     //         setAction("IndentOnTab", action); //$NON-NLS-1$
     //         markAsStateDependentAction("IndentOnTab", true); //$NON-NLS-1$
     //         markAsSelectionDependentAction("IndentOnTab", true); //$NON-NLS-1$
-    //         
+    //
 
     action = new AddBlockCommentAction(PHPEditorMessages.getResourceBundle(), "AddBlockComment.", this); //$NON-NLS-1$
     action.setActionDefinitionId(PHPEditorActionDefinitionIds.ADD_BLOCK_COMMENT);
     setAction("AddBlockComment", action); //$NON-NLS-1$
     markAsStateDependentAction("AddBlockComment", true); //$NON-NLS-1$
-    markAsSelectionDependentAction("AddBlockComment", true); //$NON-NLS-1$             
+    markAsSelectionDependentAction("AddBlockComment", true); //$NON-NLS-1$
     // WorkbenchHelp.setHelp(action, IJavaHelpContextIds.ADD_BLOCK_COMMENT_ACTION);
 
     action = new RemoveBlockCommentAction(PHPEditorMessages.getResourceBundle(), "RemoveBlockComment.", this); //$NON-NLS-1$
     action.setActionDefinitionId(PHPEditorActionDefinitionIds.REMOVE_BLOCK_COMMENT);
     setAction("RemoveBlockComment", action); //$NON-NLS-1$
     markAsStateDependentAction("RemoveBlockComment", true); //$NON-NLS-1$
-    markAsSelectionDependentAction("RemoveBlockComment", true); //$NON-NLS-1$          
+    markAsSelectionDependentAction("RemoveBlockComment", true); //$NON-NLS-1$
     // WorkbenchHelp.setHelp(action, IJavaHelpContextIds.REMOVE_BLOCK_COMMENT_ACTION);
 
     // action= new IndentAction(PHPEditorMessages.getResourceBundle(), "Indent.", this, false); //$NON-NLS-1$
@@ -1528,7 +1533,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
     // markAsStateDependentAction("Indent", true); //$NON-NLS-1$
     // markAsSelectionDependentAction("Indent", true); //$NON-NLS-1$
     //// WorkbenchHelp.setHelp(action, IJavaHelpContextIds.INDENT_ACTION);
-    // 
+    //
     action = new IndentAction(PHPEditorMessages.getResourceBundle(), "Indent.", this, true); //$NON-NLS-1$
     setAction("IndentOnTab", action); //$NON-NLS-1$
     markAsStateDependentAction("IndentOnTab", true); //$NON-NLS-1$
@@ -1565,7 +1570,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
    * Returns the most narrow element including the given offset. If <code>reconcile</code> is <code>true</code> the editor's
    * input element is reconciled in advance. If it is <code>false</code> this method only returns a result if the editor's input
    * element does not need to be reconciled.
-   * 
+   *
    * @param offset
    *          the offset included by the retrieved element
    * @param reconcile
@@ -1947,7 +1952,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
   /**
    * Handles a property change event describing a change of the php core's preferences and updates the preference related editor
    * properties.
-   * 
+   *
    * @param event
    *          the property change event
    */
@@ -2075,7 +2080,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
       if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_P_RTRIM_ON_SAVE)) {
         RTrimAction trimAction = new RTrimAction();
         trimAction.setActiveEditor(null, getSite().getPage().getActiveEditor());
-        trimAction.run(null);  
+        trimAction.run(null);
       }
 
       setStatusLineErrorMessage(null);
@@ -2102,7 +2107,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
   /**
    * The compilation unit editor implementation of this <code>AbstractTextEditor</code> method asks the user for the workspace
    * path of a file resource and saves the document there. See http://dev.eclipse.org/bugs/show_bug.cgi?id=6295
-   * 
+   *
    * @param progressMonitor
    *          the progress monitor
    */
@@ -2197,13 +2202,13 @@ public class PHPUnitEditor extends PHPEditor { //implements
   //                   IJavaElement inputElement= getInputJavaElement();
   //                   if (model == null || inputElement == null)
   //                           return;
-  //                   
+  //
   //                   fOverrideIndicatorManager= new OverrideIndicatorManager(model,
   // inputElement, null);
   //                   addReconcileListener(fOverrideIndicatorManager);
   //           }
   //   }
-  //   
+  //
   //   /*
   //    * @see
   // net.sourceforge.phpdt.internal.ui.javaeditor.JavaEditor#uninstallOverrideIndicator()
@@ -2217,7 +2222,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
 
   /**
    * Configures the toggle comment action
-   * 
+   *
    * @since 3.0
    */
   private void configureToggleCommentAction() {
@@ -2314,7 +2319,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
 
   /**
    * Asks the user if it is ok to store in non-workbench encoding.
-   * 
+   *
    * @return <true>if the user wants to continue
    */
   private boolean askIfNonWorkbenchEncodingIsOk() {
@@ -2446,7 +2451,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
   //  }
   /**
    * Tells whether this is the active editor in the active page.
-   * 
+   *
    * @return <code>true</code> if this is the active editor in the active page
    * @see IWorkbenchPage#getActiveEditor();
    */
@@ -2461,7 +2466,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
 
   /**
    * Adds the given listener. Has no effect if an identical listener was not already registered.
-   * 
+   *
    * @param listener
    *          The reconcile listener to be added
    * @since 3.0
@@ -2474,7 +2479,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
 
   /**
    * Removes the given listener. Has no effect if an identical listener was not already registered.
-   * 
+   *
    * @param listener
    *          the reconcile listener to be removed
    * @since 3.0
@@ -2557,7 +2562,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
    * <p>
    * TODO remove once the underlying problem is solved.
    * </p>
-   * 
+   *
    * @return the lock reconcilers may use to synchronize on
    */
   public Object getReconcilerLock() {
@@ -2566,7 +2571,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
 
   /*
    * (non-Javadoc)
-   * 
+   *
    * @see org.eclipse.ui.texteditor.AbstractTextEditor#editorSaved()
    */
   protected void editorSaved() {