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.AbstractButtonTest;
29: import jacareto.toolkit.event.TextValueListener;
30:
31: import javax.swing.JLabel;
32: import javax.swing.JTextField;
33: import javax.swing.event.DocumentEvent;
34:
35: /**
36: * This class is the editor class for <code>jacareto.test.AbstractButtonTest</code> tests.
37: *
38: * @author <a href="mailto:frommer@rbg.informatik.tu-darmstadt.de">Juri Frommer</a>
39: * @version 1.0
40: */
41: public class AbstractButtonTestEditor extends JComponentTestEditor {
42: /** Contains the button text to test it. */
43: protected JTextField chkButtonText;
44:
45: /**
46: * Creates an editor with the specified env.
47: *
48: * @param env the environment
49: */
50: public AbstractButtonTestEditor(Environment env) {
51: super (env);
52:
53: c.gridx = 0;
54: c.gridy += 1;
55: c.gridwidth = 2;
56:
57: JLabel btnTextLabel = new JLabel(language
58: .getString("Tests.AbstractButtonTest.ButtonTextLabel")
59: + ":");
60: editorPanel.add(btnTextLabel, c);
61:
62: c.gridx = 1;
63:
64: chkButtonText = new JTextField("", 20);
65: chkButtonText.getDocument().addDocumentListener(
66: new TextValueListener() {
67: public void textValueChanged(DocumentEvent e) {
68: if (isUpdateOnChange && (getElement() != null)) {
69: ((AbstractButtonTest) getElement())
70: .setButtonText(chkButtonText
71: .getText());
72: }
73: }
74: });
75: editorPanel.add(chkButtonText, c);
76: }
77:
78: /**
79: * @see jacareto.editor.Editor#handlesElement(jacareto.struct.StructureElement)
80: */
81: public boolean handlesElement(StructureElement element) {
82: return (element != null)
83: && (element instanceof AbstractButtonTest);
84: }
85:
86: /**
87: * @see jacareto.editor.Editor#setElement(jacareto.struct.StructureElement)
88: */
89: public void setElement(StructureElement element) {
90: super .setElement(element);
91:
92: AbstractButtonTest test = (AbstractButtonTest) element;
93: chkButtonText.setText(test.getButtonText());
94: }
95: }
|