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.cleverphl.gui;
025:
026: import jacareto.cleverphl.CleverPHL;
027: import jacareto.system.Customization;
028: import jacareto.system.Language;
029: import jacareto.toolkit.swing.IntegerTextField;
030:
031: import java.awt.BorderLayout;
032: import java.awt.GridBagConstraints;
033: import java.awt.GridBagLayout;
034: import java.awt.Point;
035: import java.awt.event.ActionEvent;
036: import java.awt.event.ActionListener;
037:
038: import javax.swing.JButton;
039: import javax.swing.JCheckBox;
040: import javax.swing.JDialog;
041: import javax.swing.JLabel;
042: import javax.swing.JPanel;
043: import javax.swing.border.EmptyBorder;
044:
045: /**
046: * Dialog for editing the mouse motion event mask.
047: *
048: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
049: * @version 1.0
050: */
051: public class MouseMotionEventMaskDialog extends JDialog {
052: /** CleverPHL. */
053: private CleverPHL cleverPHL;
054:
055: /** The checkbox for "mouse moved". */
056: private JCheckBox mouseMovedChkBox;
057:
058: /** The checkbox for "mouse dragged". */
059: private JCheckBox mouseDraggedChkBox;
060:
061: /** The text field for the minimal lag time. */
062: private IntegerTextField minLagTimeField;
063:
064: /**
065: * Creates a new MouseMotionEventMaskDialog ( initially visible ).
066: *
067: * @param cleverPHL the CleverPHL instance
068: */
069: public MouseMotionEventMaskDialog(CleverPHL cleverPHL) {
070: super (cleverPHL.getMainFrame(), true);
071: this .cleverPHL = cleverPHL;
072: setName(cleverPHL.getCustomization().getString(
073: "Components.JacaretoComponent", "JACARETO_COMPONENT"));
074:
075: Language language = cleverPHL.getLanguage();
076:
077: setTitle(language
078: .getString("CleverPHL.MouseMotionEventMaskDialog.Title"));
079:
080: JPanel chkBoxPanel = new JPanel();
081: chkBoxPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
082: chkBoxPanel.setLayout(new GridBagLayout());
083:
084: GridBagConstraints c = new GridBagConstraints();
085:
086: // mouse moved checkbox
087: mouseMovedChkBox = new JCheckBox(language
088: .getString("Events.MouseEvent.MouseMoved"));
089: c.gridx = 0;
090: c.gridy = 0;
091: c.gridwidth = 2;
092: c.gridheight = 1;
093: c.anchor = GridBagConstraints.WEST;
094: chkBoxPanel.add(mouseMovedChkBox, c);
095:
096: // mouse dragged checkbox
097: mouseDraggedChkBox = new JCheckBox(language
098: .getString("Events.MouseEvent.MouseDragged"));
099: c.gridy = 1;
100: chkBoxPanel.add(mouseDraggedChkBox, c);
101:
102: // The components for the minimal lag time
103: JPanel minLagTimePanel = new JPanel();
104: JLabel minLagTimeLabel = new JLabel(
105: language
106: .getString("EventMasks.MouseMotionEventMask.MinimalLagTime"));
107: minLagTimeField = new IntegerTextField(4);
108: minLagTimePanel.add(minLagTimeLabel);
109: minLagTimePanel.add(minLagTimeField);
110: minLagTimeLabel.setLabelFor(minLagTimeField);
111: c.gridy = 2;
112: chkBoxPanel.add(minLagTimePanel, c);
113:
114: // The panel with the two buttons
115: JPanel buttonPanel = new JPanel();
116: JButton okButton = new JButton(language.getString("General.Ok"));
117: okButton.addActionListener(new ActionListener() {
118: public void actionPerformed(ActionEvent e) {
119: changeCustomization();
120: dispose();
121: }
122: });
123:
124: JButton cancelButton = new JButton(language
125: .getString("General.Cancel"));
126: cancelButton.addActionListener(new ActionListener() {
127: public void actionPerformed(ActionEvent e) {
128: dispose();
129: }
130: });
131: buttonPanel.add(okButton);
132: buttonPanel.add(cancelButton);
133: buttonPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
134:
135: applyCustomization();
136:
137: // Add all to the content pane
138: getContentPane().setLayout(new BorderLayout());
139: getContentPane().add(chkBoxPanel, BorderLayout.NORTH);
140: getContentPane().add(buttonPanel, BorderLayout.CENTER);
141:
142: setResizable(false);
143: pack();
144:
145: Point ownerLoc = cleverPHL.getMainFrame().getLocation();
146: setLocation(((int) ownerLoc.getX()) + 30, ((int) ownerLoc
147: .getY()) + 30);
148:
149: setVisible(true);
150: }
151:
152: /**
153: * Apply the customization.
154: */
155: private void applyCustomization() {
156: Customization customization = cleverPHL.getCustomization();
157: mouseMovedChkBox.setSelected(customization.getBoolean(
158: "MouseMotionEventMask.Include.MouseMoved", false));
159: mouseDraggedChkBox.setSelected(customization.getBoolean(
160: "MouseMotionEventMask.Include.MouseDragged", false));
161: minLagTimeField.setValue(customization.getInt(
162: "MouseMotionEventMask.MinimalLagTime", 50));
163: }
164:
165: /**
166: * Change the customization.
167: */
168: void changeCustomization() {
169: Customization customization = cleverPHL.getCustomization();
170: customization.put("MouseMotionEventMask.Include.MouseMoved",
171: mouseMovedChkBox.isSelected());
172: customization.put("MouseMotionEventMask.Include.MouseDragged",
173: mouseDraggedChkBox.isSelected());
174: customization.put("MouseMotionEventMask.MinimalLagTime",
175: minLagTimeField.getValue());
176: }
177: }
|