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.Language;
028:
029: import java.awt.BorderLayout;
030: import java.awt.Color;
031: import java.awt.GridBagConstraints;
032: import java.awt.GridBagLayout;
033: import java.awt.Insets;
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.JPanel;
042: import javax.swing.border.EmptyBorder;
043: import javax.swing.border.LineBorder;
044: import javax.swing.border.TitledBorder;
045:
046: /**
047: * Dialog for inserting a test into the record.
048: *
049: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
050: * @version 1.00
051: */
052: public class InsertTestDialog extends JDialog {
053: /** Whether or not the test insertion is recursive. */
054: private boolean isRecursive;
055:
056: /** The checkbox for recursive test insertion. */
057: private JCheckBox recurseCheckBox;
058:
059: /** The checkbox for the default correcting value. */
060: private JCheckBox correctCheckBox;
061:
062: /** The checkbox for the default ignore value. */
063: private JCheckBox ignoreCheckBox;
064:
065: /** The default ignore value */
066: private boolean isIgnoring;
067:
068: /** The default correct value., */
069: private boolean isCorrecting;
070:
071: /** Whether or not the user has pressed ok. */
072: private boolean isOk;
073:
074: /**
075: * Creates a new dialog.
076: *
077: * @param cleverPHL the CleverPHL instance
078: */
079: public InsertTestDialog(CleverPHL cleverPHL) {
080: super (cleverPHL.getComponentsFrame(), true);
081: setName(cleverPHL.getCustomization().getString(
082: "Components.JacaretoComponent", "JACARETO_COMPONENT"));
083:
084: Language language = cleverPHL.getLanguage();
085: ComponentsFrame componentsFrame = cleverPHL
086: .getComponentsFrame();
087:
088: setTitle(language.getString("CleverPHL.InsertTestDialog.Title"));
089:
090: // The main panel .
091: JPanel mainPanel = new JPanel(new GridBagLayout());
092:
093: // The defaults panel
094: JPanel defaultsPanel = new JPanel(new GridBagLayout());
095: defaultsPanel.setBorder(new TitledBorder(new LineBorder(
096: Color.black, 1, true), language
097: .getString("CleverPHL.InsertTestDialog.Properties")));
098:
099: GridBagConstraints dc = new GridBagConstraints();
100: dc.gridx = 0;
101: dc.gridy = 0;
102: dc.insets = new Insets(5, 5, 5, 5);
103: correctCheckBox = new JCheckBox(language
104: .getString("Tests.Test.Correcting"));
105: defaultsPanel.add(correctCheckBox, dc);
106:
107: dc.gridy = 1;
108: ignoreCheckBox = new JCheckBox(language
109: .getString("Tests.Test.Ignoring"));
110: defaultsPanel.add(ignoreCheckBox, dc);
111:
112: GridBagConstraints c = new GridBagConstraints();
113: c.anchor = GridBagConstraints.WEST;
114: c.fill = GridBagConstraints.NONE;
115: c.gridx = 0;
116: c.gridy = 0;
117: c.insets = new Insets(5, 5, 5, 5);
118: mainPanel.add(defaultsPanel);
119:
120: c.gridy = 1;
121: c.insets = new Insets(10, 10, 10, 10);
122: recurseCheckBox = new JCheckBox(language
123: .getString("CleverPHL.InsertTestDialog.Recurse"));
124:
125: if (componentsFrame.getTab() == ComponentsFrame.TREE_TAB) {
126: recurseCheckBox.setSelected(true);
127: } else {
128: recurseCheckBox.setSelected(false);
129: recurseCheckBox.setEnabled(false);
130: }
131:
132: mainPanel.add(recurseCheckBox, c);
133:
134: // The panel with the two buttons
135: JPanel buttonPanel = new JPanel();
136: JButton okButton = new JButton(language.getString("General.Ok"));
137: okButton.addActionListener(new ActionListener() {
138: public void actionPerformed(ActionEvent e) {
139: isRecursive = recurseCheckBox.isSelected();
140: isCorrecting = correctCheckBox.isSelected();
141: isIgnoring = ignoreCheckBox.isSelected();
142: isOk = true;
143: dispose();
144: }
145: });
146:
147: JButton cancelButton = new JButton(language
148: .getString("General.Cancel"));
149: cancelButton.addActionListener(new ActionListener() {
150: public void actionPerformed(ActionEvent e) {
151: isOk = false;
152: ;
153: dispose();
154: }
155: });
156: buttonPanel.add(okButton);
157: buttonPanel.add(cancelButton);
158: buttonPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
159:
160: // Add all to the content pane
161: getContentPane().setLayout(new BorderLayout());
162: getContentPane().add(mainPanel, BorderLayout.NORTH);
163: getContentPane().add(buttonPanel, BorderLayout.CENTER);
164:
165: pack();
166: setResizable(false);
167:
168: Point ownerLoc = cleverPHL.getComponentsFrame().getLocation();
169: setLocation(((int) ownerLoc.getX()) + 30, ((int) ownerLoc
170: .getY()) + 30);
171:
172: setVisible(true);
173: }
174:
175: /**
176: * Returns whether or not the test insertion is recursive.
177: *
178: * @return DOCUMENT ME!
179: */
180: public boolean isRecursive() {
181: return isRecursive;
182: }
183:
184: /**
185: * Returns the default correct value.
186: *
187: * @return DOCUMENT ME!
188: */
189: public boolean isCorrecting() {
190: return isCorrecting;
191: }
192:
193: /**
194: * Returns the default ignore value.
195: *
196: * @return DOCUMENT ME!
197: */
198: public boolean isIgnoring() {
199: return isIgnoring;
200: }
201:
202: /**
203: * Returns whether or not the user has pressed ok.
204: *
205: * @return DOCUMENT ME!
206: */
207: public boolean isOk() {
208: return isOk;
209: }
210: }
|