1 package net.sourceforge.phpeclipse.phpeditor;
3 /**********************************************************************
4 Copyright (c) 2000, 2002 IBM Corp. and others.
5 All rights reserved. This program and the accompanying materials
6 are made available under the terms of the Common Public License v1.0
7 which accompanies this distribution, and is available at
8 http://www.eclipse.org/legal/cpl-v10.html
11 IBM Corporation - Initial implementation
12 Klaus Hartlage - www.eclipseproject.de
13 **********************************************************************/
14 import org.eclipse.core.runtime.CoreException;
15 import org.eclipse.core.runtime.IProgressMonitor;
16 import org.eclipse.jface.action.MenuManager;
17 import org.eclipse.jface.text.source.ISourceViewer;
18 import org.eclipse.ui.IEditorInput;
19 import org.eclipse.ui.editors.text.TextEditor;
20 import org.eclipse.ui.texteditor.DefaultRangeIndicator;
21 import org.eclipse.ui.texteditor.TextOperationAction;
22 import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
25 * Java specific text editor.
27 public class PHPEditor extends TextEditor {
29 /** The outline page */
30 private PHPContentOutlinePage fOutlinePage;
33 * Default constructor.
39 /** The <code>JavaEditor</code> implementation of this
40 * <code>AbstractTextEditor</code> method extend the
41 * actions to add those specific to the receiver
43 protected void createActions() {
44 super.createActions();
46 "ContentAssistProposal",
47 new TextOperationAction(
48 PHPEditorMessages.getResourceBundle(),
49 "ContentAssistProposal.",
51 ISourceViewer.CONTENTASSIST_PROPOSALS));
54 new TextOperationAction(
55 PHPEditorMessages.getResourceBundle(),
58 ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION));
61 /** The <code>JavaEditor</code> implementation of this
62 * <code>AbstractTextEditor</code> method performs any extra
63 * disposal actions required by the java editor.
65 public void dispose() {
66 PHPEditorEnvironment.disconnect(this);
67 if (fOutlinePage != null)
68 fOutlinePage.setInput(null);
72 /** The <code>JavaEditor</code> implementation of this
73 * <code>AbstractTextEditor</code> method performs any extra
74 * revert behavior required by the java editor.
76 public void doRevertToSaved() {
77 super.doRevertToSaved();
78 if (fOutlinePage != null)
79 fOutlinePage.update();
82 /** The <code>JavaEditor</code> implementation of this
83 * <code>AbstractTextEditor</code> method performs any extra
84 * save behavior required by the java editor.
86 public void doSave(IProgressMonitor monitor) {
87 super.doSave(monitor);
88 if (fOutlinePage != null)
89 fOutlinePage.update();
92 /** The <code>JavaEditor</code> implementation of this
93 * <code>AbstractTextEditor</code> method performs any extra
94 * save as behavior required by the java editor.
96 public void doSaveAs() {
98 if (fOutlinePage != null)
99 fOutlinePage.update();
102 /** The <code>JavaEditor</code> implementation of this
103 * <code>AbstractTextEditor</code> method performs sets the
104 * input of the outline page after AbstractTextEditor has set input.
106 public void doSetInput(IEditorInput input) throws CoreException {
107 super.doSetInput(input);
108 if (fOutlinePage != null)
109 fOutlinePage.setInput(input);
112 /** The <code>JavaEditor</code> implementation of this
113 * <code>AbstractTextEditor</code> method adds any
114 * JavaEditor specific entries.
116 public void editorContextMenuAboutToShow(MenuManager menu) {
117 super.editorContextMenuAboutToShow(menu);
118 addAction(menu, "ContentAssistProposal"); //$NON-NLS-1$
119 addAction(menu, "ContentAssistTip"); //$NON-NLS-1$
122 /** The <code>JavaEditor</code> implementation of this
123 * <code>AbstractTextEditor</code> method performs gets
124 * the java content outline page if request is for a an
127 public Object getAdapter(Class required) {
128 if (IContentOutlinePage.class.equals(required)) {
129 if (fOutlinePage == null) {
130 fOutlinePage = new PHPContentOutlinePage(getDocumentProvider(), this);
131 if (getEditorInput() != null)
132 fOutlinePage.setInput(getEditorInput());
136 return super.getAdapter(required);
140 * Method declared on AbstractTextEditor
142 protected void initializeEditor() {
144 PHPEditorEnvironment.connect(this);
146 setSourceViewerConfiguration(new PHPSourceViewerConfiguration());
147 setRangeIndicator(new DefaultRangeIndicator());
148 setEditorContextMenuId("#PHPEditorContext"); //$NON-NLS-1$
149 setRulerContextMenuId("#PHPRulerContext"); //$NON-NLS-1$