001: /*
002: * The contents of this file are subject to the Mozilla Public License
003: * Version 1.1 (the "License"); you may not use this file except in
004: * compliance with the License. You may obtain a copy of the License at
005: * http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
009: * License for the specific language governing rights and limitations
010: * under the License.
011: *
012: * The Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
013: *
014: * The Initial Developer of the Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
015: * Portions created by Mark A. Kobold are Copyright (C) 2000-2007. All Rights Reserved.
016: *
017: * Contributor(s):
018: * Mark A. Kobold [mkobold <at> isqlviewer <dot> com].
019: *
020: * If you didn't download this code from the following link, you should check
021: * if you aren't using an obsolete version: http://www.isqlviewer.com
022: */
023: package org.isqlviewer.mrj;
024:
025: import java.awt.event.ActionEvent;
026: import java.io.File;
027: import java.io.FileNotFoundException;
028:
029: import javax.swing.UIManager;
030:
031: import org.isqlviewer.sql.embedded.EmbeddedDatabase;
032: import org.isqlviewer.swing.action.SharedActions;
033: import org.isqlviewer.swing.action.SwingEventManager;
034: import org.isqlviewer.ui.ApplicationFrame;
035: import org.isqlviewer.util.IsqlToolkit;
036:
037: import com.apple.eawt.Application;
038: import com.apple.eawt.ApplicationAdapter;
039: import com.apple.eawt.ApplicationEvent;
040: import com.apple.eio.FileManager;
041:
042: /**
043: * Launcher class for starting the iSQL-Viewer application on Mac OS X.
044: * <p>
045: *
046: * @author Mark A. Kobold <mkobold at isqlviewer dot com>
047: * @version 1.0
048: */
049: public class AquaLauncher extends ApplicationAdapter {
050:
051: public static final short kSystemDomain = -32766;
052: public static final short kLocalDomain = -32765;
053: public static final short kNetworkDomain = -32764;
054: public static final short kClassicDomain = -32762;
055: public static final short kUserDomain = -32763;
056:
057: private SwingEventManager eventManager = null;
058:
059: public AquaLauncher(SwingEventManager eventManager) {
060:
061: this .eventManager = eventManager;
062: }
063:
064: public static void main(String[] args) {
065:
066: String applicationSupport = null;
067: try {
068: short domain = Domain.USER.value();
069: int folderType = FolderType.APPLICATION_SUPPORT.value();
070: applicationSupport = FileManager.findFolder(domain,
071: folderType, true);
072: } catch (FileNotFoundException error) {
073: error.printStackTrace();
074: return;
075: }
076: File homeDirectory = new File(applicationSupport, "iSQL-Viewer");
077: homeDirectory.mkdirs();
078: System.setProperty(IsqlToolkit.PROPERTY_MRJ_ENABLED, "true");
079: System.setProperty(IsqlToolkit.PROPERTY_HOME, homeDirectory
080: .getAbsolutePath());
081: System.setProperty("apple.laf.useScreenMenuBar", "true");
082: System.setProperty(
083: "com.apple.mrj.application.apple.menu.about.name",
084: "iSQL-Viewer");
085: System.setProperty("com.apple.mrj.application.live-resize",
086: "true");
087:
088: Application appliactionInstance = Application.getApplication();
089: appliactionInstance.setEnabledAboutMenu(true);
090: appliactionInstance.setEnabledPreferencesMenu(false);
091: try {
092: UIManager.setLookAndFeel(UIManager
093: .getSystemLookAndFeelClassName());
094: } catch (Throwable error) {
095: error.printStackTrace();
096: return;
097: }
098: // ensure that the embedded database driver is available //
099: EmbeddedDatabase.getSharedInstance();
100: ApplicationFrame frame = new ApplicationFrame();
101: appliactionInstance.addApplicationListener(new AquaLauncher(
102: frame.getSwingEventManager()));
103: frame.setVisible(true);
104: }
105:
106: @Override
107: public void handleAbout(ApplicationEvent event) {
108:
109: }
110:
111: @Override
112: public void handleOpenApplication(ApplicationEvent event) {
113:
114: }
115:
116: @Override
117: public void handleOpenFile(ApplicationEvent event) {
118:
119: }
120:
121: @Override
122: public void handlePreferences(ApplicationEvent event) {
123:
124: }
125:
126: @Override
127: public void handlePrintFile(ApplicationEvent event) {
128:
129: }
130:
131: @Override
132: public void handleQuit(ApplicationEvent event) {
133:
134: ActionEvent action = new ActionEvent(event.getSource(),
135: SharedActions.EXIT_APPLICATION, "");
136: eventManager.actionPerformed(action);
137: }
138:
139: @Override
140: public void handleReOpenApplication(ApplicationEvent event) {
141:
142: }
143: }
|