43f76d79e0c73aa067b3803ac805b82297e0764f
[phpeclipse.git] / net.sourceforge.phpeclipse.ui / src / net / sourceforge / phpeclipse / xml / ui / internal / editor / DTDEditor.java
1 /*
2  * Copyright (c) 2002-2004 Widespace, OU 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  *     Igor Malinin - initial contribution
10  *
11  * $Id: DTDEditor.java,v 1.3 2006-10-21 23:14:14 pombredanne Exp $
12  */
13
14 package net.sourceforge.phpeclipse.xml.ui.internal.editor;
15
16 import net.sourceforge.phpeclipse.xml.ui.XMLPlugin;
17 import net.sourceforge.phpeclipse.xml.ui.internal.text.DTDConfiguration;
18 import net.sourceforge.phpeclipse.xml.ui.internal.text.DTDDocumentProvider;
19 import net.sourceforge.phpeclipse.xml.ui.text.DTDTextTools;
20
21 import org.eclipse.jface.action.IAction;
22 import org.eclipse.jface.util.PropertyChangeEvent;
23 import org.eclipse.ui.editors.text.TextEditor;
24 import org.eclipse.ui.texteditor.ContentAssistAction;
25 import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
26
27 /**
28  * DTD Editor.
29  * 
30  * @author Igor Malinin
31  */
32 public class DTDEditor extends TextEditor {
33
34         public DTDEditor() {
35                 setPreferenceStore(XMLPlugin.getDefault().getPreferenceStore());
36         }
37
38         /*
39          * @see org.eclipse.ui.editors.text.TextEditor#initializeEditor()
40          */
41         protected void initializeEditor() {
42                 super.initializeEditor();
43
44                 DTDTextTools dtdTextTools = XMLPlugin.getDefault().getDTDTextTools();
45
46                 setSourceViewerConfiguration(new DTDConfiguration(dtdTextTools));
47
48                 setDocumentProvider(new DTDDocumentProvider());
49         }
50
51         protected boolean affectsTextPresentation(PropertyChangeEvent event) {
52                 return XMLPlugin.getDefault().getDTDTextTools().affectsBehavior(event);
53         }
54
55         protected void createActions() {
56                 super.createActions();
57
58                 IAction action = new ContentAssistAction(XMLEditorMessages
59                                 .getResourceBundle(), "ContentAssistProposal.", this); //$NON-NLS-1$
60                 action
61                                 .setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
62                 setAction("ContentAssistProposal", action); //$NON-NLS-1$
63                 markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$
64
65                 // IAction action= new TextOperationAction(
66                 // TemplateMessages.getResourceBundle(),
67                 // "Editor." + TEMPLATE_PROPOSALS + ".", //$NON-NLS-1$ //$NON-NLS-2$
68                 // this,
69                 // ISourceViewer.CONTENTASSIST_PROPOSALS);
70                 // action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
71                 // setAction(TEMPLATE_PROPOSALS, action);
72                 // markAsStateDependentAction(TEMPLATE_PROPOSALS, true);
73         }
74 }