@Override public void run() { Shell shell= getShell(); IWorkingSetManager manager= PlatformUI.getWorkbench().getWorkingSetManager(); IWorkingSet workingSet= fActionGroup.getWorkingSet(); if (workingSet == null || workingSet.isAggregateWorkingSet()) { setEnabled(false); return; } IWorkingSetEditWizard wizard= manager.createWorkingSetEditWizard(workingSet); if (wizard == null) { String title= WorkingSetMessages.EditWorkingSetAction_error_nowizard_title; String message= WorkingSetMessages.EditWorkingSetAction_error_nowizard_message; MessageDialog.openError(shell, title, message); return; } WizardDialog dialog= new WizardDialog(shell, wizard); dialog.create(); if (dialog.open() == Window.OK) fActionGroup.setWorkingSet(wizard.getSelection(), true); }
private void editSelectedWorkingSet() { IWorkingSetManager manager= PlatformUI.getWorkbench().getWorkingSetManager(); IWorkingSet editWorkingSet= (IWorkingSet)((IStructuredSelection)fTableViewer.getSelection()).getFirstElement(); IWorkingSetEditWizard wizard= manager.createWorkingSetEditWizard(editWorkingSet); WizardDialog dialog= new WizardDialog(getShell(), wizard); IWorkingSet originalWorkingSet= fEditedWorkingSets.get(editWorkingSet); boolean firstEdit= originalWorkingSet == null; // save the original working set values for restoration when selection // dialog is cancelled. if (firstEdit) { originalWorkingSet= PlatformUI.getWorkbench().getWorkingSetManager(). createWorkingSet(editWorkingSet.getName(), editWorkingSet.getElements()); } else { fEditedWorkingSets.remove(editWorkingSet); } dialog.create(); if (dialog.open() == Window.OK) { editWorkingSet= wizard.getSelection(); if (fIsSortingEnabled) fTableViewer.refresh(); else fTableViewer.update(editWorkingSet, null); // make sure ok button is enabled when the selected working set // is edited. Fixes bug 33386. updateButtonAvailability(); } fEditedWorkingSets.put(editWorkingSet, originalWorkingSet); }
/** * Creates a working set edit wizard for the specified working set. The * working set will already be set in the wizard. The caller is responsible * for creating and opening a wizard dialog. * * Example: <code> * IWorkingSetEditWizard wizard = workingSetManager.createWorkingSetEditWizard(workingSet); * if (wizard != null) { * WizardDialog dialog = new WizardDialog(shell, wizard); * * dialog.create(); * if (dialog.open() == Window.OK) { * workingSet = wizard.getSelection(); * } * } * </code> * * @param workingSet * working set to create a working set edit wizard for. * @return a working set edit wizard to edit the specified working set or * <code>null</code> if no edit wizard has been defined for the * working set. If the defined edit wizard for the working set could * not be loaded a default IResource based wizard will be returned. * If the default edit wizard can not be loaded <code>null</code> is * returned. * @since 2.1 */ public IWorkingSetEditWizard createWorkingSetEditWizard( IWorkingSet workingSet);