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 java.util.ResourceBundle;
16 import org.eclipse.jface.action.IMenuManager;
17 import org.eclipse.jface.action.IToolBarManager;
18 import org.eclipse.jface.action.Separator;
19 import org.eclipse.ui.IActionBars;
20 import org.eclipse.ui.IEditorPart;
21 import org.eclipse.ui.IWorkbenchActionConstants;
22 import org.eclipse.ui.editors.text.TextEditorActionContributor;
23 import org.eclipse.ui.texteditor.BasicTextEditorActionContributor;
24 import org.eclipse.ui.texteditor.ITextEditor;
25 import org.eclipse.ui.texteditor.RetargetTextEditorAction;
26 import org.eclipse.ui.texteditor.TextEditorAction;
29 * Contributes interesting Java actions to the desktop's Edit menu and the toolbar.
31 public class PHPActionContributor extends TextEditorActionContributor {
33 protected RetargetTextEditorAction fContentAssistProposal;
34 protected RetargetTextEditorAction fContentAssistTip;
35 protected TextEditorAction fTogglePresentation;
38 * Default constructor.
40 public PHPActionContributor() {
42 fContentAssistProposal= new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistProposal."); //$NON-NLS-1$
43 fContentAssistTip= new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistTip."); //$NON-NLS-1$
44 fTogglePresentation= new PresentationAction();
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 editor= null;
72 if (part instanceof ITextEditor)
73 editor= (ITextEditor) part;
75 fContentAssistProposal.setAction(getAction(editor, "ContentAssistProposal")); //$NON-NLS-1$
76 fContentAssistTip.setAction(getAction(editor, "ContentAssistTip")); //$NON-NLS-1$
78 fTogglePresentation.setEditor(editor);
79 fTogglePresentation.update();
83 * @see IEditorActionBarContributor#setActiveEditor(IEditorPart)
85 public void setActiveEditor(IEditorPart part) {
86 super.setActiveEditor(part);
87 doSetActiveEditor(part);
91 * @see IEditorActionBarContributor#dispose()
93 public void dispose() {
94 doSetActiveEditor(null);