IWorkbench workbench = PlatformUI.getWorkbench();
Shell shell = workbench.getActiveWorkbenchWindow().getShell();
FormCreationWizard wizard = new FormCreationWizard();
wizard.init(workbench, new StructuredSelection());
WizardDialog dialog = new WizardDialog(shell, wizard);
dialog.create();
if (dialog.open() != Window.OK) {
// return null;
} else {
final ResourceSet resourceSet = wizard.getDiagram().getResourceSet();
FormModel fm = (FormModel) resourceSet.getResources().get(1)
.getContents().get(0);
TransactionalEditingDomain editingDomain = TransactionUtil
.getEditingDomain(fm);
IFile affectedFile = WorkspaceSynchronizer.getFile(fm.eResource());
new AbstractTransactionalCommand(
editingDomain,
"Set Values", affectedFile == null ? null : Collections.singletonList(affectedFile)) { //$NON-NLS-1$
protected CommandResult doExecuteWithResult(
IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
((FormModel) (resourceSet.getResources().get(1).getContents().get(0))).setContext(ct);
((FormModel) (resourceSet.getResources().get(1).getContents().get(0))).setName("FormModel");
return new CommandResult(new Status(IStatus.OK, CommonCorePlugin.getPluginId(),
CommonCoreStatusCodes.OK, StringStatics.BLANK, null));
}
};
}