AbstractTransactionalCommand [message #1114956] |
Mon, 23 September 2013 13:14 |
serhat gezgin Messages: 243 Registered: January 2013 Location: Izmir |
Senior Member |
|
|
Hi all,
i need to customize element via command. So i write;
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));
}
};
}
but
((FormModel) (resourceSet.getResources().get(1).getContents().get(0))).setContext(ct);
((FormModel)(resourceSet.getResources().get(1).getContents().get(0))).setName("FormModel");
these are not executed. why don't understand.
anyone can help me ?
Regards
[Updated on: Mon, 23 September 2013 13:15] Report message to a moderator
|
|
|
|
|
|
Re: AbstractTransactionalCommand [message #1115667 is a reply to message #1114956] |
Tue, 24 September 2013 12:09 |
|
Le 23/09/2013 15:14, serhat gezgin a écrit :
> Hi all,
> i need to customize element via command. So i write;
>
>
> 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));
> }
> };
> }
>
>
> these are not executed. why don't understand.
Your code creates an instance of (an anynymous subclass of)
AbstractTransactionalCommand, but this is not enough: you must request
explicitly that is is executed.
AbstractTransactionalCommand cmd = ...
editingDomain.getCommandStack().execute(cmd);
Pierre-Charles David - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
Powered by
FUDForum. Page generated in 0.02151 seconds