/*
* Jacareto Copyright (c) 2002-2005
* Applied Computer Science Research Group, Darmstadt University of
* Technology, Institute of Mathematics & Computer Science,
* Ludwigsburg University of Education, and Computer Based
* Learning Research Group, Aachen University. All rights reserved.
*
* Jacareto is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* Jacareto is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with Jacareto; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
package jacareto.editor;
import jacareto.record.FocusEventRecordable;
import jacareto.struct.StructureElement;
import jacareto.system.Environment;
import jacareto.system.Language;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import javax.swing.JComboBox;
/**
* <p>
* An editor for focus event recordables.
* </p>
*
* @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
* @version 1.01
*/
public class FocusEventRecordableEditor extends ComponentEventRecordableEditor {
/** The combo box for the "is temporary" attribute. */
private JComboBox isTemporaryBox;
/** The combo box for the event type (=id). */
private JComboBox typeBox;
/**
* Create a new component event recordable editor.
*
* @param env the environment
*/
public FocusEventRecordableEditor (Environment env) {
super(env);
Language language = getLanguage ();
// The type box
typeBox = addComboBoxRow (language.getString ("Events.FocusEvent.Type"));
typeBox.addItem (language.getString ("Events.FocusEvent.FocusGained"));
typeBox.addItem (language.getString ("Events.FocusEvent.FocusLost"));
typeBox.addActionListener (new ActionListener() {
public void actionPerformed (ActionEvent e) {
FocusEventRecordable fRecordable = (FocusEventRecordable) getElement ();
if (isUpdateOnChange && (fRecordable != null)) {
if (typeBox.getSelectedIndex () == 0) {
fRecordable.setID (FocusEvent.FOCUS_GAINED);
} else if (typeBox.getSelectedIndex () == 1) {
fRecordable.setID (FocusEvent.FOCUS_LOST);
}
}
}
});
// The is temporary box
isTemporaryBox = addComboBoxRow (language.getString ("Events.FocusEvent.Temporary"));
isTemporaryBox.addItem (language.getString ("General.True"));
isTemporaryBox.addItem (language.getString ("General.False"));
isTemporaryBox.addActionListener (new ActionListener() {
public void actionPerformed (ActionEvent e) {
if (isUpdateOnChange && (getElement () != null)) {
if (isTemporaryBox.getSelectedIndex () == 0) {
((FocusEventRecordable) getElement ()).setTemporary (true);
} else {
((FocusEventRecordable) getElement ()).setTemporary (false);
}
}
}
});
}
/**
* Returns whether this editor is responsible for a given structure element. This editor is
* responsible for all focus event recordables.
*
* @param element the structure element
*
* @return <code>true</code> if <i>element</i> is an input event recordable and not
* <code>null</code>, otherwise <code>false</code>
*/
public boolean handlesElement (StructureElement element) {
return (element != null) && (element instanceof FocusEventRecordable);
}
/**
* Sets the structure element to edit.
*
* @param element DOCUMENT ME!
*/
public void setElement (StructureElement element) {
super.setElement (element);
FocusEventRecordable fRecordable = (FocusEventRecordable) element;
if (fRecordable.isTemporary ()) {
isTemporaryBox.setSelectedIndex (0);
} else {
isTemporaryBox.setSelectedIndex (1);
}
if (fRecordable.getID () == FocusEvent.FOCUS_GAINED) {
typeBox.setSelectedIndex (0);
} else {
typeBox.setSelectedIndex (1);
}
}
}
|