Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2021-10-04 20:21:29 +0000
committerAlexander Kurtakov2021-10-05 15:08:02 +0000
commitc08b0fe8204636808e25ea5b88e6a9ce218d619d (patch)
tree561c60f046109702612b6811a5dc309298dbdde9
parent1f0525b1d0d0eebcb74b38c4d93e4c0d903ddb57 (diff)
downloadeclipse.platform.text-I20211005-1800.tar.gz
eclipse.platform.text-I20211005-1800.tar.xz
eclipse.platform.text-I20211005-1800.zip
Get rid of internal classes part of "old" search. Change-Id: Ie29c65d7da6667aec9d57e29ea9b246040e6a3dd Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.text/+/186121 Tested-by: Platform Bot <platform-bot@eclipse.org> Reviewed-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--org.eclipse.search/.settings/.api_filters8
-rw-r--r--org.eclipse.search/plugin.xml8
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/GotoMarkerAction.java37
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveAllResultsAction.java34
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveAllSearchesAction.java34
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveMatchAction.java68
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/RemovePotentialMatchesAction.java125
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveResultAction.java101
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/ResourceToItemsMapper.java175
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/Search.java214
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchAgainAction.java35
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDropDownAction.java103
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchManager.java501
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPlugin.java36
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultLabelProvider.java85
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultView.java341
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntry.java211
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntryAdapterFactory.java65
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewer.java717
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/ShowNextResultAction.java40
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/ShowPreviousResultAction.java40
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/ShowSearchAction.java45
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/ShowSearchesAction.java144
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SortDropDownAction.java226
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileLabelProvider.java145
25 files changed, 0 insertions, 3538 deletions
diff --git a/org.eclipse.search/.settings/.api_filters b/org.eclipse.search/.settings/.api_filters
index 89f4b440387..7b25d242e3e 100644
--- a/org.eclipse.search/.settings/.api_filters
+++ b/org.eclipse.search/.settings/.api_filters
@@ -16,12 +16,4 @@
</message_arguments>
</filter>
</resource>
- <resource path="search/org/eclipse/search/internal/ui/SearchResultViewer.java" type="org.eclipse.search.internal.ui.SearchResultViewer">
- <filter id="571473929">
- <message_arguments>
- <message_argument value="TableViewer"/>
- <message_argument value="SearchResultViewer"/>
- </message_arguments>
- </filter>
- </resource>
</component>
diff --git a/org.eclipse.search/plugin.xml b/org.eclipse.search/plugin.xml
index 786ede2306c..14a01213ba5 100644
--- a/org.eclipse.search/plugin.xml
+++ b/org.eclipse.search/plugin.xml
@@ -375,14 +375,6 @@
</specification>
</extension>
- <extension point="org.eclipse.core.runtime.adapters">
- <factory
- class="org.eclipse.search.internal.ui.SearchResultViewEntryAdapterFactory"
- adaptableType="org.eclipse.search.ui.ISearchResultViewEntry">
- <adapter type="org.eclipse.core.resources.IResource"/>
- <adapter type="org.eclipse.core.resources.IMarker"/>
- </factory>
- </extension>
<extension
point="org.eclipse.core.runtime.preferences">
<initializer class="org.eclipse.search.internal.ui.SearchPreferenceInitializer"/>
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/GotoMarkerAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/GotoMarkerAction.java
deleted file mode 100644
index 813d561a5a3..00000000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/GotoMarkerAction.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import org.eclipse.jface.action.Action;
-
-/**
- * @deprecated old search
- */
-@Deprecated
-class GotoMarkerAction extends Action {
-
- private SearchResultViewer fViewer;
-
- public GotoMarkerAction(SearchResultViewer viewer) {
- super(SearchMessages.SearchResultView_gotoMarker_text);
- SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_GOTO);
- setToolTipText(SearchMessages.SearchResultView_gotoMarker_tooltip);
- fViewer= viewer;
- }
-
- @Override
- public void run() {
- fViewer.showResult();
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveAllResultsAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveAllResultsAction.java
deleted file mode 100644
index c8144f7dc63..00000000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveAllResultsAction.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import org.eclipse.jface.action.Action;
-
-/**
- * @deprecated old search
- */
-@Deprecated
-class RemoveAllResultsAction extends Action {
-
- public RemoveAllResultsAction() {
- super(SearchMessages.SearchResultView_removeAllResults_text);
- SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_REM_ALL);
- setToolTipText(SearchMessages.SearchResultView_removeAllResults_tooltip);
- }
-
- @Override
- public void run() {
- SearchManager.getDefault().removeAllResults();
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveAllSearchesAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveAllSearchesAction.java
deleted file mode 100644
index f25f1e7cebe..00000000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveAllSearchesAction.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import org.eclipse.jface.action.Action;
-
-/**
- * @deprecated old search
- */
-@Deprecated
-class RemoveAllSearchesAction extends Action {
-
- public RemoveAllSearchesAction() {
- super(SearchMessages.SearchResultView_removeAllSearches_text);
- SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_REM_ALL);
- setToolTipText(SearchMessages.SearchResultView_removeAllSearches_tooltip);
- }
-
- @Override
- public void run() {
- SearchManager.getDefault().removeAllSearches();
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveMatchAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveMatchAction.java
deleted file mode 100644
index e9ffee5512a..00000000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveMatchAction.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.core.resources.IMarker;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-
-import org.eclipse.search.internal.ui.util.ExceptionHandler;
-import org.eclipse.search.ui.ISearchResultViewEntry;
-
-/**
- * @deprecated old search
- */
-@Deprecated
-class RemoveMatchAction extends Action {
-
- private ISelectionProvider fSelectionProvider;
-
- public RemoveMatchAction(ISelectionProvider provider) {
- super(SearchMessages.SearchResultView_removeMatch_text);
- setToolTipText(SearchMessages.SearchResultView_removeMatch_tooltip);
- fSelectionProvider= provider;
- }
-
- @Override
- public void run() {
- IMarker[] markers= getMarkers(fSelectionProvider.getSelection());
- if (markers != null)
- try {
- SearchPlugin.getWorkspace().deleteMarkers(markers);
- } catch (CoreException ex) {
- ExceptionHandler.handle(ex, SearchMessages.Search_Error_deleteMarkers_title, SearchMessages.Search_Error_deleteMarkers_message);
- }
- }
-
- private IMarker[] getMarkers(ISelection s) {
- if (! (s instanceof IStructuredSelection) || s.isEmpty())
- return null;
-
- IStructuredSelection selection= (IStructuredSelection)s;
- int size= selection.size();
- if (size != 1)
- return null;
- if (selection.getFirstElement() instanceof ISearchResultViewEntry) {
- IMarker marker= ((ISearchResultViewEntry)selection.getFirstElement()).getSelectedMarker();
- if (marker != null)
- return new IMarker[] {marker};
- }
- return null;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/RemovePotentialMatchesAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/RemovePotentialMatchesAction.java
deleted file mode 100644
index 2089ea7d1fc..00000000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/RemovePotentialMatchesAction.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.core.resources.IMarker;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-
-import org.eclipse.ui.IWorkbenchSite;
-
-import org.eclipse.search.internal.ui.util.ExceptionHandler;
-import org.eclipse.search.ui.SearchUI;
-
-/**
- * @deprecated old search
- */
-@Deprecated
-class RemovePotentialMatchesAction extends Action {
-
- private IWorkbenchSite fSite;
-
- public RemovePotentialMatchesAction(IWorkbenchSite site) {
- fSite= site;
-
- if (usePluralLabel()) {
- setText(SearchMessages.RemovePotentialMatchesAction_removePotentialMatches_text);
- setToolTipText(SearchMessages.RemovePotentialMatchesAction_removePotentialMatches_tooltip);
- }
- else {
- setText(SearchMessages.RemovePotentialMatchesAction_removePotentialMatch_text);
- setToolTipText(SearchMessages.RemovePotentialMatchesAction_removePotentialMatch_tooltip);
- }
- }
-
- @Override
- public void run() {
- IMarker[] markers= getMarkers();
- if (markers != null)
- try {
- SearchPlugin.getWorkspace().deleteMarkers(markers);
- } catch (CoreException ex) {
- ExceptionHandler.handle(ex, SearchMessages.Search_Error_deleteMarkers_title, SearchMessages.Search_Error_deleteMarkers_message);
- }
- else {
- String title= SearchMessages.RemovePotentialMatchesAction_dialog_title;
- String message= SearchMessages.RemovePotentialMatchesAction_dialog_message;
- MessageDialog.openInformation(fSite.getShell(), title, message);
- }
-
- // action only makes sense once
- setEnabled(false);
- }
-
- private IMarker[] getMarkers() {
-
- ISelection s= fSite.getSelectionProvider().getSelection();
- if (! (s instanceof IStructuredSelection))
- return null;
- IStructuredSelection selection= (IStructuredSelection)s;
-
- int size= selection.size();
- if (size <= 0)
- return null;
-
- ArrayList<IMarker> markers= new ArrayList<>(size * 3);
- Iterator<?> iter= selection.iterator();
- while (iter.hasNext()) {
- SearchResultViewEntry entry= (SearchResultViewEntry)iter.next();
- Iterator<IMarker> entryIter= entry.getMarkers().iterator();
- while (entryIter.hasNext()) {
- IMarker marker= entryIter.next();
- if (marker.getAttribute(SearchUI.POTENTIAL_MATCH, false))
- markers.add(marker);
- }
- }
- return markers.toArray(new IMarker[markers.size()]);
- }
-
- private boolean usePluralLabel() {
- ISelection s= fSite.getSelectionProvider().getSelection();
-
- if (! (s instanceof IStructuredSelection) || s.isEmpty())
- return false;
-
- IStructuredSelection selection= (IStructuredSelection)s;
- int size= selection.size();
- if (size <= 0)
- return false;
-
- int markerCount= 0;
- Iterator<?> iter= selection.iterator();
- while (iter.hasNext()) {
- SearchResultViewEntry entry= (SearchResultViewEntry)iter.next();
- Iterator<IMarker> entryIter= entry.getMarkers().iterator();
- while (entryIter.hasNext()) {
- IMarker marker= entryIter.next();
- if (marker.getAttribute(SearchUI.POTENTIAL_MATCH, false)) {
- markerCount++;
- }
- if (markerCount > 1)
- return true;
- }
- }
- return false;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveResultAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveResultAction.java
deleted file mode 100644
index 6677d5d7856..00000000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/RemoveResultAction.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.swt.custom.BusyIndicator;
-
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.core.resources.IMarker;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-
-import org.eclipse.search.internal.ui.util.ExceptionHandler;
-import org.eclipse.search.ui.ISearchResultViewEntry;
-
-/**
- * @deprecated old search
- */
-@Deprecated
-class RemoveResultAction extends Action {
-
- private ISelectionProvider fSelectionProvider;
-
- public RemoveResultAction(ISelectionProvider provider, boolean stringsDependOnMatchCount) {
- fSelectionProvider= provider;
- if (!stringsDependOnMatchCount || usePluralLabel()) {
- setText(SearchMessages.SearchResultView_removeEntries_text);
- setToolTipText(SearchMessages.SearchResultView_removeEntries_tooltip);
- }
- else {
- setText(SearchMessages.SearchResultView_removeEntry_text);
- setToolTipText(SearchMessages.SearchResultView_removeEntry_tooltip);
- }
- SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_REM);
- }
-
- @Override
- public void run() {
- final IMarker[] markers= getMarkers(fSelectionProvider.getSelection());
- if (markers != null) {
- BusyIndicator.showWhile(SearchPlugin.getActiveWorkbenchShell().getDisplay(), () -> {
- try {
- SearchPlugin.getWorkspace().deleteMarkers(markers);
- } catch (CoreException ex) {
- ExceptionHandler.handle(ex, SearchMessages.Search_Error_deleteMarkers_title, SearchMessages.Search_Error_deleteMarkers_message);
- }
- });
- }
- }
-
- private IMarker[] getMarkers(ISelection s) {
- if (! (s instanceof IStructuredSelection) || s.isEmpty())
- return null;
-
- IStructuredSelection selection= (IStructuredSelection)s;
- int size= selection.size();
- if (size <= 0)
- return null;
- ArrayList<IMarker> markers= new ArrayList<>(size * 3);
- int markerCount= 0;
- Iterator<?> iter= selection.iterator();
- while (iter.hasNext()) {
- SearchResultViewEntry entry= (SearchResultViewEntry)iter.next();
- markerCount += entry.getMatchCount();
- markers.addAll(entry.getMarkers());
- }
- return markers.toArray(new IMarker[markerCount]);
- }
-
- private boolean usePluralLabel() {
- ISelection s= fSelectionProvider.getSelection();
- if (s == null || s.isEmpty() || !(s instanceof IStructuredSelection))
- return false;
- IStructuredSelection selection= (IStructuredSelection)s;
-
- if (selection.size() != 1)
- return true;
-
- Object firstElement= selection.getFirstElement();
- if (firstElement instanceof ISearchResultViewEntry)
- return ((ISearchResultViewEntry)firstElement).getMatchCount() > 1;
- return false;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/ResourceToItemsMapper.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/ResourceToItemsMapper.java
deleted file mode 100644
index 3c5605bca54..00000000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/ResourceToItemsMapper.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Stack;
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Item;
-
-import org.eclipse.core.resources.IResource;
-
-import org.eclipse.jface.viewers.ContentViewer;
-import org.eclipse.jface.viewers.ILabelProvider;
-
-import org.eclipse.search.ui.ISearchResultViewEntry;
-
-/**
- * Helper class for updating error markers and other decorators that work on resources.
- * Items are mapped to their element's underlying resource.
- * Method <code>resourceChanged</code> updates all items that are affected from the changed
- * elements.
- * @deprecated old search
- */
-@Deprecated
-class ResourceToItemsMapper {
-
- private static final int NUMBER_LIST_REUSE= 10;
-
- /** map from IResource to {@code Item | List<Item>} **/
- private HashMap<IResource, Object> fResourceToItem;
- private Stack<List<Item>> fReuseLists;
-
- private ContentViewer fContentViewer;
-
- public ResourceToItemsMapper(ContentViewer viewer) {
- fResourceToItem= new HashMap<>();
- fReuseLists= new Stack<>();
-
- fContentViewer= viewer;
- }
-
- /**
- * Must be called from the UI thread.
- * @param changedResource changed resources
- */
- @SuppressWarnings("unchecked")
- public void resourceChanged(IResource changedResource) {
- Object obj= fResourceToItem.get(changedResource);
- if (obj == null) {
- // not mapped
- } else if (obj instanceof Item) {
- updateItem((Item) obj);
- } else { // List of Items
- for (Item element : (List<Item>) obj) {
- updateItem(element);
- }
- }
- }
-
- private void updateItem(Item item) {
- if (!item.isDisposed()) { // defensive code
- ILabelProvider lprovider= (ILabelProvider) fContentViewer.getLabelProvider();
-
- Object data= item.getData();
-
- String oldText= item.getText();
- String text= lprovider.getText(data);
- if (text != null && !text.equals(oldText)) {
- item.setText(text);
- }
-
- Image oldImage= item.getImage();
- Image image= lprovider.getImage(data);
- if (image != null && !image.equals(oldImage)) {
- item.setImage(image);
- }
- }
- }
-
- /**
- * Adds a new item to the map.
- * @param element Element to map
- * @param item The item used for the element
- */
- public void addToMap(Object element, Item item) {
- IResource resource= ((ISearchResultViewEntry)element).getResource();
- if (resource != null) {
- Object existingMapping= fResourceToItem.get(resource);
- if (existingMapping == null) {
- fResourceToItem.put(resource, item);
- } else if (existingMapping instanceof Item) {
- if (existingMapping != item) {
- List<Item> list= getNewList();
- list.add((Item) existingMapping);
- list.add(item);
- fResourceToItem.put(resource, list);
- }
- } else { // List
- @SuppressWarnings("unchecked")
- List<Item> list= (List<Item>) existingMapping;
- if (!list.contains(item)) {
- list.add(item);
- }
- }
- }
- }
-
- /**
- * Removes an element from the map.
- * @param element element to remove
- * @param item The item used for the element
- */
- @SuppressWarnings("unlikely-arg-type")
- public void removeFromMap(Object element, Item item) {
- IResource resource= ((ISearchResultViewEntry)element).getResource();
- if (resource != null) {
- Object existingMapping= fResourceToItem.get(resource);
- if (existingMapping == null) {
- return;
- } else if (existingMapping instanceof Item) {
- fResourceToItem.remove(resource);
- } else { // List
- @SuppressWarnings("unchecked")
- List<Item> list= (List<Item>) existingMapping;
- list.remove(item);
- if (list.isEmpty()) {
- fResourceToItem.remove(list);
- releaseList(list);
- }
- }
- }
- }
-
- private List<Item> getNewList() {
- if (!fReuseLists.isEmpty()) {
- return fReuseLists.pop();
- }
- return new ArrayList<>(2);
- }
-
- private void releaseList(List<Item> list) {
- if (fReuseLists.size() < NUMBER_LIST_REUSE) {
- fReuseLists.push(list);
- }
- }
-
- /**
- * Clears the map.
- */
- public void clearMap() {
- fResourceToItem.clear();
- }
-
- /**
- * Tests if the map is empty
- * @return returns if the map is empty
- */
- public boolean isEmpty() {
- return fResourceToItem.isEmpty();
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/Search.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/Search.java
deleted file mode 100644
index 434a0fcb2e7..00000000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/Search.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.core.runtime.Assert;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-
-import org.eclipse.search.internal.ui.util.ExceptionHandler;
-import org.eclipse.search.ui.IActionGroupFactory;
-import org.eclipse.search.ui.IContextMenuContributor;
-import org.eclipse.search.ui.IGroupByKeyComputer;
-import org.eclipse.search.ui.ISearchResultViewEntry;
-/**
- * @deprecated old search
- */
-@Deprecated
-public class Search extends Object {
- private String fPageId;
- private String fSingularLabel;
- private String fPluralLabelPattern;
- private ImageDescriptor fImageDescriptor;
- private ILabelProvider fLabelProvider;
- private ISelection fSelection;
- private ArrayList<SearchResultViewEntry> fResults;
- private IAction fGotoMarkerAction;
- private IContextMenuContributor fContextMenuContributor;
- private IActionGroupFactory fActionGroupFactory;
- private IGroupByKeyComputer fGroupByKeyComputer;
- private IRunnableWithProgress fOperation;
-
-
- public Search(String pageId, String singularLabel, String pluralLabelPattern, ILabelProvider labelProvider, ImageDescriptor imageDescriptor, IAction gotoMarkerAction, IActionGroupFactory groupFactory, IGroupByKeyComputer groupByKeyComputer, IRunnableWithProgress operation) {
- fPageId= pageId;
- fSingularLabel= singularLabel;
- fPluralLabelPattern= pluralLabelPattern;
- fImageDescriptor= imageDescriptor;
- fLabelProvider= labelProvider;
- fGotoMarkerAction= gotoMarkerAction;
- fActionGroupFactory= groupFactory;
- fGroupByKeyComputer= groupByKeyComputer;
- fOperation= operation;
-
- if (fPluralLabelPattern == null)
- fPluralLabelPattern= ""; //$NON-NLS-1$
- }
-
- public Search(String pageId, String singularLabel, String pluralLabelPattern, ILabelProvider labelProvider, ImageDescriptor imageDescriptor, IAction gotoMarkerAction, IContextMenuContributor contextMenuContributor, IGroupByKeyComputer groupByKeyComputer, IRunnableWithProgress operation) {
- fPageId= pageId;
- fSingularLabel= singularLabel;
- fPluralLabelPattern= pluralLabelPattern;
- fImageDescriptor= imageDescriptor;
- fLabelProvider= labelProvider;
- fGotoMarkerAction= gotoMarkerAction;
- fContextMenuContributor= contextMenuContributor;
- fGroupByKeyComputer= groupByKeyComputer;
- fOperation= operation;
-
- if (fPluralLabelPattern == null)
- fPluralLabelPattern= ""; //$NON-NLS-1$
- }
-
- /**
- * Returns the full description of the search.
- * The description set by the client where
- * {0} will be replaced by the match count.
- * @return the full description
- */
- String getFullDescription() {
- if (fSingularLabel != null && getItemCount() == 1)
- return fSingularLabel;
-
- // try to replace "{0}" with the match count
- int i= fPluralLabelPattern.lastIndexOf("{0}"); //$NON-NLS-1$
- if (i < 0)
- return fPluralLabelPattern;
- return fPluralLabelPattern.substring(0, i) + getItemCount()+ fPluralLabelPattern.substring(Math.min(i + 3, fPluralLabelPattern.length()));
- }
-
- /**
- * Returns a short description of the search.
- * Cuts off after 30 characters and adds ...
- * The description set by the client where
- * {0} will be replaced by the match count.
- * @return the short description
- */
- String getShortDescription() {
- String text= getFullDescription();
- int separatorPos= text.indexOf(" - "); //$NON-NLS-1$
- if (separatorPos < 1)
- return text.substring(0, Math.min(50, text.length())) + "..."; // use first 50 characters //$NON-NLS-1$
- if (separatorPos < 30)
- return text; // don't cut
- if (text.charAt(0) == '"')
- return text.substring(0, Math.min(30, text.length())) + "...\" - " + text.substring(Math.min(separatorPos + 3, text.length())); //$NON-NLS-1$
- return text.substring(0, Math.min(30, text.length())) + "... - " + text.substring(Math.min(separatorPos + 3, text.length())); //$NON-NLS-1$
- }
- /**
- * Image used when search is displayed in a list
- * @return the image descriptor
- */
- ImageDescriptor getImageDescriptor() {
- return fImageDescriptor;
- }
-
- int getItemCount() {
- int count= 0;
- Iterator<SearchResultViewEntry> iter= getResults().iterator();
- while (iter.hasNext())
- count += ((ISearchResultViewEntry)iter.next()).getMatchCount();
- return count;
- }
-
- List<SearchResultViewEntry> getResults() {
- if (fResults == null)
- return new ArrayList<>();
- return fResults;
- }
-
- ILabelProvider getLabelProvider() {
- return fLabelProvider;
- }
-
- void searchAgain() {
- if (fOperation == null)
- return;
- Shell shell= SearchPlugin.getActiveWorkbenchShell();
- boolean isAutoBuilding= SearchPlugin.setAutoBuilding(false);
- try {
- new ProgressMonitorDialog(shell).run(true, true, fOperation);
- } catch (InvocationTargetException ex) {
- ExceptionHandler.handle(ex, shell, SearchMessages.Search_Error_search_title, SearchMessages.Search_Error_search_message);
- } catch(InterruptedException e) {
- } finally {
- SearchPlugin.setAutoBuilding(isAutoBuilding);
- }
- }
-
- boolean isSameSearch(Search search) {
- return search != null && search.getOperation() == fOperation && fOperation != null;
- }
-
- void backupMarkers() {
- Iterator<SearchResultViewEntry> iter= getResults().iterator();
- while (iter.hasNext()) {
- iter.next().backupMarkers();
- }
- }
-
- String getPageId() {
- return fPageId;
- }
-
- IGroupByKeyComputer getGroupByKeyComputer() {
- return fGroupByKeyComputer;
- }
-
- public IRunnableWithProgress getOperation() {
- return fOperation;
- }
-
- IAction getGotoMarkerAction() {
- return fGotoMarkerAction;
- }
-
- IContextMenuContributor getContextMenuContributor() {
- return fContextMenuContributor;
- }
-
- IActionGroupFactory getActionGroupFactory() {
- return fActionGroupFactory;
- }
-
- public void removeResults() {
- fResults= null;
- }
-
- void setResults(ArrayList<SearchResultViewEntry> results) {
- Assert.isNotNull(results);
- fResults= results;
- }
-
- ISelection getSelection() {
- return fSelection;
- }
-
- void setSelection(ISelection selection) {
- fSelection= selection;
- }
-}
-
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchAgainAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchAgainAction.java
deleted file mode 100644
index 5264218aebc..00000000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchAgainAction.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import org.eclipse.jface.action.Action;
-
-/**
- * @deprecated old search
- */
-@Deprecated
-class SearchAgainAction extends Action {
-
- public SearchAgainAction() {
- super(SearchMessages.SearchResultView_searchAgain_text);
- setToolTipText(SearchMessages.SearchResultView_searchAgain_tooltip);
- }
-
- @Override
- public void run() {
- Search selected= SearchManager.getDefault().getCurrentSearch();
- if (selected != null)
- selected.searchAgain();
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDropDownAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDropDownAction.java
deleted file mode 100644
index 64016879185..00000000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDropDownAction.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.util.Iterator;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IMenuCreator;
-
-/**
- * @deprecated old search
- */
-@Deprecated
-class SearchDropDownAction extends Action implements IMenuCreator {
-
-
- public static final int RESULTS_IN_DROP_DOWN= 10;
-
- private Menu fMenu;
-
- public SearchDropDownAction() {
- setText(SearchMessages.SearchResultView_previousSearches_text);
- setToolTipText(SearchMessages.SearchResultView_previousSearches_tooltip);
- SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_HISTORY);
- setMenuCreator(this);
- }
-
- @Override
- public void dispose() {
- if (fMenu != null) {
- fMenu.dispose();
- fMenu= null;
- }
- }
-
- @Override
- public Menu getMenu(Menu parent) {
- return null;
- }
-
- @Override
- public Menu getMenu(Control parent) {
- if (fMenu != null)
- fMenu.dispose();
-
- fMenu= new Menu(parent);
- boolean checkedOne= false;
- Iterator<Search> iter= SearchManager.getDefault().getPreviousSearches().iterator();
- Search selected= SearchManager.getDefault().getCurrentSearch();
- int i= 0;
- while (iter.hasNext() && i++ < RESULTS_IN_DROP_DOWN) {
- Search search= iter.next();
- ShowSearchAction action= new ShowSearchAction(search);
- action.setChecked(search.equals(selected));
- if (search.equals(selected))
- checkedOne= true;
- addActionToMenu(fMenu, action);
- }
- new MenuItem(fMenu, SWT.SEPARATOR);
- if (iter.hasNext()) {
- Action others= new ShowSearchesAction();
- others.setChecked(!checkedOne);
- addActionToMenu(fMenu, others);
- }
- addActionToMenu(fMenu, new RemoveAllSearchesAction());
- return fMenu;
- }
-
- protected void addActionToMenu(Menu parent, Action action) {
- ActionContributionItem item= new ActionContributionItem(action);
- item.fill(parent, -1);
- }
-
- @Override
- public void run() {
- new ShowSearchesAction().run(true);
- }
-
- /**
- * Get's rid of the menu, because the menu hangs on to
- * the searches, etc.
- */
- void clear() {
- dispose();
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchManager.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchManager.java
deleted file mode 100644
index e5744ce04d8..00000000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchManager.java
+++ /dev/null
@@ -1,501 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Map;
-
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IMarkerDelta;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.viewers.Viewer;
-
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-
-import org.eclipse.search.internal.ui.util.ExceptionHandler;
-import org.eclipse.search.ui.IGroupByKeyComputer;
-import org.eclipse.search.ui.SearchUI;
-
-
-/**
- * Manage search results
- * @deprecated old search
- */
-@Deprecated
-public class SearchManager implements IResourceChangeListener {
-
- static SearchManager fgDefault;
-
- Search fCurrentSearch= null;
-
- private SearchManager() {
- SearchPlugin.getWorkspace().addResourceChangeListener(this);
- }
-
- private HashSet<SearchResultViewer> fListeners= new HashSet<>();
- private LinkedList<Search> fPreviousSearches= new LinkedList<>();
- private boolean fIsRemoveAll= false;
-
- public static synchronized SearchManager getDefault() {
- if (fgDefault == null)
- fgDefault= new SearchManager();
- return fgDefault;
- }
-
- public void dispose() {
- SearchPlugin.getWorkspace().removeResourceChangeListener(this);
- }
-
- /**
- * Returns the list with previous searches (ISearch).
- * @return previous searches
- */
- LinkedList<Search> getPreviousSearches() {
- return fPreviousSearches;
- }
- /**
- * Returns the list with current (last) results
- * @return the current results
- */
- ArrayList<SearchResultViewEntry> getCurrentResults() {
- if (fCurrentSearch == null)
- return new ArrayList<>(0);
- return (ArrayList<SearchResultViewEntry>)fCurrentSearch.getResults();
- }
-
- public Search getCurrentSearch() {
- return fCurrentSearch;
- }
-
- void removeAllSearches() {
- SearchPlugin.getWorkspace().removeResourceChangeListener(this);
- WorkspaceModifyOperation op= new WorkspaceModifyOperation(null) {
- @Override
- protected void execute(IProgressMonitor monitor) throws CoreException {
- monitor.beginTask(SearchMessages.SearchManager_updating, 100);
- SearchPlugin.getWorkspace().getRoot().deleteMarkers(SearchUI.SEARCH_MARKER, true, IResource.DEPTH_INFINITE);
- monitor.worked(100);
- monitor.done();
- }
- };
- boolean isAutoBuilding= SearchPlugin.setAutoBuilding(false);
- try {
- ProgressMonitorDialog dialog= new ProgressMonitorDialog(getShell());
- dialog.run(true, true, op);
- } catch (InvocationTargetException ex) {
- ExceptionHandler.handle(ex, SearchMessages.Search_Error_deleteMarkers_title, SearchMessages.Search_Error_deleteMarkers_message);
- } catch (InterruptedException e) {
- // Do nothing. Operation has been canceled.
- } finally {
- SearchPlugin.getWorkspace().addResourceChangeListener(this);
- SearchPlugin.setAutoBuilding(isAutoBuilding);
- }
-
- // clear searches
- fPreviousSearches= new LinkedList<>();
- fCurrentSearch= null;
-
- // update viewers
- Iterator<SearchResultViewer> iter= fListeners.iterator();
- while (iter.hasNext()) {
- SearchResultViewer viewer= iter.next();
- handleAllSearchesRemoved(viewer);
- }
- }
-
- private void handleAllSearchesRemoved(SearchResultViewer viewer) {
- viewer.handleAllSearchesRemoved();
- }
-
- void setCurrentSearch(final Search search) {
- if (fCurrentSearch == search)
- return;
-
- SearchPlugin.getWorkspace().removeResourceChangeListener(this);
- WorkspaceModifyOperation op= new WorkspaceModifyOperation(null) {
- @Override
- protected void execute(IProgressMonitor monitor) throws CoreException {
- internalSetCurrentSearch(search, monitor);
- }
- };
- boolean isAutoBuilding= SearchPlugin.setAutoBuilding(false);
- try {
- ProgressMonitorDialog dialog= new ProgressMonitorDialog(getShell());
- dialog.run(true, true, op);
- } catch (InvocationTargetException ex) {
- ExceptionHandler.handle(ex, SearchMessages.Search_Error_switchSearch_title, SearchMessages.Search_Error_switchSearch_message);
- } catch (InterruptedException e) {
- // Do nothing. Operation has been canceled.
- } finally {
- SearchPlugin.setAutoBuilding(isAutoBuilding);
- }
-
- getPreviousSearches().remove(search);
- getPreviousSearches().addFirst(search);
- }
-
- void internalSetCurrentSearch(final Search search, IProgressMonitor monitor) {
- if (fCurrentSearch != null)
- fCurrentSearch.backupMarkers();
-
- final Search previousSearch= fCurrentSearch;
- fCurrentSearch= search;
- monitor.beginTask(SearchMessages.SearchManager_updating, getCurrentResults().size() + 20);
-
- // remove current search markers
- try {
- SearchPlugin.getWorkspace().getRoot().deleteMarkers(SearchUI.SEARCH_MARKER, true, IResource.DEPTH_INFINITE);
- } catch (CoreException ex) {
- ExceptionHandler.handle(ex, SearchMessages.Search_Error_deleteMarkers_title, SearchMessages.Search_Error_deleteMarkers_message);
- }
- monitor.worked(10);
-
- // add search markers
- Iterator<SearchResultViewEntry> iter= getCurrentResults().iterator();
- ArrayList<SearchResultViewEntry> emptyEntries= new ArrayList<>(10);
- boolean filesChanged= false;
- boolean filesDeleted= false;
- IGroupByKeyComputer groupByKeyComputer= getCurrentSearch().getGroupByKeyComputer();
- while (iter.hasNext()) {
- monitor.worked(1);
- SearchResultViewEntry entry= iter.next();
- Iterator<Map<String, Object>> attrPerMarkerIter= entry.getAttributesPerMarker().iterator();
- entry.clearMarkerList();
- if (entry.getResource() == null || !entry.getResource().exists()) {
- emptyEntries.add(entry);
- filesDeleted= true;
- continue;
- }
- while (attrPerMarkerIter.hasNext()) {
- IMarker newMarker= null;
- try {
- newMarker= entry.getResource().createMarker(entry.getMarkerType());
- } catch (CoreException ex) {
- ExceptionHandler.handle(ex, SearchMessages.Search_Error_createMarker_title, SearchMessages.Search_Error_createMarker_message);
- continue;
- }
- try {
- newMarker.setAttributes(attrPerMarkerIter.next());
- if (groupByKeyComputer !=null && groupByKeyComputer.computeGroupByKey(newMarker) == null) {
- filesDeleted= true;
- newMarker.delete();
- continue;
- }
- } catch (CoreException ex) {
- ExceptionHandler.handle(ex, SearchMessages.Search_Error_markerAttributeAccess_title, SearchMessages.Search_Error_markerAttributeAccess_message);
- }
- entry.add(newMarker);
- }
- if (entry.getMatchCount() == 0)
- emptyEntries.add(entry);
- else if (!filesChanged && entry.getResource().getModificationStamp() != entry.getModificationStamp())
- filesChanged= true;
- }
- getCurrentResults().removeAll(emptyEntries);
- monitor.worked(10);
-
- String warningMessage= null;
- Display display= getDisplay();
-
- if (filesChanged)
- warningMessage= SearchMessages.SearchManager_resourceChanged;
- if (filesDeleted) {
- if (warningMessage == null)
- warningMessage= ""; //$NON-NLS-1$
- else
- warningMessage += "\n"; //$NON-NLS-1$
- warningMessage += SearchMessages.SearchManager_resourceDeleted;
- }
- if (warningMessage != null) {
- if (display != null && !display.isDisposed()) {
- final String warningTitle= SearchMessages.SearchManager_resourceChangedWarning;
- final String warningMsg= warningMessage;
- display.syncExec(() -> MessageDialog.openWarning(getShell(), warningTitle, warningMsg));
- }
- }
-
- // update viewers
- Iterator<SearchResultViewer> iter2= fListeners.iterator();
- if (display != null && !display.isDisposed()) {
- final Viewer visibleViewer= ((SearchResultView)SearchUI.getSearchResultView()).getViewer();
- while (iter2.hasNext()) {
- final SearchResultViewer viewer= iter2.next();
- display.syncExec(() -> {
- if (previousSearch != null && viewer == visibleViewer)
- previousSearch.setSelection(viewer.getSelection());
- viewer.setInput(null);
- viewer.setPageId(search.getPageId());
- viewer.setGotoMarkerAction(search.getGotoMarkerAction());
- viewer.setContextMenuTarget(search.getContextMenuContributor());
- viewer.setActionGroupFactory(null);
- viewer.setInput(getCurrentResults());
- viewer.setActionGroupFactory(search.getActionGroupFactory());
- viewer.setSelection(fCurrentSearch.getSelection(), true);
- });
- }
- }
- monitor.done();
- }
-
- /**
- * Returns the number of matches
- * @return the number of matches
- */
- int getCurrentItemCount() {
- if (fCurrentSearch != null)
- return fCurrentSearch.getItemCount();
- return 0;
- }
-
- void removeAllResults() {
- fIsRemoveAll= true;
- try {
- SearchPlugin.getWorkspace().getRoot().deleteMarkers(SearchUI.SEARCH_MARKER, true, IResource.DEPTH_INFINITE);
- } catch (CoreException ex) {
- ExceptionHandler.handle(ex, SearchMessages.Search_Error_deleteMarkers_title, SearchMessages.Search_Error_deleteMarkers_message);
- fIsRemoveAll= false;
- }
- }
-
- void addNewSearch(final Search newSearch) {
-
- SearchPlugin.getWorkspace().removeResourceChangeListener(this);
-
- // Clear the viewers
- Iterator<SearchResultViewer> iter= fListeners.iterator();
- Display display= getDisplay();
- if (display != null && !display.isDisposed()) {
- final Viewer visibleViewer= ((SearchResultView)SearchUI.getSearchResultView()).getViewer();
- while (iter.hasNext()) {
- final SearchResultViewer viewer= iter.next();
- display.syncExec(() -> {
- if (fCurrentSearch != null && viewer == visibleViewer)
- fCurrentSearch.setSelection(viewer.getSelection());
- setNewSearch(viewer, newSearch);
- });
- }
- }
-
- if (fCurrentSearch != null) {
- if (fCurrentSearch.isSameSearch(newSearch))
- getPreviousSearches().remove(fCurrentSearch);
- else
- fCurrentSearch.backupMarkers();
- }
- fCurrentSearch= newSearch;
- getPreviousSearches().addFirst(fCurrentSearch);
-
- // Remove the markers
- try {
- SearchPlugin.getWorkspace().getRoot().deleteMarkers(SearchUI.SEARCH_MARKER, true, IResource.DEPTH_INFINITE);
- } catch (CoreException ex) {
- ExceptionHandler.handle(ex, SearchMessages.Search_Error_deleteMarkers_title, SearchMessages.Search_Error_deleteMarkers_message);
- }
- }
-
- void searchFinished(ArrayList<SearchResultViewEntry> results) {
- Assert.isNotNull(results);
- getCurrentSearch().setResults(results);
-
- Display display= getDisplay();
- if (display == null || display.isDisposed())
- return;
-
- if (Thread.currentThread() == display.getThread())
- handleNewSearchResult();
- else {
- display.syncExec(this::handleNewSearchResult);
- }
- SearchPlugin.getWorkspace().addResourceChangeListener(this);
- }
-
- //--- Change event handling -------------------------------------------------
-
- void addSearchChangeListener(SearchResultViewer viewer) {
- fListeners.add(viewer);
- }
-
- void removeSearchChangeListener(SearchResultViewer viewer) {
- Assert.isNotNull(viewer);
- fListeners.remove(viewer);
- }
-
- private final void handleSearchMarkersChanged(IMarkerDelta[] markerDeltas) {
- if (fIsRemoveAll) {
- handleRemoveAll();
- fIsRemoveAll= false;
- return;
- }
-
- Iterator<SearchResultViewer> iter= fListeners.iterator();
- while (iter.hasNext())
- iter.next().getControl().setRedraw(false);
-
- for (IMarkerDelta markerDelta : markerDeltas) {
- handleSearchMarkerChanged(markerDelta);
- }
-
- iter= fListeners.iterator();
- while (iter.hasNext())
- iter.next().getControl().setRedraw(true);
-
- }
-
- private void handleSearchMarkerChanged(IMarkerDelta markerDelta) {
- int kind= markerDelta.getKind();
- // don't listen for adds will be done by ISearchResultView.addMatch(...)
- if (((kind & IResourceDelta.REMOVED) != 0))
- handleRemoveMatch(markerDelta.getMarker());
- else if ((kind & IResourceDelta.CHANGED) != 0)
- handleUpdateMatch(markerDelta.getMarker());
- }
-
- private void handleRemoveAll() {
- if (fCurrentSearch != null)
- fCurrentSearch.removeResults();
- Iterator<SearchResultViewer> iter= fListeners.iterator();
- while (iter.hasNext())
- iter.next().handleRemoveAll();
- }
-
- private void handleNewSearchResult() {
- Iterator<SearchResultViewer> iter= fListeners.iterator();
- while (iter.hasNext()) {
- SearchResultViewer viewer= iter.next();
- viewer.setInput(getCurrentResults());
- }
- }
-
- private void setNewSearch(SearchResultViewer viewer, Search search) {
- viewer.setInput(null);
- viewer.clearTitle();
- viewer.setPageId(search.getPageId());
- viewer.setGotoMarkerAction(search.getGotoMarkerAction());
- viewer.setContextMenuTarget(search.getContextMenuContributor());
- viewer.setActionGroupFactory(search.getActionGroupFactory());
- }
-
- private void handleRemoveMatch(IMarker marker) {
- SearchResultViewEntry entry= findEntry(marker);
- if (entry != null) {
- entry.remove(marker);
- if (entry.getMatchCount() == 0) {
- getCurrentResults().remove(entry);
- Iterator<SearchResultViewer> iter= fListeners.iterator();
- while (iter.hasNext())
- iter.next().handleRemoveMatch(entry);
- }
- else {
- Iterator<SearchResultViewer> iter= fListeners.iterator();
- while (iter.hasNext())
- iter.next().handleUpdateMatch(entry, true);
- }
- }
- }
-
- private void handleUpdateMatch(IMarker marker) {
- SearchResultViewEntry entry= findEntry(marker);
- if (entry != null) {
- Iterator<SearchResultViewer> iter= fListeners.iterator();
- while (iter.hasNext())
- iter.next().handleUpdateMatch(entry, false);
- }
- }
-
- private SearchResultViewEntry findEntry(IMarker marker) {
- Iterator<SearchResultViewEntry> entries= getCurrentResults().iterator();
- while (entries.hasNext()) {
- SearchResultViewEntry entry= entries.next();
- if (entry.contains(marker))
- return entry;
- }
- return null;
- }
-
- /**
- * Received a resource event. Since the delta could be created in a
- * separate thread this methods post the event into the viewer's
- * display thread.
- * @param event the event
- */
- @Override
- public final void resourceChanged(final IResourceChangeEvent event) {
- if (event == null)
- return;
-
- final IMarkerDelta[] markerDeltas= event.findMarkerDeltas(SearchUI.SEARCH_MARKER, true);
- if (markerDeltas == null || markerDeltas.length < 1)
- return;
-
- Display display= getDisplay();
- if (display == null || display.isDisposed())
- return;
-
- Runnable runnable= () -> {
- if (getCurrentSearch() != null) {
- handleSearchMarkersChanged(markerDeltas);
- // update title and actions
- Iterator<SearchResultViewer> iter= fListeners.iterator();
- while (iter.hasNext()) {
- SearchResultViewer viewer= iter.next();
- viewer.enableActions();
- viewer.updateTitle();
- }
- }
- };
- display.syncExec(runnable);
- }
- /**
- * Find and return a valid display
- * @return the display
- */
- private Display getDisplay() {
- Iterator<SearchResultViewer> iter= fListeners.iterator();
- while (iter.hasNext()) {
- Control control= ((Viewer)iter.next()).getControl();
- if (control != null && !control.isDisposed()) {
- Display display= control.getDisplay();
- if (display != null && !display.isDisposed())
- return display;
- }
- }
- return null;
- }
- /**
- * Find and return a valid shell
- * @return the shell
- */
- private Shell getShell() {
- return SearchPlugin.getActiveWorkbenchShell();
- }
-}
-
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPlugin.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPlugin.java
index 022ad0311db..5d28ef49751 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPlugin.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPlugin.java
@@ -208,21 +208,11 @@ public class SearchPlugin extends AbstractUIPlugin {
@Override
public void stop(BundleContext context) throws Exception {
InternalSearchUI.shutdown();
- disposeOldSearchManager();
super.stop(context);
fgSearchPlugin= null;
}
/**
- * @deprecated old search
- */
- @Deprecated
- private void disposeOldSearchManager() {
- if (SearchManager.fgDefault != null)
- SearchManager.fgDefault.dispose();
- }
-
- /**
* @return Returns all search pages contributed to the workbench.
*/
public List<SearchPageDescriptor> getSearchPageDescriptors() {
@@ -249,32 +239,6 @@ public class SearchPlugin extends AbstractUIPlugin {
}
/**
- * @return Returns the help context ID for the Search view
- * as provided by the current search page extension.
- *
- * @since 3.0
- * @deprecated old search
- */
- @Deprecated
- public String getSearchViewHelpContextId() {
- Search currentSearch= SearchManager.getDefault().getCurrentSearch();
- if (currentSearch != null) {
- String pageId= currentSearch.getPageId();
- Iterator<SearchPageDescriptor> iter= getSearchPageDescriptors().iterator();
- while (iter.hasNext()) {
- SearchPageDescriptor desc= iter.next();
- if (desc.getId().equals(pageId)) {
- String helpId= desc.getSearchViewHelpContextId();
- if (helpId == null)
- return ISearchHelpContextIds.SEARCH_VIEW;
- return desc.getSearchViewHelpContextId();
- }
- }
- }
- return ISearchHelpContextIds.SEARCH_VIEW;
- }
-
- /**
* Creates all necessary search page nodes.
* @param elements the configuration elements
* @return the created SearchPageDescriptor
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultLabelProvider.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultLabelProvider.java
deleted file mode 100644
index 6ac45c4428d..00000000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultLabelProvider.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import org.eclipse.swt.graphics.Image;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.LabelProvider;
-
-import org.eclipse.ui.PlatformUI;
-
-import org.eclipse.search.ui.ISearchResultViewEntry;
-
-/**
- * @deprecated old search
- */
-@Deprecated
-class SearchResultLabelProvider extends LabelProvider {
-
- private static final String MATCHES_POSTFIX= " " + SearchMessages.SearchResultView_matches + ")"; //$NON-NLS-1$ //$NON-NLS-2$
-
- private ILabelProvider fLabelProvider;
-
-
- SearchResultLabelProvider(ILabelProvider provider) {
- fLabelProvider= provider;
- }
-
- @Override
- public String getText(Object element) {
- StringBuilder buf= new StringBuilder(getLabelProvider().getText(element));
- int count= ((ISearchResultViewEntry)element).getMatchCount();
- if (count > 1) {
- buf.append(" ("); //$NON-NLS-1$
- buf.append(count);
- buf.append(MATCHES_POSTFIX);
- }
- return buf.toString();
- }
-
- @Override
- public Image getImage(Object element) {
- return fLabelProvider.getImage(element);
- }
-
- // Don't dispose since label providers are reused.
- @Override
- public void dispose() {
- }
-
- ILabelProvider getLabelProvider() {
- return fLabelProvider;
- }
-
- @Override
- public void addListener(ILabelProviderListener listener) {
- super.addListener(listener);
- fLabelProvider.addListener(listener);
- PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator().addListener(listener);
- }
-
- @Override
- public boolean isLabelProperty(Object element, String property) {
- return fLabelProvider.isLabelProperty(element, property);
- }
-
- @Override
- public void removeListener(ILabelProviderListener listener) {
- super.removeListener(listener);
- fLabelProvider.removeListener(listener);
- PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator().removeListener(listener);
- }
-}
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
deleted file mode 100644
index 06287844fb0..00000000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultView.java
+++ /dev/null
@@ -1,341 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Michael Fraenkel (fraenkel@us.ibm.com) - contributed a fix for:
- * o New search view sets incorrect title
- * (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=60966)
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.core.runtime.Assert;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.viewers.IBaseLabelProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.part.CellEditorActionHandler;
-import org.eclipse.ui.part.ViewPart;
-
-import org.eclipse.search.ui.IActionGroupFactory;
-import org.eclipse.search.ui.IContextMenuContributor;
-import org.eclipse.search.ui.IGroupByKeyComputer;
-import org.eclipse.search.ui.ISearchResultView;
-
-/**
- * @deprecated old search
- */
-@Deprecated
-public class SearchResultView extends ViewPart implements ISearchResultView {
-
-
- private static Map<String, ILabelProvider> fgLabelProviders= new HashMap<>(5);
-
- private SearchResultViewer fViewer;
- private Map<Object, SearchResultViewEntry> fResponse;
- private IMemento fMemento;
- private IPropertyChangeListener fPropertyChangeListener;
- private CellEditorActionHandler fCellEditorActionHandler;
- private SelectAllAction fSelectAllAction;
-
- /*
- * Implements method from IViewPart.
- */
- @Override
- public void init(IViewSite site, IMemento memento) throws PartInitException {
- super.init(site, memento);
- fMemento= memento;
- }
-
- /*
- * Implements method from IViewPart.
- */
- @Override
- public void saveState(IMemento memento) {
- if (fViewer == null) {
- // part has not been created
- if (fMemento != null) //Keep the old state;
- memento.putMemento(fMemento);
- return;
- }
- fViewer.saveState(memento);
- }
-
- /**
- * Creates the search list inner viewer.
- * @param parent the parent
- */
- @Override
- public void createPartControl(Composite parent) {
- Assert.isTrue(fViewer == null);
- fViewer= new SearchResultViewer(this, parent);
- if (fMemento != null)
- fViewer.restoreState(fMemento);
- fMemento= null;
- SearchManager.getDefault().addSearchChangeListener(fViewer);
- fViewer.init();
-
- // Add selectAll action handlers.
- fCellEditorActionHandler = new CellEditorActionHandler(getViewSite().getActionBars());
- fSelectAllAction= new SelectAllAction();
- fSelectAllAction.setViewer(fViewer);
- fCellEditorActionHandler.setSelectAllAction(fSelectAllAction);
-
- fillActionBars(getViewSite().getActionBars());
-
- fPropertyChangeListener= event -> {
- if (SearchPreferencePage.POTENTIAL_MATCH_FG_COLOR.equals(event.getProperty()) || SearchPreferencePage.EMPHASIZE_POTENTIAL_MATCHES.equals(event.getProperty()))
- if (fViewer != null)
- fViewer.updatedPotentialMatchFgColor();
- };
-
- SearchPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPropertyChangeListener);
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(fViewer.getControl(), SearchPlugin.getDefault().getSearchViewHelpContextId());
- }
-
- /**
- * Returns the search result viewer.
- * @return the search result viewer.
- */
- public SearchResultViewer getViewer() {
- return fViewer;
- }
-
- //---- IWorkbenchPart ------------------------------------------------------
-
-
- @Override
- public void setFocus() {
- fViewer.getControl().setFocus();
- }
-
- @Override
- public void dispose() {
- if (fViewer != null) {
- SearchManager.getDefault().removeSearchChangeListener(fViewer);
- fViewer= null;
- }
- if (fPropertyChangeListener != null)
- SearchPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener);
- if (fCellEditorActionHandler != null) {
- fCellEditorActionHandler.dispose();
- fCellEditorActionHandler= null;
- }
- super.dispose();
- }
-
- @Override
- protected void setContentDescription(String title) {
- super.setContentDescription(title);
- }
-
- @Override
- protected void setTitleToolTip(String text) {
- super.setTitleToolTip(text);
- }
-
- //---- Adding Action to Toolbar -------------------------------------------
-
- private void fillActionBars(IActionBars actionBars) {
- IToolBarManager toolBar= actionBars.getToolBarManager();
- fillToolBar(toolBar);
- actionBars.updateActionBars();
-
- // Add selectAll action handlers.
- actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), fSelectAllAction);
- }
-
- private void fillToolBar(IToolBarManager tbm) {
- fViewer.fillToolBar(tbm);
- }
-
- ILabelProvider getLabelProvider(String pageId) {
- if (pageId != null)
- return fgLabelProviders.get(pageId);
- return null;
- }
-
- @Override
- public ILabelProvider getLabelProvider() {
- if (fViewer == null)
- return null;
- IBaseLabelProvider labelProvider= fViewer.getLabelProvider();
- if (labelProvider == null)
- return null;
-
- return ((SearchResultLabelProvider)labelProvider).getLabelProvider();
- }
-
- private void setGotoMarkerAction(final IAction gotoMarkerAction) {
- // Make sure we are doing it in the right thread.
- getDisplay().syncExec(() -> getViewer().setGotoMarkerAction(gotoMarkerAction));
- }
-
-
- Display getDisplay() {
- return fViewer.getControl().getDisplay();
- }
-
-
- //---- ISearchResultView --------------------------------------------------
-
-
- /*
- * Implements method from ISearchResultView
- */
- @Override
- public ISelection getSelection() {
- return fViewer.getSelection();
- }
-
- /*
- * Implements method from ISearchResultView
- */
- @Override
- public void searchStarted(
- IActionGroupFactory groupFactory,
- String singularLabel,
- String pluralLabelPattern,
- ImageDescriptor imageDescriptor,
- String pageId,
- ILabelProvider labelProvider,
- IAction gotoAction,
- IGroupByKeyComputer groupByKeyComputer,
- IRunnableWithProgress operation) {
-
-
- Assert.isNotNull(pageId);
- Assert.isNotNull(pluralLabelPattern);
- Assert.isNotNull(gotoAction);
-
- fResponse= new HashMap<>(500);
- setGotoMarkerAction(gotoAction);
-
- ILabelProvider oldLabelProvider= fgLabelProviders.get(pageId);
- if (oldLabelProvider != null)
- oldLabelProvider.dispose();
- fgLabelProviders.put(pageId, labelProvider);
-
- SearchManager.getDefault().addNewSearch(
- new Search(
- pageId,
- singularLabel,
- pluralLabelPattern,
- null,
- imageDescriptor,
- fViewer.getGotoMarkerAction(),
- groupFactory,
- groupByKeyComputer,
- operation));
- }
-
- @Override
- public void searchStarted(
- String pageId,
- String label,
- ImageDescriptor imageDescriptor,
- IContextMenuContributor contributor,
- ILabelProvider labelProvider,
- IAction gotoAction,
- IGroupByKeyComputer groupByKeyComputer,
- IRunnableWithProgress operation) {
-
- searchStarted(pageId, null, label, imageDescriptor, contributor, labelProvider, gotoAction, groupByKeyComputer, operation);
- }
-
- /*
- * Implements method from ISearchResultView
- * @deprecated As of build > 20020514
- */
- @Override
- public void searchStarted(
- String pageId,
- String singularLabel,
- String pluralLabelPattern,
- ImageDescriptor imageDescriptor,
- IContextMenuContributor contributor,
- ILabelProvider labelProvider,
- IAction gotoAction,
- IGroupByKeyComputer groupByKeyComputer,
- IRunnableWithProgress operation) {
-
-
- Assert.isNotNull(pageId);
- Assert.isNotNull(pluralLabelPattern);
- Assert.isNotNull(gotoAction);
-
- fResponse= new HashMap<>(500);
- setGotoMarkerAction(gotoAction);
-
- ILabelProvider oldLabelProvider= fgLabelProviders.get(pageId);
- if (oldLabelProvider != null)
- oldLabelProvider.dispose();
- fgLabelProviders.put(pageId, labelProvider);
-
- SearchManager.getDefault().addNewSearch(
- new Search(
- pageId,
- singularLabel,
- pluralLabelPattern,
- null,
- imageDescriptor,
- fViewer.getGotoMarkerAction(),
- contributor,
- groupByKeyComputer,
- operation));
- }
-
- /*
- * Implements method from ISearchResultView
- */
- @Override
- public void addMatch(String description, Object groupByKey, IResource resource, IMarker marker) {
- SearchResultViewEntry entry= fResponse.get(groupByKey);
- if (entry == null) {
- entry= new SearchResultViewEntry(groupByKey, resource);
- fResponse.put(groupByKey, entry);
- }
- entry.add(marker);
- }
-
-
- /*
- * Implements method from ISearchResultView
- */
- @Override
- public void searchFinished() {
- SearchManager.getDefault().searchFinished(new ArrayList<>(fResponse.values()));
- fResponse= null;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntry.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntry.java
deleted file mode 100644
index 02fd436db19..00000000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntry.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.PlatformObject;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-
-import org.eclipse.search.ui.ISearchResultViewEntry;
-import org.eclipse.search.ui.SearchUI;
-
-/**
- * Represents an entry in the search result view
- * @deprecated old search
- */
-@Deprecated
-public class SearchResultViewEntry extends PlatformObject implements ISearchResultViewEntry {
-
- private Object fGroupByKey= null;
- private IResource fResource= null;
- private IMarker fMarker= null;
- private ArrayList<IMarker> fMarkers= null;
- private ArrayList<Map<String, Object>> fAttributes;
- private int fSelectedMarkerIndex;
- private long fModificationStamp= IResource.NULL_STAMP;
- private String fMarkerType;
-
- public SearchResultViewEntry(Object groupByKey, IResource resource) {
- fGroupByKey= groupByKey;
- fResource= resource;
- if (fResource != null)
- fModificationStamp= fResource.getModificationStamp();
- }
-
- //---- Accessors ------------------------------------------------
- @Override
- public Object getGroupByKey() {
- return fGroupByKey;
- }
-
- void setGroupByKey(Object groupByKey) {
- fGroupByKey= groupByKey;
- }
-
- @Override
- public IResource getResource() {
- return fResource;
- }
-
- @Override
- public int getMatchCount() {
- if (fMarkers != null)
- return fMarkers.size();
- if (fMarkers == null && fMarker != null)
- return 1;
- return 0;
- }
-
- boolean isPotentialMatch() {
- if (fMarker != null)
- return fMarker.getAttribute(SearchUI.POTENTIAL_MATCH, false);
- return false;
- }
-
- List<Map<String, Object>> getAttributesPerMarker() {
- if (fAttributes == null)
- return new ArrayList<>(0);
- return fAttributes;
- }
-
- public long getModificationStamp() {
- return fModificationStamp;
- }
-
- void clearMarkerList() {
- fMarker= null;
- if (fMarkers != null)
- fMarkers.clear();
- }
-
- void add(IMarker marker) {
- if (marker != null && fMarkerType == null) {
- try {
- fMarkerType= marker.getType();
- } catch (CoreException ex) {
- // will default to org.eclipse.search.searchmarker
- }
- }
-
- if (fMarker == null) {
- fMarker= marker;
- if (fMarkers != null)
- fMarkers.add(marker);
- return;
- }
- if (fMarkers == null) {
- fMarkers= new ArrayList<>(10);
- addByStartpos(fMarkers, fMarker);
- }
- addByStartpos(fMarkers, marker);
- }
-
- void setSelectedMarkerIndex(int index) {
- fSelectedMarkerIndex= index;
- }
-
- @Override
- public IMarker getSelectedMarker() {
- fSelectedMarkerIndex= Math.min(fSelectedMarkerIndex, getMatchCount() - 1);
- if (fMarkers == null && fMarker == null)
- return null;
- if (fMarkers != null && fSelectedMarkerIndex >= 0)
- return fMarkers.get(fSelectedMarkerIndex);
- return fMarker;
- }
-
- public List<IMarker> getMarkers() {
- if (fMarkers == null && fMarker == null)
- return new ArrayList<>(0);
- else if (fMarkers == null && fMarker != null) {
- List<IMarker> markers= new ArrayList<>(1);
- markers.add(fMarker);
- return markers;
- }
- return fMarkers;
- }
-
- String getMarkerType() {
- if (fMarkerType == null)
- return SearchUI.SEARCH_MARKER;
- return fMarkerType;
- }
-
- boolean contains(IMarker marker) {
- if (fMarkers == null && fMarker == null)
- return false;
- if (fMarkers == null)
- return fMarker.equals(marker);
- return fMarkers.contains(marker);
- }
-
- void remove(IMarker marker) {
- if (marker == null)
- return;
-
- if (fMarkers == null) {
- if (fMarker != null && fMarker.equals(marker))
- fMarker= null;
- }
- else {
- fMarkers.remove(marker);
- if (fMarkers.size() == 1) {
- fMarker= fMarkers.get(0);
- fMarkers= null;
- }
- }
- }
-
- void backupMarkers() {
- if (fResource != null)
- fModificationStamp= fResource.getModificationStamp();
- List<IMarker> markers= getMarkers();
- fAttributes= new ArrayList<>(markers.size());
- Iterator<IMarker> iter= markers.iterator();
- while (iter.hasNext()) {
- IMarker marker= iter.next();
- Map<String, Object> attributes= null;
- try {
- attributes= marker.getAttributes();
- } catch (CoreException ex) {
- // don't backup corrupt marker
- continue;
- }
- fAttributes.add(attributes);
- }
- }
-
- private void addByStartpos(ArrayList<IMarker> markers, IMarker marker) {
- int startPos= marker.getAttribute(IMarker.CHAR_START, -1);
- int i= 0;
- int markerCount= markers.size();
- while (i < markerCount && startPos >= markers.get(i).getAttribute(IMarker.CHAR_START, -1))
- i++;
- markers.add(i, marker);
- if (i == 0)
- fMarker= marker;
- }
-
- @Override
- public <T> T getAdapter(Class<T> adapter) {
- return super.getAdapter(adapter);
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntryAdapterFactory.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntryAdapterFactory.java
deleted file mode 100644
index f82258ea02a..00000000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntryAdapterFactory.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.search.internal.ui;
-
-
-import org.eclipse.core.runtime.IAdapterFactory;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-
-import org.eclipse.search.ui.ISearchResultViewEntry;
-
-/**
- * Implements basic UI support for Java elements.
- * Implements handle to persistent support for Java elements.
- * @deprecated old search
- */
-@Deprecated
-public class SearchResultViewEntryAdapterFactory implements IAdapterFactory {
-
- private static Class<?>[] PROPERTIES= new Class[] {
- IResource.class, IMarker.class,
- };
-
-
- @Override
- public Class<?>[] getAdapterList() {
- return PROPERTIES;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public <T> T getAdapter(Object element, Class<T> key) {
-
- ISearchResultViewEntry entry= (ISearchResultViewEntry) element;
-
- if (IMarker.class.equals(key)) {
- return (T) entry.getSelectedMarker();
- }
- if (IResource.class.equals(key)) {
- IResource resource= entry.getResource();
- /*
- * This is a trick to filter out dummy markers that
- * have been attached to a project because there is no
- * corresponding resource in the workspace.
- */
- int type= resource.getType();
- if (type != IResource.PROJECT && type != IResource.ROOT)
- return (T) resource;
- }
- return null;
- }
-}
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
deleted file mode 100644
index f28beb84c4b..00000000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewer.java
+++ /dev/null
@@ -1,717 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2021 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Michael Fraenkel (fraenkel@us.ibm.com) - contributed a fix for:
- * o New search view sets incorrect title
- * (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=60966)
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Item;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Widget;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.IBaseLabelProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProviderChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionContext;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.actions.ActionGroup;
-
-import org.eclipse.search.internal.ui.util.FileLabelProvider;
-import org.eclipse.search.ui.IActionGroupFactory;
-import org.eclipse.search.ui.IContextMenuConstants;
-import org.eclipse.search.ui.IContextMenuContributor;
-import org.eclipse.search.ui.ISearchResultViewEntry;
-import org.eclipse.search.ui.SearchUI;
-
-/**
- * A special viewer to present search results. The viewer implements an
- * optimized adding and removing strategy. Furthermore it manages
- * contributions for search result types. For example the viewer's context
- * menu differs if the search result has been generated by a text or
- * a java search.
- * @deprecated old search
- */
-@Deprecated
-public class SearchResultViewer extends TableViewer {
-
- private SearchResultView fOuterPart;
- private ShowNextResultAction fShowNextResultAction;
- private ShowPreviousResultAction fShowPreviousResultAction;
- private GotoMarkerAction fGotoMarkerActionProxy;
- private SearchAgainAction fSearchAgainAction;
- private RemoveResultAction fRemoveSelectedMatchesAction;
- private RemoveAllResultsAction fRemoveAllResultsAction;
- private SortDropDownAction fSortDropDownAction;
- private SearchDropDownAction fSearchDropDownAction;
- private CopyToClipboardAction fCopyToClipboardAction;
- private int fMarkerToShow;
- private boolean fHandleSelectionChangedEvents= true;
- private ISelection fLastSelection;
- private boolean fCurrentMatchRemoved= false;
- private Color fPotentialMatchFgColor;
- private ActionGroup fActionGroup;
- private IContextMenuContributor fContextMenuContributor;
- private IAction fGotoMarkerAction;
-
- private ResourceToItemsMapper fResourceToItemsMapper;
- private String fCurrentPageId= null;
-
- public SearchResultViewer(SearchResultView outerPart, Composite parent) {
- super(new Table(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION));
-
- fResourceToItemsMapper= new ResourceToItemsMapper(this);
-
- fOuterPart= outerPart;
- Assert.isNotNull(fOuterPart);
-
- if (SearchPreferencePage.arePotentialMatchesEmphasized())
- fPotentialMatchFgColor= new Color(SearchPlugin.getActiveWorkbenchShell().getDisplay(), SearchPreferencePage.getPotentialMatchForegroundColor());
-
- setUseHashlookup(true);
- setContentProvider(ArrayContentProvider.getInstance());
-
- ILabelProvider labelProvider= new SearchResultLabelProvider(new FileLabelProvider(FileLabelProvider.SHOW_LABEL));
- setLabelProvider(labelProvider);
-
- Search currentSearch= SearchManager.getDefault().getCurrentSearch();
- boolean hasSearch= currentSearch != null;
- boolean hasSearchOperation= currentSearch != null && currentSearch.getOperation() != null;
-
- fShowNextResultAction= new ShowNextResultAction(this);
- fShowNextResultAction.setEnabled(false);
- fShowPreviousResultAction= new ShowPreviousResultAction(this);
- fShowPreviousResultAction.setEnabled(false);
- fGotoMarkerActionProxy= new GotoMarkerAction(this);
- fGotoMarkerActionProxy.setEnabled(false);
- fRemoveSelectedMatchesAction= new RemoveResultAction(this, false);
- fRemoveSelectedMatchesAction.setEnabled(false);
- fRemoveAllResultsAction= new RemoveAllResultsAction();
- fRemoveAllResultsAction.setEnabled(false);
- fSearchAgainAction= new SearchAgainAction();
- fSearchAgainAction.setEnabled(hasSearchOperation);
- fSortDropDownAction = new SortDropDownAction(this);
- fSortDropDownAction.setEnabled(getItemCount() > 0);
- fSearchDropDownAction= new SearchDropDownAction();
- fSearchDropDownAction.setEnabled(hasSearch);
- fCopyToClipboardAction= new CopyToClipboardAction(this);
-
- addSelectionChangedListener(
- event -> {
- if (fLastSelection == null || !fLastSelection.equals(event.getSelection())) {
- fLastSelection= event.getSelection();
- handleSelectionChanged();
- }
- }
- );
-
- addOpenListener(event -> showResult());
-
- MenuManager menuMgr= new MenuManager("#PopUp"); //$NON-NLS-1$
- menuMgr.setRemoveAllWhenShown(true);
- menuMgr.addMenuListener(
- mgr -> {
- SearchPlugin.createStandardGroups(mgr);
- fillContextMenu(mgr);
- });
- Menu menu= menuMgr.createContextMenu(getTable());
- getTable().setMenu(menu);
-
- // Register menu
- fOuterPart.getSite().registerContextMenu(menuMgr, this);
-
- IActionBars actionBars= fOuterPart.getViewSite().getActionBars();
- if (actionBars != null) {
- actionBars.setGlobalActionHandler(ActionFactory.NEXT.getId(), fShowNextResultAction);
- actionBars.setGlobalActionHandler(ActionFactory.PREVIOUS.getId(), fShowPreviousResultAction);
- }
-
- fOuterPart.getSite().setSelectionProvider(this);
- }
-
- void init() {
- Search search= SearchManager.getDefault().getCurrentSearch();
- if (search != null) {
- setGotoMarkerAction(search.getGotoMarkerAction());
- setContextMenuTarget(search.getContextMenuContributor());
- setActionGroupFactory(null);
- setActionGroupFactory(search.getActionGroupFactory());
- setPageId(search.getPageId());
- setInput(search.getResults());
- }
- }
-
- @Override
- protected void doUpdateItem(Widget item, Object element, boolean fullMap) {
- super.doUpdateItem(item, element, fullMap);
- if (((SearchResultViewEntry)element).isPotentialMatch()) {
- TableItem ti = (TableItem) item;
- ti.setForeground(fPotentialMatchFgColor);
- }
- }
-
- private void handleSelectionChanged() {
- int selectionCount= getSelectedEntriesCount();
- boolean hasSingleSelection= selectionCount == 1;
- boolean hasElements= getItemCount() > 0;
- fShowNextResultAction.setEnabled(hasSingleSelection || (hasElements && selectionCount == 0));
- fShowPreviousResultAction.setEnabled(hasSingleSelection || (hasElements && selectionCount == 0));
- fGotoMarkerActionProxy.setEnabled(hasSingleSelection);
- fRemoveSelectedMatchesAction.setEnabled(selectionCount > 0);
-
- if (fHandleSelectionChangedEvents) {
- fMarkerToShow= -1;
- fCurrentMatchRemoved= false;
- } else
- fHandleSelectionChangedEvents= true;
-
- updateStatusLine();
- }
-
- void updateStatusLine() {
- boolean hasSingleSelection= getSelectedEntriesCount() == 1;
- String location= ""; //$NON-NLS-1$
- if (hasSingleSelection) {
- ISearchResultViewEntry entry= (ISearchResultViewEntry)getTable().getItem(getTable().getSelectionIndex()).getData();
- IPath path= entry.getResource().getFullPath();
- if (path != null)
- location= path.makeRelative().toString();
- }
- setStatusLineMessage(location);
- }
-
- void enableActions() {
- /*
- * Note: The check before each set operation reduces flickering
- */
- boolean state= getItemCount() > 0;
- if (state != fShowNextResultAction.isEnabled())
- fShowNextResultAction.setEnabled(state);
- if (state != fShowPreviousResultAction.isEnabled())
- fShowPreviousResultAction.setEnabled(state);
- if (state != fSortDropDownAction.isEnabled())
- fSortDropDownAction.setEnabled(state);
- if (state != fRemoveAllResultsAction.isEnabled())
- fRemoveAllResultsAction.setEnabled(state);
-
- Search currentSearch= SearchManager.getDefault().getCurrentSearch();
- state= currentSearch != null;
- boolean operationState= currentSearch != null && currentSearch.getOperation() != null;
- if (state != fSearchDropDownAction.isEnabled())
- fSearchDropDownAction.setEnabled(state);
- if (operationState != fSearchAgainAction.isEnabled())
- fSearchAgainAction.setEnabled(operationState);
-
- state= !getSelection().isEmpty();
- if (state != fGotoMarkerActionProxy.isEnabled())
- fGotoMarkerActionProxy.setEnabled(state);
- if (state != fRemoveSelectedMatchesAction.isEnabled())
- fRemoveSelectedMatchesAction.setEnabled(state);
- }
-
-
- @Override
- protected void inputChanged(Object input, Object oldInput) {
- fLastSelection= null;
- getTable().removeAll();
- super.inputChanged(input, oldInput);
- fMarkerToShow= -1;
- fCurrentMatchRemoved= false;
- updateTitle();
- enableActions();
- if (getItemCount() > 0)
- selectResult(0);
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), SearchPlugin.getDefault().getSearchViewHelpContextId());
- }
-
- protected int getSelectedEntriesCount() {
- ISelection s= getSelection();
- if (s == null || s.isEmpty() || !(s instanceof IStructuredSelection))
- return 0;
- IStructuredSelection selection= (IStructuredSelection)s;
- return selection.size();
- }
-
- //--- Contribution management -----------------------------------------------
-
-
- protected boolean enableRemoveMatchMenuItem() {
- if (getSelectedEntriesCount() != 1)
- return false;
- Table table= getTable();
- int index= table.getSelectionIndex();
- SearchResultViewEntry entry= null;
- if (index > -1)
- entry= (SearchResultViewEntry)table.getItem(index).getData();
- return (entry != null && entry.getMatchCount() > 1);
-
- }
-
- void fillContextMenu(IMenuManager menu) {
- ISelection selection= getSelection();
-
- if (fActionGroup != null) {
- ActionContext context= new ActionContext(selection);
- context.setInput(getInput());
- fActionGroup.setContext(context);
- fActionGroup.fillContextMenu(menu);
- fActionGroup.setContext(null);
- }
-
- if (fContextMenuContributor != null)
- fContextMenuContributor.fill(menu, this);
-
- if (!selection.isEmpty()) {
- menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, fCopyToClipboardAction);
- menu.appendToGroup(IContextMenuConstants.GROUP_GOTO, fGotoMarkerActionProxy);
- if (enableRemoveMatchMenuItem())
- menu.appendToGroup(IContextMenuConstants.GROUP_REMOVE_MATCHES, new RemoveMatchAction(this));
- menu.appendToGroup(IContextMenuConstants.GROUP_REMOVE_MATCHES, new RemoveResultAction(this, true));
-
- if (isPotentialMatchSelected())
- menu.appendToGroup(IContextMenuConstants.GROUP_REMOVE_MATCHES, new RemovePotentialMatchesAction(fOuterPart.getViewSite()));
- }
-
- // If we have elements
- if (getItemCount() > 0)
- menu.appendToGroup(IContextMenuConstants.GROUP_REMOVE_MATCHES, new RemoveAllResultsAction());
-
- menu.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, fSearchAgainAction);
- if (getItemCount() > 0) {
- fSortDropDownAction= fSortDropDownAction.renew();
- if (fSortDropDownAction.getSorterCount() > 1)
- menu.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, fSortDropDownAction);
- }
- }
-
- private boolean isPotentialMatchSelected() {
- if (getSelectedEntriesCount() == 0)
- return false;
-
- Iterator<?> iter= Collections.emptyList().iterator();
- ISelection selection= getSelection();
- if (selection instanceof IStructuredSelection)
- iter= ((IStructuredSelection)selection).iterator();
-
- while (iter.hasNext()) {
- Object entry= iter.next();
- if (entry instanceof ISearchResultViewEntry) {
- IMarker marker= ((ISearchResultViewEntry)entry).getSelectedMarker();
- if (marker != null && marker.getAttribute(SearchUI.POTENTIAL_MATCH, false))
- return true;
- }
- }
-
- return false;
- }
-
- IAction getGotoMarkerAction() {
- // null as return value is covered (no action will take place)
- return fGotoMarkerAction;
- }
-
- void setGotoMarkerAction(IAction gotoMarkerAction) {
- fGotoMarkerAction= gotoMarkerAction;
- }
-
-
- void setContextMenuTarget(IContextMenuContributor contributor) {
- fContextMenuContributor= contributor;
- }
-
- void setActionGroupFactory(IActionGroupFactory groupFactory) {
- IActionBars actionBars= fOuterPart.getViewSite().getActionBars();
- if (fActionGroup != null) {
- fActionGroup.dispose();
- fActionGroup= null;
- }
-
- if (groupFactory != null) {
- fActionGroup= groupFactory.createActionGroup(fOuterPart);
- if (actionBars != null)
- fActionGroup.fillActionBars(actionBars);
- }
- if (actionBars != null)
- actionBars.updateActionBars();
- }
-
- void setPageId(String pageId) {
- if (fCurrentPageId != null && fCurrentPageId.equals(pageId))
- return;
-
- fCurrentPageId= pageId;
- ILabelProvider labelProvider= fOuterPart.getLabelProvider(pageId);
- if (labelProvider != null)
- internalSetLabelProvider(labelProvider);
- fSortDropDownAction.setPageId(pageId);
- }
-
- void fillToolBar(IToolBarManager tbm) {
- tbm.add(fShowNextResultAction);
- tbm.add(fShowPreviousResultAction);
-// tbm.add(fGotoMarkerAction); see bug 15275
- tbm.add(fRemoveSelectedMatchesAction);
- tbm.add(fRemoveAllResultsAction);
- tbm.add(new Separator());
- tbm.add(new OpenSearchDialogAction());
- tbm.add(fSearchDropDownAction);
-
- // need to hook F5 to table
- getTable().addKeyListener(new KeyAdapter() {
- @Override
- public void keyReleased(KeyEvent e) {
- if (e.keyCode == SWT.F5) {
- fSearchAgainAction.run();
- return; // performance
- }
- if (e.character == SWT.DEL) {
- new RemoveResultAction(SearchResultViewer.this, true).run();
- return; // performance
- }
- }
- });
- }
-
- int getItemCount() {
- return SearchManager.getDefault().getCurrentItemCount();
- }
-
- void internalSetLabelProvider(ILabelProvider provider) {
- setLabelProvider(new SearchResultLabelProvider(provider));
- }
-
- /**
- * Makes the first marker of the current result entry
- * visible in an editor. If no result
- * is visible, this method does nothing.
- */
- public void showResult() {
- Table table= getTable();
- if (!canDoShowResult(table))
- return;
-
-
- int index= table.getSelectionIndex();
- if (index < 0)
- return;
- SearchResultViewEntry entry= (SearchResultViewEntry)getTable().getItem(index).getData();
-
-
- fMarkerToShow= 0;
- fCurrentMatchRemoved= false;
- entry.setSelectedMarkerIndex(0);
- openCurrentSelection();
- }
-
-
- /**
- * Makes the next result (marker) visible in an editor. If no result
- * is visible, this method makes the first result visible.
- */
- public void showNextResult() {
- Table table= getTable();
- if (!canDoShowResult(table))
- return;
-
- int index= table.getSelectionIndex();
- SearchResultViewEntry entry= null;
- if (index > -1)
- entry= (SearchResultViewEntry)table.getItem(index).getData();
-
- if (fCurrentMatchRemoved)
- fCurrentMatchRemoved= false;
- else
- fMarkerToShow++;
- if (entry == null || fMarkerToShow >= entry.getMatchCount()) {
- // move selection
- if (index == -1) {
- index= 0;
- } else {
- index++;
- if (index >= table.getItemCount())
- index= 0;
- }
- fMarkerToShow= 0;
- entry= (SearchResultViewEntry)getTable().getItem(index).getData();
- selectResult(index);
- }
- entry.setSelectedMarkerIndex(fMarkerToShow);
- openCurrentSelection();
- updateStatusLine();
- }
-
-
- /**
- * Makes the previous result (marker) visible. If there isn't any
- * visible result, this method makes the last result visible.
- */
- public void showPreviousResult() {
- fCurrentMatchRemoved= false;
- Table table= getTable();
- if (!canDoShowResult(table))
- return;
-
- int index= table.getSelectionIndex();
- SearchResultViewEntry entry;
-
-
- fMarkerToShow--;
- if (fMarkerToShow >= 0)
- entry= (SearchResultViewEntry)getTable().getItem(getTable().getSelectionIndex()).getData();
- else {
- // move selection
- int count= table.getItemCount();
- if (index == -1) {
- index= count - 1;
- } else {
- index--;
- if (index < 0)
- index= count - 1;
- }
- entry= (SearchResultViewEntry)getTable().getItem(index).getData();
- fMarkerToShow= entry.getMatchCount() - 1;
- selectResult(index);
- }
- entry.setSelectedMarkerIndex(fMarkerToShow);
- openCurrentSelection();
- updateStatusLine();
- }
-
- private boolean canDoShowResult(Table table) {
- if (table == null || getItemCount() == 0)
- return false;
- return true;
- }
-
- private void selectResult(int index) {
- fHandleSelectionChangedEvents= false;
- Object element= getElementAt(index);
- if (element != null)
- setSelection(new StructuredSelection(getElementAt(index)), true);
- else
- setSelection(StructuredSelection.EMPTY);
- }
-
- private void openCurrentSelection() {
- IAction action= getGotoMarkerAction();
- if (action != null)
- action.run();
- }
-
- /**
- * Updates the foreground color for potential matches.
- */
- void updatedPotentialMatchFgColor() {
- fPotentialMatchFgColor= null;
- if (SearchPreferencePage.arePotentialMatchesEmphasized())
- fPotentialMatchFgColor= new Color(SearchPlugin.getActiveWorkbenchShell().getDisplay(), SearchPreferencePage.getPotentialMatchForegroundColor());
- refresh();
- }
-
- /**
- * Update the title
- */
- protected void updateTitle() {
- boolean hasCurrentSearch= SearchManager.getDefault().getCurrentSearch() != null;
- String title;
- if (hasCurrentSearch) {
- String description= SearchManager.getDefault().getCurrentSearch().getFullDescription();
- title= Messages.format(SearchMessages.SearchResultView_titleWithDescription, description);
- } else
- title= SearchMessages.SearchResultView_title;
- if (title == null || !title.equals(fOuterPart.getContentDescription()))
- fOuterPart.setContentDescription(title);
- }
-
- /**
- * Clear the title
- */
- protected void clearTitle() {
- String title= SearchMessages.SearchResultView_title;
- if (!title.equals(fOuterPart.getContentDescription()))
- fOuterPart.setContentDescription(title);
- }
-
- /**
- * Sets the message text to be displayed on the status line.
- * The image on the status line is cleared.
- * @param message the message
- */
- private void setStatusLineMessage(String message) {
- fOuterPart.getViewSite().getActionBars().getStatusLineManager().setMessage(message);
- }
-
-
- @Override
- protected void handleDispose(DisposeEvent event) {
- fLastSelection= null;
- Menu menu= getTable().getMenu();
- if (menu != null)
- menu.dispose();
- if (fActionGroup != null) {
- fActionGroup.dispose();
- fActionGroup= null;
- }
- super.handleDispose(event);
- }
-
- //--- Change event handling -------------------------------------------------
-
- /**
- * Handle a single add.
- * @param entry the entry to add
- */
- protected void handleAddMatch(ISearchResultViewEntry entry) {
- insert(entry, -1);
- }
-
- /**
- * Handle a single remove.
- * @param entry the entry to remove
- */
- protected void handleRemoveMatch(ISearchResultViewEntry entry) {
- Widget item= findItem(entry);
- if (entry.getMatchCount() == 0)
- remove(entry);
- else
- updateItem(item, entry);
- updateStatusLine();
- }
-
- /**
- * Handle remove all.
- */
- protected void handleRemoveAll() {
- setContextMenuTarget(null);
- setActionGroupFactory(null);
- setInput(null);
- }
-
- /**
- * Handle an update of an entry.
- *
- * @param entry the entry
- * @param matchRemoved <code>true</code> if a match got removed
- */
- protected void handleUpdateMatch(ISearchResultViewEntry entry, boolean matchRemoved) {
- Widget item= findItem(entry);
- updateItem(item, entry);
- if (matchRemoved && getSelectionFromWidget().contains(entry))
- fCurrentMatchRemoved= true;
- }
-
- //--- Persistency -------------------------------------------------
-
- void restoreState(IMemento memento) {
- fSortDropDownAction.restoreState(memento);
- }
-
- void saveState(IMemento memento) {
- fSortDropDownAction.saveState(memento);
- }
-
- @Override
- protected void handleLabelProviderChanged(LabelProviderChangedEvent event) {
- Object[] changed= event.getElements();
- if (changed != null && !fResourceToItemsMapper.isEmpty()) {
- ArrayList<Object> others= new ArrayList<>(changed.length);
- for (Object curr : changed) {
- if (curr instanceof IResource)
- fResourceToItemsMapper.resourceChanged((IResource) curr);
- else if (curr instanceof IAdaptable) {
- IResource resource= ((IAdaptable)curr).getAdapter(IResource.class);
- if (resource != null)
- fResourceToItemsMapper.resourceChanged(resource);
- } else
- others.add(curr);
- }
- if (others.isEmpty()) {
- return;
- }
- event= new LabelProviderChangedEvent((IBaseLabelProvider) event.getSource(), others.toArray());
- }
- super.handleLabelProviderChanged(event);
- }
-
- @Override
- protected void mapElement(Object element, Widget item) {
- super.mapElement(element, item);
- if (item instanceof Item) {
- fResourceToItemsMapper.addToMap(element, (Item)item);
- }
- }
-
- @Override
- protected void unmapElement(Object element, Widget item) {
- if (item instanceof Item) {
- fResourceToItemsMapper.removeFromMap(element, (Item)item);
- }
- super.unmapElement(element, item);
- }
-
- @Override
- protected void unmapAllElements() {
- fResourceToItemsMapper.clearMap();
- super.unmapAllElements();
- }
-
- @Override
- protected void internalRefresh(Object element, boolean updateLabels) {
- // see bug 44891
- getTable().setRedraw(false);
- super.internalRefresh(element, updateLabels);
- getTable().setRedraw(true);
- }
-
- void handleAllSearchesRemoved() {
- setContextMenuTarget(null);
- setActionGroupFactory(null);
- setInput(null);
- fSearchDropDownAction.clear();
- }
-
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/ShowNextResultAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/ShowNextResultAction.java
deleted file mode 100644
index 43f566ad1c5..00000000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/ShowNextResultAction.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import org.eclipse.jface.action.Action;
-
-import org.eclipse.ui.IWorkbenchCommandConstants;
-
-/**
- * @deprecated old search
- */
-@Deprecated
-class ShowNextResultAction extends Action {
-
- private SearchResultViewer fViewer;
-
- public ShowNextResultAction(SearchResultViewer viewer) {
- super(SearchMessages.SearchResultView_showNext_text);
- SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_NEXT);
- setToolTipText(SearchMessages.SearchResultView_showNext_tooltip);
- fViewer= viewer;
- setActionDefinitionId(IWorkbenchCommandConstants.NAVIGATE_NEXT);
- }
-
- @Override
- public void run() {
- fViewer.showNextResult();
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/ShowPreviousResultAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/ShowPreviousResultAction.java
deleted file mode 100644
index 9b461d47f48..00000000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/ShowPreviousResultAction.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import org.eclipse.jface.action.Action;
-
-import org.eclipse.ui.IWorkbenchCommandConstants;
-
-/**
- * @deprecated old search
- */
-@Deprecated
-class ShowPreviousResultAction extends Action {
-
- private SearchResultViewer fViewer;
-
- public ShowPreviousResultAction(SearchResultViewer viewer) {
- super(SearchMessages.SearchResultView_showPrev_text);
- SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_PREV);
- setToolTipText(SearchMessages.SearchResultView_showPrev_tooltip);
- setActionDefinitionId(IWorkbenchCommandConstants.NAVIGATE_PREVIOUS);
- fViewer= viewer;
- }
-
- @Override
- public void run() {
- fViewer.showPreviousResult();
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/ShowSearchAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/ShowSearchAction.java
deleted file mode 100644
index ef92309ae93..00000000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/ShowSearchAction.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import org.eclipse.jface.action.Action;
-
-/**
- * @deprecated old search
- */
-@Deprecated
-class ShowSearchAction extends Action {
- private Search fSearch;
-
- /**
- * Create a new instance of this class.
- *
- * @param search the search
- */
- public ShowSearchAction(Search search) {
- fSearch= search;
- String desc= search.getShortDescription();
- setText(desc);
- setToolTipText(desc);
- setImageDescriptor(search.getImageDescriptor());
- }
- /**
- * Invoke the resource wizard selection wizard
- */
- @Override
- public void run() {
- if (fSearch != SearchManager.getDefault().getCurrentSearch())
- SearchManager.getDefault().setCurrentSearch(fSearch);
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/ShowSearchesAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/ShowSearchesAction.java
deleted file mode 100644
index 16889b7bc88..00000000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/ShowSearchesAction.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.swt.graphics.Image;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.window.Window;
-
-import org.eclipse.ui.dialogs.ListDialog;
-
-
-/**
- * Invoke the resource creation wizard selection Wizard.
- * This action will retarget to the active view.
- * @deprecated old search
- */
-@Deprecated
-class ShowSearchesAction extends Action {
-
- private static final class SearchesLabelProvider extends LabelProvider {
-
- private ArrayList<Image> fImages= new ArrayList<>();
-
- @Override
- public String getText(Object element) {
- if (!(element instanceof ShowSearchAction))
- return ""; //$NON-NLS-1$
- return ((ShowSearchAction)element).getText();
- }
- @Override
- public Image getImage(Object element) {
- if (!(element instanceof ShowSearchAction))
- return null;
-
- ImageDescriptor imageDescriptor= ((ShowSearchAction)element).getImageDescriptor();
- if (imageDescriptor == null)
- return null;
-
- Image image= imageDescriptor.createImage();
- fImages.add(image);
-
- return image;
- }
-
- @Override
- public void dispose() {
- Iterator<Image> iter= fImages.iterator();
- while (iter.hasNext())
- iter.next().dispose();
-
- fImages= null;
- }
- }
-
- /**
- * Create a new instance of this class
- */
- public ShowSearchesAction() {
- super(SearchMessages.ShowOtherSearchesAction_label);
- setToolTipText(SearchMessages.ShowOtherSearchesAction_tooltip);
- }
- /*
- * Overrides method from Action
- */
- @Override
- public void run() {
- run(false);
- }
-
- public void run(boolean showAll) {
- Iterator<Search> iter= SearchManager.getDefault().getPreviousSearches().iterator();
- int cutOffSize;
- if (showAll)
- cutOffSize= 0;
- else
- cutOffSize= SearchDropDownAction.RESULTS_IN_DROP_DOWN;
- int size= SearchManager.getDefault().getPreviousSearches().size() - cutOffSize;
- Search selectedSearch= SearchManager.getDefault().getCurrentSearch();
- Action selectedAction = null;
- ArrayList<Action> input= new ArrayList<>(size);
- int i= 0;
- while (iter.hasNext()) {
- Search search= iter.next();
- if (i++ < cutOffSize)
- continue;
- Action action= new ShowSearchAction(search);
- input.add(action);
- if (selectedSearch == search)
- selectedAction= action;
- }
-
- // Open a list dialog.
- String title;
- String message;
- if (showAll) {
- title= SearchMessages.PreviousSearchesDialog_title;
- message= SearchMessages.PreviousSearchesDialog_message;
- }
- else {
- title= SearchMessages.OtherSearchesDialog_title;
- message= SearchMessages.OtherSearchesDialog_message;
- }
-
- LabelProvider labelProvider=new SearchesLabelProvider();
-
- ListDialog dlg= new ListDialog(SearchPlugin.getActiveWorkbenchShell());
- dlg.setInput(input);
- dlg.setTitle(title);
- dlg.setContentProvider(ArrayContentProvider.getInstance());
- dlg.setLabelProvider(labelProvider);
- dlg.setMessage(message);
- if (selectedAction != null) {
- Object[] selected= new Object[1];
- selected[0]= selectedAction;
- dlg.setInitialSelections(selected);
- }
- if (dlg.open() == Window.OK) {
- List<Object> result= Arrays.asList(dlg.getResult());
- if (result != null && result.size() == 1) {
- ((ShowSearchAction)result.get(0)).run();
- }
- }
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SortDropDownAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SortDropDownAction.java
deleted file mode 100644
index 6d843df2483..00000000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SortDropDownAction.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IMenuCreator;
-import org.eclipse.jface.viewers.ViewerSorter;
-
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.model.WorkbenchViewerSorter;
-
-/**
- * Drop down action that holds the currently registered sort actions.
- * @deprecated old search
- */
-@Deprecated
-class SortDropDownAction extends Action implements IMenuCreator {
-
- // Persistance tags.
- private static final String TAG_SORTERS= "sorters"; //$NON-NLS-1$
- private static final String TAG_DEFAULT_SORTERS= "defaultSorters"; //$NON-NLS-1$
- private static final String TAG_ELEMENT= "element"; //$NON-NLS-1$
- private static final String TAG_PAGE_ID= "pageId"; //$NON-NLS-1$
- private static final String TAG_SORTER_ID= "sorterId"; //$NON-NLS-1$
-
- private static Map<String, SorterDescriptor> fgLastCheckedForType= new HashMap<>(5);
-
- private SearchResultViewer fViewer;
- private String fPageId;
- private Menu fMenu;
- private Map<String, SorterDescriptor> fLastCheckedForType;
-
- public SortDropDownAction(SearchResultViewer viewer) {
- super(SearchMessages.SortDropDownAction_label);
- SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_SORT);
- fViewer= viewer;
- setToolTipText(SearchMessages.SortDropDownAction_tooltip);
- setMenuCreator(this);
- fLastCheckedForType= new HashMap<>(5);
- }
-
- @Override
- public void dispose() {
- if (fMenu != null && !fMenu.isDisposed())
- fMenu.dispose();
- fMenu= null;
- }
-
- @Override
- public Menu getMenu(Control parent) {
- return null;
- }
-
- void setPageId(String pageId) {
- fPageId= pageId;
- SorterDescriptor sorterDesc= fLastCheckedForType.get(pageId);
- if (sorterDesc == null)
- sorterDesc= fgLastCheckedForType.get(pageId);
- if (sorterDesc == null)
- sorterDesc= findSorter(fPageId);
- if (sorterDesc != null) {
- setChecked(sorterDesc);
- fViewer.setSorter(sorterDesc.createObject());
- } else {
- // Use default sort workbench viewer sorter
- fViewer.setSorter(new WorkbenchViewerSorter());
- }
- }
-
- @Override
- public Menu getMenu(final Menu parent) {
- dispose(); // ensure old menu gets disposed
-
- fMenu= new Menu(parent);
-
- Iterator<SorterDescriptor> iter= SearchPlugin.getDefault().getSorterDescriptors().iterator();
- while (iter.hasNext()) {
- Object value= fLastCheckedForType.get(fPageId);
- final String checkedId;
- if (value instanceof SorterDescriptor)
- checkedId= ((SorterDescriptor)value).getId();
- else
- checkedId= ""; //$NON-NLS-1$
-
- final SorterDescriptor sorterDesc= iter.next();
- if (!sorterDesc.getPageId().equals(fPageId) && !sorterDesc.getPageId().equals("*")) //$NON-NLS-1$
- continue;
- final ViewerSorter sorter= sorterDesc.createObject();
- if (sorter != null) {
- final Action action= new Action() {
- @Override
- public void run() {
- if (!checkedId.equals(sorterDesc.getId())) {
- SortDropDownAction.this.setChecked(sorterDesc);
- BusyIndicator.showWhile(parent.getDisplay(), () -> fViewer.setSorter(sorter));
- }
- }
- };
- action.setText(sorterDesc.getLabel());
- action.setImageDescriptor(sorterDesc.getImage());
- action.setToolTipText(sorterDesc.getToolTipText());
- action.setChecked(checkedId.equals(sorterDesc.getId()));
- addActionToMenu(fMenu, action);
- }
- }
- return fMenu;
- }
-
- protected void addActionToMenu(Menu parent, Action action) {
- ActionContributionItem item= new ActionContributionItem(action);
- item.fill(parent, -1);
- }
-
- @Override
- public void run() {
- // nothing to do
- }
-
- private SorterDescriptor findSorter(String pageId) {
- Iterator<SorterDescriptor> iter= SearchPlugin.getDefault().getSorterDescriptors().iterator();
- while (iter.hasNext()) {
- SorterDescriptor sorterDesc= iter.next();
- if (sorterDesc.getPageId().equals(pageId) || sorterDesc.getPageId().equals("*")) //$NON-NLS-1$
- return sorterDesc;
- }
- return null;
- }
-
- private SorterDescriptor getSorter(String sorterId) {
- Iterator<SorterDescriptor> iter= SearchPlugin.getDefault().getSorterDescriptors().iterator();
- while (iter.hasNext()) {
- SorterDescriptor sorterDesc= iter.next();
- if (sorterDesc.getId().equals(sorterId))
- return sorterDesc;
- }
- return null;
- }
-
- private void setChecked(SorterDescriptor sorterDesc) {
- fLastCheckedForType.put(fPageId, sorterDesc);
- fgLastCheckedForType.put(fPageId, sorterDesc);
- }
-
- /**
- * Disposes this action's menu and returns a new unused instance.
- * @return the action
- */
- SortDropDownAction renew() {
- SortDropDownAction action= new SortDropDownAction(fViewer);
- action.fLastCheckedForType= fLastCheckedForType;
- action.fPageId= fPageId;
- dispose();
- return action;
- }
-
- //--- Persistency -------------------------------------------------
-
- void restoreState(IMemento memento) {
- if (fLastCheckedForType.isEmpty())
- restoreState(memento, fLastCheckedForType, TAG_SORTERS);
- if (fgLastCheckedForType.isEmpty())
- restoreState(memento, fgLastCheckedForType, TAG_DEFAULT_SORTERS);
- }
-
- private void restoreState(IMemento memento, Map<String, SorterDescriptor> map, String mapName) {
- memento= memento.getChild(mapName);
- if (memento == null)
- return;
- IMemento[] mementoElements= memento.getChildren(TAG_ELEMENT);
- for (IMemento mementoElement : mementoElements) {
- String pageId= mementoElement.getString(TAG_PAGE_ID);
- String sorterId= mementoElement.getString(TAG_SORTER_ID);
- SorterDescriptor sorterDesc= getSorter(sorterId);
- if (sorterDesc != null)
- map.put(pageId, sorterDesc);
- }
- }
-
- void saveState(IMemento memento) {
- saveState(memento, fgLastCheckedForType, TAG_DEFAULT_SORTERS);
- saveState(memento, fLastCheckedForType, TAG_SORTERS);
- }
-
- private void saveState(IMemento memento, Map<String, SorterDescriptor> map, String mapName) {
- Iterator<Entry<String, SorterDescriptor>> iter= map.entrySet().iterator();
- memento= memento.createChild(mapName);
- while (iter.hasNext()) {
- IMemento mementoElement= memento.createChild(TAG_ELEMENT);
- Entry<String, SorterDescriptor> entry= iter.next();
- mementoElement.putString(TAG_PAGE_ID, entry.getKey());
- mementoElement.putString(TAG_SORTER_ID, entry.getValue().getId());
- }
- }
-
- int getSorterCount() {
- int count= 0;
- Iterator<SorterDescriptor> iter= SearchPlugin.getDefault().getSorterDescriptors().iterator();
- while (iter.hasNext()) {
- SorterDescriptor sorterDesc= iter.next();
- if (sorterDesc.getPageId().equals(fPageId) || sorterDesc.getPageId().equals("*")) //$NON-NLS-1$
- count++;
- }
- return count;
- }
-}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileLabelProvider.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileLabelProvider.java
deleted file mode 100644
index 73fa6512785..00000000000
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileLabelProvider.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.internal.ui.util;
-
-
-import java.text.MessageFormat;
-
-import org.eclipse.swt.graphics.Image;
-
-import org.eclipse.core.runtime.IPath;
-
-import org.eclipse.core.resources.IResource;
-
-import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.LabelProvider;
-
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
-
-import org.eclipse.search.internal.ui.SearchMessages;
-import org.eclipse.search.ui.ISearchResultViewEntry;
-
-/**
- * @deprecated Old search view
- */
-@Deprecated
-public class FileLabelProvider extends LabelProvider {
-
- public static final int SHOW_LABEL= 1;
- public static final int SHOW_LABEL_PATH= 2;
- public static final int SHOW_PATH_LABEL= 3;
- public static final int SHOW_PATH= 4;
-
- private static final String fgSeparatorFormat= SearchMessages.FileLabelProvider_dashSeparated;
-
- private WorkbenchLabelProvider fLabelProvider;
- private ILabelDecorator fDecorator;
-
- private int fOrder;
- private Object[] fArgs= new String[2];
-
- public FileLabelProvider(int orderFlag) {
- fDecorator= PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator();
- fLabelProvider= new WorkbenchLabelProvider();
- fOrder= orderFlag;
- }
-
- public void setOrder(int orderFlag) {
- fOrder= orderFlag;
- }
-
- @Override
- public String getText(Object element) {
- if (!(element instanceof ISearchResultViewEntry))
- return ""; //$NON-NLS-1$
-
- IResource resource= ((ISearchResultViewEntry) element).getResource();
- String text= null;
-
- if (resource == null || !resource.exists())
- text= SearchMessages.SearchResultView_removed_resource;
-
- else {
- IPath path= resource.getFullPath().removeLastSegments(1);
- if (path.getDevice() == null)
- path= path.makeRelative();
- if (fOrder == SHOW_LABEL || fOrder == SHOW_LABEL_PATH) {
- text= fLabelProvider.getText(resource);
- if (path != null && fOrder == SHOW_LABEL_PATH) {
- fArgs[0]= text;
- fArgs[1]= path.toString();
- text= MessageFormat.format(fgSeparatorFormat, fArgs);
- }
- } else {
- if (path != null)
- text= path.toString();
- else
- text= ""; //$NON-NLS-1$
- if (fOrder == SHOW_PATH_LABEL) {
- fArgs[0]= text;
- fArgs[1]= fLabelProvider.getText(resource);
- text= MessageFormat.format(fgSeparatorFormat, fArgs);
- }
- }
- }
-
- // Do the decoration
- if (fDecorator != null) {
- String decoratedText= fDecorator.decorateText(text, resource);
- if (decoratedText != null)
- return decoratedText;
- }
- return text;
- }
-
- @Override
- public Image getImage(Object element) {
- if (!(element instanceof ISearchResultViewEntry))
- return null;
-
- IResource resource= ((ISearchResultViewEntry) element).getResource();
- Image image= fLabelProvider.getImage(resource);
- if (fDecorator != null) {
- Image decoratedImage= fDecorator.decorateImage(image, resource);
- if (decoratedImage != null)
- return decoratedImage;
- }
- return image;
- }
-
- @Override
- public void dispose() {
- super.dispose();
- fLabelProvider.dispose();
- }
-
- @Override
- public boolean isLabelProperty(Object element, String property) {
- return fLabelProvider.isLabelProperty(element, property);
- }
-
- @Override
- public void removeListener(ILabelProviderListener listener) {
- super.removeListener(listener);
- fLabelProvider.removeListener(listener);
- }
-
- @Override
- public void addListener(ILabelProviderListener listener) {
- super.addListener(listener);
- fLabelProvider.addListener(listener);
- }
-}

Back to the top