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