Skip to content

Commit

Permalink
Added update of hydrogens after edit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Arvid Berg committed Nov 6, 2009
1 parent b3f5139 commit 60726a1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Expand Up @@ -1972,7 +1972,10 @@ public void execute( IEdit edit ) {
;//The optional edit is not final so do not put in on the undo stack
else
postEdit( edit );
//TODO add implicit hydrogen calculation and aromacity

for(IAtom atom:edit.getAtomsToUpdate()) {
updateAtom( ac, atom );
}
fireEvents( edit.getTypeOfChanges() );
}

Expand Down
Expand Up @@ -26,6 +26,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -80,7 +81,8 @@ void updateHydrogenCount( IAtom... atoms ) {
}

public Collection<IAtom> getAtomsToUpdate() {
return atomsToUpdate;
if(atomsToUpdate == null) return Collections.emptySet();
else return atomsToUpdate;
}

public void execute( IAtomContainer ac ) {
Expand Down
Expand Up @@ -25,12 +25,14 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.openscience.cdk.controller.Changed;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;

/**
Expand Down Expand Up @@ -98,4 +100,12 @@ public void undo() {
// reverse list
}

@Override
public Collection<IAtom> getAtomsToUpdate() {
Collection<IAtom> atoms = new ArrayList<IAtom>();
for(IEdit edit:edits)
atoms.addAll( edit.getAtomsToUpdate() );
return atoms;
}

}

0 comments on commit 60726a1

Please sign in to comment.