diff options
Diffstat (limited to 'org.eclipse.search/new search/org/eclipse/search2/internal/ui/RemoveAllSearchesAction.java')
-rw-r--r-- | org.eclipse.search/new search/org/eclipse/search2/internal/ui/RemoveAllSearchesAction.java | 35 |
1 files changed, 32 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); } } } |