Eclipse set action visible on custom complex conditions
I want to restrict, set visible false, some actions in an eclipse rcp application, based on user role.
For example when opening editor A, if the user has admin role, show actions 1-2-3-4, but if the user doesn't have admin role, show only actions 1-2.
The action enablesFor
property is too simple for my need.
Is there a way to do this in an eclipse rcp app开发者_运维问答lication ?
There are also core expression enabled activities that can be used to hide most action and command contributions that come from a plugin.xml. See How remove pop-up menu contributions in eclipse RCP for an activity example that could be enhanced with an enabledWhen
expression.
There's an example of enabling contributions with activities based on a User's Role in the examples contribution plugin: http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.ui.examples.contributions/
You should use the org.eclipse.ui.menus extension point with a visibleWhen to show/hide your contributions. You can define and use property testers to determine whether the current user should be able to see the item or not. http://wiki.eclipse.org/Menu_Contributions
精彩评论