From: <sh...@us...> - 2009-03-12 12:28:49
|
Revision: 14468 http://cdk.svn.sourceforge.net/cdk/?rev=14468&view=rev Author: shk3 Date: 2009-03-12 12:28:46 +0000 (Thu, 12 Mar 2009) Log Message: ----------- atom context menu properties settings undoable Modified Paths: -------------- jchempaint/trunk/src/main/org/openscience/jchempaint/action/EditChemObjectPropsAction.java jchempaint/trunk/src/main/org/openscience/jchempaint/dialog/editor/AtomEditor.java Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/action/EditChemObjectPropsAction.java =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/action/EditChemObjectPropsAction.java 2009-03-12 12:23:14 UTC (rev 14467) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/action/EditChemObjectPropsAction.java 2009-03-12 12:28:46 UTC (rev 14468) @@ -57,7 +57,7 @@ editor = new PseudoAtomEditor(); } else if (object instanceof Atom) { - editor = new AtomEditor(jcpPanel.getChemModel()); + editor = new AtomEditor(jcpPanel.get2DHub()); } else if (object instanceof Reaction) { editor = new ReactionEditor(); Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/dialog/editor/AtomEditor.java =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/dialog/editor/AtomEditor.java 2009-03-12 12:23:14 UTC (rev 14467) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/dialog/editor/AtomEditor.java 2009-03-12 12:28:46 UTC (rev 14468) @@ -39,6 +39,7 @@ import org.openscience.cdk.PseudoAtom; import org.openscience.cdk.config.IsotopeFactory; +import org.openscience.cdk.controller.IChemModelRelay; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IChemModel; @@ -56,12 +57,12 @@ JTextField symbolField; JSpinner hCountField; JSpinner formalChargeField; - IChemModel chemModel; + IChemModelRelay hub; - public AtomEditor(IChemModel chemModel) { + public AtomEditor(IChemModelRelay hub) { super(); constructPanel(); - this.chemModel=chemModel; + this.hub=hub; super.mayclose=false; } @@ -92,20 +93,26 @@ IAtom atom = (IAtom)source; try{ if(IsotopeFactory.getInstance(atom.getBuilder()).getElement(symbolField.getText())!=null){ - atom.setSymbol(symbolField.getText()); - atom.setHydrogenCount(((Integer)hCountField.getValue()).intValue()); - atom.setFormalCharge(((Integer)formalChargeField.getValue()).intValue()); + if(atom.getHydrogenCount()!=((Integer)hCountField.getValue()).intValue()) + hub.setHydrogenCount(atom,((Integer)hCountField.getValue()).intValue()); + if(atom.getFormalCharge()!=((Integer)formalChargeField.getValue()).intValue()) + hub.setCharge(atom,((Integer)formalChargeField.getValue()).intValue()); + if(!atom.getSymbol().equals(symbolField.getText())) + hub.setSymbol(atom, symbolField.getText()); }else{ - IAtomContainer relevantContainer = ChemModelManipulator.getRelevantAtomContainer(chemModel, atom); PseudoAtom pseudo = new PseudoAtom(atom); pseudo.setLabel(symbolField.getText()); - AtomContainerManipulator.replaceAtomByAtom(relevantContainer, - atom, pseudo); + pseudo.setHydrogenCount(((Integer)hCountField.getValue()).intValue()); + pseudo.setFormalCharge(((Integer)formalChargeField.getValue()).intValue()); + hub.replaceAtom(pseudo, atom); } }catch(IOException ex){ - atom.setSymbol(symbolField.getText()); - atom.setHydrogenCount(((Integer)hCountField.getValue()).intValue()); - atom.setFormalCharge(((Integer)formalChargeField.getValue()).intValue()); + if(atom.getHydrogenCount()!=((Integer)hCountField.getValue()).intValue()) + hub.setHydrogenCount(atom,((Integer)hCountField.getValue()).intValue()); + if(atom.getFormalCharge()!=((Integer)formalChargeField.getValue()).intValue()) + hub.setCharge(atom,((Integer)formalChargeField.getValue()).intValue()); + if(!atom.getSymbol().equals(symbolField.getText())) + hub.setSymbol(atom, symbolField.getText()); new LoggingTool(this).error("IOException when trying to test element symbol"); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |