[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.modeling.mdt.uml2.uml] Re: General help needed for commands and operations on UML2 models

James, thanks for the link to EMF Transactions. With a RecordingCommand i can perfectly do what I intended.

I just have a general question about editing domains: in order to accept a recording event, I changed from a UML2AdapterFactoryEditingDomain to a TransactionalEditingDomain, simply by changing my old code as shown below.

However, no my old actions do not work anymore, as they access the model directly and not via a nice recording actions. So my question is if I can somehow use the transactional editing domain for SOME commands, while I can still use the old editing domain for my old actions. (So that i can migrate my actions step by step...)

In a way, i want both: transactional access for my "new" commands, and plain access for those not yet ported. Is that possible?

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 old editing domain
//umlEditingDomain = new UML2AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap());


// 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@xxxxxxxxxxxxxxxxxx
Hi,

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.