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.record.HyperlinkEventRecordable;
027: import jacareto.struct.StructureElement;
028: import jacareto.system.Environment;
029: import jacareto.system.Language;
030: import jacareto.toolkit.event.TextValueListener;
031:
032: import javax.swing.JTextField;
033: import javax.swing.event.DocumentEvent;
034:
035: /**
036: * An editor for hyperlink event recordables.
037: *
038: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
039: * @version 1.00
040: */
041: public class HyperlinkEventRecordableEditor extends
042: EventObjectRecordableEditor {
043: /** The text field for the url. */
044: private JTextField urlField;
045:
046: /** The text field for the description. */
047: private JTextField descriptionField;
048:
049: /** The text field for the type. */
050: private JTextField typeField;
051:
052: /**
053: * Create a new hyperlink event recordable editor.
054: *
055: * @param env the environment
056: */
057: public HyperlinkEventRecordableEditor(Environment env) {
058: super (env);
059:
060: Language language = getLanguage();
061:
062: // The url field.
063: urlField = addTextFieldRow(language
064: .getString("Events.HyperlinkEvent.URL"), 20);
065: urlField.getDocument().addDocumentListener(
066: new TextValueListener() {
067: public void textValueChanged(DocumentEvent e) {
068: if (isUpdateOnChange && (getElement() != null)) {
069: ((HyperlinkEventRecordable) getElement())
070: .setURL(urlField.getText());
071: }
072: }
073: });
074:
075: // The description field.
076: descriptionField = addTextFieldRow(language
077: .getString("Events.HyperlinkEvent.Description"), 20);
078: descriptionField.getDocument().addDocumentListener(
079: new TextValueListener() {
080: public void textValueChanged(DocumentEvent e) {
081: if (isUpdateOnChange && (getElement() != null)) {
082: ((HyperlinkEventRecordable) getElement())
083: .setDescription(descriptionField
084: .getText());
085: }
086: }
087: });
088:
089: // The type field.
090: typeField = addTextFieldRow(language
091: .getString("Events.HyperlinkEvent.Type"), 20);
092: typeField.getDocument().addDocumentListener(
093: new TextValueListener() {
094: public void textValueChanged(DocumentEvent e) {
095: if (isUpdateOnChange && (getElement() != null)) {
096: ((HyperlinkEventRecordable) getElement())
097: .setType(typeField.getText());
098: }
099: }
100: });
101: }
102:
103: /**
104: * Returns whether this editor is responsible for a given structure element. This editor is
105: * responsible for all list selection event recordables.
106: *
107: * @param element the structure element
108: *
109: * @return <code>true</code> if <i>element</i> is a list selection event recordable and not
110: * <code>null</code>, otherwise <code>false</code>
111: */
112: public boolean handlesElement(StructureElement element) {
113: return (element != null)
114: && (element instanceof HyperlinkEventRecordable);
115: }
116:
117: /**
118: * Sets the structure element to edit.
119: *
120: * @param element DOCUMENT ME!
121: */
122: public void setElement(StructureElement element) {
123: super .setElement(element);
124:
125: HyperlinkEventRecordable hRecordable = (HyperlinkEventRecordable) element;
126: urlField.setText(hRecordable.getURL());
127: descriptionField.setText(hRecordable.getDescription());
128: typeField.setText(hRecordable.getType());
129: }
130: }
|