A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse.smarty.ui / src / net / sourceforge / phpdt / smarty / ui / internal / editor / SmartyEditor.java
1 /*
2  * Copyright (c) 2004 Christopher Lenz 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  *     Christopher Lenz - initial implementation
10  * 
11  * $Id: SmartyEditor.java,v 1.2 2006-10-21 23:19:32 pombredanne Exp $
12  */
13
14 package net.sourceforge.phpdt.smarty.ui.internal.editor;
15
16 import net.sourceforge.phpdt.smarty.ui.internal.text.SmartyConfiguration;
17 import net.sourceforge.phpeclipse.ui.editor.ShowExternalPreviewAction;
18 import net.sourceforge.phpeclipse.xml.ui.XMLPlugin;
19 import net.sourceforge.phpeclipse.xml.ui.internal.editor.XMLDocumentProvider;
20 import net.sourceforge.phpeclipse.xml.ui.internal.editor.XMLEditor;
21 import net.sourceforge.phpeclipse.xml.ui.text.XMLTextTools;
22
23 import org.eclipse.jface.action.IAction;
24 import org.eclipse.ui.texteditor.ContentAssistAction;
25 import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
26
27 /**
28  * HTML editor implementation.
29  */
30 public class SmartyEditor extends XMLEditor {
31
32         public SmartyEditor() {
33                 super(ShowExternalPreviewAction.SMARTY_TYPE);
34         }
35
36         // Instance Variables ------------------------------------------------------
37
38         /** The associated preview page. */
39         // private HTMLPreviewPage previewPage;
40         // XMLEditor Implementation ------------------------------------------------
41
42         /*
43          * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
44          */
45         public Object getAdapter(Class adapter) {
46                 // if (adapter == IBrowserPreviewPage.class) {
47                 // if (previewPage == null) {
48                 // previewPage = createPreviewPage();
49                 // }
50                 // return previewPage;
51                 // }
52                 return super.getAdapter(adapter);
53         }
54
55         // Private Methods ---------------------------------------------------------
56
57         /**
58          * Creates the HTML preview page.
59          */
60         // private HTMLPreviewPage createPreviewPage() {
61         // IEditorInput input = getEditorInput();
62         // if (input instanceof IFileEditorInput) {
63         // IFile file = ((IFileEditorInput) input).getFile();
64         // try {
65         // URL location = file.getLocation().toFile().toURL();
66         // return new HTMLPreviewPage(location);
67         // } catch (MalformedURLException e) { }
68         // }
69         // return null;
70         // }
71         protected void createActions() {
72                 super.createActions();
73
74                 IAction action = new ContentAssistAction(SmartyEditorMessages
75                                 .getResourceBundle(), "ContentAssistProposal.", this); //$NON-NLS-1$
76                 action
77                                 .setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
78                 setAction("ContentAssistProposal", action); //$NON-NLS-1$
79                 markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$
80
81                 // IAction action= new TextOperationAction(
82                 // TemplateMessages.getResourceBundle(),
83                 // "Editor." + TEMPLATE_PROPOSALS + ".", //$NON-NLS-1$ //$NON-NLS-2$
84                 // this,
85                 // ISourceViewer.CONTENTASSIST_PROPOSALS);
86                 // action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
87                 // setAction(TEMPLATE_PROPOSALS, action);
88                 // markAsStateDependentAction(TEMPLATE_PROPOSALS, true);
89         }
90
91         /*
92          * @see org.eclipse.ui.editors.text.TextEditor#initializeEditor()
93          */
94         protected void initializeEditor() {
95                 super.initializeEditor();
96
97                 XMLTextTools xmlTextTools = XMLPlugin.getDefault().getXMLTextTools();
98                 setSourceViewerConfiguration(new SmartyConfiguration(xmlTextTools, this));
99                 setDocumentProvider(new XMLDocumentProvider());
100         }
101 }