[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.mdt] Re: ChangeCommand problem...

Sorin,

This is a more appropriate question for the UML2 newsgroup (copied).

1. Yes, when stereotypes are applied/unapplied, no event is fired on the 
element to which the stereotype has been applied/unapplied, so you'll need 
to trigger a refresh of your editor in another way. This has been done in 
UML2, for example, by introducing a specialized "RefreshingChangeCommand"; 
see ApplyStereotypeAction in the sample UML editor plug-in for details.

2. ChangeCommands should be undoable, so I'm not sure what's going on here. 
However, UML2 has a specialized change command (and change recorder) that 
takes into acccount some UML-isms that aren't accounted for in EMF... I'd 
suggest trying to use it; see the UML editor again for examples.

Cheers,

Kenn

"Sorin Fagateanu" <cyron_16@xxxxxxxxx> wrote in message 
news:209e8410d148745fc9ab624f8d9e724b$1@xxxxxxxxxxxxxxxxxx
> Hello all,
>
> I have another problem.
>
> I have a in the eclipse's Project Explorer a model file,that when I expand 
> it I can see in the tree packages ,clases,operations,attributes 
> etc...,this being done with the emf generation.
> #1 comm
> I have made myself a command for renaming a Package and it look something 
> like:
>
>    EditingDomain editingDomain = AdapterFactoryEditingDomain. 
> getEditingDomainFor(package);
>    CompoundCommand command = new CompoundCommand();
>    command.append(SetCommand.create(editingDomain, package 
> ,UMLPackage.eINSTANCE.getNamedElement_Name(), newName));
>    editingDomain.getCommandStack().execute(command);
>
> After calling this it automaticaly updates the name in the tree.
> #2 comm
> I have made another command for adding a steretype and setting a value 
> and it looks like:
>
>   Runnable runnable = new Runnable() {
>      public void run() {
>         package.applyStereotype(MyStereotype); 
> package.setValue(MyStereotype, myInt, 5);
>      }
>   };
>
>   EditingDomain editingDomain = AdapterFactoryEditingDomain. 
> getEditingDomainFor(package);
>   CompoundCommand command = new CompoundCommand();
>   command.append(new ChangeCommand(editingDomain, runnable)); 
> editingDomain.getCommandStack().execute(command);
>
> However, when I call this comand, in the tree ,the package's label isn't 
> updated like I would have expected (something like : <<MyStereotipe>> 
> PackageName )
>
> At the next rename it updates the label in the tree to show also the 
> "<<MyStereotype>>".
>
>
> My problems are the following :
>
> 1. the label of package isnt't updated when applying the second command.
>
> I have observed the in the case of renaming ,when it enter's the "set" 
> method it also triggers the "notify" which iterates thru all the adapters 
> including the PackageImplAdatpter which calls my content/label provider.
> And i have observed that in the case of applying stereotype, in the 
> notify,it doesn't have a PackageImplAdapter,which it means that no changes 
> are done.
>
> 2.in case of the second command,I cant undo the command.I would have 
> expected in the Edit menu to appear something like Undo "#2 comm".
>
>
> If someone has got any ideas I would be very grateful.
>
>
> Thank you in advance!
>
>
>
>
>
>
>