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.cleverphl.session.Session;
028: import jacareto.system.*;
029: import jacareto.toolkit.PriorityList;
030:
031: import java.awt.BorderLayout;
032: import java.awt.Component;
033: import java.awt.Point;
034: import java.awt.event.ActionEvent;
035: import java.awt.event.ActionListener;
036: import java.awt.*;
037: import java.util.Iterator;
038:
039: import javax.swing.JButton;
040: import javax.swing.JDialog;
041: import javax.swing.JPanel;
042: import javax.swing.JScrollPane;
043: import javax.swing.JTable;
044: import javax.swing.border.EmptyBorder;
045: import javax.swing.table.DefaultTableModel;
046: import javax.swing.*;
047:
048: /**
049: * Sets the general session options.
050: *
051: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
052: * @version 1.00
053: */
054: public class SessionOptionsDialog extends JDialog {
055:
056: /** The full reset check box. */
057: private JCheckBox fullResetCheckBox;
058:
059: /** The customization. */
060: private Customization sessionCustomization;
061:
062: /**
063: * Creates a new session options dialog.
064: *
065: * @param cleverPHL the CleverPHL instance
066: */
067: public SessionOptionsDialog(CleverPHL cleverPHL) {
068: super (cleverPHL.getMainFrame(), true);
069: setName(cleverPHL.getCustomization().getString(
070: "Components.JacaretoComponent", "JACARETO_COMPONENT"));
071:
072: Language language = cleverPHL.getLanguage();
073: sessionCustomization = cleverPHL.getSessionList().getActual()
074: .getSessionCustomization();
075:
076: setTitle(language
077: .getString("CleverPHL.SessionOptionsDialog.Title"));
078:
079: Session actualSession = cleverPHL.getSessionList().getActual();
080:
081: // The main panel
082: JPanel mainPanel = new JPanel(new GridBagLayout());
083: GridBagConstraints c = new GridBagConstraints();
084: c.anchor = GridBagConstraints.WEST;
085: c.gridx = 1;
086: c.gridy = 1;
087: fullResetCheckBox = new JCheckBox(
088: language
089: .getString("CleverPHL.SessionOptionsDialog.FullReplayReset"));
090: fullResetCheckBox.setSelected(sessionCustomization.getBoolean(
091: "Session.FullReplayReset", true));
092: mainPanel.add(fullResetCheckBox, c);
093: mainPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
094:
095: JPanel mainPanelWrapper = new JPanel(new FlowLayout(
096: FlowLayout.LEFT));
097: mainPanelWrapper.add(mainPanel);
098:
099: // The panel with the two buttons
100: JPanel buttonPanel = new JPanel();
101: JButton okButton = new JButton(language.getString("General.Ok"));
102: okButton.addActionListener(new ActionListener() {
103: public void actionPerformed(ActionEvent e) {
104: applyChanges();
105: dispose();
106: }
107: });
108:
109: JButton cancelButton = new JButton(language
110: .getString("General.Cancel"));
111: cancelButton.addActionListener(new ActionListener() {
112: public void actionPerformed(ActionEvent e) {
113: dispose();
114: }
115: });
116:
117: buttonPanel.add(okButton);
118: buttonPanel.add(cancelButton);
119: buttonPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
120:
121: // Add all to the content pane
122: getContentPane().setLayout(new BorderLayout());
123: getContentPane().add(mainPanelWrapper, BorderLayout.NORTH);
124: getContentPane().add(buttonPanel, BorderLayout.CENTER);
125:
126: setSize(300, 160);
127: setResizable(true);
128:
129: Point ownerLoc = cleverPHL.getMainFrame().getLocation();
130: setLocation(((int) ownerLoc.getX()) + 30, ((int) ownerLoc
131: .getY()) + 30);
132: setVisible(true);
133: }
134:
135: /** Change the values. */
136: private void applyChanges() {
137: sessionCustomization.put("Session.FullReplayReset",
138: fullResetCheckBox.isSelected());
139:
140: }
141: }
|