blob: a78f2385e363262c72f7af0f06b12918f7a15c21 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/*******************************************************************************
* Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.search2.internal.ui;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.search.internal.ui.SearchPluginImages;
import org.eclipse.search.ui.ISearchQuery;
import org.eclipse.search.ui.ISearchResult;
import org.eclipse.search.ui.NewSearchUI;
class SearchAgainAction extends Action {
private SearchView fView;
public SearchAgainAction(SearchView view) {
setText(SearchMessages.SearchAgainAction_label);
setToolTipText(SearchMessages.SearchAgainAction_tooltip);
SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_AGAIN);
fView= view;
}
public void run() {
final ISearchResult search= fView.getCurrentSearchResult();
if (search != null) {
ISearchQuery query= search.getQuery();
NewSearchUI.cancelQuery(query);
if (query.canRerun()) {
if (query.canRunInBackground())
NewSearchUI.runQueryInBackground(query, fView);
else {
Shell shell= fView.getSite().getShell();
ProgressMonitorDialog pmd= new ProgressMonitorDialog(shell);
IStatus status= NewSearchUI.runQueryInForeground(pmd, query, fView);
if (!status.isOK() && status.getSeverity() != IStatus.CANCEL) {
ErrorDialog.openError(shell, SearchMessages.SearchAgainAction_Error_title, SearchMessages.SearchAgainAction_Error_message, status);
}
}
}
}
}
}
|