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.ChangeEventRecordable;
027: import jacareto.struct.StructureElement;
028: import jacareto.system.Environment;
029: import jacareto.system.Language;
030: import jacareto.toolkit.StringToolkit;
031:
032: import javax.swing.JTextField;
033:
034: /**
035: * An editor for change event recordables.
036: *
037: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
038: * @version 1.00
039: */
040: public class ChangeEventRecordableEditor extends
041: EventObjectRecordableEditor {
042: /** The text field for the additional information. */
043: private JTextField infoField;
044:
045: /**
046: * Create a new change event recordable editor.
047: *
048: * @param env the environment
049: */
050: public ChangeEventRecordableEditor(Environment env) {
051: super (env);
052:
053: Language language = getLanguage();
054:
055: // The info field.
056: infoField = addTextFieldRow(language
057: .getString("Events.ChangeEvent.Info"), 20);
058: infoField.setEditable(false);
059:
060: /*infoField.getDocument ().addDocumentListener (new TextValueListener() {
061: public void textValueChanged (DocumentEvent e) {
062: if (isUpdateOnChange && (getElement () != null)) {
063: ((ChangeEventRecordable) getElement ()).setAdditionalInformation (infoField.getText ());
064: }
065: }
066: }); */
067: }
068:
069: /**
070: * Returns whether this editor is responsible for a given structure element. This editor is
071: * responsible for all item event recordables.
072: *
073: * @param element the structure element
074: *
075: * @return <code>true</code> if <i>element</i> is an input event recordable and not
076: * <code>null</code>, otherwise <code>false</code>
077: */
078: public boolean handlesElement(StructureElement element) {
079: return (element != null)
080: && (element instanceof ChangeEventRecordable);
081: }
082:
083: /**
084: * Sets the structure element to edit.
085: *
086: * @param element DOCUMENT ME!
087: */
088: public void setElement(StructureElement element) {
089: super .setElement(element);
090:
091: ChangeEventRecordable cRecordable = (ChangeEventRecordable) element;
092:
093: String additionalInformation = cRecordable
094: .getAdditionalInformation();
095:
096: if (StringToolkit.isDefined(additionalInformation)) {
097: infoField.setText(additionalInformation);
098: } else {
099: infoField.setText("");
100: }
101: }
102: }
|