01: package org.dbbrowser;
02:
03: import java.io.File;
04: import java.io.FileInputStream;
05: import java.io.IOException;
06: import org.dbbrowser.ui.ConnectionInformationWindow;
07: import infrastructure.internationalization.InternationalizationManager;
08: import infrastructure.logging.Log;
09: import infrastructure.lookandfeel.LookAndFeelHandler;
10: import infrastructure.propertymanager.PropertyManagementException;
11: import infrastructure.propertymanager.PropertyManager;
12:
13: public class DBBrowser {
14: public static void main(String[] args) {
15: (new DBBrowser()).run();
16: }
17:
18: /**
19: * Starts the DBBrowser. Does the following:<br />
20: * 1. Initialize the property manager<br />
21: * 2. Initialize the logger<br />
22: * 3. Initialize the Message Bundle for internationalization<br />
23: * 4. Set the default look and feel. Gets the look and feel from the property file<br />
24: * 6. Show the connection info window<br />
25: */
26: public void run() {
27: System.out.println("Starting DBBrowser...");
28:
29: //1. Initialize the property manager
30: try {
31: PropertyManager.getInstance().initializeProperties(
32: new File("src/properties/db browser.properties"));
33: } catch (PropertyManagementException exc) {
34: System.err
35: .println("PropertyManager property file not found at location - src/properties/db browser.properties");
36: System.exit(-1);
37: }
38:
39: //2. Initialize the log manager
40: String log4jPropertyFilename = PropertyManager.getInstance()
41: .getProperty("dbbrowser-log4j-properties-file");
42: Log.getInstance().initialize(log4jPropertyFilename);
43: Log.getInstance().debugMessage("Logging has been initialized",
44: DBBrowser.class.getName());
45:
46: //3. Initialize the Message Bundle for internationalization
47: String pathForMessageResourceBundle = PropertyManager
48: .getInstance().getProperty("dbbrowser-i18n-properties");
49: try {
50: InternationalizationManager.getInstance()
51: .initializeInternationalizationManager(
52: new FileInputStream(
53: pathForMessageResourceBundle));
54: } catch (IOException exc) {
55: System.err
56: .println("Message resource bundle not found at location - "
57: + pathForMessageResourceBundle
58: + ", "
59: + exc.getMessage());
60: System.exit(-2);
61: }
62:
63: //4. Set the default look and feel
64: LookAndFeelHandler.getInstance()
65: .setThemepackInstallationDirectory("lib");
66: LookAndFeelHandler.getInstance().setLookAndFeel(
67: PropertyManager.getInstance().getProperty(
68: "dbbrowser.ui.lookandfeel"));
69: Log.getInstance().debugMessage(
70: "Using "
71: + LookAndFeelHandler.getInstance()
72: .getCurrentLookAndFeel()
73: + " look and feel", DBBrowser.class.getName());
74:
75: //5. Show the connection information window
76: ConnectionInformationWindow connectionInformationWindow = new ConnectionInformationWindow();
77: connectionInformationWindow.show();
78: }
79: }
|