X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java deleted file mode 100644 index 2608187..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java +++ /dev/null @@ -1,193 +0,0 @@ -package net.sourceforge.phpeclipse.phpeditor; - -/********************************************************************** -Copyright (c) 2000, 2002 IBM Corp. and others. -All rights reserved. This program and the accompanying materials -are made available under the terms of the Common Public License v1.0 -which accompanies this distribution, and is available at -http://www.eclipse.org/legal/cpl-v10.html - -Contributors: - IBM Corporation - Initial implementation - Klaus Hartlage - www.eclipseproject.de -**********************************************************************/ -import net.sourceforge.phpeclipse.phpeditor.php.PHPWordExtractor; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.help.IHelp; -import org.eclipse.help.IHelpResource; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jface.text.source.ISourceViewer; -import org.eclipse.swt.graphics.Point; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.editors.text.TextEditor; -import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.texteditor.DefaultRangeIndicator; -import org.eclipse.ui.texteditor.TextOperationAction; -import org.eclipse.ui.views.contentoutline.IContentOutlinePage; - -/** - * Java specific text editor. - */ -public class PHPEditor extends TextEditor { - - /** The outline page */ - private PHPContentOutlinePage fOutlinePage; - - /** - * Default constructor. - */ - public PHPEditor() { - super(); - } - - /** The JavaEditor implementation of this - * AbstractTextEditor 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 JavaEditor implementation of this - * AbstractTextEditor 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 JavaEditor implementation of this - * AbstractTextEditor method performs any extra - * revert behavior required by the java editor. - */ - public void doRevertToSaved() { - super.doRevertToSaved(); - if (fOutlinePage != null) - fOutlinePage.update(); - } - - /** The JavaEditor implementation of this - * AbstractTextEditor 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 JavaEditor implementation of this - * AbstractTextEditor method performs any extra - * save as behavior required by the java editor. - */ - public void doSaveAs() { - super.doSaveAs(); - if (fOutlinePage != null) - fOutlinePage.update(); - } - - /** The JavaEditor implementation of this - * AbstractTextEditor 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 JavaEditor implementation of this - * AbstractTextEditor 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 JavaEditor implementation of this - * AbstractTextEditor 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); - } - - public void openContextHelp() { - IDocument doc = this.getDocumentProvider().getDocument(this.getEditorInput()); - ITextSelection selection = (ITextSelection) this.getSelectionProvider().getSelection(); - int pos = selection.getOffset(); - String word = getFunctionName(doc, pos); - openContextHelp(word); - } - - private void openContextHelp(String word) { - open(word); - } - - public static void open(String word) { - IHelp help = WorkbenchHelp.getHelpSupport(); - if (help != null) { - IHelpResource helpResource = new PHPFunctionHelpResource(word); - WorkbenchHelp.getHelpSupport().displayHelpResource(helpResource); - } else { - // showMessage(shell, dialogTitle, ActionMessages.getString("Open help not available"), false); //$NON-NLS-1$ - } - } - - private String getFunctionName(IDocument doc, int pos) { - Point word = PHPWordExtractor.findWord(doc, pos); - if (word != null) { - try { - return doc.get(word.x, word.y).replace('_', '-'); - } catch (BadLocationException e) { - } - } - return ""; - } - - /* (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$ - } -}