Hi, to get more then one layer, you have to step down into the eclipse api and ask the view for what was selected:
ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getActivePage().findView(LayersView.ID).getSite().getSelectionProvider() .getSelection(); if (selection instanceof TreeSelection) { TreeSelection treeSelection = (TreeSelection) selection; Iterator iterator = treeSelection.iterator(); while( iterator.hasNext() ) { Object object = iterator.next(); if (object instanceof LayerImpl) { LayerImpl layer = (LayerImpl) object; YourResourceClass resource = layer.getResource( YourResourceClass.class, new NullProgressMonitor()); if (resource != null) { // do fun with resource } } } } Ciao Andrea On Fri, Apr 24, 2009 at 4:17 PM, Rui Alves <rui.maia.al...@gmail.com> wrote: > Hi, > > I am using the latest uDig stable version 1.1.1 and I want to have the > following scenario: > > I have a map with 4 layers: > > Layer4 - Lines > Layer3 - Points type C > Layer2 - Points type B > Layer1 - Points type A > > I want to select (with the typical selection Bounding Box) points on Layer 1 > and layer 3. > > Using the shift key I can select multiple layers (on this case Layer 1 and > layer 3) but when I use the selection tool only the features on the last > selected layer are selected. > I made a plug-in that goes through all the layers and select the features on > the defined bounding box. I can also restrict the selection to the layers > that are visible. > How can I restrict the selection to the selected layers (on this case layer > 1 and 3)? > > Here it is the code to select the features in all layers: > > Envelope ev; > Coordinate start; > > --------- on mouse pressed ---------- > > start=getContext().pixelToWorld(e.x, e.y); > ev.init(); > ev.expandToInclude(start); > > --------- on mouse released ---------- > Coordinate end=getContext().pixelToWorld(e.x, e.y); > ev.expandToInclude(end); > > > for(int layerInd = 0; layerInd <= map.getMapLayers().size() - 1; > layerInd++) > { > ILayer layer = map.getMapLayers().get(layerInd); > > if(layer.isVisible()) > { > Filter filter = layer.createBBoxFilter(ev, null); > command = > getContext().getSelectionFactory().createSelectCommand(layer, filter); > getContext().sendASyncCommand(command); > } > } > > Thanks, > > Rui Alves > > > _______________________________________________ > User-friendly Desktop Internet GIS (uDig) > http://udig.refractions.net > http://lists.refractions.net/mailman/listinfo/udig-devel > > _______________________________________________ User-friendly Desktop Internet GIS (uDig) http://udig.refractions.net http://lists.refractions.net/mailman/listinfo/udig-devel