misc changes
[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.1 2004-09-03 17:31:18 jsurfer 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 /**
29  * HTML editor implementation.
30  */
31 public class SmartyEditor extends XMLEditor {
32
33     public SmartyEditor() {
34       super(ShowExternalPreviewAction.SMARTY_TYPE);
35     }
36         // Instance Variables ------------------------------------------------------
37         
38         /** The associated preview page. */
39 //      private HTMLPreviewPage previewPage;
40
41         // XMLEditor Implementation ------------------------------------------------
42
43
44         /* 
45          * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
46          */
47         public Object getAdapter(Class adapter) {
48 //              if (adapter == IBrowserPreviewPage.class) {
49 //                      if (previewPage == null) {
50 //                              previewPage = createPreviewPage();
51 //                      }
52 //                      return previewPage;
53 //              }
54                 return super.getAdapter(adapter);
55         }
56
57         // Private Methods ---------------------------------------------------------
58
59         /**
60          * Creates the HTML preview page.
61          */
62 //      private HTMLPreviewPage createPreviewPage() {
63 //              IEditorInput input = getEditorInput();
64 //              if (input instanceof IFileEditorInput) {
65 //                      IFile file = ((IFileEditorInput) input).getFile();
66 //                      try {
67 //                              URL location = file.getLocation().toFile().toURL();
68 //                              return new HTMLPreviewPage(location);
69 //                      } catch (MalformedURLException e) { }
70 //              }
71 //              return null;
72 //      }
73         protected void createActions() {
74                 super.createActions();
75
76                 IAction action = new ContentAssistAction(SmartyEditorMessages.getResourceBundle(),
77                 "ContentAssistProposal.", this); //$NON-NLS-1$
78             action
79                 .setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
80             setAction("ContentAssistProposal", action); //$NON-NLS-1$
81             markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$
82             
83 //              IAction action= new TextOperationAction(
84 //                              TemplateMessages.getResourceBundle(),
85 //                              "Editor." + TEMPLATE_PROPOSALS + ".", //$NON-NLS-1$ //$NON-NLS-2$
86 //                              this,
87 //                              ISourceViewer.CONTENTASSIST_PROPOSALS);
88 //              action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
89 //              setAction(TEMPLATE_PROPOSALS, action);
90 //              markAsStateDependentAction(TEMPLATE_PROPOSALS, true);
91         }
92         /*
93          * @see org.eclipse.ui.editors.text.TextEditor#initializeEditor()
94          */
95         protected void initializeEditor() {
96                 super.initializeEditor();
97
98                 XMLTextTools xmlTextTools = XMLPlugin.getDefault().getXMLTextTools();
99                 setSourceViewerConfiguration(new SmartyConfiguration(xmlTextTools, this));
100                 setDocumentProvider(new XMLDocumentProvider());
101         }
102 }