View Javadoc

1   package org.xmlhammer.gui.output;
2   
3   import java.awt.BorderLayout;
4   import java.awt.Dimension;
5   
6   import javax.swing.Box;
7   import javax.swing.JLabel;
8   import javax.swing.JPanel;
9   import javax.swing.JScrollPane;
10  import javax.swing.JTextArea;
11  import javax.swing.JTextField;
12  
13  import org.bounce.FormLayout;
14  import org.xmlhammer.model.project.NodeType;
15  
16  public class NodePanel extends DetailsPanel {
17      private static final long serialVersionUID = 6396657641170177743L;
18      private static final Dimension EDITORPANE_SIZE = new Dimension( 100, 80);        
19  
20      private JTextField baseURIField = null;
21      private JTextField namespaceURIField = null;
22      private JTextField prefixField = null;
23      private JTextField localNameField = null;
24      private JTextField nodeNameField = null;
25      private JTextArea nodeValueField = null;
26      private JTextArea textContentField = null;
27  
28      public NodePanel() {
29          super( new FormLayout(5,5), "node");
30  
31          baseURIField = new JTextField();
32          baseURIField.setEditable(false);
33          add(new JLabel("Base URI:"), LABEL_CONSTRAINTS);
34          add(baseURIField, FormLayout.RIGHT_FILL);
35  
36          add(Box.createVerticalStrut(10), FormLayout.FULL);
37  
38          prefixField = new JTextField();
39          prefixField.setEditable(false);
40          add(new JLabel("Prefix:"), LABEL_CONSTRAINTS);
41          add(prefixField, FormLayout.RIGHT_FILL);
42  
43          namespaceURIField = new JTextField();
44          namespaceURIField.setEditable(false);
45          add(new JLabel("Namespace URI:"), LABEL_CONSTRAINTS);
46          add(namespaceURIField, FormLayout.RIGHT_FILL);
47          
48          add(Box.createVerticalStrut(10), FormLayout.FULL);
49  
50          localNameField = new JTextField();
51          localNameField.setEditable(false);
52          add(new JLabel("Local Name:"), LABEL_CONSTRAINTS);
53          add(localNameField, FormLayout.RIGHT_FILL);
54  
55          nodeNameField = new JTextField();
56          nodeNameField.setEditable(false);
57          add(new JLabel("Node Name:"), LABEL_CONSTRAINTS);
58          add(nodeNameField, FormLayout.RIGHT_FILL);
59  
60          nodeValueField = new JTextArea();
61          nodeValueField.setEditable(false);
62          nodeValueField.setLineWrap(false);
63          add(new JLabel("Node Value:"), LABEL_CONSTRAINTS);
64          
65          JPanel panel = new JPanel(new BorderLayout());
66          panel.add(nodeValueField, BorderLayout.CENTER);
67  
68          JScrollPane scroller = new JScrollPane( panel);
69          scroller.setPreferredSize(EDITORPANE_SIZE);
70          add(scroller, FormLayout.RIGHT_FILL);
71  
72          textContentField = new JTextArea();
73          textContentField.setEditable(false);
74          textContentField.setLineWrap(false);
75  //        textContentField.setPreferredSize( new Dimension(50, 50));
76          add(new JLabel("Text Content:"), LABEL_CONSTRAINTS);
77  
78          panel = new JPanel(new BorderLayout());
79          panel.add(textContentField, BorderLayout.CENTER);
80          scroller = new JScrollPane( panel);
81          scroller.setPreferredSize(EDITORPANE_SIZE);
82          add(scroller, FormLayout.RIGHT_FILL);
83      }
84  
85      public void setNode( NodeType node) {
86          baseURIField.setText(node.getBaseURI());
87          baseURIField.setCaretPosition(0);
88          prefixField.setText(node.getPrefix());
89          prefixField.setCaretPosition(0);
90          namespaceURIField.setText(node.getNamespaceURI());
91          namespaceURIField.setCaretPosition(0);
92          localNameField.setText(node.getLocalName());
93          localNameField.setCaretPosition(0);
94          nodeNameField.setText(node.getNodeName());
95          nodeNameField.setCaretPosition(0);
96          nodeValueField.setText(node.getNodeValue());
97          nodeValueField.setCaretPosition(0);
98          textContentField.setText(node.getTextContent());
99          textContentField.setCaretPosition(0);
100     }
101 }