View Javadoc

    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  /**
    15   * contains menu items for the predicate creation
    16   *
    17   * @author Boris Gruschko ( boris at gruschko.org )
    18   * @version $Id: AttributesSubMenu.java 5024 2007-01-31 21:29:24Z allancaplan $
    19   */
    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"), 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 = i.next();
    36              add(new XPathFragmentAddingItem(attribute.getName() + " = " + attribute.getValue(), model,
    37                      AttributeToolkit.constructPredicate(attribute)));
    38          }
    39      }
    40  }