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