View Javadoc

1   /*
2    * @(#)$Id: AboutDialog.java 689 2009-07-22 00:10:27Z bsigner $
3    *
4    * Author       :   Ueli Kurmann, igesture@uelikurmann.ch
5    *
6    * Purpose      :   About dialog.
7    *
8    * -----------------------------------------------------------------------
9    *
10   * Revision Information:
11   *
12   * Date             Who         Reason
13   *
14   * Feb 01, 2007     ukurmann    Initial Release
15   * Mar 24, 2007     bsigner     Cleanup
16   *
17   * -----------------------------------------------------------------------
18   *
19   * Copyright 1999-2009 ETH Zurich. All Rights Reserved.
20   *
21   * This software is the proprietary information of ETH Zurich.
22   * Use is subject to license terms.
23   * 
24   */
25  
26  package org.ximtec.igesture.tool.view;
27  
28  import java.awt.BorderLayout;
29  import java.awt.Dimension;
30  import java.awt.event.MouseAdapter;
31  import java.awt.event.MouseEvent;
32  import java.net.URL;
33  import java.util.logging.Level;
34  import java.util.logging.Logger;
35  
36  import javax.swing.JButton;
37  import javax.swing.JPanel;
38  
39  import org.sigtec.graphix.GuiBundle;
40  import org.sigtec.graphix.widget.BasicDialog;
41  import org.ximtec.igesture.tool.util.HtmlPanel;
42  
43  /**
44   * About dialog.
45   * 
46   * @version 1.0 Feb 2007
47   * @author Ueli Kurmann, igesture@uelikurmann.ch
48   * @author Beat Signer, signer@inf.ethz.ch
49   */
50  public class AboutDialog extends BasicDialog {
51  
52  	private static final long serialVersionUID = -515194690000914377L;
53  
54  	private static final Logger LOGGER = Logger.getLogger(AboutDialog.class
55  			.getName());
56  
57  	/**
58  	 * The key used to retrieve dialog details from the resource bundle.
59  	 */
60  	public static final String KEY = "AboutDialog";
61  
62  	public static final String RESOURCE = "Resource";
63  
64  	/**
65  	 * Constructs a new AboutDialog without getting any information from a GUI
66  	 * bundle.
67  	 */
68  	public AboutDialog() {
69  		super();
70  	}
71  
72  	/**
73  	 * Constructs a new AboutDialog.
74  	 * 
75  	 * @param key
76  	 *            the key to be used for the lookup of information in the GUI
77  	 *            bundle.
78  	 * @param guiBundle
79  	 *            the GUI bundle to be used to create the about dialog.
80  	 */
81  	public AboutDialog(String key, GuiBundle guiBundle) {
82  		super(key, guiBundle);
83  	}
84  
85  	/**
86  	 * Initialises the dialogue.
87  	 * 
88  	 * @param key
89  	 *            the key to be used for the lookup of dialogue information in
90  	 *            the GUI bundle.
91  	 * @param guiBundle
92  	 *            the GUI bundle to be used to create the dialogue.
93  	 */
94  	protected void init(String key, GuiBundle guiBundle) {
95  		LOGGER.log(Level.FINER, "Init About Dialog");
96  		super.init(key, guiBundle);
97  		int width = guiBundle.getWidth(key);
98  		int height = guiBundle.getHeight(key);
99  
100 		setLayout(new BorderLayout());
101 
102 		String resource = guiBundle.getProperty(key, RESOURCE);
103 		URL path = AboutDialog.class.getClassLoader().getResource(resource);
104 
105 		Dimension dimension = new Dimension(width - 10, height - 50);
106 		HtmlPanel htmlPanel = new HtmlPanel(path, dimension);
107 
108 		add(htmlPanel, BorderLayout.CENTER);
109 
110 		// FIXME i18!
111 		JButton closeButton = new JButton("Close");
112 		closeButton.addMouseListener(new MouseAdapter() {
113 
114 			@Override
115 			public void mouseClicked(MouseEvent arg0) {
116 				super.mouseClicked(arg0);
117 				closeDialog();
118 			}
119 		});
120 		JPanel panel = new JPanel();
121 		panel.add(closeButton);
122 		add(panel, BorderLayout.SOUTH);
123 		pack();
124 	} // init
125 
126 	private void closeDialog() {
127 		setVisible(false);
128 		dispose();
129 	} // closeDialog
130 
131 }