| /******************************************************************************* |
| * Copyright (c) 2000, 2003 IBM Corporation and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Common Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/cpl-v10.html |
| * |
| * Contributors: |
| * IBM Corporation - initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.search2.internal.ui; |
| |
| import java.util.ArrayList; |
| |
| import org.eclipse.jface.action.Action; |
| import org.eclipse.jface.resource.ImageDescriptor; |
| |
| import org.eclipse.search.ui.ISearchQuery; |
| import org.eclipse.search.ui.ISearchResult; |
| |
| /** |
| * Invoke the resource creation wizard selection Wizard. |
| * This action will retarget to the active view. |
| */ |
| class ShowSearchesAction extends Action { |
| private SearchView fSearchView; |
| |
| /*private static final class SearchesLabelProvider extends LabelProvider { |
| |
| private ArrayList fImages= new ArrayList(); |
| |
| public String getText(Object element) { |
| if (!(element instanceof ShowSearchAction)) |
| return ""; //$NON-NLS-1$ |
| return ((ShowSearchAction)element).getText(); |
| } |
| public Image getImage(Object element) { |
| if (!(element instanceof ShowSearchAction)) |
| return null; |
| |
| ImageDescriptor imageDescriptor= ((ShowSearchAction)element).getImageDescriptor(); |
| if (imageDescriptor == null) |
| return null; |
| |
| Image image= imageDescriptor.createImage(); |
| fImages.add(image); |
| |
| return image; |
| } |
| |
| public void dispose() { |
| Iterator iter= fImages.iterator(); |
| while (iter.hasNext()) |
| ((Image)iter.next()).dispose(); |
| |
| fImages= null; |
| } |
| }*/ |
| |
| /** |
| * Create a new instance of this class |
| */ |
| public ShowSearchesAction(SearchView searchView) { |
| super(SearchMessages.getString("ShowSearchesAction.label")); //$NON-NLS-1$ |
| setToolTipText(SearchMessages.getString("ShowSearchesAction.tooltip")); //$NON-NLS-1$ |
| fSearchView= searchView; |
| } |
| |
| public void run() { |
| QueryManager sm= InternalSearchUI.getInstance().getSearchManager(); |
| ISearchQuery[] queries= sm.getQueries(); |
| |
| ArrayList input= new ArrayList(); |
| int i= 0; |
| for (int j= 0; j < queries.length; j++) { |
| ISearchResult search= queries[i].getSearchResult(); |
| String label= search.getLabel(); |
| String tooltip= search.getTooltip(); |
| ImageDescriptor image= search.getImageDescriptor(); |
| ShowSearchAction action= new ShowSearchAction(fSearchView, search, label, image, tooltip ); |
| input.add(action); |
| } |
| } |
| } |