Skip to content

Commit

Permalink
Removed duplicate of code for synchronizing CKDMolecule with ChemMode…
Browse files Browse the repository at this point in the history
…l from editor.

Also fixed the case where the atom container in the controller hub is the same as the one in the cdkmolecule.
  • Loading branch information
goglepox committed Mar 29, 2012
1 parent 84467af commit 4d64c21
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
Expand Up @@ -559,17 +559,7 @@ public void setInput( Object element ) {
}

public ICDKMolecule getCDKMolecule() {
ICDKMolecule model = widget.getMolecule();
if(model == null) return null;
IAtomContainer modelContainer = model.getAtomContainer();
modelContainer.removeAllElements();
IChemModel chemModel = getControllerHub().getIChemModel();
for(IAtomContainer aContainer:ChemModelManipulator
.getAllAtomContainers( chemModel )) {
modelContainer.add( aContainer );
}

return model;
return widget.getMolecule();
}

public void setMoleculeProperty(Object key,Object value) {
Expand Down
Expand Up @@ -923,12 +923,15 @@ public void addDropSupport(int operations, Transfer[] transferTypes,
public ICDKMolecule getMolecule() {
ICDKMolecule model = super.getMolecule();
if(model == null) return null;
IAtomContainer modelContainer = model.getAtomContainer();
modelContainer.removeAllElements();
IChemModel chemModel = getControllerHub().getIChemModel();
for(IAtomContainer aContainer:ChemModelManipulator
.getAllAtomContainers( chemModel )) {
modelContainer.add( aContainer );
List<IAtomContainer> modelAtomContainers = ChemModelManipulator
.getAllAtomContainers( chemModel );
IAtomContainer modelContainer = model.getAtomContainer();
if( !modelAtomContainers.contains(modelContainer)) {
modelContainer.removeAllElements();
for(IAtomContainer aContainer:modelAtomContainers) {
modelContainer.add( aContainer );
}
}
return model;
}
Expand Down

0 comments on commit 4d64c21

Please sign in to comment.