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.2 2006-10-21 23:19:32 pombredanne 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;
28 * HTML editor implementation.
30 public class SmartyEditor extends XMLEditor {
32 public SmartyEditor() {
33 super(ShowExternalPreviewAction.SMARTY_TYPE);
36 // Instance Variables ------------------------------------------------------
38 /** The associated preview page. */
39 // private HTMLPreviewPage previewPage;
40 // XMLEditor Implementation ------------------------------------------------
43 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
45 public Object getAdapter(Class adapter) {
46 // if (adapter == IBrowserPreviewPage.class) {
47 // if (previewPage == null) {
48 // previewPage = createPreviewPage();
50 // return previewPage;
52 return super.getAdapter(adapter);
55 // Private Methods ---------------------------------------------------------
58 * Creates the HTML preview page.
60 // private HTMLPreviewPage createPreviewPage() {
61 // IEditorInput input = getEditorInput();
62 // if (input instanceof IFileEditorInput) {
63 // IFile file = ((IFileEditorInput) input).getFile();
65 // URL location = file.getLocation().toFile().toURL();
66 // return new HTMLPreviewPage(location);
67 // } catch (MalformedURLException e) { }
71 protected void createActions() {
72 super.createActions();
74 IAction action = new ContentAssistAction(SmartyEditorMessages
75 .getResourceBundle(), "ContentAssistProposal.", this); //$NON-NLS-1$
77 .setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
78 setAction("ContentAssistProposal", action); //$NON-NLS-1$
79 markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$
81 // IAction action= new TextOperationAction(
82 // TemplateMessages.getResourceBundle(),
83 // "Editor." + TEMPLATE_PROPOSALS + ".", //$NON-NLS-1$ //$NON-NLS-2$
85 // ISourceViewer.CONTENTASSIST_PROPOSALS);
86 // action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
87 // setAction(TEMPLATE_PROPOSALS, action);
88 // markAsStateDependentAction(TEMPLATE_PROPOSALS, true);
92 * @see org.eclipse.ui.editors.text.TextEditor#initializeEditor()
94 protected void initializeEditor() {
95 super.initializeEditor();
97 XMLTextTools xmlTextTools = XMLPlugin.getDefault().getXMLTextTools();
98 setSourceViewerConfiguration(new SmartyConfiguration(xmlTextTools, this));
99 setDocumentProvider(new XMLDocumentProvider());