1 11 package org.eclipse.ui.internal.ide.actions; 12 13 import org.eclipse.core.resources.IProject; 14 import org.eclipse.core.resources.IncrementalProjectBuilder; 15 import org.eclipse.jface.action.Action; 16 import org.eclipse.jface.dialogs.MessageDialog; 17 import org.eclipse.jface.viewers.StructuredSelection; 18 import org.eclipse.swt.widgets.Event; 19 import org.eclipse.swt.widgets.MenuItem; 20 import org.eclipse.ui.IWorkbenchWindow; 21 import org.eclipse.ui.IWorkingSet; 22 import org.eclipse.ui.actions.BuildAction; 23 import org.eclipse.ui.application.IActionBarConfigurer; 24 import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; 25 26 31 public class BuildSetAction extends Action { 32 public static BuildSetAction lastBuilt; 33 34 private IWorkingSet workingSet; 35 36 private IWorkbenchWindow window; 37 38 private IActionBarConfigurer actionBars; 39 40 43 public BuildSetAction(IWorkingSet set, IWorkbenchWindow window, IActionBarConfigurer actionBars) { 44 super(set == null ? "" : set.getLabel(), AS_RADIO_BUTTON); this.window = window; 46 this.actionBars = actionBars; 47 this.workingSet = set; 48 } 49 50 53 public IWorkingSet getWorkingSet() { 54 return workingSet; 55 } 56 57 public void run() { 58 setActionDefinitionId("org.eclipse.ui.project.buildLast"); actionBars.registerGlobalAction(this); 61 62 window.getWorkbench().getWorkingSetManager().addRecentWorkingSet(workingSet); 63 IProject[] projects = BuildUtilities.extractProjects(workingSet.getElements()); 64 if (projects.length == 0) { 65 MessageDialog.openInformation(window.getShell(), 66 IDEWorkbenchMessages.BuildSetAction_noBuildTitle, 67 IDEWorkbenchMessages.BuildSetAction_noProjects); 68 return; 69 } 70 lastBuilt = this; 71 BuildAction build = new BuildAction(window.getShell(), IncrementalProjectBuilder.INCREMENTAL_BUILD); 72 build.selectionChanged(new StructuredSelection(projects)); 73 build.run(); 74 } 75 76 public void runWithEvent(Event event) { 77 if (event.widget instanceof MenuItem) { 80 if (!((MenuItem) event.widget).getSelection()) { 81 return; 82 } 83 } 84 run(); 85 } 86 87 90 public String toString() { 91 return "BuildSetAction(" + workingSet.getName() + ")"; } 93 } 94 | Popular Tags |