Added a souce context menu to the editor; moved "Goto Matching Bracket" to "Navigate...
authorkhartlage <khartlage>
Fri, 1 Aug 2003 20:32:30 +0000 (20:32 +0000)
committerkhartlage <khartlage>
Fri, 1 Aug 2003 20:32:30 +0000 (20:32 +0000)
net.sourceforge.phpeclipse/plugin.xml
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/actions/GenerateActionGroup.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/actions/PHPdtActionConstants.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionContributor.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditorMessages.properties
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPUnitEditor.java

index 43a68cd..7148ea9 100644 (file)
@@ -176,6 +176,81 @@ Temporarily replaced until errors can be ironed out...
       </view>
    </extension> -->
    <extension
+         point="org.eclipse.ui.editors">
+      <editor
+            name="%phpEditorName"
+            default="true"
+            icon="icons/obj16/phpedit.gif"
+            extensions="php"
+            contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
+            class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
+            id="net.sourceforge.phpeclipse.PHPUnitEditor">
+      </editor>
+      <editor
+            name="%phpEditorName"
+            default="true"
+            icon="icons/obj16/phpedit.gif"
+            extensions="php3"
+            contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
+            class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
+            id="net.sourceforge.phpeclipse.PHPUnitEditor">
+      </editor>
+      <editor
+            name="%phpEditorName"
+            default="true"
+            icon="icons/obj16/phpedit.gif"
+            extensions="php4"
+            contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
+            class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
+            id="net.sourceforge.phpeclipse.PHPUnitEditor">
+      </editor>
+      <editor
+            name="%phpEditorName"
+            default="true"
+            icon="icons/obj16/phpedit.gif"
+            extensions="inc"
+            contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
+            class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
+            id="net.sourceforge.phpeclipse.PHPUnitEditor">
+      </editor>
+      <editor
+            name="%phpEditorName"
+            default="true"
+            icon="icons/obj16/phpedit.gif"
+            extensions="phtml"
+            contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
+            class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
+            id="net.sourceforge.phpeclipse.PHPUnitEditor">
+      </editor>
+      <editor
+            name="%phpEditorName"
+            default="true"
+            icon="icons/obj16/htmledit.gif"
+            extensions="htm"
+            contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
+            class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
+            id="net.sourceforge.phpeclipse.PHPUnitEditor">
+      </editor>
+      <editor
+            name="%phpEditorName"
+            default="true"
+            icon="icons/obj16/htmledit.gif"
+            extensions="html"
+            contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
+            class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
+            id="net.sourceforge.phpeclipse.PHPUnitEditor">
+      </editor>
+      <editor
+            name="%phpEditorName"
+            default="true"
+            icon="icons/obj16/xmledit.gif"
+            extensions="xml"
+            contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
+            class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
+            id="net.sourceforge.phpeclipse.PHPUnitEditor">
+      </editor>
+   </extension>
+   <extension
          point="org.eclipse.ui.actionSets">
       <actionSet
             label="PHP/Apache"
@@ -236,9 +311,7 @@ Temporarily replaced until errors can be ironed out...
                label="%SourceMenu.label"
                path="edit"
                id="net.sourceforge.phpeclipse.ui.source.menu">
-            <separator
-                  name="editGroup">
-            </separator>
+               <separator name="editGroup" />
          </menu>
          <action
                definitionId="net.sourceforge.phpeclipse.phpeditor.format"
@@ -251,13 +324,13 @@ Temporarily replaced until errors can be ironed out...
                label="%ShiftLeftAction.label"
                retarget="true"
                menubarPath="net.sourceforge.phpeclipse.ui.source.menu/editGroup"
-               id="net.sourceforge.phpeclipse.ui.actions.ShiftLeft">
+               id="net.sourceforge.phpeclipse.phpeditor.ShiftLeft">
          </action>
          <action
                label="%ShiftRightAction.label"
                retarget="true"
                menubarPath="net.sourceforge.phpeclipse.ui.source.menu/editGroup"
-               id="net.sourceforge.phpeclipse.ui.actions.ShiftRight">
+               id="net.sourceforge.phpeclipse.phpeditor.ShiftRight">
          </action>
          <action
                definitionId="net.sourceforge.phpeclipse.phpeditor.uncomment"
@@ -279,9 +352,7 @@ Temporarily replaced until errors can be ironed out...
          point="org.eclipse.ui.actionSetPartAssociations">
       <actionSetPartAssociation
             targetID="net.sourceforge.phpeclipse.ui.CodingActionSet">
-         <part
-               id="net.sourceforge.phpeclipse.PHPUnitEditor">
-         </part>
+         <part id="net.sourceforge.phpeclipse.PHPUnitEditor" />
       </actionSetPartAssociation>
    </extension>
 <!-- =========================================================================== -->
@@ -331,81 +402,7 @@ Temporarily replaced until errors can be ironed out...
          </accelerator>
       </acceleratorSet>
    </extension> -->
-   <extension
-         point="org.eclipse.ui.editors">
-      <editor
-            name="%phpEditorName"
-            default="true"
-            icon="icons/obj16/phpedit.gif"
-            extensions="php"
-            contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
-            class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
-            id="net.sourceforge.phpeclipse.PHPUnitEditor">
-      </editor>
-      <editor
-            name="%phpEditorName"
-            default="true"
-            icon="icons/obj16/phpedit.gif"
-            extensions="php3"
-            contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
-            class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
-            id="net.sourceforge.phpeclipse.PHPUnitEditor">
-      </editor>
-      <editor
-            name="%phpEditorName"
-            default="true"
-            icon="icons/obj16/phpedit.gif"
-            extensions="php4"
-            contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
-            class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
-            id="net.sourceforge.phpeclipse.PHPUnitEditor">
-      </editor>
-      <editor
-            name="%phpEditorName"
-            default="true"
-            icon="icons/obj16/phpedit.gif"
-            extensions="inc"
-            contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
-            class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
-            id="net.sourceforge.phpeclipse.PHPUnitEditor">
-      </editor>
-      <editor
-            name="%phpEditorName"
-            default="true"
-            icon="icons/obj16/phpedit.gif"
-            extensions="phtml"
-            contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
-            class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
-            id="net.sourceforge.phpeclipse.PHPUnitEditor">
-      </editor>
-      <editor
-            name="%phpEditorName"
-            default="true"
-            icon="icons/obj16/htmledit.gif"
-            extensions="htm"
-            contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
-            class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
-            id="net.sourceforge.phpeclipse.PHPUnitEditor">
-      </editor>
-      <editor
-            name="%phpEditorName"
-            default="true"
-            icon="icons/obj16/htmledit.gif"
-            extensions="html"
-            contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
-            class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
-            id="net.sourceforge.phpeclipse.PHPUnitEditor">
-      </editor>
-      <editor
-            name="%phpEditorName"
-            default="true"
-            icon="icons/obj16/xmledit.gif"
-            extensions="xml"
-            contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
-            class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
-            id="net.sourceforge.phpeclipse.PHPUnitEditor">
-      </editor>
-   </extension>
+   
    <extension
          point="org.eclipse.ui.popupMenus">
       <objectContribution
