1 package net.sourceforge.pmd.util.viewer.gui.menu; 2 3 import net.sourceforge.pmd.ast.SimpleNode; 4 import net.sourceforge.pmd.jaxen.Attribute; 5 import net.sourceforge.pmd.jaxen.AttributeAxisIterator; 6 import net.sourceforge.pmd.util.viewer.model.AttributeToolkit; 7 import net.sourceforge.pmd.util.viewer.model.ViewerModel; 8 import net.sourceforge.pmd.util.viewer.util.NLS; 9 10 import javax.swing.*; 11 import java.text.MessageFormat ; 12 13 14 20 public class AttributesSubMenu 21 extends JMenu { 22 private ViewerModel model; 23 private SimpleNode node; 24 25 public AttributesSubMenu(ViewerModel model, SimpleNode node) { 26 super(MessageFormat.format(NLS.nls("AST.MENU.ATTRIBUTES"), new Object []{node.toString()})); 27 this.model = model; 28 this.node = node; 29 init(); 30 } 31 32 private void init() { 33 AttributeAxisIterator i = new AttributeAxisIterator(node); 34 while (i.hasNext()) { 35 Attribute attribute = (Attribute) i.next(); 36 add(new XPathFragmentAddingItem(attribute.getName() + " = " + attribute.getValue(), model, 37 AttributeToolkit.constructPredicate(attribute))); 38 } 39 } 40 } 41 | Popular Tags |