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.struct.MouseExited;
027: import jacareto.struct.StructureElement;
028: import jacareto.system.Environment;
029: import jacareto.system.Language;
030:
031: import java.awt.Component;
032: import java.awt.GridBagConstraints;
033: import java.awt.GridBagLayout;
034:
035: import javax.swing.JLabel;
036: import javax.swing.JPanel;
037: import javax.swing.border.EmptyBorder;
038:
039: /**
040: * An editor for mouse exits.
041: *
042: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
043: * @version 1.01
044: */
045: public class MouseExitedEditor extends Editor {
046: /** The element to edit. */
047: private StructureElement element;
048:
049: /** The panel. */
050: private JPanel editorPanel;
051:
052: /** The grid bag constraints. */
053: private GridBagConstraints c;
054:
055: /** The text field for the source name. */
056: private JLabel componentField;
057:
058: /**
059: * Create a new "mouse exited" recordable editor.
060: *
061: * @param env the environment
062: */
063: public MouseExitedEditor(Environment env) {
064: super (env);
065:
066: Language language = getLanguage();
067:
068: // The panel with the text fields
069: editorPanel = new JPanel();
070: editorPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
071: editorPanel.setLayout(new GridBagLayout());
072:
073: // The component field label
074: c = new GridBagConstraints();
075: c.gridx = 0;
076: c.gridy = 0;
077: c.weightx = 40;
078: c.ipadx = 5;
079: c.ipady = 5;
080: c.anchor = GridBagConstraints.WEST;
081:
082: JLabel componentFieldLabel = new JLabel(language
083: .getString("Events.ComponentEvent.Component")
084: + ":");
085: editorPanel.add(componentFieldLabel, c);
086:
087: // The component field
088: c.gridx = 1;
089: c.weightx = 60;
090: componentField = new JLabel();
091: editorPanel.add(componentField, c);
092: componentFieldLabel.setLabelFor(componentField);
093: }
094:
095: /**
096: * Returns whether this editor is responsible for a given structure element. This editor is
097: * responsible for all "mouse exited" elements.
098: *
099: * @param element the structure element
100: *
101: * @return <code>true</code> if <i>element</i> is a mouse event recordable and not
102: * <code>null</code>, otherwise <code>false</code>
103: */
104: public boolean handlesElement(StructureElement element) {
105: return (element != null) && (element instanceof MouseExited);
106: }
107:
108: /**
109: * Returns the actual structure element to be edited.
110: *
111: * @return DOCUMENT ME!
112: */
113: public StructureElement getElement() {
114: return element;
115: }
116:
117: /**
118: * Sets the element to edit.
119: *
120: * @param element DOCUMENT ME!
121: */
122: public void setElement(StructureElement element) {
123: this .element = element;
124:
125: MouseExited exited = (MouseExited) element;
126: componentField.setText(exited.getComponentName());
127: }
128:
129: /**
130: * Returns the component of the editor.
131: *
132: * @return the editor component
133: */
134: public Component getComponent() {
135: return editorPanel;
136: }
137: }
|