1 |
| package net.sourceforge.pmd.util.viewer.gui; |
2 |
| |
3 |
| |
4 |
| import net.sourceforge.pmd.util.viewer.util.NLS; |
5 |
| |
6 |
| import javax.swing.*; |
7 |
| import java.awt.BorderLayout; |
8 |
| import java.awt.FlowLayout; |
9 |
| import java.awt.event.ActionEvent; |
10 |
| import java.awt.event.ActionListener; |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| |
20 |
| public class ParseExceptionHandler |
21 |
| |
22 |
| extends JDialog |
23 |
| |
24 |
| implements ActionListener { |
25 |
| |
26 |
| private Exception exc; |
27 |
| |
28 |
| private JTextArea errorArea; |
29 |
| |
30 |
| private JButton okBtn; |
31 |
| |
32 |
| |
33 |
| |
34 |
| |
35 |
| |
36 |
| |
37 |
| |
38 |
| |
39 |
| |
40 |
0
| public ParseExceptionHandler(JFrame parent, Exception exc) {
|
41 |
| |
42 |
0
| super(parent, NLS.nls("COMPILE_ERROR.DIALOG.TITLE"), true);
|
43 |
| |
44 |
| |
45 |
0
| this.exc = exc;
|
46 |
| |
47 |
| |
48 |
0
| init();
|
49 |
| |
50 |
| } |
51 |
| |
52 |
| |
53 |
0
| private void init() {
|
54 |
| |
55 |
0
| errorArea = new JTextArea();
|
56 |
| |
57 |
0
| errorArea.setEditable(false);
|
58 |
| |
59 |
0
| errorArea.setText(exc.getMessage() + "\n");
|
60 |
| |
61 |
| |
62 |
0
| getContentPane().setLayout(new BorderLayout());
|
63 |
| |
64 |
| |
65 |
0
| JPanel messagePanel = new JPanel(new BorderLayout());
|
66 |
| |
67 |
| |
68 |
0
| messagePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createRaisedBevelBorder(),
|
69 |
| |
70 |
| BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), |
71 |
| |
72 |
| NLS.nls("COMPILE_ERROR.PANEL.TITLE")))); |
73 |
| |
74 |
| |
75 |
0
| messagePanel.add(new JScrollPane(errorArea), BorderLayout.CENTER);
|
76 |
| |
77 |
| |
78 |
0
| getContentPane().add(messagePanel, BorderLayout.CENTER);
|
79 |
| |
80 |
| |
81 |
0
| JPanel btnPane = new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
82 |
| |
83 |
| |
84 |
0
| okBtn = new JButton(NLS.nls("COMPILE_ERROR.OK_BUTTON.CAPTION"));
|
85 |
| |
86 |
| |
87 |
0
| okBtn.addActionListener(this);
|
88 |
| |
89 |
| |
90 |
0
| btnPane.add(okBtn);
|
91 |
| |
92 |
| |
93 |
0
| getRootPane().setDefaultButton(okBtn);
|
94 |
| |
95 |
| |
96 |
0
| getContentPane().add(btnPane, BorderLayout.SOUTH);
|
97 |
| |
98 |
| |
99 |
0
| pack();
|
100 |
| |
101 |
| |
102 |
0
| setLocationRelativeTo(getParent());
|
103 |
| |
104 |
| |
105 |
0
| setVisible(true);
|
106 |
| |
107 |
| } |
108 |
| |
109 |
| |
110 |
| |
111 |
| |
112 |
| |
113 |
| |
114 |
0
| public void actionPerformed(ActionEvent e) {
|
115 |
| |
116 |
0
| if (e.getSource() == okBtn) {
|
117 |
| |
118 |
0
| dispose();
|
119 |
| |
120 |
| } |
121 |
| |
122 |
| } |
123 |
| |
124 |
| } |