1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others. All rights reserved.
3 * This program and the accompanying materials are made available under the
4 * terms of the Common Public License v1.0 which accompanies this distribution,
5 * and is available at http://www.eclipse.org/legal/cpl-v10.html
7 * Contributors: IBM Corporation - initial API and implementation
8 ******************************************************************************/
9 package net.sourceforge.phpeclipse.phpeditor;
11 import net.sourceforge.phpdt.ui.actions.PHPdtActionConstants;
12 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
14 import org.eclipse.core.resources.IFile;
15 import org.eclipse.jface.action.IAction;
16 import org.eclipse.jface.preference.IPreferenceStore;
17 import org.eclipse.ui.IActionBars;
18 import org.eclipse.ui.IEditorInput;
19 import org.eclipse.ui.IEditorPart;
20 import org.eclipse.ui.IFileEditorInput;
21 import org.eclipse.ui.texteditor.ITextEditor;
23 public class CompilationUnitEditorActionContributor
25 BasicEditorActionContributor {
26 protected ShowExternalPreviewAction fShowExternalPreviewAction;
27 public CompilationUnitEditorActionContributor() {
29 fShowExternalPreviewAction = ShowExternalPreviewAction.getInstance();
33 * @see IEditorActionBarContributor#setActiveEditor(IEditorPart)
35 public void setActiveEditor(IEditorPart part) {
36 super.setActiveEditor(part);
38 ITextEditor textEditor = null;
39 if (part instanceof ITextEditor)
40 textEditor = (ITextEditor) part;
43 IActionBars bars = getActionBars();
44 bars.setGlobalActionHandler(PHPdtActionConstants.COMMENT, getAction(
45 textEditor, "Comment")); //$NON-NLS-1$
46 bars.setGlobalActionHandler(PHPdtActionConstants.UNCOMMENT, getAction(
47 textEditor, "Uncomment")); //$NON-NLS-1$
48 bars.setGlobalActionHandler(PHPdtActionConstants.TOGGLE_COMMENT,
49 getAction(textEditor, "ToggleComment")); //$NON-NLS-1$
50 bars.setGlobalActionHandler(PHPdtActionConstants.FORMAT, getAction(
51 textEditor, "Format")); //$NON-NLS-1$
52 // bars.setGlobalActionHandler(PHPdtActionConstants.ADD_BLOCK_COMMENT,
53 // getAction(textEditor, "AddBlockComment")); //$NON-NLS-1$
54 // bars.setGlobalActionHandler(PHPdtActionConstants.REMOVE_BLOCK_COMMENT,
55 // getAction(textEditor, "RemoveBlockComment")); //$NON-NLS-1$
56 // bars.setGlobalActionHandler(PHPdtActionConstants.INDENT, getAction(
57 // textEditor, "Indent")); //$NON-NLS-1$ //$NON-NLS-2$
59 if (textEditor != null) {
61 IEditorInput editorInput = textEditor.getEditorInput();
63 if (editorInput instanceof IFileEditorInput) {
64 file = ((IFileEditorInput) editorInput).getFile();
67 PHPeclipsePlugin.getDefault().setLastEditorFile(file);
69 fShowExternalPreviewAction.setEditor(textEditor);
70 fShowExternalPreviewAction.update();
71 IPreferenceStore store = PHPeclipsePlugin.getDefault()
72 .getPreferenceStore();
73 IAction a = ShowExternalPreviewAction.getInstance();