Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » howto provide context menu actions in a tree in a formeditor
howto provide context menu actions in a tree in a formeditor [message #333340] Thu, 04 December 2008 14:07 Go to next message
Andreas Pakulat is currently offline Andreas PakulatFriend
Messages: 127
Registered: July 2009
Senior Member
Hi,

I've got a formeditor setup that has an swt Tree (using TreeViewer) embedded
in it. I'd like to provide a context menu with standard actions such
as "cut","copy","paste" for this. I tried to do this using something like:

MenuManager contextMenu = new MenuManager();
contextMenu.setRemoveAllWhenShown( true );
contextMenu
.add( new CopyMapEntriesAction( map, viewer ) );
Menu m = contextMenu.createContextMenu( viewer.getControl() );
viewer.getControl().setMenu( m );
editor.getSite().registerContextMenu( contextMenu, viewer );

However all I do get is a contex menu that contains stuff like "Run A..".
I've tried to look into how the PDE form editor does this, but couldn't see
anything I'm doing wrong.

Do I have to register the action somehow via plugin.xml? I didn't think this
would be necessary as I'm using a
setActionDefinitionId("org.eclipse.ui.edit.copy").

Anybody has a sample for a simple formeditor that provides the standard
copy/paste action on a tree view?

Andreas
Re: howto provide context menu actions in a tree in a formeditor [message #333341 is a reply to message #333340] Thu, 04 December 2008 14:05 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

See some of the links in my sig which explains commands (hooking into
copy, ctrl+C involves providing handlers and using the
org.eclipse.ui.menus extension with a popup: locationURI) or
http://www.eclipse.org/articles/article.php?file=Article-act ion-contribution/index.html
for the older action based contributions.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm


Re: howto provide context menu actions in a tree in a formeditor [message #333362 is a reply to message #333341] Fri, 05 December 2008 15:22 Go to previous message
Andreas Pakulat is currently offline Andreas PakulatFriend
Messages: 127
Registered: July 2009
Senior Member
Paul Webster wrote:

> See some of the links in my sig which explains commands (hooking into
> copy, ctrl+C involves providing handlers and using the
> org.eclipse.ui.menus extension with a popup: locationURI) or
>
http://www.eclipse.org/articles/article.php?file=Article-act ion-contribution/index.html
> for the older action based contributions.

Thanks, unfortunately none of those really helped. Its basic API
information, but simply not small example. Either I'm too stupid or too
ignorant to put the information from those pages together into
code+plugin.xml.

Anyway, I found a bit simpler sample code in the breakpointsview in
org.eclipse.debug.ui and that does seem to work as I want it to.

Andreas
Previous Topic:Finding the list of classes in a package like Package Explorer
Next Topic:How to refresh or force to redraw view part
Goto Forum:
  


Current Time: Fri Mar 29 10:40:38 GMT 2024

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

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

Back to the top