1 11 package org.eclipse.ui.internal.ide.actions; 12 13 import org.eclipse.jface.action.Action; 14 import org.eclipse.ui.IWorkbenchWindow; 15 import org.eclipse.ui.IWorkingSet; 16 import org.eclipse.ui.IWorkingSetManager; 17 import org.eclipse.ui.actions.ActionFactory; 18 import org.eclipse.ui.application.IActionBarConfigurer; 19 import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog; 20 import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; 21 22 28 public class SelectBuildWorkingSetAction extends Action implements 29 ActionFactory.IWorkbenchAction { 30 private IWorkbenchWindow window; 31 32 private IActionBarConfigurer actionBars; 33 34 public SelectBuildWorkingSetAction(IWorkbenchWindow window, 35 IActionBarConfigurer actionBars) { 36 super(IDEWorkbenchMessages.SelectWorkingSetAction_text); 37 this.window = window; 38 this.actionBars = actionBars; 39 } 40 41 private IWorkingSet queryForWorkingSet() { 42 IWorkingSetManager manager = window.getWorkbench() 43 .getWorkingSetManager(); 44 IWorkingSetSelectionDialog dialog = manager 45 .createWorkingSetSelectionDialog(window.getShell(), false); 46 dialog.open(); 47 IWorkingSet[] sets = dialog.getSelection(); 48 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 } 69 | Popular Tags |