|
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 extends JDialog implements ActionListener { |
|
21 |
| private Exception exc; |
|
22 |
| private JTextArea errorArea; |
|
23 |
| private JButton okBtn; |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
0
| public ParseExceptionHandler(JFrame parent, Exception exc) {
|
|
32 |
0
| super(parent, NLS.nls("COMPILE_ERROR.DIALOG.TITLE"), true);
|
|
33 |
0
| this.exc = exc;
|
|
34 |
0
| init();
|
|
35 |
| } |
|
36 |
| |
|
37 |
0
| private void init() {
|
|
38 |
0
| errorArea = new JTextArea();
|
|
39 |
0
| errorArea.setEditable(false);
|
|
40 |
0
| errorArea.setText(exc.getMessage() + "\n");
|
|
41 |
0
| getContentPane().setLayout(new BorderLayout());
|
|
42 |
0
| JPanel messagePanel = new JPanel(new BorderLayout());
|
|
43 |
0
| messagePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createRaisedBevelBorder(),
|
|
44 |
| BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), |
|
45 |
| NLS.nls("COMPILE_ERROR.PANEL.TITLE")))); |
|
46 |
0
| messagePanel.add(new JScrollPane(errorArea), BorderLayout.CENTER);
|
|
47 |
0
| getContentPane().add(messagePanel, BorderLayout.CENTER);
|
|
48 |
0
| JPanel btnPane = new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
|
49 |
0
| okBtn = new JButton(NLS.nls("COMPILE_ERROR.OK_BUTTON.CAPTION"));
|
|
50 |
0
| okBtn.addActionListener(this);
|
|
51 |
0
| btnPane.add(okBtn);
|
|
52 |
0
| getRootPane().setDefaultButton(okBtn);
|
|
53 |
0
| getContentPane().add(btnPane, BorderLayout.SOUTH);
|
|
54 |
0
| pack();
|
|
55 |
0
| setLocationRelativeTo(getParent());
|
|
56 |
0
| setVisible(true);
|
|
57 |
| } |
|
58 |
| |
|
59 |
| |
|
60 |
| |
|
61 |
| |
|
62 |
0
| public void actionPerformed(ActionEvent e) {
|
|
63 |
0
| if (e.getSource() == okBtn) {
|
|
64 |
0
| dispose();
|
|
65 |
| } |
|
66 |
| } |
|
67 |
| } |