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.JComponentTest;
029:
030: import java.awt.event.ActionEvent;
031: import java.awt.event.ActionListener;
032:
033: import javax.swing.JCheckBox;
034:
035: /**
036: * This class is the editor class for <code>jacareto.test.JComponentTest</code> tests.
037: *
038: * @author <a href="mailto:frommer@rbg.informatik.tu-darmstadt.de">Juri Frommer</a>
039: * @version 1.0
040: */
041: public class JComponentTestEditor extends TestEditor {
042: /** Whether or not the element is focused. */
043: protected JCheckBox chkFocused;
044:
045: /** Whether or not the element is enabled. */
046: protected JCheckBox chkEnabled;
047:
048: /**
049: * Creates an editor with the specified env.
050: *
051: * @param env the environment
052: */
053: public JComponentTestEditor(Environment env) {
054: super (env);
055:
056: c.gridx = 0;
057: c.gridy += 1;
058: c.gridwidth = 2;
059:
060: chkFocused = new JCheckBox(language
061: .getString("Tests.JComponentTest.Focused"));
062: chkFocused.addActionListener(new ActionListener() {
063: public void actionPerformed(ActionEvent e) {
064: if (isUpdateOnChange && (getElement() != null)) {
065: ((JComponentTest) getElement()).setFocus(chkFocused
066: .isSelected());
067: }
068: }
069: });
070: editorPanel.add(chkFocused, c);
071:
072: c.gridx = 0;
073: c.gridy += 1;
074: c.gridwidth = 2;
075:
076: chkEnabled = new JCheckBox(language
077: .getString("Tests.JComponentTest.Enabled"));
078: chkEnabled.addActionListener(new ActionListener() {
079: public void actionPerformed(ActionEvent e) {
080: if (isUpdateOnChange && (getElement() != null)) {
081: ((JComponentTest) getElement())
082: .setEnabled(chkEnabled.isSelected());
083: }
084: }
085: });
086: editorPanel.add(chkEnabled, c);
087: }
088:
089: /**
090: * @see jacareto.editor.Editor#handlesElement(jacareto.struct.StructureElement)
091: */
092: public boolean handlesElement(StructureElement element) {
093: return (element != null) && (element instanceof JComponentTest);
094: }
095:
096: /**
097: * @see jacareto.editor.Editor#setElement(jacareto.struct.StructureElement)
098: */
099: public void setElement(StructureElement element) {
100: super .setElement(element);
101:
102: JComponentTest test = (JComponentTest) element;
103: chkFocused.setSelected(test.hasFocus());
104: chkEnabled.setSelected(test.isEnabled());
105: }
106: }
|