Source Code Cross Referenced for Application.java in  » Database-Client » sqleonardo » nickyb » sqleonardo » environment » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database Client » sqleonardo » nickyb.sqleonardo.environment 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * SQLeonardo :: java database frontend
003:         * Copyright (C) 2004 nickyb@users.sourceforge.net
004:         * 
005:         * This program is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU General Public License
007:         * as published by the Free Software Foundation; either version 2
008:         * of the License, or (at your option) any later version.
009:         * 
010:         * This program is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013:         * GNU General Public License for more details.
014:         * 
015:         * You should have received a copy of the GNU General Public License
016:         * along with this program; if not, write to the Free Software
017:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
018:         *
019:         */
020:
021:        package nickyb.sqleonardo.environment;
022:
023:        import java.awt.datatransfer.Clipboard;
024:        import java.awt.datatransfer.ClipboardOwner;
025:        import java.awt.datatransfer.Transferable;
026:        import java.io.File;
027:        import java.io.IOException;
028:        import java.util.Locale;
029:
030:        import javax.swing.JLabel;
031:        import javax.swing.JOptionPane;
032:        import javax.swing.JWindow;
033:
034:        import nickyb.sqleonardo.common.util.Appearance;
035:        import nickyb.sqleonardo.common.util.I18n;
036:        import nickyb.sqleonardo.common.util.Resources;
037:        import nickyb.sqleonardo.common.util.Store;
038:        import nickyb.sqleonardo.common.util.Text;
039:        import nickyb.sqleonardo.environment.mdi.ClientMetadataExplorer;
040:        import nickyb.sqleonardo.environment.mdi.MDIWindow;
041:
042:        public class Application extends Appearance implements  _Constants,
043:                _Version {
044:            public static final ClipboardOwner defaultClipboardOwner;
045:
046:            static {
047:                defaultClipboardOwner = new ClipboardOwner() {
048:                    public void lostOwnership(Clipboard clipboard,
049:                            Transferable contents) {
050:                    }
051:                };
052:            }
053:
054:            public static MDIWindow window = null;
055:
056:            public static final Store session = new Store();
057:            public static final Resources resources = new Resources();
058:
059:            private static void loadIcons() {
060:                resources.loadIcon(ICON_CONNECT, "/images/connect.png");
061:                resources.loadIcon(ICON_DISCONNECT, "/images/disconnect.png");
062:
063:                resources.loadIcon(ICON_SAVE, "/images/disk.png");
064:                resources.loadIcon(ICON_STOP, "/images/stop.png");
065:                resources.loadIcon(ICON_FIND, "/images/find.png");
066:
067:                resources.loadIcon(ICON_COMPARER, "/images/table_error.png");
068:                resources.loadIcon(ICON_EXPLORER,
069:                        "/images/database_lightning.png");
070:                resources.loadIcon(ICON_EDITOR, "/images/page_edit.png");
071:                resources.loadIcon(ICON_PREFERENCES, "/images/wrench.png");
072:
073:                resources.loadIcon(ICON_EXPLORER_DRIVER,
074:                        "/images/database_gear.png");
075:                resources.loadIcon(ICON_EXPLORER_DATASOURCE_OK,
076:                        "/images/database_connect.png");
077:                resources.loadIcon(ICON_EXPLORER_DATASOURCE_KO,
078:                        "/images/database.png");
079:                resources.loadIcon(ICON_EXPLORER_SCHEMA,
080:                        "/images/folder_database.png");
081:                resources.loadIcon(ICON_EXPLORER_TYPES,
082:                        "/images/folder_table.png");
083:                resources.loadIcon(ICON_EXPLORER_ALL,
084:                        "/images/table_multiple.png");
085:                resources.loadIcon(ICON_EXPLORER_LINKS,
086:                        "/images/table_link.png");
087:                resources.loadIcon(ICON_EXPLORER_ADD_GROUP,
088:                        "/images/cart_add.png");
089:                resources.loadIcon(ICON_EXPLORER_REMOVE_GROUP,
090:                        "/images/cart_delete.png");
091:
092:                resources.loadIcon(ICON_EDITOR_OPEN, "/images/folder_page.png");
093:                resources.loadIcon(ICON_EDITOR_SAVE, "/images/page_save.png");
094:                resources.loadIcon(ICON_EDITOR_RUN, "/images/page_gear.png");
095:
096:                resources.loadIcon(ICON_CONTENT_UPDATE,
097:                        "/images/database_save.png");
098:                resources.loadIcon(ICON_CONTENT_DELETE,
099:                        "/images/table_row_delete.png");
100:                resources.loadIcon(ICON_CONTENT_INSERT,
101:                        "/images/table_row_insert.png");
102:
103:                resources.loadIcon(ICON_QUERY_LAUNCH, "/images/table_gear.png");
104:            }
105:
106:            private static void loadSession() {
107:                try {
108:                    if (new File(sessionFilename()).exists()) {
109:                        session.load(sessionFilename());
110:                        if (session.canMount(ENTRY_INFO)) {
111:                            session.mount(ENTRY_INFO);
112:                            println("\tversion: "
113:                                    + session.jump("version").get(0));
114:                        }
115:                    }
116:                    Preferences.loadDefaults();
117:                } catch (Exception e) {
118:                    println(e, false);
119:                }
120:            }
121:
122:            public static void shutdown() {
123:                Application.window.dispose();
124:                try {
125:                    session.mount(ENTRY_INFO);
126:                    session.home();
127:                    session.jump("version");
128:
129:                    if (session.jump().size() == 0)
130:                        session.jump().add(getVersion());
131:                    else
132:                        session.jump().set(0, getVersion());
133:
134:                    session.save(sessionFilename());
135:                } catch (IOException e) {
136:                    println(e, false);
137:                } finally {
138:                    System.exit(0);
139:                }
140:            }
141:
142:            private static String sessionFilename() {
143:                return System.getProperty("user.home") + File.separator
144:                        + ".sqleonardo";
145:            }
146:
147:            public static String getVersion() {
148:                return MAJOR + "." + MINOR;
149:            }
150:
151:            public static String getVersion2() {
152:                return PROGRAM + "." + getVersion();
153:            }
154:
155:            public static String getVersion3() {
156:                return getVersion2() + " [ " + WEB + " ]";
157:            }
158:
159:            public static void alert(String title, String message) {
160:                JOptionPane.showMessageDialog(window, message, title,
161:                        JOptionPane.WARNING_MESSAGE);
162:            }
163:
164:            public static boolean confirm(String title, String message) {
165:                return JOptionPane.showConfirmDialog(window, message, title,
166:                        JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION;
167:            }
168:
169:            public static String input(String title, String message) {
170:                return JOptionPane.showInputDialog(window, message, title,
171:                        JOptionPane.PLAIN_MESSAGE);
172:            }
173:
174:            public static void println(Exception e, boolean alert) {
175:                if (alert)
176:                    alert(e.getClass().getName(), Text.wrap(e.toString(), 100));
177:                else
178:                    System.out.println(e);
179:            }
180:
181:            public static void println(String s) {
182:                System.out.println(s);
183:            }
184:
185:            public static void initI18n() {
186:                String s = Preferences.getString("app.locale", "en_EN");
187:
188:                if (s != null && s.length() > 0) {
189:                    String language = s;
190:                    if (s.indexOf("_") > 0) {
191:                        language = s.substring(0, s.indexOf("_"));
192:                        s = s.substring(s.indexOf("_") + 1);
193:                    } else
194:                        s = "";
195:
196:                    String country = s;
197:                    if (s.indexOf("_") > 0) {
198:                        country = s.substring(0, s.indexOf("_"));
199:                        s = s.substring(s.indexOf("_") + 1);
200:                    } else
201:                        s = "";
202:
203:                    String variant = s;
204:
205:                    if (language.length() > 0 && country.length() > 0
206:                            && variant.length() > 0) {
207:                        I18n.setCurrentLocale(new Locale(language, country,
208:                                variant));
209:                    } else if (language.length() > 0 && country.length() > 0) {
210:                        I18n.setCurrentLocale(new Locale(language, country));
211:                    } else {
212:                        I18n.setCurrentLocale(new Locale(language));
213:                    }
214:                }
215:            }
216:
217:            public static void main(String[] args) {
218:                // Fix for java Bug ID:  4521075  
219:                System.setProperty("sun.swing.enableImprovedDragGesture", "");
220:
221:                if (System.getProperty("nickyb.sqleonardo.laf.class") != null) {
222:                    try {
223:                        javax.swing.UIManager.setLookAndFeel(System
224:                                .getProperty("nickyb.sqleonardo.laf.class"));
225:                    } catch (Exception e) {
226:                        e.printStackTrace();
227:                    }
228:                }
229:
230:                System.out.println(javax.swing.UIManager
231:                        .getSystemLookAndFeelClassName());
232:
233:                Application.println("loading resources...");
234:                Application.loadIcons();
235:                Application.println("loading session...");
236:                Application.loadSession();
237:                Application.initI18n();
238:                Application.window = new MDIWindow();
239:                Application.println("loading window...");
240:                Application.window.show();
241:
242:                JWindow wait = new JWindow(window);
243:                wait.getContentPane().add(
244:                        new JLabel("wait, auto connections...", JLabel.CENTER));
245:                wait.setSize(250, 40);
246:                wait.setLocationRelativeTo(window);
247:                wait.show();
248:
249:                ClientMetadataExplorer cme = (ClientMetadataExplorer) window
250:                        .getClient(ClientMetadataExplorer.DEFAULT_TITLE);
251:                cme.getControl().getNavigator().onFireAutoConnect();
252:                wait.dispose();
253:            }
254:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.