}
@Override
public void perform( IProgressMonitor monitor ) {
Layer destinationLayer;
IMap destinationMap;
if( getDestination() instanceof IMap ){
destinationMap=(IMap) getDestination();
destinationLayer=(Layer) destinationMap.getEditManager().getSelectedLayer();
}else if( getDestination() instanceof Layer ){
destinationLayer=(Layer)getDestination();
destinationMap=destinationLayer.getMap();
}else {
return;
}
if( getData() instanceof IAdaptable ){
ILayer layer=(ILayer) ((IAdaptable)getData()).getAdapter(ILayer.class);
Filter filter=(Filter) ((IAdaptable)getData()).getAdapter(Filter.class);
if (filter == null) {
SimpleFeature feature = (SimpleFeature) ((IAdaptable) getData()).getAdapter(SimpleFeature.class);
FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
if (feature != null) {
filter = filterFactory.id(FeatureUtils.stringToId(
filterFactory, feature.getID()));
} else {
return;
}
}
if( layer==null){
setSelection(filter==null?(Filter)getData():filter, destinationLayer, monitor);
}else{
MapCommand c=EditCommandFactory.getInstance().createCopyFeaturesCommand( layer, filter, destinationLayer);
destinationMap.sendCommandASync(c);
}
}else{
setSelection((Filter)getData(), destinationLayer, monitor);
}
}