Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Custom feature always marks editor as dirty
Custom feature always marks editor as dirty [message #653095] Tue, 08 February 2011 13:16 Go to next message
Volker Wegert is currently offline Volker WegertFriend
Messages: 169
Registered: July 2009
Senior Member
Hello,

I've got a slight issue with a custom feature. As far as I can see, the
framework provides an EMF transaction and always commits this transaction,
whether something was changed or not. In my case, this leads to an irritating
effect - my custom feature displays a dialog to change some detail values. If
none of the values were changed or the dialog was aborted, no actual model
values are changed - but the transaction is still commited. Since the editor
uses the CommandStack method isSaveNeeded, even an empty operation will trick
the CommandStack into thinking that something has changed. Is there a way out
of this that does not require patching the framework? ;-)

Thanks
Volker

--
* Volker Wegert * http://www.volker-wegert.de/contact *
"If we knew what it was we were doing, it wouldn't be called research, now
would it?" (Albert Einstein)
Re: Custom feature always marks editor as dirty [message #653096 is a reply to message #653095] Tue, 08 February 2011 13:27 Go to previous messageGo to next message
Tim Kaiser is currently offline Tim KaiserFriend
Messages: 118
Registered: July 2009
Senior Member
Hi Volker,

have you tried overriding the
hasDoneChanges() method from AbstractFeature?

If you return false if nothing has changed, the command should be handled
properly.

Best, Tim
Re: Custom feature always marks editor as dirty [message #653099 is a reply to message #653096] Tue, 08 February 2011 13:36 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Volker,

there is a bug in Graphiti 0.7.0 that has been fixed with Indigo M4
(Graphiti 0.8.0). hasDoneChanges was not called for CustomFeatures, see
https://bugs.eclipse.org/bugs/show_bug.cgi?id=327756

Michael
Re: Custom feature always marks editor as dirty [message #653116 is a reply to message #653096] Tue, 08 February 2011 14:41 Go to previous messageGo to next message
Volker Wegert is currently offline Volker WegertFriend
Messages: 169
Registered: July 2009
Senior Member
Hi,

"Tim Kaiser" <tim.kaiser@sap.com> writes:
> have you tried overriding the
> hasDoneChanges() method from AbstractFeature?

No, I haven't - didn't know about this method before. However, this does not
solve my immediate problem - hasDoneChanges() is called after the operation
was executed. At this point, the command stack is already marked as
isSaveNeeded().

Volker

--
* Volker Wegert * http://www.volker-wegert.de/contact *
"Auch die beunruhigendste Gegenwart wird bald Vergangenheit sein. Das ist
immerhin tröstlich." (Thornton Wilder)
Re: Custom feature always marks editor as dirty [message #653117 is a reply to message #653099] Tue, 08 February 2011 14:42 Go to previous messageGo to next message
Volker Wegert is currently offline Volker WegertFriend
Messages: 169
Registered: July 2009
Senior Member
Michael,

"Michael Wenz" <michael.wenz@sap.com> writes:
> there is a bug in Graphiti 0.7.0 that has been fixed with Indigo M4 (Graphiti
> 0.8.0). hasDoneChanges was not called for CustomFeatures, see
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=327756

thanks for the hint, but I'm on the bleeding edge (CVS) anyway :-)

Volker

--
* Volker Wegert * http://www.volker-wegert.de/contact *
"Wer sich in der Diskussion auf eine Autorität beruft, gebraucht nicht den
Verstand, sondern sein Gedächnis." (Leonardo da Vinci)
Re: Custom feature always marks editor as dirty [message #653136 is a reply to message #653116] Tue, 08 February 2011 15:44 Go to previous messageGo to next message
Tim Kaiser is currently offline Tim KaiserFriend
Messages: 118
Registered: July 2009
Senior Member
Hi Volker,

give it a try.
It should clean up the command stack.

Does it work?

Best, Tim
Re: Custom feature always marks editor as dirty [message #653530 is a reply to message #653136] Thu, 10 February 2011 06:51 Go to previous messageGo to next message
Volker Wegert is currently offline Volker WegertFriend
Messages: 169
Registered: July 2009
Senior Member
Tim,

after some digging, I found out that the problem is actually a
CommandStackListener that is notified whenever a transaction is commited, then
checks whether the command stack needs saving and flags the editor as dirty if
appropriate. (This is a multi-page editor with two pages containing Graphiti
editors, the other pages are "classic" editors - so I need something that
works for all pages.). At that time, the transaction is not undone, so the
editor is marked dirty. :-(

At the moment, the only thing I can think of as a partial solution would be
something like a "delayed check" - in the listener implementation, wait half a
second before checking the status of the command stack. Is there a better way
to do this?

Thanks
Volker

--
* Volker Wegert * http://www.volker-wegert.de/contact *
"Wir müssen lernen, gegenseitig unsere Theorien umzubringen statt uns selbst."
(Karl Popper)
Re: Custom feature always marks editor as dirty [message #653795 is a reply to message #653530] Fri, 11 February 2011 09:05 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Volker,

actually, there is a similar pattern in the Graphiti editor as well: we also
have a command stack listener (FWCommandStackListener) that triggers the
editor being marked dirty. But that happens via Display.asyncExec (the
marking anyway needs the UI thread). In the async exec we do a
firePropertyChange that again triggers isDirty in the editor; there the
command stack is queried. At the time the async exec runs tha command stack
is clean again.

Does that help in your scenario as well?

Michael
Re: Custom feature always marks editor as dirty [message #653796 is a reply to message #653530] Fri, 11 February 2011 09:13 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
I just noticed that after the romoval of the command from the stack we call
notifyListeners(Command, int) which only notifies the registered
CommandStackEventListeners but not the CommandStackListeners; the latter
would be done by calling notifyListeners() (no parameters), but this method
is deprecated in the GEF command stack, no idea why. But this is probably
the reason why we don't call that method.

Michael
Re: Custom feature always marks editor as dirty [message #653842 is a reply to message #653795] Fri, 11 February 2011 13:47 Go to previous messageGo to next message
Volker Wegert is currently offline Volker WegertFriend
Messages: 169
Registered: July 2009
Senior Member
Michael,

thanks for the time you're taking for this.

"Michael Wenz" <michael.wenz@sap.com> writes:
> actually, there is a similar pattern in the Graphiti editor as well: we also
> have a command stack listener (FWCommandStackListener) that triggers the
> editor being marked dirty. But that happens via Display.asyncExec (the
> marking anyway needs the UI thread). In the async exec we do a
> firePropertyChange that again triggers isDirty in the editor; there the
> command stack is queried. At the time the async exec runs tha command stack
> is clean again.

For some reason, this does not work within my editor. I've even added a delay
of several seconds, to no avail - after the aborted action, the command stack
alway insists on isSaveNeeded(). The WCSI checks for an undoable operation and
receives my feature operation (that did nothing). It is (understandably)
unable to determine that this operation didn't change anything and has to
assume that something has happened.

> I just noticed that after the romoval of the command from the stack we call
> notifyListeners(Command, int) which only notifies the registered
> CommandStackEventListeners but not the CommandStackListeners; the latter
> would be done by calling notifyListeners() (no parameters), but this method
> is deprecated in the GEF command stack, no idea why. But this is probably
> the reason why we don't call that method.

I don't think I can use that - I've got a mixed editor with GEF and non-GEF
parts. As far as I can see, CommandStackEventListeners are GEF-only stuff
while the CommandStackListeners are attached to the underlying EMF domain
model.

I'm still unsure about this, but I think a feature should be able to signal to
the framework "User pushed the Big Red Button, undo the entire transaction"
somehow...

Volker

--
* Volker Wegert * http://www.volker-wegert.de/contact *
"Wir müssen lernen, gegenseitig unsere Theorien umzubringen statt uns selbst."
(Karl Popper)
Re: Custom feature always marks editor as dirty [message #654523 is a reply to message #653842] Wed, 16 February 2011 08:10 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Volker,

I have thought about this, but have to give up. Sorry, but without having
the concrete coding I'm afraid I cannot help. Can you make up a small
example that shows this issue?

Michael
Previous Topic:Patterns - support for direct editing, removal, deletion?
Next Topic:Update Diagram for create
Goto Forum:
  


Current Time: Sat Dec 20 12:20:57 GMT 2014

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

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