Change Eclipse-LazyStart: true to Bundle-ActivationPolicy: lazy (upgrade to The Equin...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / actions / PHPOpenDeclarationAction.java
index 7fc1dae..47edccb 100644 (file)
@@ -22,82 +22,92 @@ import org.eclipse.ui.IWorkbenchSite;
 import org.eclipse.ui.IWorkbenchWindow;
 
 public class PHPOpenDeclarationAction extends SelectionDispatchAction {
-  private IWorkbenchWindow fWindow;
+       private IWorkbenchWindow fWindow;
 
-  private PHPEditor fEditor;
+       private PHPEditor fEditor;
 
-  public void dispose() {
-  }
+       public void dispose() {
+       }
 
-  public PHPOpenDeclarationAction(IWorkbenchSite site) {
-    super(site);
-    // setText(ActionMessages.getString("OpenAction.label")); //$NON-NLS-1$
-    // setToolTipText(ActionMessages.getString("OpenAction.tooltip")); //$NON-NLS-1$
-    // setDescription(ActionMessages.getString("OpenAction.description")); //$NON-NLS-1$
-    // WorkbenchHelp.setHelp(this, IJavaHelpContextIds.OPEN_ACTION);
-  }
-  
-  /**
-   * Note: This constructor is for internal use only. Clients should not call this constructor.
-   */
-  public PHPOpenDeclarationAction(PHPEditor editor) {
-    this(editor.getEditorSite());
-    fEditor = editor;
-    //         setText(ActionMessages.getString("OpenAction.declaration.label")); //$NON-NLS-1$
-    setEnabled(SelectionConverter.canOperateOn(fEditor));
-  }
-  
-  public void init(IWorkbenchWindow window) {
-    this.fWindow = window;
-  }
+       public PHPOpenDeclarationAction(IWorkbenchSite site) {
+               super(site);
+               // setText(ActionMessages.getString("OpenAction.label")); //$NON-NLS-1$
+               // setToolTipText(ActionMessages.getString("OpenAction.tooltip"));
+               // //$NON-NLS-1$
+               // setDescription(ActionMessages.getString("OpenAction.description"));
+               // //$NON-NLS-1$
+               // WorkbenchHelp.setHelp(this, IJavaHelpContextIds.OPEN_ACTION);
+       }
 
-  public void selectionChanged(IAction action, ISelection selection) {
-    if (!selection.isEmpty()) {
-      if (selection instanceof TextSelection) {
-        action.setEnabled(true);
-      } else if (fWindow.getActivePage() != null && fWindow.getActivePage().getActivePart() != null) {
-        //
-      }
-    }
-  }
+       /**
+        * Note: This constructor is for internal use only. Clients should not call
+        * this constructor.
+        */
+       public PHPOpenDeclarationAction(PHPEditor editor) {
+               this(editor.getEditorSite());
+               fEditor = editor;
+               // setText(ActionMessages.getString("OpenAction.declaration.label"));
+               // //$NON-NLS-1$
+               setEnabled(SelectionConverter.canOperateOn(fEditor));
+       }
 
-  private boolean checkEnabled(IStructuredSelection selection) {
-    if (selection.isEmpty())
-      return false;
-    return true;
-  }
+       public void init(IWorkbenchWindow window) {
+               this.fWindow = window;
+       }
 
-  /*
-   * (non-Javadoc) Method declared on SelectionDispatchAction.
-   */
-  public void run(ITextSelection selection) {
-    if (!ActionUtil.isProcessable(getShell(), fEditor))
-      return;
-    OpenDeclarationEditorAction openAction = new OpenDeclarationEditorAction(fEditor);
-    openAction.openSelectedElement(selection);
-  }
+       public void selectionChanged(IAction action, ISelection selection) {
+               if (!selection.isEmpty()) {
+                       if (selection instanceof TextSelection) {
+                               action.setEnabled(true);
+                       } else if (fWindow.getActivePage() != null
+                                       && fWindow.getActivePage().getActivePart() != null) {
+                               //
+                       }
+               }
+       }
 
-  /*
-   * (non-Javadoc) Method declared on SelectionDispatchAction.
-   */
-  public void run(IStructuredSelection selection) {
-    if (!checkEnabled(selection))
-      return;
-    run(selection.toArray());
-  }
+       private boolean checkEnabled(IStructuredSelection selection) {
+               if (selection.isEmpty())
+                       return false;
+               return true;
+       }
 
-  /**
-   * Note: this method is for internal use only. Clients should not call this method.
-   */
-  public void run(Object[] elements) {
-    if (elements != null && elements.length > 0) {
-      ITextSelection selection = (ITextSelection) fEditor.getSelectionProvider().getSelection();
-      IDocument doc = fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
-      int pos = selection.getOffset();
+       /*
+        * (non-Javadoc) Method declared on SelectionDispatchAction.
+        */
+       public void run(ITextSelection selection) {
+               if (!ActionUtil.isProcessable(getShell(), fEditor))
+                       return;
+               OpenDeclarationEditorAction openAction = new OpenDeclarationEditorAction(
+                               fEditor);
+               openAction.openSelectedElement(selection);
+       }
 
-      OpenDeclarationEditorAction openAction = new OpenDeclarationEditorAction(fEditor);
-      openAction.openSelectedPosition(doc, pos);
-    }
-  }
+       /*
+        * (non-Javadoc) Method declared on SelectionDispatchAction.
+        */
+       public void run(IStructuredSelection selection) {
+               if (!checkEnabled(selection))
+                       return;
+               run(selection.toArray());
+       }
+
+       /**
+        * Note: this method is for internal use only. Clients should not call this
+        * method.
+        */
+       public void run(Object[] elements) {
+               if (elements != null && elements.length > 0) {
+                       ITextSelection selection = (ITextSelection) fEditor
+                                       .getSelectionProvider().getSelection();
+                       IDocument doc = fEditor.getDocumentProvider().getDocument(
+                                       fEditor.getEditorInput());
+                       int pos = selection.getOffset();
+
+                       OpenDeclarationEditorAction openAction = new OpenDeclarationEditorAction(
+                                       fEditor);
+                       openAction.openSelectedPosition(doc, pos);
+               }
+       }
 
 }
\ No newline at end of file