Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Global selection
Global selection [message #480658] Tue, 18 August 2009 06:43 Go to next message
T. Wilhelm is currently offline T. WilhelmFriend
Messages: 129
Registered: July 2009
Senior Member
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 #480672 is a reply to message #480658] Tue, 18 August 2009 08:04 Go to previous messageGo to next message
Jeeeyul Lee is currently offline Jeeeyul LeeFriend
Messages: 117
Registered: July 2009
Location: Seoul
Senior Member

to sure, I need declaration of reference "vas.ek.perspective.check".

I think that definition may has some active view restriction. remove it.


Every selection which connected with site selection will be active
global(in Workbench Window scoped) selection. (You should consider
multiple workbench window environment.)

If you can sure your handler works with just correct selection, try this
one:
<activeWhen>
<with variable="selection">
<iterate operator="and">
<instanceof value="yourpackage.correctType" />
</iterate>
</with>
</activeWhen>
It checks type of every elements in selection.



T. Wilhelm wrote:
> 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 #480697 is a reply to message #480672] Tue, 18 August 2009 09:12 Go to previous messageGo to next message
T. Wilhelm is currently offline T. WilhelmFriend
Messages: 129
Registered: July 2009
Senior Member
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




Jiyul wrote:

> to sure, I need declaration of reference "vas.ek.perspective.check".

> I think that definition may has some active view restriction. remove it.


> Every selection which connected with site selection will be active
> global(in Workbench Window scoped) selection. (You should consider
> multiple workbench window environment.)

> If you can sure your handler works with just correct selection, try this
> one:
> <activeWhen>
> <with variable="selection">
> <iterate operator="and">
> <instanceof value="yourpackage.correctType" />
> </iterate>
> </with>
> </activeWhen>
> It checks type of every elements in selection.



> T. Wilhelm wrote:
>> 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 09:39 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

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 09:38 Go to previous message
Jeeeyul Lee is currently offline Jeeeyul LeeFriend
Messages: 117
Registered: July 2009
Location: Seoul
Senior Member

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
Previous Topic:Error log view triggers dozens of EditorPart.getAdapter() calls
Next Topic:how to perform a manual local site update
Goto Forum:
  


Current Time: Fri Apr 26 19:28:34 GMT 2024

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

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

Back to the top