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 java.util.ResourceBundle;
15 import org.eclipse.core.runtime.CoreException;
16 import org.eclipse.core.runtime.IProgressMonitor;
17 import org.eclipse.jface.action.MenuManager;
18 import org.eclipse.jface.text.source.ISourceViewer;
19 import org.eclipse.ui.IEditorInput;
20 import org.eclipse.ui.editors.text.TextEditor;
21 import org.eclipse.ui.texteditor.DefaultRangeIndicator;
22 import org.eclipse.ui.texteditor.TextOperationAction;
23 import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
26 * Java specific text editor.
28 public class PHPEditor extends TextEditor {
30 /** The outline page */
31 private PHPContentOutlinePage fOutlinePage;
34 * Default constructor.
40 /** The <code>JavaEditor</code> implementation of this
41 * <code>AbstractTextEditor</code> method extend the
42 * actions to add those specific to the receiver
44 protected void createActions() {
45 super.createActions();
46 setAction("ContentAssistProposal", new TextOperationAction(PHPEditorMessages.getResourceBundle(), "ContentAssistProposal.", this, ISourceViewer.CONTENTASSIST_PROPOSALS));
47 setAction("ContentAssistTip", new TextOperationAction(PHPEditorMessages.getResourceBundle(), "ContentAssistTip.", this, ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION));
50 /** The <code>JavaEditor</code> implementation of this
51 * <code>AbstractTextEditor</code> method performs any extra
52 * disposal actions required by the java editor.
54 public void dispose() {
55 PHPEditorEnvironment.disconnect(this);
56 if (fOutlinePage != null)
57 fOutlinePage.setInput(null);
61 /** The <code>JavaEditor</code> implementation of this
62 * <code>AbstractTextEditor</code> method performs any extra
63 * revert behavior required by the java editor.
65 public void doRevertToSaved() {
66 super.doRevertToSaved();
67 if (fOutlinePage != null)
68 fOutlinePage.update();
71 /** The <code>JavaEditor</code> implementation of this
72 * <code>AbstractTextEditor</code> method performs any extra
73 * save behavior required by the java editor.
75 public void doSave(IProgressMonitor monitor) {
76 super.doSave(monitor);
77 if (fOutlinePage != null)
78 fOutlinePage.update();
81 /** The <code>JavaEditor</code> implementation of this
82 * <code>AbstractTextEditor</code> method performs any extra
83 * save as behavior required by the java editor.
85 public void doSaveAs() {
87 if (fOutlinePage != null)
88 fOutlinePage.update();
91 /** The <code>JavaEditor</code> implementation of this
92 * <code>AbstractTextEditor</code> method performs sets the
93 * input of the outline page after AbstractTextEditor has set input.
95 public void doSetInput(IEditorInput input) throws CoreException {
96 super.doSetInput(input);
97 if (fOutlinePage != null)
98 fOutlinePage.setInput(input);
101 /** The <code>JavaEditor</code> implementation of this
102 * <code>AbstractTextEditor</code> method adds any
103 * JavaEditor specific entries.
105 public void editorContextMenuAboutToShow(MenuManager menu) {
106 super.editorContextMenuAboutToShow(menu);
107 addAction(menu, "ContentAssistProposal"); //$NON-NLS-1$
108 addAction(menu, "ContentAssistTip"); //$NON-NLS-1$
111 /** The <code>JavaEditor</code> implementation of this
112 * <code>AbstractTextEditor</code> method performs gets
113 * the java content outline page if request is for a an
116 public Object getAdapter(Class required) {
117 if (IContentOutlinePage.class.equals(required)) {
118 if (fOutlinePage == null) {
119 fOutlinePage= new PHPContentOutlinePage(getDocumentProvider(), this);
120 if (getEditorInput() != null)
121 fOutlinePage.setInput(getEditorInput());
125 return super.getAdapter(required);
129 * Method declared on AbstractTextEditor
131 protected void initializeEditor() {
133 PHPEditorEnvironment.connect(this);
135 setSourceViewerConfiguration(new PHPSourceViewerConfiguration());
136 setRangeIndicator(new DefaultRangeIndicator());
137 setEditorContextMenuId("#PHPEditorContext"); //$NON-NLS-1$
138 setRulerContextMenuId("#PHPRulerContext"); //$NON-NLS-1$