View Javadoc

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   * $Log: SimpleNodeSubMenu.java,v $
65   * Revision 1.3  2004/04/15 18:21:58  tomcopeland
66   * Cleaned up imports with new version of IDEA; fixed some deprecated Ant junx
67   *
68   * Revision 1.2  2003/09/23 20:51:06  tomcopeland
69   * Cleaned up imports
70   *
71   * Revision 1.1  2003/09/23 20:32:42  tomcopeland
72   * Added Boris Gruschko's new AST/XPath viewer
73   *
74   * Revision 1.1  2003/09/24 01:33:03  bgr
75   * moved to a new package
76   *
77   * Revision 1.1  2003/09/23 07:52:16  bgr
78   * menus added
79   *
80   */