|
1 |
| package net.sourceforge.pmd.util.viewer.gui; |
|
2 |
| |
|
3 |
| |
|
4 |
| import net.sourceforge.pmd.util.viewer.model.ViewerModel; |
|
5 |
| import net.sourceforge.pmd.util.viewer.model.ViewerModelEvent; |
|
6 |
| import net.sourceforge.pmd.util.viewer.model.ViewerModelListener; |
|
7 |
| import net.sourceforge.pmd.util.viewer.util.NLS; |
|
8 |
| |
|
9 |
| import javax.swing.*; |
|
10 |
| import java.awt.Dimension; |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
| public class XPathPanel |
|
21 |
| |
|
22 |
| extends JTabbedPane |
|
23 |
| |
|
24 |
| implements ViewerModelListener { |
|
25 |
| |
|
26 |
| private ViewerModel model; |
|
27 |
| |
|
28 |
| private JTextArea xPathArea; |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
0
| public XPathPanel(ViewerModel model) {
|
|
38 |
| |
|
39 |
0
| super(JTabbedPane.BOTTOM);
|
|
40 |
| |
|
41 |
| |
|
42 |
0
| this.model = model;
|
|
43 |
| |
|
44 |
| |
|
45 |
0
| init();
|
|
46 |
| |
|
47 |
| } |
|
48 |
| |
|
49 |
| |
|
50 |
0
| private void init() {
|
|
51 |
| |
|
52 |
0
| model.addViewerModelListener(this);
|
|
53 |
| |
|
54 |
| |
|
55 |
0
| xPathArea = new JTextArea();
|
|
56 |
| |
|
57 |
| |
|
58 |
0
| setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), NLS.nls("XPATH.PANEL.TITLE")));
|
|
59 |
| |
|
60 |
| |
|
61 |
0
| add(new JScrollPane(xPathArea), NLS.nls("XPATH.PANEL.EXPRESSION"));
|
|
62 |
| |
|
63 |
0
| add(new EvaluationResultsPanel(model), NLS.nls("XPATH.PANEL.RESULTS"));
|
|
64 |
| |
|
65 |
| |
|
66 |
0
| setPreferredSize(new Dimension(-1, 200));
|
|
67 |
| |
|
68 |
| } |
|
69 |
| |
|
70 |
| |
|
71 |
| |
|
72 |
| |
|
73 |
| |
|
74 |
| |
|
75 |
| |
|
76 |
| |
|
77 |
0
| public String getXPathExpression() {
|
|
78 |
| |
|
79 |
0
| return xPathArea.getText();
|
|
80 |
| |
|
81 |
| } |
|
82 |
| |
|
83 |
| |
|
84 |
| |
|
85 |
| |
|
86 |
| |
|
87 |
| |
|
88 |
0
| public void viewerModelChanged(ViewerModelEvent e) {
|
|
89 |
| |
|
90 |
0
| switch (e.getReason()) {
|
|
91 |
| |
|
92 |
0
| case ViewerModelEvent.PATH_EXPRESSION_APPENDED:
|
|
93 |
| |
|
94 |
| |
|
95 |
0
| if (e.getSource() != this) {
|
|
96 |
| |
|
97 |
0
| xPathArea.append((String) e.getParameter());
|
|
98 |
| |
|
99 |
| } |
|
100 |
| |
|
101 |
| |
|
102 |
0
| setSelectedIndex(0);
|
|
103 |
| |
|
104 |
| |
|
105 |
0
| break;
|
|
106 |
| |
|
107 |
| |
|
108 |
0
| case ViewerModelEvent.CODE_RECOMPILED:
|
|
109 |
| |
|
110 |
0
| setSelectedIndex(0);
|
|
111 |
| |
|
112 |
| |
|
113 |
0
| break;
|
|
114 |
| |
|
115 |
| } |
|
116 |
| |
|
117 |
| } |
|
118 |
| |
|
119 |
| } |