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