001: /*
002: * Jacareto Copyright (c) 2002-2005
003: * Applied Computer Science Research Group, Darmstadt University of
004: * Technology, Institute of Mathematics & Computer Science,
005: * Ludwigsburg University of Education, and Computer Based
006: * Learning Research Group, Aachen University. All rights reserved.
007: *
008: * Jacareto is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU General Public
010: * License as published by the Free Software Foundation; either
011: * version 2 of the License, or (at your option) any later version.
012: *
013: * Jacareto is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016: * General Public License for more details.
017: *
018: * You should have received a copy of the GNU General Public
019: * License along with Jacareto; if not, write to the Free
020: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021: *
022: */
023:
024: package jacareto.editor;
025:
026: import jacareto.struct.StructureElement;
027: import jacareto.system.Environment;
028: import jacareto.test.JTableTest;
029: import jacareto.toolkit.event.TextValueListener;
030: import jacareto.toolkit.swing.IntegerTextField;
031:
032: import java.awt.GridLayout;
033:
034: import javax.swing.JLabel;
035: import javax.swing.JPanel;
036: import javax.swing.event.DocumentEvent;
037:
038: /**
039: * This class is the editor class for <code>jacareto.test.JTableTest</code> tests.
040: *
041: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
042: * @version 1.0
043: */
044: public class JTableTestEditor extends JComponentTestEditor {
045: /** Contains the text field for the selected row. */
046: protected IntegerTextField selectedRowField;
047:
048: /** Contains the text field for the selected column. */
049: protected IntegerTextField selectedColumnField;
050:
051: /**
052: * Creates an editor with the specified env.
053: *
054: * @param env the environment
055: */
056: public JTableTestEditor(Environment env) {
057: super (env);
058:
059: c.gridx = 0;
060: c.gridy += 1;
061: c.gridwidth = 2;
062:
063: JPanel rowColumnPanel = new JPanel(new GridLayout(2, 2));
064:
065: JLabel labelTextLabel = new JLabel(language
066: .getString("Tests.JTableTest.Attributes.SelectedRow")
067: + ":");
068: rowColumnPanel.add(labelTextLabel);
069:
070: selectedRowField = new IntegerTextField(0, 4);
071: selectedRowField.getDocument().addDocumentListener(
072: new TextValueListener() {
073: public void textValueChanged(DocumentEvent e) {
074: if (isUpdateOnChange && (getElement() != null)) {
075: ((JTableTest) getElement())
076: .setSelectedRow(selectedRowField
077: .getValue());
078: }
079: }
080: });
081: rowColumnPanel.add(selectedRowField);
082:
083: JLabel labelTextLabel2 = new JLabel(
084: language
085: .getString("Tests.JTableTest.Attributes.SelectedColumn")
086: + ":");
087: rowColumnPanel.add(labelTextLabel2);
088:
089: selectedColumnField = new IntegerTextField(0, 4);
090: selectedColumnField.getDocument().addDocumentListener(
091: new TextValueListener() {
092: public void textValueChanged(DocumentEvent e) {
093: if (isUpdateOnChange && (getElement() != null)) {
094: ((JTableTest) getElement())
095: .setSelectedColumn(selectedColumnField
096: .getValue());
097: }
098: }
099: });
100: rowColumnPanel.add(selectedColumnField);
101:
102: editorPanel.add(rowColumnPanel, c);
103: }
104:
105: /**
106: * @see jacareto.editor.Editor#handlesElement(jacareto.struct.StructureElement)
107: */
108: public boolean handlesElement(StructureElement element) {
109: return (element != null) && (element instanceof JTableTest);
110: }
111:
112: /**
113: * @see jacareto.editor.Editor#setElement(jacareto.struct.StructureElement)
114: */
115: public void setElement(StructureElement element) {
116: super .setElement(element);
117:
118: JTableTest test = (JTableTest) element;
119: selectedRowField.setValue(test.getSelectedRow());
120: selectedColumnField.setValue(test.getSelectedColumn());
121: }
122: }
|