1 11 package org.eclipse.search2.internal.ui; 12 13 import java.util.ArrayList ; 14 import java.util.Arrays ; 15 import java.util.List ; 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 29 class ShowSearchesAction extends Action { 30 private SearchView fSearchView; 31 32 33 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 input= new ArrayList (); 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 [] selected= new Object [1]; 57 selected[0]= current; 58 dlg.setInitialSelections(selected); 59 } 60 if (dlg.open() == Window.OK) { 61 List 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 |