KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > pmd > util > viewer > gui > menu > AttributesSubMenu


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 JavaDoc;
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,v 1.10 2006/02/10 14:15:31 tomcopeland Exp $
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"), new Object JavaDoc[]{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