source: gli/trunk/src/org/greenstone/gatherer/gui/AboutDialog.java@ 20957

Last change on this file since 20957 was 18370, checked in by kjdon, 15 years ago

committed code submitted by Amin Hedjazi for making the GLI right to left. I worked on this code on the rtl-gli branch, then merged the branch back to the trunk at revision 18368. The branch code was slightly different in a couple of places where it shouldn't have been. So don't use the branch code next time. Start a new branch.

  • Property svn:keywords set to Author Date Id Revision
File size: 7.9 KB
RevLine 
[5032]1/**
2 *#########################################################################
3 *
[6382]4 * A component of the Greenstone Librarian Interface (GLI) application,
5 * part of the Greenstone digital library software suite from the New
6 * Zealand Digital Library Project at the University of Waikato,
7 * New Zealand.
[5032]8 *
[6382]9 * Author: John Thompson
10 * Greenstone Project, New Zealand Digital Library
11 * University of Waikato
12 * http://www.nzdl.org
[5032]13 *
[6382]14 * Copyright (C) 2004 New Zealand Digital Library, University of Waikato
[5032]15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 *########################################################################
30 */
[5589]31package org.greenstone.gatherer.gui;
32
[5032]33import java.awt.*;
34import java.awt.event.*;
35import javax.swing.*;
[17916]36
37import org.greenstone.gatherer.Configuration;
[5032]38import org.greenstone.gatherer.Dictionary;
[11624]39import org.greenstone.gatherer.Gatherer;
[10011]40import org.greenstone.gatherer.util.JarTools;
[5032]41import org.greenstone.gatherer.util.Utility;
[5589]42
[6382]43/** Generates a pretty about dialog which not only thanks those for their contributions but also meets our legal requirements if we wish to ship the JVM with GLI.
44 * @author John Thompson, Greenstone Project, New Zealand Digital Library, University of Waikato
45 * @version 2.41 final
[5032]46 */
47// RICOH SOURCE CODE PUBLIC LICENSE - http://www.risource.org/RPL/RPL-1.0A.shtml
48public class AboutDialog
49 extends JDialog {
[6382]50 /** The default size of the about dialog. */
51 static final private Dimension SIZE = new Dimension(600, 325);
52 /** The size of the GLI icon to display on dialog. */
53 static final private int ICON_SIZE = 65;
54 /** A reference to ourself so that our inner classes can dismiss us. */
[5032]55 private AboutDialog self;
[6382]56 /** The button used for dismissing the about dialog. */
[5032]57 private JButton close_button;
[6382]58 /** The constructor not only builds, but displays the about dialog. This method doesn't return until the dialog is dismissed.
59 * @param parent the JFrame which owns this dialog for use in centering the dialog
60 * @see org.greenstone.gatherer.Dictionary#get
61 * @see org.greenstone.gatherer.Dictionary#setBoth
62 * @see org.greenstone.gatherer.Dictionary#setText
63 * @see org.greenstone.gatherer.gui.AboutDialog.CloseButtonListener
64 * @see org.greenstone.gatherer.gui.GLIButton
65 */
[5032]66 public AboutDialog(JFrame parent) {
[5593]67 super(parent, Dictionary.get("AboutDialog.Title"), true);
[5032]68 this.self = this;
69 setSize(SIZE);
[18370]70 this.setComponentOrientation(Dictionary.getOrientation());
[5032]71 JPanel content_pane = (JPanel) getContentPane();
[18370]72 content_pane.setComponentOrientation(Dictionary.getOrientation());
73
[5032]74 JPanel upper_pane = new JPanel();
[18370]75 upper_pane.setComponentOrientation(Dictionary.getOrientation());
76
[17916]77 String gmedium_image = "gatherer_medium.gif";
78 if (Configuration.fedora_info.isActive()) {
79 gmedium_image = "fli-" + gmedium_image;
80 }
81
82 ImageIcon icon = JarTools.getImage(gmedium_image);
[5032]83 ImageIcon scaled_icon = new ImageIcon(icon.getImage().getScaledInstance(ICON_SIZE, ICON_SIZE, Image.SCALE_DEFAULT));
84 JLabel icon_label = new JLabel(scaled_icon);
[18370]85 icon_label.setComponentOrientation(Dictionary.getOrientation());
86
87 JPanel title_pane = new JPanel();
88 title_pane.setComponentOrientation(Dictionary.getOrientation());
89
90 JLabel title_one_label = new JLabel(Dictionary.get("AboutDialog.Title_One"));
91 title_one_label.setComponentOrientation(Dictionary.getOrientation());
92 JLabel title_two_label = new JLabel(Gatherer.PROGRAM_NAME + " " + Gatherer.PROGRAM_VERSION + " " + Dictionary.get("AboutDialog.Date"));
93 title_two_label.setComponentOrientation(Dictionary.getOrientation());
94 JLabel title_three_label = new JLabel(Dictionary.get("AboutDialog.Title_Two"));
95 title_three_label.setComponentOrientation(Dictionary.getOrientation());
96 JLabel copyright_label = new JLabel(Dictionary.get("AboutDialog.Copyright"));
97 copyright_label.setComponentOrientation(Dictionary.getOrientation());
98 JLabel gpl_label = new JLabel(Dictionary.get("AboutDialog.Copyright_Two"));
99 gpl_label.setComponentOrientation(Dictionary.getOrientation());
100
[5032]101 JTextArea text = new JTextArea();
[18370]102 text.setComponentOrientation(Dictionary.getOrientation());
[5032]103 text.setLineWrap(true);
104 text.setWrapStyleWord(true);
[18370]105
106
[5032]107 JPanel button_pane = new JPanel();
[18370]108 button_pane.setComponentOrientation(Dictionary.getOrientation());
[12119]109 close_button = new GLIButton(Dictionary.get("General.Close"), Dictionary.get("General.Close_Tooltip"));
110
[5032]111 // Connection
112 close_button.addActionListener(new CloseButtonListener());
113
114 // Layout
115 icon_label.setBorder(BorderFactory.createEmptyBorder(0,0,0,10));
116
[6206]117 title_pane.setLayout(new GridLayout(5,1,0,2));
[5032]118 title_pane.add(title_one_label);
119 title_pane.add(title_two_label);
120 title_pane.add(title_three_label);
121 title_pane.add(copyright_label);
[6206]122 title_pane.add(gpl_label);
[5032]123
124 upper_pane.setBorder(BorderFactory.createEmptyBorder(0,0,5,0));
125 upper_pane.setLayout(new BorderLayout());
[18370]126 upper_pane.add(icon_label, BorderLayout.LINE_START);
[5032]127 upper_pane.add(title_pane, BorderLayout.CENTER);
128
129 button_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
130 button_pane.setLayout(new BorderLayout());
[18370]131 button_pane.add(close_button, BorderLayout.LINE_END);
[5032]132
133 content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
134 content_pane.setLayout(new BorderLayout());
135 content_pane.add(upper_pane, BorderLayout.NORTH);
136 content_pane.add(new JScrollPane(text), BorderLayout.CENTER);
137 content_pane.add(button_pane, BorderLayout.SOUTH);
[5589]138
[5032]139 // Build text content
[5593]140 text.append(Dictionary.get("AboutDialog.Java_Req"));
[5032]141 text.append("\n");
[5593]142 text.append(Dictionary.get("AboutDialog.Java_Req_One"));
[5032]143 text.append("\n");
[5593]144 text.append(Dictionary.get("AboutDialog.Java_Req_Two"));
[5032]145 text.append("\n\n");
[5593]146 text.append("*****" + Dictionary.get("AboutDialog.Acknowledgement") + "*****");
[5032]147 text.append("\n\n");
[5593]148 text.append(Dictionary.get("AboutDialog.Item0"));
[5032]149 text.append("\n\n");
[5593]150 text.append(Dictionary.get("AboutDialog.Item2"));
[5032]151 text.append("\n\n");
[5593]152 text.append(Dictionary.get("AboutDialog.Item3"));
[5032]153 text.append("\n\n");
[5593]154 text.append("*****" + Dictionary.get("AboutDialog.Thanks") + "*****");
[5032]155 text.append("\n\n");
[5593]156 text.append(Dictionary.get("AboutDialog.Item4"));
[5032]157 text.append("\n\n");
[5593]158 text.append(Dictionary.get("AboutDialog.Item5"));
[5032]159 text.append("\n\n");
[5593]160 text.append(Dictionary.get("AboutDialog.Item6"));
[5032]161 text.append("\n\n");
[5593]162 text.append(Dictionary.get("AboutDialog.Item7"));
[5343]163 text.append("\n\n");
[5593]164 text.append(Dictionary.get("AboutDialog.Item8"));
[14775]165 text.append("\n\n");
166 text.append(Dictionary.get("AboutDialog.Item9"));
167 text.append("\n\n");
[5032]168 text.setCaretPosition(0);
169
170 // Show
171 Rectangle frame_bounds = parent.getBounds();
172 setLocation(frame_bounds.x + (frame_bounds.width - SIZE.width) / 2, frame_bounds.y + (frame_bounds.height - SIZE.height) / 2);
[8474]173 setVisible(true);
[5032]174 }
[6382]175 /** Listens for actions upon the close button, and when detected closes the dialog. */
[5032]176 private class CloseButtonListener
177 implements ActionListener {
[6382]178 /** Called whenever an action occurs on the close button, thus asking the dialog to close.
179 * @param event an ActionEvent containing information about the button press
180 */
[5032]181 public void actionPerformed(ActionEvent event) {
[8474]182 self.setVisible(false);
[5032]183 self.dispose();
184 }
185 }
186}
Note: See TracBrowser for help on using the repository browser.