first PHP parser version (doesn't work actually)
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / PHPActionContributor.java
index 1fbefe5..54a3038 100644 (file)
@@ -30,68 +30,74 @@ import org.eclipse.ui.texteditor.TextEditorAction;
  */
 public class PHPActionContributor extends TextEditorActionContributor {
 
-       protected RetargetTextEditorAction fContentAssistProposal;
-       protected RetargetTextEditorAction fContentAssistTip;
-       protected TextEditorAction fTogglePresentation;
-
-       /**
-        * Default constructor.
-        */
-       public PHPActionContributor() {
-               super();
-               fContentAssistProposal= new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistProposal."); //$NON-NLS-1$
-               fContentAssistTip= new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistTip."); //$NON-NLS-1$
-               fTogglePresentation= new PresentationAction();
-       }
-       
-       /*
-        * @see IEditorActionBarContributor#init(IActionBars)
-        */
-       public void init(IActionBars bars) {
-               super.init(bars);
-               
-               IMenuManager menuManager= bars.getMenuManager();
-               IMenuManager editMenu= menuManager.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
-               if (editMenu != null) {
-                       editMenu.add(new Separator());
-                       editMenu.add(fContentAssistProposal);
-                       editMenu.add(fContentAssistTip);
-               }       
-               
-               IToolBarManager toolBarManager= bars.getToolBarManager();
-               if (toolBarManager != null) {
-                       toolBarManager.add(new Separator());
-                       toolBarManager.add(fTogglePresentation);
-               }
-       }
-       
-       private void doSetActiveEditor(IEditorPart part) {
-               super.setActiveEditor(part);
-
-               ITextEditor editor= null;
-               if (part instanceof ITextEditor)
-                       editor= (ITextEditor) part;
-
-               fContentAssistProposal.setAction(getAction(editor, "ContentAssistProposal")); //$NON-NLS-1$
-               fContentAssistTip.setAction(getAction(editor, "ContentAssistTip")); //$NON-NLS-1$
-
-               fTogglePresentation.setEditor(editor);
-               fTogglePresentation.update();
-       }
-       
-       /*
-        * @see IEditorActionBarContributor#setActiveEditor(IEditorPart)
-        */
-       public void setActiveEditor(IEditorPart part) {
-               super.setActiveEditor(part);
-               doSetActiveEditor(part);
-       }
-       
-       /*
-        * @see IEditorActionBarContributor#dispose()
-        */
-       public void dispose() {
-               doSetActiveEditor(null);
-               super.dispose();
-       }
+  protected RetargetTextEditorAction fContentAssistProposal;
+  protected RetargetTextEditorAction fContentAssistTip;
+  protected TextEditorAction fTogglePresentation;
+  protected PHPParserAction parserAction;
+
+  /**
+   * Default constructor.
+   */
+  public PHPActionContributor() {
+    super();
+    fContentAssistProposal = new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistProposal."); //$NON-NLS-1$
+    fContentAssistTip = new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistTip."); //$NON-NLS-1$
+    fTogglePresentation = new PresentationAction();
+    parserAction = PHPParserAction.getInstance();
+  }
+
+  /*
+   * @see IEditorActionBarContributor#init(IActionBars)
+   */
+  public void init(IActionBars bars) {
+    super.init(bars);
+
+    IMenuManager menuManager = bars.getMenuManager();
+    IMenuManager editMenu = menuManager.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
+    if (editMenu != null) {
+      editMenu.add(new Separator());
+      editMenu.add(fContentAssistProposal);
+      editMenu.add(fContentAssistTip);
+    }
+
+    IToolBarManager toolBarManager = bars.getToolBarManager();
+    if (toolBarManager != null) {
+      toolBarManager.add(new Separator());
+      toolBarManager.add(fTogglePresentation);
+    }
+  }
+
+  private void doSetActiveEditor(IEditorPart part) {
+    super.setActiveEditor(part);
+
+    ITextEditor editor = null;
+    if (part instanceof ITextEditor)
+      editor = (ITextEditor) part;
+
+    fContentAssistProposal.setAction(getAction(editor, "ContentAssistProposal")); //$NON-NLS-1$
+    fContentAssistTip.setAction(getAction(editor, "ContentAssistTip")); //$NON-NLS-1$
+
+    fTogglePresentation.setEditor(editor);
+    fTogglePresentation.update();
+
+    parserAction.setEditor(editor);
+    parserAction.update();
+  }
+
+  /*
+   * @see IEditorActionBarContributor#setActiveEditor(IEditorPart)
+   */
+  public void setActiveEditor(IEditorPart part) {
+    super.setActiveEditor(part);
+    doSetActiveEditor(part);
+
+  }
+
+  /*
+   * @see IEditorActionBarContributor#dispose()
+   */
+  public void dispose() {
+    doSetActiveEditor(null);
+    super.dispose();
+  }
 }