KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > search2 > internal > ui > ShowSearchHistoryDialogAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.search2.internal.ui;
12
13 import java.util.ArrayList JavaDoc;
14
15 import org.eclipse.jface.action.Action;
16 import org.eclipse.jface.window.Window;
17
18 import org.eclipse.search.ui.ISearchQuery;
19 import org.eclipse.search.ui.ISearchResult;
20 import org.eclipse.search.ui.NewSearchUI;
21
22 import org.eclipse.search.internal.ui.SearchPlugin;
23
24
25
26 /**
27  * Invoke the resource creation wizard selection Wizard.
28  * This action will retarget to the active view.
29  */

30 class ShowSearchHistoryDialogAction extends Action {
31     private SearchView fSearchView;
32
33
34     /*
35      * Create a new instance of this class
36      */

37     public ShowSearchHistoryDialogAction(SearchView searchView) {
38         super(SearchMessages.ShowSearchesAction_label);
39         setToolTipText(SearchMessages.ShowSearchesAction_tooltip);
40         fSearchView= searchView;
41     }
42      
43     public void run() {
44         ISearchQuery[] queries= NewSearchUI.getQueries();
45
46         ArrayList JavaDoc input= new ArrayList JavaDoc();
47         for (int j= 0; j < queries.length; j++) {
48             ISearchResult search= queries[j].getSearchResult();
49             input.add(search);
50         }
51         
52         SearchHistorySelectionDialog dlg= new SearchHistorySelectionDialog(SearchPlugin.getActiveWorkbenchShell(),input);
53         
54         ISearchResult current= fSearchView.getCurrentSearchResult();
55         if (current != null) {
56             Object JavaDoc[] selected= new Object JavaDoc[1];
57             selected[0]= current;
58             dlg.setInitialSelections(selected);
59         }
60         if (dlg.open() == Window.OK) {
61             Object JavaDoc[] result= dlg.getResult();
62             if (result != null && result.length == 1) {
63                 ISearchResult searchResult= (ISearchResult) result[0];
64                 InternalSearchUI.getInstance().showSearchResult(fSearchView, searchResult, dlg.isOpenInNewView());
65             }
66         }
67
68     }
69 }
70
Popular Tags