Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » undo notification
undo notification [message #474210] Sun, 15 July 2007 06:22 Go to next message
Bogdan Pistol is currently offline Bogdan PistolFriend
Messages: 29
Registered: July 2009
Junior Member
Hello,

The UML elements are Notifiers, so I can add an Adapter to their eAdapters
and I can listen for notifications.
But when I undo() a ChangeCommand from a BasicCommandStack the
notifications from the UML elements are not fired.

I sow that I can listen for events directly from BasicCommandStack with
commandStackChanged(EventObject), but I do not know how to find out what
features of what objects changed.

Is there a way to configure the UML elements to notify me when an undo()
or redo() affects those elements or their features?

Bogdan,
Re: undo notification [message #474266 is a reply to message #474210] Mon, 16 July 2007 20:01 Go to previous messageGo to next message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Hi Bogdan,

It's my understanding that you should be getting notifications whenever the
change command causes setting of uml elements.
That notification mechanism does not change ( or slience notifications )
when triggered from an undo().
If you are not seeing notifications it could be intentional? or there could
be other problems.

- James


"Bogdan Pistol" <bogdanciprian@gmail.com> wrote in message
news:f7ceef$6ib$1@build.eclipse.org...
> Hello,
>
> The UML elements are Notifiers, so I can add an Adapter to their eAdapters
> and I can listen for notifications.
> But when I undo() a ChangeCommand from a BasicCommandStack the
> notifications from the UML elements are not fired.
>
> I sow that I can listen for events directly from BasicCommandStack with
> commandStackChanged(EventObject), but I do not know how to find out what
> features of what objects changed.
>
> Is there a way to configure the UML elements to notify me when an undo()
> or redo() affects those elements or their features?
>
> Bogdan,
Re: undo notification [message #474272 is a reply to message #474266] Wed, 18 July 2007 06:30 Go to previous messageGo to next message
Bogdan Pistol is currently offline Bogdan PistolFriend
Messages: 29
Registered: July 2009
Junior Member
> It's my understanding that you should be getting notifications whenever the
> change command causes setting of uml elements.
> That notification mechanism does not change ( or slience notifications )
> when triggered from an undo().
> If you are not seeing notifications it could be intentional? or there could
> be other problems.

Hi James,

Here's the code I tried:

BasicCommandStack commandStack = new BasicCommandStack();
EditingDomain ed = new UML2AdapterFactoryEditingDomain(null, commandStack);

final Model m = UMLFactory.eINSTANCE.createModel();
m.eAdapters().add(new EContentAdapter() {
public void notifyChanged(Notification notification) {
super.notifyChanged(notification);
System.out.println("Event fired!");
}
});

ed.getCommandStack().execute(new ChangeCommand(ed, new Runnable() {
public void run() {
m.createOwnedClass("Foo", false);
}
}));
System.out.println("Testing undo...");
ed.getCommandStack().undo();
System.out.println("Done.");

The output:

Event fired!
Event fired!
Event fired!
Event fired!
Testing undo...
Done.

I should get an "Event fired!" after "Testing undo..."?

Thanks,

Bogdan,
Re: undo notification [message #474378 is a reply to message #474272] Wed, 18 July 2007 13:13 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Bogdan,

You haven't affiliated the model with the editing domain in any way, so the
change command will be unable to detect the changes. Try adding the model to
a resource in the editing domain's resource set and I suspect you'll get the
desired result.

Kenn'

"Bogdan Pistol" <bogdanciprian@gmail.com> wrote in message
news:f7kc1l$vqv$1@build.eclipse.org...
>> It's my understanding that you should be getting notifications whenever
>> the
>> change command causes setting of uml elements.
>> That notification mechanism does not change ( or slience notifications )
>> when triggered from an undo().
>> If you are not seeing notifications it could be intentional? or there
>> could
>> be other problems.
>
> Hi James,
>
> Here's the code I tried:
>
> BasicCommandStack commandStack = new BasicCommandStack();
> EditingDomain ed = new UML2AdapterFactoryEditingDomain(null,
> commandStack);
>
> final Model m = UMLFactory.eINSTANCE.createModel();
> m.eAdapters().add(new EContentAdapter() {
> public void notifyChanged(Notification notification) {
> super.notifyChanged(notification);
> System.out.println("Event fired!");
> }
> });
>
> ed.getCommandStack().execute(new ChangeCommand(ed, new Runnable() {
> public void run() {
> m.createOwnedClass("Foo", false);
> }
> }));
> System.out.println("Testing undo...");
> ed.getCommandStack().undo();
> System.out.println("Done.");
>
> The output:
>
> Event fired!
> Event fired!
> Event fired!
> Event fired!
> Testing undo...
> Done.
>
> I should get an "Event fired!" after "Testing undo..."?
>
> Thanks,
>
> Bogdan,
Re: undo notification [message #474380 is a reply to message #474378] Wed, 18 July 2007 16:21 Go to previous message
Bogdan Pistol is currently offline Bogdan PistolFriend
Messages: 29
Registered: July 2009
Junior Member
Hi Kenn

> You haven't affiliated the model with the editing domain in any way, so the
> change command will be unable to detect the changes.

Yes, you're right! The tip solved my problem.

Thank you Kenn and James

Bogdan,
Re: undo notification [message #623743 is a reply to message #474210] Mon, 16 July 2007 20:01 Go to previous message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Hi Bogdan,

It's my understanding that you should be getting notifications whenever the
change command causes setting of uml elements.
That notification mechanism does not change ( or slience notifications )
when triggered from an undo().
If you are not seeing notifications it could be intentional? or there could
be other problems.

- James


"Bogdan Pistol" <bogdanciprian@gmail.com> wrote in message
news:f7ceef$6ib$1@build.eclipse.org...
> Hello,
>
> The UML elements are Notifiers, so I can add an Adapter to their eAdapters
> and I can listen for notifications.
> But when I undo() a ChangeCommand from a BasicCommandStack the
> notifications from the UML elements are not fired.
>
> I sow that I can listen for events directly from BasicCommandStack with
> commandStackChanged(EventObject), but I do not know how to find out what
> features of what objects changed.
>
> Is there a way to configure the UML elements to notify me when an undo()
> or redo() affects those elements or their features?
>
> Bogdan,
Re: undo notification [message #623749 is a reply to message #474266] Wed, 18 July 2007 06:30 Go to previous message
Bogdan Pistol is currently offline Bogdan PistolFriend
Messages: 29
Registered: July 2009
Junior Member
> It's my understanding that you should be getting notifications whenever the
> change command causes setting of uml elements.
> That notification mechanism does not change ( or slience notifications )
> when triggered from an undo().
> If you are not seeing notifications it could be intentional? or there could
> be other problems.

Hi James,

Here's the code I tried:

BasicCommandStack commandStack = new BasicCommandStack();
EditingDomain ed = new UML2AdapterFactoryEditingDomain(null, commandStack);

final Model m = UMLFactory.eINSTANCE.createModel();
m.eAdapters().add(new EContentAdapter() {
public void notifyChanged(Notification notification) {
super.notifyChanged(notification);
System.out.println("Event fired!");
}
});

ed.getCommandStack().execute(new ChangeCommand(ed, new Runnable() {
public void run() {
m.createOwnedClass("Foo", false);
}
}));
System.out.println("Testing undo...");
ed.getCommandStack().undo();
System.out.println("Done.");

The output:

Event fired!
Event fired!
Event fired!
Event fired!
Testing undo...
Done.

I should get an "Event fired!" after "Testing undo..."?

Thanks,

Bogdan,
Re: undo notification [message #623755 is a reply to message #474272] Wed, 18 July 2007 13:13 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Bogdan,

You haven't affiliated the model with the editing domain in any way, so the
change command will be unable to detect the changes. Try adding the model to
a resource in the editing domain's resource set and I suspect you'll get the
desired result.

Kenn'

"Bogdan Pistol" <bogdanciprian@gmail.com> wrote in message
news:f7kc1l$vqv$1@build.eclipse.org...
>> It's my understanding that you should be getting notifications whenever
>> the
>> change command causes setting of uml elements.
>> That notification mechanism does not change ( or slience notifications )
>> when triggered from an undo().
>> If you are not seeing notifications it could be intentional? or there
>> could
>> be other problems.
>
> Hi James,
>
> Here's the code I tried:
>
> BasicCommandStack commandStack = new BasicCommandStack();
> EditingDomain ed = new UML2AdapterFactoryEditingDomain(null,
> commandStack);
>
> final Model m = UMLFactory.eINSTANCE.createModel();
> m.eAdapters().add(new EContentAdapter() {
> public void notifyChanged(Notification notification) {
> super.notifyChanged(notification);
> System.out.println("Event fired!");
> }
> });
>
> ed.getCommandStack().execute(new ChangeCommand(ed, new Runnable() {
> public void run() {
> m.createOwnedClass("Foo", false);
> }
> }));
> System.out.println("Testing undo...");
> ed.getCommandStack().undo();
> System.out.println("Done.");
>
> The output:
>
> Event fired!
> Event fired!
> Event fired!
> Event fired!
> Testing undo...
> Done.
>
> I should get an "Event fired!" after "Testing undo..."?
>
> Thanks,
>
> Bogdan,
Re: undo notification [message #623757 is a reply to message #474378] Wed, 18 July 2007 16:21 Go to previous message
Bogdan Pistol is currently offline Bogdan PistolFriend
Messages: 29
Registered: July 2009
Junior Member
Hi Kenn

> You haven't affiliated the model with the editing domain in any way, so the
> change command will be unable to detect the changes.

Yes, you're right! The tip solved my problem.

Thank you Kenn and James

Bogdan,
Previous Topic:How to check two models against each other
Next Topic:new Problem on applieng a StereoType
Goto Forum:
  


Current Time: Thu Apr 25 18:53:44 GMT 2024

Powered by FUDForum. Page generated in 0.03619 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top