Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDani Megert2002-09-19 13:10:20 +0000
committerDani Megert2002-09-19 13:10:20 +0000
commit7ca7e02babfa60a80bc0417c087603e94451b9b0 (patch)
tree5509d328a80f67d89cc586fd873b5ace87358138
parent8ecaca78d84f179e01213c1e345dc300f1b8b246 (diff)
downloadeclipse.platform.text-7ca7e02babfa60a80bc0417c087603e94451b9b0.tar.gz
eclipse.platform.text-7ca7e02babfa60a80bc0417c087603e94451b9b0.tar.xz
eclipse.platform.text-7ca7e02babfa60a80bc0417c087603e94451b9b0.zip
Fixed 23595: NPE searching in Hierarchy Perspective
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultView.java5
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewer.java16
2 files changed, 12 insertions, 9 deletions
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultView.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultView.java
index 6f4edadb7..5a2fe4d2d 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultView.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultView.java
@@ -82,10 +82,7 @@ public class SearchResultView extends ViewPart implements ISearchResultView {
fViewer.restoreState(fMemento);
fMemento= null;
SearchManager.getDefault().addSearchChangeListener(fViewer);
- Search search= SearchManager.getDefault().getCurrentSearch();
- if (search != null)
- fViewer.setPageId(search.getPageId());
- fViewer.setInput(SearchManager.getDefault().getCurrentResults());
+ fViewer.init();
fillToolBar(getViewSite().getActionBars().getToolBarManager());
// Add selectAll action handlers.
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewer.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewer.java
index 103bffe73..a2584dd98 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewer.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewer.java
@@ -163,15 +163,19 @@ public class SearchResultViewer extends TableViewer {
}
fOuterPart.getSite().setSelectionProvider(this);
-
+ }
+
+ void init() {
Search search= SearchManager.getDefault().getCurrentSearch();
- if (search != null) {
+ if (search != null) {
setGotoMarkerAction(search.getGotoMarkerAction());
setContextMenuTarget(search.getContextMenuContributor());
setActionGroupFactory(null);
+ // preserving selection since next call destroys it
+ ISelection selection= search.getSelection();
setInput(search.getResults());
setActionGroupFactory(search.getActionGroupFactory());
- setSelection(search.getSelection(), true);
+ setSelection(selection, true);
setPageId(search.getPageId());
}
}
@@ -188,10 +192,12 @@ public class SearchResultViewer extends TableViewer {
}
private void handleSelectionChanged() {
-
int selectionCount= getSelectedEntriesCount();
boolean hasSingleSelection= selectionCount == 1;
boolean hasElements= getItemCount() > 0;
+ Search search= SearchManager.getDefault().getCurrentSearch();
+ if (search != null)
+ search.setSelection(fLastSelection);
fShowNextResultAction.setEnabled(hasSingleSelection || (hasElements && selectionCount == 0));
fShowPreviousResultAction.setEnabled(hasSingleSelection || (hasElements && selectionCount == 0));
fGotoMarkerActionProxy.setEnabled(hasSingleSelection);
@@ -356,10 +362,10 @@ public class SearchResultViewer extends TableViewer {
}
void setPageId(String pageId) {
- fSortDropDownAction.setPageId(pageId);
ILabelProvider labelProvider= fOuterPart.getLabelProvider(pageId);
if (labelProvider != null)
internalSetLabelProvider(labelProvider);
+ fSortDropDownAction.setPageId(pageId);
}
void fillToolBar(IToolBarManager tbm) {

Back to the top