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
index 11cf34f..71ff3fb 100644
--- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java
+++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java
@@ -11,30 +11,38 @@ Contributors:
IBM Corporation - Initial implementation
Klaus Hartlage - www.eclipseproject.de
**********************************************************************/
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+import net.sourceforge.phpeclipse.phpeditor.php.PHPCodeScanner;
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.Action;
+import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextOperationTarget;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
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.ITextEditorActionConstants;
import org.eclipse.ui.texteditor.TextOperationAction;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
-import org.eclipse.jface.action.IAction;
/**
* Java specific text editor.
*/
public class PHPEditor extends TextEditor {
+ protected PHPActionGroup actionGroup;
/** The outline page */
private PHPContentOutlinePage fOutlinePage;
@@ -65,6 +73,17 @@ public class PHPEditor extends TextEditor {
"ContentAssistTip.",
this,
ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION));
+
+ Action action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "Comment.", this, ITextOperationTarget.PREFIX);
+ action.setActionDefinitionId(PHPEditorActionDefinitionIds.COMMENT);
+ setAction("Comment", action);
+
+ action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "Uncomment.", this, ITextOperationTarget.STRIP_PREFIX);
+ action.setActionDefinitionId(PHPEditorActionDefinitionIds.UNCOMMENT);
+ setAction("Uncomment", action);
+
+ actionGroup = new PHPActionGroup(this, ITextEditorActionConstants.GROUP_EDIT);
+
}
/** The JavaEditor
implementation of this
@@ -78,9 +97,9 @@ public class PHPEditor extends TextEditor {
super.dispose();
}
- /** The JavaEditor
implementation of this
+ /** The PHPEditor
implementation of this
* AbstractTextEditor
method performs any extra
- * revert behavior required by the java editor.
+ * revert behavior required by the php editor.
*/
public void doRevertToSaved() {
super.doRevertToSaved();
@@ -88,23 +107,26 @@ public class PHPEditor extends TextEditor {
fOutlinePage.update();
}
- /** The JavaEditor
implementation of this
+ /** The PHPEditor
implementation of this
* AbstractTextEditor
method performs any extra
- * save behavior required by the java editor.
+ * save behavior required by the php editor.
*/
public void doSave(IProgressMonitor monitor) {
super.doSave(monitor);
// compile or not, according to the user preferences
- IAction a = PHPParserAction.getInstance();
- if (a != null)
- a.run();
+ IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
+ if (store.getBoolean(PHPeclipsePlugin.PHP_PARSE_ON_SAVE)) {
+ IAction a = PHPParserAction.getInstance();
+ if (a != null)
+ a.run();
+ }
if (fOutlinePage != null)
fOutlinePage.update();
}
- /** The JavaEditor
implementation of this
+ /** The PHPEditor
implementation of this
* AbstractTextEditor
method performs any extra
- * save as behavior required by the java editor.
+ * save as behavior required by the php editor.
*/
public void doSaveAs() {
super.doSaveAs();
@@ -112,7 +134,7 @@ public class PHPEditor extends TextEditor {
fOutlinePage.update();
}
- /** The JavaEditor
implementation of this
+ /** The PHPEditor
implementation of this
* AbstractTextEditor
method performs sets the
* input of the outline page after AbstractTextEditor has set input.
*/
@@ -128,8 +150,9 @@ public class PHPEditor extends TextEditor {
*/
public void editorContextMenuAboutToShow(MenuManager menu) {
super.editorContextMenuAboutToShow(menu);
- addAction(menu, "ContentAssistProposal"); //$NON-NLS-1$
- addAction(menu, "ContentAssistTip"); //$NON-NLS-1$
+ // addAction(menu, "ContentAssistProposal"); //$NON-NLS-1$
+ // addAction(menu, "ContentAssistTip"); //$NON-NLS-1$
+ actionGroup.fillContextMenu(menu);
}
/** The JavaEditor
implementation of this
@@ -193,5 +216,18 @@ public class PHPEditor extends TextEditor {
setRangeIndicator(new DefaultRangeIndicator());
setEditorContextMenuId("#PHPEditorContext"); //$NON-NLS-1$
setRulerContextMenuId("#PHPRulerContext"); //$NON-NLS-1$
+ // setDocumentProvider(PHPeclipsePlugin.getCompilationUnitDocumentProvider());
+
+ PHPeclipsePlugin.getDefault().getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ PHPCodeScanner scanner = PHPEditorEnvironment.getPHPCodeScanner();
+ if (scanner != null) {
+ scanner.updateToken(PHPEditorEnvironment.getPHPColorProvider());
+ }
+ if (getSourceViewer() != null) {
+ getSourceViewer().invalidateTextPresentation();
+ }
+ }
+ });
}
}