@@ -717,8 +714,112 @@ Temporarily replaced until errors can be ironed out...
             id="net.sourceforge.phpeclipse.views.phpconsoleview">
       </view>
    </extension>
+
 <!-- =========================================================================== -->
-<!-- Java Editor Key Bindings -->
+<!-- PHPDT/UI command definitions                                                   -->
+<!-- =========================================================================== -->
+<!--
+<extension point="org.eclipse.ui.commands">
+       <category
+               name="%category.source.name"
+               description="%category.source.description"
+               id="net.sourceforge.phpeclipse.ui.category.source">
+       </category>
+
+      
+       <scope
+               name="%scope.javaEditor.name"
+               parent="org.eclipse.ui.textEditorScope"
+               description="%scope.javaEditor.description"
+               id="net.sourceforge.phpeclipse.ui.textEditorScope">
+       </scope>
+     
+          
+       <command
+               category="org.eclipse.ui.category.edit"
+               id="org.eclipse.jdt.ui.edit.text.java.correction.assist.proposals"
+               name= "%ActionDefinition.correctionAssistProposals.name"
+               description="%ActionDefinition.correctionAssistProposals.description">
+       </command>
+       <keyBinding
+               string="Ctrl+1"
+               scope="net.sourceforge.phpeclipse.ui.textEditorScope"
+               command="org.eclipse.jdt.ui.edit.text.java.correction.assist.proposals"
+               configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+       </keyBinding>      
+       <keyBinding
+               platform="carbon"
+               string="Command+1"
+               scope="net.sourceforge.phpeclipse.ui.textEditorScope"
+               command="org.eclipse.jdt.ui.edit.text.java.correction.assist.proposals"
+               configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+       </keyBinding>      
+                 
+      
+       <command
+               category="net.sourceforge.phpeclipse.ui.category.source"
+               id="net.sourceforge.phpeclipse.phpeditor.comment"
+               name= "%ActionDefinition.comment.name"
+               description= "%ActionDefinition.comment.description">
+       </command>
+       <keyBinding
+               string="Ctrl+/"
+               scope="net.sourceforge.phpeclipse.ui.textEditorScope"
+               command="net.sourceforge.phpeclipse.phpeditor.comment"
+               configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+       </keyBinding>
+       <keyBinding
+               platform="carbon"
+               string="Command+/"
+               scope="net.sourceforge.phpeclipse.ui.textEditorScope"
+               command="net.sourceforge.phpeclipse.phpeditor.comment"
+               configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+       </keyBinding>
+
+       <command
+               category="net.sourceforge.phpeclipse.ui.category.source"
+               id="net.sourceforge.phpeclipse.phpeditor.uncomment"
+               name= "%ActionDefinition.uncomment.name"
+               description= "%ActionDefinition.uncomment.description">
+       </command>
+       <keyBinding
+               string="Ctrl+\"
+               scope="net.sourceforge.phpeclipse.ui.textEditorScope"
+               command="net.sourceforge.phpeclipse.phpeditor.uncomment"
+               configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+       </keyBinding>
+       <keyBinding
+               platform="carbon"
+               string="Command+\"
+               scope="net.sourceforge.phpeclipse.ui.textEditorScope"
+               command="net.sourceforge.phpeclipse.phpeditor.uncomment"
+               configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+       </keyBinding>
+
+       <command
+               category="net.sourceforge.phpeclipse.ui.category.source"
+               id="org.eclipse.jdt.ui.edit.text.java.format"
+               name= "%ActionDefinition.format.name"
+               description= "%ActionDefinition.format.description">
+       </command>
+       <keyBinding
+               string="Ctrl+Shift+F"
+               scope="net.sourceforge.phpeclipse.ui.textEditorScope"
+               command="org.eclipse.jdt.ui.edit.text.java.format"
+               configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+       </keyBinding>
+       <keyBinding
+               platform="carbon"
+               string="Command+Shift+F"
+               scope="net.sourceforge.phpeclipse.ui.textEditorScope"
+               command="org.eclipse.jdt.ui.edit.text.java.format"
+               configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+       </keyBinding>
+
+</extension>
+-->
+<!-- =========================================================================== -->
+<!-- PHP Editor Key Bindings -->
 <!-- =========================================================================== -->
    <extension
          point="org.eclipse.ui.acceleratorSets">
@@ -742,7 +843,7 @@ Temporarily replaced until errors can be ironed out...
          <accelerator
                key="Ctrl+\"
                id="net.sourceforge.phpeclipse.phpeditor.uncomment">
-         </accelerator>
+         </accelerator> 
          <accelerator
                key="Ctrl+Shift+F"
                id="net.sourceforge.phpeclipse.phpeditor.format">
@@ -814,7 +915,7 @@ Temporarily replaced until errors can be ironed out...
                platform="carbon"
                key="Command+\"
                id="net.sourceforge.phpeclipse.phpeditor.uncomment">
-         </accelerator>
+         </accelerator> 
       </acceleratorSet>
    </extension>
 
index 0607a3e..36797b8 100644 (file)
@@ -14,15 +14,14 @@ import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
+import net.sourceforge.phpdt.internal.ui.actions.ActionMessages;
 import net.sourceforge.phpdt.internal.ui.actions.AddTaskAction;
 import net.sourceforge.phpdt.ui.IContextMenuConstants;
 import net.sourceforge.phpeclipse.phpeditor.PHPEditor;
 
