01: /*
02: * Jacareto Copyright (c) 2002-2005
03: * Applied Computer Science Research Group, Darmstadt University of
04: * Technology, Institute of Mathematics & Computer Science,
05: * Ludwigsburg University of Education, and Computer Based
06: * Learning Research Group, Aachen University. All rights reserved.
07: *
08: * Jacareto is free software; you can redistribute it and/or
09: * modify it under the terms of the GNU General Public
10: * License as published by the Free Software Foundation; either
11: * version 2 of the License, or (at your option) any later version.
12: *
13: * Jacareto is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16: * General Public License for more details.
17: *
18: * You should have received a copy of the GNU General Public
19: * License along with Jacareto; if not, write to the Free
20: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21: *
22: */
23:
24: package jacareto.editor;
25:
26: import jacareto.struct.StructureElement;
27: import jacareto.system.Environment;
28: import jacareto.test.JToggleButtonTest;
29:
30: import java.awt.event.ActionEvent;
31: import java.awt.event.ActionListener;
32:
33: import javax.swing.JCheckBox;
34:
35: /**
36: * This class is the editor class for <code>jacareto.test.JToggleButtonTest</code> tests.
37: *
38: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
39: * @version 1.0
40: */
41: public class JToggleButtonTestEditor extends AbstractButtonTestEditor {
42: /** Whether or not the toggle button is selected. */
43: protected JCheckBox chkSelected;
44:
45: /**
46: * Creates an editor with the specified env.
47: *
48: * @param env the environment
49: */
50: public JToggleButtonTestEditor(Environment env) {
51: super (env);
52:
53: // The selected checkbox
54: c.gridx = 0;
55: c.gridy++;
56: c.gridwidth = 2;
57: chkSelected = new JCheckBox(language
58: .getString("Tests.JToggleButtonTest.Selected"));
59: chkSelected.addActionListener(new ActionListener() {
60: public void actionPerformed(ActionEvent e) {
61: if (isUpdateOnChange && (getElement() != null)) {
62: ((JToggleButtonTest) getElement())
63: .setSelected(chkSelected.isSelected());
64: }
65: }
66: });
67: editorPanel.add(chkSelected, c);
68: }
69:
70: /**
71: * @see jacareto.editor.Editor#handlesElement(jacareto.struct.StructureElement)
72: */
73: public boolean handlesElement(StructureElement element) {
74: return (element != null)
75: && (element instanceof JToggleButtonTest);
76: }
77:
78: /**
79: * @see jacareto.editor.Editor#setElement(jacareto.struct.StructureElement)
80: */
81: public void setElement(StructureElement element) {
82: super .setElement(element);
83:
84: JToggleButtonTest test = (JToggleButtonTest) element;
85: chkSelected.setSelected(test.isSelected());
86: }
87: }
|