Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Custom Control in menu item
Custom Control in menu item [message #1764133] Thu, 25 May 2017 15:33 Go to next message
Piero Campalani is currently offline Piero CampalaniFriend
Messages: 114
Registered: January 2015
Senior Member

Hi,

I would like to generate a menu item as a custom control (a checkbox-button with text in my case).

I implemented a org.eclipse.jface.action.ControlContribution then added to my MenuManger, but this way I am breaking an internal JFace assertion:

org.eclipse.core.runtime.AssertionFailedException: assertion failed: Can't add a control to a menu
	at org.eclipse.core.runtime.Assert.isTrue(Assert.java:110)
	at org.eclipse.jface.action.ControlContribution.fill(ControlContribution.java:88)
	at org.eclipse.jface.action.MenuManager.doItemFill(MenuManager.java:728)
	at org.eclipse.jface.action.MenuManager.update(MenuManager.java:810)
	at org.eclipse.jface.action.MenuManager.handleAboutToShow(MenuManager.java:472)
	at org.eclipse.jface.action.MenuManager.access$1(MenuManager.java:465)
	at org.eclipse.jface.action.MenuManager$2.menuShown(MenuManager.java:497)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:256)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5227)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1340)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1366)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1345)
	at org.eclipse.swt.widgets.Menu.gtk_show(Menu.java:711)
	at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:1949)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5492)
	at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method)
	at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:2495)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4149)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1121)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1022)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:150)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:161)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1492)


Any comment?
thanks!

-Piero
Re: Custom Control in menu item [message #1764186 is a reply to message #1764133] Fri, 26 May 2017 13:58 Go to previous messageGo to next message
Eclipse UserFriend
You'd need support in SWT, which doesn't exist.

But you can get what you want with a `MenuItem(..., SWT.CHECK)`.
Re: Custom Control in menu item [message #1764204 is a reply to message #1764186] Fri, 26 May 2017 15:49 Go to previous messageGo to next message
Piero Campalani is currently offline Piero CampalaniFriend
Messages: 114
Registered: January 2015
Senior Member

Thank yoy Brian.

Having a checkbox item is enough here.
I blindly did not notice the IAction.AS_CHECK_BOX style bit for actions, which worked for me.

However, I would like the menu to stay open when clicking on this checkbox-ed item, to be able to toggle without having to re-open the menu each time.

How could I control that?

thanks,
-Piero
Re: Custom Control in menu item [message #1764213 is a reply to message #1764204] Fri, 26 May 2017 17:20 Go to previous messageGo to next message
Eclipse UserFriend
I don't think you can: that's determined by the operating/windowing system. Such togglable behaviour might be better done through a tool item.
Re: Custom Control in menu item [message #1764356 is a reply to message #1764186] Mon, 29 May 2017 07:03 Go to previous message
Piero Campalani is currently offline Piero CampalaniFriend
Messages: 114
Registered: January 2015
Senior Member

Thank yoy Brian.

Having a checkbox item is enough here.
I blindly did not notice the IAction.AS_CHECK_BOX style bit for actions, which worked for me.

However, I would like the menu to stay open when clicking on this checkbox-ed item, to be able to toggle without having to re-open the menu each time.

How could I control that?

thanks,
-Piero
Previous Topic:Need ComboBoxCellEditor drop down multi selection functionality in SWT
Next Topic:Editing in TreeViewer
Goto Forum:
  


Current Time: Fri Mar 29 05:21:30 GMT 2024

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

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

Back to the top