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.JMenuBarTest;
29: import jacareto.toolkit.event.TextValueListener;
30: import jacareto.toolkit.swing.IntegerTextField;
31:
32: import javax.swing.JLabel;
33: import javax.swing.event.DocumentEvent;
34:
35: /**
36: * This class is the editor class for <code>jacareto.test.JMenuBarTest</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 JMenuBarTestEditor extends JComponentTestEditor {
42: /** Contains the number of menus in the menu bar to test it. */
43: protected IntegerTextField elementCountField;
44:
45: /**
46: * Creates an editor with the specified env.
47: *
48: * @param env the environment
49: */
50: public JMenuBarTestEditor(Environment env) {
51: super (env);
52:
53: // The count label
54: c.gridx = 0;
55: c.gridy += 1;
56: c.gridwidth = 1;
57:
58: JLabel selectedValueLabel = new JLabel(language
59: .getString("Tests.JMenuBarTest.elementCount")
60: + ":");
61: editorPanel.add(selectedValueLabel, c);
62:
63: // The count textfield
64: c.gridx = 1;
65: elementCountField = new IntegerTextField(0, 5);
66: elementCountField.getDocument().addDocumentListener(
67: new TextValueListener() {
68: public void textValueChanged(DocumentEvent e) {
69: if (isUpdateOnChange && (getElement() != null)) {
70: ((JMenuBarTest) getElement())
71: .setMenuElementCount(elementCountField
72: .getValue());
73: }
74: }
75: });
76: editorPanel.add(elementCountField, c);
77: selectedValueLabel.setLabelFor(elementCountField);
78:
79: //chkCorrect.setEnabled(false);
80: }
81:
82: /**
83: * @see jacareto.editor.Editor#handlesElement(jacareto.struct.StructureElement)
84: */
85: public boolean handlesElement(StructureElement element) {
86: return (element != null) && (element instanceof JMenuBarTest);
87: }
88:
89: /**
90: * @see jacareto.editor.Editor#setElement(jacareto.struct.StructureElement)
91: */
92: public void setElement(StructureElement element) {
93: super .setElement(element);
94:
95: JMenuBarTest test = (JMenuBarTest) element;
96: elementCountField.setValue(test.getMenuElementCount());
97: }
98: }
|