KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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 import java.util.Arrays JavaDoc;
15 import java.util.List JavaDoc;
16
17 import org.eclipse.jface.action.Action;
18 import org.eclipse.jface.window.Window;
19 import org.eclipse.search.internal.ui.SearchPlugin;
20 import org.eclipse.search.ui.ISearchQuery;
21 import org.eclipse.search.ui.ISearchResult;
22
23
24
25 /**
26  * Invoke the resource creation wizard selection Wizard.
27  * This action will retarget to the active view.
28  */

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

36     public ShowSearchesAction(SearchView searchView) {
37         super(SearchMessages.ShowSearchesAction_label);
38         setToolTipText(SearchMessages.ShowSearchesAction_tooltip);
39         fSearchView= searchView;
40     }
41      
42     public void run() {
43         QueryManager sm= InternalSearchUI.getInstance().getSearchManager();
44         ISearchQuery[] queries= sm.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         SearchesDialog dlg= new SearchesDialog(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             List JavaDoc result= Arrays.asList(dlg.getResult());
62             if (result != null && result.size() == 1) {
63                 fSearchView.showSearchResult((ISearchResult) result.get(0));
64             }
65         }
66
67     }
68 }
69
Popular Tags