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: HTMLEditor.java,v 1.2 2004-09-03 17:32:25 jsurfer Exp $
14 package net.sourceforge.phpeclipse.html.ui.internal.editor;
16 import net.sourceforge.phpeclipse.html.ui.internal.text.HTMLConfiguration;
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 HTMLEditor extends XMLEditor {
33 // Instance Variables ------------------------------------------------------
35 super(ShowExternalPreviewAction.HTML_TYPE);
37 /** The associated preview page. */
38 // private HTMLPreviewPage previewPage;
40 // XMLEditor Implementation ------------------------------------------------
43 * @see org.eclipse.ui.texteditor.AbstractTextEditor#editorSaved()
45 // protected void editorSaved() {
46 // if (previewPage != null) {
47 // previewPage.update();
52 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
54 public Object getAdapter(Class adapter) {
55 // if (adapter == IBrowserPreviewPage.class) {
56 // if (previewPage == null) {
57 // previewPage = createPreviewPage();
59 // return previewPage;
61 return super.getAdapter(adapter);
64 // Private Methods ---------------------------------------------------------
67 * Creates the HTML preview page.
69 // private HTMLPreviewPage createPreviewPage() {
70 // IEditorInput input = getEditorInput();
71 // if (input instanceof IFileEditorInput) {
72 // IFile file = ((IFileEditorInput) input).getFile();
74 // URL location = file.getLocation().toFile().toURL();
75 // return new HTMLPreviewPage(location);
76 // } catch (MalformedURLException e) { }
80 protected void createActions() {
81 super.createActions();
83 IAction action = new ContentAssistAction(HTMLEditorMessages.getResourceBundle(),
84 "ContentAssistProposal.", this); //$NON-NLS-1$
86 .setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
87 setAction("ContentAssistProposal", action); //$NON-NLS-1$
88 markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$
90 // IAction action= new TextOperationAction(
91 // TemplateMessages.getResourceBundle(),
92 // "Editor." + TEMPLATE_PROPOSALS + ".", //$NON-NLS-1$ //$NON-NLS-2$
94 // ISourceViewer.CONTENTASSIST_PROPOSALS);
95 // action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
96 // setAction(TEMPLATE_PROPOSALS, action);
97 // markAsStateDependentAction(TEMPLATE_PROPOSALS, true);
100 * @see org.eclipse.ui.editors.text.TextEditor#initializeEditor()
102 protected void initializeEditor() {
103 super.initializeEditor();
105 XMLTextTools xmlTextTools = XMLPlugin.getDefault().getXMLTextTools();
106 setSourceViewerConfiguration(new HTMLConfiguration(xmlTextTools, this));
107 setDocumentProvider(new XMLDocumentProvider());