View Javadoc

1   /*
2    * $Id$
3    *
4    * The contents of this file are subject to the Mozilla Public License 
5    * Version 1.1 (the "License"); you may not use this file except in 
6    * compliance with the License. You may obtain a copy of the License at 
7    * http://www.mozilla.org/MPL/ 
8    *
9    * Software distributed under the License is distributed on an "AS IS" basis, 
10   * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
11   * for the specific language governing rights and limitations under the License.
12   *
13   * The Original Code is XML Hammer code. (org.xmlhammer.*)
14   *
15   * The Initial Developer of the Original Code is Edwin Dankert. Portions created 
16   * by the Initial Developer are Copyright (C) 2005 - 2006 the Initial Developer. 
17   * All Rights Reserved.
18   *
19   * Contributor(s): Edwin Dankert <edankert@gmail.com>
20   */
21  package org.xmlhammer.gui.output;
22  
23  import java.awt.BorderLayout;
24  import java.awt.Dimension;
25  
26  import javax.swing.JFrame;
27  import javax.swing.JLabel;
28  import javax.swing.JPanel;
29  import javax.swing.JScrollPane;
30  import javax.swing.JTextArea;
31  import javax.swing.JTextField;
32  
33  import org.bounce.FormLayout;
34  import org.xmlhammer.model.project.Message;
35  
36  class MessageDetailsDialog extends DetailsDialog {
37      private static final long serialVersionUID = 6396657641170177743L;
38      private static final Dimension EDITORPANE_SIZE = new Dimension( 100, 80);        
39      
40      private JTextField srcField = null;
41      private JTextField typeField = null;
42      
43      private JTextArea valueField = null;
44      
45      MessageDetailsDialog(JFrame parent) {
46          super(parent, "Message Details");
47          
48          DetailsPanel general = new DetailsPanel(new BorderLayout(), "message");
49          JPanel form = new JPanel(new FormLayout(5, 5));
50  
51          srcField = new JTextField();
52          srcField.setEditable(false);
53          form.add(new JLabel("URI:"), LABEL_CONSTRAINTS);
54          form.add(srcField, FormLayout.RIGHT_FILL);
55  
56          typeField = new JTextField();
57          typeField.setEditable(false);
58          form.add(new JLabel("Type:"), LABEL_CONSTRAINTS);
59          form.add(typeField, FormLayout.RIGHT_FILL);
60  
61          valueField = new JTextArea();
62          valueField.setEditable(false);
63          valueField.setLineWrap(false);
64          form.add(new JLabel("Value:"), LABEL_CONSTRAINTS);
65          form.add(new JLabel(), FormLayout.RIGHT_FILL);
66          
67          JPanel panel = new JPanel(new BorderLayout());
68          panel.add(valueField, BorderLayout.CENTER);
69  
70          JScrollPane scroller = new JScrollPane( panel);
71          scroller.setPreferredSize(EDITORPANE_SIZE);
72  
73          general.add(form, BorderLayout.NORTH);
74          general.add(scroller, BorderLayout.CENTER);
75  
76          addTab("General", general);
77          
78          pack();
79          
80          setSize( new Dimension( 500, getSize().height));
81          setLocationRelativeTo(parent);
82      }
83      
84      public void setMessage(Message message) {
85          setTitle("Message Details");
86  
87          srcField.setText(message.getSrc());
88          srcField.setCaretPosition(0);
89          if ( "err".equals(message.getType())) {
90              typeField.setText("System.err");
91          } else {
92              typeField.setText("System.out");
93          }
94          
95          typeField.setCaretPosition(0);
96  
97          valueField.setText(message.getValue());
98          valueField.setCaretPosition(0);
99      }
100 
101     @Override
102     protected String getBaseHelpID() {
103         return "output";
104     }
105 }