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 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| |
20 |
| public class AttributesSubMenu |
21 |
| extends JMenu { |
22 |
| private ViewerModel model; |
23 |
| private SimpleNode node; |
24 |
| |
25 |
0
| public AttributesSubMenu(ViewerModel model, SimpleNode node) {
|
26 |
0
| super(MessageFormat.format(NLS.nls("AST.MENU.ATTRIBUTES"), new Object[]{node.toString()}));
|
27 |
0
| this.model = model;
|
28 |
0
| this.node = node;
|
29 |
0
| init();
|
30 |
| } |
31 |
| |
32 |
0
| private void init() {
|
33 |
0
| AttributeAxisIterator i = new AttributeAxisIterator(node);
|
34 |
0
| while (i.hasNext()) {
|
35 |
0
| Attribute attribute = (Attribute) i.next();
|
36 |
0
| add(new XPathFragmentAddingItem(attribute.getName() + " = " + attribute.getValue(), model,
|
37 |
| AttributeToolkit.constructPredicate(attribute))); |
38 |
| } |
39 |
| } |
40 |
| } |