View Javadoc

1   package net.sourceforge.pmd.util.viewer.gui.menu;
2   
3   import net.sourceforge.pmd.util.viewer.model.ViewerModel;
4   
5   import javax.swing.*;
6   import java.awt.event.ActionEvent;
7   import java.awt.event.ActionListener;
8   
9   
10  /***
11   * adds the given path fragment to the XPath expression upon action
12   *
13   * @author Boris Gruschko ( boris at gruschko.org )
14   * @version $Id: XPathFragmentAddingItem.java,v 1.3 2004/04/15 18:21:58 tomcopeland Exp $
15   */
16  public class XPathFragmentAddingItem
17    extends JMenuItem
18    implements ActionListener
19  {
20    private ViewerModel model;
21    private String      fragment;
22  
23    /***
24     * constructs the item
25     *
26     * @param caption menu item's caption
27     * @param model model to refer to
28     * @param fragment XPath expression fragment to be added upon action
29     */
30    public XPathFragmentAddingItem( 
31      String caption, ViewerModel model, String fragment )
32    {
33      super( caption );
34  
35      this.model      = model;
36      this.fragment   = fragment;
37  
38      addActionListener( this );
39    }
40  
41    /***
42     * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
43     */
44    public void actionPerformed( ActionEvent e )
45    {
46      model.appendToXPathExpression( fragment, this );
47    }
48  }
49  
50  
51  /*
52   * $Log: XPathFragmentAddingItem.java,v $
53   * Revision 1.3  2004/04/15 18:21:58  tomcopeland
54   * Cleaned up imports with new version of IDEA; fixed some deprecated Ant junx
55   *
56   * Revision 1.2  2003/09/23 20:51:06  tomcopeland
57   * Cleaned up imports
58   *
59   * Revision 1.1  2003/09/23 20:32:42  tomcopeland
60   * Added Boris Gruschko's new AST/XPath viewer
61   *
62   * Revision 1.1  2003/09/24 01:33:03  bgr
63   * moved to a new package
64   *
65   * Revision 1.1  2003/09/23 07:52:16  bgr
66   * menus added
67   *
68   */