| [news.eclipse.modeling.mdt.uml2.uml] Re: General help needed for commands and operations on UML2 models |
Thanks in advance, Fredrik
List factories = new ArrayList(); factories.add(new UMLResourceItemProviderAdapterFactory()); factories.add(new UMLItemProviderAdapterFactory()); factories.add(new EcoreItemProviderAdapterFactory()); factories.add(new UMLReflectiveItemProviderAdapterFactory()); BasicCommandStack commandStack = new BasicCommandStack(); adapterFactory = new ComposedAdapterFactory(factories);
// the new editing domain umlEditingDomain = new TransactionalEditingDomainImpl(adapterFactory);
James Bruck wrote:
Hi Fredrik,
An example of using the ChangeCommand can be found in the og.eclipse.uml2.uml.editor.actions.DestroyElementAction. Using the ChangeCommand is a good way to go if you want to "undo" and "redo" your actions.
You might benefit from emft-transaction (batched events). Have a look at:
http://www.eclipse.org/emft/projects/transaction/?project=transaction#transaction
Cheers,
-James.
"Fredrik" <robertssen@xxxxxxxxxxxxxx> wrote in message news:52db665ae2bdde7e168a7171471d15db$1@xxxxxxxxxxxxxxxxxxHi,
I have built some wizards to create some UML model elements. Create a component, assign a name to it, add a state machine, region, apply some stereotype and so on. I am curently implementing all this using statements like:
component.setName("name"); ..
And, of course, receive notifications to all listeners for each single change.
I wonder:
- Should I instead use EMF commands to manipulate the model? Would I then get Undo for free? - Using these commands, and maybe some composite commands, would I just receive one notification for the model update instead of one for each small change? - Is there any source to find more about commands specifically for UML2? What about the class org.eclipse.uml2.common.edit.command.ChangeCommand - shoudl I use it? - Are commands also the answer to lock the model, so that consistency of the operations can be ensured?
I have read about commands in the EMF book, but struggled quite a bit in using them for UML2.
So, any hints to examples or documentation are very welcome!
Thanks, Fredrik.