Hi,
I guess i did not gave enough description to my problem...
I have a custom catalog, and it does not appear to support selection.
Until now, Ive done:
added to view plugin in createPartControl method
final ISelectionService selectionService =
getViewSite().getWorkbenchWindow().getSelectionService();
selectionService.addSelectionListener(new WorkbenchSelectionListener());
where WorkbenchSelectionListener implements ISelectionListener.
and there implemented selectionChanged,as shown
public void selectionChanged( IWorkbenchPart part, ISelection selection ) {
updateSelection((IStructuredSelection) selection);
}
private void updateSelection( IStructuredSelection selection ) {
Object selected = selection.getFirstElement();
final Layer selectedLayer;
if (selected instanceof Map) {
selectedLayer = ((Map)
selected).getEditManagerInternal().getSelectedLayer();
} else if (selected instanceof Layer) {
selectedLayer = (Layer) selected;
} else if (selected instanceof AdaptingFilter) {
AdaptingFilter adaptingFilter = (AdaptingFilter) selected;
selectedLayer = (Layer) adaptingFilter.getAdapter(Layer.class);
} else {
return;
}
GetSelectedFeaturesFromLayer.getSelectedFeaturesFromLayerRestrictedToFIDs(selectedLayer,
null);
}
and there, while calling getSelectedFeaturesFromLayerRestrictedToFIDs,
i get exception that schema is null.
getSelectedFeaturesFromLayerRestrictedToFIDs can be found here:
http://www.koders.com/java/fidF3B10E04E5583C0120063667A798B0E4FBC4599B.aspx?s=FeatureExportTask
any ideas?
Thanks,
Milan
> Jody Garnett
> Thu, 14 May 2009 16:01:55 -0700
>
> Okay; I have not tried that technique before. I usually listen to
> workbench selection and see if the current selection adapts to a layer
> (and then use the layer.getFilter() method).
>
> A raster layer or mapgraphic will not have a schema; a schema is only
> for vector layers.
> Jody
>
> On Fri, May 15, 2009 at 7:45 AM, Milan Dinic <[email protected]> wrote:
> > Hi,
> >
> > context menu option is not my goal, i need to get selection without
> > extra clicking on tools on menu items.
> > I've managed to catch selection event by creating class that
> > implements the ISelectionListener, and by adding instance of this
> > class to the selection service.
> >
> > My next problem occurred while using
> > GetSelectedFeaturesFromLayer
> > (http://www.koders.com/java/fidF3B10E04E5583C0120063667A798B0E4FBC4599B.aspx?s=FeatureExportTask)
> > I'm getting null for the layer.getSchema()
> >
> > Query query = new
> > DefaultQuery(layer.getSchema().getName().getLocalPart(),
> > layer.getFilter(), new String[0]);
> >
> > any idea when (why) layer might be without scheme?
> >
> > Thanks,
> > Milan
> > _______________________________________________
> > 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