01: /*******************************************************************************
02: * Copyright (c) 2004, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM - Initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.ide.actions;
11:
12: import org.eclipse.jface.action.Action;
13: import org.eclipse.ui.IWorkbenchWindow;
14: import org.eclipse.ui.IWorkingSet;
15: import org.eclipse.ui.IWorkingSetManager;
16: import org.eclipse.ui.actions.ActionFactory;
17: import org.eclipse.ui.application.IActionBarConfigurer;
18: import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog;
19: import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
20:
21: /**
22: * This action asks the user to select a working set, and then creates
23: * and runs a corresponding BuildSetAction.
24: *
25: * @since 3.0
26: */
27: public class SelectBuildWorkingSetAction extends Action implements
28: ActionFactory.IWorkbenchAction {
29: private IWorkbenchWindow window;
30:
31: private IActionBarConfigurer actionBars;
32:
33: public SelectBuildWorkingSetAction(IWorkbenchWindow window,
34: IActionBarConfigurer actionBars) {
35: super (IDEWorkbenchMessages.SelectWorkingSetAction_text);
36: this .window = window;
37: this .actionBars = actionBars;
38: }
39:
40: private IWorkingSet queryForWorkingSet() {
41: IWorkingSetManager manager = window.getWorkbench()
42: .getWorkingSetManager();
43: IWorkingSetSelectionDialog dialog = manager
44: .createWorkingSetSelectionDialog(window.getShell(),
45: false);
46: dialog.open();
47: IWorkingSet[] sets = dialog.getSelection();
48: //check for cancel
49: if (sets == null || sets.length == 0) {
50: return null;
51: }
52: return sets[0];
53: }
54:
55: public void run() {
56: IWorkingSet set = queryForWorkingSet();
57: if (set != null) {
58: new BuildSetAction(set, window, actionBars).run();
59: }
60: }
61:
62: public void dispose() {
63: }
64:
65: public void setActionBars(IActionBarConfigurer actionBars) {
66: this.actionBars = actionBars;
67: }
68: }
|