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.text.PlainDocument;
35
36 import org.bounce.FormLayout;
37 import org.bounce.text.LineNumberMargin;
38 import org.bounce.text.ScrollableEditorPanel;
39 import org.bounce.text.xml.XMLEditorKit;
40 import org.xmlhammer.model.project.Attribute;
41
42 class AttributeDetailsDialog extends DetailsDialog {
43 private static final long serialVersionUID = 6396657641170177743L;
44
45 private NodePanel nodePanel = null;
46 private TypePanel typePanel = null;
47
48 private JTextField srcField = null;
49 private JTextField classField = null;
50 private JTextField nameField = null;
51 private JTextField valueField = null;
52 private JTextField pathField = null;
53
54 private CheckLabel specifiedField = null;
55 private CheckLabel idField = null;
56
57 private JEditorPane contextPane = null;
58
59 AttributeDetailsDialog(JFrame parent) {
60 super(parent, "Attribute 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 specifiedField = new CheckLabel("Specified");
85 form.add(new JLabel(), LABEL_CONSTRAINTS);
86 form.add(specifiedField, FormLayout.RIGHT);
87
88 idField = new CheckLabel("ID");
89 form.add(new JLabel(), LABEL_CONSTRAINTS);
90 form.add(idField, FormLayout.RIGHT);
91
92 nameField = new JTextField();
93 nameField.setEditable(false);
94 form.add(new JLabel("Name:"), LABEL_CONSTRAINTS);
95 form.add(nameField, FormLayout.RIGHT_FILL);
96
97 valueField = new JTextField();
98 valueField.setEditable(false);
99 form.add(new JLabel("Value:"), LABEL_CONSTRAINTS);
100 form.add(valueField, FormLayout.RIGHT_FILL);
101
102 form.add(Box.createVerticalStrut(10), FormLayout.FULL);
103
104 form.add(new JLabel("Context:"), FormLayout.FULL);
105
106 nodePanel = new NodePanel();
107 typePanel = new TypePanel();
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 JScrollPane 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 addTab("Type", typePanel);
127
128 pack();
129
130 setSize(new Dimension( 500, getSize().height));
131 setLocationRelativeTo(parent);
132 }
133
134 public void setAttribute( Attribute attribute) {
135 setTitle(attribute.getNodeName()+" - Attribute Details");
136 nodePanel.setNode(attribute);
137 typePanel.setType( attribute.getType());
138
139 srcField.setText(attribute.getSrc());
140 srcField.setCaretPosition(0);
141 classField.setText(attribute.getClazz());
142 classField.setCaretPosition(0);
143 pathField.setText( attribute.getPath());
144 pathField.setCaretPosition(0);
145 specifiedField.setSelected(attribute.isSpecified());
146 idField.setSelected(attribute.isId());
147
148 nameField.setText( attribute.getName());
149 nameField.setCaretPosition(0);
150 valueField.setText( attribute.getValue());
151 valueField.setCaretPosition(0);
152
153 contextPane.setText(attribute.getContext());
154 contextPane.setCaretPosition(0);
155 }
156
157 @Override
158 protected String getBaseHelpID() {
159 return "output.result.attribute";
160 }
161 }