|
|
Re: Command grouping in CommandStack [message #1387173 is a reply to message #1387157] |
Tue, 24 June 2014 15:21 |
Mauro Condarelli Messages: 428 Registered: September 2009 |
Senior Member |
|
|
Hi Ed,
comments inline.
Il 24/06/2014 15:42, Ed Merks ha scritto:
> Mauro,
>
> Comments below.
>
> On 24/06/2014 3:23 PM, Mauro Condarelli wrote:
>> Hi,
>> I need to do some housekeeping operations whenever some model classes
>> are destroyed.
> 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:
getEditingDomain().getCommandStack().execute(DeleteCommand.create(...));
>>
>> 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.
Ok.
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
>> anymore.
>> 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.
Many thanks
Mauro
|
|
|
Powered by
FUDForum. Page generated in 0.03257 seconds