Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Delete Command
Delete Command [message #89980] Sat, 06 January 2007 03:13 Go to next message
Eclipse UserFriend
Originally posted by: irbull.cs.uvic.ca

I have a tool, and in the handleButtonDown I get the targetEditPart and
I am trying to delete it.

I tried the:
org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand, but this
only deleted the view (not the actual EMF model node). I tried the EMF
delete command as follows:

org.eclipse.emf.edit.command.DeleteCommand dc = new
org.eclipse.emf.edit.command.DeleteCommand(editingDomain,lis t );
boolean isExecutable=dc.canExecute();
if(isExecutable){
editingDomain.getCommandStack().execute(dc);
}

where list has the EMF Objects I want to delete. This had the opposite
effect. The view nodes remained. Do I really have to delete both? Is
there a way that the notification handle this?

Cheers,
Ian

}
Re: Delete Command [message #90101 is a reply to message #89980] Sat, 06 January 2007 13:38 Go to previous messageGo to next message
Eclipse UserFriend
Hello Ian,

On deleting an element GMF explicitly execute delete command for semantic
model element and for a view. I suggest you to copy the logic from DiagramGlobalActionHandler.getDeleteCommand()
method to invoke delete command by your action.

-----------------
Alex Shatalin
Re: Delete Command [message #90146 is a reply to message #90101] Sat, 06 January 2007 15:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: irbull.cs.uvic.ca

Thanks Alex! That worked like a charm.

The only thing that remains is how to hook the compound command into the
command stack. If I call execute on on my CompoundCommand then the
edit part and corresponding semantic model element is removed, but the
undo history is incorrect.

I'm sure it is just a matter of using the correct command stack and
passing the command to it, but with 3 command stacks (EMF, GEF and
Eclipse), I don't know which one to pass it too.

I tried to put a breakpoint in CompoundCommand execute to see how delete
does it, but when I delete a model element (select it and press delete)
the execute method doesn't happen.

Thanks for all your help,
I have used a EMF and GEF a lot in the past few years and tried GMF a
few times, but in the past few months GMF has become a really great
tool! I think GMF will be the big winner at EclipseCon this year!

Cheers,
Ian

Alex Shatalin wrote:
> Hello Ian,
>
> On deleting an element GMF explicitly execute delete command for
> semantic model element and for a view. I suggest you to copy the logic
> from DiagramGlobalActionHandler.getDeleteCommand() method to invoke
> delete command by your action.
>
> -----------------
> Alex Shatalin
>
>
Re: Delete Command [message #90264 is a reply to message #90146] Sun, 07 January 2007 19:05 Go to previous message
Eclipse UserFriend
Originally posted by: irbull.cs.uvic.ca

I have figured it out.
From within your Tool you can say
getDomain().getCommandStack().execute(deleteCC);

It is the getDomain().getCommandStack() that you want to execute your
GMF commands on.

Cheers,
Ian

Ian Bull wrote:
> Thanks Alex! That worked like a charm.
>
> The only thing that remains is how to hook the compound command into the
> command stack. If I call execute on on my CompoundCommand then the
> edit part and corresponding semantic model element is removed, but the
> undo history is incorrect.
>
> I'm sure it is just a matter of using the correct command stack and
> passing the command to it, but with 3 command stacks (EMF, GEF and
> Eclipse), I don't know which one to pass it too.
>
> I tried to put a breakpoint in CompoundCommand execute to see how delete
> does it, but when I delete a model element (select it and press delete)
> the execute method doesn't happen.
>
> Thanks for all your help,
> I have used a EMF and GEF a lot in the past few years and tried GMF a
> few times, but in the past few months GMF has become a really great
> tool! I think GMF will be the big winner at EclipseCon this year!
>
> Cheers,
> Ian
>
> Alex Shatalin wrote:
>> Hello Ian,
>>
>> On deleting an element GMF explicitly execute delete command for
>> semantic model element and for a view. I suggest you to copy the logic
>> from DiagramGlobalActionHandler.getDeleteCommand() method to invoke
>> delete command by your action.
>>
>> -----------------
>> Alex Shatalin
>>
>>
Previous Topic:What Formats are Icons?
Next Topic:how to install newest GMF milestones
Goto Forum:
  


Current Time: Tue May 13 18:18:23 EDT 2025

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

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

Back to the top