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
9 * Christopher Lenz - initial implementation
11 * $Id: SmartyEditor.java,v 1.1 2004-09-03 17:31:18 jsurfer Exp $
14 package net.sourceforge.phpdt.smarty.ui.internal.editor;
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;
23 import org.eclipse.jface.action.IAction;
24 import org.eclipse.ui.texteditor.ContentAssistAction;
25 import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
29 * HTML editor implementation.
31 public class SmartyEditor extends XMLEditor {
33 public SmartyEditor() {
34 super(ShowExternalPreviewAction.SMARTY_TYPE);
36 // Instance Variables ------------------------------------------------------
38 /** The associated preview page. */
39 // private HTMLPreviewPage previewPage;
41 // XMLEditor Implementation ------------------------------------------------
45 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
47 public Object getAdapter(Class adapter) {
48 // if (adapter == IBrowserPreviewPage.class) {
49 // if (previewPage == null) {
50 // previewPage = createPreviewPage();
52 // return previewPage;
54 return super.getAdapter(adapter);
57 // Private Methods ---------------------------------------------------------
60 * Creates the HTML preview page.
62 // private HTMLPreviewPage createPreviewPage() {
63 // IEditorInput input = getEditorInput();
64 // if (input instanceof IFileEditorInput) {
65 // IFile file = ((IFileEditorInput) input).getFile();
67 // URL location = file.getLocation().toFile().toURL();
68 // return new HTMLPreviewPage(location);
69 // } catch (MalformedURLException e) { }
73 protected void createActions() {
74 super.createActions();
76 IAction action = new ContentAssistAction(SmartyEditorMessages.getResourceBundle(),
77 "ContentAssistProposal.", this); //$NON-NLS-1$
79 .setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
80 setAction("ContentAssistProposal", action); //$NON-NLS-1$
81 markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$
83 // IAction action= new TextOperationAction(
84 // TemplateMessages.getResourceBundle(),
85 // "Editor." + TEMPLATE_PROPOSALS + ".", //$NON-NLS-1$ //$NON-NLS-2$
87 // ISourceViewer.CONTENTASSIST_PROPOSALS);
88 // action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
89 // setAction(TEMPLATE_PROPOSALS, action);
90 // markAsStateDependentAction(TEMPLATE_PROPOSALS, true);
93 * @see org.eclipse.ui.editors.text.TextEditor#initializeEditor()
95 protected void initializeEditor() {
96 super.initializeEditor();
98 XMLTextTools xmlTextTools = XMLPlugin.getDefault().getXMLTextTools();
99 setSourceViewerConfiguration(new SmartyConfiguration(xmlTextTools, this));
100 setDocumentProvider(new XMLDocumentProvider());