Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDani Megert2001-11-08 12:12:16 -0500
committerDani Megert2001-11-08 12:12:16 -0500
commit79102ed4ba9e853441a62deeabab9df7908b4ecb (patch)
treedc7ecd99bc77b366d854a3b33e596ea0371a58ad
parentd0ef2940d9f7d4b7c115b38fbd10f65b8ae920ee (diff)
downloadeclipse.platform.text-79102ed4ba9e853441a62deeabab9df7908b4ecb.tar.gz
eclipse.platform.text-79102ed4ba9e853441a62deeabab9df7908b4ecb.tar.xz
eclipse.platform.text-79102ed4ba9e853441a62deeabab9df7908b4ecb.zip
Fixed 5356: Search Result descriptions don't use singular
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/Search.java25
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.properties5
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultView.java46
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchOperation.java10
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchResultCollector.java3
-rw-r--r--org.eclipse.search/search/org/eclipse/search/ui/ISearchResultView.java45
6 files changed, 102 insertions, 32 deletions
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
index bf807a93d..9189eed8e 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/Search.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/Search.java
@@ -27,7 +27,8 @@ import org.eclipse.search.ui.ISearchResultViewEntry;
class Search extends Object {
private String fPageId;
- private String fDescription;
+ private String fSingularLabel;
+ private String fPluralLabelPattern;
private ImageDescriptor fImageDescriptor;
private ILabelProvider fLabelProvider;
private ArrayList fResults;
@@ -37,32 +38,38 @@ class Search extends Object {
private IRunnableWithProgress fOperation;
- public Search(String pageId, String description, ILabelProvider labelProvider, ImageDescriptor imageDescriptor, IAction gotoMarkerAction, IContextMenuContributor contextMenuContributor, IGroupByKeyComputer groupByKeyComputer, IRunnableWithProgress operation) {
+ public Search(String pageId, String singularLabel, String pluralLabelPattern, ILabelProvider labelProvider, ImageDescriptor imageDescriptor, IAction gotoMarkerAction, IContextMenuContributor contextMenuContributor, IGroupByKeyComputer groupByKeyComputer, IRunnableWithProgress operation) {
fPageId= pageId;
- fDescription= description;
+ 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.
*/
String getFullDescription() {
- if (fDescription == null)
- return ""; //$NON-NLS-1$
+ if (fSingularLabel != null && getItemCount() == 1)
+ return fSingularLabel;
// try to replace "{0}" with the match count
- int i= fDescription.lastIndexOf("{0}"); //$NON-NLS-1$
+ int i= fPluralLabelPattern.lastIndexOf("{0}"); //$NON-NLS-1$
if (i < 0)
- return fDescription;
+ return fPluralLabelPattern;
else
- return fDescription.substring(0, i) + getItemCount()+ fDescription.substring(Math.min(i + 3, fDescription.length()));
+ 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 ...
@@ -70,8 +77,6 @@ class Search extends Object {
* {0} will be replaced by the match count.
*/
String getShortDescription() {
- if (fDescription == null)
- return ""; //$NON-NLS-1$
String text= getFullDescription();
int separatorPos= text.indexOf(" - "); //$NON-NLS-1$
if (separatorPos < 1)
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.properties b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.properties
index d73695b9c..16a7d2ea8 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.properties
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.properties
@@ -101,7 +101,10 @@ PreviousSearchesDialog.title= Previous Searches
PreviousSearchesDialog.message= &Select one of the searches
# The first argument will be replaced by the pattern, the second by the count and the last by the scope
-TextSearchOperation.descriptionPostfix= "{0}" - {1} Occurrences in {2}
+TextSearchOperation.singularLabelPostfix= "{0}" - 1 Occurrence in {1}
+TextSearchOperation.pluralLabelPatternPostfix= "{0}" - {1} Occurrences in {2}
+
+TypedResourceVisitor.unknownResourceType= Unknown resource type
OpenSearchDialogAction.label= Search
OpenSearchDialogAction.tooltip= Search
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultView.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultView.java
index caffbf06a..2327e3d4e 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultView.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultView.java
@@ -163,32 +163,52 @@ public class SearchResultView extends ViewPart implements ISearchResultView {
return fViewer.getSelection();
}
+ /**
+ * Implements method from ISearchResultView
+ * @deprecated As of build > 20011107, replaced by the new version with additonal parameter
+ */
+ 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
*/
public void searchStarted(
- String pageId,
- String label,
- ImageDescriptor imageDescriptor,
+ String pageId,
+ String singularLabel,
+ String pluralLabelPattern,
+ ImageDescriptor imageDescriptor,
IContextMenuContributor contributor,
- ILabelProvider labelProvider,
- IAction gotoAction,
- IGroupByKeyComputer groupByKeyComputer,
+ ILabelProvider labelProvider,
+ IAction gotoAction,
+ IGroupByKeyComputer groupByKeyComputer,
IRunnableWithProgress operation) {
-
+
+
Assert.isNotNull(pageId);
- Assert.isNotNull(label);
+ Assert.isNotNull(pluralLabelPattern);
Assert.isNotNull(gotoAction);
-
+
fResponse= new HashMap(500);
setGotoMarkerAction(gotoAction);
-
+
fgLabelProviders.put(pageId, labelProvider);
-
+
SearchManager.getDefault().addNewSearch(
new Search(
pageId,
- label,
+ singularLabel,
+ pluralLabelPattern,
null,
imageDescriptor,
fViewer.getGotoMarkerAction(),
@@ -196,7 +216,7 @@ public class SearchResultView extends ViewPart implements ISearchResultView {
groupByKeyComputer,
operation));
};
-
+
/*
* Implements method from ISearchResultView
*/
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchOperation.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchOperation.java
index 479ecb210..4c33134c3 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchOperation.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchOperation.java
@@ -53,9 +53,13 @@ public class TextSearchOperation extends WorkspaceModifyOperation {
TextSearchEngine engine= new TextSearchEngine();
engine.search(fWorkspace, fPattern, fOptions, fScope, fCollector);
}
-
- String getDescription() {
- return SearchMessages.getFormattedString("TextSearchOperation.descriptionPostfix", new String[] {fPattern, "{0}", fScope.getDescription()}); //$NON-NLS-2$ //$NON-NLS-1$
+
+ String getSingularLabel() {
+ return SearchMessages.getFormattedString("TextSearchOperation.singularLabelPostfix", new String[] {fPattern, fScope.getDescription()}); //$NON-NLS-2$ //$NON-NLS-1$
+ }
+
+ String getPluralLabelPattern() {
+ return SearchMessages.getFormattedString("TextSearchOperation.pluralLabelPatternPostfix", new String[] {fPattern, "{0}", fScope.getDescription()}); //$NON-NLS-2$ //$NON-NLS-1$
}
ImageDescriptor getImageDescriptor() {
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchResultCollector.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchResultCollector.java
index 7823f871b..17ddcb3e0 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchResultCollector.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchResultCollector.java
@@ -51,7 +51,8 @@ public class TextSearchResultCollector implements ITextSearchResultCollector {
if (fView != null) {
fView.searchStarted(
TextSearchPage.EXTENSION_POINT_ID,
- fOperation.getDescription(),
+ fOperation.getSingularLabel(),
+ fOperation.getPluralLabelPattern(),
fOperation.getImageDescriptor(),
null,
new FileLabelProvider(FileLabelProvider.SHOW_LABEL_PATH),
diff --git a/org.eclipse.search/search/org/eclipse/search/ui/ISearchResultView.java b/org.eclipse.search/search/org/eclipse/search/ui/ISearchResultView.java
index 2d3e22fd5..b744089da 100644
--- a/org.eclipse.search/search/org/eclipse/search/ui/ISearchResultView.java
+++ b/org.eclipse.search/search/org/eclipse/search/ui/ISearchResultView.java
@@ -48,15 +48,16 @@ public interface ISearchResultView extends IViewPart {
* @param pageId the id of the search page which started the search
* @param label the label to be used for this search occurrence
* @param imageDescriptor the image descriptor to be used for this search occurrence,
- * or <code>null</code> if this search should not have an image
+ * or <code>null</code> if this search should not have an image
* @param contributor the context menu contributor
- * or <code>null</code> if no context menu is contributed
+ * or <code>null</code> if no context menu is contributed
* @param labelProvider the label provider used by this search result view
- * or <code>null</code> if the default provider should be used.
- * The default label provider shows the resource name and the corresponding image.
+ * or <code>null</code> if the default provider should be used.
+ * The default label provider shows the resource name and the corresponding image.
* @param gotoAction the action used by the view to go to a marker
* @param groupByKeyComputer the computer used by the view to compute the key for a marker
* @param operation the runnable used by the view to repeat the search
+ * @deprecated As of build > 20011107, replaced by the new version with additonal parameter
*/
public void searchStarted(
String pageId,
@@ -69,6 +70,42 @@ public interface ISearchResultView extends IViewPart {
IRunnableWithProgress operation);
/**
+ * Informs the view that a search has started.
+ * Provides all necessary information to create an entry in the search result
+ * view.
+ * If every match should show up in the search result view then the match
+ * itself can be used as key.
+ *
+ * @param pageId the id of the search page which started the search
+ * @param singularLabel the label to be used for this search occurrence
+ * if there is one match
+ * or <code>null</code> if the pluralLabelPattern should be used
+ * @param pluralLabelPattern the label pattern to be used for this search occurrence
+ * if there are more than one matches or none.
+ * This string may contain {0} which will be replace by the match count
+ * @param imageDescriptor the image descriptor to be used for this search occurrence,
+ * or <code>null</code> if this search should not have an image
+ * @param contributor the context menu contributor
+ * or <code>null</code> if no context menu is contributed
+ * @param labelProvider the label provider used by this search result view
+ * or <code>null</code> if the default provider should be used.
+ * The default label provider shows the resource name and the corresponding image.
+ * @param gotoAction the action used by the view to go to a marker
+ * @param groupByKeyComputer the computer used by the view to compute the key for a marker
+ * @param operation the runnable used by the view to repeat the search
+ */
+ public void searchStarted(
+ String pageId,
+ String singularLabel,
+ String pluralLabelPattern,
+ ImageDescriptor imageDescriptor,
+ IContextMenuContributor contributor,
+ ILabelProvider labelProvider,
+ IAction gotoAction,
+ IGroupByKeyComputer groupByKeyComputer,
+ IRunnableWithProgress operation);
+
+ /**
* Informs the view that the search has finished.
* This method must also be called in case of the search
* fails or has been canceled.

Back to the top