IBM Corporation - Initial implementation
Klaus Hartlage - www.eclipseproject.de
**********************************************************************/
-import java.util.ResourceBundle;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.MenuManager;
*/
public class PHPEditor extends TextEditor {
- /** The outline page */
- private PHPContentOutlinePage fOutlinePage;
-
- /**
- * Default constructor.
- */
- public PHPEditor() {
- super();
- }
-
- /** The <code>JavaEditor</code> implementation of this
- * <code>AbstractTextEditor</code> method extend the
- * actions to add those specific to the receiver
- */
- protected void createActions() {
- super.createActions();
- setAction("ContentAssistProposal", new TextOperationAction(PHPEditorMessages.getResourceBundle(), "ContentAssistProposal.", this, ISourceViewer.CONTENTASSIST_PROPOSALS));
- setAction("ContentAssistTip", new TextOperationAction(PHPEditorMessages.getResourceBundle(), "ContentAssistTip.", this, ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION));
- }
-
- /** The <code>JavaEditor</code> implementation of this
- * <code>AbstractTextEditor</code> method performs any extra
- * disposal actions required by the java editor.
- */
- public void dispose() {
- PHPEditorEnvironment.disconnect(this);
- if (fOutlinePage != null)
- fOutlinePage.setInput(null);
- super.dispose();
- }
-
- /** The <code>JavaEditor</code> implementation of this
- * <code>AbstractTextEditor</code> method performs any extra
- * revert behavior required by the java editor.
- */
- public void doRevertToSaved() {
- super.doRevertToSaved();
- if (fOutlinePage != null)
- fOutlinePage.update();
- }
-
- /** The <code>JavaEditor</code> implementation of this
- * <code>AbstractTextEditor</code> method performs any extra
- * save behavior required by the java editor.
- */
- public void doSave(IProgressMonitor monitor) {
- super.doSave(monitor);
- if (fOutlinePage != null)
- fOutlinePage.update();
- }
-
- /** The <code>JavaEditor</code> implementation of this
- * <code>AbstractTextEditor</code> method performs any extra
- * save as behavior required by the java editor.
- */
- public void doSaveAs() {
- super.doSaveAs();
- if (fOutlinePage != null)
- fOutlinePage.update();
- }
-
- /** The <code>JavaEditor</code> implementation of this
- * <code>AbstractTextEditor</code> method performs sets the
- * input of the outline page after AbstractTextEditor has set input.
- */
- public void doSetInput(IEditorInput input) throws CoreException {
- super.doSetInput(input);
- if (fOutlinePage != null)
- fOutlinePage.setInput(input);
- }
-
- /** The <code>JavaEditor</code> implementation of this
- * <code>AbstractTextEditor</code> method adds any
- * JavaEditor specific entries.
- */
- public void editorContextMenuAboutToShow(MenuManager menu) {
- super.editorContextMenuAboutToShow(menu);
- addAction(menu, "ContentAssistProposal"); //$NON-NLS-1$
- addAction(menu, "ContentAssistTip"); //$NON-NLS-1$
- }
-
- /** The <code>JavaEditor</code> implementation of this
- * <code>AbstractTextEditor</code> method performs gets
- * the java content outline page if request is for a an
- * outline page.
- */
- public Object getAdapter(Class required) {
- if (IContentOutlinePage.class.equals(required)) {
- if (fOutlinePage == null) {
- fOutlinePage= new PHPContentOutlinePage(getDocumentProvider(), this);
- if (getEditorInput() != null)
- fOutlinePage.setInput(getEditorInput());
- }
- return fOutlinePage;
- }
- return super.getAdapter(required);
- }
-
- /* (non-Javadoc)
- * Method declared on AbstractTextEditor
- */
- protected void initializeEditor() {
-
- PHPEditorEnvironment.connect(this);
-
- setSourceViewerConfiguration(new PHPSourceViewerConfiguration());
- setRangeIndicator(new DefaultRangeIndicator());
- setEditorContextMenuId("#PHPEditorContext"); //$NON-NLS-1$
- setRulerContextMenuId("#PHPRulerContext"); //$NON-NLS-1$
- }
+ /** The outline page */
+ private PHPContentOutlinePage fOutlinePage;
+
+ /**
+ * Default constructor.
+ */
+ public PHPEditor() {
+ super();
+ }
+
+ /** The <code>JavaEditor</code> implementation of this
+ * <code>AbstractTextEditor</code> method extend the
+ * actions to add those specific to the receiver
+ */
+ protected void createActions() {
+ super.createActions();
+ setAction(
+ "ContentAssistProposal",
+ new TextOperationAction(
+ PHPEditorMessages.getResourceBundle(),
+ "ContentAssistProposal.",
+ this,
+ ISourceViewer.CONTENTASSIST_PROPOSALS));
+ setAction(
+ "ContentAssistTip",
+ new TextOperationAction(
+ PHPEditorMessages.getResourceBundle(),
+ "ContentAssistTip.",
+ this,
+ ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION));
+ }
+
+ /** The <code>JavaEditor</code> implementation of this
+ * <code>AbstractTextEditor</code> method performs any extra
+ * disposal actions required by the java editor.
+ */
+ public void dispose() {
+ PHPEditorEnvironment.disconnect(this);
+ if (fOutlinePage != null)
+ fOutlinePage.setInput(null);
+ super.dispose();
+ }
+
+ /** The <code>JavaEditor</code> implementation of this
+ * <code>AbstractTextEditor</code> method performs any extra
+ * revert behavior required by the java editor.
+ */
+ public void doRevertToSaved() {
+ super.doRevertToSaved();
+ if (fOutlinePage != null)
+ fOutlinePage.update();
+ }
+
+ /** The <code>JavaEditor</code> implementation of this
+ * <code>AbstractTextEditor</code> method performs any extra
+ * save behavior required by the java editor.
+ */
+ public void doSave(IProgressMonitor monitor) {
+ super.doSave(monitor);
+ if (fOutlinePage != null)
+ fOutlinePage.update();
+ }
+
+ /** The <code>JavaEditor</code> implementation of this
+ * <code>AbstractTextEditor</code> method performs any extra
+ * save as behavior required by the java editor.
+ */
+ public void doSaveAs() {
+ super.doSaveAs();
+ if (fOutlinePage != null)
+ fOutlinePage.update();
+ }
+
+ /** The <code>JavaEditor</code> implementation of this
+ * <code>AbstractTextEditor</code> method performs sets the
+ * input of the outline page after AbstractTextEditor has set input.
+ */
+ public void doSetInput(IEditorInput input) throws CoreException {
+ super.doSetInput(input);
+ if (fOutlinePage != null)
+ fOutlinePage.setInput(input);
+ }
+
+ /** The <code>JavaEditor</code> implementation of this
+ * <code>AbstractTextEditor</code> method adds any
+ * JavaEditor specific entries.
+ */
+ public void editorContextMenuAboutToShow(MenuManager menu) {
+ super.editorContextMenuAboutToShow(menu);
+ addAction(menu, "ContentAssistProposal"); //$NON-NLS-1$
+ addAction(menu, "ContentAssistTip"); //$NON-NLS-1$
+ }
+
+ /** The <code>JavaEditor</code> implementation of this
+ * <code>AbstractTextEditor</code> method performs gets
+ * the java content outline page if request is for a an
+ * outline page.
+ */
+ public Object getAdapter(Class required) {
+ if (IContentOutlinePage.class.equals(required)) {
+ if (fOutlinePage == null) {
+ fOutlinePage = new PHPContentOutlinePage(getDocumentProvider(), this);
+ if (getEditorInput() != null)
+ fOutlinePage.setInput(getEditorInput());
+ }
+ return fOutlinePage;
+ }
+ return super.getAdapter(required);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on AbstractTextEditor
+ */
+ protected void initializeEditor() {
+
+ PHPEditorEnvironment.connect(this);
+
+ setSourceViewerConfiguration(new PHPSourceViewerConfiguration());
+ setRangeIndicator(new DefaultRangeIndicator());
+ setEditorContextMenuId("#PHPEditorContext"); //$NON-NLS-1$
+ setRulerContextMenuId("#PHPRulerContext"); //$NON-NLS-1$
+ }
}