public void run() {
if (workbenchWindow == null) {
// action has been disposed
return;
}
NewWizard wizard = new NewWizard();
wizard.setCategoryId(categoryId);
ISelection selection = workbenchWindow.getSelectionService()
.getSelection();
IStructuredSelection selectionToPass = StructuredSelection.EMPTY;
if (selection instanceof IStructuredSelection) {
selectionToPass = (IStructuredSelection) selection;
} else {
// @issue the following is resource-specific legacy code
// Build the selection from the IFile of the editor
Class resourceClass = LegacyResourceSupport.getResourceClass();
if (resourceClass != null) {
IWorkbenchPart part = workbenchWindow.getPartService()
.getActivePart();
if (part instanceof IEditorPart) {
IEditorInput input = ((IEditorPart) part).getEditorInput();
Object resource = Util.getAdapter(input, resourceClass);
if (resource != null) {
selectionToPass = new StructuredSelection(resource);
}
}
}
}
wizard.init(workbenchWindow.getWorkbench(), selectionToPass);
IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault()
.getDialogSettings();
IDialogSettings wizardSettings = workbenchSettings
.getSection("NewWizardAction"); //$NON-NLS-1$
if (wizardSettings == null) {
wizardSettings = workbenchSettings.addNewSection("NewWizardAction"); //$NON-NLS-1$
}
wizard.setDialogSettings(wizardSettings);
wizard.setForcePreviousAndNextButtons(true);
Shell parent = workbenchWindow.getShell();
WizardDialog dialog = new WizardDialog(parent, wizard);
dialog.create();
dialog.getShell().setSize(