|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
| package edu.rice.cs.drjava.ui; |
|
38 |
| |
|
39 |
| import javax.swing.*; |
|
40 |
| import javax.swing.event.*; |
|
41 |
| import javax.swing.border.*; |
|
42 |
| import java.awt.event.*; |
|
43 |
| import java.awt.*; |
|
44 |
| |
|
45 |
| import edu.rice.cs.drjava.DrJava; |
|
46 |
| import edu.rice.cs.drjava.config.OptionConstants; |
|
47 |
| import edu.rice.cs.util.swing.Utilities; |
|
48 |
| |
|
49 |
| |
|
50 |
| |
|
51 |
| |
|
52 |
| public class DrJavaErrorPopup extends JDialog { |
|
53 |
| |
|
54 |
| private JComponent _errorInfo; |
|
55 |
| |
|
56 |
| private JCheckBox _keepDisplaying; |
|
57 |
| |
|
58 |
| private JPanel _bottomPanel; |
|
59 |
| |
|
60 |
| private JPanel _buttonPanel; |
|
61 |
| |
|
62 |
| private JButton _okButton; |
|
63 |
| |
|
64 |
| private JButton _moreButton; |
|
65 |
| |
|
66 |
| private Throwable _error; |
|
67 |
| |
|
68 |
| |
|
69 |
| |
|
70 |
| |
|
71 |
0
| public DrJavaErrorPopup(JFrame parent, Throwable error) {
|
|
72 |
0
| super(parent, "DrJava Error");
|
|
73 |
| |
|
74 |
| |
|
75 |
0
| _error = error;
|
|
76 |
| |
|
77 |
0
| this.setSize(500,150);
|
|
78 |
| |
|
79 |
| |
|
80 |
| |
|
81 |
0
| _keepDisplaying = new JCheckBox("Keep showing this notification",
|
|
82 |
| DrJava.getConfig().getSetting(OptionConstants.DIALOG_DRJAVA_ERROR_POPUP_ENABLED).booleanValue()); |
|
83 |
0
| _keepDisplaying.addChangeListener(new ChangeListener() {
|
|
84 |
0
| public void stateChanged(ChangeEvent e) {
|
|
85 |
0
| DrJava.getConfig().setSetting(OptionConstants.DIALOG_DRJAVA_ERROR_POPUP_ENABLED, _keepDisplaying.isSelected());
|
|
86 |
| } |
|
87 |
| }); |
|
88 |
| |
|
89 |
0
| _moreButton = new JButton(_moreAction);
|
|
90 |
0
| _okButton = new JButton(_okAction);
|
|
91 |
| |
|
92 |
0
| _bottomPanel = new JPanel(new BorderLayout());
|
|
93 |
0
| _buttonPanel = new JPanel();
|
|
94 |
0
| _buttonPanel.add(_moreButton);
|
|
95 |
0
| _buttonPanel.add(_okButton);
|
|
96 |
0
| _bottomPanel.add(_keepDisplaying, BorderLayout.WEST);
|
|
97 |
0
| _bottomPanel.add(_buttonPanel, BorderLayout.EAST);
|
|
98 |
| |
|
99 |
0
| if (_error instanceof DrJavaErrorHandler.LoggedCondition) { msg[1] = "Logged condition: " + _error.getMessage(); }
|
|
100 |
0
| else { msg[1] = _error.toString(); }
|
|
101 |
0
| _errorInfo = new JOptionPane(msg,JOptionPane.ERROR_MESSAGE,
|
|
102 |
| JOptionPane.DEFAULT_OPTION,null, |
|
103 |
| new Object[0]); |
|
104 |
| |
|
105 |
0
| JPanel cp = new JPanel(new BorderLayout(5,5));
|
|
106 |
0
| cp.setBorder(new EmptyBorder(5,5,5,5));
|
|
107 |
0
| setContentPane(cp);
|
|
108 |
0
| cp.add(_errorInfo, BorderLayout.CENTER);
|
|
109 |
0
| cp.add(_bottomPanel, BorderLayout.SOUTH);
|
|
110 |
0
| getRootPane().setDefaultButton(_okButton);
|
|
111 |
| } |
|
112 |
| |
|
113 |
| |
|
114 |
| private Action _okAction = new AbstractAction("OK") { |
|
115 |
0
| public void actionPerformed(ActionEvent e) {
|
|
116 |
0
| DrJavaErrorPopup.this.dispose();
|
|
117 |
0
| if (DrJavaErrorHandler.getButton() == null) { System.exit(1); }
|
|
118 |
| } |
|
119 |
| }; |
|
120 |
| |
|
121 |
| |
|
122 |
| private Action _moreAction = new AbstractAction("More Information") { |
|
123 |
0
| public void actionPerformed(ActionEvent e) {
|
|
124 |
0
| if (! Utilities.TEST_MODE) {
|
|
125 |
0
| DrJavaErrorPopup.this.dispose();
|
|
126 |
0
| Utilities.setPopupLoc(DrJavaErrorWindow.singleton(), DrJavaErrorWindow.getFrame());
|
|
127 |
0
| DrJavaErrorWindow.singleton().setVisible(true);
|
|
128 |
| } |
|
129 |
| } |
|
130 |
| }; |
|
131 |
| |
|
132 |
| |
|
133 |
| |
|
134 |
| private final String[] msg = { |
|
135 |
| "An error occurred in DrJava:", |
|
136 |
| "", |
|
137 |
| "You may wish to save all your work and restart DrJava."}; |
|
138 |
| } |