4
* $Date: 2007-04-16 10:40:19 +0200 (Mon, 16 Apr 2007) $
7
* Copyright (C) 2003-2007 E.L. Willighagen <elw38@cam.ac.uk>
9
* Contact: jchempaint-devel@lists.sf.net
11
* This program is free software; you can redistribute it and/or
12
* modify it under the terms of the GNU Lesser General Public License
13
* as published by the Free Software Foundation; either version 2.1
14
* of the License, or (at your option) any later version.
15
* All we ask is that proper credit is given for our work, which includes
16
* - but is not limited to - adding the above copyright notice to the beginning
17
* of your source code files, and to any copyright notice that you may distribute
18
* with programs based on this work.
20
* This program is distributed in the hope that it will be useful,
21
* but WITHOUT ANY WARRANTY; without even the implied warranty of
22
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
* GNU Lesser General Public License for more details.
25
* You should have received a copy of the GNU Lesser General Public License
26
* along with this program; if not, write to the Free Software
27
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
29
package org.openscience.cdk.applications.jchempaint.action;
31
import java.awt.event.ActionEvent;
33
import org.openscience.cdk.Atom;
34
import org.openscience.cdk.interfaces.IChemObject;
35
import org.openscience.cdk.PseudoAtom;
36
import org.openscience.cdk.Reaction;
37
import org.openscience.cdk.applications.jchempaint.JChemPaintModel;
38
import org.openscience.cdk.applications.jchempaint.dialogs.ChemObjectPropertyDialog;
39
import org.openscience.cdk.applications.swing.editor.AtomEditor;
40
import org.openscience.cdk.applications.swing.editor.BondEditor;
41
import org.openscience.cdk.applications.swing.editor.ChemObjectEditor;
42
import org.openscience.cdk.applications.swing.editor.PseudoAtomEditor;
43
import org.openscience.cdk.applications.swing.editor.ReactionEditor;
46
* Action for triggering an edit of a IChemObject
48
* @author E.L. Willighagen <elw38@cam.ac.uk>
49
* @cdk.module jchempaint
51
public class EditChemObjectPropsAction extends JCPAction {
53
private static final long serialVersionUID = 7123137508085454087L;
55
public void actionPerformed(ActionEvent event) {
56
if (jcpPanel.getJChemPaintModel() != null) {
57
JChemPaintModel jcpmodel = jcpPanel.getJChemPaintModel();
58
IChemObject object = getSource(event);
59
logger.debug("Showing object properties for: ", object);
60
ChemObjectEditor editor = null;
61
if (object instanceof PseudoAtom) {
62
editor = new PseudoAtomEditor();
64
else if (object instanceof Atom) {
65
editor = new AtomEditor();
67
else if (object instanceof Reaction) {
68
editor = new ReactionEditor();
70
else if (object instanceof org.openscience.cdk.interfaces.IBond) {
71
editor = new BondEditor();
75
editor.setChemObject((org.openscience.cdk.ChemObject)object);
76
ChemObjectPropertyDialog frame =
77
new ChemObjectPropertyDialog(jcpmodel, editor);