1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.smarty.ui.internal.editor;
13 import net.sourceforge.phpeclipse.ui.editor.ShowExternalPreviewAction;
15 import org.eclipse.core.resources.IFile;
16 import org.eclipse.ui.IEditorInput;
17 import org.eclipse.ui.IEditorPart;
18 import org.eclipse.ui.IFileEditorInput;
19 import org.eclipse.ui.texteditor.BasicTextEditorActionContributor;
20 import org.eclipse.ui.texteditor.ITextEditor;
23 * Common base class for action contributors for Java editors.
25 public class SmartyEditorActionContributor extends BasicTextEditorActionContributor {
28 * @see org.eclipse.ui.IEditorActionBarContributor#setActiveEditor(org.eclipse.ui.IEditorPart)
30 public void setActiveEditor(IEditorPart part) {
31 super.setActiveEditor(part);
32 ITextEditor textEditor = null;
33 if (part instanceof ITextEditor)
34 textEditor = (ITextEditor) part;
36 if (textEditor != null) {
38 IEditorInput editorInput = textEditor.getEditorInput();
40 if (editorInput instanceof IFileEditorInput) {
41 file = ((IFileEditorInput) editorInput).getFile();
44 ShowExternalPreviewAction fShowExternalPreviewAction = ShowExternalPreviewAction.getInstance();
45 fShowExternalPreviewAction.setEditor(textEditor);
46 fShowExternalPreviewAction.update();
47 if (fShowExternalPreviewAction != null)
48 fShowExternalPreviewAction.doRun(ShowExternalPreviewAction.SMARTY_TYPE);