Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 27092 Details for
Bug 109468
get rid of subclasses of StructuredTextEditor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
org.eclipse.wst.sse.ui.patch
org.eclipse.wst.sse.ui.patch (text/plain), 47.08 KB, created by
Amy Wu
on 2005-09-14 02:20:08 EDT
(
hide
)
Description:
org.eclipse.wst.sse.ui.patch
Filename:
MIME Type:
Creator:
Amy Wu
Created:
2005-09-14 02:20:08 EDT
Size:
47.08 KB
patch
obsolete
>Index: plugin.xml >=================================================================== >RCS file: /home/webtools/wst/components/sse/plugins/org.eclipse.wst.sse.ui/plugin.xml,v >retrieving revision 1.30 >diff -u -r1.30 plugin.xml >--- plugin.xml 7 Sep 2005 23:49:10 -0000 1.30 >+++ plugin.xml 14 Sep 2005 06:18:08 -0000 >@@ -112,185 +112,188 @@ > <extension-point id="dragSourceTransfers" name="Drag Source Transfers"/> > --> > <extension point="org.eclipse.ui.commands"> >- <scope >- name="%scope.structuredTextEditor.name" >- parent="org.eclipse.ui.textEditorScope" >- description="%scope.structuredTextEditor.description" >- id="org.eclipse.wst.sse.ui.structuredTextEditorScope"> >- </scope> >- <!-- dmw 6/6 (and 11/10 :) removed from 'scope' parentId="org.eclipse.ui.textEditorScope" --> >- <!-- afw 11/11 added scope back in because these are keybindings for structuredtexteditors only --> >- > <!-- Edit commands --> > <command > name="%ActionDefinition.selectEnclosing.name" > description="%ActionDefinition.selectEnclosing.description" >- category="org.eclipse.ui.category.edit" >+ categoryId="org.eclipse.ui.category.edit" > id="org.eclipse.wst.sse.ui.structure.select.enclosing"> > </command> > <command > name="%ActionDefinition.selectNext.name" > description="%ActionDefinition.selectNext.description" >- category="org.eclipse.ui.category.edit" >+ categoryId="org.eclipse.ui.category.edit" > id="org.eclipse.wst.sse.ui.structure.select.next"> > </command> > <command > name="%ActionDefinition.selectPrevious.name" > description="%ActionDefinition.selectPrevious.description" >- category="org.eclipse.ui.category.edit" >+ categoryId="org.eclipse.ui.category.edit" > id="org.eclipse.wst.sse.ui.structure.select.previous"> > </command> > <command > name="%ActionDefinition.selectLast.name" > description="%ActionDefinition.selectLast.description" >- category="org.eclipse.ui.category.edit" >+ categoryId="org.eclipse.ui.category.edit" > id="org.eclipse.wst.sse.ui.structure.select.last"> > </command> > <command > name="%ActionDefinition.showJavadoc.name" > description="%ActionDefinition.showJavadoc.description" >- category="org.eclipse.ui.category.edit" >+ categoryId="org.eclipse.ui.category.edit" > id="org.eclipse.wst.sse.ui.show.javadoc"> > </command> > <command > name="%ActionDefinition.quickFix.name" > description="%ActionDefinition.quickFix.description" >- category="org.eclipse.ui.category.edit" >+ categoryId="org.eclipse.ui.category.edit" > id="org.eclipse.wst.sse.ui.edit.text.java.correction.assist.proposals"> > </command> > <!-- Source commands --> > <command > name="%command.toggle.comment.name" > description="%command.toggle.comment.description" >- category="org.eclipse.ui.category.edit" >+ categoryId="org.eclipse.ui.category.edit" > id="org.eclipse.wst.sse.ui.toggle.comment"> > </command> > <command > name="%command.add.block.comment.name" > description="%command.add.block.comment.description" >- category="org.eclipse.ui.category.edit" >+ categoryId="org.eclipse.ui.category.edit" > id="org.eclipse.wst.sse.ui.add.block.comment"> > </command> > <command > name="%command.remove.block.comment.name" > description="%command.remove.block.comment.description" >- category="org.eclipse.ui.category.edit" >+ categoryId="org.eclipse.ui.category.edit" > id="org.eclipse.wst.sse.ui.remove.block.comment"> > </command> > <command > name="%command.cleanup.document.name" > description="%command.cleanup.document.description" >- category="org.eclipse.ui.category.edit" >+ categoryId="org.eclipse.ui.category.edit" > id="org.eclipse.wst.sse.ui.cleanup.document"> > </command> > <command > name="%command.format.document.name" > description="%command.format.document.description" >- category="org.eclipse.ui.category.edit" >+ categoryId="org.eclipse.ui.category.edit" > id="org.eclipse.wst.sse.ui.format.document"> > </command> > <command > name="%command.format.active.elements.name" > description="%command.format.active.elements.description" >- category="org.eclipse.ui.category.edit" >+ categoryId="org.eclipse.ui.category.edit" > id="org.eclipse.wst.sse.ui.format.active.elements"> > </command> > <!-- Navigate commands --> > <command > name="%command.open.file.from.source.name" > description="%command.open.file.from.source.description" >- category="org.eclipse.ui.category.edit" >+ categoryId="org.eclipse.ui.category.edit" > id="org.eclipse.wst.sse.ui.open.file.from.source"> > </command> > <!-- Find Occurrences --> > <command > name="%command.search.find.occurrences.name" > description="%command.search.find.occurrences.description" >- category="org.eclipse.ui.category.edit" >+ categoryId="org.eclipse.ui.category.edit" > id="org.eclipse.wst.sse.ui.search.find.occurrences"> > </command> >+ </extension> >+ <!-- Keybinding scope for source editor --> >+ <extension point="org.eclipse.ui.contexts"> >+ <context >+ name="%scope.structuredTextEditor.name" >+ parentId="org.eclipse.ui.textEditorScope" >+ description="%scope.structuredTextEditor.description" >+ id="org.eclipse.wst.sse.ui.structuredTextEditorScope"> >+ </context> >+ </extension> >+ <!-- Keybindings for source editor --> >+ <extension point="org.eclipse.ui.bindings"> > <!-- Edit commands --> >- <keyBinding >- string="Alt+Shift+ARROW_UP" >- scope="org.eclipse.wst.sse.ui.structuredTextEditorScope" >- command="org.eclipse.wst.sse.ui.structure.select.enclosing" >- configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> >- </keyBinding> >- <keyBinding >- string="Alt+Shift+ARROW_RIGHT" >- scope="org.eclipse.wst.sse.ui.structuredTextEditorScope" >- command="org.eclipse.wst.sse.ui.structure.select.next" >- configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> >- </keyBinding> >- <keyBinding >- string="Alt+Shift+ARROW_LEFT" >- scope="org.eclipse.wst.sse.ui.structuredTextEditorScope" >- command="org.eclipse.wst.sse.ui.structure.select.previous" >- configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> >- </keyBinding> >- <keyBinding >- string="Alt+Shift+ARROW_DOWN" >- scope="org.eclipse.wst.sse.ui.structuredTextEditorScope" >- command="org.eclipse.wst.sse.ui.structure.select.last" >- configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> >- </keyBinding> >- <keyBinding >- string="F2" >- scope="org.eclipse.wst.sse.ui.structuredTextEditorScope" >- command="org.eclipse.wst.sse.ui.show.javadoc" >- configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> >- </keyBinding> >- <keyBinding >- string="Ctrl+1" >- scope="org.eclipse.wst.sse.ui.structuredTextEditorScope" >- command="org.eclipse.wst.sse.ui.edit.text.java.correction.assist.proposals" >- configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> >- </keyBinding> >+ <key >+ sequence="Alt+Shift+ARROW_UP" >+ contextId="org.eclipse.wst.sse.ui.structuredTextEditorScope" >+ commandId="org.eclipse.wst.sse.ui.structure.select.enclosing" >+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"> >+ </key> >+ <key >+ sequence="Alt+Shift+ARROW_RIGHT" >+ contextId="org.eclipse.wst.sse.ui.structuredTextEditorScope" >+ commandId="org.eclipse.wst.sse.ui.structure.select.next" >+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"> >+ </key> >+ <key >+ sequence="Alt+Shift+ARROW_LEFT" >+ contextId="org.eclipse.wst.sse.ui.structuredTextEditorScope" >+ commandId="org.eclipse.wst.sse.ui.structure.select.previous" >+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"> >+ </key> >+ <key >+ sequence="Alt+Shift+ARROW_DOWN" >+ contextId="org.eclipse.wst.sse.ui.structuredTextEditorScope" >+ commandId="org.eclipse.wst.sse.ui.structure.select.last" >+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"> >+ </key> >+ <key >+ sequence="F2" >+ contextId="org.eclipse.wst.sse.ui.structuredTextEditorScope" >+ commandId="org.eclipse.wst.sse.ui.show.javadoc" >+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"> >+ </key> >+ <key >+ sequence="Ctrl+1" >+ contextId="org.eclipse.wst.sse.ui.structuredTextEditorScope" >+ commandId="org.eclipse.wst.sse.ui.edit.text.java.correction.assist.proposals" >+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"> >+ </key> > <!-- Source commands --> >- <keyBinding >- string="Ctrl+Shift+C" >- scope="org.eclipse.wst.sse.ui.structuredTextEditorScope" >- command="org.eclipse.wst.sse.ui.toggle.comment" >- configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> >- </keyBinding> >- <keyBinding >- string="Ctrl+Shift+/" >- scope="org.eclipse.wst.sse.ui.structuredTextEditorScope" >- command="org.eclipse.wst.sse.ui.add.block.comment" >- configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> >- </keyBinding> >- <keyBinding >- string="Ctrl+Shift+\" >- scope="org.eclipse.wst.sse.ui.structuredTextEditorScope" >- command="org.eclipse.wst.sse.ui.remove.block.comment" >- configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> >- </keyBinding> >- <keyBinding >- string="Ctrl+Shift+F" >- scope="org.eclipse.wst.sse.ui.structuredTextEditorScope" >- command="org.eclipse.wst.sse.ui.format.document" >- configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> >- </keyBinding> >- <keyBinding >- string="Ctrl+I" >- scope="org.eclipse.wst.sse.ui.structuredTextEditorScope" >- command="org.eclipse.wst.sse.ui.format.active.elements" >- configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> >- </keyBinding> >+ <key >+ sequence="Ctrl+Shift+C" >+ contextId="org.eclipse.wst.sse.ui.structuredTextEditorScope" >+ commandId="org.eclipse.wst.sse.ui.toggle.comment" >+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"> >+ </key> >+ <key >+ sequence="Ctrl+Shift+/" >+ contextId="org.eclipse.wst.sse.ui.structuredTextEditorScope" >+ commandId="org.eclipse.wst.sse.ui.add.block.comment" >+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"> >+ </key> >+ <key >+ sequence="Ctrl+Shift+\" >+ contextId="org.eclipse.wst.sse.ui.structuredTextEditorScope" >+ commandId="org.eclipse.wst.sse.ui.remove.block.comment" >+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"> >+ </key> >+ <key >+ sequence="Ctrl+Shift+F" >+ contextId="org.eclipse.wst.sse.ui.structuredTextEditorScope" >+ commandId="org.eclipse.wst.sse.ui.format.document" >+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"> >+ </key> >+ <key >+ sequence="Ctrl+I" >+ contextId="org.eclipse.wst.sse.ui.structuredTextEditorScope" >+ commandId="org.eclipse.wst.sse.ui.format.active.elements" >+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"> >+ </key> > <!-- Navigate commands --> >- <keyBinding >- string="F3" >- scope="org.eclipse.wst.sse.ui.structuredTextEditorScope" >- command="org.eclipse.wst.sse.ui.open.file.from.source" >- configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> >- </keyBinding> >+ <key >+ sequence="F3" >+ contextId="org.eclipse.wst.sse.ui.structuredTextEditorScope" >+ commandId="org.eclipse.wst.sse.ui.open.file.from.source" >+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"> >+ </key> > <!-- Find Occurrences --> >- <keyBinding >- string="Ctrl+Shift+A" >- scope="org.eclipse.wst.sse.ui.structuredTextEditorScope" >- command="org.eclipse.wst.sse.ui.search.find.occurrences" >- configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> >- </keyBinding> >+ <key >+ sequence="Ctrl+Shift+A" >+ contextId="org.eclipse.wst.sse.ui.structuredTextEditorScope" >+ commandId="org.eclipse.wst.sse.ui.search.find.occurrences" >+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"> >+ </key> > </extension> > <!-- Font and colors contributions --> > <extension point="org.eclipse.ui.themes"> >Index: src/org/eclipse/wst/sse/ui/internal/StructuredTextEditor.java >=================================================================== >RCS file: /home/webtools/wst/components/sse/plugins/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/StructuredTextEditor.java,v >retrieving revision 1.28 >diff -u -r1.28 StructuredTextEditor.java >--- src/org/eclipse/wst/sse/ui/internal/StructuredTextEditor.java 14 Sep 2005 04:55:09 -0000 1.28 >+++ src/org/eclipse/wst/sse/ui/internal/StructuredTextEditor.java 14 Sep 2005 06:18:10 -0000 >@@ -171,10 +171,6 @@ > import org.eclipse.wst.sse.ui.internal.provisional.views.properties.PropertySheetConfiguration; > import org.eclipse.wst.sse.ui.internal.provisional.views.properties.StructuredPropertySheetConfiguration; > import org.eclipse.wst.sse.ui.internal.selection.SelectionHistory; >-import org.eclipse.wst.sse.ui.internal.selection.StructureSelectEnclosingAction; >-import org.eclipse.wst.sse.ui.internal.selection.StructureSelectHistoryAction; >-import org.eclipse.wst.sse.ui.internal.selection.StructureSelectNextAction; >-import org.eclipse.wst.sse.ui.internal.selection.StructureSelectPreviousAction; > import org.eclipse.wst.sse.ui.internal.text.DocumentRegionEdgeMatcher; > import org.eclipse.wst.sse.ui.internal.util.Assert; > >@@ -815,6 +811,8 @@ > /** The text context menu manager to be disposed. */ > private MenuManager fTextContextMenuManager; > private String fViewerConfigurationTargetId; >+ /** The selection history of the editor */ >+ private SelectionHistory fSelectionHistory; > > private boolean fUpdateMenuTextPending; > int hoverX = -1; >@@ -1155,24 +1153,6 @@ > setAction(StructuredTextEditorActionConstants.ACTION_NAME_OPEN_FILE, action); > > fShowPropertiesAction = new ShowPropertiesAction(); >- >- SelectionHistory selectionHistory = new SelectionHistory(this); >- action = new StructureSelectEnclosingAction(this, selectionHistory); >- action.setActionDefinitionId(ActionDefinitionIds.STRUCTURE_SELECT_ENCLOSING); >- setAction(StructuredTextEditorActionConstants.ACTION_NAME_STRUCTURE_SELECT_ENCLOSING, action); >- >- action = new StructureSelectNextAction(this, selectionHistory); >- action.setActionDefinitionId(ActionDefinitionIds.STRUCTURE_SELECT_NEXT); >- setAction(StructuredTextEditorActionConstants.ACTION_NAME_STRUCTURE_SELECT_NEXT, action); >- >- action = new StructureSelectPreviousAction(this, selectionHistory); >- action.setActionDefinitionId(ActionDefinitionIds.STRUCTURE_SELECT_PREVIOUS); >- setAction(StructuredTextEditorActionConstants.ACTION_NAME_STRUCTURE_SELECT_PREVIOUS, action); >- >- action = new StructureSelectHistoryAction(this, selectionHistory); >- action.setActionDefinitionId(ActionDefinitionIds.STRUCTURE_SELECT_HISTORY); >- setAction(StructuredTextEditorActionConstants.ACTION_NAME_STRUCTURE_SELECT_HISTORY, action); >- selectionHistory.setHistoryAction((StructureSelectHistoryAction) action); > } > > protected LineChangeHover createChangeHover() { >@@ -1385,6 +1365,12 @@ > System.out.println("Total time in getAdapter: " + adapterTime); //$NON-NLS-1$ > System.out.println("Average time per call: " + (adapterTime / adapterRequests)); //$NON-NLS-1$ > } >+ >+ // dispose of selection history >+ if (fSelectionHistory != null) { >+ fSelectionHistory.dispose(); >+ fSelectionHistory = null; >+ } > > // dispose of document folding support > if (fProjectionModelUpdater != null) { >@@ -1733,6 +1719,11 @@ > else if (IShowInTargetList.class.equals(required)) { > return new ShowInTargetListAdapter(); > } >+ else if (SelectionHistory.class.equals(required)) { >+ if (fSelectionHistory == null) >+ fSelectionHistory = new SelectionHistory(this); >+ return fSelectionHistory; >+ } > else { > if (result == null && getInternalModel() != null) { > result = getInternalModel().getAdapter(required); >Index: src/org/eclipse/wst/sse/ui/internal/search/BasicFindOccurrencesAction.java >=================================================================== >RCS file: /home/webtools/wst/components/sse/plugins/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/BasicFindOccurrencesAction.java,v >retrieving revision 1.6 >diff -u -r1.6 BasicFindOccurrencesAction.java >--- src/org/eclipse/wst/sse/ui/internal/search/BasicFindOccurrencesAction.java 31 May 2005 07:41:51 -0000 1.6 >+++ src/org/eclipse/wst/sse/ui/internal/search/BasicFindOccurrencesAction.java 14 Sep 2005 06:18:11 -0000 >@@ -42,7 +42,7 @@ > * Java elements, etc...) > * </p> > * >- * @author pavery >+ * @deprecated use FindOccurrencesProcessor instead > */ > public class BasicFindOccurrencesAction extends TextEditorAction { > private IStructuredDocument fDocument = null; >Index: src/org/eclipse/wst/sse/ui/internal/search/FindOccurrencesActionProvider.java >=================================================================== >RCS file: /home/webtools/wst/components/sse/plugins/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/FindOccurrencesActionProvider.java,v >retrieving revision 1.6 >diff -u -r1.6 FindOccurrencesActionProvider.java >--- src/org/eclipse/wst/sse/ui/internal/search/FindOccurrencesActionProvider.java 13 Apr 2005 22:43:41 -0000 1.6 >+++ src/org/eclipse/wst/sse/ui/internal/search/FindOccurrencesActionProvider.java 14 Sep 2005 06:18:11 -0000 >@@ -33,7 +33,7 @@ > * Clients can add actions for different partitions via > * <code>addAction(BasicFindOccurrencesAction action)</code> > * >- * @author pavery >+ * @deprecated use FindOccurrencesActionDelegate instead > */ > public class FindOccurrencesActionProvider extends TextEditorAction { > >Index: src/org/eclipse/wst/sse/ui/internal/selection/SelectionHistory.java >=================================================================== >RCS file: /home/webtools/wst/components/sse/plugins/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/SelectionHistory.java,v >retrieving revision 1.3 >diff -u -r1.3 SelectionHistory.java >--- src/org/eclipse/wst/sse/ui/internal/selection/SelectionHistory.java 11 Nov 2004 08:37:48 -0000 1.3 >+++ src/org/eclipse/wst/sse/ui/internal/selection/SelectionHistory.java 14 Sep 2005 06:18:11 -0000 >@@ -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); >+ } >+ } > } > } >Index: src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectAction.java >=================================================================== >RCS file: /home/webtools/wst/components/sse/plugins/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectAction.java,v >retrieving revision 1.6 >diff -u -r1.6 StructureSelectAction.java >--- src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectAction.java 18 Apr 2005 07:59:42 -0000 1.6 >+++ src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectAction.java 14 Sep 2005 06:18:11 -0000 >@@ -13,32 +13,32 @@ > 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.internal.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; > protected SelectionHistory fHistory; >- 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 +47,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 +97,8 @@ > try { > fHistory.ignoreSelectionChanges(); > fEditor.selectAndReveal(newRegion.getOffset(), newRegion.getLength()); >- } finally { >+ } >+ finally { > fHistory.listenToSelectionChanges(); > } > } >Index: src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectEnclosingAction.java >=================================================================== >RCS file: /home/webtools/wst/components/sse/plugins/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectEnclosingAction.java,v >retrieving revision 1.7 >diff -u -r1.7 StructureSelectEnclosingAction.java >--- src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectEnclosingAction.java 18 Apr 2005 07:59:42 -0000 1.7 >+++ src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectEnclosingAction.java 14 Sep 2005 06:18:11 -0000 >@@ -18,9 +18,14 @@ > import org.eclipse.wst.sse.ui.internal.StructuredTextEditor; > import org.w3c.dom.Node; > >+/** >+ * @deprecated use >+ * org.eclipse.wst.xml.ui.internal.selection.StructuredSelectEnclosingXMLActionDelegate >+ * instead >+ */ > 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$ >Index: src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectHistoryAction.java >=================================================================== >RCS file: /home/webtools/wst/components/sse/plugins/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectHistoryAction.java,v >retrieving revision 1.7 >diff -u -r1.7 StructureSelectHistoryAction.java >--- src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectHistoryAction.java 18 Apr 2005 07:59:42 -0000 1.7 >+++ src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectHistoryAction.java 14 Sep 2005 06:18:11 -0000 >@@ -20,13 +20,17 @@ > import org.eclipse.wst.sse.ui.internal.StructuredTextEditor; > import org.w3c.dom.Node; > >+/** >+ * @deprecated use StructuredSelectHistoryActionDelegate instead >+ */ > 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$ > >+ fHistory.setHistoryAction(this); > update(); > } > >Index: src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectNextAction.java >=================================================================== >RCS file: /home/webtools/wst/components/sse/plugins/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectNextAction.java,v >retrieving revision 1.7 >diff -u -r1.7 StructureSelectNextAction.java >--- src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectNextAction.java 18 Apr 2005 07:59:42 -0000 1.7 >+++ src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectNextAction.java 14 Sep 2005 06:18:11 -0000 >@@ -18,9 +18,14 @@ > import org.eclipse.wst.sse.ui.internal.StructuredTextEditor; > import org.w3c.dom.Node; > >+/** >+ * @deprecated use >+ * org.eclipse.wst.xml.ui.internal.selection.StructuredSelectNextXMLActionDelegate >+ * instead >+ */ > 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$ >Index: src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectPreviousAction.java >=================================================================== >RCS file: /home/webtools/wst/components/sse/plugins/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectPreviousAction.java,v >retrieving revision 1.7 >diff -u -r1.7 StructureSelectPreviousAction.java >--- src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectPreviousAction.java 18 Apr 2005 07:59:42 -0000 1.7 >+++ src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectPreviousAction.java 14 Sep 2005 06:18:11 -0000 >@@ -18,9 +18,14 @@ > import org.eclipse.wst.sse.ui.internal.StructuredTextEditor; > import org.w3c.dom.Node; > >+/** >+ * @deprecated use >+ * org.eclipse.wst.xml.ui.internal.selection.StructuredSelectPreviousXMLActionDelegate >+ * instead >+ */ > 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$ >Index: src/org/eclipse/wst/sse/ui/internal/search/FindOccurrencesActionDelegate.java >=================================================================== >RCS file: src/org/eclipse/wst/sse/ui/internal/search/FindOccurrencesActionDelegate.java >diff -N src/org/eclipse/wst/sse/ui/internal/search/FindOccurrencesActionDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/sse/ui/internal/search/FindOccurrencesActionDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,147 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * >+ *******************************************************************************/ >+ >+package org.eclipse.wst.sse.ui.internal.search; >+ >+import java.util.Iterator; >+import java.util.List; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.text.BadLocationException; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.ITextSelection; >+import org.eclipse.jface.text.ITypedRegion; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.ui.IActionDelegate2; >+import org.eclipse.ui.IEditorActionDelegate; >+import org.eclipse.ui.IEditorPart; >+import org.eclipse.ui.IFileEditorInput; >+import org.eclipse.ui.IViewActionDelegate; >+import org.eclipse.ui.IViewPart; >+import org.eclipse.ui.texteditor.ITextEditor; >+import org.eclipse.wst.sse.ui.internal.SSEUIMessages; >+import org.eclipse.wst.sse.ui.internal.util.PlatformStatusLineUtil; >+ >+/** >+ * Performs the appropriate FindOccurrencesProcessor action call based on >+ * selection. Clients can add processors for different partitions via >+ * <code>getProcessors</code> >+ * >+ */ >+abstract public class FindOccurrencesActionDelegate implements IEditorActionDelegate, IActionDelegate2, IViewActionDelegate { >+ private IEditorPart fEditor; >+ >+ public void setActiveEditor(IAction action, IEditorPart targetEditor) { >+ fEditor = targetEditor; >+ } >+ >+ public void dispose() { >+ // nulling out just in case >+ fEditor = null; >+ } >+ >+ public void init(IAction action) { >+ if (action != null) { >+ action.setText(SSEUIMessages.FindOccurrences_label); >+ } >+ } >+ >+ public void runWithEvent(IAction action, Event event) { >+ run(action); >+ } >+ >+ public void run(IAction action) { >+ boolean okay = false; >+ if (fEditor instanceof ITextEditor) { >+ ITextEditor textEditor = (ITextEditor) fEditor; >+ IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput()); >+ if (document != null) { >+ ITextSelection textSelection = getTextSelection(textEditor); >+ FindOccurrencesProcessor findOccurrenceProcessor = getProcessorForCurrentSelection(document, textSelection); >+ if (findOccurrenceProcessor != null) { >+ if (textEditor.getEditorInput() instanceof IFileEditorInput) { >+ IFile file = ((IFileEditorInput) textEditor.getEditorInput()).getFile(); >+ okay = findOccurrenceProcessor.findOccurrences(document, textSelection, file); >+ } >+ } >+ } >+ } >+ if (okay) { >+ // clear status message >+ PlatformStatusLineUtil.clearStatusLine(); >+ } >+ else { >+ String errorMessage = SSEUIMessages.FindOccurrencesActionProvider_0; //$NON-NLS-1$ >+ PlatformStatusLineUtil.displayErrorMessage(errorMessage); >+ PlatformStatusLineUtil.addOneTimeClearListener(); >+ } >+ } >+ >+ public void init(IViewPart view) { >+ // do nothing >+ } >+ >+ public void selectionChanged(IAction action, ISelection selection) { >+ // clear status message >+ PlatformStatusLineUtil.clearStatusLine(); >+ } >+ >+ /** >+ * Get the appropriate find occurrences processor >+ * >+ * @param document - >+ * assumes not null >+ * @param textSelection >+ * @return >+ */ >+ private FindOccurrencesProcessor getProcessorForCurrentSelection(IDocument document, ITextSelection textSelection) { >+ // check if we have an action that's enabled on the current partition >+ ITypedRegion tr = getPartition(document, textSelection); >+ String partition = tr != null ? tr.getType() : ""; //$NON-NLS-1$ >+ >+ Iterator it = getProcessors().iterator(); >+ FindOccurrencesProcessor action = null; >+ while (it.hasNext()) { >+ action = (FindOccurrencesProcessor) it.next(); >+ // we just choose the first action that can handle the partition >+ if (action.enabledForParitition(partition)) >+ return action; >+ } >+ return null; >+ } >+ >+ private ITypedRegion getPartition(IDocument document, ITextSelection textSelection) { >+ ITypedRegion region = null; >+ if (textSelection != null) { >+ try { >+ region = document.getPartition(textSelection.getOffset()); >+ } >+ catch (BadLocationException e) { >+ region = null; >+ } >+ } >+ return region; >+ } >+ >+ private ITextSelection getTextSelection(ITextEditor textEditor) { >+ ITextSelection textSelection = null; >+ ISelection selection = textEditor.getSelectionProvider().getSelection(); >+ if (selection instanceof ITextSelection && !selection.isEmpty()) { >+ textSelection = (ITextSelection) selection; >+ } >+ return textSelection; >+ } >+ >+ abstract protected List getProcessors(); >+} >Index: src/org/eclipse/wst/sse/ui/internal/search/FindOccurrencesProcessor.java >=================================================================== >RCS file: src/org/eclipse/wst/sse/ui/internal/search/FindOccurrencesProcessor.java >diff -N src/org/eclipse/wst/sse/ui/internal/search/FindOccurrencesProcessor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/sse/ui/internal/search/FindOccurrencesProcessor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,121 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * >+ *******************************************************************************/ >+ >+package org.eclipse.wst.sse.ui.internal.search; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.ITextSelection; >+import org.eclipse.search.ui.ISearchQuery; >+import org.eclipse.search.ui.NewSearchUI; >+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; >+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; >+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; >+ >+/** >+ * <p> >+ * Finds occurrences of a specified region type w/ region text in an >+ * IStructuredDocument. Clients must implement getPartitionTypes() and >+ * getRegionTypes() to indicate which partition types and region types it can >+ * operate on. >+ * </p> >+ * >+ * <p> >+ * Clients should override <code>getSearchQuery()</code> in order to provide >+ * their own type of "search" (eg. searching for XML start tags, searching for >+ * Java elements, etc...) >+ * </p> >+ * >+ */ >+abstract public class FindOccurrencesProcessor { >+ public boolean findOccurrences(IDocument document, ITextSelection textSelection, IFile file) { >+ boolean findOccurrences = false; >+ >+ // determine if action should be enabled or not >+ if (document instanceof IStructuredDocument) { >+ IStructuredDocument structuredDocument = (IStructuredDocument) document; >+ IStructuredDocumentRegion sdRegion = structuredDocument.getRegionAtCharacterOffset(textSelection.getOffset()); >+ if (sdRegion != null) { >+ ITextRegion r = sdRegion.getRegionAtCharacterOffset(textSelection.getOffset()); >+ if (r != null) { >+ String type = r.getType(); >+ if (enabledForRegionType(type)) { >+ String matchText = sdRegion.getText(r); >+ >+ // first of all activate the view >+ NewSearchUI.activateSearchResultView(); >+ >+ if (matchText != null && type != null) { >+ ISearchQuery searchQuery = getSearchQuery(file, structuredDocument, matchText, type, textSelection); >+ if (searchQuery != null) { >+ if (searchQuery.canRunInBackground()) >+ NewSearchUI.runQueryInBackground(searchQuery); >+ else >+ NewSearchUI.runQueryInForeground(null, searchQuery); >+ } >+ findOccurrences = true; >+ } >+ } >+ } >+ } >+ } >+ return findOccurrences; >+ } >+ >+ /** >+ * @param regionType >+ * @return <code>true</code> if this action can operate on this region >+ * type (ITextRegion), otherwise false. >+ */ >+ private boolean enabledForRegionType(String regionType) { >+ >+ String[] accept = getRegionTypes(); >+ for (int i = 0; i < accept.length; i++) { >+ if (regionType.equals(accept[i])) >+ return true; >+ } >+ return false; >+ } >+ >+ /** >+ * Clients should override this to enable find occurrences on certain >+ * partition(s). >+ */ >+ abstract protected String[] getPartitionTypes(); >+ >+ /** >+ * Clients should override this to enable find occurrences on different >+ * region type(s). >+ */ >+ abstract protected String[] getRegionTypes(); >+ >+ /** >+ * Clients should override to provide their own search for the file. >+ */ >+ protected ISearchQuery getSearchQuery(IFile file, IStructuredDocument document, String regionText, String regionType, ITextSelection textSelection) { >+ return new OccurrencesSearchQuery(file, document, regionText, regionType); >+ } >+ >+ /** >+ * @param partitionType >+ * @return <code>true</code> if this action can operate on this type of >+ * partition, otherwise <code>false</code>. >+ */ >+ public boolean enabledForParitition(String partitionType) { >+ String[] accept = getPartitionTypes(); >+ for (int i = 0; i < accept.length; i++) { >+ if (partitionType.equals(accept[i])) >+ return true; >+ } >+ return false; >+ } >+} >Index: src/org/eclipse/wst/sse/ui/internal/selection/StructuredSelectActionDelegate.java >=================================================================== >RCS file: src/org/eclipse/wst/sse/ui/internal/selection/StructuredSelectActionDelegate.java >diff -N src/org/eclipse/wst/sse/ui/internal/selection/StructuredSelectActionDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/sse/ui/internal/selection/StructuredSelectActionDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,124 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * >+ *******************************************************************************/ >+ >+package org.eclipse.wst.sse.ui.internal.selection; >+ >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.ITextSelection; >+import org.eclipse.jface.text.Region; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.ui.IActionDelegate2; >+import org.eclipse.ui.IEditorActionDelegate; >+import org.eclipse.ui.IEditorPart; >+import org.eclipse.ui.IViewActionDelegate; >+import org.eclipse.ui.IViewPart; >+import org.eclipse.ui.texteditor.ITextEditor; >+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; >+ >+abstract public class StructuredSelectActionDelegate implements IEditorActionDelegate, IActionDelegate2, IViewActionDelegate { >+ private IEditorPart fEditor; >+ private SelectionHistory fHistory; >+ >+ public void dispose() { >+ fEditor = null; >+ fHistory = null; >+ } >+ >+ public void init(IViewPart view) { >+ // do nothing >+ } >+ >+ public void runWithEvent(IAction action, Event event) { >+ run(action); >+ } >+ >+ public void run(IAction action) { >+ if (fEditor instanceof ITextEditor) { >+ ITextEditor textEditor = (ITextEditor) fEditor; >+ >+ ISelection selection = textEditor.getSelectionProvider().getSelection(); >+ IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput()); >+ // determine current text selection >+ if (selection instanceof ITextSelection && document != null) { >+ ITextSelection textSelection = (ITextSelection) selection; >+ >+ if (textSelection.getLength() < document.getLength()) { >+ // get current indexed region >+ IndexedRegion cursorIndexedRegion = getCursorIndexedRegion(document, textSelection); >+ >+ // determine new selection based on current indexed region >+ Region newSelectionRegion = getNewSelectionRegion(cursorIndexedRegion, textSelection); >+ >+ // select new selection >+ if (newSelectionRegion != null) { >+ fHistory.remember(new Region(textSelection.getOffset(), textSelection.getLength())); >+ try { >+ fHistory.ignoreSelectionChanges(); >+ textEditor.selectAndReveal(newSelectionRegion.getOffset(), newSelectionRegion.getLength()); >+ } >+ finally { >+ fHistory.listenToSelectionChanges(); >+ } >+ } >+ } >+ } >+ } >+ } >+ >+ public void selectionChanged(IAction action, ISelection selection) { >+ // do nothing >+ } >+ >+ public void setActiveEditor(IAction action, IEditorPart targetEditor) { >+ fEditor = targetEditor; >+ if (fEditor != null) >+ fHistory = (SelectionHistory) fEditor.getAdapter(SelectionHistory.class); >+ else >+ fHistory = null; >+ } >+ >+ abstract protected IndexedRegion getCursorIndexedRegion(IDocument document, ITextSelection textSelection); >+ >+ abstract protected Region getNewSelectionRegion(IndexedRegion indexedRegion, ITextSelection textSelection); >+ >+ /** >+ * This method will probably be removed and replaced by using new selection provider >+ * @param document >+ * @param offset >+ * @return >+ */ >+ protected IndexedRegion getIndexedRegion(IDocument document, int offset) { >+ IndexedRegion indexedRegion = null; >+ >+ int lastOffset = offset; >+ 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; >+ } >+ >+} >Index: src/org/eclipse/wst/sse/ui/internal/selection/StructuredSelectHistoryActionDelegate.java >=================================================================== >RCS file: src/org/eclipse/wst/sse/ui/internal/selection/StructuredSelectHistoryActionDelegate.java >diff -N src/org/eclipse/wst/sse/ui/internal/selection/StructuredSelectHistoryActionDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/sse/ui/internal/selection/StructuredSelectHistoryActionDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,83 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * >+ *******************************************************************************/ >+ >+package org.eclipse.wst.sse.ui.internal.selection; >+ >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.text.IRegion; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.ui.IActionDelegate2; >+import org.eclipse.ui.IEditorActionDelegate; >+import org.eclipse.ui.IEditorPart; >+import org.eclipse.ui.IViewActionDelegate; >+import org.eclipse.ui.IViewPart; >+import org.eclipse.ui.texteditor.ITextEditor; >+import org.eclipse.wst.sse.ui.internal.SSEUIMessages; >+ >+/** >+ * Selection history action delegate. Keeps track of selection within editor. >+ */ >+public class StructuredSelectHistoryActionDelegate implements IEditorActionDelegate, IActionDelegate2, IViewActionDelegate { >+ private IEditorPart fEditor; >+ private SelectionHistory fHistory; >+ >+ public void dispose() { >+ fEditor = null; >+ fHistory = null; >+ } >+ >+ public void init(IAction action) { >+ if (action != null) { >+ action.setText(SSEUIMessages.StructureSelectHistory_label); >+ action.setToolTipText(SSEUIMessages.StructureSelectHistory_tooltip); >+ action.setDescription(SSEUIMessages.StructureSelectHistory_description); >+ } >+ } >+ >+ public void init(IViewPart view) { >+ // do nothing >+ } >+ >+ public void run(IAction action) { >+ IRegion old = fHistory.getLast(); >+ if (old != null) { >+ try { >+ fHistory.ignoreSelectionChanges(); >+ if (fEditor instanceof ITextEditor) >+ ((ITextEditor) fEditor).selectAndReveal(old.getOffset(), old.getLength()); >+ } >+ finally { >+ fHistory.listenToSelectionChanges(); >+ } >+ } >+ } >+ >+ public void runWithEvent(IAction action, Event event) { >+ run(action); >+ } >+ >+ public void selectionChanged(IAction action, ISelection selection) { >+ // do nothing >+ } >+ >+ public void setActiveEditor(IAction action, IEditorPart targetEditor) { >+ fEditor = targetEditor; >+ if (fEditor != null) >+ fHistory = (SelectionHistory) fEditor.getAdapter(SelectionHistory.class); >+ else >+ fHistory = null; >+ if (fHistory != null) { >+ fHistory.setHistoryAction(action); >+ } >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 109468
:
27089
|
27090
|
27091
| 27092 |
27093
|
27094
|
27095
|
27128