Skip to main content



      Home
Home » Eclipse Projects » GEF » ContextMenu
ContextMenu [message #57068] Wed, 22 January 2003 11:39 Go to next message
Eclipse UserFriend
I want to add actions to a ContextMenu that can only be determined at
runtime. The basic model is that I have an edit part that connects to other
edit parts. Once an edit part is added to a diagram I want to be able to
provide a list of objects that it is allowed to connect to and then
automatically add the object that the user selects. There are hundreds of
objects, but typically only one or two can connect. So what I want to
create is a sub-menu with these objects. e.g.

Add -> Object1
Object57
Object203

I can't see any obvious way I can achieve this using the ContextMenu as
provided. As it appears to require the Id for the Action when the action is
registered. Am I missing something or do I need to find another approach?

Thanks,

John.
Re: ContextMenu [message #57099 is a reply to message #57068] Wed, 22 January 2003 12:30 Go to previous message
Eclipse UserFriend
In your ContextMenuProvider.buildContextMenu(IMenuManager), you can call getViewer().getContents()
to get the EditPart associated with the top-most model object. Then you can iterate through its
children and check to see if you can connect to any of them. If you find items you can connect to,
create a new Action and add it to the context menu. If you do this, the editor won't know about
these actions and won't be able to dispose of them. You should probably dispose of the action after
it runs.

Eric


John Howard wrote:
> I want to add actions to a ContextMenu that can only be determined at
> runtime. The basic model is that I have an edit part that connects to other
> edit parts. Once an edit part is added to a diagram I want to be able to
> provide a list of objects that it is allowed to connect to and then
> automatically add the object that the user selects. There are hundreds of
> objects, but typically only one or two can connect. So what I want to
> create is a sub-menu with these objects. e.g.
>
> Add -> Object1
> Object57
> Object203
>
> I can't see any obvious way I can achieve this using the ContextMenu as
> provided. As it appears to require the Id for the Action when the action is
> registered. Am I missing something or do I need to find another approach?
>
> Thanks,
>
> John.
>
>
Previous Topic:Property change
Next Topic:The Command in GEF & EMF
Goto Forum:
  


Current Time: Sun May 11 08:30:38 EDT 2025

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

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

Back to the top