001/* ---------------------------------------------------------------------------- 002 The Kiwi Toolkit - A Java Class Library 003 Copyright (C) 1998-2004 Mark A. Lindner 004 005 This library is free software; you can redistribute it and/or 006 modify it under the terms of the GNU General Public License as 007 published by the Free Software Foundation; either version 2 of the 008 License, or (at your option) any later version. 009 010 This library is distributed in the hope that it will be useful, 011 but WITHOUT ANY WARRANTY; without even the implied warranty of 012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 General Public License for more details. 014 015 You should have received a copy of the GNU General Public License 016 along with this library; if not, write to the Free Software 017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 018 02111-1307, USA. 019 020 The author may be contacted at: mark_a_lindner@yahoo.com 021 ---------------------------------------------------------------------------- 022 $Log: DocumentBrowserFrame.java,v $ 023 Revision 1.10 2004/05/31 07:48:58 markl 024 rewritten to use new kiwi.ui.model package. 025 026 Revision 1.9 2004/03/16 06:43:39 markl 027 LocaleManager method change 028 029 Revision 1.8 2003/01/19 09:50:53 markl 030 Javadoc & comment header updates. 031 032 Revision 1.7 2001/06/26 06:17:15 markl 033 Updated with new LocaleManager API. 034 035 Revision 1.6 2001/03/12 09:56:54 markl 036 KLabel/KLabelArea changes. 037 038 Revision 1.5 2001/03/12 09:27:54 markl 039 Source code and Javadoc cleanup. 040 041 Revision 1.4 2000/07/15 02:18:37 markl 042 Fixed typo. 043 044 Revision 1.3 1999/04/19 05:59:19 markl 045 I18N changes. 046 047 Revision 1.2 1999/01/10 02:05:37 markl 048 added GPL header & RCS tag 049 ---------------------------------------------------------------------------- 050*/ 051 052package kiwi.ui; 053 054import java.awt.*; 055import java.awt.event.*; 056import java.net.URL; 057import javax.swing.*; 058import javax.swing.border.EmptyBorder; 059 060import kiwi.ui.model.*; 061import kiwi.util.*; 062 063/** This class represents a document browser window. It displays a 064 * <code>DocumentBrowserView</code> in a dedicated frame and handles all 065 * window-related events. 066 * 067 * <p><center> 068 * <img src="snapshot/DocumentBrowserFrame.gif"><br> 069 * <i>An example DocumentBrowserFrame.</i> 070 * </center> 071 * 072 * @author Mark Lindner 073 */ 074 075public class DocumentBrowserFrame extends KFrame 076 { 077 private KButton b_close; 078 private DocumentDataSource dataSource; 079 private DocumentBrowserView browser; 080 081 /** Construct a new <code>DocumentBrowserFrame</code>. 082 * 083 * @param title The window title. 084 * @param comment A comment string for the top portion of the window. 085 * @param dataSource The data source for the browser. 086 */ 087 088 public DocumentBrowserFrame(String title, String comment, 089 DocumentDataSource dataSource) 090 { 091 super(title); 092 093 this.dataSource = dataSource; 094 095 LocaleData loc = LocaleManager.getDefault().getLocaleData("KiwiDialogs"); 096 097 KPanel panel = getMainContainer(); 098 099 panel.setBorder(KiwiUtils.defaultBorder); 100 panel.setLayout(new BorderLayout(5, 5)); 101 102 KLabel l = new KLabel(comment); 103 panel.add("North", l); 104 105 ExternalKTreeModel model = new ExternalKTreeModel(dataSource); 106 panel.add("Center", browser = new DocumentBrowserView(model)); 107 108 ButtonPanel buttons = new ButtonPanel(); 109 110 b_close = new KButton(loc.getMessage("kiwi.button.close")); 111 b_close.addActionListener(new ActionListener() 112 { 113 public void actionPerformed(ActionEvent evt) 114 { 115 _hide(); 116 } 117 }); 118 buttons.addButton(b_close); 119 120 panel.add("South", buttons); 121 122 addWindowListener(new WindowAdapter() 123 { 124 public void windowClosing(WindowEvent evt) 125 { 126 _hide(); 127 } 128 }); 129 130 pack(); 131 } 132 133 /* hide the window */ 134 135 private void _hide() 136 { 137 setVisible(false); 138 dispose(); 139 } 140 141 } 142 143/* end of source file */