Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] how to listen for selection changes _WITHOUT_ a view?

I finally worked out how to gain access to the service,
but when i use the uDig editor to select stuff, i do not get notifications… (i tried the info tool and the ‚select with rectangle‘ tool (sorry, it is german here, and i have no clue how ist called in the english version…)

The new code to register at workbench is attached as RegisterAtWorkbench.java (not the most beautiful way, but it works!)

Any comments about how to react to selection changes are welcome!!

Thanks!

P Bitte denken Sie an die Umwelt, bevor Sie dieses Mail drucken. Avon da stampar questa communicaziun patertgei vid igl ambient. Prima di stampare questo messaggio pensate all' ambiente

 

Von: udig-devel-bounces@xxxxxxxxxxxxxxxxxxxxx [mailto:udig-devel-bounces@xxxxxxxxxxxxxxxxxxxxx] Im Auftrag von Moser-Spitzenstaetter Ludwig
Gesendet: Montag, 06. Mai 2013 08:29
An: User-friendly Desktop Internet GIS
Betreff: [udig-devel] how to listen for selection changes _WITHOUT_ a view?

 

Hello NG,

 

i’ve been looking through the Workbench example with the SelectionListener from Eclipse.

In my case i do not want to use a View to listen for changes, i want to use an OSGi Service.

Therefore i have no getSite().getWorkbenchWindow() etc…

 

How can i gain access to the SelectionService mwithout a view?

 

I tried to get it via the Activator like this:

 

            Activator activator = Activator.getDefault();

            IWorkbench workbench = activator.getWorkbench();

            IWorkbenchWindow workbenchWindow =

            workbench.getActiveWorkbenchWindow();

            return workbenchWindow.getSelectionService();

 

this failed for me!

Then i tried to get it via PlatformUI:

 

ISelectionService selectionService = (ISelectionService) PlatformUI

                        .getWorkbench().getActiveWorkbenchWindow()

                        .getService(ISelectionService.class);

            return selectionService;

 

but also this fails.

 

i thought this might happen as my service tries to get the SelectionService too early when no WorkbenchWindow is active, so i retry and retry. But i NEVER get this service, in no way described above.

 

Why? How can i gain this Service properly without View?

 

Thanks in advance!

Ludwig

 

PS: why no view? Because it would need activation before i can use it. If i have a service running i can open the proper perspective/view when needed…

Attachment: RegisterAtWorkbench.java
Description: RegisterAtWorkbench.java


Back to the top