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