1 11 12 package org.eclipse.ui.internal.actions; 13 14 import org.eclipse.core.runtime.Assert; 15 import org.eclipse.jface.action.Action; 16 import org.eclipse.jface.dialogs.MessageDialog; 17 import org.eclipse.jface.window.Window; 18 import org.eclipse.jface.wizard.WizardDialog; 19 import org.eclipse.swt.widgets.Shell; 20 import org.eclipse.ui.IWorkingSet; 21 import org.eclipse.ui.IWorkingSetManager; 22 import org.eclipse.ui.PlatformUI; 23 import org.eclipse.ui.actions.WorkingSetFilterActionGroup; 24 import org.eclipse.ui.dialogs.IWorkingSetEditWizard; 25 import org.eclipse.ui.internal.IWorkbenchHelpContextIds; 26 import org.eclipse.ui.internal.WorkbenchMessages; 27 28 33 public class EditWorkingSetAction extends Action { 34 private Shell shell; 35 36 private WorkingSetFilterActionGroup actionGroup; 37 38 44 public EditWorkingSetAction(WorkingSetFilterActionGroup actionGroup, 45 Shell shell) { 46 super(WorkbenchMessages.EditWorkingSetAction_text); 47 Assert.isNotNull(actionGroup); 48 setToolTipText(WorkbenchMessages.EditWorkingSetAction_toolTip); 49 50 this.shell = shell; 51 this.actionGroup = actionGroup; 52 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, 53 IWorkbenchHelpContextIds.EDIT_WORKING_SET_ACTION); 54 } 55 56 61 public void run() { 62 IWorkingSetManager manager = PlatformUI.getWorkbench() 63 .getWorkingSetManager(); 64 IWorkingSet workingSet = actionGroup.getWorkingSet(); 65 66 if (workingSet == null) { 67 setEnabled(false); 68 return; 69 } 70 IWorkingSetEditWizard wizard = manager 71 .createWorkingSetEditWizard(workingSet); 72 if (wizard == null) { 73 String title = WorkbenchMessages.EditWorkingSetAction_error_nowizard_title; 74 String message = WorkbenchMessages.EditWorkingSetAction_error_nowizard_message; 75 MessageDialog.openError(shell, title, message); 76 return; 77 } 78 WizardDialog dialog = new WizardDialog(shell, wizard); 79 dialog.create(); 80 if (dialog.open() == Window.OK) { 81 actionGroup.setWorkingSet(wizard.getSelection()); 82 } 83 } 84 } 85 | Popular Tags |