Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Roth2016-04-17 01:20:02 +0000
committerRobert Roth2021-02-01 11:46:42 +0000
commitb7afb46b4a3ad50a4f9107cf6c0197864233f491 (patch)
tree8c489c86c166fb6fd5ea2e5f9292bff747df7131
parent013925a7e22618bef7ed8e968ee4a935d8a61d68 (diff)
downloadeclipse.platform.text-b7afb46b4a3ad50a4f9107cf6c0197864233f491.tar.gz
eclipse.platform.text-b7afb46b4a3ad50a4f9107cf6c0197864233f491.tar.xz
eclipse.platform.text-b7afb46b4a3ad50a4f9107cf6c0197864233f491.zip
Changes included: * ask for confirmation on clear search history Change-Id: I99d48be2a1e5fd1c775aef62a10ddca0d473e3b1 Signed-off-by: Robert Roth <robert.roth.off@gmail.com>
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/RemoveAllSearchesAction.java35
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchMessages.java3
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchMessages.properties2
3 files changed, 37 insertions, 3 deletions
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/RemoveAllSearchesAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/RemoveAllSearchesAction.java
index 4869e854c0a..39b1bcd8c9c 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/RemoveAllSearchesAction.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/RemoveAllSearchesAction.java
@@ -10,11 +10,15 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Robert Roth (robert.roth.off@gmail.com) - Bug 487093: You can too easily clear the search history
*******************************************************************************/
package org.eclipse.search2.internal.ui;
import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.search.internal.ui.SearchPlugin;
import org.eclipse.search.ui.ISearchQuery;
import org.eclipse.search.ui.NewSearchUI;
@@ -26,12 +30,37 @@ class RemoveAllSearchesAction extends Action {
setToolTipText(SearchMessages.RemoveAllSearchesAction_tooltip);
}
+ /**
+ * Returns whether to ask for confirmation on search history clear. Consults the preference and prompts the user if
+ * necessary.
+ *
+ * @return <code>true</code> if clear search history should be confirmed by user, and <code>false</code>
+ * otherwise.
+ */
+ private boolean promptForConfirmation() {
+
+ MessageDialog dialog= new MessageDialog(SearchPlugin.getActiveWorkbenchShell(),
+ SearchMessages.RemoveAllSearchesAction_tooltip, // title
+ null, // image
+ SearchMessages.RemoveAllSearchesAction_confirm_message, // message
+ MessageDialog.CONFIRM,
+ new String[] {SearchMessages.RemoveAllSearchesAction_confirm_label, IDialogConstants.CANCEL_LABEL},
+ IDialogConstants.OK_ID);
+
+ dialog.open();
+ if (dialog.getReturnCode() != IDialogConstants.OK_ID) {
+ return false;
+ }
+ return true;
+ }
+
@Override
public void run() {
ISearchQuery[] queries= NewSearchUI.getQueries();
- for (ISearchQuery querie : queries) {
- if (!NewSearchUI.isQueryRunning(querie)) {
- InternalSearchUI.getInstance().removeQuery(querie);
+ if (promptForConfirmation()) {
+ for (ISearchQuery querie : queries) {
+ if (!NewSearchUI.isQueryRunning(querie))
+ InternalSearchUI.getInstance().removeQuery(querie);
}
}
}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchMessages.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchMessages.java
index 7a3de33bda0..75adbe4b6a2 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchMessages.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchMessages.java
@@ -10,6 +10,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Robert Roth (robert.roth.off@gmail.com) - Bug 487093: You can too easily clear the search history
*******************************************************************************/
package org.eclipse.search2.internal.ui;
@@ -102,5 +103,7 @@ public final class SearchMessages extends NLS {
public static String RetrieverAction_empty_selection;
public static String RetrieverAction_error_title;
public static String RetrieverAction_error_message;
+ public static String RemoveAllSearchesAction_confirm_label;
+ public static String RemoveAllSearchesAction_confirm_message;
}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchMessages.properties b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchMessages.properties
index 8a92054c80b..6cf4d5eaad4 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchMessages.properties
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchMessages.properties
@@ -33,6 +33,8 @@ RemoveAllSearchesAction_label=Clear History
RetrieverAction_dialog_title=Text Search
RetrieverAction_error_message=The search could not be initialized.
RemoveAllSearchesAction_tooltip=Clear Search History
+RemoveAllSearchesAction_confirm_label=&Clear History
+RemoveAllSearchesAction_confirm_message=Are you sure you want to clear the search history?
RetrieverAction_empty_selection=Could not evaluate a text selection.
RemoveAllMatchesAction_label=Remove All Matches
RemoveAllMatchesAction_tooltip=Remove All Matches

Back to the top