Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » MDT (Model Development Tools) » ChangeCommand problem...
ChangeCommand problem... [message #380015] Fri, 10 April 2009 08:13 Go to next message
Sorin Fagateanu is currently offline Sorin Fagateanu
Messages: 46
Registered: July 2009
Member
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!
Re: ChangeCommand problem... [message #380016 is a reply to message #380015] Wed, 22 April 2009 09:25 Go to previous message
Kenn Hussey is currently offline Kenn Hussey
Messages: 1618
Registered: July 2009
Senior Member
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@yahoo.com> wrote in message
news:209e8410d148745fc9ab624f8d9e724b$1@www.eclipse.org...
> 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!
>
>
>
>
>
>
>
Re: ChangeCommand problem... [message #597612 is a reply to message #380015] Wed, 22 April 2009 09:25 Go to previous message
Kenn Hussey is currently offline Kenn Hussey
Messages: 1618
Registered: July 2009
Senior Member
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@yahoo.com> wrote in message
news:209e8410d148745fc9ab624f8d9e724b$1@www.eclipse.org...
> 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!
>
>
>
>
>
>
>
Previous Topic:ChangeCommand problem...
Next Topic:Problems with saving order
Goto Forum:
  


Current Time: Mon Sep 01 03:33:39 EDT 2014

Powered by FUDForum. Page generated in 0.08939 seconds