1 11 package org.eclipse.jdt.internal.ui.workingsets; 12 13 import org.eclipse.jface.viewers.IStructuredSelection; 14 import org.eclipse.jface.wizard.WizardDialog; 15 16 import org.eclipse.ui.IWorkbenchSite; 17 import org.eclipse.ui.IWorkingSet; 18 import org.eclipse.ui.PlatformUI; 19 import org.eclipse.ui.dialogs.IWorkingSetEditWizard; 20 21 import org.eclipse.jdt.ui.actions.SelectionDispatchAction; 22 23 24 public class OpenPropertiesWorkingSetAction extends SelectionDispatchAction { 25 26 public OpenPropertiesWorkingSetAction(IWorkbenchSite site) { 27 super(site); 28 setText(WorkingSetMessages.OpenPropertiesWorkingSetAction_label); 29 setEnabled(false); 30 } 31 32 public void selectionChanged(IStructuredSelection selection) { 33 setEnabled(getWorkingSet(selection) != null); 34 } 35 36 private IWorkingSet getWorkingSet(IStructuredSelection selection) { 37 if (selection.size() != 1) 38 return null; 39 Object element= selection.getFirstElement(); 40 if (!(element instanceof IWorkingSet)) 41 return null; 42 IWorkingSet ws= (IWorkingSet)element; 43 if (!ws.isEditable()) 44 return null; 45 return ws; 46 } 47 48 public void run(IStructuredSelection selection) { 49 IWorkingSet ws= getWorkingSet(selection); 50 if (ws == null) 51 return; 52 IWorkingSetEditWizard wizard= PlatformUI.getWorkbench(). 53 getWorkingSetManager().createWorkingSetEditWizard(ws); 54 WizardDialog dialog= new WizardDialog(getShell(), wizard); 55 dialog.open(); 56 } 57 } 58 | Popular Tags |