1 package net.sourceforge.phpeclipse.phpeditor;
 
   3 /**********************************************************************
 
   4 Copyright (c) 2000, 2002 IBM Corp. and others.
 
   5 All rights reserved. This program and the accompanying materials
 
   6 are made available under the terms of the Common Public License v1.0
 
   7 which accompanies this distribution, and is available at
 
   8 http://www.eclipse.org/legal/cpl-v10.html
 
  11     IBM Corporation - Initial implementation
 
  12     Klaus Hartlage - www.eclipseproject.de
 
  13 **********************************************************************/
 
  15 import net.sourceforge.phpdt.ui.actions.*;
 
  16 import org.eclipse.jface.action.IMenuManager;
 
  17 import org.eclipse.jface.action.Separator;
 
  18 import org.eclipse.ui.IActionBars;
 
  19 import org.eclipse.ui.IEditorPart;
 
  20 import org.eclipse.ui.IWorkbenchActionConstants;
 
  21 import org.eclipse.ui.actions.ActionGroup;
 
  22 import org.eclipse.ui.texteditor.BasicTextEditorActionContributor;
 
  23 import org.eclipse.ui.texteditor.ITextEditor;
 
  24 import org.eclipse.ui.texteditor.RetargetTextEditorAction;
 
  27  * Contributes interesting PHP actions to the desktop's Edit menu and the toolbar.
 
  29 public class PHPActionContributor extends BasicTextEditorActionContributor   {
 
  31   protected RetargetTextEditorAction fContentAssistProposal;
 
  32   // protected RetargetTextEditorAction fContentAssistTip;
 
  33   // protected TextEditorAction fTogglePresentation;
 
  34   protected PHPParserAction parserAction;
 
  37    * Default constructor.
 
  39   public PHPActionContributor() {
 
  41     fContentAssistProposal = new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistProposal."); //$NON-NLS-1$
 
  42     //  fContentAssistTip = new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistTip."); //$NON-NLS-1$
 
  43     //  fTogglePresentation = new PresentationAction();
 
  44     parserAction = PHPParserAction.getInstance();
 
  48    * @see IEditorActionBarContributor#init(IActionBars)
 
  50   public void init(IActionBars bars) {
 
  53     IMenuManager menuManager = bars.getMenuManager();
 
  54     IMenuManager editMenu = menuManager.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
 
  55     if (editMenu != null) {
 
  56       editMenu.add(new Separator());
 
  57       editMenu.add(fContentAssistProposal);
 
  58       //   editMenu.add(fContentAssistTip);
 
  61     //    IToolBarManager toolBarManager = bars.getToolBarManager();
 
  62     //    if (toolBarManager != null) {
 
  63     //      toolBarManager.add(new Separator());
 
  64     //      toolBarManager.add(fTogglePresentation);
 
  68   private void doSetActiveEditor(IEditorPart part) {
 
  69     super.setActiveEditor(part);
 
  71     ITextEditor textEditor = null;
 
  72     if (part instanceof ITextEditor)
 
  73       textEditor = (ITextEditor) part;
 
  75     fContentAssistProposal.setAction(getAction(textEditor, "ContentAssistProposal")); //$NON-NLS-1$
 
  76     //  fContentAssistTip.setAction(getAction(editor, "ContentAssistTip")); //$NON-NLS-1$
 
  78     IActionBars bars = getActionBars();
 
  79     bars.setGlobalActionHandler(PHPdtActionConstants.COMMENT, getAction(textEditor, "Comment"));
 
  80     bars.setGlobalActionHandler(PHPdtActionConstants.UNCOMMENT, getAction(textEditor, "Uncomment"));
 
  82     if (part instanceof PHPEditor) {
 
  83       PHPEditor cuEditor= (PHPEditor)part;
 
  84       ActionGroup group= cuEditor.getActionGroup();
 
  86         group.fillActionBars(bars);
 
  88     //    fTogglePresentation.setEditor(editor);
 
  89     //    fTogglePresentation.update();
 
  91     parserAction.setEditor(textEditor);
 
  92     parserAction.update();
 
  96    * @see IEditorActionBarContributor#setActiveEditor(IEditorPart)
 
  98   public void setActiveEditor(IEditorPart part) {
 
  99     doSetActiveEditor(part);   
 
 103    * @see IEditorActionBarContributor#dispose()
 
 105   public void dispose() {
 
 106     doSetActiveEditor(null);