Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Dynamic context menu for an editpart
Dynamic context menu for an editpart [message #218723] Wed, 28 June 2006 19:03 Go to next message
Eclipse UserFriend
Originally posted by: hlau.cs.tu-berlin.de

Hello!

Perhaps you can help me with this problem.

I am working on a GEF-Editor where Items (with EditParts) could be mapped
to another. Each Item can be mapped to many others, so each mapping should
be deleteable on its own. The mappings are part of the metamodel but have
no editparts themself.

In the context menu for each Item I would like to add actions like

unmap from 0
unmap from 1
...
unmap from n

, so I have to add new Actions each time the mapping changes or each time
the menu pops up.

Is their any chance to do this in GEF?

I would be glad for any answer!
Hannes Lau
Re: Dynamic context menu for an editpart [message #218738 is a reply to message #218723] Thu, 29 June 2006 06:18 Go to previous message
kiril mitov is currently offline kiril mitovFriend
Messages: 128
Registered: July 2009
Senior Member
I have achived similar functionality in this way:
I have a TimeContextMenuProvider that extends the ContextMenuProvider.

The contextMenuProvider is set in the configureGraphicalViewer()
and is something like:
TimeContextMenuProvider provider = new TimeContextMenuProvider(viewer,
this);
getGraphicalViewer().setContextMenu(provider);

This class has a method buildContextMenu().
This class also nows the currently selected edit part!
When the TimeContextMenuProvider builds the menu it does the following:

for (Iterator iter=editPart.getNewActionsList().listIterator();
iter.hasNext();) {
menu.add(iter.next());
}

This way the editPart returns the actions that make sence to be run on it.
So when you mapping change you update the editPart. When the
contextMenuProvider build the menu it will ask the editPart for the
actions. And because the editPart was updated it will return the new
action list.

Now how can the TimeContextMenuProvider now which is the currently
selected editPart? The selection mechanisum I have implemented in this
editor is rather complex(other issues are concerned) but you may start
with a look at EditPartListener, SelectionEditPolicy,
AbstractEditPartViewer::addSelectionChangedListener(ISelecti onChangedListener).

Hope this helps
kiril

Hannes Lau wrote:
>
> Hello!
>
> Perhaps you can help me with this problem.
>
> I am working on a GEF-Editor where Items (with EditParts) could be
> mapped to another. Each Item can be mapped to many others, so each
> mapping should be deleteable on its own. The mappings are part of the
> metamodel but have no editparts themself.
> In the context menu for each Item I would like to add actions like
>
> unmap from 0
> unmap from 1
> ...
> unmap from n
>
> , so I have to add new Actions each time the mapping changes or each
> time the menu pops up.
> Is their any chance to do this in GEF?
>
> I would be glad for any answer!
> Hannes Lau
>
Previous Topic:wrong direction of scrollbars
Next Topic:setting a new model in an opened editor
Goto Forum:
  


Current Time: Thu Sep 19 05:42:07 GMT 2024

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

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

Back to the top