1 package org.xmlhammer.gui.output;
2
3 import javax.swing.JLabel;
4 import javax.swing.JPanel;
5 import javax.swing.JTextField;
6
7 import org.bounce.FormConstraints;
8 import org.bounce.FormLayout;
9 import org.xmlhammer.model.project.Type;
10
11 public class CharacterDataPanel extends JPanel {
12
13 private static final long serialVersionUID = -845135182604250202L;
14
15 private static final FormConstraints LABEL_CONSTRAINTS = new FormConstraints(FormConstraints.LEFT, FormConstraints.RIGHT, FormConstraints.TOP);
16
17 private JTextField namespaceField = null;
18 private JTextField nameField = null;
19
20 public CharacterDataPanel() {
21 super( new FormLayout(5,5));
22
23 nameField = new JTextField();
24 nameField.setEditable(false);
25 add(new JLabel("Name:"), LABEL_CONSTRAINTS);
26 add(nameField, FormLayout.RIGHT_FILL);
27
28 namespaceField = new JTextField();
29 namespaceField.setEditable(false);
30 add(new JLabel("Namespace:"), LABEL_CONSTRAINTS);
31 add(namespaceField, FormLayout.RIGHT_FILL);
32 }
33
34 public void setType( Type type) {
35 if (type != null) {
36 namespaceField.setText(type.getNamespace());
37 nameField.setText(type.getName());
38 } else {
39 namespaceField.setText("");
40 nameField.setText("");
41 }
42
43 nameField.setCaretPosition(0);
44 namespaceField.setCaretPosition(0);
45 }
46 }