Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Visibility of Menu Contributions - a suggestion
Visibility of Menu Contributions - a suggestion [message #330565] Sat, 02 August 2008 11:53 Go to next message
Kai Schlamp is currently offline Kai SchlampFriend
Messages: 344
Registered: July 2009
Senior Member
Hello.
In my RCP application I have many custom properties (like
isConnectedToDatabase, isServiceRunning) that affects the visibility of
various menu and toolbar items.
If I understand the Menu Contributions correctly, the way would be to
use custom sources or property testers. I use the later one. So I have
to write property tester(s) for my custom properties plus call the
IEvaluationService in the original class of the properties to force
reevalutation after a property was changed.
I wonder now, if there is really no way to show/hide/disable/enable menu
items or toolbar items fully programmatically (I don't see a way at the
moment to do this, am I wrong?).

I suggest to have following functions:
IMenuService.setVisible(boolean visible, String menuId)
ICommandService.setEnabled(boolean enabled, String commandId)

This would allow to setup commands and menu contributions declaratively,
but also allow to modify the visibility programmatically.

What do you think?

Best regards,
Kai
Re: Visibility of Menu Contributions - a suggestion [message #330700 is a reply to message #330565] Sun, 10 August 2008 05:59 Go to previous messageGo to next message
Shawn Spiars is currently offline Shawn SpiarsFriend
Messages: 16
Registered: July 2009
Junior Member
Kai,

This is probably not the official eclipse way to do this, but here
is what I do. I am using the CommonNavigator and have a class that
extends the CommonActionProvider. I put my program logic that
determines which menu items to show/hide/disable/enable inside of the
fillContextMenu(IMenuManager menu) method.

Shawn
Phurnace Software


Kai Schlamp wrote:
> Hello.
> In my RCP application I have many custom properties (like
> isConnectedToDatabase, isServiceRunning) that affects the visibility of
> various menu and toolbar items.
> If I understand the Menu Contributions correctly, the way would be to
> use custom sources or property testers. I use the later one. So I have
> to write property tester(s) for my custom properties plus call the
> IEvaluationService in the original class of the properties to force
> reevalutation after a property was changed.
> I wonder now, if there is really no way to show/hide/disable/enable menu
> items or toolbar items fully programmatically (I don't see a way at the
> moment to do this, am I wrong?).
>
> I suggest to have following functions:
> IMenuService.setVisible(boolean visible, String menuId)
> ICommandService.setEnabled(boolean enabled, String commandId)
>
> This would allow to setup commands and menu contributions declaratively,
> but also allow to modify the visibility programmatically.
>
> What do you think?
>
> Best regards,
> Kai
Re: Visibility of Menu Contributions - a suggestion [message #330855 is a reply to message #330565] Thu, 14 August 2008 17:23 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Kai Schlamp wrote:
> I wonder now, if there is really no way to show/hide/disable/enable menu
> items or toolbar items fully programmatically (I don't see a way at the
> moment to do this, am I wrong?).

No, there's no programmatic way to do this. It had to do with who owns
the actions (framework) and who owns the behaviour (client) and the
various lifecycles, and then on the command framework it has to do with
the separation of the command, handler, and UI element that was added in
response to some of the usecases the action framework couldn't handle.

Something I'm interested in solving is the fact that the UI element
(menu or tool item) is in a context (it's in a view, or the main
toolbar, or a form editor section, etc), but the command determines if
it is enabled or not, and the command has a hard time finding out that
UI context information.

There does have to be a separation between UI (view), model, and
controller, but it seems to me the enablement of a UI element should be
calculated in the context of that UI element.

This is not a simple problem to solve, though, so it'll probably take a
lot of time.

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


Previous Topic:code to test "objectClass" of object contribution of "popupMenus" extension-poin
Next Topic:CVS and Linked Source Folder
Goto Forum:
  


Current Time: Tue Jul 16 16:56:14 GMT 2024

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

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

Back to the top