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 * submenu for the simple node itself
14 *
15 * @author Boris Gruschko ( boris at gruschko.org )
16 * @version $Id: SimpleNodeSubMenu.java,v 1.3 2004/04/15 18:21:58 tomcopeland Exp $
17 */
18 public class SimpleNodeSubMenu
19 extends JMenu
20 {
21 private ViewerModel model;
22 private SimpleNode node;
23
24 /***
25 * constructs the submenu
26 *
27 * @param model model to which the actions will be forwarded
28 * @param node menu's owner
29 */
30 public SimpleNodeSubMenu( ViewerModel model, SimpleNode node )
31 {
32 super(
33 MessageFormat.format(
34 NLS.nls( "AST.MENU.NODE.TITLE" ), new Object[] { node.toString( ) } ) );
35
36 this.model = model;
37 this.node = node;
38
39 init( );
40 }
41
42 private void init( )
43 {
44 StringBuffer buf = new StringBuffer( 200 );
45
46 for ( Node temp = node; temp != null; temp = temp.jjtGetParent( ) )
47 {
48 buf.insert( 0, "/" + temp.toString( ) );
49 }
50
51 add(
52 new XPathFragmentAddingItem(
53 NLS.nls( "AST.MENU.NODE.ADD_ABSOLUTE_PATH" ), model, buf.toString( ) ) );
54
55 add(
56 new XPathFragmentAddingItem(
57 NLS.nls( "AST.MENU.NODE.ADD_ALLDESCENDANTS" ), model,
58 "//" + node.toString( ) ) );
59 }
60 }
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80