|Re: Command grouping in CommandStack [message #1387173 is a reply to message #1387157]
||Tue, 24 June 2014 15:21
| Mauro Condarelli
Registered: September 2009
Il 24/06/2014 15:42, Ed Merks ha scritto:
> Comments below.
> On 24/06/2014 3:23 PM, Mauro Condarelli wrote:
>> I need to do some housekeeping operations whenever some model classes
>> are destroyed.
Yes, I am modeling a computation network, so "objects" represent
computations on data and references represent data channels.
"deleting" an element implies reconfiguring all attached "pipes", not
just destroy them.
>> Unfortunately operations depend on the order of deletions, so I need
>> to do them WHILE the deletion takes place.
> And deletion is done as a command?
Actual deletion of objects is done via:
>> Obviously this is a problem only when I delete complex objects
>> composed by many other EObjects.
> The delete command
> (org.eclipse.emf.edit.command.DeleteCommand.execute()) does visit all
> objects being deleted, including contained children so it can remove all
> references to them.
Is there some way I can attach a listener there?
I need something like overriding destroy() or a real Listener called
*before* removing objects ("on the way down" of the recursion).
>> Is there some way to "hook" to actual object deletion (if it is done
>> recursively and not simply relying on gc)?
> Objects used in a editor won't generally be gc'd because they have
> adapters attached to them (and of course the commands reference even
> deleted things so you can undo it).
I understand. thanks.
The above question stands.
>> Alternatively I can recourse on my model (that's what I'm doing now)
>> explicitly deleting depth-first all contained children.
> I'm not sure how that relates to what's done as part of a command but
> you can look at how a delete command produces a single compound command
> to undo the delete...
I'll try to follow...
>> In this case, however I have the problem undo/redo won't be atomic
>> I seem to recall there's a way to logically group many commands (I am
>> NOT speaking about CompoundCommand !) so that they are undone
>> together, but I couldn't find it anywhere.
> At least with EMF's core command framework, compound commands are the
> only way...
>> Perhaps I just dreamed.
It seems I dreamed :(
I seem to remember there is some way to "mark" positions in the command
stack, so I can repeatedly undo/redo till I find a matching mark.
I think that is used at least to mark the point where last File->Save
occurred... but I cannot find it again.
Powered by FUDForum
. Page generated in 0.01780 seconds