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