01: /*
02: The contents of this file are subject to the Mozilla Public License Version 1.1
03: (the "License"); you may not use this file except in compliance with the License.
04: You may obtain a copy of the License at http://www.mozilla.org/MPL/
05:
06: Software distributed under the License is distributed on an "AS IS" basis,
07: WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
08: for the specific language governing rights and limitations under the License.
09:
10: The Original Code is "The Columba Project"
11:
12: The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13: Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14:
15: All Rights Reserved.
16: */
17:
18: package org.columba.core.gui.scripting;
19:
20: import java.awt.BorderLayout;
21: import java.awt.Dialog;
22: import java.awt.FlowLayout;
23: import java.awt.event.ActionEvent;
24: import java.awt.event.ActionListener;
25:
26: import javax.swing.BorderFactory;
27: import javax.swing.JDialog;
28: import javax.swing.JLabel;
29: import javax.swing.JPanel;
30: import javax.swing.JScrollPane;
31: import javax.swing.JTextArea;
32:
33: import org.columba.core.gui.base.ButtonWithMnemonic;
34: import org.columba.core.scripting.ScriptLogger;
35:
36: /**
37: @author Celso Pinto <cpinto@yimports.com> */
38: public class MessageDetailsDialog extends JDialog implements
39: ActionListener {
40: private static final String RES_TITLE = "Log message details",
41: RES_CLOSE = "&Close";
42:
43: public MessageDetailsDialog(Dialog owner,
44: ScriptLogger.LogEntry logEntry) {
45: super (owner, RES_TITLE, true);
46: init(logEntry);
47:
48: setLocationRelativeTo(getParent());
49:
50: }
51:
52: private void init(ScriptLogger.LogEntry logEntry) {
53:
54: JPanel main = new JPanel(new BorderLayout(10, 10)), centerPanel = new JPanel(
55: new BorderLayout(10, 5)), buttonPanel = new JPanel(
56: new FlowLayout(FlowLayout.RIGHT));
57:
58: JLabel messageLabel = new JLabel(logEntry.getMessage());
59:
60: JScrollPane scroll = new JScrollPane(
61: JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
62: JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
63:
64: JTextArea detailsField = new JTextArea(logEntry.getDetails(),
65: 5, 40);
66: ButtonWithMnemonic closeButton = new ButtonWithMnemonic(
67: RES_CLOSE);
68:
69: detailsField.setLineWrap(true);
70: detailsField.setWrapStyleWord(true);
71:
72: scroll.getViewport().add(detailsField);
73:
74: centerPanel.add(messageLabel, BorderLayout.NORTH);
75: centerPanel.add(scroll, BorderLayout.CENTER);
76:
77: closeButton.addActionListener(this );
78: buttonPanel.add(closeButton);
79:
80: main.add(buttonPanel, BorderLayout.SOUTH);
81: main.add(centerPanel, BorderLayout.CENTER);
82: main.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
83:
84: setLayout(new BorderLayout());
85: add(main, BorderLayout.CENTER);
86: pack();
87: }
88:
89: public void actionPerformed(ActionEvent e) {
90: setVisible(false);
91: dispose();
92: }
93:
94: }
|