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: /*
025: * Created on 20.05.2003
026: *
027: * To change the template for this generated file go to
028: * Window>Preferences>Java>Code Generation>Code and Comments
029: */
030: package jacareto.editor;
031:
032: import jacareto.struct.StructureElement;
033: import jacareto.system.Environment;
034: import jacareto.test.JPopupMenuTest;
035: import jacareto.toolkit.event.TextValueListener;
036: import jacareto.toolkit.swing.IntegerTextField;
037:
038: import java.awt.event.ActionEvent;
039: import java.awt.event.ActionListener;
040:
041: import javax.swing.JCheckBox;
042: import javax.swing.JLabel;
043: import javax.swing.JTextField;
044: import javax.swing.event.DocumentEvent;
045:
046: /**
047: * This class is the editor class for <code>jacareto.test.JPopupMenuTest</code> tests.
048: *
049: * @author <a href="mailto:coch@rbg.informatik.tu-darmstadt.de">Carola Coch</a>
050: * @version 1.0
051: */
052: public class JPopupMenuTestEditor extends JComponentTestEditor {
053: /** Whether or not the element is visible. */
054: protected JCheckBox chkVisible;
055:
056: /** Contains the popup label text to test it. */
057: protected JTextField popupTextField;
058:
059: /** Integer text field containing menu element count. */
060: protected IntegerTextField elementCountField;
061:
062: /**
063: * Creates an editor with the specified env.
064: *
065: * @param env the environment
066: */
067: public JPopupMenuTestEditor(Environment env) {
068: super (env);
069:
070: // The visible checkbox
071: c.gridx = 0;
072: c.gridy++;
073: c.gridwidth = 2;
074:
075: chkVisible = new JCheckBox(language
076: .getString("Tests.JPopupMenuTest.Visible"));
077: chkVisible.addActionListener(new ActionListener() {
078: public void actionPerformed(ActionEvent e) {
079: if (isUpdateOnChange && (getElement() != null)) {
080: ((JPopupMenuTest) getElement())
081: .setVisible(chkVisible.isVisible());
082: }
083: }
084: });
085: editorPanel.add(chkVisible, c);
086:
087: c.gridx = 0;
088: c.gridy++;
089: c.gridwidth = 2;
090:
091: JLabel popupLabel = new JLabel(language
092: .getString("Tests.JPopupMenuTest.PopupLabel")
093: + ":");
094: editorPanel.add(popupLabel, c);
095:
096: c.gridx = 1;
097:
098: popupTextField = new JTextField("", 20);
099: popupTextField.getDocument().addDocumentListener(
100: new TextValueListener() {
101: public void textValueChanged(DocumentEvent e) {
102: if (isUpdateOnChange && (getElement() != null)) {
103: ((JPopupMenuTest) getElement())
104: .setMenuLabel(popupTextField
105: .getText());
106: }
107: }
108: });
109: editorPanel.add(popupTextField, c);
110:
111: // The count label
112: c.gridx = 0;
113: c.gridy++;
114: c.gridwidth = 1;
115:
116: JLabel selectedValueLabel = new JLabel(language
117: .getString("Tests.JPopupMenuTest.ElementCount")
118: + ":");
119: editorPanel.add(selectedValueLabel, c);
120:
121: // The count textfield
122: c.gridx = 1;
123: elementCountField = new IntegerTextField(0, 5);
124: elementCountField.getDocument().addDocumentListener(
125: new TextValueListener() {
126: public void textValueChanged(DocumentEvent e) {
127: if (isUpdateOnChange && (getElement() != null)) {
128: ((JPopupMenuTest) getElement())
129: .setMenuElementCount(elementCountField
130: .getValue());
131: }
132: }
133: });
134: editorPanel.add(elementCountField, c);
135: selectedValueLabel.setLabelFor(elementCountField);
136: }
137:
138: /**
139: * @see jacareto.editor.Editor#handlesElement(jacareto.struct.StructureElement)
140: */
141: public boolean handlesElement(StructureElement element) {
142: return (element != null) && (element instanceof JPopupMenuTest);
143: }
144:
145: /**
146: * @see jacareto.editor.Editor#setElement(jacareto.struct.StructureElement)
147: */
148: public void setElement(StructureElement element) {
149: super .setElement(element);
150:
151: JPopupMenuTest test = (JPopupMenuTest) element;
152:
153: chkVisible.setSelected(test.isVisible());
154: popupTextField.setText(test.getMenuLabel());
155: elementCountField.setValue(test.getMenuElementCount());
156: }
157: }
|