1) Moved net.sourceforge.phpeclipse.ui\src\net\sourceforge\phpdt back to net.sourcefo...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / ui / actions / OpenEditorActionGroup.java
index 067a9f1..0d41704 100644 (file)
@@ -13,7 +13,6 @@ package net.sourceforge.phpdt.ui.actions;
 import net.sourceforge.phpdt.internal.ui.actions.ActionMessages;
 import net.sourceforge.phpdt.ui.IContextMenuConstants;
 import net.sourceforge.phpeclipse.actions.PHPOpenDeclarationAction;
-import net.sourceforge.phpeclipse.actions.PHPOpenDeclarationEditorAction;
 import net.sourceforge.phpeclipse.phpeditor.PHPEditor;
 
 import org.eclipse.core.resources.IFile;
@@ -26,15 +25,15 @@ import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.ISelectionProvider;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IViewPart;
+//import org.eclipse.ui.IViewPart;
 import org.eclipse.ui.IWorkbenchSite;
 import org.eclipse.ui.actions.ActionGroup;
 import org.eclipse.ui.actions.OpenWithMenu;
 
 /**
- * Action group that adds the actions opening a new editor to the 
- * context menu and the action bar's navigate menu.
- *
+ * Action group that adds the actions opening a new editor to the context menu
+ * and the action bar's navigate menu.
+ * 
  * <p>
  * This class may be instantiated; it is not intended to be subclassed.
  * </p>
@@ -44,63 +43,67 @@ import org.eclipse.ui.actions.OpenWithMenu;
 public class OpenEditorActionGroup extends ActionGroup {
 
        private IWorkbenchSite fSite;
+
        private boolean fIsEditorOwner;
+
        private PHPOpenDeclarationAction fOpen;
 
        /**
-        * Creates a new <code>OpenActionGroup</code>. The group requires
-        * that the selection provided by the part's selection provider is of type <code>
+        * Creates a new <code>OpenActionGroup</code>. The group requires that
+        * the selection provided by the part's selection provider is of type <code>
         * org.eclipse.jface.viewers.IStructuredSelection</code>.
         * 
-        * @param part the view part that owns this action group
+        * @param part
+        *            the view part that owns this action group
         */
-       public OpenEditorActionGroup(IViewPart part) {
-               fSite= part.getSite();
-               fOpen= new PHPOpenDeclarationAction(fSite);
-               fOpen.setActionDefinitionId(PHPEditorActionDefinitionIds.OPEN_EDITOR);
-               initialize(fSite.getSelectionProvider());
-       }
-       
+//     public OpenEditorActionGroup(IViewPart part) {
+//             fSite = part.getSite();
+//             fOpen = new PHPOpenDeclarationAction(fSite);
+//             fOpen.setActionDefinitionId(PHPEditorActionDefinitionIds.OPEN_EDITOR);
+//             initialize(fSite.getSelectionProvider());
+//     }
+
        /**
-        * Note: This constructor is for internal use only. Clients should not call this constructor.
+        * Note: This constructor is for internal use only. Clients should not call
+        * this constructor.
         */
        public OpenEditorActionGroup(PHPEditor part) {
-               fIsEditorOwner= true;
-               fOpen= new PHPOpenDeclarationAction(part);
+               fIsEditorOwner = true;
+               fOpen = new PHPOpenDeclarationAction(part);
                fOpen.setActionDefinitionId(PHPEditorActionDefinitionIds.OPEN_EDITOR);
                part.setAction("OpenEditor", fOpen); //$NON-NLS-1$
-               fSite= part.getEditorSite();
+               fSite = part.getEditorSite();
                initialize(fSite.getSelectionProvider());
        }
 
        /**
-        * Returns the open action managed by this action group. 
+        * Returns the open action managed by this action group.
         * 
-        * @return the open action. Returns <code>null</code> if the group
-        *      doesn't provide any open action
+        * @return the open action. Returns <code>null</code> if the group doesn't
+        *         provide any open action
         */
-       public IAction getOpenAction() {
-               return fOpen;
-       }
+//     public IAction getOpenAction() {
+//             return fOpen;
+//     }
 
        private void initialize(ISelectionProvider provider) {
-               ISelection selection= provider.getSelection();
+               ISelection selection = provider.getSelection();
                fOpen.update(selection);
                if (!fIsEditorOwner) {
                        provider.addSelectionChangedListener(fOpen);
                }
        }
 
-       /* (non-Javadoc)
-        * Method declared in ActionGroup
+       /*
+        * (non-Javadoc) Method declared in ActionGroup
         */
        public void fillActionBars(IActionBars actionBar) {
                super.fillActionBars(actionBar);
                setGlobalActionHandlers(actionBar);
        }
-       
-       /* (non-Javadoc)
-        * Method declared in ActionGroup
+
+       /*
+        * (non-Javadoc) Method declared in ActionGroup
         */
        public void fillContextMenu(IMenuManager menu) {
                super.fillContextMenu(menu);
@@ -114,39 +117,40 @@ public class OpenEditorActionGroup extends ActionGroup {
         * @see ActionGroup#dispose()
         */
        public void dispose() {
-               ISelectionProvider provider= fSite.getSelectionProvider();
+               ISelectionProvider provider = fSite.getSelectionProvider();
                provider.removeSelectionChangedListener(fOpen);
                super.dispose();
        }
-       
+
        private void setGlobalActionHandlers(IActionBars actionBars) {
                actionBars.setGlobalActionHandler(PHPdtActionConstants.OPEN, fOpen);
        }
-       
+
        private void appendToGroup(IMenuManager menu, IAction action) {
                if (action.isEnabled())
                        menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, action);
        }
-       
+
        private void addOpenWithMenu(IMenuManager menu) {
-               ISelection selection= getContext().getSelection();
+               ISelection selection = getContext().getSelection();
                if (selection.isEmpty() || !(selection instanceof IStructuredSelection))
                        return;
-               IStructuredSelection ss= (IStructuredSelection)selection;
+               IStructuredSelection ss = (IStructuredSelection) selection;
                if (ss.size() != 1)
                        return;
 
-               Object o= ss.getFirstElement();
+               Object o = ss.getFirstElement();
                if (!(o instanceof IAdaptable))
                        return;
 
-               IAdaptable element= (IAdaptable)o;
-               Object resource= element.getAdapter(IResource.class);
+               IAdaptable element = (IAdaptable) o;
+               Object resource = element.getAdapter(IResource.class);
                if (!(resource instanceof IFile))
-                       return; 
+                       return;
 
                // Create a menu flyout.
-               IMenuManager submenu= new MenuManager(ActionMessages.getString("OpenWithMenu.label")); //$NON-NLS-1$
+               IMenuManager submenu = new MenuManager(ActionMessages
+                               .getString("OpenWithMenu.label")); //$NON-NLS-1$
                submenu.add(new OpenWithMenu(fSite.getPage(), (IFile) resource));
 
                // Add the submenu.