From: <sh...@us...> - 2008-12-02 14:49:56
|
Revision: 13428 http://cdk.svn.sourceforge.net/cdk/?rev=13428&view=rev Author: shk3 Date: 2008-12-02 14:49:53 +0000 (Tue, 02 Dec 2008) Log Message: ----------- more applet stuff Modified Paths: -------------- jchempaint/trunk/src/main/org/openscience/jchempaint/JChemPaintPanel.java jchempaint/trunk/src/main/org/openscience/jchempaint/action/NewAction.java jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintEditorApplet.java jchempaint/trunk/src/main/org/openscience/jchempaint/application/JChemPaint.java jchempaint/trunk/src/main/org/openscience/jchempaint/resources/JCPGUI_applet.properties Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/JChemPaintPanel.java =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/JChemPaintPanel.java 2008-12-02 13:32:16 UTC (rev 13427) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/JChemPaintPanel.java 2008-12-02 14:49:53 UTC (rev 13428) @@ -49,11 +49,12 @@ import javax.swing.JToolBar; import javax.swing.filechooser.FileFilter; -import org.openscience.cdk.controller.ControllerHub; +import org.openscience.cdk.applications.undoredo.ClearAllEdit; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.jchempaint.action.SaveAction; +import org.openscience.jchempaint.applet.JChemPaintEditorApplet; public class JChemPaintPanel extends AbstractJChemPaintPanel implements IChemObjectListener { @@ -77,13 +78,17 @@ private JToolBar toolbar; private int lines=1; + public JChemPaintPanel(IChemModel chemModel, String gui){ + this(chemModel,gui,1); + } /** * Builds a JCPPanel with a certain model and a certain gui * * @param chemModel The model * @param gui The gui string */ - public JChemPaintPanel(IChemModel chemModel, String gui){ + public JChemPaintPanel(IChemModel chemModel, String gui, int lines){ + this.lines=lines; this.guistring=gui; this.setLayout(new BorderLayout()); topContainer = new JPanel(new BorderLayout()); @@ -343,7 +348,11 @@ return isAlreadyAFile; } - /** + public String getGuistring() { + return guistring; + } + + /** * Set to indicate whether the insert text field should be used. * * @param showInsertTextField true is the text entry widget is to be shown @@ -377,23 +386,18 @@ * @return OptionPane.YES_OPTION/OptionPane.NO_OPTION/OptionPane.CANCEL_OPTION */ public int showWarning() { - if (isModified){ //TODO && !getIsOpenedByViewer() && !guiString.equals("applet")) { + if (isModified && !guistring.equals(JChemPaintEditorApplet.GUI_APPLET)){ //TODO && !getIsOpenedByViewer()) { int answer = JOptionPane.showConfirmDialog(this, renderPanel.getChemModel().getID() + " " + JCPLocalizationHandler.getInstance().getString("warning"), JCPLocalizationHandler.getInstance().getString("warningheader"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); if (answer == JOptionPane.YES_OPTION) { new SaveAction(this, false).actionPerformed(new ActionEvent(this, 12, "")); } return answer; - /* TODO } else if(guiString.equals("applet")){ + } else if(guistring.equals(JChemPaintEditorApplet.GUI_APPLET)){ //In case of the applet we do not ask for save but put the clear into the undo stack ClearAllEdit coa = null; - try { - coa = new ClearAllEdit(this.getChemModel(),(IMoleculeSet)this.getChemModel().getMoleculeSet().clone(),this.getChemModel().getReactionSet()); - this.jchemPaintModel.getControllerModel().getUndoSupport().postEdit(coa); - } catch (Exception e) { - logger.error("Clone of IMoleculeSet failed: ", e.getMessage()); - logger.debug(e); - } - return JOptionPane.YES_OPTION;*/ + //TODO undo redo missing coa = new ClearAllEdit(this.getChemModel(),(IMoleculeSet)this.getChemModel().getMoleculeSet().clone(),this.getChemModel().getReactionSet()); + //this.jchemPaintModel.getControllerModel().getUndoSupport().postEdit(coa); + return JOptionPane.YES_OPTION; } else { return JOptionPane.YES_OPTION; } Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/action/NewAction.java =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/action/NewAction.java 2008-12-02 13:32:16 UTC (rev 13427) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/action/NewAction.java 2008-12-02 14:49:53 UTC (rev 13428) @@ -30,6 +30,9 @@ import java.awt.event.ActionEvent; +import javax.swing.JOptionPane; + +import org.openscience.jchempaint.applet.JChemPaintEditorApplet; import org.openscience.jchempaint.application.JChemPaint; /** @@ -46,18 +49,18 @@ *@param e Description of the Parameter */ public void actionPerformed(ActionEvent e) { - /*TODO if(jcpPanel.isEmbedded()){ + if(jcpPanel.getGuistring().equals(JChemPaintEditorApplet.GUI_APPLET)){ int clear=jcpPanel.showWarning(); if(clear==JOptionPane.YES_OPTION){ - if(jcpPanel.getJChemPaintModel().getChemModel().getMoleculeSet()!=null) - jcpPanel.getJChemPaintModel().getChemModel().getMoleculeSet().removeAllAtomContainers(); - if(jcpPanel.getJChemPaintModel().getChemModel().getReactionSet()!=null) - jcpPanel.getJChemPaintModel().getChemModel().getReactionSet().removeAllReactions(); - jcpPanel.repaint(); + if(jcpPanel.getChemModel().getMoleculeSet()!=null) + jcpPanel.getChemModel().getMoleculeSet().removeAllAtomContainers(); + if(jcpPanel.getChemModel().getReactionSet()!=null) + jcpPanel.getChemModel().getReactionSet().removeAllReactions(); + jcpPanel.get2DHub().updateView(); } - }else{*/ + }else{ JChemPaint.showEmptyInstance(); - //} + } } } Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintEditorApplet.java =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintEditorApplet.java 2008-12-02 13:32:16 UTC (rev 13427) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintEditorApplet.java 2008-12-02 14:49:53 UTC (rev 13428) @@ -29,17 +29,12 @@ package org.openscience.jchempaint.applet; import org.openscience.cdk.ChemModel; -import org.openscience.cdk.DefaultChemObjectBuilder; -import org.openscience.cdk.interfaces.IAtomContainer; -import org.openscience.cdk.interfaces.IMolecule; -import org.openscience.cdk.layout.StructureDiagramGenerator; -import org.openscience.cdk.smiles.SmilesParser; import org.openscience.jchempaint.JChemPaintPanel; public class JChemPaintEditorApplet extends JChemPaintAbstractApplet{ - + public static final String GUI_APPLET="applet"; public void init() { - JChemPaintPanel p = new JChemPaintPanel(new ChemModel(),"applet"); + JChemPaintPanel p = new JChemPaintPanel(new ChemModel(),GUI_APPLET,2); p.setShowInsertTextField(false); p.setShowStatusBar(false); setTheJcpp(p); Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/application/JChemPaint.java =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/application/JChemPaint.java 2008-12-02 13:32:16 UTC (rev 13427) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/application/JChemPaint.java 2008-12-02 14:49:53 UTC (rev 13428) @@ -49,18 +49,14 @@ import org.apache.commons.cli.UnrecognizedOptionException; import org.openscience.cdk.ChemModel; import org.openscience.cdk.DefaultChemObjectBuilder; -import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemObject; -import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.io.CMLReader; import org.openscience.cdk.io.INChIReader; import org.openscience.cdk.io.ISimpleChemObjectReader; import org.openscience.cdk.io.MDLV2000Reader; import org.openscience.cdk.io.ReaderFactory; -import org.openscience.cdk.layout.StructureDiagramGenerator; -import org.openscience.cdk.smiles.SmilesParser; import org.openscience.cdk.tools.manipulator.ChemModelManipulator; import org.openscience.jchempaint.JCPLocalizationHandler; import org.openscience.jchempaint.JChemPaintPanel; @@ -69,22 +65,6 @@ public class JChemPaint { public static int instancecounter=1; - - - public static IAtomContainer makeMolecule(String smiles) { - SmilesParser parser = new SmilesParser(DefaultChemObjectBuilder.getInstance()); - try { - IMolecule mol = parser.parseSmiles(smiles); - - StructureDiagramGenerator generator = new StructureDiagramGenerator(); - generator.setMolecule(mol); - generator.generateCoordinates(); - - return (IAtomContainer) generator.getMolecule(); - } catch (Exception e) { - return null; - } - } @SuppressWarnings("static-access") public static void main(String[] args) { Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/resources/JCPGUI_applet.properties =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/resources/JCPGUI_applet.properties 2008-12-02 13:32:16 UTC (rev 13427) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/resources/JCPGUI_applet.properties 2008-12-02 14:49:53 UTC (rev 13428) @@ -104,10 +104,9 @@ # toolbar definition # ####################################################### -toolbar=new open saveAs - \ - undo redo bond - \ - cyclesymbol periodictable enterelement up_bond down_bond plus minus move - \ - eraser lasso select cleanup triangle - square pentagon \ +toolbar= undo redo - bond new \ + cyclesymbol periodictable enterelement up_bond down_bond plus minus - move \ + eraser lasso select cleanup - triangle square pentagon \ hexagon heptagon octagon benzene chemtoolbar= elementtoolbar=C H O N P S F Cl Br I This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |