From: <sh...@us...> - 2008-11-27 13:54:51
|
Revision: 13341 http://cdk.svn.sourceforge.net/cdk/?rev=13341&view=rev Author: shk3 Date: 2008-11-27 13:54:46 +0000 (Thu, 27 Nov 2008) Log Message: ----------- removed the svg from save, some cleanups Modified Paths: -------------- jchempaint/trunk/src/main/org/openscience/jchempaint/JChemPaintPanel.java jchempaint/trunk/src/main/org/openscience/jchempaint/action/SaveAction.java jchempaint/trunk/src/main/org/openscience/jchempaint/action/SaveAsAction.java jchempaint/trunk/src/main/org/openscience/jchempaint/io/JCPSaveFileFilter.java Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/JChemPaintPanel.java =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/JChemPaintPanel.java 2008-11-27 13:46:04 UTC (rev 13340) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/JChemPaintPanel.java 2008-11-27 13:54:46 UTC (rev 13341) @@ -106,6 +106,22 @@ } /** + * Allows setting of the is modified stage (e. g. after save) + * + * @param isModified is modified + */ + public void setModified(boolean isModified) { + this.isModified = isModified; + if(this.getParent().getParent().getParent().getParent() instanceof JFrame){ + if(isModified) + ((JFrame)this.getParent().getParent().getParent().getParent()).setTitle(renderPanel.getChemModel().getID()+"*"); + else + ((JFrame)this.getParent().getParent().getParent().getParent()).setTitle(renderPanel.getChemModel().getID()); + } + } + + + /** * Helps in keeping the current action button highlighted - needs to be set * if a new action button is choosen * @@ -431,9 +447,7 @@ * @see org.openscience.cdk.interfaces.IChemObjectListener#stateChanged(org.openscience.cdk.interfaces.IChemObjectChangeEvent) */ public void stateChanged(IChemObjectChangeEvent event) { - isModified=true; - if(this.getParent().getParent().getParent().getParent() instanceof JFrame) - ((JFrame)this.getParent().getParent().getParent().getParent()).setTitle(renderPanel.getChemModel().getID()+"*"); + setModified(true); /* TODO gives concurrent access problems if (this.getChemModel() != null) { for (int i = 0; i < 3; i++) { String status = p.getStatus(i); Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/action/SaveAction.java =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/action/SaveAction.java 2008-11-27 13:46:04 UTC (rev 13340) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/action/SaveAction.java 2008-11-27 13:54:46 UTC (rev 13341) @@ -86,9 +86,6 @@ } else if (type.equals(JCPSaveFileFilter.smiles)) { saveAsSMILES(model, outFile); - } else if (type.equals(JCPSaveFileFilter.svg)) - { - saveAsSVG(model, outFile); } else if (type.equals(JCPSaveFileFilter.cdk)) { saveAsCDKSourceCode(model, outFile); @@ -99,7 +96,7 @@ JOptionPane.showMessageDialog(jcpPanel, error); return; } - //TODO jcpPanel.getJChemPaintModel().resetIsModified(); + jcpPanel.setModified(false); }catch(Exception ex){ String error = "Error while writing file: " + ex.getMessage(); logger.error(error); Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/action/SaveAsAction.java =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/action/SaveAsAction.java 2008-11-27 13:46:04 UTC (rev 13340) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/action/SaveAsAction.java 2008-11-27 13:54:46 UTC (rev 13341) @@ -41,20 +41,16 @@ import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.filechooser.FileFilter; -import javax.vecmath.Point2d; import org.openscience.cdk.Reaction; -import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemObject; -import org.openscience.cdk.interfaces.IMoleculeSet; import org.openscience.cdk.io.CDKSourceCodeWriter; import org.openscience.cdk.io.IChemObjectWriter; import org.openscience.cdk.io.MDLWriter; import org.openscience.cdk.io.SMILESWriter; import org.openscience.cdk.io.listener.SwingGUIListener; -import org.openscience.cdk.renderer.Renderer2DModel; import org.openscience.cdk.tools.manipulator.ChemModelManipulator; import org.openscience.jchempaint.JCPPropertyHandler; import org.openscience.jchempaint.JChemPaintPanel; @@ -125,15 +121,8 @@ JCPSaveFileFilter.addChoosableFileFilters(chooser); if (jcpPanel.getCurrentSaveFileFilter() != null) { - // XXX needs fixing - // chooser.setFileFilter(jcpPanel.getCurrentSaveFileFilter()); + chooser.setFileFilter(jcpPanel.getCurrentSaveFileFilter()); } - //shk3: this makes the choosen file type show up twice if save as is done a second - //time - no idea what it is good for - /*if (currentFilter != null) - { - chooser.setFileFilter(currentFilter); - }*/ chooser.setFileView(new JCPFileView()); int returnVal = chooser.showSaveDialog(jcpPanel); @@ -174,9 +163,6 @@ } else if (type.equals(JCPSaveFileFilter.smiles)) { outFile = saveAsSMILES(model, outFile); - } else if (type.equals(JCPSaveFileFilter.svg)) - { - outFile = saveAsSVG(model, outFile); } else if (type.equals(JCPSaveFileFilter.cdk)) { outFile = saveAsCDKSourceCode(model, outFile); @@ -187,7 +173,7 @@ JOptionPane.showMessageDialog(jcpPanel, error); return; } - //TODO model.resetIsModified(); + jcpPanel.setModified(false); } catch (Exception exc) { String error = "Error while writing file: " + exc.getMessage(); @@ -209,6 +195,7 @@ logger.error(error); JOptionPane.showMessageDialog(jcpPanel, error); } + jcpPanel.setModified(false); } catch (Exception exc) { String error = "Error while writing file: " + exc.getMessage(); @@ -333,37 +320,5 @@ ((JFrame)jcpPanel.getParent().getParent().getParent().getParent()).setTitle(jcpPanel.getChemModel().getID()); return outFile; } - - protected File saveAsSVG(IChemModel model, File outFile) throws Exception - { - logger.info("Saving the contents as a SVG file..."); - /*TODO String fileName = outFile.toString(); - if (!fileName.endsWith(".svg")) { - fileName += ".svg"; - outFile = new File(fileName); - } - cow = new SVGWriter(new FileWriter(outFile)); - if (cow != null && askIOSettings()) - { - cow.addChemObjectIOListener(new SwingGUIListener(jcpPanel, 4)); - } - Iterator containers = ChemModelManipulator.getAllAtomContainers(model).iterator(); - while (containers.hasNext()) { - IAtomContainer ac = (IAtomContainer)containers.next(); - if (ac != null) - { - for(int i=0;i<ac.getAtomCount();i++){ - ac.getAtom(i).setPoint2d((Point2d)jcpPanel.getJChemPaintModel().getRendererModel().getRenderingCoordinates().get(ac.getAtom(i))); - } - cow.write((IAtomContainer) ac.clone()); - } else - { - System.err.println("AC == null!"); - } - } - cow.close();*/ - ((JFrame)jcpPanel.getParent().getParent().getParent().getParent()).setTitle(jcpPanel.getChemModel().getID()); - return outFile; - } } Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/io/JCPSaveFileFilter.java =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/io/JCPSaveFileFilter.java 2008-11-27 13:46:04 UTC (rev 13340) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/io/JCPSaveFileFilter.java 2008-11-27 13:54:46 UTC (rev 13341) @@ -48,11 +48,10 @@ /** * Adds the JCPFileFilter to the JFileChooser object. + * TODO why only these? what about e. g. rxn? */ public static void addChoosableFileFilters(JFileChooser chooser) { chooser.addChoosableFileFilter(new JCPFileFilter(JCPFileFilter.mol)); - //shk3: svg export is broken in 1.0 branch, I remove this. - chooser.addChoosableFileFilter(new JCPSaveFileFilter(JCPSaveFileFilter.svg)); chooser.addChoosableFileFilter(new JCPSaveFileFilter(JCPSaveFileFilter.smiles)); chooser.addChoosableFileFilter(new JCPSaveFileFilter(JCPSaveFileFilter.cdk)); chooser.addChoosableFileFilter(new JCPFileFilter(JCPFileFilter.cml)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |