1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.xmlhammer.gui.output;
23
24 import java.awt.Dimension;
25 import java.net.URI;
26
27 import javax.swing.ImageIcon;
28 import javax.swing.JFrame;
29 import javax.swing.JPopupMenu;
30
31 import org.bounce.RunnableAction;
32 import org.bounce.MenuUtilities;
33 import org.bounce.image.ImageLoader;
34 import org.xmlhammer.model.project.Attribute;
35
36 /***
37 * The node for an XML attribute.
38 *
39 * @version $Revision: 1.9 $, $Date: 2007/07/04 19:42:48 $
40 * @author Edwin Dankert <edankert@gmail.com>
41 */
42 public class AttributeNode extends ResultNode {
43 static final Dimension EDITORPANE_SIZE = new Dimension( 100, 60);
44
45 private static final long serialVersionUID = -1312728718437717912L;
46
47 private static final ImageIcon ICON = ImageLoader.get().getImage( "/org/xmlhammer/gui/icons/obj16/att_URI_obj.gif");;
48 private static AttributeDetailsDialog dialog = null;
49
50 private Attribute value = null;
51 private URI uri = null;
52
53 public AttributeNode(URI uri, Attribute value) {
54 this.value = value;
55 this.uri = uri;
56 }
57
58 public String getName() {
59 return value.getName();
60 }
61
62 public String getValue() {
63 return value.getNodeName()+" - "+value.getNodeValue();
64 }
65
66 public String getDescription() {
67 return "{"+value.getNamespaceURI()+"}"+value.getName()+" - "+value.getValue();
68 }
69
70 public ImageIcon getIcon() {
71 return ICON;
72 }
73
74 @Override
75 public JPopupMenu getPopupMenu(JFrame parent) {
76 JPopupMenu popup = new JPopupMenu();
77 popup.add(getOpenURIAction(uri, 0, 0));
78 popup.add(getEditURIAction(uri, 0, 0));
79 popup.addSeparator();
80 popup.add(getCopyAction());
81 popup.addSeparator();
82 popup.add(getPropertiesAction(getDialog(parent)));
83
84 MenuUtilities.alignMenu(popup);
85
86 return popup;
87 }
88
89 @Override
90 public RunnableAction getDefaultAction(JFrame parent) {
91 return getPropertiesAction(getDialog(parent));
92 }
93
94 private AttributeDetailsDialog getDialog(JFrame parent) {
95 if (dialog == null) {
96 dialog = new AttributeDetailsDialog(parent);
97 }
98
99 dialog.setAttribute(value);
100
101 return dialog;
102 }
103
104 public String getCopyValue() {
105 return value.getNodeName()+"=\""+value.getNodeValue()+"\"";
106 }
107 }