-import org.eclipse.debug.internal.ui.actions.ActionMessages;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.action.IMenuManager;
 import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
 import org.eclipse.jface.util.Assert;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -52,7 +51,7 @@ import org.eclipse.ui.texteditor.IUpdate;
 public class GenerateActionGroup extends ActionGroup {
        
   private PHPEditor fEditor;
-       private boolean fEditorIsOwner;
+//     private boolean fEditorIsOwner;
        private IWorkbenchSite fSite;
        private String fGroupName= IContextMenuConstants.GROUP_SOURCE;
        private List fRegisteredSelectionListeners;
@@ -79,9 +78,9 @@ public class GenerateActionGroup extends ActionGroup {
         */
        public GenerateActionGroup(PHPEditor editor, String groupName) {
                fSite= editor.getSite();
-    fEditor= editor;
-               fEditorIsOwner= true;
+               fEditor= editor;
                fGroupName= groupName;
+                               
                ISelectionProvider provider= fSite.getSelectionProvider();
                ISelection selection= provider.getSelection();
 
@@ -216,7 +215,7 @@ public class GenerateActionGroup extends ActionGroup {
         * Note: This method is for internal use only. Clients should not call this method.
         */
        public void editorStateChanged() {
-               Assert.isTrue(fEditorIsOwner);
+               Assert.isTrue(isEditorOwner());
                
                // http://dev.eclipse.org/bugs/show_bug.cgi?id=17709
                fConvertToMac.update();
@@ -235,20 +234,34 @@ public class GenerateActionGroup extends ActionGroup {
        /* (non-Javadoc)
         * Method declared in ActionGroup
         */
+//     public void fillContextMenu(IMenuManager menu) {
+//             super.fillContextMenu(menu);
+//             if (fEditorIsOwner) {
+//                     IMenuManager subMenu= createEditorSubMenu(menu);
+//                     if (subMenu != null)
+//                             menu.appendToGroup(fGroupName, subMenu);
+//             } else {
+////                   appendToGroup(menu, fOrganizeImports);
+////                   appendToGroup(menu, fOverrideMethods);
+////                   appendToGroup(menu, fAddGetterSetter);
+////                   appendToGroup(menu, fAddUnimplementedConstructors);
+////                   appendToGroup(menu, fAddJavaDocStub);
+//                     appendToGroup(menu, fAddBookmark);
+//             }
+//     }
+       /* (non-Javadoc)
+        * Method declared in ActionGroup
+        */
        public void fillContextMenu(IMenuManager menu) {
                super.fillContextMenu(menu);
-               if (fEditorIsOwner) {
-                       IMenuManager subMenu= createEditorSubMenu(menu);
-                       if (subMenu != null)
-                               menu.appendToGroup(fGroupName, subMenu);
+               IMenuManager subMenu= null;
+               if (isEditorOwner()) {
+                       subMenu= createEditorSubMenu(menu);
                } else {
-//                     appendToGroup(menu, fOrganizeImports);
-//                     appendToGroup(menu, fOverrideMethods);
-//                     appendToGroup(menu, fAddGetterSetter);
-//                     appendToGroup(menu, fAddUnimplementedConstructors);
-//                     appendToGroup(menu, fAddJavaDocStub);
-                       appendToGroup(menu, fAddBookmark);
+       //              subMenu= createViewSubMenu(menu);
                }
+               if (subMenu != null)
+                       menu.appendToGroup(fGroupName, subMenu);
        }
        
   private IMenuManager createEditorSubMenu(IMenuManager mainMenu) {
@@ -256,15 +269,16 @@ public class GenerateActionGroup extends ActionGroup {
     int added= 0;
     added+= addEditorAction(result, "Comment"); //$NON-NLS-1$
     added+= addEditorAction(result, "Uncomment"); //$NON-NLS-1$
+               added+= addEditorAction(result, "Format"); //$NON-NLS-1$
 //    result.add(new Separator());
 //    added+= addAction(result, fOrganizeImports);
 //    added+= addAction(result, fAddImport);
-    result.add(new Separator());
+//    result.add(new Separator());
 //    added+= addAction(result, fOverrideMethods);
 //    added+= addAction(result, fAddGetterSetter);
 //    added+= addAction(result, fAddUnimplementedConstructors);
 //    added+= addAction(result, fAddJavaDocStub);
-    added+= addAction(result, fAddBookmark);
+//    added+= addAction(result, fAddBookmark);
 //    result.add(new Separator());             
 //    added+= addAction(result, fSurroundWithTryCatch);
 //    added+= addAction(result, fExternalizeStrings);
@@ -300,7 +314,7 @@ public class GenerateActionGroup extends ActionGroup {
                actionBar.setGlobalActionHandler(PHPdtActionConstants.CONVERT_LINE_DELIMITERS_TO_WINDOWS, fConvertToWindows);
                actionBar.setGlobalActionHandler(PHPdtActionConstants.CONVERT_LINE_DELIMITERS_TO_UNIX, fConvertToUNIX);
                actionBar.setGlobalActionHandler(PHPdtActionConstants.CONVERT_LINE_DELIMITERS_TO_MAC, fConvertToMac);
-               if (!fEditorIsOwner) {
+               if (!isEditorOwner()) {
                        // editor provides its own implementation of these actions.
                        actionBar.setGlobalActionHandler(IWorkbenchActionConstants.BOOKMARK, fAddBookmark);
                        actionBar.setGlobalActionHandler(IWorkbenchActionConstants.ADD_TASK, fAddTaskAction);
index 0b9bf6b..350dfef 100644 (file)
@@ -43,35 +43,46 @@ public class PHPdtActionConstants {
    * (value <code>"net.sourceforge.phpdt.ui.actions.Uncomment"</code>).
    */
   public static final String UNCOMMENT = "net.sourceforge.phpeclipse.phpeditor.Uncomment"; //$NON-NLS-1$
+  /**
+        * Source menu: name of standard Shift Rightl action
+        * (value <code>"net.sourceforge.phpeclipse.phpeditor.ShiftRight"</code>).
+        */
+  public static final String SHIFT_RIGHT = "net.sourceforge.phpeclipse.phpeditor.ShiftRight"; //$NON-NLS-1$
+
+  /**
+   * Source menu: name of standard Shift Left global action
+   * (value <code>"net.sourceforge.phpeclipse.phpeditor.ShiftLeft"</code>).
+   */
+  public static final String SHIFT_LEFT = "net.sourceforge.phpeclipse.phpeditor.ShiftLeft"; //$NON-NLS-1$
 
   /**
    * Source menu: name of standard Format global action (value <code>"org.
    * phpeclipse.phpdt.ui.actions.Format"</code>).
    */
   public static final String FORMAT = "net.sourceforge.phpeclipse.phpeditor.Format"; //$NON-NLS-1$
-  
+
   /**
    * Source menu: name of standard Convert Line Delimiters To Windows global action
    * (value <code>"org.phpeclipse.phpdt.ui.actions.ConvertLineDelimitersToWindows"</code>).
    */
-  public static String CONVERT_LINE_DELIMITERS_TO_WINDOWS= "net.sourceforge.phpeclipse.ui.actions.ConvertLineDelimitersToWindows"; //$NON-NLS-1$
+  public static String CONVERT_LINE_DELIMITERS_TO_WINDOWS = "net.sourceforge.phpeclipse.ui.actions.ConvertLineDelimitersToWindows"; //$NON-NLS-1$
 
   /**
    * Source menu: name of standard Convert Line Delimiters To UNIX global action
    * (value <code>"org.phpeclipse.phpdt.ui.actions.ConvertLineDelimitersToUNIX"</code>).
    */
-  public static String CONVERT_LINE_DELIMITERS_TO_UNIX= "net.sourceforge.phpeclipse.ui.actions.ConvertLineDelimitersToUNIX"; //$NON-NLS-1$
+  public static String CONVERT_LINE_DELIMITERS_TO_UNIX = "net.sourceforge.phpeclipse.ui.actions.ConvertLineDelimitersToUNIX"; //$NON-NLS-1$
 
   /**
    * Source menu: name of standardConvert Line Delimiters ToMac global action
    * (value <code>"org.phpeclipse.phpdt.ui.actions.ConvertLineDelimitersToMac"</code>).
    */
-  public static String CONVERT_LINE_DELIMITERS_TO_MAC= "net.sourceforge.phpeclipse.ui.actions.ConvertLineDelimitersToMac"; //$NON-NLS-1$
+  public static String CONVERT_LINE_DELIMITERS_TO_MAC = "net.sourceforge.phpeclipse.ui.actions.ConvertLineDelimitersToMac"; //$NON-NLS-1$
 
   /**
    * Navigate menu: name of standard Open global action
    * (value <code>"org.phpeclipse.phpdt.ui.actions.Open"</code>).
    */
-  public static final String OPEN= "net.sourceforge.phpeclipse.ui.actions.Open"; //$NON-NLS-1$
+  public static final String OPEN = "net.sourceforge.phpeclipse.ui.actions.Open"; //$NON-NLS-1$
 
 }
index 66656e2..10e9170 100644 (file)
@@ -17,6 +17,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.ResourceBundle;
 
+import net.sourceforge.phpdt.ui.IContextMenuConstants;
 import net.sourceforge.phpdt.ui.actions.GotoMatchingBracketAction;
 import net.sourceforge.phpdt.ui.actions.PHPdtActionConstants;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
@@ -24,6 +25,7 @@ import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IStatusLineManager;
 import org.eclipse.jface.action.IToolBarManager;
 import org.eclipse.jface.action.Separator;
 import org.eclipse.jface.preference.IPreferenceStore;
@@ -33,7 +35,7 @@ import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IFileEditorInput;
 import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.actions.RetargetAction;
 import org.eclipse.ui.texteditor.AbstractTextEditor;
 import org.eclipse.ui.texteditor.BasicTextEditorActionContributor;
@@ -45,13 +47,14 @@ import org.eclipse.ui.texteditor.RetargetTextEditorAction;
  */
 public class PHPActionContributor extends BasicTextEditorActionContributor {
 
-  // protected RetargetTextEditorAction fContentAssistTip;
+  protected RetargetTextEditorAction fContentAssistTip;
   // protected TextEditorAction fTogglePresentation;
   protected RetargetAction fRetargetContentAssist;
 
   protected RetargetTextEditorAction fContentAssist;
   private RetargetTextEditorAction fGotoMatchingBracket;
   private List fRetargetToolbarActions = new ArrayList();
+  private List fPartListeners = new ArrayList();
 
   protected PHPParserAction fParserAction;
   protected ShowExternalPreviewAction fShowExternalPreviewAction;
@@ -65,28 +68,37 @@ public class PHPActionContributor extends BasicTextEditorActionContributor {
     ResourceBundle b = PHPEditorMessages.getResourceBundle();
 
     fRetargetContentAssist = new RetargetAction(PHPdtActionConstants.CONTENT_ASSIST, PHPEditorMessages.getString("ContentAssistProposal.label")); //$NON-NLS-1$
-    fRetargetContentAssist.setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
+    fRetargetContentAssist.setActionDefinitionId(
+      PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
+    markAsPartListener(fRetargetContentAssist);
 
     fContentAssist = new RetargetTextEditorAction(b, "ContentAssistProposal."); //$NON-NLS-1$
-    fContentAssist.setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
+    fContentAssist.setActionDefinitionId(
+      PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
 
     fGotoMatchingBracket = new RetargetTextEditorAction(b, "GotoMatchingBracket."); //$NON-NLS-1$
-    fGotoMatchingBracket.setActionDefinitionId(PHPEditorActionDefinitionIds.GOTO_MATCHING_BRACKET);
+    fGotoMatchingBracket.setActionDefinitionId(
+      PHPEditorActionDefinitionIds.GOTO_MATCHING_BRACKET);
 
     // fContentAssist.setImageDescriptor(JavaPluginImages.DESC_CLCL_CODE_ASSIST);
     // fContentAssist.setDisabledImageDescriptor(JavaPluginImages.DESC_DLCL_CODE_ASSIST);
 
     // fContentAssist = new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistProposal."); //$NON-NLS-1$
-    //  fContentAssistTip = new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistTip."); //$NON-NLS-1$
+    fContentAssistTip = new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistTip."); //$NON-NLS-1$
     //  fTogglePresentation = new PresentationAction();
 
     fParserAction = PHPParserAction.getInstance();
 
     if (SWT.getPlatform().equals("win32")) {
+      // ExternalPreview only available as ActiveX on win32 (Eclipse2.1)
       fShowExternalPreviewAction = ShowExternalPreviewAction.getInstance();
     }
   }
 
+  protected final void markAsPartListener(RetargetAction action) {
+    fPartListeners.add(action);
+  }
+
   /*
    * @see EditorActionBarContributor#contributeToMenu(IMenuManager)
    */
@@ -124,6 +136,47 @@ public class PHPActionContributor extends BasicTextEditorActionContributor {
   //  }
 
   /*
+        * @see org.eclipse.ui.part.EditorActionBarContributor#contributeToMenu(org.eclipse.jface.action.IMenuManager)
+        */
+  public void contributeToMenu(IMenuManager menu) {
+
+    super.contributeToMenu(menu);
+
+    IMenuManager editMenu =
+      menu.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
+    if (editMenu != null) {
+      editMenu.add(new Separator(IContextMenuConstants.GROUP_OPEN));
+      editMenu.add(new Separator(IContextMenuConstants.GROUP_GENERATE));
+      editMenu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
+
+//      editMenu.appendToGroup(
+//        IContextMenuConstants.GROUP_GENERATE,
+//        fRetargetContentAssist);
+
+      //                               MenuManager structureSelection= new MenuManager(JavaEditorMessages.getString("ExpandSelectionMenu.label"), "expandSelection"); //$NON-NLS-1$ //$NON-NLS-2$ 
+      //                               structureSelection.add(fStructureSelectEnclosingAction);
+      //                               structureSelection.add(fStructureSelectNextAction);
+      //                               structureSelection.add(fStructureSelectPreviousAction);
+      //                               structureSelection.add(fStructureSelectHistoryAction);
+      //                               editMenu.appendToGroup(IContextMenuConstants.GROUP_OPEN, structureSelection);
+
+      //                               editMenu.appendToGroup(IContextMenuConstants.GROUP_GENERATE, fRetargetShowJavaDoc);
+    }
+
+    //                 IMenuManager navigateMenu= menu.findMenuUsingPath(IWorkbenchActionConstants.M_NAVIGATE);
+    //                 if (navigateMenu != null) {
+    //                         navigateMenu.appendToGroup(IWorkbenchActionConstants.SHOW_EXT, fShowOutline);
+    //                 }
+
+    IMenuManager gotoMenu = menu.findMenuUsingPath("navigate/goTo"); //$NON-NLS-1$
+    if (gotoMenu != null) {
+      gotoMenu.add(new Separator("additions2")); //$NON-NLS-1$
+      //                               gotoMenu.appendToGroup("additions2", fGotoPreviousMemberAction); //$NON-NLS-1$
+      //                               gotoMenu.appendToGroup("additions2", fGotoNextMemberAction); //$NON-NLS-1$
+      gotoMenu.appendToGroup("additions2", fGotoMatchingBracket); //$NON-NLS-1$
+    }
+  }
+  /*
    * @see EditorActionBarContributor#contributeToToolBar(IToolBarManager)
    */
   public void contributeToToolBar(IToolBarManager tbm) {
@@ -134,22 +187,34 @@ public class PHPActionContributor extends BasicTextEditorActionContributor {
   }
 
   /*
+   * @see IEditorActionBarContributor#init(IActionBars, IWorkbenchPage)
+   */
+  public void init(IActionBars bars, IWorkbenchPage page) {
+    Iterator e = fPartListeners.iterator();
+    while (e.hasNext())
+      page.addPartListener((RetargetAction) e.next());
+
+    super.init(bars, page);
+  }
+  /*
    * @see IEditorActionBarContributor#init(IActionBars)
    */
   public void init(IActionBars bars) {
     super.init(bars);
 
     IMenuManager menuManager = bars.getMenuManager();
-    IMenuManager editMenu = menuManager.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
+    IMenuManager editMenu =
+      menuManager.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
     if (editMenu != null) {
       editMenu.add(new Separator());
       editMenu.add(fContentAssist);
-      editMenu.add(fGotoMatchingBracket);
-
+      // editMenu.add(fGotoMatchingBracket);
       //   editMenu.add(fContentAssistTip);
     }
 
-    bars.setGlobalActionHandler(PHPdtActionConstants.CONTENT_ASSIST, fContentAssist);
+    bars.setGlobalActionHandler(
+      PHPdtActionConstants.CONTENT_ASSIST,
+      fContentAssist);
     //    IToolBarManager toolBarManager = bars.getToolBarManager();
     //    if (toolBarManager != null) {
     //      toolBarManager.add(new Separator());
@@ -160,25 +225,43 @@ public class PHPActionContributor extends BasicTextEditorActionContributor {
   private void doSetActiveEditor(IEditorPart part) {
     super.setActiveEditor(part);
 
+    IActionBars bars = getActionBars();
+    IStatusLineManager manager = bars.getStatusLineManager();
+    manager.setMessage(null);
+    manager.setErrorMessage(null);
+
     ITextEditor textEditor = null;
     if (part instanceof ITextEditor)
       textEditor = (ITextEditor) part;
 
     fContentAssist.setAction(getAction(textEditor, "ContentAssistProposal")); //$NON-NLS-1$
-    //  fContentAssistTip.setAction(getAction(editor, "ContentAssistTip")); //$NON-NLS-1$
-    fGotoMatchingBracket.setAction(getAction(textEditor, GotoMatchingBracketAction.GOTO_MATCHING_BRACKET));
-
-    IActionBars bars = getActionBars();
-    bars.setGlobalActionHandler(PHPdtActionConstants.COMMENT, getAction(textEditor, "Comment"));
-    bars.setGlobalActionHandler(PHPdtActionConstants.UNCOMMENT, getAction(textEditor, "Uncomment"));
-    bars.setGlobalActionHandler(PHPdtActionConstants.FORMAT, getAction(textEditor, "Format"));
+    fContentAssistTip.setAction(getAction(textEditor, "ContentAssistTip")); //$NON-NLS-1$
+    fGotoMatchingBracket.setAction(
+      getAction(textEditor, GotoMatchingBracketAction.GOTO_MATCHING_BRACKET));
+
+    bars.setGlobalActionHandler(PHPdtActionConstants.SHIFT_RIGHT, getAction(textEditor, "ShiftRight")); //$NON-NLS-1$
+    bars.setGlobalActionHandler(PHPdtActionConstants.SHIFT_LEFT, getAction(textEditor, "ShiftLeft")); //$NON-NLS-1$
+
+    bars.setGlobalActionHandler(
+      PHPdtActionConstants.COMMENT,
+      getAction(textEditor, "Comment"));
+    bars.setGlobalActionHandler(
+      PHPdtActionConstants.UNCOMMENT,
+      getAction(textEditor, "Uncomment"));
+    bars.setGlobalActionHandler(
+      PHPdtActionConstants.FORMAT,
+      getAction(textEditor, "Format"));
 
     if (part instanceof PHPEditor) {
-      PHPEditor cuEditor = (PHPEditor) part;
-      ActionGroup group = cuEditor.getActionGroup();
-      if (group != null)
-        group.fillActionBars(bars);
+      PHPEditor phpEditor = (PHPEditor) part;
+      phpEditor.getActionGroup().fillActionBars(getActionBars());
     }
+    //    if (part instanceof PHPEditor) {
+    //      PHPEditor cuEditor = (PHPEditor) part;
+    //      ActionGroup group = cuEditor.getActionGroup();
+    //      if (group != null)
+    //        group.fillActionBars(bars);
+    //    }
     //    fTogglePresentation.setEditor(editor);
     //    fTogglePresentation.update();
 
@@ -194,10 +277,12 @@ public class PHPActionContributor extends BasicTextEditorActionContributor {
       PHPeclipsePlugin.getDefault().setLastEditorFile(file);
       fParserAction.setEditor(textEditor);
       fParserAction.update();
-      if (SWT.getPlatform().equals("win32") && textEditor instanceof AbstractTextEditor) {
+      if (SWT.getPlatform().equals("win32")
+        && textEditor instanceof AbstractTextEditor) {
         fShowExternalPreviewAction.setEditor(textEditor);
         fShowExternalPreviewAction.update();
-        IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
+        IPreferenceStore store =
+          PHPeclipsePlugin.getDefault().getPreferenceStore();
         if (store.getBoolean(PHPeclipsePlugin.SHOW_EXTERNAL_PREVIEW_PREF)) {
           IAction a = ShowExternalPreviewAction.getInstance();
           if (a != null)
@@ -205,7 +290,7 @@ public class PHPActionContributor extends BasicTextEditorActionContributor {
         }
       }
     }
-    
+
   }
 
   /*
@@ -219,6 +304,11 @@ public class PHPActionContributor extends BasicTextEditorActionContributor {
    * @see IEditorActionBarContributor#dispose()
    */
   public void dispose() {
+    Iterator e = fPartListeners.iterator();
+    while (e.hasNext())
+      getPage().removePartListener((RetargetAction) e.next());
+    fPartListeners.clear();
+
     doSetActiveEditor(null);
     super.dispose();
   }
index b61c156..712a200 100644 (file)
@@ -18,6 +18,7 @@ import net.sourceforge.phpdt.internal.ui.actions.CompositeActionGroup;
 import net.sourceforge.phpdt.internal.ui.text.HTMLTextPresenter;
 import net.sourceforge.phpdt.internal.ui.text.PHPPairMatcher;
 import net.sourceforge.phpdt.internal.ui.viewsupport.IViewPartInputProvider;
+import net.sourceforge.phpdt.ui.IContextMenuConstants;
 import net.sourceforge.phpdt.ui.PreferenceConstants;
 import net.sourceforge.phpdt.ui.actions.GenerateActionGroup;
 import net.sourceforge.phpdt.ui.actions.GotoMatchingBracketAction;
@@ -30,8 +31,10 @@ import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.GroupMarker;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.preference.PreferenceConverter;
 import org.eclipse.jface.text.BadLocationException;
@@ -78,14 +81,19 @@ import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
 /**
  * PHP specific text editor.
  */
-public class PHPEditor extends StatusTextEditor implements IViewPartInputProvider { // extends TextEditor {
+public class PHPEditor
+  extends StatusTextEditor
+  implements IViewPartInputProvider { // extends TextEditor {
 
   /** Preference key for showing the line number ruler */
-  private final static String LINE_NUMBER_RULER = PreferenceConstants.EDITOR_LINE_NUMBER_RULER;
+  private final static String LINE_NUMBER_RULER =
+    PreferenceConstants.EDITOR_LINE_NUMBER_RULER;
   /** Preference key for the foreground color of the line numbers */
-  private final static String LINE_NUMBER_COLOR = PreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR;
+  private final static String LINE_NUMBER_COLOR =
+    PreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR;
   /** Preference key for the link color */
-  private final static String LINK_COLOR = PreferenceConstants.EDITOR_LINK_COLOR;
+  private final static String LINK_COLOR =
+    PreferenceConstants.EDITOR_LINK_COLOR;
 
   // protected PHPActionGroup fActionGroups;
   /** The outline page */
@@ -102,8 +110,8 @@ public class PHPEditor extends StatusTextEditor implements IViewPartInputProvide
 
   protected CompositeActionGroup fActionGroups;
   /** The standard action groups added to the menu */
-  private GenerateActionGroup fGenerateActionGroup;
-  private CompositeActionGroup fContextMenuGroup;
+  protected GenerateActionGroup fGenerateActionGroup;
+  protected CompositeActionGroup fContextMenuGroup;
 
   /** The information presenter. */
   private InformationPresenter fInformationPresenter;
@@ -114,7 +122,8 @@ public class PHPEditor extends StatusTextEditor implements IViewPartInputProvide
   public PHPEditor() {
     super();
     JavaTextTools textTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
-    setSourceViewerConfiguration(new PHPSourceViewerConfiguration(textTools, this));
+    setSourceViewerConfiguration(
+      new PHPSourceViewerConfiguration(textTools, this));
     setRangeIndicator(new DefaultRangeIndicator());
     setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
 
@@ -150,22 +159,32 @@ public class PHPEditor extends StatusTextEditor implements IViewPartInputProvide
 
       String t = types[i];
 
-      int[] stateMasks = configuration.getConfiguredTextHoverStateMasks(getSourceViewer(), t);
+      int[] stateMasks =
+        configuration.getConfiguredTextHoverStateMasks(getSourceViewer(), t);
 
       ISourceViewer sourceViewer = getSourceViewer();
       if (sourceViewer instanceof ITextViewerExtension2) {
         if (stateMasks != null) {
           for (int j = 0; j < stateMasks.length; j++) {
             int stateMask = stateMasks[j];
-            ITextHover textHover = configuration.getTextHover(sourceViewer, t, stateMask);
-            ((ITextViewerExtension2) sourceViewer).setTextHover(textHover, t, stateMask);
+            ITextHover textHover =
+              configuration.getTextHover(sourceViewer, t, stateMask);
+            ((ITextViewerExtension2) sourceViewer).setTextHover(
+              textHover,
+              t,
+              stateMask);
           }
         } else {
           ITextHover textHover = configuration.getTextHover(sourceViewer, t);
-          ((ITextViewerExtension2) sourceViewer).setTextHover(textHover, t, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
+          ((ITextViewerExtension2) sourceViewer).setTextHover(
+            textHover,
+            t,
+            ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
         }
       } else
-        sourceViewer.setTextHover(configuration.getTextHover(sourceViewer, t), t);
+        sourceViewer.setTextHover(
+          configuration.getTextHover(sourceViewer, t),
+          t);
     }
   }
 
@@ -183,11 +202,16 @@ public class PHPEditor extends StatusTextEditor implements IViewPartInputProvide
   public void createPartControl(Composite parent) {
     super.createPartControl(parent);
 
-    IInformationControlCreator informationControlCreator = new IInformationControlCreator() {
+    IInformationControlCreator informationControlCreator =
+      new IInformationControlCreator() {
       public IInformationControl createInformationControl(Shell parent) {
         boolean cutDown = false;
         int style = cutDown ? SWT.NONE : (SWT.V_SCROLL | SWT.H_SCROLL);
-        return new DefaultInformationControl(parent, SWT.RESIZE, style, new HTMLTextPresenter(cutDown));
+        return new DefaultInformationControl(
+          parent,
+          SWT.RESIZE,
+          style,
+          new HTMLTextPresenter(cutDown));
       }
     };
 
@@ -202,7 +226,8 @@ public class PHPEditor extends StatusTextEditor implements IViewPartInputProvide
    * @return the document's complete text
    */
   public String get() {
-    IDocument doc = this.getDocumentProvider().getDocument(this.getEditorInput());
+    IDocument doc =
+      this.getDocumentProvider().getDocument(this.getEditorInput());
     return doc.get();
   }
 
@@ -225,16 +250,6 @@ public class PHPEditor extends StatusTextEditor implements IViewPartInputProvide
     super.createActions();
 
     Action action;
-    //    setAction(
-    //      "ContentAssistProposal",
-    //      new TextOperationAction(
-    //        PHPEditorMessages.getResourceBundle(),
-    //        "ContentAssistProposal.",
-    //        this,
-    //        ISourceViewer.CONTENTASSIST_PROPOSALS));
-    action = new ContentAssistAction(PHPEditorMessages.getResourceBundle(), "ContentAssistProposal.", this); //$NON-NLS-1$
-    action.setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
-    setAction("ContentAssistProposal", action); //$NON-NLS-1$
 
     setAction(
       "ContentAssistTip",
@@ -244,33 +259,46 @@ public class PHPEditor extends StatusTextEditor implements IViewPartInputProvide
         this,
         ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION));
 
-    action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "Comment.", this, ITextOperationTarget.PREFIX);
+    action = new ContentAssistAction(PHPEditorMessages.getResourceBundle(), "ContentAssistProposal.", this); //$NON-NLS-1$
+    action.setActionDefinitionId(
+      PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
+    setAction("ContentAssistProposal", action); //$NON-NLS-1$
+    markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$
+    // WorkbenchHelp.setHelp(action, IJavaHelpContextIds.CONTENT_ASSIST_ACTION);
+
+    action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "Comment.", this, ITextOperationTarget.PREFIX); //$NON-NLS-1$
     action.setActionDefinitionId(PHPEditorActionDefinitionIds.COMMENT);
-    setAction("Comment", action);
+    setAction("Comment", action); //$NON-NLS-1$
+    markAsStateDependentAction("Comment", true); //$NON-NLS-1$
+    //         WorkbenchHelp.setHelp(action, IJavaHelpContextIds.COMMENT_ACTION);
 
-    action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "Uncomment.", this, ITextOperationTarget.STRIP_PREFIX);
+    action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "Uncomment.", this, ITextOperationTarget.STRIP_PREFIX); //$NON-NLS-1$
     action.setActionDefinitionId(PHPEditorActionDefinitionIds.UNCOMMENT);
-    setAction("Uncomment", action);
+    setAction("Uncomment", action); //$NON-NLS-1$
+    markAsStateDependentAction("Uncomment", true); //$NON-NLS-1$
+    //         WorkbenchHelp.setHelp(action, IJavaHelpContextIds.UNCOMMENT_ACTION);
 
     action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "Format.", this, ISourceViewer.FORMAT); //$NON-NLS-1$
     action.setActionDefinitionId(PHPEditorActionDefinitionIds.FORMAT);
     setAction("Format", action); //$NON-NLS-1$
-
-    markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$
-    markAsStateDependentAction("Comment", true); //$NON-NLS-1$
-    markAsStateDependentAction("Uncomment", true); //$NON-NLS-1$
     markAsStateDependentAction("Format", true); //$NON-NLS-1$
+    markAsSelectionDependentAction("Format", true); //$NON-NLS-1$              
+    // WorkbenchHelp.setHelp(action, IJavaHelpContextIds.FORMAT_ACTION);
 
     action = new GotoMatchingBracketAction(this);
-    action.setActionDefinitionId(PHPEditorActionDefinitionIds.GOTO_MATCHING_BRACKET);
+    action.setActionDefinitionId(
+      PHPEditorActionDefinitionIds.GOTO_MATCHING_BRACKET);
     setAction(GotoMatchingBracketAction.GOTO_MATCHING_BRACKET, action);
 
-    fGenerateActionGroup = new GenerateActionGroup(this, ITextEditorActionConstants.GROUP_EDIT);
+    fGenerateActionGroup =
+      new GenerateActionGroup(this, ITextEditorActionConstants.GROUP_EDIT);
 
-    fActionGroups = new CompositeActionGroup(new ActionGroup[] { fGenerateActionGroup });
+    fActionGroups =
+      new CompositeActionGroup(new ActionGroup[] { fGenerateActionGroup });
 
     // We have to keep the context menu group separate to have better control over positioning
-    fContextMenuGroup = new CompositeActionGroup(new ActionGroup[] { fGenerateActionGroup });
+    fContextMenuGroup =
+      new CompositeActionGroup(new ActionGroup[] { fGenerateActionGroup });
     //      rg, 
     //      new LocalHistoryActionGroup(this, ITextEditorActionConstants.GROUP_EDIT)});
 
@@ -323,11 +351,11 @@ public class PHPEditor extends StatusTextEditor implements IViewPartInputProvide
       if (a != null)
         a.run();
     }
-//    if (SWT.getPlatform().equals("win32")) {
-//      IAction a = ShowExternalPreviewAction.getInstance();
-//      if (a != null)
-//        a.run();
-//    }
+    //    if (SWT.getPlatform().equals("win32")) {
+    //      IAction a = ShowExternalPreviewAction.getInstance();
+    //      if (a != null)
+    //        a.run();
+    //    }
     if (fOutlinePage != null)
       fOutlinePage.update();
   }
@@ -365,13 +393,20 @@ public class PHPEditor extends StatusTextEditor implements IViewPartInputProvide
    */
   public void editorContextMenuAboutToShow(MenuManager menu) {
     super.editorContextMenuAboutToShow(menu);
-
-    addAction(menu, ITextEditorActionConstants.GROUP_EDIT, "Format"); //$NON-NLS-1$
-
-    ActionContext context = new ActionContext(getSelectionProvider().getSelection());
-    fContextMenuGroup.setContext(context);
-    fContextMenuGroup.fillContextMenu(menu);
-    fContextMenuGroup.setContext(null);
+               menu.appendToGroup(ITextEditorActionConstants.GROUP_UNDO, new Separator(IContextMenuConstants.GROUP_OPEN));     
+               menu.insertAfter(IContextMenuConstants.GROUP_OPEN, new GroupMarker(IContextMenuConstants.GROUP_SHOW));  
+               
+               ActionContext context= new ActionContext(getSelectionProvider().getSelection());
+               fContextMenuGroup.setContext(context);
+               fContextMenuGroup.fillContextMenu(menu);
+               fContextMenuGroup.setContext(null);
+//    addAction(menu, ITextEditorActionConstants.GROUP_EDIT, "Format"); //$NON-NLS-1$
+//
+//    ActionContext context =
+//      new ActionContext(getSelectionProvider().getSelection());
+//    fContextMenuGroup.setContext(context);
+//    fContextMenuGroup.fillContextMenu(menu);
+//    fContextMenuGroup.setContext(null);
   }
 
   protected void updateStateDependentActions() {
@@ -447,7 +482,8 @@ public class PHPEditor extends StatusTextEditor implements IViewPartInputProvide
         if (value instanceof Integer) {
           sourceViewer.getTextWidget().setTabs(((Integer) value).intValue());
         } else if (value instanceof String) {
-          sourceViewer.getTextWidget().setTabs(Integer.parseInt((String) value));
+          sourceViewer.getTextWidget().setTabs(
+            Integer.parseInt((String) value));
         }
         return;
       }
@@ -592,9 +628,13 @@ public class PHPEditor extends StatusTextEditor implements IViewPartInputProvide
       if (!store.getBoolean(PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)) {
         if (store.contains(PREFERENCE_COLOR_BACKGROUND)) {
           if (store.isDefault(PREFERENCE_COLOR_BACKGROUND))
-            rgb = PreferenceConverter.getDefaultColor(store, PREFERENCE_COLOR_BACKGROUND);
+            rgb =
+              PreferenceConverter.getDefaultColor(
+                store,
+                PREFERENCE_COLOR_BACKGROUND);
           else
-            rgb = PreferenceConverter.getColor(store, PREFERENCE_COLOR_BACKGROUND);
+            rgb =
+              PreferenceConverter.getColor(store, PREFERENCE_COLOR_BACKGROUND);
         }
       }
       rulerColumn.setBackground(manager.getColor(rgb));
@@ -680,12 +720,15 @@ public class PHPEditor extends StatusTextEditor implements IViewPartInputProvide
     return false;
   }
 
-  private static boolean isSurroundedByBrackets(IDocument document, int offset) {
+  private static boolean isSurroundedByBrackets(
+    IDocument document,
+    int offset) {
     if (offset == 0 || offset == document.getLength())
       return false;
 
     try {
-      return isBracket(document.getChar(offset - 1)) && isBracket(document.getChar(offset));
+      return isBracket(document.getChar(offset - 1))
+        && isBracket(document.getChar(offset));
 
     } catch (BadLocationException e) {
       return false;
@@ -732,7 +775,8 @@ public class PHPEditor extends StatusTextEditor implements IViewPartInputProvide
       return;
 
     int anchor = fBracketMatcher.getAnchor();
-    int targetOffset = (PHPPairMatcher.RIGHT == anchor) ? offset : offset + length - 1;
+    int targetOffset =
+      (PHPPairMatcher.RIGHT == anchor) ? offset : offset + length - 1;
 
     boolean visible = false;
     if (sourceViewer instanceof ITextViewerExtension3) {
@@ -740,7 +784,9 @@ public class PHPEditor extends StatusTextEditor implements IViewPartInputProvide
       visible = (extension.modelOffset2WidgetOffset(targetOffset) > -1);
     } else {
       IRegion visibleRegion = sourceViewer.getVisibleRegion();
-      visible = (targetOffset >= visibleRegion.getOffset() && targetOffset < visibleRegion.getOffset() + visibleRegion.getLength());
+      visible =
+        (targetOffset >= visibleRegion.getOffset()
+          && targetOffset < visibleRegion.getOffset() + visibleRegion.getLength());
     }
 
     if (!visible) {
@@ -760,7 +806,8 @@ public class PHPEditor extends StatusTextEditor implements IViewPartInputProvide
      * @param msg message to be set
      */
   protected void setStatusLineErrorMessage(String msg) {
-    IEditorStatusLine statusLine = (IEditorStatusLine) getAdapter(IEditorStatusLine.class);
+    IEditorStatusLine statusLine =
+      (IEditorStatusLine) getAdapter(IEditorStatusLine.class);
     if (statusLine != null)
       statusLine.setMessage(true, msg, null);
   }
@@ -774,14 +821,18 @@ public class PHPEditor extends StatusTextEditor implements IViewPartInputProvide
      * @return the line's bidi segmentation
      * @throws BadLocationException in case lineOffset is not valid in document
      */
-  public static int[] getBidiLineSegments(IDocument document, int lineOffset) throws BadLocationException {
+  public static int[] getBidiLineSegments(IDocument document, int lineOffset)
+    throws BadLocationException {
 
     IRegion line = document.getLineInformationOfOffset(lineOffset);
-    ITypedRegion[] linePartitioning = document.computePartitioning(lineOffset, line.getLength());
+    ITypedRegion[] linePartitioning =
+      document.computePartitioning(lineOffset, line.getLength());
 
     List segmentation = new ArrayList();
     for (int i = 0; i < linePartitioning.length; i++) {
-      if (IPHPPartitionScannerConstants.PHP_STRING.equals(linePartitioning[i].getType()))
+      if (IPHPPartitionScannerConstants
+        .PHP_STRING
+        .equals(linePartitioning[i].getType()))
         segmentation.add(linePartitioning[i]);
     }
 
@@ -841,7 +892,10 @@ public class PHPEditor extends StatusTextEditor implements IViewPartInputProvide
   /*
    * @see AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int)
    */
-  protected final ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
+  protected final ISourceViewer createSourceViewer(
+    Composite parent,
+    IVerticalRuler ruler,
+    int styles) {
     ISourceViewer viewer = createJavaSourceViewer(parent, ruler, styles);
     StyledText text = viewer.getTextWidget();
     text.addBidiSegmentListener(new BidiSegmentListener() {
@@ -856,7 +910,10 @@ public class PHPEditor extends StatusTextEditor implements IViewPartInputProvide
   /*
    * @see AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int)
    */
-  protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
+  protected ISourceViewer createJavaSourceViewer(
+    Composite parent,
+    IVerticalRuler ruler,
+    int styles) {
     return super.createSourceViewer(parent, ruler, styles);
   }
 
index d79bc16..3bbf088 100644 (file)
@@ -17,6 +17,10 @@ ContentAssistTip.tooltip=Content Tip
 ContentAssistTip.image=
 ContentAssistTip.description=Content Tip
 
+Format.label=F&ormat
+Format.tooltip=Format the Selected Text
+Format.description=Format the selected text
+
 Comment.label=Comment@Ctrl+/
 Comment.tooltip=Comment selected lines
 
index ac993f6..af5cf00 100644 (file)
@@ -7,6 +7,7 @@ import java.util.List;
 import java.util.Map;
 
 import net.sourceforge.phpdt.internal.compiler.parser.Scanner;
+import net.sourceforge.phpdt.internal.ui.actions.CompositeActionGroup;
 import net.sourceforge.phpdt.internal.ui.text.ContentAssistPreference;
 import net.sourceforge.phpdt.internal.ui.text.PHPPairMatcher;
 import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionManager;
@@ -22,6 +23,7 @@ import org.eclipse.core.resources.IFile;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.Preferences;
 import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
+import org.eclipse.jface.action.IMenuManager;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.preference.PreferenceConverter;
 import org.eclipse.jface.text.AbstractHoverInformationControlManager;
@@ -56,6 +58,7 @@ import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Layout;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.actions.ActionContext;
 import org.eclipse.ui.help.WorkbenchHelp;
 import org.eclipse.ui.texteditor.IDocumentProvider;
 
@@ -844,7 +847,6 @@ public class PHPUnitEditor extends PHPEditor {
       AnnotationType.SEARCH_RESULT,
       AnnotationType.WARNING,
       AnnotationType.ERROR };
-
   /**
    * Creates a new php unit editor.
    */
@@ -1404,4 +1406,16 @@ public class PHPUnitEditor extends PHPEditor {
 
     return oldExtension.equals(newExtension);
   }
+  
+       /*
+        * @see AbstractTextEditor#editorContextMenuAboutToShow(IMenuManager)
+        */
+       public void editorContextMenuAboutToShow(IMenuManager menu) {
+               super.editorContextMenuAboutToShow(menu);               
+                               
+               ActionContext context= new ActionContext(getSelectionProvider().getSelection());
+               fContextMenuGroup.setContext(context);
+               fContextMenuGroup.fillContextMenu(menu);
+               fContextMenuGroup.setContext(null);
+       }
 }