[109468] get rid of subclasses of StructuredTextEditor
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/SelectionHistory.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/SelectionHistory.java
index 7bafc46..a235234 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/SelectionHistory.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/SelectionHistory.java
@@ -13,8 +13,10 @@
package org.eclipse.wst.sse.ui.internal.selection;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
+import org.eclipse.jface.action.IAction;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.util.Assert;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -23,9 +25,8 @@
public class SelectionHistory {
private ITextEditor fEditor;
-
private List fHistory;
- private StructureSelectHistoryAction fHistoryAction;
+ private List fHistoryActions;
private int fSelectionChangeListenerCounter;
private ISelectionChangedListener fSelectionListener;
@@ -44,13 +45,20 @@
public void dispose() {
fEditor.getSelectionProvider().removeSelectionChangedListener(fSelectionListener);
+ fEditor = null;
+ if (fHistory != null && !fHistory.isEmpty()) {
+ fHistory.clear();
+ }
+ if (fHistoryActions != null && !fHistoryActions.isEmpty()) {
+ fHistoryActions.clear();
+ }
}
public void flush() {
if (fHistory.isEmpty())
return;
fHistory.clear();
- fHistoryAction.update();
+ updateHistoryAction();
}
public IRegion getLast() {
@@ -58,7 +66,7 @@
return null;
int size = fHistory.size();
IRegion result = (IRegion) fHistory.remove(size - 1);
- fHistoryAction.update();
+ updateHistoryAction();
return result;
}
@@ -76,11 +84,34 @@
public void remember(IRegion region) {
fHistory.add(region);
- fHistoryAction.update();
+ updateHistoryAction();
}
- public void setHistoryAction(StructureSelectHistoryAction action) {
+ public void setHistoryAction(IAction action) {
Assert.isNotNull(action);
- fHistoryAction = action;
+
+ if (fHistoryActions == null)
+ fHistoryActions = new ArrayList();
+ if (!fHistoryActions.contains(action))
+ fHistoryActions.add(action);
+
+ // update action
+ if (fHistory != null && !fHistory.isEmpty())
+ action.setEnabled(true);
+ else
+ action.setEnabled(false);
+ }
+
+ private void updateHistoryAction() {
+ if (fHistoryActions != null && !fHistoryActions.isEmpty()) {
+ boolean enabled = false;
+ if (fHistory != null && !fHistory.isEmpty())
+ enabled = true;
+
+ Iterator iter = fHistoryActions.iterator();
+ while (iter.hasNext()) {
+ ((IAction)iter.next()).setEnabled(enabled);
+ }
+ }
}
}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectAction.java
index 7036f9f..1c39cbb 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectAction.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectAction.java
@@ -13,14 +13,19 @@
package org.eclipse.wst.sse.ui.internal.selection;
import org.eclipse.jface.action.Action;
+import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.util.Assert;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
import org.w3c.dom.Node;
+/**
+ * @deprecated use StructuredSelectActionDelegate instead
+ */
public abstract class StructureSelectAction extends Action {
protected StructuredTextEditor fEditor = null;
@@ -28,17 +33,15 @@
protected IStructuredModel fModel = null;
protected StructuredTextViewer fViewer = null;
- public StructureSelectAction(StructuredTextEditor editor, SelectionHistory history) {
+ public StructureSelectAction(StructuredTextEditor editor) {
super();
Assert.isNotNull(editor);
- Assert.isNotNull(history);
fEditor = editor;
- fHistory = history;
+ fHistory = (SelectionHistory) editor.getAdapter(SelectionHistory.class);
fViewer = editor.getTextViewer();
fModel = editor.getModel();
Assert.isNotNull(fViewer);
- //Assert.isNotNull(fModel);
}
abstract protected IndexedRegion getCursorIndexedRegion();
@@ -47,10 +50,19 @@
IndexedRegion indexedRegion = null;
int lastOffset = offset;
- indexedRegion = fModel.getIndexedRegion(lastOffset);
- while (indexedRegion == null && lastOffset >= 0) {
- lastOffset--;
- indexedRegion = fModel.getIndexedRegion(lastOffset);
+ IDocument document = fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
+ IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForRead(document);
+ if (model != null) {
+ try {
+ indexedRegion = model.getIndexedRegion(lastOffset);
+ while (indexedRegion == null && lastOffset >= 0) {
+ lastOffset--;
+ indexedRegion = model.getIndexedRegion(lastOffset);
+ }
+ }
+ finally {
+ model.releaseFromRead();
+ }
}
return indexedRegion;
@@ -88,7 +100,8 @@
try {
fHistory.ignoreSelectionChanges();
fEditor.selectAndReveal(newRegion.getOffset(), newRegion.getLength());
- } finally {
+ }
+ finally {
fHistory.listenToSelectionChanges();
}
}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectEnclosingAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectEnclosingAction.java
index 56a58a6..828bec2 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectEnclosingAction.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectEnclosingAction.java
@@ -19,8 +19,8 @@
import org.w3c.dom.Node;
public class StructureSelectEnclosingAction extends StructureSelectAction {
- public StructureSelectEnclosingAction(StructuredTextEditor editor, SelectionHistory history) {
- super(editor, history);
+ public StructureSelectEnclosingAction(StructuredTextEditor editor) {
+ super(editor);
setText(SSEUIMessages.StructureSelectEnclosing_label); //$NON-NLS-1$
setToolTipText(SSEUIMessages.StructureSelectEnclosing_tooltip); //$NON-NLS-1$
setDescription(SSEUIMessages.StructureSelectEnclosing_description); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectHistoryAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectHistoryAction.java
index 85b5637..c697450 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectHistoryAction.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectHistoryAction.java
@@ -21,8 +21,8 @@
import org.w3c.dom.Node;
public class StructureSelectHistoryAction extends StructureSelectAction implements IUpdate {
- public StructureSelectHistoryAction(StructuredTextEditor editor, SelectionHistory history) {
- super(editor, history);
+ public StructureSelectHistoryAction(StructuredTextEditor editor) {
+ super(editor);
setText(SSEUIMessages.StructureSelectHistory_label); //$NON-NLS-1$
setToolTipText(SSEUIMessages.StructureSelectHistory_tooltip); //$NON-NLS-1$
setDescription(SSEUIMessages.StructureSelectHistory_description); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectNextAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectNextAction.java
index 416e348..9efd05a 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectNextAction.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectNextAction.java
@@ -19,8 +19,8 @@
import org.w3c.dom.Node;
public class StructureSelectNextAction extends StructureSelectAction {
- public StructureSelectNextAction(StructuredTextEditor editor, SelectionHistory history) {
- super(editor, history);
+ public StructureSelectNextAction(StructuredTextEditor editor) {
+ super(editor);
setText(SSEUIMessages.StructureSelectNext_label); //$NON-NLS-1$
setToolTipText(SSEUIMessages.StructureSelectNext_tooltip); //$NON-NLS-1$
setDescription(SSEUIMessages.StructureSelectNext_description); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectPreviousAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectPreviousAction.java
index ee62e68..e395efe 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectPreviousAction.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectPreviousAction.java
@@ -19,8 +19,8 @@
import org.w3c.dom.Node;
public class StructureSelectPreviousAction extends StructureSelectAction {
- public StructureSelectPreviousAction(StructuredTextEditor editor, SelectionHistory history) {
- super(editor, history);
+ public StructureSelectPreviousAction(StructuredTextEditor editor) {
+ super(editor);
setText(SSEUIMessages.StructureSelectPrevious_label); //$NON-NLS-1$
setToolTipText(SSEUIMessages.StructureSelectPrevious_tooltip); //$NON-NLS-1$
setDescription(SSEUIMessages.StructureSelectPrevious_description); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AddBlockCommentActionXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AddBlockCommentActionXML.java
index 3ae707b..007928c 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AddBlockCommentActionXML.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AddBlockCommentActionXML.java
@@ -21,6 +21,9 @@
import org.eclipse.wst.xml.core.internal.document.CommentImpl;
import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
+/**
+ * @deprecated use AddBlockCommentActionXMLDelegate instead
+ */
public class AddBlockCommentActionXML extends CommentActionXML {
protected int fCloseCommentOffset;
protected int fOpenCommentOffset;
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/CleanupActionXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/CleanupActionXML.java
index bec5167..d9098bd 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/CleanupActionXML.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/CleanupActionXML.java
@@ -21,7 +21,9 @@
import org.eclipse.wst.sse.ui.internal.actions.CleanupAction;
import org.eclipse.wst.xml.core.internal.cleanup.CleanupProcessorXML;
-
+/**
+ * @deprecated Use CleanupActionXMLDelegate instead.
+ */
public class CleanupActionXML extends CleanupAction {
protected IStructuredCleanupProcessor fCleanupProcessor;
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/CommentActionXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/CommentActionXML.java
index 4aea2fc..2ccbe42 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/CommentActionXML.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/CommentActionXML.java
@@ -32,6 +32,10 @@
import org.eclipse.wst.sse.core.internal.provisional.exceptions.SourceEditingRuntimeException;
import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
+/**
+ * @deprecated use AbstractCommentActionXMLDelegate or
+ * ToggleCommentActionXMLDelegate instead
+ */
public class CommentActionXML extends TextEditorAction {
protected static final String CLOSE_COMMENT = "-->"; //$NON-NLS-1$
protected static final String OPEN_COMMENT = "<!--"; //$NON-NLS-1$
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/RemoveBlockCommentActionXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/RemoveBlockCommentActionXML.java
index 2525b95..d0baaf2 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/RemoveBlockCommentActionXML.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/RemoveBlockCommentActionXML.java
@@ -20,6 +20,9 @@
import org.eclipse.wst.xml.core.internal.document.CommentImpl;
import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
+/**
+ * @deprecated use RemoveBlockCommentActionXMLDelegate instead
+ */
public class RemoveBlockCommentActionXML extends AddBlockCommentActionXML {
public RemoveBlockCommentActionXML(ResourceBundle bundle, String prefix, ITextEditor editor) {
super(bundle, prefix, editor);
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ToggleCommentActionXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ToggleCommentActionXML.java
index 3aba896..44a823e 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ToggleCommentActionXML.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ToggleCommentActionXML.java
@@ -20,6 +20,9 @@
import org.eclipse.wst.sse.core.internal.provisional.exceptions.SourceEditingRuntimeException;
import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
+/**
+ * @deprecated use ToggleCommentActionXMLDelegate instead
+ */
public class ToggleCommentActionXML extends UncommentActionXML {
public ToggleCommentActionXML(ResourceBundle bundle, String prefix, ITextEditor editor) {
super(bundle, prefix, editor);
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/UncommentActionXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/UncommentActionXML.java
index 9fcd5f4..03cf5a9 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/UncommentActionXML.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/UncommentActionXML.java
@@ -20,6 +20,9 @@
import org.eclipse.wst.sse.core.internal.provisional.exceptions.SourceEditingRuntimeException;
import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
+/**
+ * @deprecated use ToggleCommentActionXMLDelegate instead
+ */
public class UncommentActionXML extends CommentActionXML {
public UncommentActionXML(ResourceBundle bundle, String prefix, ITextEditor editor) {
super(bundle, prefix, editor);
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/provisional/StructuredTextEditorXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/provisional/StructuredTextEditorXML.java
index e3acc6f..f6b638d 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/provisional/StructuredTextEditorXML.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/provisional/StructuredTextEditorXML.java
@@ -27,6 +27,10 @@
import org.eclipse.wst.xml.ui.internal.editor.IHelpContextIds;
import org.eclipse.wst.xml.ui.internal.search.XMLFindOccurrencesAction;
+/**
+ * @deprecated XML editor is created from StructuredTextEditor with
+ * XML configurations
+ */
public class StructuredTextEditorXML extends StructuredTextEditor {
private final static String UNDERSCORE = "_"; //$NON-NLS-1$
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/search/XMLFindOccurrencesAction.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/search/XMLFindOccurrencesAction.java
index f47127b..e542079 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/search/XMLFindOccurrencesAction.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/search/XMLFindOccurrencesAction.java
@@ -30,7 +30,7 @@
* Uses default <code>getSearchQuery()</code>.
* </p>
*
- * @author pavery
+ * @deprecated use XMLFindOccurrencesProcessor instead
*/
public class XMLFindOccurrencesAction extends BasicFindOccurrencesAction {