001: // This file is part of KeY - Integrated Deductive Software Design
002: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
003: // Universitaet Koblenz-Landau, Germany
004: // Chalmers University of Technology, Sweden
005: //
006: // The KeY system is protected by the GNU General Public License.
007: // See LICENSE.TXT for details.
008: //
009: //
010:
011: package de.uka.ilkd.key.gui.configuration;
012:
013: import java.awt.BorderLayout;
014: import java.awt.GridLayout;
015: import java.awt.event.ActionEvent;
016: import java.awt.event.ActionListener;
017: import java.awt.event.ItemEvent;
018: import java.awt.event.ItemListener;
019:
020: import javax.swing.*;
021: import javax.swing.border.TitledBorder;
022:
023: import de.uka.ilkd.key.gui.KeYMediator;
024:
025: public class SimultaneousUpdateSimplifierConfiguration extends JDialog {
026:
027: private SimultaneousUpdateSimplifierSettings settingsFromConfigurationFile;
028:
029: private KeYMediator mediator = null;
030:
031: private boolean localDeleteEffectlessUpdates = false;
032: private boolean localEagerMode = false;
033:
034: /** creates a new HeuristicSelector */
035: public SimultaneousUpdateSimplifierConfiguration(
036: KeYMediator mediator,
037: SimultaneousUpdateSimplifierSettings settings) {
038: super (new JFrame(), "Update Simplification", true);
039:
040: settingsFromConfigurationFile = settings;
041:
042: localDeleteEffectlessUpdates = deleteEffectlessUpdates();
043: localEagerMode = eagerMode();
044:
045: setMediator(mediator);
046:
047: layoutSimutanUpdatesimplifier();
048:
049: pack();
050: setLocation(70, 70);
051: }
052:
053: /** sets the mediator to correspond with other gui elements
054: * @param mediator the KeYMediator
055: */
056: public void setMediator(KeYMediator mediator) {
057: this .mediator = mediator;
058: }
059:
060: // setter
061:
062: private void setDeleteEffectlessUpdates(boolean b) {
063: localDeleteEffectlessUpdates = b;
064: }
065:
066: private void setEagerMode(boolean b) {
067: localEagerMode = b;
068: }
069:
070: private void pushSettings() {
071: settingsFromConfigurationFile
072: .setDeleteEffectlessUpdates(localDeleteEffectlessUpdates);
073: settingsFromConfigurationFile.setEagerMode(localEagerMode);
074:
075: mediator.setSimplifier(settingsFromConfigurationFile
076: .getSimplifier());
077: }
078:
079: // getter
080:
081: public boolean deleteEffectlessUpdates() {
082: return settingsFromConfigurationFile.deleteEffectlessUpdates();
083: }
084:
085: public boolean eagerMode() {
086: return settingsFromConfigurationFile.eagerMode();
087: }
088:
089: /** lays out the configuration dialog */
090: public void layoutSimutanUpdatesimplifier() {
091: JPanel checkBoxPanel = new JPanel(new GridLayout(2, 1));
092: checkBoxPanel.setBorder(new TitledBorder(
093: "Current Configuration"));
094:
095: JCheckBox delete_effectless_cb = new JCheckBox(
096: "Delete effectless updates", deleteEffectlessUpdates());
097: delete_effectless_cb.addItemListener(new ItemListener() {
098: public void itemStateChanged(ItemEvent ce) {
099: setDeleteEffectlessUpdates(ce.getStateChange() == ItemEvent.SELECTED);
100: }
101: });
102:
103: checkBoxPanel.add(delete_effectless_cb);
104:
105: JCheckBox eagerModeCheckbox = new JCheckBox(
106: "One Pass Simplification", eagerMode());
107: eagerModeCheckbox.addItemListener(new ItemListener() {
108: public void itemStateChanged(ItemEvent ce) {
109: setEagerMode(ce.getStateChange() == ItemEvent.SELECTED);
110: }
111: });
112:
113: checkBoxPanel.add(eagerModeCheckbox);
114:
115: JPanel buttonPanel = new JPanel(new GridLayout(1, 2));
116: JButton ok = new JButton("OK");
117: ok.addActionListener(new ActionListener() {
118: public void actionPerformed(ActionEvent ae) {
119: pushSettings();
120: dispose();
121: }
122: });
123: JButton cancel = new JButton("Cancel");
124: cancel.addActionListener(new ActionListener() {
125: public void actionPerformed(ActionEvent ae) {
126: dispose();
127: }
128: });
129: buttonPanel.add(ok);
130: buttonPanel.add(cancel);
131:
132: getContentPane().setLayout(new BorderLayout());
133: getContentPane().add(checkBoxPanel, BorderLayout.CENTER);
134: getContentPane().add(buttonPanel, BorderLayout.SOUTH);
135:
136: }
137:
138: }
|