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