Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Hiding MenuContriubtions for a given Command
Hiding MenuContriubtions for a given Command [message #327473] Mon, 21 April 2008 20:04 Go to next message
Stuart Pond is currently offline Stuart PondFriend
Messages: 27
Registered: July 2009
Junior Member
My RCP Application needs to hide all menuContributions tied to a certain
Command under certain application state (such as user role). The other
kicker is the list of commands that can be hidden is *dynamic* and thus can
not be specified in the plugin.xml.

I looked into Activities it seemed like that might work, but could not
figure how you could dynamically set the patterns in the PatternBinding.
This looks like it has to be managed from ActivityPatternBinding Extension
Point which is not acceptable.

So now, I am looking into PropertyTester on every MenuContribution's
visibleWhen clause. I figured out how to register a custom SourceProvider
that can fire PropertyChangeNotify events whenever the application state
changes (such as user role or the list of command ids to be hidden.

So I would have to add the following to every MenuContributions visibleWhen
expression
<with variable="custom.COMMAND_SUPPRESSION">
<test args="xxxCommandID" property="HIDDEN_TESTER"/>
</with>

Or am I missing something more obvious, better way to do it??
Re: Hiding MenuContriubtions for a given Command [message #327527 is a reply to message #327473] Wed, 23 April 2008 14:58 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

There are a couple of ways to do it ... if the system admin of your RCP
app can configure which roles link to which commands, then you would
probably have to use your property tester.

The best way to do it is to create a couple of
org.eclipse.core.expressions.definitions and reuse them in your menu
contribution visibleWhen clauses.

There is an outstanding feature (maybe 3.5?) for menu overrides, the
ability (especially for a product or RCP app) to override a menu item or
tool items visibility (and potentially other things like image, text,
enabled state, etc). Not implemented, and not well spec'ed out.

In 3.4 there is decent API to register your own source provider
(org.eclipse.ui.services), and also decent API to simply requests a
specific property tester-property be re-evaluated (IEvaluationService)
(if your property tester doesn't need a specific source).

In 3.3, it's a lot more "hackery", and not enough API.

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


Re: Hiding MenuContriubtions for a given Command [message #327530 is a reply to message #327527] Wed, 23 April 2008 15:52 Go to previous message
Stuart Pond is currently offline Stuart PondFriend
Messages: 27
Registered: July 2009
Junior Member
Yes, we are using Eclipse 3.3. and yes the system admin can configure the
roles to link to which commands.

I have created a command_suppression custom source and this works, but boy
is my menu contribution xml kind of ugly. Is there any way to clean this
up? Can Definitions take variables like command id

Every single command's MenuContribution has something like this:

<visibleWhen>
<with variable="command_suppression">
<not>
<iterate operator="or">
<equals
value="org.eclipse.ui.file.print">
</equals>
</iterate>
</not>
</with>
</visibleWhen>

Is there a way to clean this up. Is there a way to say currentCommandId?

Also, is there away I could add the visibleWhen clause programatically to
all commandContributions?

"Paul Webster" <pwebster@ca.ibm.com> wrote in message
news:funifo$akc$1@build.eclipse.org...
> There are a couple of ways to do it ... if the system admin of your RCP
> app can configure which roles link to which commands, then you would
> probably have to use your property tester.
>
> The best way to do it is to create a couple of
> org.eclipse.core.expressions.definitions and reuse them in your menu
> contribution visibleWhen clauses.
>
> There is an outstanding feature (maybe 3.5?) for menu overrides, the
> ability (especially for a product or RCP app) to override a menu item or
> tool items visibility (and potentially other things like image, text,
> enabled state, etc). Not implemented, and not well spec'ed out.
>
> In 3.4 there is decent API to register your own source provider
> (org.eclipse.ui.services), and also decent API to simply requests a
> specific property tester-property be re-evaluated (IEvaluationService) (if
> your property tester doesn't need a specific source).
>
> In 3.3, it's a lot more "hackery", and not enough API.
>
> 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:Label refresh
Next Topic:startup.jar in org.eclipse.releng.eclipsebuilder
Goto Forum:
  


Current Time: Thu Jun 27 19:50:36 GMT 2024

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

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

Back to the top