01: package net.sourceforge.pmd.util.viewer.gui.menu;
02:
03: import net.sourceforge.pmd.ast.Node;
04: import net.sourceforge.pmd.ast.SimpleNode;
05: import net.sourceforge.pmd.util.viewer.model.ViewerModel;
06: import net.sourceforge.pmd.util.viewer.util.NLS;
07:
08: import javax.swing.*;
09: import java.text.MessageFormat;
10:
11: /**
12: * submenu for the simple node itself
13: *
14: * @author Boris Gruschko ( boris at gruschko.org )
15: * @version $Id: SimpleNodeSubMenu.java 5024 2007-01-31 21:29:24Z allancaplan $
16: */
17: public class SimpleNodeSubMenu extends JMenu {
18: private ViewerModel model;
19: private SimpleNode node;
20:
21: /**
22: * constructs the submenu
23: *
24: * @param model model to which the actions will be forwarded
25: * @param node menu's owner
26: */
27: public SimpleNodeSubMenu(ViewerModel model, SimpleNode node) {
28: super (MessageFormat.format(NLS.nls("AST.MENU.NODE.TITLE"), node
29: .toString()));
30: this .model = model;
31: this .node = node;
32: init();
33: }
34:
35: private void init() {
36: StringBuffer buf = new StringBuffer(200);
37: for (Node temp = node; temp != null; temp = temp.jjtGetParent()) {
38: buf.insert(0, "/" + temp.toString());
39: }
40: add(new XPathFragmentAddingItem(NLS
41: .nls("AST.MENU.NODE.ADD_ABSOLUTE_PATH"), model, buf
42: .toString()));
43: add(new XPathFragmentAddingItem(NLS
44: .nls("AST.MENU.NODE.ADD_ALLDESCENDANTS"), model, "//"
45: + node.toString()));
46: }
47: }
|