Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Hide/Show MenuItems in a Menu
Hide/Show MenuItems in a Menu [message #530265] Thu, 29 April 2010 03:16 Go to next message
Missing name Mising name is currently offline Missing name Mising name
Messages: 10
Registered: February 2010
Junior Member
Is there a way to hide/show MenuItems inside a Menu?
Neither Menu provides something like menu.setVisible (int index_of_menu_item) nor MenuItem provides anything like menuitem.setVisible (boolean)

Thus, for menus whose contents change depending on the context, the code for creating menu is repeated over and over again (during each pop-up of the menu) which involves adding listeners for menu selection too.
This is quite inefficient I guess.

Simple hide/show mechanism will enable create-once-use-forever approach which will be very efficient.
Re: Hide/Show MenuItems in a Menu [message #530487 is a reply to message #530265] Thu, 29 April 2010 14:46 Go to previous message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

you're correct, removing menu items means disposing them. Adding one
back in the correct place involves creating the MenuItem with the
correct index.

In the eclipse Platform we use MenuManager and ContributionItems that
manage the logic of when to dispose and when to recreate MenuItems.
They come from org.eclipse.jface.

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/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Previous Topic:org.eclipse.swt.widgets.Text and Scroll bar
Next Topic:Wrong cell color return in Linux
Goto Forum:
  


Current Time: Sat Aug 30 18:32:18 EDT 2014

Powered by FUDForum. Page generated in 0.01765 seconds