3
* $Date: 2007-01-04 18:26:00 +0100 (Thu, 04 Jan 2007) $
6
* Copyright (C) 1997-2007 The JChemPaint project
8
* Contact: jchempaint-devel@lists.sourceforge.net
10
* This program is free software; you can redistribute it and/or
11
* modify it under the terms of the GNU Lesser General Public License
12
* as published by the Free Software Foundation; either version 2.1
13
* of the License, or (at your option) any later version.
14
* All we ask is that proper credit is given for our work, which includes
15
* - but is not limited to - adding the above copyright notice to the beginning
16
* of your source code files, and to any copyright notice that you may distribute
17
* with programs based on this work.
19
* This program is distributed in the hope that it will be useful,
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
* GNU Lesser General Public License for more details.
24
* You should have received a copy of the GNU Lesser General Public License
25
* along with this program; if not, write to the Free Software
26
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
28
package org.openscience.cdk.applications.jchempaint.dialogs;
30
import java.awt.BorderLayout;
31
import java.awt.Dimension;
32
import java.awt.event.ActionEvent;
34
import javax.swing.AbstractAction;
35
import javax.swing.DefaultCellEditor;
36
import javax.swing.JButton;
37
import javax.swing.JComboBox;
38
import javax.swing.JFrame;
39
import javax.swing.JPanel;
40
import javax.swing.JScrollPane;
41
import javax.swing.JTable;
42
import javax.swing.table.TableColumn;
44
import org.openscience.cdk.ChemObject;
45
import org.openscience.cdk.applications.jchempaint.JChemPaintEditorPanel;
46
import org.openscience.cdk.applications.swing.DictRefEditorTableModel;
49
* Frame to allows editing of dictionary references of
52
* @cdk.module jchempaint
54
public class EditDictRefs extends JFrame {
56
private static final long serialVersionUID = 1835058218886715502L;
58
DictRefEditorTableModel tableModel;
60
public EditDictRefs() {
61
super("Edit Dictionary References");
62
getContentPane().setLayout(new BorderLayout());
63
JPanel southPanel = new JPanel();
64
JButton cancelButton = new JButton("Cancel");
65
JButton applyButton = new JButton("Apply");
66
applyButton.addActionListener(new ApplyAction());
67
cancelButton.addActionListener(new CancelAction());
68
southPanel.add(applyButton);
69
southPanel.add(cancelButton);
71
tableModel = new DictRefEditorTableModel();
72
JTable table = new JTable(tableModel);
73
table.setPreferredSize(new Dimension(500, 300));
75
// setup dictionary list
76
TableColumn dictColumn = table.getColumnModel().getColumn(1);
77
JComboBox comboBox = new JComboBox();
78
String[] dicts = JChemPaintEditorPanel.getDictionaryDatabase().getDictionaryNames();
79
for (int i=0; i<dicts.length; i++) {
80
comboBox.addItem(dicts[i]);
82
dictColumn.setCellEditor(new DefaultCellEditor(comboBox));
84
JScrollPane scrollPane = new JScrollPane(table);
85
scrollPane.setPreferredSize(new Dimension(500, 100));
87
getContentPane().setLayout(new BorderLayout());
88
getContentPane().add("Center", scrollPane);
89
getContentPane().add("South", southPanel);
93
* Sets the IChemObject that is being edited.
95
public void setChemObject(ChemObject object) {
96
tableModel.setChemObject(object);
99
public void closeFrame() {
103
class ApplyAction extends AbstractAction {
105
private static final long serialVersionUID = -5199060935605242223L;
111
public void actionPerformed(ActionEvent e) {
116
class CancelAction extends AbstractAction {
118
private static final long serialVersionUID = -3203480495994212236L;
124
public void actionPerformed(ActionEvent e) {