1 |
| package net.sourceforge.pmd.util.viewer.gui.menu; |
2 |
| |
3 |
| import net.sourceforge.pmd.ast.Node; |
4 |
| import net.sourceforge.pmd.ast.SimpleNode; |
5 |
| import net.sourceforge.pmd.util.viewer.model.ViewerModel; |
6 |
| import net.sourceforge.pmd.util.viewer.util.NLS; |
7 |
| |
8 |
| import javax.swing.*; |
9 |
| import java.text.MessageFormat; |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| public class SimpleNodeSubMenu |
19 |
| extends JMenu { |
20 |
| private ViewerModel model; |
21 |
| private SimpleNode node; |
22 |
| |
23 |
| |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
0
| public SimpleNodeSubMenu(ViewerModel model, SimpleNode node) {
|
30 |
0
| super(MessageFormat.format(NLS.nls("AST.MENU.NODE.TITLE"), new Object[]{node.toString()}));
|
31 |
0
| this.model = model;
|
32 |
0
| this.node = node;
|
33 |
0
| init();
|
34 |
| } |
35 |
| |
36 |
0
| private void init() {
|
37 |
0
| StringBuffer buf = new StringBuffer(200);
|
38 |
0
| for (Node temp = node; temp != null; temp = temp.jjtGetParent()) {
|
39 |
0
| buf.insert(0, "/" + temp.toString());
|
40 |
| } |
41 |
0
| add(new XPathFragmentAddingItem(NLS.nls("AST.MENU.NODE.ADD_ABSOLUTE_PATH"), model, buf.toString()));
|
42 |
0
| add(new XPathFragmentAddingItem(NLS.nls("AST.MENU.NODE.ADD_ALLDESCENDANTS"), model,
|
43 |
| "//" + node.toString())); |
44 |
| } |
45 |
| } |
46 |
| |
47 |
| |