Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Creating SWT context menu in Swing Controls.
Creating SWT context menu in Swing Controls. [message #467455] Fri, 04 May 2007 00:50 Go to next message
Eclipse UserFriend
Originally posted by: freakycreak.yahoo.com

Hi frnds,

I've got an editor and in its createPartControl method Im creating a
Swing Frame, Panel and adding a context menu.

But, the context menu doesn't pop up when i do a right click.
I know that the menu works cause if i remove the Frame and leave just
the parent composite, the menu shows.

I dont want to create my popupmenu using Swing controls because i would
like to have my context menu extensable
by other plugins.

So, Is there some way I could get the context menu to show in the Frame
and also be extensable?


Here's my createPartControl and plugin.xml:


public void createPartControl(Composite parent) {
final Composite composite = new Composite(container, SWT.EMBEDDED);
final Frame frame = SWT_AWT.new_Frame(composite);
Panel panel = new java.awt.Panel(BorderLayout());
frame.add(panel);
JPanel jpanel = new JPanel(BorderLayout());
panel.add(jpanel); jpanel.add(view); //View is a JComponent with
a Canvas


// Create menu manager.
MenuManager menuMgr = new MenuManager();
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager mgr) {
mgr.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
}
});


// Create menu.
Menu menu = menuMgr.createContextMenu(composite);
composite.setMenu(menu);


// Register menu for extension.

getSite().registerContextMenu("test.menuid",menuMgr,getSite().getSelectionProvider());

}


And in my plugin.xml I'm creating a popupmenu:


<extension point="org.eclipse.ui.popupMenus">
<viewerContribution
id="test.viewerContribution"
targetID="test.menuid">
<menu
label="New Submenu"
path="additions"
id="test.popupMenu.submenu">
<separator
name="additions">
</separator>
</menu>
<action id="test.ZoomInAction"
label="Zoom In"
icon="icons/sample.gif"
menubarPath="test.popupMenu.submenu/additions"
class="test.ZoomInAction"> </action>
</viewerContribution> </extension>

--
Can anyone please guide me on this. Is it posiible to create such swt
context menu on that swing controls ??

Thanks in advance.
Re: Creating SWT context menu in Swing Controls. [message #467726 is a reply to message #467455] Thu, 10 May 2007 09:21 Go to previous message
Eclipse UserFriend
I think this was answered recently (like in the last 2 weeks) in another
thread in eclipse.platform.swt

PW
Previous Topic:Menu contributions grayed out in 3.3
Next Topic:Eclipse 33M7 Help issue
Goto Forum:
  


Current Time: Fri May 16 12:51:26 EDT 2025

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

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

Back to the top