01: package net.sourceforge.pmd.util.viewer.gui.menu;
02:
03: import net.sourceforge.pmd.util.viewer.model.ViewerModel;
04:
05: import javax.swing.*;
06: import java.awt.event.ActionEvent;
07: import java.awt.event.ActionListener;
08:
09: /**
10: * adds the given path fragment to the XPath expression upon action
11: *
12: * @author Boris Gruschko ( boris at gruschko.org )
13: * @version $Id: XPathFragmentAddingItem.java 4217 2006-02-10 14:15:31Z tomcopeland $
14: */
15: public class XPathFragmentAddingItem extends JMenuItem implements
16: ActionListener {
17: private ViewerModel model;
18: private String fragment;
19:
20: /**
21: * constructs the item
22: *
23: * @param caption menu item's caption
24: * @param model model to refer to
25: * @param fragment XPath expression fragment to be added upon action
26: */
27: public XPathFragmentAddingItem(String caption, ViewerModel model,
28: String fragment) {
29: super (caption);
30: this .model = model;
31: this .fragment = fragment;
32: addActionListener(this );
33: }
34:
35: /**
36: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
37: */
38: public void actionPerformed(ActionEvent e) {
39: model.appendToXPathExpression(fragment, this);
40: }
41: }
|