View Javadoc
1 /*** 2 * LogDisplay.java 3 * 4 * Project: Dependency Tool 5 * 6 * WHEN WHO WHAT 7 * 06.06.2003 pko initial public release 8 * 10.12.2002 pko creation 9 * 10 * Copyright 2003 ELCA Informatique SA 11 * Av. de la Harpe 22-24, 1000 Lausanne 13, Switzerland 12 * www.elca.ch 13 * 14 * This library is free software; you can redistribute it and/or 15 * modify it under the terms of the GNU Lesser General Public License 16 * as published by the Free Software Foundation; either version 2.1 of 17 * the License, or (at your option) any later version. 18 * 19 * This library is distributed in the hope that it will be useful, but 20 * WITHOUT ANY WARRANTY; without even the implied warranty of 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 * Lesser General Public License for more details. 23 * 24 * You should have received a copy of the GNU Lesser General Public 25 * License along with this library; if not, write to the Free Software 26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 27 * USA 28 */ 29 30 package ch.elca.dependency.gui; 31 32 import java.awt.BorderLayout; 33 import java.awt.Container; 34 import java.awt.Toolkit; 35 import javax.swing.*; 36 37 import org.apache.commons.lang.StringUtils; 38 39 /*** 40 * <code>LogDisplay</code> used to display log messages within the DependencyTool GUI. 41 * 42 * @author Pawel Kowalski 43 * @version 1.0-beta 44 */ 45 public class LogDisplay extends JInternalFrame { 46 47 private static final String LOG_FRAME_NAME = "Log display"; 48 private static final boolean RESIZABLE = true; 49 private static final boolean CLOSEABLE = false; 50 private static final boolean MAXIMIZABLE = false; 51 private static final boolean ICONIFIABLE = true; 52 private static final int s_frameWidth = 800; 53 private static final int s_frameHeight = 100; 54 private JTextArea m_textArea = null; 55 private static LogDisplay s_instance = null; 56 57 /*** 58 * Get a created LogDisplay or create one in case it's the first such request. 59 * 60 * @return a <code>LogDisplay</code> value 61 */ 62 public static synchronized LogDisplay getLogDisplay() { 63 if (s_instance == null) { 64 s_instance = new LogDisplay(); 65 } 66 return s_instance; 67 } 68 69 /*** 70 * Creates a new <code>LogDisplay</code> instance. 71 * 72 */ 73 public LogDisplay() { 74 super(LOG_FRAME_NAME, RESIZABLE, CLOSEABLE, MAXIMIZABLE, ICONIFIABLE); 75 initFrame(); 76 setContentPane(makeGUI()); 77 } 78 79 /*** 80 * Init frame. 81 */ 82 private void initFrame() { 83 84 setSize(s_frameWidth, s_frameHeight); 85 86 Toolkit tollkit = Toolkit.getDefaultToolkit(); 87 int screenWidth = tollkit.getScreenSize().width; 88 int screenHeight = tollkit.getScreenSize().height; 89 90 setLocation(((screenWidth - s_frameWidth) / 2), 91 ((screenHeight - s_frameHeight) / 10) * 9); 92 93 } 94 95 /*** 96 * Make the GUI of this LogDisplay. 97 * 98 * @return a <code>Container</code> value 99 */ 100 private Container makeGUI() { 101 102 JPanel contentPane = new JPanel(); 103 contentPane.setLayout(new BorderLayout()); 104 105 m_textArea = new JTextArea(); 106 m_textArea.setEditable(false); 107 JScrollPane m_scrollPane = new JScrollPane(m_textArea); 108 contentPane.add(m_scrollPane, BorderLayout.CENTER); 109 return contentPane; 110 } 111 112 /*** 113 * Append a log-message to this LogDisplay. 114 * 115 * @param message a <code>String</code> value 116 */ 117 public void append(String message) { 118 m_textArea.append(StringUtils.chopNewline(message) + "\n"); 119 } 120 }

This page was automatically generated by Maven