e62f2031ab007e1e3b17f27561f6768429ee7273
[phpeclipse.git] / net.sourceforge.phpeclipse.ui / src / net / sourceforge / phpeclipse / xml / ui / internal / editor / XMLEditorActionContributor.java
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
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpeclipse.xml.ui.internal.editor;
12
13 import net.sourceforge.phpeclipse.ui.editor.ShowExternalPreviewAction;
14
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;
21
22 /**
23  * Common base class for action contributors for Java editors.
24  */
25 public class XMLEditorActionContributor extends
26                 BasicTextEditorActionContributor {
27
28         /*
29          * (non-Javadoc)
30          * 
31          * @see org.eclipse.ui.IEditorActionBarContributor#setActiveEditor(org.eclipse.ui.IEditorPart)
32          */
33         public void setActiveEditor(IEditorPart part) {
34                 super.setActiveEditor(part);
35                 ITextEditor textEditor = null;
36                 if (part instanceof ITextEditor)
37                         textEditor = (ITextEditor) part;
38
39                 if (textEditor != null) {
40                         //IFile file = null;
41                         //IEditorInput editorInput = textEditor.getEditorInput();
42
43 //                      if (editorInput instanceof IFileEditorInput) {
44 //                              file = ((IFileEditorInput) editorInput).getFile();
45 //                      }
46
47                         ShowExternalPreviewAction fShowExternalPreviewAction = ShowExternalPreviewAction
48                                         .getInstance();
49                         fShowExternalPreviewAction.setEditor(textEditor);
50                         fShowExternalPreviewAction.update();
51                         if (fShowExternalPreviewAction != null)
52                                 fShowExternalPreviewAction
53                                                 .doRun(ShowExternalPreviewAction.PHP_TYPE);
54                 }
55         }
56 }