ExternalizeStringsAction.label= &Externalize Strings...
-ConvertLineDelimitersActions.label= Co&nvert Line Delimiters
-ConvertLineDelimitersToWindowsAction.label= To &Windows
-ConvertLineDelimitersToUNIXAction.label= To &UNIX
-ConvertLineDelimitersToMacAction.label= To &Mac
+ConvertLineDelimitersActions.label= Co&nvert Line Delimiters To
+ConvertLineDelimitersToWindowsAction.label= &Windows
+ConvertLineDelimitersToUNIXAction.label= &UNIX
+ConvertLineDelimitersToMacAction.label= &Mac
##########################################################################
# Javadoc Support
</actionSet>
<actionSet
label="%CodingActionSet.label"
+ description="%CodingActionSet.description"
visible="false"
id="net.sourceforge.phpeclipse.ui.CodingActionSet">
<!-- =========================================================================== -->
label="%SourceMenu.label"
path="edit"
id="net.sourceforge.phpeclipse.ui.source.menu">
- <separator name="editGroup" />
+ <separator
+ name="editGroup">
+ </separator>
+ <separator
+ name="convertGroup">
+ </separator>
</menu>
<action
definitionId="net.sourceforge.phpeclipse.phpeditor.format"
menubarPath="net.sourceforge.phpeclipse.ui.source.menu/editGroup"
id="net.sourceforge.phpeclipse.phpeditor.ShiftRight">
</action>
+ <action
+ definitionId="net.sourceforge.phpeclipse.remove.block.comment"
+ label="%RemoveBlockCommentAction.label"
+ retarget="true"
+ menubarPath="net.sourceforge.phpeclipse.ui.source.menu/editGroup"
+ id="net.sourceforge.phpeclipse.ui.actions.RemoveBlockComment">
+ </action>
+ <action
+ definitionId="net.sourceforge.phpeclipse.add.block.comment"
+ label="%AddBlockCommentAction.label"
+ retarget="true"
+ menubarPath="net.sourceforge.phpeclipse.ui.source.menu/editGroup"
+ id="net.sourceforge.phpeclipse.ui.actions.AddBlockComment">
+ </action>
+ <action
+ definitionId="net.sourceforge.phpeclipse.toggle.comment"
+ label="%ToggleCommentAction.label"
+ retarget="true"
+ menubarPath="net.sourceforge.phpeclipse.ui.source.menu/editGroup"
+ id="net.sourceforge.phpeclipse.ui.actions.ToggleComment">
+ </action>
<action
definitionId="net.sourceforge.phpeclipse.phpeditor.uncomment"
label="%UncommentAction.label"
menubarPath="net.sourceforge.phpeclipse.ui.source.menu/editGroup"
id="net.sourceforge.phpeclipse.phpeditor.Comment">
</action>
+<!-- convert group -->
+ <menu
+ label="%ConvertLineDelimitersActions.label"
+ path="net.sourceforge.phpeclipse.ui.source.menu/convertGroup"
+ id="convertSubMenu">
+ <separator
+ name="group1">
+ </separator>
+ </menu>
+ <action
+ label="%ConvertLineDelimitersToMacAction.label"
+ retarget="true"
+ menubarPath="net.sourceforge.phpeclipse.ui.source.menu/convertSubMenu/group1"
+ allowLabelUpdate="true"
+ id="net.sourceforge.phpeclipse.ui.actions.ConvertLineDelimitersToMac">
+ </action>
+ <action
+ label="%ConvertLineDelimitersToUNIXAction.label"
+ retarget="true"
+ menubarPath="net.sourceforge.phpeclipse.ui.source.menu/convertSubMenu/group1"
+ allowLabelUpdate="true"
+ id="net.sourceforge.phpeclipse.ui.actions.ConvertLineDelimitersToUNIX">
+ </action>
+ <action
+ label="%ConvertLineDelimitersToWindowsAction.label"
+ retarget="true"
+ menubarPath="net.sourceforge.phpeclipse.ui.source.menu/convertSubMenu/group1"
+ allowLabelUpdate="true"
+ id="net.sourceforge.phpeclipse.ui.actions.ConvertLineDelimitersToWindows">
+ </action>
</actionSet>
</extension>
<extension
</action>
</viewerContribution>
</extension>
+ <!-- =========================================================================== -->
+<!-- JDT/UI command definitions -->
+<!-- =========================================================================== -->
+ <extension
+ point="org.eclipse.ui.commands">
+ <category
+ name="%category.source.name"
+ description="%category.source.description"
+ id="net.sourceforge.phpeclipse.ui.category.source">
+ </category>
+ <command
+ name="%ActionDefinition.showJavadoc.name"
+ description="%ActionDefinition.showJavadoc.description"
+ category="org.eclipse.ui.category.edit"
+ id="net.sourceforge.phpeclipse.show.javadoc">
+ </command>
+ <keyBinding
+ string="F2"
+ scope="net.sourceforge.phpdt.ui.phpEditorScope"
+ command="net.sourceforge.phpeclipse.show.javadoc"
+ configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+ </keyBinding>
+
+ <!-- source -->
+ <command
+ name="%ActionDefinition.comment.name"
+ description="%ActionDefinition.comment.description"
+ category="net.sourceforge.phpeclipse.ui.category.source"
+ id="net.sourceforge.phpeclipse.phpeditor.comment">
+ </command>
+ <command
+ name="%ActionDefinition.uncomment.name"
+ description="%ActionDefinition.uncomment.description"
+ category="net.sourceforge.phpeclipse.ui.category.source"
+ id="net.sourceforge.phpeclipse.phpeditor.uncomment">
+ </command>
+ <command
+ name="%ActionDefinition.toggleComment.name"
+ description="%ActionDefinition.toggleComment.description"
+ category="net.sourceforge.phpeclipse.ui.category.source"
+ id="net.sourceforge.phpeclipse.toggle.comment">
+ </command>
+ <keyBinding
+ string="Ctrl+Shift+C"
+ scope="net.sourceforge.phpdt.ui.phpEditorScope"
+ command="net.sourceforge.phpeclipse.toggle.comment"
+ configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+ </keyBinding>
+ <keyBinding
+ platform="carbon"
+ string="Ctrl+Shift+C"
+ scope="net.sourceforge.phpdt.ui.phpEditorScope"
+ command=""
+ configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+ </keyBinding>
+ <keyBinding
+ platform="carbon"
+ string="Command+Shift+C"
+ scope="net.sourceforge.phpdt.ui.phpEditorScope"
+ command="net.sourceforge.phpeclipse.toggle.comment"
+ configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+ </keyBinding>
+ <keyBinding
+ platform="gtk"
+ string="Ctrl+Shift+C"
+ scope="net.sourceforge.phpdt.ui.phpEditorScope"
+ command=""
+ configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+ </keyBinding>
+ <keyBinding
+ platform="gtk"
+ string="Esc Ctrl+C"
+ scope="net.sourceforge.phpdt.ui.phpEditorScope"
+ command="net.sourceforge.phpeclipse.toggle.comment"
+ configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+ </keyBinding>
+ <command
+ name="%ActionDefinition.format.name"
+ description="%ActionDefinition.format.description"
+ category="net.sourceforge.phpeclipse.ui.category.source"
+ id="net.sourceforge.phpeclipse.phpeditor.format">
+ </command>
+ <keyBinding
+ string="Ctrl+Shift+F"
+ scope="net.sourceforge.phpdt.ui.phpEditorScope"
+ command="net.sourceforge.phpeclipse.phpeditor.format"
+ configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+ </keyBinding>
+ <keyBinding
+ platform="carbon"
+ string="Ctrl+Shift+F"
+ scope="net.sourceforge.phpdt.ui.phpEditorScope"
+ command=""
+ configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+ </keyBinding>
+ <keyBinding
+ platform="carbon"
+ string="Command+Shift+F"
+ scope="net.sourceforge.phpdt.ui.phpEditorScope"
+ command="net.sourceforge.phpeclipse.phpeditor.format"
+ configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+ </keyBinding>
+ <keyBinding
+ platform="gtk"
+ string="Ctrl+Shift+F"
+ scope="net.sourceforge.phpdt.ui.phpEditorScope"
+ command=""
+ configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+ </keyBinding>
+ <keyBinding
+ platform="gtk"
+ string="Esc Ctrl+F"
+ scope="net.sourceforge.phpdt.ui.phpEditorScope"
+ command="net.sourceforge.phpeclipse.phpeditor.format"
+ configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+ </keyBinding>
+ </extension>
<extension
point="org.eclipse.ui.preferencePages">
<page
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation 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 API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.actions;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ResourceBundle;
+
+import net.sourceforge.phpdt.internal.corext.Assert;
+import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.BadPartitioningException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentExtension3;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+/**
+ * Action that encloses the editor's current selection with Java block comment terminators
+ * (<code>/*</code> and <code>*/</code>).
+ *
+ * @since 3.0
+ */
+public class AddBlockCommentAction extends BlockCommentAction {
+
+ /**
+ * Creates a new instance.
+ *
+ * @param bundle the resource bundle
+ * @param prefix a prefix to be prepended to the various resource keys
+ * (described in <code>ResourceAction</code> constructor), or
+ * <code>null</code> if none
+ * @param editor the text editor
+ */
+ public AddBlockCommentAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
+ super(bundle, prefix, editor);
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.actions.BlockCommentAction#runInternal(org.eclipse.jface.text.ITextSelection, org.eclipse.jface.text.IDocumentExtension3, org.eclipse.jdt.internal.ui.actions.BlockCommentAction.Edit.EditFactory)
+ */
+ protected void runInternal(ITextSelection selection, IDocumentExtension3 docExtension, Edit.EditFactory factory) throws BadLocationException, BadPartitioningException {
+ int selectionOffset= selection.getOffset();
+ int selectionEndOffset= selectionOffset + selection.getLength();
+ List edits= new LinkedList();
+ ITypedRegion partition= docExtension.getPartition(IPHPPartitions.PHP_PARTITIONING, selectionOffset);
+
+ handleFirstPartition(partition, edits, factory, selectionOffset);
+
+ while (partition.getOffset() + partition.getLength() < selectionEndOffset) {
+ partition= handleInteriorPartition(partition, edits, factory, docExtension);
+ }
+
+ handleLastPartition(partition, edits, factory, selectionEndOffset);
+
+ executeEdits(edits);
+ }
+
+ /**
+ * Handle the first partition of the selected text.
+ *
+ * @param partition
+ * @param edits
+ * @param factory
+ * @param offset
+ */
+ private void handleFirstPartition(ITypedRegion partition, List edits, Edit.EditFactory factory, int offset) throws BadLocationException {
+
+ int partOffset= partition.getOffset();
+ String partType= partition.getType();
+
+ Assert.isTrue(partOffset <= offset, "illegal partition"); //$NON-NLS-1$
+
+ // first partition: mark start of comment
+ if (partType == IDocument.DEFAULT_CONTENT_TYPE) {
+ // Java code: right where selection starts
+ edits.add(factory.createEdit(offset, 0, getCommentStart()));
+ } else if (isSpecialPartition(partType)) {
+ // special types: include the entire partition
+ edits.add(factory.createEdit(partOffset, 0, getCommentStart()));
+ } // javadoc: no mark, will only start after comment
+
+ }
+
+ /**
+ * Handles the end of the given partition and the start of the next partition, which is returned.
+ *
+ * @param partition
+ * @param edits
+ * @param factory
+ * @param docExtension
+ * @return
+ * @throws BadLocationException
+ * @throws BadPartitioningException
+ */
+ private ITypedRegion handleInteriorPartition(ITypedRegion partition, List edits, Edit.EditFactory factory, IDocumentExtension3 docExtension) throws BadPartitioningException, BadLocationException {
+
+ // end of previous partition
+ String partType= partition.getType();
+ int partEndOffset= partition.getOffset() + partition.getLength();
+ int tokenLength= getCommentStart().length();
+
+ boolean wasJavadoc= false; // true if the previous partition is javadoc
+
+ if (partType == IPHPPartitions.PHP_MULTILINE_COMMENT) {
+
+ wasJavadoc= true;
+
+// } else if (partType == IPHPPartitions.JAVA_MULTI_LINE_COMMENT) {
+//
+// // already in a comment - remove ending mark
+// edits.add(factory.createEdit(partEndOffset - tokenLength, tokenLength, "")); //$NON-NLS-1$
+//
+ }
+
+ // advance to next partition
+ partition= docExtension.getPartition(IPHPPartitions.PHP_PARTITIONING, partEndOffset);
+ partType= partition.getType();
+
+ // start of next partition
+ if (wasJavadoc) {
+
+ // if previous was javadoc, and the current one is not, then add block comment start
+ if (partType == IDocument.DEFAULT_CONTENT_TYPE
+ || isSpecialPartition(partType)) {
+ edits.add(factory.createEdit(partition.getOffset(), 0, getCommentStart()));
+ }
+
+ } else { // !wasJavadoc
+
+ if (partType == IPHPPartitions.PHP_MULTILINE_COMMENT) {
+ // if next is javadoc, end block comment before
+ edits.add(factory.createEdit(partition.getOffset(), 0, getCommentEnd()));
+// } else if (partType == IJavaPartitions.JAVA_MULTI_LINE_COMMENT) {
+// // already in a comment - remove startToken
+// edits.add(factory.createEdit(partition.getOffset(), getCommentStart().length(), "")); //$NON-NLS-1$
+ }
+ }
+
+ return partition;
+ }
+
+ /**
+ * Handles the end of the last partition.
+ *
+ * @param partition
+ * @param edits
+ * @param factory
+ * @param endOffset
+ */
+ private void handleLastPartition(ITypedRegion partition, List edits, Edit.EditFactory factory, int endOffset) throws BadLocationException {
+
+ String partType= partition.getType();
+
+ if (partType == IDocument.DEFAULT_CONTENT_TYPE) {
+ // normal java: end comment where selection ends
+ edits.add(factory.createEdit(endOffset, 0, getCommentEnd()));
+ } else if (isSpecialPartition(partType)) {
+ // special types: consume entire partition
+ edits.add(factory.createEdit(partition.getOffset() + partition.getLength(), 0, getCommentEnd()));
+ }
+
+ }
+
+ /**
+ * Returns whether <code>partType</code> is special, i.e. a Java <code>String</code>,
+ * <code>Character</code>, or <code>Line End Comment</code> partition.
+ *
+ * @param partType the partition type to check
+ * @return <code>true</code> if <code>partType</code> is special, <code>false</code> otherwise
+ */
+ private boolean isSpecialPartition(String partType) {
+ return// partType == IPHPPartitions.PHP_CHARACTER
+ //||
+ partType == IPHPPartitions.PHP_STRING;
+ //|| partType == IPHPPartitions.PHP_SINGLE_LINE_COMMENT;
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.actions.BlockCommentAction#validSelection(org.eclipse.jface.text.ITextSelection)
+ */
+ protected boolean isValidSelection(ITextSelection selection) {
+ return selection != null && !selection.isEmpty() && selection.getLength() > 0;
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation 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 API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.actions;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.ResourceBundle;
+
+import net.sourceforge.phpdt.internal.corext.Assert;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.BadPartitioningException;
+import org.eclipse.jface.text.BadPositionCategoryException;
+import org.eclipse.jface.text.DefaultPositionUpdater;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentExtension3;
+import org.eclipse.jface.text.IPositionUpdater;
+import org.eclipse.jface.text.IRewriteTarget;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.ITextEditorExtension2;
+import org.eclipse.ui.texteditor.TextEditorAction;
+
+
+/**
+ * Common block comment code.
+ *
+ * @since 3.0
+ */
+public abstract class BlockCommentAction extends TextEditorAction {
+
+ /**
+ * Creates a new instance.
+ * @param bundle
+ * @param prefix
+ * @param editor
+ */
+ public BlockCommentAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
+ super(bundle, prefix, editor);
+ }
+
+ /**
+ * An edit is a kind of <code>DocumentEvent</code>, in this case an edit instruction, that is
+ * affilitated with a <code>Position</code> on a document. The offset of the document event is
+ * not stored statically, but taken from the affiliated <code>Position</code>, which gets
+ * updated when other edits occurr.
+ */
+ static class Edit extends DocumentEvent {
+
+ /**
+ * Factory for edits which manages the creation, installation and destruction of
+ * position categories, position updaters etc. on a certain document. Once a factory has
+ * been obtained, <code>Edit</code> objects can be obtained from it which will be linked to
+ * the document by positions of one position category.
+ * <p>Clients are required to call <code>release</code> once the <code>Edit</code>s are not
+ * used any more, so the positions can be discarded.</p>
+ */
+ public static class EditFactory {
+
+ /** The position category basename for this edits. */
+ private static final String CATEGORY= "__positionalEditPositionCategory"; //$NON-NLS-1$
+
+ /** The count of factories. */
+ private static int fgCount= 0;
+
+ /** This factory's category. */
+ private final String fCategory;
+ private IDocument fDocument;
+ private IPositionUpdater fUpdater;
+
+ /**
+ * Creates a new <code>EditFactory</code> with an unambiguous position category name.
+ * @param document the document that is being edited.
+ */
+ public EditFactory(IDocument document) {
+ fCategory= CATEGORY + fgCount++;
+ fDocument= document;
+ }
+
+ /**
+ * Creates a new edition on the document of this factory.
+ *
+ * @param offset the offset of the edition at the point when is created.
+ * @param length the length of the edition (not updated via the position update mechanism)
+ * @param text the text to be replaced on the document
+ * @return an <code>Edit</code> reflecting the edition on the document
+ */
+ public Edit createEdit(int offset, int length, String text) throws BadLocationException {
+
+ if (!fDocument.containsPositionCategory(fCategory)) {
+ fDocument.addPositionCategory(fCategory);
+ fUpdater= new DefaultPositionUpdater(fCategory);
+ fDocument.addPositionUpdater(fUpdater);
+ }
+
+ Position position= new Position(offset);
+ try {
+ fDocument.addPosition(fCategory, position);
+ } catch (BadPositionCategoryException e) {
+ Assert.isTrue(false);
+ }
+ return new Edit(fDocument, length, text, position);
+ }
+
+ /**
+ * Releases the position category on the document and uninstalls the position updater.
+ * <code>Edit</code>s managed by this factory are not updated after this call.
+ */
+ public void release() {
+ if (fDocument != null && fDocument.containsPositionCategory(fCategory)) {
+ fDocument.removePositionUpdater(fUpdater);
+ try {
+ fDocument.removePositionCategory(fCategory);
+ } catch (BadPositionCategoryException e) {
+ Assert.isTrue(false);
+ }
+ fDocument= null;
+ fUpdater= null;
+ }
+ }
+ }
+
+ /** The position in the document where this edit be executed. */
+ private Position fPosition;
+
+ /**
+ * Creates a new edition on <code>document</code>, taking its offset from <code>position</code>.
+ *
+ * @param document the document being edited
+ * @param length the length of the edition
+ * @param text the replacement text of the edition
+ * @param position the position keeping the edition's offset
+ */
+ protected Edit(IDocument document, int length, String text, Position position) {
+ super(document, 0, length, text);
+ fPosition= position;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.DocumentEvent#getOffset()
+ */
+ public int getOffset() {
+ return fPosition.getOffset();
+ }
+
+ /**
+ * Executes the edition on document. The offset is taken from the position.
+ *
+ * @throws BadLocationException if the execution of the document fails.
+ */
+ public void perform() throws BadLocationException {
+ getDocument().replace(getOffset(), getLength(), getText());
+ }
+
+ }
+
+ public void run() {
+ if (!isEnabled())
+ return;
+
+ ITextEditor editor= getTextEditor();
+ if (editor == null || !ensureEditable(editor))
+ return;
+
+ ITextSelection selection= getCurrentSelection();
+ if (!isValidSelection(selection))
+ return;
+
+ if (!validateEditorInputState())
+ return;
+
+ IDocumentProvider docProvider= editor.getDocumentProvider();
+ IEditorInput input= editor.getEditorInput();
+ if (docProvider == null || input == null)
+ return;
+
+ IDocument document= docProvider.getDocument(input);
+ if (document == null)
+ return;
+
+ IDocumentExtension3 docExtension;
+ if (document instanceof IDocumentExtension3)
+ docExtension= (IDocumentExtension3) document;
+ else
+ return;
+
+ IRewriteTarget target= (IRewriteTarget)editor.getAdapter(IRewriteTarget.class);
+ if (target != null) {
+ target.beginCompoundChange();
+ }
+
+ Edit.EditFactory factory= new Edit.EditFactory(document);
+
+ try {
+ runInternal(selection, docExtension, factory);
+
+ } catch (BadLocationException e) {
+ // can happen on concurrent modification, deletion etc. of the document
+ // -> don't complain, just bail out
+ } catch (BadPartitioningException e) {
+ // should not happen
+ Assert.isTrue(false, "bad partitioning"); //$NON-NLS-1$
+ } finally {
+ factory.release();
+
+ if (target != null) {
+ target.endCompoundChange();
+ }
+ }
+ }
+
+ /**
+ * Calls <code>perform</code> on all <code>Edit</code>s in <code>edits</code>.
+ *
+ * @param edits a list of <code>Edit</code>s
+ * @throws BadLocationException if an <code>Edit</code> threw such an exception.
+ */
+ protected void executeEdits(List edits) throws BadLocationException {
+ for (Iterator it= edits.iterator(); it.hasNext();) {
+ Edit edit= (Edit) it.next();
+ edit.perform();
+ }
+ }
+
+ /**
+ * Ensures that the editor is modifyable. If the editor is an instance of
+ * <code>ITextEditorExtension2</code>, its <code>validateEditorInputState</code> method
+ * is called, otherwise, the result of <code>isEditable</code> is returned.
+ *
+ * @param editor the editor to be checked
+ * @return <code>true</code> if the editor is editable, <code>false</code> otherwise
+ */
+ protected boolean ensureEditable(ITextEditor editor) {
+ Assert.isNotNull(editor);
+
+ if (editor instanceof ITextEditorExtension2) {
+ ITextEditorExtension2 ext= (ITextEditorExtension2) editor;
+ return ext.validateEditorInputState();
+ }
+
+ return editor.isEditable();
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.IUpdate#update()
+ */
+ public void update() {
+ super.update();
+
+ if (isEnabled()) {
+ if (!canModifyEditor() || !isValidSelection(getCurrentSelection()))
+ setEnabled(false);
+ }
+ }
+
+ /**
+ * Returns the editor's selection, or <code>null</code> if no selection can be obtained or the
+ * editor is <code>null</code>.
+ *
+ * @return the selection of the action's editor, or <code>null</code>
+ */
+ protected ITextSelection getCurrentSelection() {
+ ITextEditor editor= getTextEditor();
+ if (editor != null) {
+ ISelectionProvider provider= editor.getSelectionProvider();
+ if (provider != null) {
+ ISelection selection= provider.getSelection();
+ if (selection instanceof ITextSelection)
+ return (ITextSelection) selection;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Runs the real command once all the editor, document, and selection checks have succeeded.
+ *
+ * @param selection the current selection we are being called for
+ * @param docExtension the document extension where we get the partitioning from
+ * @param factory the edit factory we can use to create <code>Edit</code>s
+ * @throws BadLocationException if an edition fails
+ * @throws BadPartitioningException if a partitioning call fails
+ */
+ protected abstract void runInternal(ITextSelection selection, IDocumentExtension3 docExtension, Edit.EditFactory factory) throws BadLocationException, BadPartitioningException;
+
+ /**
+ * Checks whether <code>selection</code> is valid.
+ *
+ * @param selection the selection to check
+ * @return <code>true</code> if the selection is valid, <code>false</code> otherwise
+ */
+ protected abstract boolean isValidSelection(ITextSelection selection);
+
+ /**
+ * Returns the text to be inserted at the selection start.
+ *
+ * @return the text to be inserted at the selection start
+ */
+ protected String getCommentStart() {
+ // for now: no space story
+ return "/*"; //$NON-NLS-1$
+ }
+
+ /**
+ * Returns the text to be inserted at the selection end.
+ *
+ * @return the text to be inserted at the selection end
+ */
+ protected String getCommentEnd() {
+ // for now: no space story
+ return "*/"; //$NON-NLS-1$
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation 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 API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.actions;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ResourceBundle;
+
+import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.BadPartitioningException;
+import org.eclipse.jface.text.IDocumentExtension3;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+
+/**
+ * Action that removes the enclosing comment marks from a Java block comment.
+ *
+ * @since 3.0
+ */
+public class RemoveBlockCommentAction extends BlockCommentAction {
+
+ /**
+ * Creates a new instance.
+ *
+ * @param bundle the resource bundle
+ * @param prefix a prefix to be prepended to the various resource keys
+ * (described in <code>ResourceAction</code> constructor), or
+ * <code>null</code> if none
+ * @param editor the text editor
+ */
+ public RemoveBlockCommentAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
+ super(bundle, prefix, editor);
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.actions.AddBlockCommentAction#runInternal(org.eclipse.jface.text.ITextSelection, org.eclipse.jface.text.IDocumentExtension3, org.eclipse.jdt.internal.ui.actions.AddBlockCommentAction.Edit.EditFactory)
+ */
+ protected void runInternal(ITextSelection selection, IDocumentExtension3 docExtension, Edit.EditFactory factory) throws BadPartitioningException, BadLocationException {
+ List edits= new LinkedList();
+ int tokenLength= getCommentStart().length();
+
+ int offset= selection.getOffset();
+ int endOffset= offset + selection.getLength();
+
+ ITypedRegion partition= docExtension.getPartition(IPHPPartitions.PHP_PARTITIONING, offset);
+ int partOffset= partition.getOffset();
+ int partEndOffset= partOffset + partition.getLength();
+
+ while (partEndOffset < endOffset) {
+
+ if (partition.getType() == IPHPPartitions.PHP_MULTILINE_COMMENT) {
+ edits.add(factory.createEdit(partOffset, tokenLength, "")); //$NON-NLS-1$
+ edits.add(factory.createEdit(partEndOffset - tokenLength, tokenLength, "")); //$NON-NLS-1$
+ }
+
+ partition= docExtension.getPartition(IPHPPartitions.PHP_PARTITIONING, partEndOffset);
+ partOffset= partition.getOffset();
+ partEndOffset= partOffset + partition.getLength();
+ }
+
+ if (partition.getType() == IPHPPartitions.PHP_MULTILINE_COMMENT) {
+ edits.add(factory.createEdit(partOffset, tokenLength, "")); //$NON-NLS-1$
+ edits.add(factory.createEdit(partEndOffset - tokenLength, tokenLength, "")); //$NON-NLS-1$
+ }
+
+ executeEdits(edits);
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.actions.AddBlockCommentAction#validSelection(org.eclipse.jface.text.ITextSelection)
+ */
+ protected boolean isValidSelection(ITextSelection selection) {
+ return selection != null && !selection.isEmpty();
+ }
+
+}
import net.sourceforge.phpdt.ui.text.JavaTextTools;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
import net.sourceforge.phpeclipse.phpeditor.php.HTMLCompletionProcessor;
-import net.sourceforge.phpeclipse.phpeditor.php.IPHPPartitionScannerConstants;
import net.sourceforge.phpeclipse.phpeditor.php.PHPCompletionProcessor;
import org.eclipse.jface.preference.IPreferenceStore;
}
private static PHPCompletionProcessor getJavaProcessor(ContentAssistant assistant) {
- IContentAssistProcessor p = assistant.getContentAssistProcessor(IPHPPartitionScannerConstants.PHP);
+ IContentAssistProcessor p = assistant.getContentAssistProcessor(IPHPPartitions.PHP_PARTITIONING);
if (p instanceof PHPCompletionProcessor)
return (PHPCompletionProcessor) p;
return null;
}
private static PHPDocCompletionProcessor getJavaDocProcessor(ContentAssistant assistant) {
- IContentAssistProcessor p = assistant.getContentAssistProcessor(IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
+ IContentAssistProcessor p = assistant.getContentAssistProcessor(IPHPPartitions.PHP_MULTILINE_COMMENT);
if (p instanceof PHPDocCompletionProcessor)
return (PHPDocCompletionProcessor) p;
return null;
}
private static HTMLCompletionProcessor getHTMLProcessor(ContentAssistant assistant) {
- IContentAssistProcessor p = assistant.getContentAssistProcessor(IPHPPartitionScannerConstants.HTML);
+ IContentAssistProcessor p = assistant.getContentAssistProcessor(IPHPPartitions.HTML);
if (p instanceof HTMLCompletionProcessor)
return (HTMLCompletionProcessor) p;
return null;
* Created on 05.03.2003
*
*/
-package net.sourceforge.phpeclipse.phpeditor.php;
+package net.sourceforge.phpdt.internal.ui.text;
/**
* @author Stefan Langer (musk)
*
*/
-public interface IPHPPartitionScannerConstants
+public interface IPHPPartitions
{
- public final static String PHP = "__php"; //$NON-NLS-1$
+ public final static String PHP_PARTITIONING = "__php"; //$NON-NLS-1$
public final static String PHP_MULTILINE_COMMENT = "__php_multiline_comment"; //$NON-NLS-1$
- public final static String PHP_STRING = "__php_string"; //$NON-NLS-1$
+ public final static String PHP_STRING = "__php_string"; //$NON-NLS-1$
public final static String JAVASCRIPT = "__javascript"; //$NON-NLS-1$
public final static String JS_MULTILINE_COMMENT = "__js_multiline_comment"; //$NON-NLS-1$
public final static String CSS = "__css"; //$NON-NLS-1$
******************************************************************************/
package net.sourceforge.phpdt.ui;
+import net.sourceforge.phpdt.core.IClasspathEntry;
import net.sourceforge.phpeclipse.IPreferenceConstants;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.texteditor.AbstractTextEditor;
-import org.eclipse.ui.texteditor.WorkbenchChainedTextFontFieldEditor;
//
//import org.phpeclipse.phpdt.internal.ui.JavaPlugin;
//import org.phpeclipse.phpdt.internal.ui.preferences.NewJavaProjectPreferencePage;
* @since 2.1
*/
public static final String EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER = "browserLikeLinksKeyModifier"; //$NON-NLS-1$
+ /**
+ * A named preference that controls whether occurrences are marked in the editor.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ *
+ * @since 3.0
+ */
+ public static final String EDITOR_MARK_OCCURRENCES= "markOccurrences"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether occurrences are sticky in the editor.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ *
+ * @since 3.0
+ */
+ public static final String EDITOR_STICKY_OCCURRENCES= "stickyOccurrences"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls disabling of the overwrite mode.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ *
+ * @since 3.0
+ */
+ public static final String EDITOR_DISABLE_OVERWRITE_MODE= "disable_overwrite_mode"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls the "smart semicolon" smart typing handler
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ *
+ * @since 3.0
+ */
+ public static final String EDITOR_SMART_SEMICOLON= "smart_semicolon"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls the "smart opening brace" smart typing handler
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ *
+ * @since 3.0
+ */
+ public static final String EDITOR_SMART_OPENING_BRACE= "smart_opening_brace"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls the smart tab behaviour.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ *
+ * @since 3.0
+ */
+ public static final String EDITOR_SMART_TAB= "smart_tab"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether Java comments should be
+ * spell-checked.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ *
+ * @since 3.0
+ */
+// public final static String SPELLING_CHECK_SPELLING= ISpellCheckPreferenceKeys.SPELLING_CHECK_SPELLING;
+
+ /**
+ * A named preference that controls whether words containing digits should
+ * be skipped during spell-checking.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ *
+ * @since 3.0
+ */
+// public final static String SPELLING_IGNORE_DIGITS= ISpellCheckPreferenceKeys.SPELLING_IGNORE_DIGITS;
+
+ /**
+ * A named preference that controls whether mixed case words should be
+ * skipped during spell-checking.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ *
+ * @since 3.0
+ */
+// public final static String SPELLING_IGNORE_MIXED= ISpellCheckPreferenceKeys.SPELLING_IGNORE_MIXED;
+
+ /**
+ * A named preference that controls whether sentence capitalization should
+ * be ignored during spell-checking.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ *
+ * @since 3.0
+ */
+// public final static String SPELLING_IGNORE_SENTENCE= ISpellCheckPreferenceKeys.SPELLING_IGNORE_SENTENCE;
+
+ /**
+ * A named preference that controls whether upper case words should be
+ * skipped during spell-checking.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ *
+ * @since 3.0
+ */
+// public final static String SPELLING_IGNORE_UPPER= ISpellCheckPreferenceKeys.SPELLING_IGNORE_UPPER;
+
+ /**
+ * A named preference that controls whether urls should be ignored during
+ * spell-checking.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ *
+ * @since 3.0
+ */
+// public final static String SPELLING_IGNORE_URLS= ISpellCheckPreferenceKeys.SPELLING_IGNORE_URLS;
+
+ /**
+ * A named preference that controls the locale used for spell-checking.
+ * <p>
+ * Value is of type <code>String</code>.
+ * </p>
+ *
+ * @since 3.0
+ */
+// public final static String SPELLING_LOCALE= ISpellCheckPreferenceKeys.SPELLING_LOCALE;
+
+ /**
+ * A named preference that controls the number of proposals offered during
+ * spell-checking.
+ * <p>
+ * Value is of type <code>Integer</code>.
+ * </p>
+ *
+ * @since 3.0
+ */
+// public final static String SPELLING_PROPOSAL_THRESHOLD= ISpellCheckPreferenceKeys.SPELLING_PROPOSAL_THRESHOLD;
+
+ /**
+ * A named preference that specifies the workspace user dictionary.
+ * <p>
+ * Value is of type <code>Integer</code>.
+ * </p>
+ *
+ * @since 3.0
+ */
+// public final static String SPELLING_USER_DICTIONARY= ISpellCheckPreferenceKeys.SPELLING_USER_DICTIONARY;
+
+ /**
+ * A named preference that specifies whether spelling dictionaries are available to content assist.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ *
+ * @since 3.0
+ */
+// public final static String SPELLING_ENABLE_CONTENTASSIST= ISpellCheckPreferenceKeys.SPELLING_ENABLE_CONTENTASSIST;
+
+ /**
+ * A named preference that controls whether code snippets are formatted
+ * in Javadoc comments.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ *
+ * @since 3.0
+ */
+ public final static String FORMATTER_COMMENT_FORMATSOURCE= "comment_format_source_code"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether description of Javadoc
+ * parameters are indented.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ *
+ * @since 3.0
+ */
+ public final static String FORMATTER_COMMENT_INDENTPARAMETERDESCRIPTION= "comment_indent_parameter_description"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the header comment of
+ * a Java source file is formatted.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ *
+ * @since 3.0
+ */
+ public final static String FORMATTER_COMMENT_FORMATHEADER= "comment_format_header"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether Javadoc root tags
+ * are indented.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ *
+ * @since 3.0
+ */
+ public final static String FORMATTER_COMMENT_INDENTROOTTAGS= "comment_indent_root_tags"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether Javadoc comments
+ * are formatted by the content formatter.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ *
+ * @since 3.0
+ */
+ public final static String FORMATTER_COMMENT_FORMAT= "comment_format_comments"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether a new line is inserted
+ * after Javadoc root tag parameters.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ *
+ * @since 3.0
+ */
+ public final static String FORMATTER_COMMENT_NEWLINEFORPARAMETER= "comment_new_line_for_parameter"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether an empty line is inserted before
+ * the Javadoc root tag block.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ *
+ * @since 3.0
+ */
+ public final static String FORMATTER_COMMENT_SEPARATEROOTTAGS= "comment_separate_root_tags"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether blank lines are cleared during formatting
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ *
+ * @since 3.0
+ */
+ public final static String FORMATTER_COMMENT_CLEARBLANKLINES= "comment_clear_blank_lines"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls the line length of comments.
+ * <p>
+ * Value is of type <code>Integer</code>. The value must be at least 4 for reasonable formatting.
+ * </p>
+ *
+ * @since 3.0
+ */
+ public final static String FORMATTER_COMMENT_LINELENGTH= "comment_line_length"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether html tags are formatted.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ *
+ * @since 3.0
+ */
+ public final static String FORMATTER_COMMENT_FORMATHTML= "comment_format_html"; //$NON-NLS-1$
/**
* A named preference that controls if the Java code assist gets auto activated.
public class PHPdtActionConstants {
// Edit menu
-
+ /**
+ * Edit menu: name of standard Show Javadoc global action
+ * (value <code>"org.eclipse.jdt.ui.actions.ShowJavaDoc"</code>).
+ */
+ public static final String SHOW_JAVA_DOC= "net.sourceforge.phpeclipse.phpeditor.ShowJavaDoc"; //$NON-NLS-1$
+
/**
* Edit menu: name of standard Code Assist global action
* (value <code>"org.phpeclipse.phpdt.ui.actions.ContentAssist"</code>).
*/
import net.sourceforge.phpdt.internal.ui.text.FastJavaPartitionScanner;
+import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
import net.sourceforge.phpdt.internal.ui.text.JavaColorManager;
import net.sourceforge.phpdt.internal.ui.text.phpdoc.PHPDocCodeScanner;
import net.sourceforge.phpeclipse.IPreferenceConstants;
import net.sourceforge.phpeclipse.phpeditor.php.HTMLCodeScanner;
-import net.sourceforge.phpeclipse.phpeditor.php.IPHPPartitionScannerConstants;
import net.sourceforge.phpeclipse.phpeditor.php.PHPCodeScanner;
import net.sourceforge.phpeclipse.phpeditor.php.PHPPartitionScanner;
import net.sourceforge.phpeclipse.phpeditor.php.SmartyCodeScanner;
// private final static String[] TYPES= new String[] { PHPPartitionScanner.PHP, PHPPartitionScanner.JAVA_DOC, PHPPartitionScanner.JAVA_MULTILINE_COMMENT };
private final static String[] TYPES =
new String[] {
- IPHPPartitionScannerConstants.PHP,
- IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT,
- IPHPPartitionScannerConstants.HTML,
- IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT,
- IPHPPartitionScannerConstants.JAVASCRIPT,
- IPHPPartitionScannerConstants.CSS,
- IPHPPartitionScannerConstants.SMARTY,
- IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT };
+ IPHPPartitions.PHP_PARTITIONING,
+ IPHPPartitions.PHP_MULTILINE_COMMENT,
+ IPHPPartitions.HTML,
+ IPHPPartitions.HTML_MULTILINE_COMMENT,
+ IPHPPartitions.JAVASCRIPT,
+ IPHPPartitions.CSS,
+ IPHPPartitions.SMARTY,
+ IPHPPartitions.SMARTY_MULTILINE_COMMENT };
private static PHPPartitionScanner XML_PARTITION_SCANNER = null;
/**
*/
private static PHPPartitionScanner getHTMLPartitionScanner() {
if (HTML_PARTITION_SCANNER == null)
- HTML_PARTITION_SCANNER = new PHPPartitionScanner(IPHPPartitionScannerConstants.HTML_FILE);
+ HTML_PARTITION_SCANNER = new PHPPartitionScanner(IPHPPartitions.HTML_FILE);
return HTML_PARTITION_SCANNER;
}
/**
*/
private static PHPPartitionScanner getPHPPartitionScanner() {
if (PHP_PARTITION_SCANNER == null)
- PHP_PARTITION_SCANNER = new PHPPartitionScanner(IPHPPartitionScannerConstants.PHP_FILE);
+ PHP_PARTITION_SCANNER = new PHPPartitionScanner(IPHPPartitions.PHP_FILE);
return PHP_PARTITION_SCANNER;
}
*/
private static PHPPartitionScanner getSmartyPartitionScanner() {
if (SMARTY_PARTITION_SCANNER == null)
- SMARTY_PARTITION_SCANNER = new PHPPartitionScanner(IPHPPartitionScannerConstants.SMARTY_FILE);
+ SMARTY_PARTITION_SCANNER = new PHPPartitionScanner(IPHPPartitions.SMARTY_FILE);
return SMARTY_PARTITION_SCANNER;
}
*/
private static PHPPartitionScanner getXMLPartitionScanner() {
if (XML_PARTITION_SCANNER == null)
- XML_PARTITION_SCANNER = new PHPPartitionScanner(IPHPPartitionScannerConstants.XML_FILE);
+ XML_PARTITION_SCANNER = new PHPPartitionScanner(IPHPPartitions.XML_FILE);
return XML_PARTITION_SCANNER;
}
package net.sourceforge.phpeclipse;
-
import net.sourceforge.phpeclipse.views.browser.BrowserView;
import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.search.ui.SearchUI;
import org.eclipse.ui.IFolderLayout;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;
+import org.eclipse.ui.console.IConsoleConstants;
//import org.eclipse.update.internal.ui.UpdatePerspective;
-
public class PHPPerspectiveFactory implements IPerspectiveFactory {
-
public PHPPerspectiveFactory() {
super();
}
-
public void createInitialLayout(IPageLayout layout) {
String editorArea = layout.getEditorArea();
-
- // IFolderLayout phpResourcesArea = layout.createFolder("phpresourcesarea", IPageLayout.LEFT, (float)0.25, editorArea);
+ // IFolderLayout phpResourcesArea = layout.createFolder("phpresourcesarea",
+ // IPageLayout.LEFT, (float)0.25, editorArea);
// phpResourcesArea.addView(PHPeclipsePlugin.PHP_RESOURCES_VIEW_ID);
- IFolderLayout folder = layout.createFolder("left", IPageLayout.LEFT, (float) 0.25, editorArea); //$NON-NLS-1$
+ IFolderLayout folder = layout.createFolder("left", IPageLayout.LEFT,
+ (float) 0.25, editorArea); //$NON-NLS-1$
folder.addView(IPageLayout.ID_RES_NAV);
//folder.addPlaceholder(IPageLayout.ID_RES_NAV);
-
- IFolderLayout consoleArea =
- layout.createFolder(
- "consoleArea",
- IPageLayout.BOTTOM,
- (float) 0.75,
+ IFolderLayout outputfolder = layout.createFolder("bottom",
+ IPageLayout.BOTTOM, (float) 0.75, editorArea); //$NON-NLS-1$
+ outputfolder.addView(IPageLayout.ID_PROBLEM_VIEW);
+ outputfolder.addPlaceholder(SearchUI.SEARCH_RESULT_VIEW_ID);
+ outputfolder.addView(IConsoleConstants.ID_CONSOLE_VIEW);
+ outputfolder.addView(IPageLayout.ID_BOOKMARKS);
+
+ layout.addView(IPageLayout.ID_OUTLINE, IPageLayout.RIGHT, (float) 0.75,
editorArea);
-
- consoleArea.addView(IPageLayout.ID_TASK_LIST);
- consoleArea.addView(org.eclipse.ui.console.IConsoleConstants.ID_CONSOLE_VIEW);
- consoleArea.addView(IPageLayout.ID_BOOKMARKS);
-
- layout.addView(
- IPageLayout.ID_OUTLINE,
- IPageLayout.RIGHT,
- (float) 0.75,
- editorArea);
-
layout.addActionSet(IDebugUIConstants.LAUNCH_ACTION_SET);
layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET);
- layout.addActionSet(PHPeclipsePlugin.PHP_CODING_ACTION_SET_ID);
-
- layout.addShowViewShortcut(org.eclipse.ui.console.IConsoleConstants.ID_CONSOLE_VIEW);
-// if (SWT.getPlatform().equals("win32")) {
-// layout.addShowViewShortcut(UpdatePerspective.ID_BROWSER);
-// }
layout.addShowViewShortcut(BrowserView.ID_BROWSER);
- // layout.addShowViewShortcut(PHPeclipsePlugin.PHP_RESOURCES_VIEW_ID);
-
+ // views - search
+ layout.addShowViewShortcut(SearchUI.SEARCH_RESULT_VIEW_ID);
+ // views - debugging
+ layout.addShowViewShortcut(IConsoleConstants.ID_CONSOLE_VIEW);
// views - standard workbench
layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
- layout.addShowViewShortcut(IPageLayout.ID_TASK_LIST);
- layout.addShowViewShortcut(IPageLayout.ID_BOOKMARKS);
-
+ layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW);
+ layout.addShowViewShortcut(IPageLayout.ID_RES_NAV);
// new actions - PHP project creation wizards
-// layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewInterfaceCreationWizard"); //$NON-NLS-1$
- layout.addNewWizardShortcut("net.sourceforge.phpeclipse.wizards.PHPFileWizard"); //$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder");//$NON-NLS-1$
- layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.file");//$NON-NLS-1$
+ // layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewInterfaceCreationWizard");
+ // //$NON-NLS-1$
+ layout
+ .addNewWizardShortcut("net.sourceforge.phpeclipse.wizards.PHPFileWizard"); //$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder");//$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.file");//$NON-NLS-1$
}
-
}
IEditorRegistry registry = getWorkbench().getEditorRegistry();
IEditorDescriptor desc = registry.getDefaultEditor(filename);
if (desc == null) {
- desc = registry.getDefaultEditor();
+ desc = registry.findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
+ // desc = registry.getDefaultEditor();
}
IEditorInput input = new ExternalEditorInput(storage);
editor = page.openEditor(input, desc.getId());
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation 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 API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpeclipse.phpeditor;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ResourceBundle;
+
+import net.sourceforge.phpdt.ui.IContextMenuConstants;
+import net.sourceforge.phpdt.ui.actions.GotoMatchingBracketAction;
+import net.sourceforge.phpdt.ui.actions.PHPdtActionConstants;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IStatusLineManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.actions.RetargetAction;
+import org.eclipse.ui.texteditor.BasicTextEditorActionContributor;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
+import org.eclipse.ui.texteditor.RetargetTextEditorAction;
+
+/**
+ * Common base class for action contributors for Java editors.
+ */
+public class BasicJavaEditorActionContributor extends BasicTextEditorActionContributor {
+
+ private List fPartListeners= new ArrayList();
+
+ private TogglePresentationAction fTogglePresentation;
+// private GotoAnnotationAction fPreviousAnnotation;
+// private GotoAnnotationAction fNextAnnotation;
+
+ private RetargetTextEditorAction fGotoMatchingBracket;
+// private RetargetTextEditorAction fShowOutline;
+// private RetargetTextEditorAction fOpenStructure;
+// private RetargetTextEditorAction fOpenHierarchy;
+
+ private RetargetAction fRetargetShowJavaDoc;
+ private RetargetTextEditorAction fShowJavaDoc;
+
+// private RetargetTextEditorAction fStructureSelectEnclosingAction;
+// private RetargetTextEditorAction fStructureSelectNextAction;
+// private RetargetTextEditorAction fStructureSelectPreviousAction;
+// private RetargetTextEditorAction fStructureSelectHistoryAction;
+
+// private RetargetTextEditorAction fGotoNextMemberAction;
+// private RetargetTextEditorAction fGotoPreviousMemberAction;
+//
+// private RetargetTextEditorAction fRemoveOccurrenceAnnotationsAction;
+
+ public BasicJavaEditorActionContributor() {
+ super();
+
+ ResourceBundle b= PHPEditorMessages.getResourceBundle();
+
+ fRetargetShowJavaDoc= new RetargetAction(PHPdtActionConstants.SHOW_JAVA_DOC, PHPEditorMessages.getString("ShowJavaDoc.label")); //$NON-NLS-1$
+ fRetargetShowJavaDoc.setActionDefinitionId(PHPEditorActionDefinitionIds.SHOW_JAVADOC);
+ markAsPartListener(fRetargetShowJavaDoc);
+
+ // actions that are "contributed" to editors, they are considered belonging to the active editor
+ fTogglePresentation= new TogglePresentationAction();
+
+// fPreviousAnnotation= new GotoAnnotationAction("PreviousAnnotation.", false); //$NON-NLS-1$
+//
+// fNextAnnotation= new GotoAnnotationAction("NextAnnotation.", true); //$NON-NLS-1$
+
+ fGotoMatchingBracket= new RetargetTextEditorAction(b, "GotoMatchingBracket."); //$NON-NLS-1$
+ fGotoMatchingBracket.setActionDefinitionId(PHPEditorActionDefinitionIds.GOTO_MATCHING_BRACKET);
+
+ fShowJavaDoc= new RetargetTextEditorAction(b, "ShowJavaDoc."); //$NON-NLS-1$
+ fShowJavaDoc.setActionDefinitionId(PHPEditorActionDefinitionIds.SHOW_JAVADOC);
+
+// fShowOutline= new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ShowOutline."); //$NON-NLS-1$
+// fShowOutline.setActionDefinitionId(PHPEditorActionDefinitionIds.SHOW_OUTLINE);
+//
+// fOpenHierarchy= new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "OpenHierarchy."); //$NON-NLS-1$
+// fOpenHierarchy.setActionDefinitionId(PHPEditorActionDefinitionIds.OPEN_HIERARCHY);
+//
+// fOpenStructure= new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "OpenStructure."); //$NON-NLS-1$
+// fOpenStructure.setActionDefinitionId(PHPEditorActionDefinitionIds.OPEN_STRUCTURE);
+
+// fStructureSelectEnclosingAction= new RetargetTextEditorAction(b, "StructureSelectEnclosing."); //$NON-NLS-1$
+// fStructureSelectEnclosingAction.setActionDefinitionId(PHPEditorActionDefinitionIds.SELECT_ENCLOSING);
+// fStructureSelectNextAction= new RetargetTextEditorAction(b, "StructureSelectNext."); //$NON-NLS-1$
+// fStructureSelectNextAction.setActionDefinitionId(PHPEditorActionDefinitionIds.SELECT_NEXT);
+// fStructureSelectPreviousAction= new RetargetTextEditorAction(b, "StructureSelectPrevious."); //$NON-NLS-1$
+// fStructureSelectPreviousAction.setActionDefinitionId(PHPEditorActionDefinitionIds.SELECT_PREVIOUS);
+// fStructureSelectHistoryAction= new RetargetTextEditorAction(b, "StructureSelectHistory."); //$NON-NLS-1$
+// fStructureSelectHistoryAction.setActionDefinitionId(PHPEditorActionDefinitionIds.SELECT_LAST);
+//
+// fGotoNextMemberAction= new RetargetTextEditorAction(b, "GotoNextMember."); //$NON-NLS-1$
+// fGotoNextMemberAction.setActionDefinitionId(PHPEditorActionDefinitionIds.GOTO_NEXT_MEMBER);
+// fGotoPreviousMemberAction= new RetargetTextEditorAction(b, "GotoPreviousMember."); //$NON-NLS-1$
+// fGotoPreviousMemberAction.setActionDefinitionId(PHPEditorActionDefinitionIds.GOTO_PREVIOUS_MEMBER);
+//
+// fRemoveOccurrenceAnnotationsAction= new RetargetTextEditorAction(b, "RemoveOccurrenceAnnotations."); //$NON-NLS-1$
+// fRemoveOccurrenceAnnotationsAction.setActionDefinitionId(PHPEditorActionDefinitionIds.REMOVE_OCCURRENCE_ANNOTATIONS);
+ }
+
+ protected final void markAsPartListener(RetargetAction action) {
+ fPartListeners.add(action);
+ }
+
+ /*
+ * @see IEditorActionBarContributor#init(IActionBars, IWorkbenchPage)
+ */
+ public void init(IActionBars bars, IWorkbenchPage page) {
+ Iterator e= fPartListeners.iterator();
+ while (e.hasNext())
+ page.addPartListener((RetargetAction) e.next());
+
+ super.init(bars, page);
+
+ // register actions that have a dynamic editor.
+// bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_NEXT_ANNOTATION, fNextAnnotation);
+// bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_PREVIOUS_ANNOTATION, fPreviousAnnotation);
+// bars.setGlobalActionHandler(ITextEditorActionConstants.NEXT, fNextAnnotation);
+// bars.setGlobalActionHandler(ITextEditorActionConstants.PREVIOUS, fPreviousAnnotation);
+ bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY, fTogglePresentation);
+
+ bars.setGlobalActionHandler(PHPdtActionConstants.SHOW_JAVA_DOC, fShowJavaDoc);
+ }
+
+ /*
+ * @see org.eclipse.ui.part.EditorActionBarContributor#contributeToMenu(org.eclipse.jface.action.IMenuManager)
+ */
+ public void contributeToMenu(IMenuManager menu) {
+
+ super.contributeToMenu(menu);
+
+ IMenuManager editMenu= menu.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
+ if (editMenu != null) {
+
+ editMenu.add(new Separator(IContextMenuConstants.GROUP_OPEN));
+ editMenu.add(new Separator(IContextMenuConstants.GROUP_GENERATE));
+ editMenu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
+
+// MenuManager structureSelection= new MenuManager(PHPEditorMessages.getString("ExpandSelectionMenu.label"), "expandSelection"); //$NON-NLS-1$ //$NON-NLS-2$
+// structureSelection.add(fStructureSelectEnclosingAction);
+// structureSelection.add(fStructureSelectNextAction);
+// structureSelection.add(fStructureSelectPreviousAction);
+// structureSelection.add(fStructureSelectHistoryAction);
+// editMenu.appendToGroup(IContextMenuConstants.GROUP_OPEN, structureSelection);
+
+ editMenu.appendToGroup(IContextMenuConstants.GROUP_GENERATE, fRetargetShowJavaDoc);
+ }
+
+// IMenuManager navigateMenu= menu.findMenuUsingPath(IWorkbenchActionConstants.M_NAVIGATE);
+// if (navigateMenu != null) {
+// navigateMenu.appendToGroup(IWorkbenchActionConstants.SHOW_EXT, fShowOutline);
+// navigateMenu.appendToGroup(IWorkbenchActionConstants.SHOW_EXT, fOpenHierarchy);
+// }
+
+ IMenuManager gotoMenu= menu.findMenuUsingPath("navigate/goTo"); //$NON-NLS-1$
+ if (gotoMenu != null) {
+ gotoMenu.add(new Separator("additions2")); //$NON-NLS-1$
+// gotoMenu.appendToGroup("additions2", fGotoPreviousMemberAction); //$NON-NLS-1$
+// gotoMenu.appendToGroup("additions2", fGotoNextMemberAction); //$NON-NLS-1$
+ gotoMenu.appendToGroup("additions2", fGotoMatchingBracket); //$NON-NLS-1$
+ }
+ }
+
+ /*
+ * @see EditorActionBarContributor#setActiveEditor(IEditorPart)
+ */
+ public void setActiveEditor(IEditorPart part) {
+
+ super.setActiveEditor(part);
+
+ IActionBars actionBars= getActionBars();
+ IStatusLineManager manager= actionBars.getStatusLineManager();
+ manager.setMessage(null);
+ manager.setErrorMessage(null);
+
+ ITextEditor textEditor= null;
+ if (part instanceof ITextEditor)
+ textEditor= (ITextEditor) part;
+
+ fTogglePresentation.setEditor(textEditor);
+// fPreviousAnnotation.setEditor(textEditor);
+// fNextAnnotation.setEditor(textEditor);
+
+ fGotoMatchingBracket.setAction(getAction(textEditor, GotoMatchingBracketAction.GOTO_MATCHING_BRACKET));
+ fShowJavaDoc.setAction(getAction(textEditor, "ShowJavaDoc")); //$NON-NLS-1$
+// fShowOutline.setAction(getAction(textEditor, IJavaEditorActionDefinitionIds.SHOW_OUTLINE));
+// fOpenHierarchy.setAction(getAction(textEditor, IJavaEditorActionDefinitionIds.OPEN_HIERARCHY));
+// fOpenStructure.setAction(getAction(textEditor, IJavaEditorActionDefinitionIds.OPEN_STRUCTURE));
+
+// fStructureSelectEnclosingAction.setAction(getAction(textEditor, StructureSelectionAction.ENCLOSING));
+// fStructureSelectNextAction.setAction(getAction(textEditor, StructureSelectionAction.NEXT));
+// fStructureSelectPreviousAction.setAction(getAction(textEditor, StructureSelectionAction.PREVIOUS));
+// fStructureSelectHistoryAction.setAction(getAction(textEditor, StructureSelectionAction.HISTORY));
+
+// fGotoNextMemberAction.setAction(getAction(textEditor, GoToNextPreviousMemberAction.NEXT_MEMBER));
+// fGotoPreviousMemberAction.setAction(getAction(textEditor, GoToNextPreviousMemberAction.PREVIOUS_MEMBER));
+
+// fRemoveOccurrenceAnnotationsAction.setAction(getAction(textEditor, "RemoveOccurrenceAnnotations")); //$NON-NLS-1$
+
+ if (part instanceof PHPEditor) {
+ PHPEditor javaEditor= (PHPEditor) part;
+ javaEditor.getActionGroup().fillActionBars(getActionBars());
+ }
+ }
+
+ /*
+ * @see IEditorActionBarContributor#dispose()
+ */
+ public void dispose() {
+
+ Iterator e= fPartListeners.iterator();
+ while (e.hasNext())
+ getPage().removePartListener((RetargetAction) e.next());
+ fPartListeners.clear();
+
+ setActiveEditor(null);
+ super.dispose();
+ }
+}
import java.util.Iterator;
import java.util.List;
import java.util.ResourceBundle;
+
+import net.sourceforge.phpdt.internal.ui.PHPUiImages;
import net.sourceforge.phpdt.ui.IContextMenuConstants;
-import net.sourceforge.phpdt.ui.actions.GotoMatchingBracketAction;
import net.sourceforge.phpdt.ui.actions.PHPdtActionConstants;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.SWT;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.actions.RetargetAction;
import org.eclipse.ui.editors.text.EncodingActionGroup;
+import org.eclipse.ui.ide.IDEActionFactory;
import org.eclipse.ui.texteditor.AbstractTextEditor;
import org.eclipse.ui.texteditor.BasicTextEditorActionContributor;
import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
import org.eclipse.ui.texteditor.RetargetTextEditorAction;
/**
* Contributes interesting PHP actions to the desktop's Edit menu and the
* toolbar.
*/
-public class PHPActionContributor extends BasicTextEditorActionContributor {
- protected RetargetTextEditorAction fContentAssistTip;
+public class PHPActionContributor extends BasicJavaEditorActionContributor {
+// protected RetargetTextEditorAction fContentAssistTip;
// protected TextEditorAction fTogglePresentation;
protected RetargetAction fRetargetContentAssist;
protected RetargetTextEditorAction fContentAssist;
+ protected RetargetTextEditorAction fContextInformation;
private RetargetTextEditorAction fGotoMatchingBracket;
private List fRetargetToolbarActions = new ArrayList();
- private List fPartListeners = new ArrayList();
+// private List fPartListeners = new ArrayList();
protected PHPParserAction fParserAction;
protected ShowExternalPreviewAction fShowExternalPreviewAction;
private EncodingActionGroup fEncodingActionGroup;
public PHPActionContributor() {
super();
ResourceBundle b = PHPEditorMessages.getResourceBundle();
- fRetargetContentAssist = new RetargetAction(
- PHPdtActionConstants.CONTENT_ASSIST, PHPEditorMessages
- .getString("ContentAssistProposal.label")); //$NON-NLS-1$
- fRetargetContentAssist
- .setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
- markAsPartListener(fRetargetContentAssist);
- fContentAssist = new RetargetTextEditorAction(b, "ContentAssistProposal."); //$NON-NLS-1$
- fContentAssist
- .setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
- fGotoMatchingBracket = new RetargetTextEditorAction(b,
- "GotoMatchingBracket."); //$NON-NLS-1$
- fGotoMatchingBracket
- .setActionDefinitionId(PHPEditorActionDefinitionIds.GOTO_MATCHING_BRACKET);
- // fContentAssist.setImageDescriptor(JavaPluginImages.DESC_CLCL_CODE_ASSIST);
- // fContentAssist.setDisabledImageDescriptor(JavaPluginImages.DESC_DLCL_CODE_ASSIST);
- // fContentAssist = new
- // RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(),
- // "ContentAssistProposal."); //$NON-NLS-1$
- fContentAssistTip = new RetargetTextEditorAction(PHPEditorMessages
- .getResourceBundle(), "ContentAssistTip."); //$NON-NLS-1$
- // fTogglePresentation = new PresentationAction();
- // character encoding
- fEncodingActionGroup = new EncodingActionGroup();
+
+// fRetargetContentAssist = new RetargetAction(
+// PHPdtActionConstants.CONTENT_ASSIST, PHPEditorMessages
+// .getString("ContentAssistProposal.label")); //$NON-NLS-1$
+// fRetargetContentAssist
+// .setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
+// markAsPartListener(fRetargetContentAssist);
+//
+// fContentAssist = new RetargetTextEditorAction(b, "ContentAssistProposal."); //$NON-NLS-1$
+// fContentAssist
+// .setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
+
+ fRetargetContentAssist= new RetargetAction(PHPdtActionConstants.CONTENT_ASSIST, PHPEditorMessages.getString("ContentAssistProposal.label")); //$NON-NLS-1$
+ fRetargetContentAssist.setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
+ markAsPartListener(fRetargetContentAssist);
+
+ fContentAssist= new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistProposal."); //$NON-NLS-1$
+ fContentAssist.setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
+ fContentAssist.setImageDescriptor(PHPUiImages.DESC_CLCL_CODE_ASSIST);
+ fContentAssist.setDisabledImageDescriptor(PHPUiImages.DESC_DLCL_CODE_ASSIST);
+
+ fContextInformation= new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistContextInformation."); //$NON-NLS-1$
+ fContextInformation.setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
+
+// fCorrectionAssist= new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "CorrectionAssistProposal."); //$NON-NLS-1$
+// fCorrectionAssist.setActionDefinitionId(PHPEditorActionDefinitionIds.CORRECTION_ASSIST_PROPOSALS);
+
+ // character encoding
+ fEncodingActionGroup= new EncodingActionGroup();
+
fParserAction = PHPParserAction.getInstance();
- if (SWT.getPlatform().equals("win32")) {
- // ExternalPreview only available as ActiveX on win32 (Eclipse2.1)
- fShowExternalPreviewAction = ShowExternalPreviewAction.getInstance();
- }
- }
- protected final void markAsPartListener(RetargetAction action) {
- fPartListeners.add(action);
+ fShowExternalPreviewAction = ShowExternalPreviewAction.getInstance();
}
+
/*
* @see EditorActionBarContributor#contributeToMenu(IMenuManager)
*/
*/
public void contributeToMenu(IMenuManager menu) {
super.contributeToMenu(menu);
- IMenuManager editMenu = menu
- .findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
- if (editMenu != null) {
- editMenu.add(new Separator(IContextMenuConstants.GROUP_OPEN));
- editMenu.add(new Separator(IContextMenuConstants.GROUP_GENERATE));
- editMenu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
- // editMenu.appendToGroup(
- // IContextMenuConstants.GROUP_GENERATE,
- // fRetargetContentAssist);
- // MenuManager structureSelection= new
- // MenuManager(JavaEditorMessages.getString("ExpandSelectionMenu.label"),
- // "expandSelection"); //$NON-NLS-1$ //$NON-NLS-2$
- // structureSelection.add(fStructureSelectEnclosingAction);
- // structureSelection.add(fStructureSelectNextAction);
- // structureSelection.add(fStructureSelectPreviousAction);
- // structureSelection.add(fStructureSelectHistoryAction);
- // editMenu.appendToGroup(IContextMenuConstants.GROUP_OPEN,
- // structureSelection);
- // editMenu.appendToGroup(IContextMenuConstants.GROUP_GENERATE,
- // fRetargetShowJavaDoc);
- }
- // IMenuManager navigateMenu=
- // menu.findMenuUsingPath(IWorkbenchActionConstants.M_NAVIGATE);
- // if (navigateMenu != null) {
- // navigateMenu.appendToGroup(IWorkbenchActionConstants.SHOW_EXT,
- // fShowOutline);
- // }
- IMenuManager gotoMenu = menu.findMenuUsingPath("navigate/goTo"); //$NON-NLS-1$
- if (gotoMenu != null) {
- gotoMenu.add(new Separator("additions2")); //$NON-NLS-1$
- // gotoMenu.appendToGroup("additions2", fGotoPreviousMemberAction);
- // //$NON-NLS-1$
- // gotoMenu.appendToGroup("additions2", fGotoNextMemberAction);
- // //$NON-NLS-1$
- gotoMenu.appendToGroup("additions2", fGotoMatchingBracket); //$NON-NLS-1$
- }
- }
- /*
- * @see EditorActionBarContributor#contributeToToolBar(IToolBarManager)
- */
- public void contributeToToolBar(IToolBarManager tbm) {
- tbm.add(new Separator());
- Iterator e = fRetargetToolbarActions.iterator();
- while (e.hasNext())
- tbm.add((IAction) e.next());
+
+ IMenuManager editMenu= menu.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
+ if (editMenu != null) {
+ editMenu.appendToGroup(IContextMenuConstants.GROUP_GENERATE, fRetargetContentAssist);
+// editMenu.appendToGroup(IContextMenuConstants.GROUP_GENERATE, fCorrectionAssist);
+ editMenu.appendToGroup(IContextMenuConstants.GROUP_GENERATE, fContextInformation);
+ }
}
+// /*
+// * @see EditorActionBarContributor#contributeToToolBar(IToolBarManager)
+// */
+// public void contributeToToolBar(IToolBarManager tbm) {
+// tbm.add(new Separator());
+// Iterator e = fRetargetToolbarActions.iterator();
+// while (e.hasNext())
+// tbm.add((IAction) e.next());
+// }
/*
* @see IEditorActionBarContributor#init(IActionBars, IWorkbenchPage)
*/
- public void init(IActionBars bars, IWorkbenchPage page) {
- Iterator e = fPartListeners.iterator();
- while (e.hasNext())
- page.addPartListener((RetargetAction) e.next());
- // character encoding
- fEncodingActionGroup.fillActionBars(bars);
- super.init(bars, page);
- }
- /*
- * @see IEditorActionBarContributor#init(IActionBars)
- */
- public void init(IActionBars bars) {
- super.init(bars);
- IMenuManager menuManager = bars.getMenuManager();
- IMenuManager editMenu = menuManager
- .findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
- if (editMenu != null) {
- editMenu.add(new Separator());
- editMenu.add(fContentAssist);
- // editMenu.add(fGotoMatchingBracket);
- // editMenu.add(fContentAssistTip);
- }
- bars.setGlobalActionHandler(PHPdtActionConstants.CONTENT_ASSIST,
- fContentAssist);
- // IToolBarManager toolBarManager = bars.getToolBarManager();
- // if (toolBarManager != null) {
- // toolBarManager.add(new Separator());
- // toolBarManager.add(fTogglePresentation);
- // }
- }
+// public void init(IActionBars bars, IWorkbenchPage page) {
+// Iterator e = fPartListeners.iterator();
+// while (e.hasNext())
+// page.addPartListener((RetargetAction) e.next());
+// // character encoding
+// fEncodingActionGroup.fillActionBars(bars);
+// super.init(bars, page);
+// }
+
+ /*
+ * @see IEditorActionBarContributor#init(IActionBars, IWorkbenchPage)
+ */
+ public void init(IActionBars bars, IWorkbenchPage page) {
+ super.init(bars, page);
+
+ // register actions that have a dynamic editor.
+ bars.setGlobalActionHandler(PHPdtActionConstants.CONTENT_ASSIST, fContentAssist);
+ // character encoding
+ fEncodingActionGroup.fillActionBars(bars);
+ }
+ // /*
+// * @see IEditorActionBarContributor#init(IActionBars)
+// */
+// public void init(IActionBars bars) {
+// super.init(bars);
+// IMenuManager menuManager = bars.getMenuManager();
+// IMenuManager editMenu = menuManager
+// .findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
+// if (editMenu != null) {
+// editMenu.add(new Separator());
+// editMenu.add(fContentAssist);
+// // editMenu.add(fGotoMatchingBracket);
+// // editMenu.add(fContentAssistTip);
+// }
+// bars.setGlobalActionHandler(PHPdtActionConstants.CONTENT_ASSIST,
+// fContentAssist);
+// // IToolBarManager toolBarManager = bars.getToolBarManager();
+// // if (toolBarManager != null) {
+// // toolBarManager.add(new Separator());
+// // toolBarManager.add(fTogglePresentation);
+// // }
+// }
+
+
/*
* @see IEditorActionBarContributor#setActiveEditor(IEditorPart)
*/
IStatusLineManager manager = bars.getStatusLineManager();
manager.setMessage(null);
manager.setErrorMessage(null);
- ITextEditor textEditor = null;
+
+ ITextEditor textEditor = null;
if (part instanceof ITextEditor)
textEditor = (ITextEditor) part;
- fContentAssist.setAction(getAction(textEditor, "ContentAssistProposal")); //$NON-NLS-1$
- fContentAssistTip.setAction(getAction(textEditor, "ContentAssistTip")); //$NON-NLS-1$
- fGotoMatchingBracket.setAction(getAction(textEditor,
- GotoMatchingBracketAction.GOTO_MATCHING_BRACKET));
- bars.setGlobalActionHandler(PHPdtActionConstants.SHIFT_RIGHT, getAction(
- textEditor, "ShiftRight")); //$NON-NLS-1$
- bars.setGlobalActionHandler(PHPdtActionConstants.SHIFT_LEFT, getAction(
- textEditor, "ShiftLeft")); //$NON-NLS-1$
- // character encoding
- fEncodingActionGroup.retarget(textEditor);
- bars.setGlobalActionHandler(PHPdtActionConstants.COMMENT, getAction(
- textEditor, "Comment"));
- bars.setGlobalActionHandler(PHPdtActionConstants.UNCOMMENT, getAction(
- textEditor, "Uncomment"));
- bars.setGlobalActionHandler(PHPdtActionConstants.FORMAT, getAction(
- textEditor, "Format"));
- if (part instanceof PHPEditor) {
- PHPEditor phpEditor = (PHPEditor) part;
- phpEditor.getActionGroup().fillActionBars(getActionBars());
- }
- // if (part instanceof PHPEditor) {
- // PHPEditor cuEditor = (PHPEditor) part;
- // ActionGroup group = cuEditor.getActionGroup();
- // if (group != null)
- // group.fillActionBars(bars);
- // }
- // fTogglePresentation.setEditor(editor);
- // fTogglePresentation.update();
+
+ fContentAssist.setAction(getAction(textEditor, "ContentAssistProposal")); //$NON-NLS-1$
+ fContextInformation.setAction(getAction(textEditor, "ContentAssistContextInformation")); //$NON-NLS-1$
+// fCorrectionAssist.setAction(getAction(textEditor, "CorrectionAssistProposal")); //$NON-NLS-1$
+
+ IActionBars actionBars= getActionBars();
+ actionBars.setGlobalActionHandler(PHPdtActionConstants.SHIFT_RIGHT, getAction(textEditor, "ShiftRight")); //$NON-NLS-1$
+ actionBars.setGlobalActionHandler(PHPdtActionConstants.SHIFT_LEFT, getAction(textEditor, "ShiftLeft")); //$NON-NLS-1$
+
+ actionBars.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), getAction(textEditor, IDEActionFactory.ADD_TASK.getId())); //$NON-NLS-1$
+ actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), getAction(textEditor, IDEActionFactory.BOOKMARK.getId())); //$NON-NLS-1$
+
+ // character encoding
+ fEncodingActionGroup.retarget(textEditor);
+
if (textEditor != null) {
IFile file = null;
IEditorInput editorInput = textEditor.getEditorInput();
}
}
}
- /*
- * @see IEditorActionBarContributor#dispose()
- */
- public void dispose() {
- Iterator e = fPartListeners.iterator();
- while (e.hasNext())
- getPage().removePartListener((RetargetAction) e.next());
- fPartListeners.clear();
- setActiveEditor(null);
- super.dispose();
- }
+
}
import net.sourceforge.phpdt.core.IMember;
import net.sourceforge.phpdt.core.ISourceRange;
import net.sourceforge.phpdt.core.ISourceReference;
-import net.sourceforge.phpdt.core.JavaModelException;
import net.sourceforge.phpdt.core.JavaCore;
+import net.sourceforge.phpdt.core.JavaModelException;
import net.sourceforge.phpdt.internal.ui.actions.CompositeActionGroup;
import net.sourceforge.phpdt.internal.ui.text.HTMLTextPresenter;
+import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
import net.sourceforge.phpdt.internal.ui.text.PHPPairMatcher;
import net.sourceforge.phpdt.internal.ui.viewsupport.IViewPartInputProvider;
import net.sourceforge.phpdt.ui.IContextMenuConstants;
import net.sourceforge.phpdt.ui.JavaUI;
import net.sourceforge.phpdt.ui.PreferenceConstants;
-import net.sourceforge.phpdt.ui.actions.GenerateActionGroup;
import net.sourceforge.phpdt.ui.actions.GotoMatchingBracketAction;
import net.sourceforge.phpdt.ui.text.JavaTextTools;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-import net.sourceforge.phpeclipse.phpeditor.php.IPHPPartitionScannerConstants;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextHover;
import org.eclipse.jface.text.ITextInputListener;
-import org.eclipse.jface.text.ITextOperationTarget;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.ITextViewerExtension2;
import org.eclipse.ui.editors.text.DefaultEncodingSupport;
import org.eclipse.ui.editors.text.IEncodingSupport;
import org.eclipse.ui.part.IShowInTargetList;
-import org.eclipse.ui.texteditor.ContentAssistAction;
import org.eclipse.ui.texteditor.DefaultRangeIndicator;
import org.eclipse.ui.texteditor.ExtendedTextEditor;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.IEditorStatusLine;
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
-import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
import org.eclipse.ui.texteditor.MarkerAnnotation;
import org.eclipse.ui.texteditor.ResourceAction;
import org.eclipse.ui.texteditor.TextEditorAction;
protected JavaOutlinePage fOutlinePage;
/** Outliner context menu Id */
protected String fOutlinerContextMenuId;
+ /**
+ * The editor selection changed listener.
+ *
+ * @since 3.0
+ */
+// private EditorSelectionChangedListener fEditorSelectionChangedListener;
/** Indicates whether this editor should react on outline page selection changes */
private int fIgnoreOutlinePageSelection;
private MouseClickListener fMouseListener;
protected CompositeActionGroup fActionGroups;
- /** The standard action groups added to the menu */
- protected GenerateActionGroup fGenerateActionGroup;
protected CompositeActionGroup fContextMenuGroup;
/** The information presenter. */
*/
public PHPEditor() {
super();
- JavaTextTools textTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
- setSourceViewerConfiguration(new PHPSourceViewerConfiguration(textTools, this));
- setRangeIndicator(new DefaultRangeIndicator());
- setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
-
- // don't activate this scope without synchronizing plugin.xml !!!
- // setKeyBindingScopes(new String[] { "net.sourceforge.phpdt.ui.phpEditorScope" }); //$NON-NLS-1$
-
- if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE))
- fUpdater= new OutlinePageSelectionUpdater();
+ JavaTextTools textTools= PHPeclipsePlugin.getDefault().getJavaTextTools();
+ setSourceViewerConfiguration(new PHPSourceViewerConfiguration(textTools, this)); //, IJavaPartitions.JAVA_PARTITIONING));
+ setRangeIndicator(new DefaultRangeIndicator());
+ IPreferenceStore store= PHPeclipsePlugin.getDefault().getPreferenceStore();
+ setPreferenceStore(store);
+ setKeyBindingScopes(new String[] { "net.sourceforge.phpdt.ui.phpEditorScope" }); //$NON-NLS-1$
+// fMarkOccurrenceAnnotations= store.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
+// fStickyOccurrenceAnnotations= store.getBoolean(PreferenceConstants.EDITOR_STICKY_OCCURRENCES);
+
+ // TODO changed in 3.x ?
+ if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE))
+ fUpdater= new OutlinePageSelectionUpdater();
}
- //
- // /**
- // * @see IMember#getCompilationUnit()
- // */
- // public ICompilationUnit getCompilationUnit() {
- // return this;
- // }
- // /**
- // * @see org.phpeclipse.phpdt.internal.compiler.env.ICompilationUnit#getContents()
- // */
- // public char[] getContents() {
- // IDocument doc = this.getDocumentProvider().getDocument(this.getEditorInput());
- //
- // return doc.get().toCharArray();
- // }
+
/*
* @see org.eclipse.ui.texteditor.AbstractTextEditor#updatePropertyDependentActions()
*/
*/
protected void createActions() {
super.createActions();
+
+ ResourceAction resAction= new TextOperationAction(PHPEditorMessages.getResourceBundle(), "ShowJavaDoc.", this, ISourceViewer.INFORMATION, true); //$NON-NLS-1$
+ resAction= new InformationDispatchAction(PHPEditorMessages.getResourceBundle(), "ShowJavaDoc.", (TextOperationAction) resAction); //$NON-NLS-1$
+ resAction.setActionDefinitionId(PHPEditorActionDefinitionIds.SHOW_JAVADOC);
+ setAction("ShowJavaDoc", resAction); //$NON-NLS-1$
+// WorkbenchHelp.setHelp(resAction, IJavaHelpContextIds.SHOW_JAVADOC_ACTION);
+
+ Action action= new GotoMatchingBracketAction(this);
+ action.setActionDefinitionId(PHPEditorActionDefinitionIds.GOTO_MATCHING_BRACKET);
+ setAction(GotoMatchingBracketAction.GOTO_MATCHING_BRACKET, action);
+
+// action= new TextOperationAction(PHPEditorMessages.getResourceBundle(),"ShowOutline.", this, JavaSourceViewer.SHOW_OUTLINE, true); //$NON-NLS-1$
+// action.setActionDefinitionId(PHPEditorActionDefinitionIds.SHOW_OUTLINE);
+// setAction(PHPEditorActionDefinitionIds.SHOW_OUTLINE, action);
+//// WorkbenchHelp.setHelp(action, IJavaHelpContextIds.SHOW_OUTLINE_ACTION);
+//
+// action= new TextOperationAction(PHPEditorMessages.getResourceBundle(),"OpenStructure.", this, JavaSourceViewer.OPEN_STRUCTURE, true); //$NON-NLS-1$
+// action.setActionDefinitionId(PHPEditorActionDefinitionIds.SHOW_OUTLINE.OPEN_STRUCTURE);
+// setAction(PHPEditorActionDefinitionIds.SHOW_OUTLINE.OPEN_STRUCTURE, action);
+//// WorkbenchHelp.setHelp(action, IJavaHelpContextIds.OPEN_STRUCTURE_ACTION);
+//
+// action= new TextOperationAction(PHPEditorMessages.getResourceBundle(),"OpenHierarchy.", this, JavaSourceViewer.SHOW_HIERARCHY, true); //$NON-NLS-1$
+// action.setActionDefinitionId(PHPEditorActionDefinitionIds.SHOW_OUTLINE.OPEN_HIERARCHY);
+// setAction(PHPEditorActionDefinitionIds.SHOW_OUTLINE.OPEN_HIERARCHY, action);
+//// WorkbenchHelp.setHelp(action, IJavaHelpContextIds.OPEN_HIERARCHY_ACTION);
+
+ fEncodingSupport= new DefaultEncodingSupport();
+ fEncodingSupport.initialize(this);
+
+// fSelectionHistory= new SelectionHistory(this);
+//
+// action= new StructureSelectEnclosingAction(this, fSelectionHistory);
+// action.setActionDefinitionId(PHPEditorActionDefinitionIds.SELECT_ENCLOSING);
+// setAction(StructureSelectionAction.ENCLOSING, action);
+//
+// action= new StructureSelectNextAction(this, fSelectionHistory);
+// action.setActionDefinitionId(PHPEditorActionDefinitionIds.SELECT_NEXT);
+// setAction(StructureSelectionAction.NEXT, action);
+//
+// action= new StructureSelectPreviousAction(this, fSelectionHistory);
+// action.setActionDefinitionId(PHPEditorActionDefinitionIds.SELECT_PREVIOUS);
+// setAction(StructureSelectionAction.PREVIOUS, action);
+//
+// StructureSelectHistoryAction historyAction= new StructureSelectHistoryAction(this, fSelectionHistory);
+// historyAction.setActionDefinitionId(PHPEditorActionDefinitionIds.SELECT_LAST);
+// setAction(StructureSelectionAction.HISTORY, historyAction);
+// fSelectionHistory.setHistoryAction(historyAction);
+//
+// action= GoToNextPreviousMemberAction.newGoToNextMemberAction(this);
+// action.setActionDefinitionId(PHPEditorActionDefinitionIds.GOTO_NEXT_MEMBER);
+// setAction(GoToNextPreviousMemberAction.NEXT_MEMBER, action);
+//
+// action= GoToNextPreviousMemberAction.newGoToPreviousMemberAction(this);
+// action.setActionDefinitionId(PHPEditorActionDefinitionIds.GOTO_PREVIOUS_MEMBER);
+// setAction(GoToNextPreviousMemberAction.PREVIOUS_MEMBER, action);
+//
+// action= new QuickFormatAction();
+// action.setActionDefinitionId(PHPEditorActionDefinitionIds.QUICK_FORMAT);
+// setAction(IJavaEditorActionDefinitionIds.QUICK_FORMAT, action);
+//
+// action= new RemoveOccurrenceAnnotations(this);
+// action.setActionDefinitionId(PHPEditorActionDefinitionIds.REMOVE_OCCURRENCE_ANNOTATIONS);
+// setAction("RemoveOccurrenceAnnotations", action); //$NON-NLS-1$
- ResourceAction resAction = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "ShowJavaDoc.", this, ISourceViewer.INFORMATION, true); //$NON-NLS-1$
- resAction = new InformationDispatchAction(PHPEditorMessages.getResourceBundle(), "ShowJavaDoc.", (TextOperationAction) resAction); //$NON-NLS-1$
- resAction.setActionDefinitionId(PHPEditorActionDefinitionIds.SHOW_JAVADOC);
- setAction("ShowJavaDoc", resAction); //$NON-NLS-1$
- // WorkbenchHelp.setHelp(resAction, IJavaHelpContextIds.SHOW_JAVADOC_ACTION);
-
- Action action;
-
- setAction(
- "ContentAssistTip",
- new TextOperationAction(PHPEditorMessages.getResourceBundle(), "ContentAssistTip.", this, ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION));
-
- action = new ContentAssistAction(PHPEditorMessages.getResourceBundle(), "ContentAssistProposal.", this); //$NON-NLS-1$
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
- setAction("ContentAssistProposal", action); //$NON-NLS-1$
- markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$
- // WorkbenchHelp.setHelp(action, IJavaHelpContextIds.CONTENT_ASSIST_ACTION);
-
- fEncodingSupport = new DefaultEncodingSupport();
- fEncodingSupport.initialize(this);
-
- action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "Comment.", this, ITextOperationTarget.PREFIX); //$NON-NLS-1$
- action.setActionDefinitionId(PHPEditorActionDefinitionIds.COMMENT);
- setAction("Comment", action); //$NON-NLS-1$
- markAsStateDependentAction("Comment", true); //$NON-NLS-1$
- // WorkbenchHelp.setHelp(action, IJavaHelpContextIds.COMMENT_ACTION);
-
- action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "Uncomment.", this, ITextOperationTarget.STRIP_PREFIX); //$NON-NLS-1$
- action.setActionDefinitionId(PHPEditorActionDefinitionIds.UNCOMMENT);
- setAction("Uncomment", action); //$NON-NLS-1$
- markAsStateDependentAction("Uncomment", true); //$NON-NLS-1$
- // WorkbenchHelp.setHelp(action, IJavaHelpContextIds.UNCOMMENT_ACTION);
-
- action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "Format.", this, ISourceViewer.FORMAT); //$NON-NLS-1$
- action.setActionDefinitionId(PHPEditorActionDefinitionIds.FORMAT);
- setAction("Format", action); //$NON-NLS-1$
- markAsStateDependentAction("Format", true); //$NON-NLS-1$
- markAsSelectionDependentAction("Format", true); //$NON-NLS-1$
- // WorkbenchHelp.setHelp(action, IJavaHelpContextIds.FORMAT_ACTION);
-
- action = new GotoMatchingBracketAction(this);
- action.setActionDefinitionId(PHPEditorActionDefinitionIds.GOTO_MATCHING_BRACKET);
- setAction(GotoMatchingBracketAction.GOTO_MATCHING_BRACKET, action);
-
- fGenerateActionGroup = new GenerateActionGroup(this, ITextEditorActionConstants.GROUP_EDIT);
-
- fActionGroups = new CompositeActionGroup(new ActionGroup[] { fGenerateActionGroup });
-
- // We have to keep the context menu group separate to have better control over positioning
- fContextMenuGroup = new CompositeActionGroup(new ActionGroup[] { fGenerateActionGroup });
- // rg,
- // new LocalHistoryActionGroup(this, ITextEditorActionConstants.GROUP_EDIT)});
-
+ // add annotation actions
+ action= new JavaSelectMarkerRulerAction2(PHPEditorMessages.getResourceBundle(), "Editor.RulerAnnotationSelection.", this); //$NON-NLS-1$
+ setAction("AnnotationAction", action); //$NON-NLS-1$
+
// add annotation actions
action= new JavaSelectMarkerRulerAction2(PHPEditorMessages.getResourceBundle(), "Editor.RulerAnnotationSelection.", this); //$NON-NLS-1$
setAction("AnnotationAction", action); //$NON-NLS-1$
fOutlinePage.addSelectionChangedListener(fSelectionChangedListener);
}
}
- protected void updateStateDependentActions() {
- super.updateStateDependentActions();
- fGenerateActionGroup.editorStateChanged();
- }
protected void setSelection(ISourceReference reference, boolean moveCursor) {
return;
}
+// if (PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE.equals(property)) {
+// if ((event.getNewValue() instanceof Boolean) && ((Boolean)event.getNewValue()).booleanValue())
+// fEditorSelectionChangedListener.selectionChanged();
+// return;
+// }
+
+ if (PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE.equals(property)) {
+ if (event.getNewValue() instanceof Boolean) {
+ Boolean disable= (Boolean) event.getNewValue();
+ configureInsertMode(OVERWRITE, !disable.booleanValue());
+ }
+ }
+
+// if (PreferenceConstants.EDITOR_MARK_OCCURRENCES.equals(property)) {
+// if (event.getNewValue() instanceof Boolean) {
+// boolean markOccurrenceAnnotations= ((Boolean)event.getNewValue()).booleanValue();
+// if (markOccurrenceAnnotations != fMarkOccurrenceAnnotations) {
+// fMarkOccurrenceAnnotations= markOccurrenceAnnotations;
+// if (!fMarkOccurrenceAnnotations)
+// uninstallOccurrencesFinder();
+// else
+// installOccurrencesFinder();
+// }
+// }
+// }
+// if (PreferenceConstants.EDITOR_STICKY_OCCURRENCES.equals(property)) {
+// if (event.getNewValue() instanceof Boolean) {
+// boolean stickyOccurrenceAnnotations= ((Boolean)event.getNewValue()).booleanValue();
+// if (stickyOccurrenceAnnotations != fStickyOccurrenceAnnotations) {
+// fStickyOccurrenceAnnotations= stickyOccurrenceAnnotations;
+//// if (!fMarkOccurrenceAnnotations)
+//// uninstallOccurrencesFinder();
+//// else
+//// installOccurrencesFinder();
+// }
+// }
+// }
+
} finally {
super.handlePreferenceStoreChanged(event);
}
List segmentation = new ArrayList();
for (int i = 0; i < linePartitioning.length; i++) {
- if (IPHPPartitionScannerConstants.PHP_STRING.equals(linePartitioning[i].getType()))
+ if (IPHPPartitions.PHP_STRING.equals(linePartitioning[i].getType()))
segmentation.add(linePartitioning[i]);
}
package net.sourceforge.phpeclipse.phpeditor;
-public interface PHPEditorActionDefinitionIds {
+import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
+
+public interface PHPEditorActionDefinitionIds extends ITextEditorActionDefinitionIds {
/**
* Action definition ID of the edit -> go to matching bracket action
* (value <code>"org.phpeclipse.phpdt.ui.edit.text.php.goto.matching.bracket"</code>).
* Value: net.sourceforge.phpeclipse.phpeditor.uncomment
*/
public static final String UNCOMMENT = "net.sourceforge.phpeclipse.phpeditor.uncomment";
+ /**
+ * Action definition ID of the source -> toggle comment action
+ * (value <code>"org.eclipse.jdt.ui.edit.text.java.toggle.comment"</code>).
+ * @since 3.0
+ */
+ public static final String TOGGLE_COMMENT= "net.sourceforge.phpeclipse.phpeditor.toggle.comment"; //$NON-NLS-1$
+
+
+ /**
+ * Action definition ID of the source -> add block comment action
+ * (value <code>"org.eclipse.jdt.ui.edit.text.java.add.block.comment"</code>).
+ * @since 3.0
+ */
+ public static final String ADD_BLOCK_COMMENT= "net.sourceforge.phpeclipse.phpeditor.add.block.comment"; //$NON-NLS-1$
+ /**
+ * Action definition ID of the source -> remove block comment action
+ * (value <code>"org.eclipse.jdt.ui.edit.text.java.remove.block.comment"</code>).
+ * @since 3.0
+ */
+ public static final String REMOVE_BLOCK_COMMENT= "net.sourceforge.phpeclipse.phpeditor.remove.block.comment"; //$NON-NLS-1$
+
+ /**
+ * Action definition ID of the source -> indent action
+ * (value <code>"org.eclipse.jdt.ui.edit.text.java.indent"</code>).
+ */
+ public static final String INDENT= "net.sourceforge.phpeclipse.phpeditor.indent"; //$NON-NLS-1$
+
/**
* Action definition ID of the source -> format action
*/
import net.sourceforge.phpdt.core.JavaCore;
import net.sourceforge.phpdt.internal.ui.text.ContentAssistPreference;
import net.sourceforge.phpdt.internal.ui.text.HTMLTextPresenter;
+import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
import net.sourceforge.phpdt.internal.ui.text.JavaAnnotationHover;
import net.sourceforge.phpdt.internal.ui.text.JavaElementProvider;
import net.sourceforge.phpdt.internal.ui.text.JavaOutlineInformationControl;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
import net.sourceforge.phpeclipse.phpeditor.html.HTMLFormattingStrategy;
import net.sourceforge.phpeclipse.phpeditor.php.HTMLCompletionProcessor;
-import net.sourceforge.phpeclipse.phpeditor.php.IPHPPartitionScannerConstants;
import net.sourceforge.phpeclipse.phpeditor.php.PHPAutoIndentStrategy;
import net.sourceforge.phpeclipse.phpeditor.php.PHPCompletionProcessor;
import net.sourceforge.phpeclipse.phpeditor.php.PHPDoubleClickSelector;
*/
public IAutoIndentStrategy getAutoIndentStrategy(
ISourceViewer sourceViewer, String contentType) {
- return (IPHPPartitionScannerConstants.PHP.equals(contentType)
+ return (IPHPPartitions.PHP_PARTITIONING.equals(contentType)
? new PHPAutoIndentStrategy()
: new DefaultAutoIndentStrategy());
}
* (non-Javadoc) Method declared on SourceViewerConfiguration
*/
public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
- return new String[]{IPHPPartitionScannerConstants.HTML,
- IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT,
- IPHPPartitionScannerConstants.PHP,
- IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT,
- IPHPPartitionScannerConstants.CSS,
- IPHPPartitionScannerConstants.CSS_MULTILINE_COMMENT,
- IPHPPartitionScannerConstants.JAVASCRIPT,
- IPHPPartitionScannerConstants.JS_MULTILINE_COMMENT,
- IPHPPartitionScannerConstants.SMARTY,
- IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT,
+ return new String[]{IPHPPartitions.HTML,
+ IPHPPartitions.HTML_MULTILINE_COMMENT,
+ IPHPPartitions.PHP_PARTITIONING,
+ IPHPPartitions.PHP_MULTILINE_COMMENT,
+ IPHPPartitions.CSS,
+ IPHPPartitions.CSS_MULTILINE_COMMENT,
+ IPHPPartitions.JAVASCRIPT,
+ IPHPPartitions.JS_MULTILINE_COMMENT,
+ IPHPPartitions.SMARTY,
+ IPHPPartitions.SMARTY_MULTILINE_COMMENT,
IDocument.DEFAULT_CONTENT_TYPE};
}
/*
ContentAssistant assistant = new ContentAssistant();
IContentAssistProcessor processor = new HTMLCompletionProcessor();
assistant.setContentAssistProcessor(processor,
- IPHPPartitionScannerConstants.HTML);
+ IPHPPartitions.HTML);
assistant.setContentAssistProcessor(processor,
- IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
+ IPHPPartitions.HTML_MULTILINE_COMMENT);
assistant.setContentAssistProcessor(processor,
IDocument.DEFAULT_CONTENT_TYPE);
assistant.setContentAssistProcessor(processor,
- IPHPPartitionScannerConstants.CSS);
+ IPHPPartitions.CSS);
assistant.setContentAssistProcessor(processor,
- IPHPPartitionScannerConstants.CSS_MULTILINE_COMMENT);
+ IPHPPartitions.CSS_MULTILINE_COMMENT);
assistant.setContentAssistProcessor(processor,
- IPHPPartitionScannerConstants.JAVASCRIPT);
+ IPHPPartitions.JAVASCRIPT);
assistant.setContentAssistProcessor(processor,
- IPHPPartitionScannerConstants.JS_MULTILINE_COMMENT);
+ IPHPPartitions.JS_MULTILINE_COMMENT);
// TODO define special smarty partition content assist
assistant.setContentAssistProcessor(processor,
- IPHPPartitionScannerConstants.SMARTY);
+ IPHPPartitions.SMARTY);
assistant.setContentAssistProcessor(processor,
- IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT);
+ IPHPPartitions.SMARTY_MULTILINE_COMMENT);
assistant.setContentAssistProcessor(new PHPCompletionProcessor(),
- IPHPPartitionScannerConstants.PHP);
+ IPHPPartitions.PHP_PARTITIONING);
assistant.setContentAssistProcessor(new PHPDocCompletionProcessor(),
- IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
+ IPHPPartitions.PHP_MULTILINE_COMMENT);
// assistant.enableAutoActivation(true);
// assistant.setAutoActivationDelay(500);
// assistant.setProposalPopupOrientation(ContentAssistant.PROPOSAL_OVERLAY);
reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
dr = new DefaultDamagerRepairer(getHTMLScanner());
- reconciler.setDamager(dr, IPHPPartitionScannerConstants.HTML);
- reconciler.setRepairer(dr, IPHPPartitionScannerConstants.HTML);
+ reconciler.setDamager(dr, IPHPPartitions.HTML);
+ reconciler.setRepairer(dr, IPHPPartitions.HTML);
dr = new DefaultDamagerRepairer(getHTMLScanner());
- reconciler.setDamager(dr, IPHPPartitionScannerConstants.CSS);
- reconciler.setRepairer(dr, IPHPPartitionScannerConstants.CSS);
+ reconciler.setDamager(dr, IPHPPartitions.CSS);
+ reconciler.setRepairer(dr, IPHPPartitions.CSS);
dr = new DefaultDamagerRepairer(getHTMLScanner());
reconciler.setDamager(dr,
- IPHPPartitionScannerConstants.CSS_MULTILINE_COMMENT);
+ IPHPPartitions.CSS_MULTILINE_COMMENT);
reconciler.setRepairer(dr,
- IPHPPartitionScannerConstants.CSS_MULTILINE_COMMENT);
+ IPHPPartitions.CSS_MULTILINE_COMMENT);
dr = new DefaultDamagerRepairer(getHTMLScanner());
- reconciler.setDamager(dr, IPHPPartitionScannerConstants.JAVASCRIPT);
- reconciler.setRepairer(dr, IPHPPartitionScannerConstants.JAVASCRIPT);
+ reconciler.setDamager(dr, IPHPPartitions.JAVASCRIPT);
+ reconciler.setRepairer(dr, IPHPPartitions.JAVASCRIPT);
dr = new DefaultDamagerRepairer(getHTMLScanner());
reconciler.setDamager(dr,
- IPHPPartitionScannerConstants.JS_MULTILINE_COMMENT);
+ IPHPPartitions.JS_MULTILINE_COMMENT);
reconciler.setRepairer(dr,
- IPHPPartitionScannerConstants.JS_MULTILINE_COMMENT);
+ IPHPPartitions.JS_MULTILINE_COMMENT);
dr = new DefaultDamagerRepairer(getSmartyScanner());
- reconciler.setDamager(dr, IPHPPartitionScannerConstants.SMARTY);
- reconciler.setRepairer(dr, IPHPPartitionScannerConstants.SMARTY);
+ reconciler.setDamager(dr, IPHPPartitions.SMARTY);
+ reconciler.setRepairer(dr, IPHPPartitions.SMARTY);
dr = new DefaultDamagerRepairer(getSmartyDocScanner());
reconciler.setDamager(dr,
- IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT);
+ IPHPPartitions.SMARTY_MULTILINE_COMMENT);
reconciler.setRepairer(dr,
- IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT);
+ IPHPPartitions.SMARTY_MULTILINE_COMMENT);
dr = new DefaultDamagerRepairer(new SingleTokenScanner(
new TextAttribute(fJavaTextTools.getColorManager().getColor(
PHPColorProvider.MULTI_LINE_COMMENT))));
reconciler.setDamager(dr,
- IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
+ IPHPPartitions.HTML_MULTILINE_COMMENT);
reconciler.setRepairer(dr,
- IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
+ IPHPPartitions.HTML_MULTILINE_COMMENT);
dr = new DefaultDamagerRepairer(getCodeScanner());
- reconciler.setDamager(dr, IPHPPartitionScannerConstants.PHP);
- reconciler.setRepairer(dr, IPHPPartitionScannerConstants.PHP);
+ reconciler.setDamager(dr, IPHPPartitions.PHP_PARTITIONING);
+ reconciler.setRepairer(dr, IPHPPartitions.PHP_PARTITIONING);
dr = new DefaultDamagerRepairer(getPHPDocScanner());
reconciler.setDamager(dr,
- IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
+ IPHPPartitions.PHP_MULTILINE_COMMENT);
reconciler.setRepairer(dr,
- IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
+ IPHPPartitions.PHP_MULTILINE_COMMENT);
return reconciler;
}
/*
presenter.setInformationProvider(provider,
IDocument.DEFAULT_CONTENT_TYPE);
presenter.setInformationProvider(provider,
- IPHPPartitionScannerConstants.PHP);
+ IPHPPartitions.PHP_PARTITIONING);
presenter.setInformationProvider(provider,
- IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
+ IPHPPartitions.PHP_MULTILINE_COMMENT);
presenter.setInformationProvider(provider,
- IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT);
+ IPHPPartitions.SMARTY_MULTILINE_COMMENT);
presenter.setInformationProvider(provider,
- IPHPPartitionScannerConstants.HTML);
+ IPHPPartitions.HTML);
presenter.setInformationProvider(provider,
- IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
+ IPHPPartitions.HTML_MULTILINE_COMMENT);
presenter.setSizeConstraints(40, 20, true, false);
return presenter;
}
package net.sourceforge.phpeclipse.phpeditor;
-
import java.lang.reflect.InvocationTargetException;
import java.text.MessageFormat;
import java.util.ArrayList;
import net.sourceforge.phpdt.core.IJavaElement;
import net.sourceforge.phpdt.core.ISourceRange;
import net.sourceforge.phpdt.core.ISourceReference;
-import net.sourceforge.phpdt.core.JavaModelException;
import net.sourceforge.phpdt.core.JavaCore;
+import net.sourceforge.phpdt.core.JavaModelException;
import net.sourceforge.phpdt.internal.compiler.parser.Scanner;
+import net.sourceforge.phpdt.internal.ui.actions.AddBlockCommentAction;
+import net.sourceforge.phpdt.internal.ui.actions.CompositeActionGroup;
+import net.sourceforge.phpdt.internal.ui.actions.RemoveBlockCommentAction;
import net.sourceforge.phpdt.internal.ui.text.ContentAssistPreference;
+import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
import net.sourceforge.phpdt.internal.ui.text.PHPPairMatcher;
import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionManager;
import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionUI;
import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionUI.ExitFlags;
import net.sourceforge.phpdt.ui.IWorkingCopyManager;
import net.sourceforge.phpdt.ui.PreferenceConstants;
+import net.sourceforge.phpdt.ui.actions.GenerateActionGroup;
import net.sourceforge.phpdt.ui.text.JavaTextTools;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-import net.sourceforge.phpeclipse.phpeditor.php.IPHPPartitionScannerConstants;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ILineTracker;
import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextOperationTarget;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.text.ITextViewerExtension;
import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.VerifyKeyListener;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
import org.eclipse.ui.dialogs.SaveAsDialog;
import org.eclipse.ui.editors.text.IStorageDocumentProvider;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.texteditor.ContentAssistAction;
import org.eclipse.ui.texteditor.IDocumentProvider;
-
-/**********************************************************************
-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 org.eclipse.ui.texteditor.ITextEditorActionConstants;
+import org.eclipse.ui.texteditor.TextOperationAction;
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
/**
* PHP specific text editor.
*/
public class PHPUnitEditor extends PHPEditor {
-
interface ITextConverter {
void customizeDocumentCommand(IDocument document, DocumentCommand command);
};
-
// class AdaptedRulerLayout extends Layout {
//
// protected int fGap;
// fAdaptedSourceViewer = asv;
// }
//
- // protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
+ // protected Point computeSize(Composite composite, int wHint, int hHint,
+ // boolean flushCache) {
// Control[] children = composite.getChildren();
- // Point s = children[children.length - 1].computeSize(SWT.DEFAULT, SWT.DEFAULT, flushCache);
+ // Point s = children[children.length - 1].computeSize(SWT.DEFAULT,
+ // SWT.DEFAULT, flushCache);
// if (fAdaptedSourceViewer.isVerticalRulerVisible())
// s.x += fAdaptedSourceViewer.getVerticalRuler().getWidth() + fGap;
// return s;
// if (fAdaptedSourceViewer.isOverviewRulerVisible()) {
// OverviewRuler or = fAdaptedSourceViewer.getOverviewRuler();
// orWidth = or.getWidth();
- // or.getControl().setBounds(clArea.width - orWidth, scrollbarHeight, orWidth, clArea.height - 3 * scrollbarHeight);
+ // or.getControl().setBounds(clArea.width - orWidth, scrollbarHeight,
+ // orWidth, clArea.height - 3 * scrollbarHeight);
// }
//
- // textWidget.setBounds(vrWidth + fGap, 0, clArea.width - vrWidth - orWidth - 2 * fGap, clArea.height);
+ // textWidget.setBounds(vrWidth + fGap, 0, clArea.width - vrWidth - orWidth -
+ // 2 * fGap, clArea.height);
// vr.getControl().setBounds(0, 0, vrWidth, clArea.height - scrollbarHeight);
//
// } else {
// }
// };
//
- // class AdaptedSourceViewer extends SourceViewer { // extends JavaCorrectionSourceViewer {
+ // class AdaptedSourceViewer extends SourceViewer { // extends
+ // JavaCorrectionSourceViewer {
//
// private List fTextConverters;
//
// private OverviewRuler fOverviewRuler;
// private boolean fIsOverviewRulerVisible;
// /** The viewer's overview ruler hovering controller */
- // private AbstractHoverInformationControlManager fOverviewRulerHoveringController;
+ // private AbstractHoverInformationControlManager
+ // fOverviewRulerHoveringController;
//
// private boolean fIgnoreTextConverters = false;
//
// private IVerticalRuler fCachedVerticalRuler;
// private boolean fCachedIsVerticalRulerVisible;
//
- // public AdaptedSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
+ // public AdaptedSourceViewer(Composite parent, IVerticalRuler ruler, int
+ // styles) {
// super(parent, ruler, styles); //, CompilationUnitEditor.this);
//
// fCachedVerticalRuler = ruler;
// */
// public void showAnnotations(boolean show) {
// fCachedIsVerticalRulerVisible = (show && fCachedVerticalRuler != null);
- // // super.showAnnotations(show);
+ // // super.showAnnotations(show);
// }
//
// public IContentAssistant getContentAssistant() {
// super.customizeDocumentCommand(command);
// if (!fIgnoreTextConverters && fTextConverters != null) {
// for (Iterator e = fTextConverters.iterator(); e.hasNext();)
- // ((ITextConverter) e.next()).customizeDocumentCommand(getDocument(), command);
+ // ((ITextConverter) e.next()).customizeDocumentCommand(getDocument(),
+ // command);
// }
// fIgnoreTextConverters = false;
// }
// fOverviewRuler.createControl(composite, this);
// }
// }
-
// protected void ensureOverviewHoverManagerInstalled() {
- // if (fOverviewRulerHoveringController == null && fAnnotationHover != null && fHoverControlCreator != null) {
+ // if (fOverviewRulerHoveringController == null && fAnnotationHover != null
+ // && fHoverControlCreator != null) {
// fOverviewRulerHoveringController =
- // new OverviewRulerHoverManager(fOverviewRuler, this, fAnnotationHover, fHoverControlCreator);
+ // new OverviewRulerHoverManager(fOverviewRuler, this, fAnnotationHover,
+ // fHoverControlCreator);
// fOverviewRulerHoveringController.install(fOverviewRuler.getControl());
// }
// }
// IAnnotationModel annotationModel,
// int visibleRegionOffset,
// int visibleRegionLength) {
- // super.setDocument(document, annotationModel, visibleRegionOffset, visibleRegionLength);
+ // super.setDocument(document, annotationModel, visibleRegionOffset,
+ // visibleRegionLength);
// fOverviewRuler.setModel(annotationModel);
// }
//
// }
//
// /*
- // * @see org.eclipse.jface.text.source.ISourceViewer#configure(org.eclipse.jface.text.source.SourceViewerConfiguration)
+ // * @see
+ // org.eclipse.jface.text.source.ISourceViewer#configure(org.eclipse.jface.text.source.SourceViewerConfiguration)
// */
// public void configure(SourceViewerConfiguration configuration) {
// super.configure(configuration);
- // // prependAutoEditStrategy(new SmartBracesAutoEditStrategy(this), IDocument.DEFAULT_CONTENT_TYPE);
+ // // prependAutoEditStrategy(new SmartBracesAutoEditStrategy(this),
+ // IDocument.DEFAULT_CONTENT_TYPE);
// }
//
// protected void handleDispose() {
// }
//
// };
-
class AdaptedSourceViewer extends JavaSourceViewer {
-
private List fTextConverters;
private boolean fIgnoreTextConverters = false;
// private JavaCorrectionAssistant fCorrectionAssistant;
-
- public AdaptedSourceViewer(
- Composite parent,
- IVerticalRuler verticalRuler,
- IOverviewRuler overviewRuler,
- boolean showAnnotationsOverview,
- int styles) {
- super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles);
+ public AdaptedSourceViewer(Composite parent, IVerticalRuler verticalRuler,
+ IOverviewRuler overviewRuler, boolean showAnnotationsOverview,
+ int styles) {
+ super(parent, verticalRuler, overviewRuler, showAnnotationsOverview,
+ styles);
}
-
public IContentAssistant getContentAssistant() {
return fContentAssistant;
}
-
/*
* @see ITextOperationTarget#doOperation(int)
*/
public void doOperation(int operation) {
-
if (getTextWidget() == null)
return;
-
switch (operation) {
case CONTENTASSIST_PROPOSALS :
String msg = fContentAssistant.showPossibleCompletions();
setStatusLineErrorMessage(msg);
return;
- // case CORRECTIONASSIST_PROPOSALS:
- // fCorrectionAssistant.showPossibleCompletions();
- // return;
+ // case CORRECTIONASSIST_PROPOSALS:
+ // fCorrectionAssistant.showPossibleCompletions();
+ // return;
case UNDO :
fIgnoreTextConverters = true;
break;
fIgnoreTextConverters = true;
break;
}
-
super.doOperation(operation);
}
-
/*
* @see ITextOperationTarget#canDoOperation(int)
*/
// return isEditable();
return super.canDoOperation(operation);
}
-
/*
* @see TextViewer#handleDispose()
*/
// }
super.handleDispose();
}
-
public void insertTextConverter(ITextConverter textConverter, int index) {
throw new UnsupportedOperationException();
}
-
public void addTextConverter(ITextConverter textConverter) {
if (fTextConverters == null) {
fTextConverters = new ArrayList(1);
} else if (!fTextConverters.contains(textConverter))
fTextConverters.add(textConverter);
}
-
public void removeTextConverter(ITextConverter textConverter) {
if (fTextConverters != null) {
fTextConverters.remove(textConverter);
fTextConverters = null;
}
}
-
/*
* @see TextViewer#customizeDocumentCommand(DocumentCommand)
*/
super.customizeDocumentCommand(command);
if (!fIgnoreTextConverters && fTextConverters != null) {
for (Iterator e = fTextConverters.iterator(); e.hasNext();)
- ((ITextConverter) e.next()).customizeDocumentCommand(getDocument(), command);
+ ((ITextConverter) e.next()).customizeDocumentCommand(getDocument(),
+ command);
}
fIgnoreTextConverters = false;
}
-
// http://dev.eclipse.org/bugs/show_bug.cgi?id=19270
public void updateIndentationPrefixes() {
SourceViewerConfiguration configuration = getSourceViewerConfiguration();
setIndentPrefixes(prefixes, types[i]);
}
}
-
/*
* @see IWidgetTokenOwner#requestWidgetToken(IWidgetTokenKeeper)
*/
return false;
return super.requestWidgetToken(requester);
}
-
/*
* @see org.eclipse.jface.text.source.ISourceViewer#configure(org.eclipse.jface.text.source.SourceViewerConfiguration)
*/
public void configure(SourceViewerConfiguration configuration) {
super.configure(configuration);
- // fCorrectionAssistant= new JavaCorrectionAssistant(CompilationUnitEditor.this);
+ // fCorrectionAssistant= new
+ // JavaCorrectionAssistant(CompilationUnitEditor.this);
// fCorrectionAssistant.install(this);
//TODO install SmartBracesAutoEditStrategy
- // prependAutoEditStrategy(new SmartBracesAutoEditStrategy(this), IDocument.DEFAULT_CONTENT_TYPE);
+ // prependAutoEditStrategy(new SmartBracesAutoEditStrategy(this),
+ // IDocument.DEFAULT_CONTENT_TYPE);
}
};
static class TabConverter implements ITextConverter {
-
private int fTabRatio;
private ILineTracker fLineTracker;
-
public TabConverter() {
}
-
public void setNumberOfSpacesPerTab(int ratio) {
fTabRatio = ratio;
}
-
public void setLineTracker(ILineTracker lineTracker) {
fLineTracker = lineTracker;
}
-
private int insertTabString(StringBuffer buffer, int offsetInLine) {
-
if (fTabRatio == 0)
return 0;
-
int remainder = offsetInLine % fTabRatio;
remainder = fTabRatio - remainder;
for (int i = 0; i < remainder; i++)
buffer.append(' ');
return remainder;
}
-
- public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
+ public void customizeDocumentCommand(IDocument document,
+ DocumentCommand command) {
String text = command.text;
if (text == null)
return;
-
int index = text.indexOf('\t');
if (index > -1) {
-
StringBuffer buffer = new StringBuffer();
-
fLineTracker.set(command.text);
int lines = fLineTracker.getNumberOfLines();
-
try {
-
for (int i = 0; i < lines; i++) {
-
int offset = fLineTracker.getLineOffset(i);
int endOffset = offset + fLineTracker.getLineLength(i);
String line = text.substring(offset, endOffset);
-
int position = 0;
if (i == 0) {
- IRegion firstLine = document.getLineInformationOfOffset(command.offset);
+ IRegion firstLine = document
+ .getLineInformationOfOffset(command.offset);
position = command.offset - firstLine.getOffset();
}
-
int length = line.length();
for (int j = 0; j < length; j++) {
char c = line.charAt(j);
++position;
}
}
-
}
-
command.text = buffer.toString();
-
} catch (BadLocationException x) {
}
}
}
};
-
private static class ExitPolicy implements LinkedPositionUI.ExitPolicy {
-
final char fExitCharacter;
-
public ExitPolicy(char exitCharacter) {
fExitCharacter = exitCharacter;
}
-
/*
- * @see org.phpeclipse.phpdt.internal.ui.text.link.LinkedPositionUI.ExitPolicy#doExit(org.phpeclipse.phpdt.internal.ui.text.link.LinkedPositionManager, org.eclipse.swt.events.VerifyEvent, int, int)
+ * @see org.phpeclipse.phpdt.internal.ui.text.link.LinkedPositionUI.ExitPolicy#doExit(org.phpeclipse.phpdt.internal.ui.text.link.LinkedPositionManager,
+ * org.eclipse.swt.events.VerifyEvent, int, int)
*/
- public ExitFlags doExit(LinkedPositionManager manager, VerifyEvent event, int offset, int length) {
-
+ public ExitFlags doExit(LinkedPositionManager manager, VerifyEvent event,
+ int offset, int length) {
if (event.character == fExitCharacter) {
if (manager.anyPositionIncludes(offset, length))
- return new ExitFlags(LinkedPositionUI.COMMIT | LinkedPositionUI.UPDATE_CARET, false);
+ return new ExitFlags(LinkedPositionUI.COMMIT
+ | LinkedPositionUI.UPDATE_CARET, false);
else
return new ExitFlags(LinkedPositionUI.COMMIT, true);
}
-
switch (event.character) {
case '\b' :
if (manager.getFirstPosition().length == 0)
return new ExitFlags(0, false);
else
return null;
-
case '\n' :
case '\r' :
return new ExitFlags(LinkedPositionUI.COMMIT, true);
-
default :
return null;
}
}
-
}
-
private static class BracketLevel {
int fOffset;
int fLength;
LinkedPositionManager fManager;
LinkedPositionUI fEditor;
};
-
- private class BracketInserter implements VerifyKeyListener, LinkedPositionUI.ExitListener {
-
+ private class BracketInserter
+ implements
+ VerifyKeyListener,
+ LinkedPositionUI.ExitListener {
private boolean fCloseBracketsPHP = true;
private boolean fCloseStringsPHP = true;
private boolean fCloseBracketsHTML = true;
private boolean fCloseStringsHTML = true;
-
private int fOffset;
private int fLength;
-
public void setCloseBracketsPHPEnabled(boolean enabled) {
fCloseBracketsPHP = enabled;
}
-
public void setCloseStringsPHPEnabled(boolean enabled) {
fCloseStringsPHP = enabled;
}
-
public void setCloseBracketsHTMLEnabled(boolean enabled) {
fCloseBracketsHTML = enabled;
}
-
public void setCloseStringsHTMLEnabled(boolean enabled) {
fCloseStringsHTML = enabled;
}
-
private boolean hasIdentifierToTheRight(IDocument document, int offset) {
try {
int end = offset;
int maxEnd = endLine.getOffset() + endLine.getLength();
while (end != maxEnd && Character.isWhitespace(document.getChar(end)))
++end;
-
- return end != maxEnd && Scanner.isPHPIdentifierPart(document.getChar(end));
-
+ return end != maxEnd
+ && Scanner.isPHPIdentifierPart(document.getChar(end));
} catch (BadLocationException e) {
// be conservative
return true;
}
}
-
private boolean hasIdentifierToTheLeft(IDocument document, int offset) {
try {
int start = offset;
IRegion startLine = document.getLineInformationOfOffset(start);
int minStart = startLine.getOffset();
- while (start != minStart && Character.isWhitespace(document.getChar(start - 1)))
+ while (start != minStart
+ && Character.isWhitespace(document.getChar(start - 1)))
--start;
-
- return start != minStart && Scanner.isPHPIdentifierPart(document.getChar(start - 1));
-
+ return start != minStart
+ && Scanner.isPHPIdentifierPart(document.getChar(start - 1));
} catch (BadLocationException e) {
return true;
}
}
-
- private boolean hasCharacterToTheRight(IDocument document, int offset, char character) {
+ private boolean hasCharacterToTheRight(IDocument document, int offset,
+ char character) {
try {
int end = offset;
IRegion endLine = document.getLineInformationOfOffset(end);
int maxEnd = endLine.getOffset() + endLine.getLength();
while (end != maxEnd && Character.isWhitespace(document.getChar(end)))
++end;
-
return end != maxEnd && document.getChar(end) == character;
-
} catch (BadLocationException e) {
// be conservative
return true;
}
}
-
/*
* @see org.eclipse.swt.custom.VerifyKeyListener#verifyKey(org.eclipse.swt.events.VerifyEvent)
*/
public void verifyKey(VerifyEvent event) {
-
if (!event.doit)
return;
-
final ISourceViewer sourceViewer = getSourceViewer();
IDocument document = sourceViewer.getDocument();
-
final Point selection = sourceViewer.getSelectedRange();
final int offset = selection.x;
final int length = selection.y;
-
try {
ITypedRegion partition = document.getPartition(offset);
String type = partition.getType();
- if (type.equals(IPHPPartitionScannerConstants.PHP)) {
+ if (type.equals(IPHPPartitions.PHP_PARTITIONING)) {
switch (event.character) {
case '(' :
if (hasCharacterToTheRight(document, offset + length, '('))
return;
-
- // fall through
-
+ // fall through
case '[' :
if (!fCloseBracketsPHP)
return;
if (hasIdentifierToTheRight(document, offset + length))
return;
-
- // fall through
-
+ // fall through
case '"' :
if (event.character == '"') {
if (!fCloseStringsPHP)
return;
- // changed for statements like echo "" print ""
- // if (hasIdentifierToTheLeft(document, offset) || hasIdentifierToTheRight(document, offset + length))
+ // changed for statements like echo "" print ""
+ // if (hasIdentifierToTheLeft(document, offset) ||
+ // hasIdentifierToTheRight(document, offset + length))
if (hasIdentifierToTheRight(document, offset + length))
return;
}
-
// ITypedRegion partition= document.getPartition(offset);
- // if (! IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType()) && (partition.getOffset() != offset))
+ // if (!
+ // IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType()) &&
+ // (partition.getOffset() != offset))
// return;
-
final char character = event.character;
final char closingCharacter = getPeerCharacter(character);
final StringBuffer buffer = new StringBuffer();
buffer.append(character);
buffer.append(closingCharacter);
-
document.replace(offset, length, buffer.toString());
-
- LinkedPositionManager manager = new LinkedPositionManager(document);
+ LinkedPositionManager manager = new LinkedPositionManager(
+ document);
manager.addPosition(offset + 1, 0);
-
fOffset = offset;
fLength = 2;
-
- LinkedPositionUI editor = new LinkedPositionUI(sourceViewer, manager);
+ LinkedPositionUI editor = new LinkedPositionUI(sourceViewer,
+ manager);
editor.setCancelListener(this);
editor.setExitPolicy(new ExitPolicy(closingCharacter));
editor.setFinalCaretOffset(offset + 2);
editor.enter();
-
IRegion newSelection = editor.getSelectedRegion();
- sourceViewer.setSelectedRange(newSelection.getOffset(), newSelection.getLength());
-
+ sourceViewer.setSelectedRange(newSelection.getOffset(),
+ newSelection.getLength());
event.doit = false;
}
- } else if (type.equals(IPHPPartitionScannerConstants.HTML) || type.equals(IDocument.DEFAULT_CONTENT_TYPE)) {
+ } else if (type.equals(IPHPPartitions.HTML)
+ || type.equals(IDocument.DEFAULT_CONTENT_TYPE)) {
switch (event.character) {
case '(' :
if (hasCharacterToTheRight(document, offset + length, '('))
return;
-
- // fall through
-
+ // fall through
case '[' :
if (!fCloseBracketsHTML)
return;
if (hasIdentifierToTheRight(document, offset + length))
return;
-
- // fall through
-
+ // fall through
case '"' :
if (event.character == '"') {
if (!fCloseStringsHTML)
return;
-
- if (hasIdentifierToTheLeft(document, offset) || hasIdentifierToTheRight(document, offset + length))
+ if (hasIdentifierToTheLeft(document, offset)
+ || hasIdentifierToTheRight(document, offset + length))
return;
}
-
// ITypedRegion partition= document.getPartition(offset);
- // if (! IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType()) && (partition.getOffset() != offset))
+ // if (!
+ // IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType()) &&
+ // (partition.getOffset() != offset))
// return;
-
final char character = event.character;
final char closingCharacter = getPeerCharacter(character);
final StringBuffer buffer = new StringBuffer();
buffer.append(character);
buffer.append(closingCharacter);
-
document.replace(offset, length, buffer.toString());
-
- LinkedPositionManager manager = new LinkedPositionManager(document);
+ LinkedPositionManager manager = new LinkedPositionManager(
+ document);
manager.addPosition(offset + 1, 0);
-
fOffset = offset;
fLength = 2;
-
- LinkedPositionUI editor = new LinkedPositionUI(sourceViewer, manager);
+ LinkedPositionUI editor = new LinkedPositionUI(sourceViewer,
+ manager);
editor.setCancelListener(this);
editor.setExitPolicy(new ExitPolicy(closingCharacter));
editor.setFinalCaretOffset(offset + 2);
editor.enter();
-
IRegion newSelection = editor.getSelectedRegion();
- sourceViewer.setSelectedRange(newSelection.getOffset(), newSelection.getLength());
-
+ sourceViewer.setSelectedRange(newSelection.getOffset(),
+ newSelection.getLength());
event.doit = false;
}
}
} catch (BadLocationException e) {
}
-
}
-
/*
* @see org.phpeclipse.phpdt.internal.ui.text.link.LinkedPositionUI.ExitListener#exit(boolean)
*/
public void exit(boolean accept) {
if (accept)
return;
-
// remove brackets
try {
final ISourceViewer sourceViewer = getSourceViewer();
} catch (BadLocationException e) {
}
}
-
}
-
/** The editor's save policy */
protected ISavePolicy fSavePolicy;
- /** Listener to annotation model changes that updates the error tick in the tab image */
+ /**
+ * Listener to annotation model changes that updates the error tick in the
+ * tab image
+ */
private JavaEditorErrorTickUpdater fJavaEditorErrorTickUpdater;
-
/** The editor's paint manager */
// private PaintManager fPaintManager;
/** The editor's bracket painter */
private TabConverter fTabConverter;
/** History for structure select action */
//private SelectionHistory fSelectionHistory;
-
/** The preference property change listener for php core. */
- // private IPropertyChangeListener fPropertyChangeListener = new PropertyChangeListener();
+ // private IPropertyChangeListener fPropertyChangeListener = new
+ // PropertyChangeListener();
/** The remembered java element */
private IJavaElement fRememberedElement;
/** The remembered selection */
private int fRememberedElementOffset;
/** The bracket inserter. */
private BracketInserter fBracketInserter = new BracketInserter();
-
+
+ /** The standard action groups added to the menu */
+ private GenerateActionGroup fGenerateActionGroup;
+ private CompositeActionGroup fContextMenuGroup;
// private class PropertyChangeListener implements IPropertyChangeListener {
// /*
// * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
// */
- // public void propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent event) {
+ // public void
+ // propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent
+ // event) {
// handlePreferencePropertyChanged(event);
// }
// }
/** Preference key for inserting spaces rather than tabs */
private final static String SPACES_FOR_TABS = PreferenceConstants.EDITOR_SPACES_FOR_TABS;
/** Preference key for error indication */
-// private final static String ERROR_INDICATION = PreferenceConstants.EDITOR_PROBLEM_INDICATION;
+ // private final static String ERROR_INDICATION =
+ // PreferenceConstants.EDITOR_PROBLEM_INDICATION;
/** Preference key for error color */
-// private final static String ERROR_INDICATION_COLOR = PreferenceConstants.EDITOR_PROBLEM_INDICATION_COLOR;
+ // private final static String ERROR_INDICATION_COLOR =
+ // PreferenceConstants.EDITOR_PROBLEM_INDICATION_COLOR;
/** Preference key for warning indication */
-// private final static String WARNING_INDICATION = PreferenceConstants.EDITOR_WARNING_INDICATION;
+ // private final static String WARNING_INDICATION =
+ // PreferenceConstants.EDITOR_WARNING_INDICATION;
/** Preference key for warning color */
-// private final static String WARNING_INDICATION_COLOR = PreferenceConstants.EDITOR_WARNING_INDICATION_COLOR;
+ // private final static String WARNING_INDICATION_COLOR =
+ // PreferenceConstants.EDITOR_WARNING_INDICATION_COLOR;
/** Preference key for task indication */
private final static String TASK_INDICATION = PreferenceConstants.EDITOR_TASK_INDICATION;
/** Preference key for task color */
private final static String LINKED_POSITION_COLOR = PreferenceConstants.EDITOR_LINKED_POSITION_COLOR;
/** Preference key for shwoing the overview ruler */
private final static String OVERVIEW_RULER = PreferenceConstants.EDITOR_OVERVIEW_RULER;
-
/** Preference key for error indication in overview ruler */
private final static String ERROR_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_ERROR_INDICATION_IN_OVERVIEW_RULER;
/** Preference key for warning indication in overview ruler */
- private final static String WARNING_INDICATION_IN_OVERVIEW_RULER =
- PreferenceConstants.EDITOR_WARNING_INDICATION_IN_OVERVIEW_RULER;
+ private final static String WARNING_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_WARNING_INDICATION_IN_OVERVIEW_RULER;
/** Preference key for task indication in overview ruler */
private final static String TASK_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER;
/** Preference key for bookmark indication in overview ruler */
- private final static String BOOKMARK_INDICATION_IN_OVERVIEW_RULER =
- PreferenceConstants.EDITOR_BOOKMARK_INDICATION_IN_OVERVIEW_RULER;
+ private final static String BOOKMARK_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_BOOKMARK_INDICATION_IN_OVERVIEW_RULER;
/** Preference key for search result indication in overview ruler */
- private final static String SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER =
- PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER;
+ private final static String SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER;
/** Preference key for unknown annotation indication in overview ruler */
- private final static String UNKNOWN_INDICATION_IN_OVERVIEW_RULER =
- PreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER;
+ private final static String UNKNOWN_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER;
/** Preference key for automatically closing strings */
private final static String CLOSE_STRINGS_PHP = PreferenceConstants.EDITOR_CLOSE_STRINGS_PHP;
/** Preference key for automatically wrapping Java strings */
private final static String CLOSE_STRINGS_HTML = PreferenceConstants.EDITOR_CLOSE_STRINGS_HTML;
/** Preference key for automatically closing brackets and parenthesis */
private final static String CLOSE_BRACKETS_HTML = PreferenceConstants.EDITOR_CLOSE_BRACKETS_HTML;
-
/** Preference key for smart paste */
private final static String SMART_PASTE = PreferenceConstants.EDITOR_SMART_PASTE;
// private final static class AnnotationInfo {
// public String fOverviewRulerPreference;
// public String fEditorPreference;
// };
-
// private final static Map ANNOTATION_MAP;
// static {
//
//
// info = new AnnotationInfo();
// info.fColorPreference = SEARCH_RESULT_INDICATION_COLOR;
- // info.fOverviewRulerPreference = SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER;
+ // info.fOverviewRulerPreference =
+ // SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER;
// info.fEditorPreference = SEARCH_RESULT_INDICATION;
// ANNOTATION_MAP.put(AnnotationType.SEARCH, info);
//
*/
public PHPUnitEditor() {
super();
- setDocumentProvider(PHPeclipsePlugin.getDefault().getCompilationUnitDocumentProvider());
+ setDocumentProvider(PHPeclipsePlugin.getDefault()
+ .getCompilationUnitDocumentProvider());
setEditorContextMenuId("#PHPEditorContext"); //$NON-NLS-1$
setRulerContextMenuId("#PHPRulerContext"); //$NON-NLS-1$
setOutlinerContextMenuId("#PHPOutlinerContext"); //$NON-NLS-1$
// don't set help contextId, we install our own help context
fSavePolicy = null;
-
fJavaEditorErrorTickUpdater = new JavaEditorErrorTickUpdater(this);
}
-
/*
- * @see JavaEditor#getElementAt(int)
- */
+ * @see AbstractTextEditor#createActions()
+ */
+ protected void createActions() {
+ super.createActions();
+ Action action;
+ // Action action= new
+ // TextOperationAction(PHPEditorMessages.getResourceBundle(),
+ // "CorrectionAssistProposal.", this, CORRECTIONASSIST_PROPOSALS);
+ // //$NON-NLS-1$
+ // action.setActionDefinitionId(PHPEditorActionDefinitionIds.CORRECTION_ASSIST_PROPOSALS);
+ // setAction("CorrectionAssistProposal", action); //$NON-NLS-1$
+ // markAsStateDependentAction("CorrectionAssistProposal", true);
+ // //$NON-NLS-1$
+ //// WorkbenchHelp.setHelp(action, IJavaHelpContextIds.QUICK_FIX_ACTION);
+ action = new ContentAssistAction(PHPEditorMessages.getResourceBundle(),
+ "ContentAssistProposal.", this); //$NON-NLS-1$
+ action
+ .setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
+ setAction("ContentAssistProposal", action); //$NON-NLS-1$
+ markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$
+ // WorkbenchHelp.setHelp(action,
+ // IJavaHelpContextIds.CONTENT_ASSIST_ACTION);
+ action = new TextOperationAction(PHPEditorMessages.getResourceBundle(),
+ "ContentAssistContextInformation.", this,
+ ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION); //$NON-NLS-1$
+ action
+ .setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
+ setAction("ContentAssistContextInformation", action); //$NON-NLS-1$
+ markAsStateDependentAction("ContentAssistContextInformation", true); //$NON-NLS-1$
+ // WorkbenchHelp.setHelp(action,
+ // IJavaHelpContextIds.PARAMETER_HINTS_ACTION);
+ // action= new TextOperationAction(PHPEditorMessages.getResourceBundle(),
+ // "ContentAssistCompletePrefix.", this, CONTENTASSIST_COMPLETE_PREFIX);
+ // //$NON-NLS-1$
+ // action.setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_COMPLETE_PREFIX);
+ // setAction("ContentAssistCompletePrefix", action); //$NON-NLS-1$
+ // markAsStateDependentAction("ContentAssistCompletePrefix", true);
+ // //$NON-NLS-1$
+ //// WorkbenchHelp.setHelp(action,
+ // IJavaHelpContextIds.PARAMETER_HINTS_ACTION);
+ action = new TextOperationAction(PHPEditorMessages.getResourceBundle(),
+ "Comment.", this, ITextOperationTarget.PREFIX); //$NON-NLS-1$
+ action.setActionDefinitionId(PHPEditorActionDefinitionIds.COMMENT);
+ setAction("Comment", action); //$NON-NLS-1$
+ markAsStateDependentAction("Comment", true); //$NON-NLS-1$
+ // WorkbenchHelp.setHelp(action, IJavaHelpContextIds.COMMENT_ACTION);
+ action = new TextOperationAction(PHPEditorMessages.getResourceBundle(),
+ "Uncomment.", this, ITextOperationTarget.STRIP_PREFIX); //$NON-NLS-1$
+ action.setActionDefinitionId(PHPEditorActionDefinitionIds.UNCOMMENT);
+ setAction("Uncomment", action); //$NON-NLS-1$
+ markAsStateDependentAction("Uncomment", true); //$NON-NLS-1$
+ // WorkbenchHelp.setHelp(action, IJavaHelpContextIds.UNCOMMENT_ACTION);
+ action = new ToggleCommentAction(PHPEditorMessages.getResourceBundle(),
+ "ToggleComment.", this, getSourceViewerConfiguration()
+ .getDefaultPrefixes(getSourceViewer(), "")); //$NON-NLS-1$ //$NON-NLS-2$
+ action.setActionDefinitionId(PHPEditorActionDefinitionIds.TOGGLE_COMMENT);
+ setAction("ToggleComment", action); //$NON-NLS-1$
+ markAsStateDependentAction("ToggleComment", true); //$NON-NLS-1$
+ // WorkbenchHelp.setHelp(action,
+ // IJavaHelpContextIds.TOGGLE_COMMENT_ACTION);
+ action = new TextOperationAction(PHPEditorMessages.getResourceBundle(),
+ "Format.", this, ISourceViewer.FORMAT); //$NON-NLS-1$
+ action.setActionDefinitionId(PHPEditorActionDefinitionIds.FORMAT);
+ setAction("Format", action); //$NON-NLS-1$
+ markAsStateDependentAction("Format", true); //$NON-NLS-1$
+ markAsSelectionDependentAction("Format", true); //$NON-NLS-1$
+ // WorkbenchHelp.setHelp(action, IJavaHelpContextIds.FORMAT_ACTION);
+ action = new AddBlockCommentAction(PHPEditorMessages.getResourceBundle(),
+ "AddBlockComment.", this); //$NON-NLS-1$
+ action
+ .setActionDefinitionId(PHPEditorActionDefinitionIds.ADD_BLOCK_COMMENT);
+ setAction("AddBlockComment", action); //$NON-NLS-1$
+ markAsStateDependentAction("AddBlockComment", true); //$NON-NLS-1$
+ markAsSelectionDependentAction("AddBlockComment", true); //$NON-NLS-1$
+ // WorkbenchHelp.setHelp(action,
+ // IJavaHelpContextIds.ADD_BLOCK_COMMENT_ACTION);
+ action = new RemoveBlockCommentAction(
+ PHPEditorMessages.getResourceBundle(), "RemoveBlockComment.", this); //$NON-NLS-1$
+ action
+ .setActionDefinitionId(PHPEditorActionDefinitionIds.REMOVE_BLOCK_COMMENT);
+ setAction("RemoveBlockComment", action); //$NON-NLS-1$
+ markAsStateDependentAction("RemoveBlockComment", true); //$NON-NLS-1$
+ markAsSelectionDependentAction("RemoveBlockComment", true); //$NON-NLS-1$
+ // WorkbenchHelp.setHelp(action,
+ // IJavaHelpContextIds.ADD_BLOCK_COMMENT_ACTION);
+ // action= new IndentAction(PHPEditorMessages.getResourceBundle(),
+ // "Indent.", this, false); //$NON-NLS-1$
+ // action.setActionDefinitionId(PHPEditorActionDefinitionIds.INDENT);
+ // setAction("Indent", action); //$NON-NLS-1$
+ // markAsStateDependentAction("Indent", true); //$NON-NLS-1$
+ // markAsSelectionDependentAction("Indent", true); //$NON-NLS-1$
+ //// WorkbenchHelp.setHelp(action, IJavaHelpContextIds.INDENT_ACTION);
+ //
+ // action= new IndentAction(PHPEditorMessages.getResourceBundle(),
+ // "Indent.", this, true); //$NON-NLS-1$
+ // setAction("IndentOnTab", action); //$NON-NLS-1$
+ // markAsStateDependentAction("IndentOnTab", true); //$NON-NLS-1$
+ // markAsSelectionDependentAction("IndentOnTab", true); //$NON-NLS-1$
+ //
+ if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SMART_TAB)) {
+ // don't replace Shift Right - have to make sure their enablement is
+ // mutually exclusive
+ // removeActionActivationCode(ITextEditorActionConstants.SHIFT_RIGHT);
+ setActionActivationCode("IndentOnTab", '\t', -1, SWT.NONE); //$NON-NLS-1$
+ }
+ fGenerateActionGroup = new GenerateActionGroup(this,
+ ITextEditorActionConstants.GROUP_EDIT);
+ fActionGroups = new CompositeActionGroup(
+ new ActionGroup[]{fGenerateActionGroup});
+ // We have to keep the context menu group separate to have better control
+ // over positioning
+ fContextMenuGroup = new CompositeActionGroup(new ActionGroup[] { fGenerateActionGroup });
+ // rg,
+ // new LocalHistoryActionGroup(this, ITextEditorActionConstants.GROUP_EDIT)});
+
+ }
+ /*
+ * @see JavaEditor#getElementAt(int)
+ */
protected IJavaElement getElementAt(int offset) {
return getElementAt(offset, true);
}
-
/**
- * Returns the most narrow element including the given offset. If <code>reconcile</code>
- * is <code>true</code> the editor's input element is reconciled in advance. If it is
- * <code>false</code> this method only returns a result if the editor's input element
- * does not need to be reconciled.
+ * Returns the most narrow element including the given offset. If <code>reconcile</code>
+ * is <code>true</code> the editor's input element is reconciled in
+ * advance. If it is <code>false</code> this method only returns a result
+ * if the editor's input element does not need to be reconciled.
*
- * @param offset the offset included by the retrieved element
- * @param reconcile <code>true</code> if working copy should be reconciled
+ * @param offset
+ * the offset included by the retrieved element
+ * @param reconcile
+ * <code>true</code> if working copy should be reconciled
*/
protected IJavaElement getElementAt(int offset, boolean reconcile) {
- IWorkingCopyManager manager = PHPeclipsePlugin.getDefault().getWorkingCopyManager();
+ IWorkingCopyManager manager = PHPeclipsePlugin.getDefault()
+ .getWorkingCopyManager();
ICompilationUnit unit = manager.getWorkingCopy(getEditorInput());
-
if (unit != null) {
try {
if (reconcile) {
return unit.getElementAt(offset);
} else if (unit.isConsistent())
return unit.getElementAt(offset);
-
} catch (JavaModelException x) {
PHPeclipsePlugin.log(x.getStatus());
// nothing found, be tolerant and go on
}
}
-
return null;
}
-
/*
* @see JavaEditor#getCorrespondingElement(IJavaElement)
*/
}
return null;
}
-
public void createPartControl(Composite parent) {
super.createPartControl(parent);
-
// fPaintManager = new PaintManager(getSourceViewer());
-
LinePainter linePainter;
linePainter = new LinePainter(getSourceViewer());
-
- linePainter.setHighlightColor(new Color(Display.getCurrent(), 225, 235, 224));
-
+ linePainter
+ .setHighlightColor(new Color(Display.getCurrent(), 225, 235, 224));
// fPaintManager.addPainter(linePainter);
-
if (isBracketHighlightingEnabled())
startBracketHighlighting();
if (isLineHighlightingEnabled())
startLineHighlighting();
if (isPrintMarginVisible())
showPrintMargin();
-
// Iterator e = ANNOTATION_MAP.keySet().iterator();
// while (e.hasNext()) {
// AnnotationType type = (AnnotationType) e.next();
// if (isAnnotationIndicationEnabled(type))
// startAnnotationIndication(type);
// }
-
if (isTabConversionEnabled())
startTabConversion();
-
// if (isOverviewRulerVisible())
// showOverviewRuler();
//
- // Preferences preferences = PHPeclipsePlugin.getDefault().getPluginPreferences();
+ // Preferences preferences =
+ // PHPeclipsePlugin.getDefault().getPluginPreferences();
// preferences.addPropertyChangeListener(fPropertyChangeListener);
-
IPreferenceStore preferenceStore = getPreferenceStore();
boolean closeBracketsPHP = preferenceStore.getBoolean(CLOSE_BRACKETS_PHP);
boolean closeStringsPHP = preferenceStore.getBoolean(CLOSE_STRINGS_PHP);
boolean closeBracketsHTML = preferenceStore.getBoolean(CLOSE_BRACKETS_HTML);
boolean closeStringsHTML = preferenceStore.getBoolean(CLOSE_STRINGS_HTML);
-
fBracketInserter.setCloseBracketsPHPEnabled(closeBracketsPHP);
fBracketInserter.setCloseStringsPHPEnabled(closeStringsPHP);
fBracketInserter.setCloseBracketsHTMLEnabled(closeBracketsHTML);
fBracketInserter.setCloseStringsHTMLEnabled(closeStringsHTML);
-
ISourceViewer sourceViewer = getSourceViewer();
if (sourceViewer instanceof ITextViewerExtension)
- ((ITextViewerExtension) sourceViewer).prependVerifyKeyListener(fBracketInserter);
-
+ ((ITextViewerExtension) sourceViewer)
+ .prependVerifyKeyListener(fBracketInserter);
}
-
private static char getPeerCharacter(char character) {
switch (character) {
case '(' :
return ')';
-
case ')' :
return '(';
-
case '[' :
return ']';
-
case ']' :
return '[';
-
case '"' :
return character;
-
default :
throw new IllegalArgumentException();
}
}
/**
- * The compilation unit editor implementation of this <code>AbstractTextEditor</code>
- * method asks the user for the workspace path of a file resource and saves the document
- * there. See http://dev.eclipse.org/bugs/show_bug.cgi?id=6295
- */
+ * The compilation unit editor implementation of this <code>AbstractTextEditor</code>
+ * method asks the user for the workspace path of a file resource and saves
+ * the document there. See http://dev.eclipse.org/bugs/show_bug.cgi?id=6295
+ */
protected void performSaveAs(IProgressMonitor progressMonitor) {
-
Shell shell = getSite().getShell();
IEditorInput input = getEditorInput();
-
SaveAsDialog dialog = new SaveAsDialog(shell);
-
- IFile original = (input instanceof IFileEditorInput) ? ((IFileEditorInput) input).getFile() : null;
+ IFile original = (input instanceof IFileEditorInput)
+ ? ((IFileEditorInput) input).getFile()
+ : null;
if (original != null)
dialog.setOriginalFile(original);
-
dialog.create();
-
IDocumentProvider provider = getDocumentProvider();
if (provider == null) {
// editor has been programmatically closed while the dialog was open
return;
}
-
if (provider.isDeleted(input) && original != null) {
- String message = PHPEditorMessages.getFormattedString("CompilationUnitEditor.warning.save.delete", new Object[] { original.getName()}); //$NON-NLS-1$
+ String message = PHPEditorMessages.getFormattedString(
+ "CompilationUnitEditor.warning.save.delete", new Object[]{original
+ .getName()}); //$NON-NLS-1$
dialog.setErrorMessage(null);
dialog.setMessage(message, IMessageProvider.WARNING);
}
-
if (dialog.open() == Dialog.CANCEL) {
if (progressMonitor != null)
progressMonitor.setCanceled(true);
return;
}
-
IPath filePath = dialog.getResult();
if (filePath == null) {
if (progressMonitor != null)
progressMonitor.setCanceled(true);
return;
}
-
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IFile file = workspace.getRoot().getFile(filePath);
final IEditorInput newInput = new FileEditorInput(file);
-
WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
public void execute(final IProgressMonitor monitor) throws CoreException {
- getDocumentProvider().saveDocument(monitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true);
+ getDocumentProvider().saveDocument(monitor, newInput,
+ getDocumentProvider().getDocument(getEditorInput()), true);
}
};
-
boolean success = false;
try {
-
provider.aboutToChange(newInput);
new ProgressMonitorDialog(shell).run(false, true, op);
success = true;
-
} catch (InterruptedException x) {
} catch (InvocationTargetException x) {
-
Throwable t = x.getTargetException();
if (t instanceof CoreException) {
CoreException cx = (CoreException) t;
- ErrorDialog.openError(shell, PHPEditorMessages.getString("CompilationUnitEditor.error.saving.title2"), PHPEditorMessages.getString("CompilationUnitEditor.error.saving.message2"), cx.getStatus()); //$NON-NLS-1$ //$NON-NLS-2$
+ ErrorDialog.openError(shell, PHPEditorMessages
+ .getString("CompilationUnitEditor.error.saving.title2"),
+ PHPEditorMessages
+ .getString("CompilationUnitEditor.error.saving.message2"), cx
+ .getStatus()); //$NON-NLS-1$ //$NON-NLS-2$
} else {
- MessageDialog.openError(shell, PHPEditorMessages.getString("CompilationUnitEditor.error.saving.title3"), PHPEditorMessages.getString("CompilationUnitEditor.error.saving.message3") + t.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+ MessageDialog.openError(shell, PHPEditorMessages
+ .getString("CompilationUnitEditor.error.saving.title3"),
+ PHPEditorMessages
+ .getString("CompilationUnitEditor.error.saving.message3")
+ + t.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
}
-
} finally {
provider.changed(newInput);
if (success)
setInput(newInput);
}
-
if (progressMonitor != null)
progressMonitor.setCanceled(!success);
}
super.doSetInput(input);
configureTabConverter();
}
-
private void startBracketHighlighting() {
if (fBracketPainter == null) {
ISourceViewer sourceViewer = getSourceViewer();
// fPaintManager.addPainter(fBracketPainter);
}
}
-
private void stopBracketHighlighting() {
if (fBracketPainter != null) {
// fPaintManager.removePainter(fBracketPainter);
fBracketPainter = null;
}
}
-
private boolean isBracketHighlightingEnabled() {
IPreferenceStore store = getPreferenceStore();
return store.getBoolean(MATCHING_BRACKETS);
}
-
private void startLineHighlighting() {
if (fLinePainter == null) {
ISourceViewer sourceViewer = getSourceViewer();
// fPaintManager.addPainter(fLinePainter);
}
}
-
private void stopLineHighlighting() {
if (fLinePainter != null) {
// fPaintManager.removePainter(fLinePainter);
fLinePainter = null;
}
}
-
private boolean isLineHighlightingEnabled() {
IPreferenceStore store = getPreferenceStore();
return store.getBoolean(CURRENT_LINE);
}
-
private void showPrintMargin() {
if (fPrintMarginPainter == null) {
fPrintMarginPainter = new PrintMarginPainter(getSourceViewer());
fPrintMarginPainter.setMarginRulerColor(getColor(PRINT_MARGIN_COLOR));
- fPrintMarginPainter.setMarginRulerColumn(getPreferenceStore().getInt(PRINT_MARGIN_COLUMN));
+ fPrintMarginPainter.setMarginRulerColumn(getPreferenceStore().getInt(
+ PRINT_MARGIN_COLUMN));
// fPaintManager.addPainter(fPrintMarginPainter);
}
}
-
private void hidePrintMargin() {
if (fPrintMarginPainter != null) {
// fPaintManager.removePainter(fPrintMarginPainter);
fPrintMarginPainter = null;
}
}
-
private boolean isPrintMarginVisible() {
IPreferenceStore store = getPreferenceStore();
return store.getBoolean(PRINT_MARGIN);
}
-
// private void startAnnotationIndication(AnnotationType annotationType) {
// if (fProblemPainter == null) {
// fProblemPainter = new ProblemPainter(this, getSourceViewer());
- //// fPaintManager.addPainter(fProblemPainter);
+ //// fPaintManager.addPainter(fProblemPainter);
// }
// fProblemPainter.setColor(annotationType, getColor(annotationType));
// fProblemPainter.paintAnnotations(annotationType, true);
// if (fProblemPainter != null) {
//
// if (!fProblemPainter.isPaintingAnnotations()) {
- //// fPaintManager.removePainter(fProblemPainter);
+ //// fPaintManager.removePainter(fProblemPainter);
// fProblemPainter.deactivate(true);
// fProblemPainter.dispose();
// fProblemPainter = null;
// }
// }
//
- // private boolean isAnnotationIndicationEnabled(AnnotationType annotationType) {
+ // private boolean isAnnotationIndicationEnabled(AnnotationType
+ // annotationType) {
// IPreferenceStore store = getPreferenceStore();
// AnnotationInfo info = (AnnotationInfo) ANNOTATION_MAP.get(annotationType);
// if (info != null)
// return false;
// }
//
- // private boolean isAnnotationIndicationInOverviewRulerEnabled(AnnotationType annotationType) {
+ // private boolean
+ // isAnnotationIndicationInOverviewRulerEnabled(AnnotationType
+ // annotationType) {
// IPreferenceStore store = getPreferenceStore();
// AnnotationInfo info = (AnnotationInfo) ANNOTATION_MAP.get(annotationType);
// if (info != null)
// return false;
// }
//
- // private void showAnnotationIndicationInOverviewRuler(AnnotationType annotationType, boolean show) {
+ // private void showAnnotationIndicationInOverviewRuler(AnnotationType
+ // annotationType, boolean show) {
// AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
// OverviewRuler ruler = asv.getOverviewRuler();
// if (ruler != null) {
// }
// }
//
- // private void setColorInOverviewRuler(AnnotationType annotationType, Color color) {
+ // private void setColorInOverviewRuler(AnnotationType annotationType, Color
+ // color) {
// AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
// OverviewRuler ruler = asv.getOverviewRuler();
// if (ruler != null) {
// ruler.update();
// }
// }
-
private void configureTabConverter() {
if (fTabConverter != null) {
IDocumentProvider provider = getDocumentProvider();
}
}
}
-
private int getTabSize() {
- Preferences preferences = PHPeclipsePlugin.getDefault().getPluginPreferences();
+ Preferences preferences = PHPeclipsePlugin.getDefault()
+ .getPluginPreferences();
return preferences.getInt(CODE_FORMATTER_TAB_SIZE);
}
-
private void startTabConversion() {
if (fTabConverter == null) {
fTabConverter = new TabConverter();
asv.updateIndentationPrefixes();
}
}
-
private void stopTabConversion() {
if (fTabConverter != null) {
AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
fTabConverter = null;
}
}
-
private boolean isTabConversionEnabled() {
IPreferenceStore store = getPreferenceStore();
return store.getBoolean(SPACES_FOR_TABS);
}
-
// private void showOverviewRuler() {
// AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
// asv.showOverviewRuler();
// IPreferenceStore store = getPreferenceStore();
// return store.getBoolean(OVERVIEW_RULER);
// }
-
private Color getColor(String key) {
RGB rgb = PreferenceConverter.getColor(getPreferenceStore(), key);
return getColor(rgb);
}
-
private Color getColor(RGB rgb) {
JavaTextTools textTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
return textTools.getColorManager().getColor(rgb);
}
-
// private Color getColor(AnnotationType annotationType) {
// AnnotationInfo info = (AnnotationInfo) ANNOTATION_MAP.get(annotationType);
// if (info != null)
// return getColor(info.fColorPreference);
// return null;
// }
-
public void dispose() {
ISourceViewer sourceViewer = getSourceViewer();
if (sourceViewer instanceof ITextViewerExtension)
- ((ITextViewerExtension) sourceViewer).removeVerifyKeyListener(fBracketInserter);
-
+ ((ITextViewerExtension) sourceViewer)
+ .removeVerifyKeyListener(fBracketInserter);
// if (fPropertyChangeListener != null) {
- // Preferences preferences = PHPeclipsePlugin.getDefault().getPluginPreferences();
+ // Preferences preferences =
+ // PHPeclipsePlugin.getDefault().getPluginPreferences();
// preferences.removePropertyChangeListener(fPropertyChangeListener);
// fPropertyChangeListener = null;
// }
-
if (fJavaEditorErrorTickUpdater != null) {
fJavaEditorErrorTickUpdater.dispose();
fJavaEditorErrorTickUpdater = null;
}
-
// if (fSelectionHistory != null)
// fSelectionHistory.dispose();
-
// if (fPaintManager != null) {
// fPaintManager.dispose();
// fPaintManager = null;
// }
-
if (fActionGroups != null) {
fActionGroups.dispose();
fActionGroups = null;
}
-
super.dispose();
}
-
// protected AnnotationType getAnnotationType(String preferenceKey) {
// Iterator e = ANNOTATION_MAP.keySet().iterator();
// while (e.hasNext()) {
// }
// return null;
// }
-
/*
* @see AbstractTextEditor#handlePreferenceStoreChanged(PropertyChangeEvent)
*/
protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
-
try {
-
AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
if (asv != null) {
-
String p = event.getProperty();
-
if (CLOSE_BRACKETS_PHP.equals(p)) {
- fBracketInserter.setCloseBracketsPHPEnabled(getPreferenceStore().getBoolean(p));
+ fBracketInserter.setCloseBracketsPHPEnabled(getPreferenceStore()
+ .getBoolean(p));
return;
}
-
if (CLOSE_STRINGS_PHP.equals(p)) {
- fBracketInserter.setCloseStringsPHPEnabled(getPreferenceStore().getBoolean(p));
+ fBracketInserter.setCloseStringsPHPEnabled(getPreferenceStore()
+ .getBoolean(p));
return;
}
-
if (CLOSE_BRACKETS_HTML.equals(p)) {
- fBracketInserter.setCloseBracketsHTMLEnabled(getPreferenceStore().getBoolean(p));
+ fBracketInserter.setCloseBracketsHTMLEnabled(getPreferenceStore()
+ .getBoolean(p));
return;
}
-
if (CLOSE_STRINGS_HTML.equals(p)) {
- fBracketInserter.setCloseStringsHTMLEnabled(getPreferenceStore().getBoolean(p));
+ fBracketInserter.setCloseStringsHTMLEnabled(getPreferenceStore()
+ .getBoolean(p));
return;
}
-
if (SPACES_FOR_TABS.equals(p)) {
if (isTabConversionEnabled())
startTabConversion();
stopTabConversion();
return;
}
-
if (MATCHING_BRACKETS.equals(p)) {
if (isBracketHighlightingEnabled())
startBracketHighlighting();
stopBracketHighlighting();
return;
}
-
if (MATCHING_BRACKETS_COLOR.equals(p)) {
if (fBracketPainter != null)
- fBracketPainter.setHighlightColor(getColor(MATCHING_BRACKETS_COLOR));
+ fBracketPainter
+ .setHighlightColor(getColor(MATCHING_BRACKETS_COLOR));
return;
}
-
if (CURRENT_LINE.equals(p)) {
if (isLineHighlightingEnabled())
startLineHighlighting();
stopLineHighlighting();
return;
}
-
if (CURRENT_LINE_COLOR.equals(p)) {
if (fLinePainter != null) {
stopLineHighlighting();
}
return;
}
-
if (PRINT_MARGIN.equals(p)) {
if (isPrintMarginVisible())
showPrintMargin();
hidePrintMargin();
return;
}
-
if (PRINT_MARGIN_COLOR.equals(p)) {
if (fPrintMarginPainter != null)
- fPrintMarginPainter.setMarginRulerColor(getColor(PRINT_MARGIN_COLOR));
+ fPrintMarginPainter
+ .setMarginRulerColor(getColor(PRINT_MARGIN_COLOR));
return;
}
-
if (PRINT_MARGIN_COLUMN.equals(p)) {
if (fPrintMarginPainter != null)
- fPrintMarginPainter.setMarginRulerColumn(getPreferenceStore().getInt(PRINT_MARGIN_COLUMN));
+ fPrintMarginPainter.setMarginRulerColumn(getPreferenceStore()
+ .getInt(PRINT_MARGIN_COLUMN));
return;
}
-
// if (OVERVIEW_RULER.equals(p)) {
// if (isOverviewRulerVisible())
// showOverviewRuler();
// hideOverviewRuler();
// return;
// }
-
// AnnotationType type = getAnnotationType(p);
// if (type != null) {
//
// return;
// }
// }
-
IContentAssistant c = asv.getContentAssistant();
if (c instanceof ContentAssistant)
- ContentAssistPreference.changeConfiguration((ContentAssistant) c, getPreferenceStore(), event);
+ ContentAssistPreference.changeConfiguration((ContentAssistant) c,
+ getPreferenceStore(), event);
}
-
} finally {
super.handlePreferenceStoreChanged(event);
}
}
-
/*
- * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#handlePreferencePropertyChanged(org.eclipse.core.runtime.Preferences.PropertyChangeEvent)
- */
- protected void handlePreferencePropertyChanged(org.eclipse.core.runtime.Preferences.PropertyChangeEvent event) {
+ * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#handlePreferencePropertyChanged(org.eclipse.core.runtime.Preferences.PropertyChangeEvent)
+ */
+ protected void handlePreferencePropertyChanged(
+ org.eclipse.core.runtime.Preferences.PropertyChangeEvent event) {
AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
if (asv != null) {
String p = event.getProperty();
}
super.handlePreferencePropertyChanged(event);
}
-
/**
- * Handles a property change event describing a change
- * of the php core's preferences and updates the preference
- * related editor properties.
+ * Handles a property change event describing a change of the php core's
+ * preferences and updates the preference related editor properties.
*
- * @param event the property change event
+ * @param event
+ * the property change event
*/
- // protected void handlePreferencePropertyChanged(org.eclipse.core.runtime.Preferences.PropertyChangeEvent event) {
+ // protected void
+ // handlePreferencePropertyChanged(org.eclipse.core.runtime.Preferences.PropertyChangeEvent
+ // event) {
// AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
// if (asv != null) {
// String p = event.getProperty();
// }
// }
// }
-
/*
* @see PHPEditor#createJavaSourceViewer(Composite, IVerticalRuler, int)
*/
- protected ISourceViewer createJavaSourceViewer(
- Composite parent,
- IVerticalRuler verticalRuler,
- IOverviewRuler overviewRuler,
- boolean isOverviewRulerVisible,
- int styles) {
- return new AdaptedSourceViewer(parent, verticalRuler, overviewRuler, isOverviewRulerVisible, styles);
+ protected ISourceViewer createJavaSourceViewer(Composite parent,
+ IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
+ boolean isOverviewRulerVisible, int styles) {
+ return new AdaptedSourceViewer(parent, verticalRuler, overviewRuler,
+ isOverviewRulerVisible, styles);
}
- // protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
+ // protected ISourceViewer createJavaSourceViewer(Composite parent,
+ // IVerticalRuler ruler, int styles) {
// return new AdaptedSourceViewer(parent, ruler, styles);
// }
-
private boolean isValidSelection(int offset, int length) {
IDocumentProvider provider = getDocumentProvider();
if (provider != null) {
if (document != null) {
int end = offset + length;
int documentLength = document.getLength();
- return 0 <= offset && offset <= documentLength && 0 <= end && end <= documentLength;
+ return 0 <= offset && offset <= documentLength && 0 <= end
+ && end <= documentLength;
}
}
return false;
}
-
/*
* @see AbstractTextEditor#canHandleMove(IEditorInput, IEditorInput)
*/
- protected boolean canHandleMove(IEditorInput originalElement, IEditorInput movedElement) {
-
+ protected boolean canHandleMove(IEditorInput originalElement,
+ IEditorInput movedElement) {
String oldExtension = ""; //$NON-NLS-1$
if (originalElement instanceof IFileEditorInput) {
IFile file = ((IFileEditorInput) originalElement).getFile();
oldExtension = ext;
}
}
-
String newExtension = ""; //$NON-NLS-1$
if (movedElement instanceof IFileEditorInput) {
IFile file = ((IFileEditorInput) movedElement).getFile();
if (file != null)
newExtension = file.getFileExtension();
}
-
return oldExtension.equals(newExtension);
}
-
/*
* @see AbstractTextEditor#editorContextMenuAboutToShow(IMenuManager)
*/
public void editorContextMenuAboutToShow(IMenuManager menu) {
super.editorContextMenuAboutToShow(menu);
-
- ActionContext context = new ActionContext(getSelectionProvider().getSelection());
+ ActionContext context = new ActionContext(getSelectionProvider()
+ .getSelection());
fContextMenuGroup.setContext(context);
fContextMenuGroup.fillContextMenu(menu);
fContextMenuGroup.setContext(null);
}
-
/*
* @see JavaEditor#setOutlinePageInput(JavaOutlinePage, IEditorInput)
*/
protected void setOutlinePageInput(JavaOutlinePage page, IEditorInput input) {
if (page != null) {
- IWorkingCopyManager manager = PHPeclipsePlugin.getDefault().getWorkingCopyManager();
+ IWorkingCopyManager manager = PHPeclipsePlugin.getDefault()
+ .getWorkingCopyManager();
page.setInput(manager.getWorkingCopy(input));
}
}
-
/*
- * @see AbstractTextEditor#performSaveOperation(WorkspaceModifyOperation, IProgressMonitor)
+ * @see AbstractTextEditor#performSaveOperation(WorkspaceModifyOperation,
+ * IProgressMonitor)
*/
-// protected void performSaveOperation(WorkspaceModifyOperation operation, IProgressMonitor progressMonitor) {
-// IDocumentProvider p = getDocumentProvider();
-// if (p instanceof PHPDocumentProvider) {
-// PHPDocumentProvider cp = (PHPDocumentProvider) p;
-// cp.setSavePolicy(fSavePolicy);
-// }
-//
-// try {
-// super.performSaveOperation(operation, progressMonitor);
-// } finally {
-// if (p instanceof PHPDocumentProvider) {
-// PHPDocumentProvider cp = (PHPDocumentProvider) p;
-// cp.setSavePolicy(null);
-// }
-// }
-// }
-
+ // protected void performSaveOperation(WorkspaceModifyOperation operation,
+ // IProgressMonitor progressMonitor) {
+ // IDocumentProvider p = getDocumentProvider();
+ // if (p instanceof PHPDocumentProvider) {
+ // PHPDocumentProvider cp = (PHPDocumentProvider) p;
+ // cp.setSavePolicy(fSavePolicy);
+ // }
+ //
+ // try {
+ // super.performSaveOperation(operation, progressMonitor);
+ // } finally {
+ // if (p instanceof PHPDocumentProvider) {
+ // PHPDocumentProvider cp = (PHPDocumentProvider) p;
+ // cp.setSavePolicy(null);
+ // }
+ // }
+ // }
/*
- * @see org.eclipse.ui.texteditor.AbstractTextEditor#performSave(boolean, org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.ui.texteditor.AbstractTextEditor#performSave(boolean,
+ * org.eclipse.core.runtime.IProgressMonitor)
*/
protected void performSave(boolean overwrite, IProgressMonitor progressMonitor) {
- IDocumentProvider p= getDocumentProvider();
+ IDocumentProvider p = getDocumentProvider();
if (p instanceof PHPDocumentProvider) {
- PHPDocumentProvider cp= (PHPDocumentProvider) p;
+ PHPDocumentProvider cp = (PHPDocumentProvider) p;
cp.setSavePolicy(fSavePolicy);
}
try {
super.performSave(overwrite, progressMonitor);
} finally {
if (p instanceof PHPDocumentProvider) {
- PHPDocumentProvider cp= (PHPDocumentProvider) p;
+ PHPDocumentProvider cp = (PHPDocumentProvider) p;
cp.setSavePolicy(null);
}
}
super.doSaveAs();
}
}
-
/*
- * @see AbstractTextEditor#doSave(IProgressMonitor)
- */
+ * @see AbstractTextEditor#doSave(IProgressMonitor)
+ */
public void doSave(IProgressMonitor progressMonitor) {
-
IDocumentProvider p = getDocumentProvider();
if (p == null) {
// editor has been closed
return;
}
-
if (!askIfNonWorkbenchEncodingIsOk()) {
progressMonitor.setCanceled(true);
return;
}
-
if (p.isDeleted(getEditorInput())) {
-
if (isSaveAsAllowed()) {
-
/*
- * 1GEUSSR: ITPUI:ALL - User should never loose changes made in the editors.
- * Changed Behavior to make sure that if called inside a regular save (because
- * of deletion of input element) there is a way to report back to the caller.
+ * 1GEUSSR: ITPUI:ALL - User should never loose changes made in the
+ * editors. Changed Behavior to make sure that if called inside a
+ * regular save (because of deletion of input element) there is a way
+ * to report back to the caller.
*/
// performSaveAs(progressMonitor);
super.doSave(progressMonitor);
} else {
-
- /*
+ /*
* 1GF5YOX: ITPJUI:ALL - Save of delete file claims it's still there
* Missing resources.
*/
Shell shell = getSite().getShell();
- MessageDialog.openError(shell, PHPEditorMessages.getString("PHPUnitEditor.error.saving.title1"), PHPEditorMessages.getString("PHPUnitEditor.error.saving.message1")); //$NON-NLS-1$ //$NON-NLS-2$
+ MessageDialog.openError(shell, PHPEditorMessages
+ .getString("PHPUnitEditor.error.saving.title1"), PHPEditorMessages
+ .getString("PHPUnitEditor.error.saving.message1")); //$NON-NLS-1$ //$NON-NLS-2$
}
-
} else {
-
setStatusLineErrorMessage(null);
super.doSave(progressMonitor);
-
- // IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();
+ // IWorkingCopyManager manager=
+ // JavaPlugin.getDefault().getWorkingCopyManager();
// ICompilationUnit unit= manager.getWorkingCopy(getEditorInput());
//
// if (unit != null) {
- // synchronized (unit) {
- // performSaveOperation(createSaveOperation(false), progressMonitor);
+ // synchronized (unit) {
+ // performSaveOperation(createSaveOperation(false), progressMonitor);
// }
- // } else
+ // } else
// performSaveOperation(createSaveOperation(false), progressMonitor);
}
}
/**
* Asks the user if it is ok to store in non-workbench encoding.
- * @return <true> if the user wants to continue
+ *
+ * @return <true>if the user wants to continue
*/
private boolean askIfNonWorkbenchEncodingIsOk() {
IDocumentProvider provider = getDocumentProvider();
String defaultEncoding = storageProvider.getDefaultEncoding();
if (encoding != null && !encoding.equals(defaultEncoding)) {
Shell shell = getSite().getShell();
- String title = PHPEditorMessages.getString("PHPUnitEditor.warning.save.nonWorkbenchEncoding.title"); //$NON-NLS-1$
+ String title = PHPEditorMessages
+ .getString("PHPUnitEditor.warning.save.nonWorkbenchEncoding.title"); //$NON-NLS-1$
String msg;
if (input != null)
- msg = MessageFormat.format(PHPEditorMessages.getString("PHPUnitEditor.warning.save.nonWorkbenchEncoding.message1"), new String[] { input.getName(), encoding }); //$NON-NLS-1$
+ msg = MessageFormat
+ .format(
+ PHPEditorMessages
+ .getString("PHPUnitEditor.warning.save.nonWorkbenchEncoding.message1"),
+ new String[]{input.getName(), encoding}); //$NON-NLS-1$
else
- msg = MessageFormat.format(PHPEditorMessages.getString("PHPUnitEditor.warning.save.nonWorkbenchEncoding.message2"), new String[] { encoding }); //$NON-NLS-1$
+ msg = MessageFormat
+ .format(
+ PHPEditorMessages
+ .getString("PHPUnitEditor.warning.save.nonWorkbenchEncoding.message2"),
+ new String[]{encoding}); //$NON-NLS-1$
return MessageDialog.openQuestion(shell, title, msg);
}
}
return true;
}
/*
- * @see IReconcilingParticipant#reconciled()
- */
+ * @see IReconcilingParticipant#reconciled()
+ */
public void reconciled() {
if (synchronizeOutlineOnCursorMove()) {
Shell shell = getSite().getShell();
}
}
}
-
- private boolean synchronizeOutlineOnCursorMove() {
- return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE);
- }
+
protected void updateStateDependentActions() {
super.updateStateDependentActions();
fGenerateActionGroup.editorStateChanged();
}
+
+ private boolean synchronizeOutlineOnCursorMove() {
+ return PreferenceConstants.getPreferenceStore().getBoolean(
+ PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE);
+ }
/**
* Returns the updated java element for the old java element.
*/
private IJavaElement findElement(IJavaElement element) {
-
if (element == null)
return null;
-
- IWorkingCopyManager manager = PHPeclipsePlugin.getDefault().getWorkingCopyManager();
+ IWorkingCopyManager manager = PHPeclipsePlugin.getDefault()
+ .getWorkingCopyManager();
ICompilationUnit unit = manager.getWorkingCopy(getEditorInput());
-
if (unit != null) {
try {
-
synchronized (unit) {
unit.reconcile();
}
IJavaElement[] findings = unit.findElements(element);
if (findings != null && findings.length > 0)
return findings[0];
-
} catch (JavaModelException x) {
PHPeclipsePlugin.log(x.getStatus());
// nothing found, be tolerant and go on
}
}
-
return null;
}
-
/**
* Returns the offset of the given Java element.
*/
}
return -1;
}
-
/*
* @see AbstractTextEditor#rememberSelection()
*/
protected void rememberSelection() {
ISelectionProvider sp = getSelectionProvider();
- fRememberedSelection = (sp == null ? null : (ITextSelection) sp.getSelection());
+ fRememberedSelection = (sp == null ? null : (ITextSelection) sp
+ .getSelection());
if (fRememberedSelection != null) {
fRememberedElement = getElementAt(fRememberedSelection.getOffset(), true);
fRememberedElementOffset = getOffset(fRememberedElement);
}
}
-
/*
* @see AbstractTextEditor#restoreSelection()
*/
protected void restoreSelection() {
-
try {
-
if (getSourceViewer() == null || fRememberedSelection == null)
return;
-
IJavaElement newElement = findElement(fRememberedElement);
int newOffset = getOffset(newElement);
- int delta = (newOffset > -1 && fRememberedElementOffset > -1) ? newOffset - fRememberedElementOffset : 0;
- if (isValidSelection(delta + fRememberedSelection.getOffset(), fRememberedSelection.getLength()))
- selectAndReveal(delta + fRememberedSelection.getOffset(), fRememberedSelection.getLength());
-
+ int delta = (newOffset > -1 && fRememberedElementOffset > -1) ? newOffset
+ - fRememberedElementOffset : 0;
+ if (isValidSelection(delta + fRememberedSelection.getOffset(),
+ fRememberedSelection.getLength()))
+ selectAndReveal(delta + fRememberedSelection.getOffset(),
+ fRememberedSelection.getLength());
} finally {
fRememberedSelection = null;
fRememberedElement = null;
fRememberedElementOffset = -1;
}
}
-
}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation 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 API and implementation
+ *******************************************************************************/
+
+package net.sourceforge.phpeclipse.phpeditor;
+
+import java.util.ResourceBundle;
+
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+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.viewers.ISelection;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.ResourceAction;
+import org.eclipse.ui.texteditor.TextEditorAction;
+
+
+
+/**
+ * An action which toggles the single line comment prefixes on the selected lines.
+ *
+ * @since 3.0
+ */
+public final class ToggleCommentAction extends TextEditorAction {
+
+ /** The text operation target */
+ private ITextOperationTarget fOperationTarget;
+ /** The comment prefixes */
+ private String[] fCommentPrefixes;
+
+ /**
+ * Creates and initializes the action for the given text editor. The action
+ * configures its visual representation from the given resource bundle.
+ *
+ * @param bundle the resource bundle
+ * @param prefix a prefix to be prepended to the various resource keys
+ * (described in <code>ResourceAction</code> constructor), or
+ * <code>null</code> if none
+ * @param editor the text editor
+ * @see ResourceAction#ResourceAction
+ */
+ public ToggleCommentAction(ResourceBundle bundle, String prefix, ITextEditor editor, String[] commentPrefixes) {
+ super(bundle, prefix, editor);
+ fCommentPrefixes= commentPrefixes;
+ }
+
+ /**
+ * Implementation of the <code>IAction</code> prototype. Checks if the selected
+ * lines are all commented or not and uncomment/comments them respectively.
+ */
+ public void run() {
+ if (fOperationTarget == null)
+ return;
+
+ ITextEditor editor= getTextEditor();
+ if (!(editor instanceof PHPEditor))
+ return;
+
+ if (!validateEditorInputState())
+ return;
+
+ final int operationCode;
+ if (isSelectionCommented(editor.getSelectionProvider().getSelection()))
+ operationCode= ITextOperationTarget.STRIP_PREFIX;
+ else
+ operationCode= ITextOperationTarget.PREFIX;
+
+ Shell shell= editor.getSite().getShell();
+ if (!fOperationTarget.canDoOperation(operationCode)) {
+ if (shell != null)
+ MessageDialog.openError(shell, PHPEditorMessages.getString("ToggleComment.error.title"), PHPEditorMessages.getString("ToggleComment.error.message")); //$NON-NLS-1$ //$NON-NLS-2$
+ return;
+ }
+
+ Display display= null;
+ if (shell != null && !shell.isDisposed())
+ display= shell.getDisplay();
+
+ BusyIndicator.showWhile(display, new Runnable() {
+ public void run() {
+ fOperationTarget.doOperation(operationCode);
+ }
+ });
+ }
+
+ /**
+ * Is the given selection single-line commented?
+ *
+ * @param selection Selection to check
+ * @return <code>true</code> iff all selected lines are single-line commented
+ */
+ private boolean isSelectionCommented(ISelection selection) {
+ if (!(selection instanceof ITextSelection))
+ return false;
+
+ ITextSelection ts= (ITextSelection) selection;
+ if (ts.getStartLine() < 0 || ts.getEndLine() < 0)
+ return false;
+
+ IDocument document= getTextEditor().getDocumentProvider().getDocument(getTextEditor().getEditorInput());
+ OUTER: for (int i= ts.getStartLine(); i <= ts.getEndLine(); i++) {
+ for (int j= 0; j < fCommentPrefixes.length; j++) {
+ try {
+ if (fCommentPrefixes[j].length() == 0)
+ continue;
+ String s= document.get(document.getLineOffset(i), document.getLineLength(i));
+ int index= s.indexOf(fCommentPrefixes[j]);
+ if (index >= 0 && s.substring(0, index).trim().length() == 0)
+ continue OUTER;
+ } catch (BadLocationException e) {
+ // should not happen
+ PHPeclipsePlugin.log(e);
+ }
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Implementation of the <code>IUpdate</code> prototype method discovers
+ * the operation through the current editor's
+ * <code>ITextOperationTarget</code> adapter, and sets the enabled state
+ * accordingly.
+ */
+ public void update() {
+ super.update();
+
+ if (!canModifyEditor()) {
+ setEnabled(false);
+ return;
+ }
+
+ ITextEditor editor= getTextEditor();
+ if (fOperationTarget == null && editor != null)
+ fOperationTarget= (ITextOperationTarget) editor.getAdapter(ITextOperationTarget.class);
+
+ boolean isEnabled= (fOperationTarget != null && fOperationTarget.canDoOperation(ITextOperationTarget.PREFIX) && fOperationTarget.canDoOperation(ITextOperationTarget.STRIP_PREFIX));
+ setEnabled(isEnabled);
+ }
+
+ /*
+ * @see TextEditorAction#setEditor(ITextEditor)
+ */
+ public void setEditor(ITextEditor editor) {
+ super.setEditor(editor);
+ fOperationTarget= null;
+ }
+}
*/
package net.sourceforge.phpeclipse.phpeditor.php;
+import net.sourceforge.phpdt.internal.ui.text.*;
+
import org.eclipse.jface.text.IDocument;
/**
* @author slanger
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class PHPPartition extends Partition
{
super(
document,
new char[] { '<', '>' },
- IPHPPartitionScannerConstants.PHP,
+ IPHPPartitions.PHP_PARTITIONING,
parentPartition);
}
*/
protected boolean allowedPartition(String type)
{
- if(type.equals(IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT))
+ if(type.equals(IPHPPartitions.PHP_MULTILINE_COMMENT))
return true;
return false;
* Created on 05.03.2003
*
* @author Stefan Langer (musk)
- * @version $Revision: 1.22 $
+ * @version $Revision: 1.23 $
*/
package net.sourceforge.phpeclipse.phpeditor.php;
import java.util.HashMap;
import java.util.Map;
+import net.sourceforge.phpdt.internal.ui.text.*;
+
import org.eclipse.jface.text.Assert;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
private boolean fInDoubString = false;
private IDocument fDocument = null;
private int fOffset = -1;
- private String fContentType = IPHPPartitionScannerConstants.HTML;
- private String fPrevContentType = IPHPPartitionScannerConstants.HTML;
+ private String fContentType = IPHPPartitions.HTML;
+ private String fPrevContentType = IPHPPartitions.HTML;
private boolean partitionBorder = false;
private int fTokenOffset;
private int fEnd = -1;
private Map tokens = new HashMap();
public PHPPartitionScanner() {
- this(IPHPPartitionScannerConstants.PHP_FILE);
+ this(IPHPPartitions.PHP_FILE);
}
public PHPPartitionScanner(int fileType) {
- this.tokens.put(IPHPPartitionScannerConstants.PHP, new Token(IPHPPartitionScannerConstants.PHP));
+ this.tokens.put(IPHPPartitions.PHP_PARTITIONING, new Token(IPHPPartitions.PHP_PARTITIONING));
this.tokens.put(
- IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT,
- new Token(IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT));
- this.tokens.put(IPHPPartitionScannerConstants.HTML, new Token(IPHPPartitionScannerConstants.HTML));
+ IPHPPartitions.PHP_MULTILINE_COMMENT,
+ new Token(IPHPPartitions.PHP_MULTILINE_COMMENT));
+ this.tokens.put(IPHPPartitions.HTML, new Token(IPHPPartitions.HTML));
this.tokens.put(
- IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT,
- new Token(IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT));
+ IPHPPartitions.HTML_MULTILINE_COMMENT,
+ new Token(IPHPPartitions.HTML_MULTILINE_COMMENT));
- this.tokens.put(IPHPPartitionScannerConstants.SMARTY, new Token(IPHPPartitionScannerConstants.SMARTY));
+ this.tokens.put(IPHPPartitions.SMARTY, new Token(IPHPPartitions.SMARTY));
this.tokens.put(
- IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT,
- new Token(IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT));
+ IPHPPartitions.SMARTY_MULTILINE_COMMENT,
+ new Token(IPHPPartitions.SMARTY_MULTILINE_COMMENT));
this.tokens.put(IDocument.DEFAULT_CONTENT_TYPE, new Token(IDocument.DEFAULT_CONTENT_TYPE));
fFileType = fileType;
while ((c = read()) != ICharacterScanner.EOF) {
switch (c) {
case '<' :
- if (!isInString(IPHPPartitionScannerConstants.PHP)
- && fContentType != IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT
+ if (!isInString(IPHPPartitions.PHP_PARTITIONING)
+ && fContentType != IPHPPartitions.PHP_MULTILINE_COMMENT
&& checkPattern(new char[] { '?', 'p', 'h', 'p' }, true)) {
- if (fContentType != IPHPPartitionScannerConstants.PHP && fCurrentLength > 5) {
+ if (fContentType != IPHPPartitions.PHP_PARTITIONING && fCurrentLength > 5) {
unread(5);
IToken token = getToken(fContentType);
// save previouse contenttype
//TODO build stack for previouse contenttype
fPrevContentType = fContentType;
- fContentType = IPHPPartitionScannerConstants.PHP;
+ fContentType = IPHPPartitions.PHP_PARTITIONING;
return token;
} else
- fContentType = IPHPPartitionScannerConstants.PHP;
+ fContentType = IPHPPartitions.PHP_PARTITIONING;
// remember offset of this partition
fTokenOffset = fOffset - 5;
fCurrentLength = 5;
} else if (
- !isInString(IPHPPartitionScannerConstants.PHP)
- && fContentType != IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT
+ !isInString(IPHPPartitions.PHP_PARTITIONING)
+ && fContentType != IPHPPartitions.PHP_MULTILINE_COMMENT
&& checkPattern(new char[] { '?' }, false)) {
- if (fContentType != IPHPPartitionScannerConstants.PHP && fCurrentLength > 2) {
+ if (fContentType != IPHPPartitions.PHP_PARTITIONING && fCurrentLength > 2) {
unread(2);
IToken token = getToken(fContentType);
// save previouse contenttype
fPrevContentType = fContentType;
- fContentType = IPHPPartitionScannerConstants.PHP;
+ fContentType = IPHPPartitions.PHP_PARTITIONING;
return token;
} else
- fContentType = IPHPPartitionScannerConstants.PHP;
+ fContentType = IPHPPartitions.PHP_PARTITIONING;
// remember offset of this partition
fTokenOffset = fOffset - 2;
fCurrentLength = 2;
} else if (
- !isInString(IPHPPartitionScannerConstants.PHP)
- && (fContentType != IPHPPartitionScannerConstants.PHP) // BUG #769044
- && (fContentType != IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT) // BUG #769044
+ !isInString(IPHPPartitions.PHP_PARTITIONING)
+ && (fContentType != IPHPPartitions.PHP_PARTITIONING) // BUG #769044
+ && (fContentType != IPHPPartitions.PHP_MULTILINE_COMMENT) // BUG #769044
&& checkPattern(new char[] { '!', '-', '-' })) { // return previouse partition
- if (fContentType != IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT && fCurrentLength > 4) {
+ if (fContentType != IPHPPartitions.HTML_MULTILINE_COMMENT && fCurrentLength > 4) {
unread(4);
IToken token = getToken(fContentType);
- fContentType = IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT;
+ fContentType = IPHPPartitions.HTML_MULTILINE_COMMENT;
return token;
} else
- fContentType = IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT;
+ fContentType = IPHPPartitions.HTML_MULTILINE_COMMENT;
fTokenOffset = fOffset - 4;
fCurrentLength = 4;
}
break;
case '?' :
- if (!isInString(IPHPPartitionScannerConstants.PHP) && fContentType == IPHPPartitionScannerConstants.PHP) {
+ if (!isInString(IPHPPartitions.PHP_PARTITIONING) && fContentType == IPHPPartitions.PHP_PARTITIONING) {
if ((c = read()) == '>') {
if (fPrevContentType != null)
fContentType = fPrevContentType;
else
- fContentType = IPHPPartitionScannerConstants.HTML;
+ fContentType = IPHPPartitions.HTML;
partitionBorder = true;
- return getToken(IPHPPartitionScannerConstants.PHP);
+ return getToken(IPHPPartitions.PHP_PARTITIONING);
} else if (c != ICharacterScanner.EOF)
unread();
}
break;
case '-' :
- if (!isInString(IPHPPartitionScannerConstants.PHP)
- && fContentType == IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT
+ if (!isInString(IPHPPartitions.PHP_PARTITIONING)
+ && fContentType == IPHPPartitions.HTML_MULTILINE_COMMENT
&& checkPattern(new char[] { '-', '>' })) {
- fContentType = IPHPPartitionScannerConstants.HTML;
+ fContentType = IPHPPartitions.HTML;
partitionBorder = true;
- return getToken(IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
+ return getToken(IPHPPartitions.HTML_MULTILINE_COMMENT);
}
break;
case '{' : // SMARTY code starts here ?
- if (fFileType == IPHPPartitionScannerConstants.SMARTY_FILE) {
+ if (fFileType == IPHPPartitions.SMARTY_FILE) {
if ((c = read()) == '*') {
if (DEBUG) {
System.out.println(
+ " fCurrentLength="
+ fCurrentLength);
}
- if (fContentType != IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT && fCurrentLength > 2) {
+ if (fContentType != IPHPPartitions.SMARTY_MULTILINE_COMMENT && fCurrentLength > 2) {
// SMARTY doc code starts here
unread(2);
IToken token = getToken(fContentType);
- fContentType = IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT;
+ fContentType = IPHPPartitions.SMARTY_MULTILINE_COMMENT;
return token;
// } else if (fContentType == IPHPPartitionScannerConstants.HTML && fOffset == 2) {
// fContentType = IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT;
} else { // if (fContentType == IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT) {
- fContentType = IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT;
+ fContentType = IPHPPartitions.SMARTY_MULTILINE_COMMENT;
fTokenOffset = fOffset - 2;
fCurrentLength = 2;
}
if (c != ICharacterScanner.EOF) {
unread();
}
- if (fContentType != IPHPPartitionScannerConstants.SMARTY && fCurrentLength > 1) {
+ if (fContentType != IPHPPartitions.SMARTY && fCurrentLength > 1) {
unread(1);
IToken token = getToken(fContentType);
- fContentType = IPHPPartitionScannerConstants.SMARTY;
+ fContentType = IPHPPartitions.SMARTY;
return token;
// } else if (fContentType == IPHPPartitionScannerConstants.HTML && fOffset==1) {
// fContentType = IPHPPartitionScannerConstants.SMARTY;
} else {
- fContentType = IPHPPartitionScannerConstants.SMARTY;
+ fContentType = IPHPPartitions.SMARTY;
fTokenOffset = fOffset - 1;
fCurrentLength = 1;
}
}
break;
case '}' : // SMARTY code ends here ?
- if (fFileType == IPHPPartitionScannerConstants.SMARTY_FILE && fContentType == IPHPPartitionScannerConstants.SMARTY) {
+ if (fFileType == IPHPPartitions.SMARTY_FILE && fContentType == IPHPPartitions.SMARTY) {
if (DEBUG) {
System.out.println(
"SMARTY_TOKEN end "
+ " fOffset="
+ fOffset);
}
- fContentType = IPHPPartitionScannerConstants.HTML;
+ fContentType = IPHPPartitions.HTML;
partitionBorder = true;
- return getToken(IPHPPartitionScannerConstants.SMARTY);
+ return getToken(IPHPPartitions.SMARTY);
}
break;
case '/' :
- if (!isInString(IPHPPartitionScannerConstants.PHP) && (c = read()) == '*') { // MULTINE COMMENT JAVASCRIPT, CSS, PHP
- if (fContentType == IPHPPartitionScannerConstants.PHP && fCurrentLength > 2) {
+ if (!isInString(IPHPPartitions.PHP_PARTITIONING) && (c = read()) == '*') { // MULTINE COMMENT JAVASCRIPT, CSS, PHP
+ if (fContentType == IPHPPartitions.PHP_PARTITIONING && fCurrentLength > 2) {
unread(2);
IToken token = getToken(fContentType);
- fContentType = IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT;
+ fContentType = IPHPPartitions.PHP_MULTILINE_COMMENT;
return token;
- } else if (fContentType == IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT) {
+ } else if (fContentType == IPHPPartitions.PHP_MULTILINE_COMMENT) {
fTokenOffset = fOffset - 2;
fCurrentLength = 2;
}
- } else if (!isInString(IPHPPartitionScannerConstants.PHP) && c != ICharacterScanner.EOF)
+ } else if (!isInString(IPHPPartitions.PHP_PARTITIONING) && c != ICharacterScanner.EOF)
unread();
break;
case '*' :
- if (!isInString(IPHPPartitionScannerConstants.PHP) && (c = read()) == '/') {
- if (fContentType == IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT) {
- fContentType = IPHPPartitionScannerConstants.PHP;
+ if (!isInString(IPHPPartitions.PHP_PARTITIONING) && (c = read()) == '/') {
+ if (fContentType == IPHPPartitions.PHP_MULTILINE_COMMENT) {
+ fContentType = IPHPPartitions.PHP_PARTITIONING;
partitionBorder = true;
- return getToken(IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
- } else if (fContentType == IPHPPartitionScannerConstants.CSS_MULTILINE_COMMENT) {
- } else if (fContentType == IPHPPartitionScannerConstants.JS_MULTILINE_COMMENT) {
+ return getToken(IPHPPartitions.PHP_MULTILINE_COMMENT);
+ } else if (fContentType == IPHPPartitions.CSS_MULTILINE_COMMENT) {
+ } else if (fContentType == IPHPPartitions.JS_MULTILINE_COMMENT) {
}
- } else if (fFileType == IPHPPartitionScannerConstants.SMARTY_FILE && (c = read()) == '}') {
+ } else if (fFileType == IPHPPartitions.SMARTY_FILE && (c = read()) == '}') {
if (DEBUG) {
System.out.println(
"SMARTYDOC_TOKEN end "
+ " fOffset="
+ fOffset);
}
- if (fContentType == IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT) {
- fContentType = IPHPPartitionScannerConstants.HTML;
+ if (fContentType == IPHPPartitions.SMARTY_MULTILINE_COMMENT) {
+ fContentType = IPHPPartitions.HTML;
partitionBorder = true;
- return getToken(IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT);
+ return getToken(IPHPPartitions.SMARTY_MULTILINE_COMMENT);
}
- } else if (!isInString(IPHPPartitionScannerConstants.PHP) && c != ICharacterScanner.EOF) {
+ } else if (!isInString(IPHPPartitions.PHP_PARTITIONING) && c != ICharacterScanner.EOF) {
unread();
}
break;
fEnd = fOffset + length;
fInString = false;
fInDoubString = false;
- fContentType = IPHPPartitionScannerConstants.HTML;
+ fContentType = IPHPPartitions.HTML;
// String[] prev = getPartitionStack(offset);
}
*/
package net.sourceforge.phpeclipse.phpeditor.php;
+import net.sourceforge.phpdt.internal.ui.text.*;
+
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.rules.ICharacterScanner;
* partitions contained within other partitions.
*
* @author Stefan Langer
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public abstract class Partition
{
public Partition(IDocument document, char[] delim, String contentType)
{
- this(document, delim, contentType, IPHPPartitionScannerConstants.HTML);
+ this(document, delim, contentType, IPHPPartitions.HTML);
}
/**
import java.util.ArrayList;
+import net.sourceforge.phpdt.internal.ui.text.*;
+
import org.eclipse.jface.text.IDocument;
/**
* contain other partitions.
*
* @author Stefan Langer
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class PartitionStack
{
return (String)fPartitionStack.get(fStackTop--);
}
- return IPHPPartitionScannerConstants.HTML;
+ return IPHPPartitions.HTML;
}
public boolean isEmpty()