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.awt.BorderLayout;
24 import java.awt.Dimension;
25 import java.awt.Font;
26
27 import javax.swing.Box;
28 import javax.swing.JEditorPane;
29 import javax.swing.JFrame;
30 import javax.swing.JLabel;
31 import javax.swing.JPanel;
32 import javax.swing.JScrollPane;
33 import javax.swing.JTextArea;
34 import javax.swing.JTextField;
35 import javax.swing.border.EmptyBorder;
36 import javax.swing.text.PlainDocument;
37
38 import org.bounce.FormLayout;
39 import org.bounce.text.LineNumberMargin;
40 import org.bounce.text.ScrollableEditorPanel;
41 import org.bounce.text.xml.XMLEditorKit;
42 import org.xmlhammer.model.project.ProcessingInstruction;
43
44 class ProcessingInstructionDetailsDialog extends DetailsDialog {
45 private static final long serialVersionUID = 6396657641170177743L;
46 private static final Dimension EDITORPANE_SIZE = new Dimension( 100, 80);
47
48 private NodePanel nodePanel = null;
49
50 private JTextField srcField = null;
51 private JTextField classField = null;
52 private JTextField pathField = null;
53
54 private JTextField targetField = null;
55 private JTextArea dataField = null;
56
57 private JEditorPane contextPane = null;
58
59 ProcessingInstructionDetailsDialog(JFrame parent) {
60 super(parent, "Element Details");
61
62 DetailsPanel general = new DetailsPanel(new BorderLayout(), "general");
63 JPanel form = new JPanel( new FormLayout(5, 5));
64
65 srcField = new JTextField();
66 srcField.setEditable(false);
67 form.add(new JLabel("URI:"), LABEL_CONSTRAINTS);
68 form.add(srcField, FormLayout.RIGHT_FILL);
69
70 classField = new JTextField();
71 classField.setEditable(false);
72 form.add(new JLabel("Class:"), LABEL_CONSTRAINTS);
73 form.add(classField, FormLayout.RIGHT_FILL);
74
75 form.add(Box.createVerticalStrut(10), FormLayout.FULL);
76
77 pathField = new JTextField();
78 pathField.setEditable(false);
79 form.add(new JLabel("Path:"), LABEL_CONSTRAINTS);
80 form.add(pathField, FormLayout.RIGHT_FILL);
81
82 form.add(Box.createVerticalStrut(10), FormLayout.FULL);
83
84 targetField = new JTextField();
85 targetField.setEditable(false);
86 form.add(new JLabel("Target:"), LABEL_CONSTRAINTS);
87 form.add(targetField, FormLayout.RIGHT_FILL);
88
89 dataField = new JTextArea();
90 dataField.setEditable(false);
91 dataField.setLineWrap(false);
92 form.add(new JLabel("Data:"), LABEL_CONSTRAINTS);
93
94 JPanel panel = new JPanel(new BorderLayout());
95 panel.add(dataField, BorderLayout.CENTER);
96
97 JScrollPane scroller = new JScrollPane( panel);
98 scroller.setPreferredSize(EDITORPANE_SIZE);
99 form.add(scroller, FormLayout.RIGHT_FILL);
100
101 form.add(Box.createVerticalStrut(10), FormLayout.FULL);
102
103 form.add(new JLabel("Context:"), FormLayout.FULL);
104
105
106 nodePanel = new NodePanel();
107 nodePanel.setBorder( new EmptyBorder(10, 10, 10, 10));
108
109 contextPane = new JEditorPane();
110 contextPane.setEditorKit(new XMLEditorKit());
111 contextPane.setEditable(false);
112 contextPane.setFont(new Font("monospaced", Font.PLAIN, 12));
113 contextPane.getDocument().putProperty(PlainDocument.tabSizeAttribute, new Integer(2));
114
115 scroller = new JScrollPane(new ScrollableEditorPanel(contextPane));
116 scroller.setPreferredSize(AttributeNode.EDITORPANE_SIZE);
117
118
119 scroller.setRowHeaderView(new LineNumberMargin(contextPane));
120
121 general.add(form, BorderLayout.NORTH);
122 general.add(scroller, BorderLayout.CENTER);
123
124 addTab("General", general);
125 addTab("Node", nodePanel);
126
127 pack();
128
129 setSize( new Dimension( 500, getSize().height));
130 setLocationRelativeTo(parent);
131 }
132
133 public void setProcessingInstruction(ProcessingInstruction pi) {
134 setTitle("Processing Instruction Details");
135 nodePanel.setNode(pi);
136
137 srcField.setText(pi.getSrc());
138 srcField.setCaretPosition(0);
139 classField.setText(pi.getClazz());
140 classField.setCaretPosition(0);
141 pathField.setText(pi.getPath());
142 pathField.setCaretPosition(0);
143
144 dataField.setText(pi.getData());
145 dataField.setCaretPosition(0);
146
147 targetField.setText(pi.getTarget());
148 targetField.setCaretPosition(0);
149
150 contextPane.setText(pi.getContext());
151 contextPane.setCaretPosition(0);
152 }
153
154 @Override
155 protected String getBaseHelpID() {
156 return "output.result.processing-instruction";
157 }
158 }