From: <sh...@us...> - 2008-09-29 14:12:25
|
Revision: 12493 http://cdk.svn.sourceforge.net/cdk/?rev=12493&view=rev Author: shk3 Date: 2008-09-29 14:12:09 +0000 (Mon, 29 Sep 2008) Log Message: ----------- - After a save as, further saves work (caused a npe till now) Modified Paths: -------------- cdk/branches/cdk-1.0.x/changelog.txt cdk/branches/cdk-1.0.x/src/org/openscience/cdk/applications/jchempaint/action/OpenAction.java cdk/branches/cdk-1.0.x/src/org/openscience/cdk/applications/jchempaint/action/SaveAsAction.java Modified: cdk/branches/cdk-1.0.x/changelog.txt =================================================================== --- cdk/branches/cdk-1.0.x/changelog.txt 2008-09-29 13:44:24 UTC (rev 12492) +++ cdk/branches/cdk-1.0.x/changelog.txt 2008-09-29 14:12:09 UTC (rev 12493) @@ -6,6 +6,7 @@ - The viewer applet no longer has the vertical scroll bar when not necessary - background parameter of applet accepts hexadecimal values - When opening a file and there is unsaved content, jcp asks for save (was silently dropped till now) +- After a save as, further saves work (caused a npe till now) ------------------------------------------------------------------------ Modified: cdk/branches/cdk-1.0.x/src/org/openscience/cdk/applications/jchempaint/action/OpenAction.java =================================================================== --- cdk/branches/cdk-1.0.x/src/org/openscience/cdk/applications/jchempaint/action/OpenAction.java 2008-09-29 13:44:24 UTC (rev 12492) +++ cdk/branches/cdk-1.0.x/src/org/openscience/cdk/applications/jchempaint/action/OpenAction.java 2008-09-29 14:12:09 UTC (rev 12493) @@ -163,10 +163,7 @@ //we do nothing - firstly if IO does not work, we should not get here, secondly, if only this does not work, don't worry } } - int result=jcpPanel.showWarning(); - if(result==JOptionPane.YES_OPTION){ - new SaveAction(jcpPanel,false).actionPerformed(e); - } + jcpPanel.showWarning(); String error = null; ChemModel chemModel = null; IChemFile chemFile=null; Modified: cdk/branches/cdk-1.0.x/src/org/openscience/cdk/applications/jchempaint/action/SaveAsAction.java =================================================================== --- cdk/branches/cdk-1.0.x/src/org/openscience/cdk/applications/jchempaint/action/SaveAsAction.java 2008-09-29 13:44:24 UTC (rev 12492) +++ cdk/branches/cdk-1.0.x/src/org/openscience/cdk/applications/jchempaint/action/SaveAsAction.java 2008-09-29 14:12:09 UTC (rev 12493) @@ -168,19 +168,19 @@ { if (type.equals(JCPSaveFileFilter.mol)) { - saveAsMol(model, outFile); + outFile = saveAsMol(model, outFile); } else if (type.equals(JCPSaveFileFilter.cml)) { - saveAsCML2(model, outFile); + outFile = saveAsCML2(model, outFile); } else if (type.equals(JCPSaveFileFilter.smiles)) { - saveAsSMILES(model, outFile); + outFile = saveAsSMILES(model, outFile); } else if (type.equals(JCPSaveFileFilter.svg)) { - saveAsSVG(model, outFile); + outFile = saveAsSVG(model, outFile); } else if (type.equals(JCPSaveFileFilter.cdk)) { - saveAsCDKSourceCode(model, outFile); + outFile = saveAsCDKSourceCode(model, outFile); } else { String error = "Cannot save file in this format: " + type; @@ -203,7 +203,7 @@ { if (type.equals(JCPSaveFileFilter.cml)) { - saveAsCML2(object, outFile); + outFile = saveAsCML2(object, outFile); } else { String error = "Cannot save reaction in this format: " + type; @@ -233,7 +233,7 @@ .getProperty("askForIOSettings", "true").equals("true"); } - protected void saveAsMol(IChemModel model, File outFile) throws Exception + protected File saveAsMol(IChemModel model, File outFile) throws Exception { logger.info("Saving the contents in a MDL molfile file..."); String fileName = outFile.toString(); @@ -250,13 +250,14 @@ org.openscience.cdk.interfaces.IMoleculeSet som = model.getMoleculeSet(); cow.write(som); cow.close(); + return outFile; } - protected void saveAsCML2(IChemObject object, File outFile) throws Exception + protected File saveAsCML2(IChemObject object, File outFile) throws Exception { if(Float.parseFloat(System.getProperty("java.specification.version"))<1.5){ JOptionPane.showMessageDialog(null,"For saving as CML you need Java 1.5 or higher!"); - return; + return outFile; } logger.info("Saving the contents in a CML 2.0 file..."); String fileName = outFile.toString(); @@ -282,9 +283,10 @@ cow.write(object); cow.close(); sw.close(); + return outFile; } - protected void saveAsSMILES(IChemModel model, File outFile) throws Exception + protected File saveAsSMILES(IChemModel model, File outFile) throws Exception { logger.info("Saving the contents in SMILES format..."); String fileName = outFile.toString(); @@ -300,9 +302,10 @@ org.openscience.cdk.interfaces.IMoleculeSet som = model.getMoleculeSet(); cow.write(som); cow.close(); + return outFile; } - protected void saveAsCDKSourceCode(IChemModel model, File outFile) throws Exception + protected File saveAsCDKSourceCode(IChemModel model, File outFile) throws Exception { logger.info("Saving the contents as a CDK source code file..."); String fileName = outFile.toString(); @@ -325,9 +328,10 @@ } } cow.close(); + return outFile; } - protected void saveAsSVG(IChemModel model, File outFile) throws Exception + protected File saveAsSVG(IChemModel model, File outFile) throws Exception { logger.info("Saving the contents as a SVG file..."); cow = new SVGWriter(new FileWriter(outFile)); @@ -347,6 +351,7 @@ } } cow.close(); + return outFile; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |