Help needed writing a custom expression for visibleWhen of a command menuContribution [message #325887] |
Fri, 29 February 2008 17:35  |
Eclipse User |
|
|
|
I work on an RCP-based application and I'm trying to use the
org.eclipse.ui.menus extension point to conditionally include a toolbar
item in a view's local toolbar where the toolbar item is contributed
from a different plug-in. I'd like the toolbar item to conditionally
show up, however, I'm having trouble with building an expression to make
this happen. The problem is that I need the condition to evaluate for
the hosting view's input and not a selection in the view. I was
wondering if someone could help me with this problem.
I defined a command and a handler for the action. I then created an
extension to org.eclipse.ui.menus which uses <menuContribution> and
<command>. The location URI for the menuContribution uses the "toolbar"
scheme and my view's id. I'd like to build an expression using
<visibleWhen> to show or hide the toolbar item.
My view takes as input a specific object which contains a reference to a
parent object. The parent object has a type property whose values are
either type1 or type2. I'd like for the toolbar item to only appear
whenever the type of the view input's parent object is type1. I'd like
the expression to get the view's input, then from it get the input's
parent and finally check the type on the parent object.
Can I write an expression where the context is set to either the view id
specified in the menuContribution's location URI, or a specific view id
(which would be set to the same value as the one in the location URI)?
If I could get this, I could maybe use a propertyTester to translate
from the view to its input to its parent object's type. Given a parent
object I already have a propertyTester which can test it's type. I just
can't figure out how to get to the parent object.
I see how to set the context to the activeViewId, however, I want the
expression context set to a specific view since this visibility
expression will be defined for a command contributed to a specific view.
If I used activeViewId, the command would appear or disappear when
unrelated views are activated which wouldn't be good because it's only
hosted in the specific view. Currently the context is based on the
current selection which isn't that useful for this case.
Is there perhaps another way to go about this?
Any help is appreciated.
-Ryan
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04920 seconds