Global selection [message #480658] |
Tue, 18 August 2009 02:43  |
Eclipse User |
|
|
|
Hey all,
i have a handler which should be active when a selection was made in my
tableviewer. So i registered my TableViewer as selection provider and used
the activeWhen declaration like that:
<activeWhen>
<and>
<reference definitionId="vas.ek.perspective.check">
</reference>
<with variable="selection">
<count value="+">
</count>
</with>
</and>
</activeWhen>
Everything works fine as long as iŽm in the view with the TableViewer. But
now i want to be able to open the selected Object also when another view
is Active. How can i do that? Is there something like a "global selection"?
Thanks a lot
Greetz
Thomas
|
|
|
|
|
Re: Global selection [message #480701 is a reply to message #480697] |
Tue, 18 August 2009 05:39  |
Eclipse User |
|
|
|
The global workbench selection is taken from the active view. That's why your expressions is only true when your view is active.
You could write a property tester that acts at against Object and use that in your expression ... when your view knew that your view has a selection change it would have to call org.eclipse.ui.services.IEvaluationService.requestEvaluation (String) to update expressions that use that property.
The other alternative is to write a programmatic handler that can check the enabled state of your view selection directly. Then activate it through your view site IHandlerService using org.eclipse.ui.handlers.IHandlerService.activateHandler(Stri ng, IHandler, Expression, boolean).
Both of these suggestions only work for commands you provide ... they wouldn't work for copy, for example.
PW
|
|
|
Re: Global selection [message #480707 is a reply to message #480697] |
Tue, 18 August 2009 05:38  |
Eclipse User |
|
|
|
Sorry, I miss understood your question, forgive my poor English.
1. define a variable for expression
In org.eclipse.ui.services extension point, you can define your own
variable which will be used in expression like as "selection"
So you can provider some variable like "myTableSelection" or something
like it. refer ISourceProvider and AbstractSourceProvider. Your provider
takes responsibility to update variable with selection of your table
viewer.
then change expression like this:
<with variable="variableNameYouDefined">
...
</with>
2. Property tester can be solution too, but I think you perfer to first
approach.
T. Wilhelm wrote:
> hey Jiyul,
>
> Here is the declaration of the reference, but i dont have any view
> restriction in it: <extension
> point="org.eclipse.core.expressions.definitions">
> <definition
> id="vas.ek.perspective.check">
> <with
> variable="activeWorkbenchWindow.activePerspective">
> <equals
> value="myPerspectiveId">
> </equals>
> </with>
> </definition>
> </extension>
>
> To check the type of selection doesnt bring any advantage. My problem is
> that i have a view (call it view1) which has a tableViewer which is
> registered as SelectionProvider
> (getViewSite().setSelectionProvider(myTableViewer)). When i click on
> another view (i.e. view2) my handler gets disabled. But i want it to be
> enabled as long as there is a selection in my table, no matter which
> view is active.
> Thanks alot
> Thomas
|
|
|
Powered by
FUDForum. Page generated in 0.03822 seconds