// a different access
// to current layer is adopted
if (MergeContext.getInstance().getMergeMode() == MergeContext.MERGEMODE_TOOL) {
// sets the command using the features present in the merge
// builder
IToolContext context = getContext();
layer = context.getSelectedLayer();
} else if (MergeContext.getInstance().getMergeMode() == MergeContext.MERGEMODE_OPERATION) {
layer = ApplicationGIS.getActiveMap().getEditManager()
.getSelectedLayer();
}
MergeFeatureBuilder mergeBuilder = mergeComposite.getMergeBuilder();
final List<SimpleFeature> sourceFeatures = mergeBuilder
.getSourceFeatures();
final SimpleFeatureCollection sourceFeaturesCollection = DataUtilities
.collection(sourceFeatures);
final SimpleFeature mergedFeature = mergeBuilder
.buildMergedFeature();
mergeBuilder.removeFromSourceFeatures(sourceFeatures);
MergeFeaturesCommand cmd = MergeFeaturesCommand.getInstance(layer,
sourceFeaturesCollection, mergedFeature);
context.getMap().sendCommandASync(cmd);
StatusBar.setStatusBarMessage(context,
Messages.MergeTool_successful);
context.getViewportPane().repaint();
close();
}