KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > search2 > internal > ui > text2 > FindInWorkingSetActionDelegate


1 /*******************************************************************************
2  * Copyright (c) 2006 Wind River Systems 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  * Markus Schorn - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.search2.internal.ui.text2;
13
14 import org.eclipse.core.runtime.CoreException;
15 import org.eclipse.core.runtime.OperationCanceledException;
16
17 import org.eclipse.jface.window.Window;
18
19 import org.eclipse.ui.IWorkbenchPage;
20 import org.eclipse.ui.IWorkingSet;
21 import org.eclipse.ui.IWorkingSetManager;
22 import org.eclipse.ui.PlatformUI;
23 import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog;
24
25 import org.eclipse.search.ui.ISearchQuery;
26 import org.eclipse.search.ui.text.TextSearchQueryProvider;
27
28 import org.eclipse.search2.internal.ui.SearchMessages;
29
30 public class FindInWorkingSetActionDelegate extends FindInRecentScopeActionDelegate {
31
32     public FindInWorkingSetActionDelegate() {
33         super(SearchMessages.FindInWorkingSetActionDelegate_text);
34         setActionDefinitionId("org.eclipse.search.ui.performTextSearchWorkingSet"); //$NON-NLS-1$
35
}
36     
37     protected ISearchQuery createQuery(TextSearchQueryProvider provider, String JavaDoc searchForString) throws CoreException {
38         IWorkbenchPage page= getWorkbenchPage();
39         if (page != null) {
40             IWorkingSetManager manager= PlatformUI.getWorkbench().getWorkingSetManager();
41             IWorkingSetSelectionDialog dialog= manager.createWorkingSetSelectionDialog(page.getWorkbenchWindow().getShell(), true);
42             if (dialog.open() == Window.OK) {
43                 IWorkingSet[] workingSets= dialog.getSelection();
44                 if (workingSets != null) {
45                     return provider.createQuery(searchForString, workingSets);
46                 }
47             }
48         }
49         throw new OperationCanceledException();
50     }
51 }
52
Popular Tags