Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Add CreateDevice action to context menu
Add CreateDevice action to context menu [message #249317] Wed, 17 June 2009 09:01 Go to next message
Matthieu is currently offline MatthieuFriend
Messages: 7
Registered: July 2009
Junior Member
Hi,

As you can see in the title, I would like to add a customized action to my
context menu. Actually I would be able to insert a node on a Connection
via the context menu on the selected Connection. It means :
1) to create a node
2) to reconnect the selected Connection with the created node
3) to create a new Connection between the created node and the last node

if 'O' is an old Node, 'N' the new Node to insert and '-' a Connection, I
could draw the situation like this :
0) O-O
1) O-O N
2) O-N O
3) O-N-O

Could you give me information or some help to create such actions ?

Thanks
Matthieu
Re: Add CreateDevice action to context menu [message #249333 is a reply to message #249317] Thu, 18 June 2009 01:36 Go to previous messageGo to next message
Ben Vitale is currently offline Ben VitaleFriend
Messages: 247
Registered: July 2009
Senior Member
Assuming you have model objects which represent nodes and connections,
you should be able to create a new node model object, delete the old
connection, and hook up two new connections. These changes should all
fire notifications indicating the changes have occurred. The edit parts
should be listening for these changes and get updated automatically.

Regarding the action itself, you can subclass
org.eclipse.gef.ui.actions.SelectionAction so you can get a handle to
the connection that provides the starting context.

Hope that helps
Ben

Matthieu wrote:
> Hi,
>
> As you can see in the title, I would like to add a customized action to
> my context menu. Actually I would be able to insert a node on a
> Connection via the context menu on the selected Connection. It means :
> 1) to create a node
> 2) to reconnect the selected Connection with the created node
> 3) to create a new Connection between the created node and the last node
>
> if 'O' is an old Node, 'N' the new Node to insert and '-' a Connection,
> I could draw the situation like this :
> 0) O-O 1) O-O N 2) O-N O
> 3) O-N-O
>
> Could you give me information or some help to create such actions ?
>
> Thanks
> Matthieu
>
Re: Add CreateDevice action to context menu [message #249430 is a reply to message #249333] Fri, 26 June 2009 09:01 Go to previous messageGo to next message
Matthieu is currently offline MatthieuFriend
Messages: 7
Registered: July 2009
Junior Member
Hi,

Ben Vitale wrote:

> Regarding the action itself, you can subclass
> org.eclipse.gef.ui.actions.SelectionAction so you can get a handle to
> the connection that provides the starting context.
> Hope that helps

Thank you for the information, now it works properly but I still a
question about this set of Actions.

For the moment I have separate the Node creation from Connection creations
because I guess that if I try to use a CompoundCommand to put them
together in it I'll be in trouble to get the needed EditPart for
Connections whereas it has not already been created. I mean when I use
run() method I get Node creation command which is executed and then I
create and execute Connection commands.

Anyway how can I gather the result of 3 actions in the same undo() method
? Indeed I need only one redo() to perform the 3 actions but I need 3
undo() calls to go back.
Re: Add CreateDevice action to context menu [message #249478 is a reply to message #249430] Fri, 03 July 2009 01:04 Go to previous message
Ben Vitale is currently offline Ben VitaleFriend
Messages: 247
Registered: July 2009
Senior Member
If it's one action from the user's perspective, then you should have a
single Command that implements all the necessary steps and has logic to
redo() them or undo() them in one shot.

HTH
Ben

Matthieu wrote:
> Hi,
>
> Ben Vitale wrote:
>
>> Regarding the action itself, you can subclass
>> org.eclipse.gef.ui.actions.SelectionAction so you can get a handle to
>> the connection that provides the starting context.
>> Hope that helps
>
> Thank you for the information, now it works properly but I still a
> question about this set of Actions.
>
> For the moment I have separate the Node creation from Connection
> creations because I guess that if I try to use a CompoundCommand to put
> them together in it I'll be in trouble to get the needed EditPart for
> Connections whereas it has not already been created. I mean when I use
> run() method I get Node creation command which is executed and then I
> create and execute Connection commands.
>
> Anyway how can I gather the result of 3 actions in the same undo()
> method ? Indeed I need only one redo() to perform the 3 actions but I
> need 3 undo() calls to go back.
>
Previous Topic:Drag and drop from a TreeViewer
Next Topic:How to create a connection between two models with a right-click drag
Goto Forum:
  


Current Time: Thu Apr 25 13:43:14 GMT 2024

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

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

Back to the top