01: package net.sourceforge.pmd.util.viewer.gui.menu;
02:
03: import net.sourceforge.pmd.ast.SimpleNode;
04: import net.sourceforge.pmd.jaxen.Attribute;
05: import net.sourceforge.pmd.jaxen.AttributeAxisIterator;
06: import net.sourceforge.pmd.util.viewer.model.AttributeToolkit;
07: import net.sourceforge.pmd.util.viewer.model.ViewerModel;
08: import net.sourceforge.pmd.util.viewer.util.NLS;
09:
10: import javax.swing.*;
11: import java.text.MessageFormat;
12:
13: /**
14: * contains menu items for the predicate creation
15: *
16: * @author Boris Gruschko ( boris at gruschko.org )
17: * @version $Id: AttributesSubMenu.java 5024 2007-01-31 21:29:24Z allancaplan $
18: */
19: public class AttributesSubMenu extends JMenu {
20: private ViewerModel model;
21: private SimpleNode node;
22:
23: public AttributesSubMenu(ViewerModel model, SimpleNode node) {
24: super (MessageFormat.format(NLS.nls("AST.MENU.ATTRIBUTES"), node
25: .toString()));
26: this .model = model;
27: this .node = node;
28: init();
29: }
30:
31: private void init() {
32: AttributeAxisIterator i = new AttributeAxisIterator(node);
33: while (i.hasNext()) {
34: Attribute attribute = i.next();
35: add(new XPathFragmentAddingItem(attribute.getName() + " = "
36: + attribute.getValue(), model, AttributeToolkit
37: .constructPredicate(attribute)));
38: }
39: }
40: }
|