if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
IStructuredSelection selected = (IStructuredSelection) selection;
for( Iterator< ? > iter = selected.iterator(); iter.hasNext(); ) {
Object item = iter.next();
if (item instanceof ILayer) {
return new FeatureSiteImpl((ILayer) item);
} else if (item instanceof IMap) {
return new FeatureSiteImpl((IMap) item);
} else if (item instanceof IAdaptable) {
IAdaptable adaptable = (IAdaptable) item;
ILayer layer = (ILayer) adaptable.getAdapter(ILayer.class);
if (layer != null) {
return new FeatureSiteImpl(layer);
}
IMap map = (IMap) adaptable.getAdapter(IMap.class);
if (map != null) {
return new FeatureSiteImpl(map);
}
}
}
}
return null;