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.starter.ApplicationStarter;
027: import jacareto.struct.StructureElement;
028: import jacareto.system.Environment;
029: import jacareto.system.Language;
030: import jacareto.toolkit.event.TextValueListener;
031:
032: import java.awt.Component;
033: import java.awt.FlowLayout;
034:
035: import javax.swing.JLabel;
036: import javax.swing.JPanel;
037: import javax.swing.JTabbedPane;
038: import javax.swing.JTextField;
039: import javax.swing.event.DocumentEvent;
040:
041: /**
042: * An editor for application starters.
043: *
044: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
045: * @version 1.03
046: */
047: public class ApplicationStarterEditor extends StarterEditor {
048: /** The editor component. */
049: private JTabbedPane editorComponent;
050:
051: /** The text field for the capture parameters. */
052: private JTextField captureParamsField;
053:
054: /** The text field for the replay parameters. */
055: private JTextField replayParamsField;
056:
057: /** The cursor images panel. */
058: private CursorImagesPanel cursorImagesPanel;
059:
060: /** The system properties panel. */
061: private SystemPropertiesPanel systemPropertiesPanel;
062:
063: /**
064: * Create a new application starter editor.
065: *
066: * @param env the environment
067: */
068: public ApplicationStarterEditor(Environment env) {
069: super (env);
070:
071: Language language = getLanguage();
072:
073: // The capture params field label
074: c.gridx = 0;
075: c.gridy = 6;
076:
077: JLabel captureParamsFieldLabel = new JLabel(
078: language
079: .getString("Starters.ApplicationStarter.Attributes.CaptureParams")
080: + ":");
081: editorPanel.add(captureParamsFieldLabel, c);
082:
083: // The capture params field
084: c.gridx = 1;
085: captureParamsField = new JTextField(20);
086: captureParamsField.getDocument().addDocumentListener(
087: new TextValueListener() {
088: public void textValueChanged(DocumentEvent e) {
089: if (isUpdateOnChange && (getElement() != null)) {
090: ((ApplicationStarter) getElement())
091: .setCaptureParams(captureParamsField
092: .getText());
093: }
094: }
095: });
096: editorPanel.add(captureParamsField, c);
097: captureParamsFieldLabel.setLabelFor(captureParamsField);
098:
099: // The replay params field label
100: c.gridx = 0;
101: c.gridy = 7;
102:
103: JLabel replayParamsFieldLabel = new JLabel(
104: language
105: .getString("Starters.ApplicationStarter.Attributes.ReplayParams")
106: + ":");
107: editorPanel.add(replayParamsFieldLabel, c);
108:
109: // The replay params field
110: c.gridx = 1;
111: replayParamsField = new JTextField(20);
112: replayParamsField.getDocument().addDocumentListener(
113: new TextValueListener() {
114: public void textValueChanged(DocumentEvent e) {
115: if (isUpdateOnChange && (getElement() != null)) {
116: ((ApplicationStarter) getElement())
117: .setReplayParams(replayParamsField
118: .getText());
119: }
120: }
121: });
122: editorPanel.add(replayParamsField, c);
123: replayParamsFieldLabel.setLabelFor(replayParamsField);
124:
125: // The other panels
126: cursorImagesPanel = new CursorImagesPanel(env, this ,
127: isUpdateOnChange);
128: systemPropertiesPanel = new SystemPropertiesPanel(env, this ,
129: isUpdateOnChange);
130: }
131:
132: /**
133: * Returns the editor component.
134: *
135: * @return DOCUMENT ME!
136: */
137: public Component getComponent() {
138: if (editorComponent == null) {
139: editorComponent = new JTabbedPane();
140:
141: JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
142: panel.add(super .getComponent());
143: editorComponent
144: .addTab(
145: language
146: .getString("Starters.ApplicationStarter.TabTitles.General"),
147: panel);
148: editorComponent.addTab(language
149: .getString("Starters.Starter.System.System"),
150: systemPropertiesPanel);
151: editorComponent
152: .addTab(
153: language
154: .getString("Starters.Starter.TabTitles.CursorImages"),
155: cursorImagesPanel);
156: }
157:
158: return editorComponent;
159: }
160:
161: /**
162: * Returns whether this editor is responsible for a given structure element. This editor is
163: * responsible for application starters.
164: *
165: * @param element the structure element
166: *
167: * @return <code>true</code> if <i>element</i> is an application starter and not
168: * <code>null</code>, otherwise <code>false</code>
169: */
170: public boolean handlesElement(StructureElement element) {
171: return (element != null)
172: && (element instanceof ApplicationStarter);
173: }
174:
175: /**
176: * Sets the structure element to edit.
177: *
178: * @param element DOCUMENT ME!
179: */
180: public void setElement(StructureElement element) {
181: super .setElement(element);
182:
183: ApplicationStarter starter = (ApplicationStarter) element;
184: captureParamsField.setText(starter.getCaptureParams());
185: replayParamsField.setText(starter.getReplayParams());
186:
187: cursorImagesPanel.setTableData(starter.getCursorImages());
188: systemPropertiesPanel.setTableData(starter
189: .getSystemProperties());
190: }
191: }
|