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
26 BasicTextEditorActionContributor {
31 * @see org.eclipse.ui.IEditorActionBarContributor#setActiveEditor(org.eclipse.ui.IEditorPart)
33 public void setActiveEditor(IEditorPart part) {
34 super.setActiveEditor(part);
35 ITextEditor textEditor = null;
36 if (part instanceof ITextEditor)
37 textEditor = (ITextEditor) part;
39 if (textEditor != null) {
41 IEditorInput editorInput = textEditor.getEditorInput();
43 if (editorInput instanceof IFileEditorInput) {
44 file = ((IFileEditorInput) editorInput).getFile();
47 ShowExternalPreviewAction fShowExternalPreviewAction = ShowExternalPreviewAction
49 fShowExternalPreviewAction.setEditor(textEditor);
50 fShowExternalPreviewAction.update();
51 if (fShowExternalPreviewAction != null)
52 fShowExternalPreviewAction
53 .doRun(ShowExternalPreviewAction.SMARTY_TYPE);