01: // This file is part of KeY - Integrated Deductive Software Design
02: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
03: // Universitaet Koblenz-Landau, Germany
04: // Chalmers University of Technology, Sweden
05: //
06: // The KeY system is protected by the GNU General Public License.
07: // See LICENSE.TXT for details.
08:
09: package de.uka.ilkd.key.gui;
10:
11: import java.awt.Dimension;
12: import java.awt.event.ActionEvent;
13: import java.awt.event.ActionListener;
14: import java.util.Set;
15:
16: import javax.swing.JButton;
17: import javax.swing.JDialog;
18: import javax.swing.JFrame;
19: import javax.swing.JPanel;
20:
21: import de.uka.ilkd.key.casetool.ModelClass;
22: import de.uka.ilkd.key.speclang.ListOfClassInvariant;
23:
24: public class ClassInvariantSelectionDialog extends JDialog {
25:
26: private boolean successful = false;
27: private ClassInvariantSelectionPanel panel;
28:
29: /**
30: * Creates and displays a dialog box asking the user to select a set of
31: * invariants.
32: * @param modelClasses the classes to choose invariants from
33: */
34: public ClassInvariantSelectionDialog(String title,
35: Set modelClasses, boolean useThroughoutInvs,
36: ModelClass defaultClass) {
37: super (new JFrame(), title, true);
38: panel = new ClassInvariantSelectionPanel(modelClasses,
39: useThroughoutInvs, defaultClass, true);
40: JPanel rightButtonPanel = panel.getButtonPanel();
41:
42: Dimension buttonDim = new Dimension(95, 25);
43:
44: // create "ok" button
45: JButton okButton = new JButton("OK");
46: okButton.setPreferredSize(buttonDim);
47: okButton.setMinimumSize(buttonDim);
48: okButton.addActionListener(new ActionListener() {
49: public void actionPerformed(ActionEvent e) {
50: successful = true;
51: setVisible(false);
52: }
53: });
54: rightButtonPanel.add(okButton);
55: getRootPane().setDefaultButton(okButton);
56:
57: //create "cancel" button
58: JButton cancelButton = new JButton("Cancel");
59: cancelButton.setPreferredSize(buttonDim);
60: cancelButton.setMinimumSize(buttonDim);
61: cancelButton.addActionListener(new ActionListener() {
62: public void actionPerformed(ActionEvent e) {
63: setVisible(false);
64: }
65: });
66: rightButtonPanel.add(cancelButton);
67:
68: getContentPane().add(panel);
69: pack();
70: setLocation(70, 70);
71: setVisible(true);
72: }
73:
74: /**
75: * Tells whether the user clicked "ok".
76: */
77: public boolean wasSuccessful() {
78: return successful;
79: }
80:
81: /**
82: * Returns the selected set of invariants.
83: */
84: public ListOfClassInvariant getClassInvariants() {
85: return panel.getClassInvariants();
86: }
87: }
|