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.ProcessingInstruction;
33
34 /***
35 * The node for a Processing 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 ProcessingInstructionNode extends ResultNode {
41 private static final long serialVersionUID = 1945113504830911025L;
42
43 private static final ImageIcon ICON = ImageLoader.get().getImage( "/org/xmlhammer/gui/icons/obj16/change_obj.gif");;
44
45 private static ProcessingInstructionDetailsDialog dialog = null;
46
47 private ProcessingInstruction pi = null;
48 private String value = null;
49 private URI uri = null;
50
51 public ProcessingInstructionNode(URI uri, ProcessingInstruction pi) {
52 this.pi = pi;
53 this.uri = uri;
54 }
55
56 public String getName() {
57 return pi.getTarget();
58 }
59
60 public String getValue() {
61 if ( value == null) {
62 StringBuffer buffer = new StringBuffer( pi.getTarget());
63 buffer.append( " - ");
64 buffer.append( getFirstLine(pi.getData()));
65
66 value = buffer.toString();
67 }
68
69 return value;
70 }
71
72 public String getDescription() {
73 return value;
74 }
75
76 public ImageIcon getIcon() {
77 return ICON;
78 }
79
80 @Override
81 public JPopupMenu getPopupMenu(JFrame parent) {
82 JPopupMenu popup = new JPopupMenu();
83 popup.add(getOpenURIAction(uri, 0, 0));
84 popup.add(getEditURIAction(uri, 0, 0));
85 popup.addSeparator();
86 popup.add(getCopyAction());
87 popup.addSeparator();
88 popup.add(getPropertiesAction(getDialog(parent)));
89
90 MenuUtilities.alignMenu(popup);
91
92 return popup;
93 }
94
95 @Override
96 public RunnableAction getDefaultAction(JFrame parent) {
97 return getPropertiesAction(getDialog(parent));
98 }
99
100 private ProcessingInstructionDetailsDialog getDialog(JFrame parent) {
101 if (dialog == null) {
102 dialog = new ProcessingInstructionDetailsDialog(parent);
103 }
104
105 dialog.setProcessingInstruction(pi);
106
107 return dialog;
108 }
109
110 public String getCopyValue() {
111 StringBuffer buffer = new StringBuffer("<?");
112 buffer.append(pi.getTarget());
113 buffer.append(" ");
114 buffer.append(pi.getData());
115 buffer.append("?>");
116
117 return buffer.toString();
118 }
119 }