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.JTextField;
34 import javax.swing.border.EmptyBorder;
35 import javax.swing.text.PlainDocument;
36
37 import org.bounce.FormConstraints;
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.Element;
43
44 class ElementDetailsDialog extends DetailsDialog {
45 private static final long serialVersionUID = 6396657641170177743L;
46 private NodePanel nodePanel = null;
47 private TypePanel typePanel = null;
48 private FormConstraints labelConstraints = new FormConstraints(FormConstraints.LEFT, FormConstraints.RIGHT, FormConstraints.TOP);
49
50 private JTextField srcField = null;
51 private JTextField classField = null;
52 private JTextField tagNameField = null;
53 private JTextField pathField = null;
54 private JEditorPane contextPane = null;
55
56 ElementDetailsDialog(JFrame parent) {
57 super(parent, "Element 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:"), labelConstraints);
65 form.add(srcField, FormLayout.RIGHT_FILL);
66
67 classField = new JTextField();
68 classField.setEditable(false);
69 form.add(new JLabel("Class:"), labelConstraints);
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:"), labelConstraints);
77 form.add(pathField, FormLayout.RIGHT_FILL);
78
79 form.add(Box.createVerticalStrut(10), FormLayout.FULL);
80
81 tagNameField = new JTextField();
82 tagNameField.setEditable(false);
83 form.add(new JLabel("Name:"), labelConstraints);
84 form.add(tagNameField, FormLayout.RIGHT_FILL);
85
86 form.add(Box.createVerticalStrut(10), FormLayout.FULL);
87
88 form.add(new JLabel("Context:"), FormLayout.FULL);
89
90
91 nodePanel = new NodePanel();
92 nodePanel.setBorder( new EmptyBorder(10, 10, 10, 10));
93
94 typePanel = new TypePanel();
95 typePanel.setBorder( new EmptyBorder(10, 10, 10, 10));
96
97 contextPane = new JEditorPane();
98 contextPane.setEditorKit(new XMLEditorKit());
99 contextPane.setEditable(false);
100 contextPane.setFont(new Font("monospaced", Font.PLAIN, 12));
101 contextPane.getDocument().putProperty(PlainDocument.tabSizeAttribute, new Integer(2));
102
103 JScrollPane scroller = new JScrollPane(new ScrollableEditorPanel(contextPane));
104 scroller.setPreferredSize(AttributeNode.EDITORPANE_SIZE);
105
106
107 scroller.setRowHeaderView(new LineNumberMargin(contextPane));
108
109 general.add(form, BorderLayout.NORTH);
110 general.add(scroller, BorderLayout.CENTER);
111
112 addTab("General", general);
113 addTab("Node", nodePanel);
114 addTab("Type", typePanel);
115
116 pack();
117
118 setSize( new Dimension( 500, getSize().height));
119 setLocationRelativeTo(parent);
120 }
121
122 public void setElement( Element element) {
123 setTitle(element.getNodeName()+" - Element Details");
124 nodePanel.setNode(element);
125 typePanel.setType( element.getType());
126
127 srcField.setText(element.getSrc());
128 srcField.setCaretPosition(0);
129 classField.setText(element.getClazz());
130 classField.setCaretPosition(0);
131 pathField.setText( element.getPath());
132 pathField.setCaretPosition(0);
133
134 tagNameField.setText( element.getTagName());
135 tagNameField.setCaretPosition(0);
136
137 contextPane.setText(element.getContext());
138 contextPane.setCaretPosition(0);
139 }
140
141 @Override
142 protected String getBaseHelpID() {
143 return "output.result.element";
144 }
145 }