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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68