public void selectionChanged( IWorkbenchPart part, final ISelection selection ) {
if (part == MapEditorWithPalette.this || getSite().getPage().getActivePart() != part
|| selection instanceof IBlockingSelection)
return;
ISafeRunnable sendAnimation = new ISafeRunnable(){
public void run() {
if (selection instanceof IStructuredSelection) {
IStructuredSelection s = (IStructuredSelection) selection;
List<SimpleFeature> features = new ArrayList<SimpleFeature>();
for( Iterator iter = s.iterator(); iter.hasNext(); ) {
Object element = iter.next();
if (element instanceof SimpleFeature) {
SimpleFeature feature = (SimpleFeature) element;
features.add(feature);
} else if (element instanceof IAdaptable) {
final IAdaptable adaptable = (IAdaptable) element;
final Object featureObj = adaptable.getAdapter(SimpleFeature.class);
if (featureObj != null && featureObj instanceof SimpleFeature) {
final SimpleFeature feature = (SimpleFeature) featureObj;
features.add(feature);
}
}
}
if (features.size() == 0)
return;
if (!getRenderManager().isDisposed()) {
IAnimation anim = createAnimation(features);
if (anim != null)
AnimationUpdater.runTimer(getMap().getRenderManager()
.getMapDisplay(), anim);
}
}
}
public void handleException( Throwable exception ) {
ProjectUIPlugin.log("Exception preparing animation", exception); //$NON-NLS-1$
}
};
try {
sendAnimation.run();
} catch (Exception e) {
ProjectUIPlugin.log("", e); //$NON-NLS-1$
}
// PlatformGIS.run(sendAnimation);
}