~tapaal-contributor/tapaal/autodetect-lens-check2

« back to all changes in this revision

Viewing changes to src/pipe/gui/widgets/ConstantsDialogPanel.java

merged in lp:~yrke/tapaal/evenMore-gui-cleanup doing GUI cleanup and fixing memory access check, about menu in Mac, exception in verification and reenabled quick draw

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
import java.awt.GridBagLayout;
6
6
import java.awt.Insets;
7
7
import java.awt.event.KeyEvent;
8
 
import java.io.IOException;
9
8
import java.util.regex.Pattern;
10
9
 
11
10
import javax.swing.JButton;
23
22
import dk.aau.cs.model.tapn.Constant;
24
23
import dk.aau.cs.model.tapn.TimedArcPetriNetNetwork;
25
24
 
26
 
/*
27
 
 * LeftConstantsPane.java
28
 
 *
29
 
 * Created on 08-10-2009, 13:51:42
30
 
 */
31
 
 
32
 
/**
33
 
 * 
34
 
 * @author Morten Jacobsen
35
 
 */
36
25
public class ConstantsDialogPanel extends javax.swing.JPanel {
37
26
 
38
 
        private JRootPane rootPane;
39
 
        private TimedArcPetriNetNetwork model;
 
27
    private final TimedArcPetriNetNetwork model;
40
28
        private int lowerBound;
41
29
        private int upperBound;
42
30
        private int initialValue = 0;
43
31
        private EscapableDialog dialog;
44
32
 
45
 
        JPanel nameTextFieldPane;
46
 
        JTextField nameTextField;
 
33
    JTextField nameTextField;
47
34
        Dimension size;
48
 
        JLabel nameLabel;  
49
 
        JPanel valueSpinnerPane;
50
 
        JLabel valueLabel;      
 
35
        JLabel nameLabel;
 
36
    JLabel valueLabel;
51
37
        CustomJSpinner valueSpinner;
52
38
        JPanel container;
53
39
        JPanel buttonContainer;
54
40
        JButton okButton;
55
41
        JButton cancelButton;
56
42
 
57
 
        private String oldName;
58
 
 
59
 
        public ConstantsDialogPanel() throws IOException {
60
 
                initComponents();               
61
 
        }
62
 
 
63
 
        public ConstantsDialogPanel(JRootPane pane, TimedArcPetriNetNetwork model) throws IOException {
64
 
                initComponents();
65
 
                rootPane = pane;
66
 
                this.model = model;             
67
 
                oldName = "";
68
 
                nameTextField.setText(oldName);
69
 
        }
70
 
 
71
 
        public ConstantsDialogPanel(JRootPane pane, TimedArcPetriNetNetwork model,
72
 
                        Constant constant) throws IOException {         
73
 
                rootPane = pane;
74
 
                this.model = model;     
75
 
 
76
 
                initialValue = constant.value();                
77
 
                initComponents();
78
 
                
79
 
                oldName = constant.name();
80
 
                lowerBound = constant.lowerBound();
81
 
                upperBound = constant.upperBound();              
 
43
        private final String oldName;
 
44
 
 
45
    public ConstantsDialogPanel(TimedArcPetriNetNetwork model) {
 
46
                this(model, null);
 
47
        }
 
48
 
 
49
        public ConstantsDialogPanel(TimedArcPetriNetNetwork model, Constant constant) {
 
50
        this.model = model;
 
51
 
 
52
        if (constant != null) {
 
53
            initialValue = constant.value();
 
54
            oldName = constant.name();
 
55
            lowerBound = constant.lowerBound();
 
56
            upperBound = constant.upperBound();
 
57
        } else {
 
58
            oldName = "";
 
59
        }
 
60
                initComponents();
 
61
 
82
62
                nameTextField.setText(oldName);
83
63
        }
84
64
 
85
65
        public void showDialog() {
86
 
                dialog = new EscapableDialog(CreateGui.getApp(),
87
 
                                "Edit Constant", true);
 
66
                dialog = new EscapableDialog(CreateGui.getApp(), "Edit Constant", true);
88
67
                dialog.add(container);
89
68
                dialog.getRootPane().setDefaultButton(okButton);
90
69
                dialog.setResizable(false);
93
72
                dialog.setVisible(true);
94
73
        }
95
74
 
96
 
        private void initComponents() throws IOException {                                              
 
75
        private void initComponents() {
97
76
                container = new JPanel();
98
77
                container.setLayout(new GridBagLayout());
99
78
                size = new Dimension(330, 25);