01: /*
02: * WhatsNewViewer.java
03: *
04: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
05: *
06: * Copyright 2002-2008, Thomas Kellerer
07: * No part of this code maybe reused without the permission of the author
08: *
09: * To contact the author please send an email to: support@sql-workbench.net
10: *
11: */
12: package workbench.gui.help;
13:
14: import workbench.gui.components.SearchableTextPane;
15: import java.awt.BorderLayout;
16: import java.awt.event.WindowAdapter;
17: import java.awt.event.WindowEvent;
18: import java.net.URL;
19:
20: import javax.swing.JDialog;
21: import javax.swing.JScrollPane;
22:
23: import workbench.gui.WbSwingUtilities;
24: import workbench.log.LogMgr;
25: import workbench.resource.ResourceMgr;
26: import workbench.resource.Settings;
27:
28: public class WhatsNewViewer extends JDialog {
29: public WhatsNewViewer(java.awt.Frame owner) {
30: super (owner, false);
31: setTitle(ResourceMgr.getFormattedString(
32: "TxtWhatsNewWindowTitle", ResourceMgr.getBuildNumber()
33: .toString()));
34: SearchableTextPane display = new SearchableTextPane(this );
35: display.setFont(Settings.getInstance().getEditorFont());
36: display.setEditable(false);
37: JScrollPane scroll = new JScrollPane(display);
38:
39: getContentPane().setLayout(new BorderLayout());
40: getContentPane().add(scroll, BorderLayout.CENTER);
41:
42: if (!Settings.getInstance().restoreWindowSize(this )) {
43: setSize(800, 600);
44: }
45:
46: if (!Settings.getInstance().restoreWindowPosition(this )) {
47: WbSwingUtilities.center(this , owner);
48: }
49:
50: try {
51:
52: URL file = this .getClass().getClassLoader().getResource(
53: "help/history.txt");
54: if (file != null) {
55: display.setPage(file);
56: } else {
57: display
58: .setText("No history available! Please report this to support@sql-workbench.net");
59: }
60:
61: } catch (Exception e) {
62: LogMgr.logError("WhatsNewViewer.<init>",
63: "Error creating dialog", e);
64: }
65:
66: addWindowListener(new WindowAdapter() {
67: public void windowClosing(WindowEvent evt) {
68: saveSettings();
69: setVisible(false);
70: dispose();
71: }
72: });
73: }
74:
75: protected void saveSettings() {
76: Settings.getInstance().storeWindowPosition(this);
77: Settings.getInstance().storeWindowSize(this);
78: }
79:
80: }
|