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.JTabbedPaneTest;
029: import jacareto.toolkit.event.TextValueListener;
030: import jacareto.toolkit.swing.IntegerTextField;
031:
032: import javax.swing.JLabel;
033: import javax.swing.JTextField;
034: import javax.swing.event.DocumentEvent;
035:
036: /**
037: * This class is the editor class for <code>jacareto.test.JTabbedPaneTest</code> tests.
038: *
039: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
040: * @version 1.0
041: */
042: public class JTabbedPaneTestEditor extends JComponentTestEditor {
043: /** Which pane is selected. */
044: protected IntegerTextField selectedIndexField;
045:
046: /** Contains the pane text to test it. */
047: protected JTextField chkPaneText;
048:
049: /**
050: * Creates an editor with the specified env.
051: *
052: * @param env the environment
053: */
054: public JTabbedPaneTestEditor(Environment env) {
055: super (env);
056:
057: // The selected index label
058: c.gridx = 0;
059: c.gridy += 1;
060: c.gridwidth = 1;
061:
062: JLabel selectedIndexLabel = new JLabel(language
063: .getString("Tests.JTabbedPaneTest.SelectedIndex")
064: + ":");
065: editorPanel.add(selectedIndexLabel, c);
066:
067: // The selected index textfield
068: c.gridx = 1;
069: selectedIndexField = new IntegerTextField(0, 5);
070: selectedIndexField.getDocument().addDocumentListener(
071: new TextValueListener() {
072: public void textValueChanged(DocumentEvent e) {
073: if (isUpdateOnChange && (getElement() != null)) {
074: ((JTabbedPaneTest) getElement())
075: .setSelectedIndex(selectedIndexField
076: .getValue());
077: }
078: }
079: });
080: editorPanel.add(selectedIndexField, c);
081: selectedIndexLabel.setLabelFor(selectedIndexField);
082:
083: c.gridx = 0;
084: c.gridy += 1;
085: c.gridwidth = 1;
086:
087: JLabel paneTextLabel = new JLabel(language
088: .getString("Tests.JTabbedPaneTest.PaneTextLabel")
089: + ":");
090: editorPanel.add(paneTextLabel, c);
091:
092: c.gridx = 1;
093:
094: chkPaneText = new JTextField("", 20);
095: chkPaneText.getDocument().addDocumentListener(
096: new TextValueListener() {
097: public void textValueChanged(DocumentEvent e) {
098: if (isUpdateOnChange && (getElement() != null)) {
099: ((JTabbedPaneTest) getElement())
100: .setPaneText(chkPaneText.getText());
101: }
102: }
103: });
104: editorPanel.add(chkPaneText, c);
105: }
106:
107: /**
108: * @see jacareto.editor.Editor#handlesElement(jacareto.struct.StructureElement)
109: */
110: public boolean handlesElement(StructureElement element) {
111: return (element != null)
112: && (element instanceof JTabbedPaneTest);
113: }
114:
115: /**
116: * @see jacareto.editor.Editor#setElement(jacareto.struct.StructureElement)
117: */
118: public void setElement(StructureElement element) {
119: super .setElement(element);
120:
121: JTabbedPaneTest test = (JTabbedPaneTest) element;
122: selectedIndexField.setValue(test.getSelectedIndex());
123: chkPaneText.setText(test.getPaneText());
124: }
125: }
|