e.printStackTrace();
}
}
// Undo section to undo/redo the merge
IUndoRedoFactory factory = getUndoRedoFactory();
UndoRedoHandler handler = getUndoRedoHandler();
if (movedDistance != null && factory != null && handler != null) {
// we look if anything has been moved which was not merged
IAtomContainer undoRedoContainer = getIChemModel().getBuilder()
.newInstance(IAtomContainer.class);
if (renderer.getRenderer2DModel().getSelection()
.getConnectedAtomContainer() != null) {
undoRedoContainer.add(renderer.getRenderer2DModel()
.getSelection().getConnectedAtomContainer());
}
Iterator<IAtom> it2 = mergeMap.keySet().iterator();
while (it2.hasNext()) {
IAtom remove = it2.next();
undoRedoContainer.removeAtom(remove);
}
IUndoRedoable moveundoredo = getUndoRedoFactory().getMoveAtomEdit(
undoRedoContainer, movedDistance, "Move atom");
IUndoRedoable undoredo = factory.getMergeMoleculesEdit(mergedAtoms,
containers, droppedContainers, removedBondss,
bondsWithReplacedAtoms, movedDistance, mergedPartnerAtoms,
moveundoredo, oldRGroupHash, newRGroupHash,
"Move and merge atoms", this);
handler.postEdit(undoredo);