Source Code Cross Referenced for VAGlobals.java in  » Installer » VAInstall » com » memoire » vainstall » 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 » Installer » VAInstall » com.memoire.vainstall 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * $RCSfile: VAGlobals.java,v $
003:         * @creation     01/02/00
004:         * @modification $Date: 2005/03/16 19:55:26 $
005:         * Bug-fixing and additional features by Antonio Petrelli
006:         */package com.memoire.vainstall;
007:
008:        import java.awt.Color;
009:        import java.text.MessageFormat;
010:        import java.util.Hashtable;
011:        import java.util.Locale;
012:        import java.util.MissingResourceException;
013:        import java.util.ResourceBundle;
014:        import java.util.StringTokenizer;
015:        import java.util.Vector;
016:
017:        import javax.swing.UIManager;
018:
019:        /**
020:         * @version      $Id: VAGlobals.java,v 1.27 2005/03/16 19:55:26 deniger Exp $
021:         * @author       Axel von Arnim
022:         */
023:
024:        public class VAGlobals {
025:            public final static boolean DEBUG = "yes".equals(System
026:                    .getProperty("DEBUG"));
027:
028:            public final static String NAME = "VAInstall";
029:            public final static String VERSION = "0.23a";
030:            public final static String AUTHOR = "Axel von Arnim";
031:            public final static String COPYRIGHT = "2000-2002";
032:            public final static String LICENSE = "GPL2";
033:            public final static String HTTP = "http://www.ifrance.com/vonarnim/vainstall";
034:            public final static String EMAIL = "vonarnim@club-internet.fr";
035:            public final static Class BASE_CLASS = new VAGlobals().getClass();
036:
037:            public final static int UNKNOWN = 0;
038:            public final static int INSTALL = 1;
039:            public final static int UNINSTALL = 2;
040:            public final static int UPDATE = 3;
041:            public static int OPERATION = UNKNOWN;
042:
043:            public static String UI_MODE;
044:            public static boolean UI_BLUESCREEN;
045:            public static Color UI_BLUESCREEN_COLOR;
046:            public static String IMAGE;
047:            public static boolean USE_FULL_JAVA_PATH;
048:            public static boolean SHORTCUTS_IN_INSTALLDIR;
049:            public static String DEST_PATH;
050:            public static String APP_NAME;
051:            public static String APP_VERSION;
052:
053:            public static String JNI_DLL_FILE;
054:
055:            public static String LINK_SECTION_NAME;
056:            public static String LINK_SECTION_ICON;
057:            public static String LINK_ENTRY_NAME;
058:            public static String LINK_ENTRY_ICON;
059:            public static boolean CREATE_UNINSTALL_SHORTCUT;
060:
061:            /**
062:             *  Supported languages
063:             */
064:            public static String[][] languages = {
065:                    { "danish", "Danish", "da", "DK" },
066:                    { "german", "Deutsch", "de", "DE" },
067:                    { "english", "English", "en", "UK" },
068:                    { "french", "Français", "fr", "FR" },
069:                    { "italian", "Italian", "it", "IT" },
070:                    { "japanese", "Japanese", "ja", "JP" } };
071:            private static String[] allSupportedLanguages;
072:
073:            private static String[] supportedLanguages;
074:
075:            /**
076:             *  The locale that is used now
077:             */
078:            private static Locale locale;
079:
080:            /**
081:             *  The language that is used now
082:             */
083:            private static String currentLanguage;
084:
085:            /**
086:             *  Cached resources
087:             */
088:            private static Hashtable resourceList = null;
089:
090:            // AVA : deprecated
091:            //  private static Properties transTable=null;
092:
093:            public static void printDebug(String msg) {
094:                if (DEBUG)
095:                    System.err.println(msg);
096:            }
097:
098:            public static String i18n(String key) {
099:                String s = null;
100:                try {
101:                    s = getResource("com.memoire.vainstall.Language", key);
102:                } catch (MissingResourceException e) {
103:                }
104:                if (s == null)
105:                    try {
106:                        s = getResource("com.memoire.vainstall.gui.Language",
107:                                key);
108:                    } catch (MissingResourceException e) {
109:                    }
110:                if (s == null)
111:                    try {
112:                        s = getResource("com.memoire.vainstall.xui.Language",
113:                                key);
114:                    } catch (MissingResourceException e) {
115:                    }
116:                if (s == null)
117:                    try {
118:                        s = getResource("com.memoire.vainstall.tui.Language",
119:                                key);
120:                    } catch (MissingResourceException e) {
121:                    }
122:                // last try failed -> print key
123:                if (s == null)
124:                    s = key;
125:                return s;
126:            }
127:
128:            public static String i18n(String key, Object[] params) {
129:                String s = i18n(key);
130:                if (s != null && params != null) {
131:                    s = MessageFormat.format(s, params);
132:                }
133:                return s;
134:            }
135:
136:            /* AVA : deprecated
137:             public static String getString(String s)
138:             {
139:             Locale l=Locale.getDefault();
140:             if("en".equals(l.getLanguage())) return s;
141:             if( transTable==null ) {
142:             transTable=new Properties();
143:             try {
144:             InputStream fin=BASE_CLASS.getResourceAsStream("vai_"+l.getLanguage()+".lang");
145:             if( fin!=null ) {
146:             transTable.load(fin);
147:             fin.close();
148:             }
149:             } catch( IOException e ) { printDebug("error while reading vai_"+l.getLanguage()+".lang"); }
150:             }
151:             String res=transTable.getProperty(s);
152:             if( (res==null)||("".equals(res.trim())) ) res=s;
153:             return res;
154:             }
155:             */
156:
157:            /**
158:             *  Get a String resource from a resourcebundle.
159:             *  @param baseName String The name of the resource class ex. 'com.memorie.vainstall.Language'
160:             *  @param key String The keyword to find
161:             *  @return String
162:             */
163:            public static String getResource(String baseName, String key)
164:                    throws MissingResourceException {
165:
166:                if ((locale == null) || DEBUG) {
167:                    locale = new Locale("en", "UK");
168:                }
169:
170:                if (resourceList == null) {
171:                    resourceList = new java.util.Hashtable();
172:                }
173:
174:                // check to see if we have cached
175:                if (resourceList.contains(baseName) == false) {
176:                    // throws java.util.MissingResourceException
177:                    ResourceBundle resource = ResourceBundle.getBundle(
178:                            baseName, locale);
179:
180:                    // we got the resource bundle
181:                    resourceList.put(baseName, resource);
182:                    return resource.getString(key);
183:                } else {
184:                    return ((ResourceBundle) resourceList.get(baseName))
185:                            .getString(key);
186:                }
187:
188:            } // endmethod
189:
190:            /**
191:             *  Get a 'int' resource from a resourcebundle.
192:             *  @param baseName String The name of the resource class ex. 'com.memorie.vainstall.Language'
193:             *  @param key String The keyword to find
194:             *  @return int
195:             */
196:            public static int getResourceInt(String baseName, String key)
197:                    throws java.util.MissingResourceException {
198:
199:                if (locale == null) {
200:                    locale = new Locale("en", "UK");
201:                }
202:
203:                if (resourceList == null) {
204:                    resourceList = new java.util.Hashtable();
205:                }
206:
207:                // check to see if we have cached
208:                if (resourceList.contains(baseName) == false) {
209:                    // throws java.util.MissingResourceException
210:                    ResourceBundle resource = ResourceBundle.getBundle(
211:                            baseName, locale);
212:
213:                    // we got the resource bundle
214:                    resourceList.put(baseName, resource);
215:
216:                    Integer value = (Integer) resource.getObject(key);
217:                    return (int) value.intValue();
218:                } else {
219:                    Integer value = (Integer) ((ResourceBundle) resourceList
220:                            .get(baseName)).getObject(key);
221:                    return (int) value.intValue();
222:                }
223:
224:            } // endmethod
225:
226:            /**
227:             *  Set the language as defined in the documentation.
228:             *  We translate the name to a 'controlled' Java Locale.
229:             *  @param language String The language as defined in the documentation
230:             *                         english, french, danish etc.
231:             *  @return void
232:             */
233:            public static void setLanguage(String language) {
234:                // clear resourcelist cache
235:                if (resourceList != null) {
236:                    resourceList.clear();
237:                }
238:
239:                if (language.toLowerCase().indexOf("choose") != -1) {
240:                    // 'choose ' keywork alone equals that all supported languages
241:                    // can be choosen
242:                    if (language.equalsIgnoreCase("choose") == true) {
243:                        setLanguage("default");
244:                        return;
245:                    }
246:
247:                    Vector languageList = new Vector();
248:                    String[] supportedLangs = getAllSupportedLanguages();
249:
250:                    Locale l = Locale.getDefault();
251:                    for (int i = 0; i < languages.length; i++) {
252:                        if (l.getLanguage().equals(languages[i][2]) == true) {
253:                            currentLanguage = languages[i][0];
254:                        }
255:                    }
256:
257:                    StringTokenizer nizer = new StringTokenizer(language, ",");
258:                    while (nizer.hasMoreTokens() == true) {
259:                        String element = (String) nizer.nextToken();
260:                        element = element.trim().toLowerCase();
261:
262:                        for (int i = 0; i < languages.length; i++) {
263:                            if (element.equals(languages[i][0]) == true) {
264:
265:                                if (element.equals(currentLanguage) == true) {
266:                                    languageList.insertElementAt(
267:                                            languages[i][0], 0);
268:                                } else {
269:                                    languageList.addElement(languages[i][0]);
270:                                }
271:                            }
272:                        }
273:                    }
274:
275:                    supportedLanguages = new String[languageList.size()];
276:                    for (int i = 0; i < languageList.size(); i++) {
277:                        for (int j = 0; j < languages.length; j++) {
278:                            if (languageList.elementAt(i).equals(
279:                                    languages[j][0]) == true) {
280:                                supportedLanguages[i] = (String) languages[j][1];
281:                            }
282:                        }
283:                    }
284:                    setLanguage("default");
285:                    return;
286:                }
287:
288:                /* If 'default' then we try to initially
289:                   look at the default language.
290:                   If it's one of the supported we use that.
291:                   During install we use the default language if supported
292:                   until the user selects one.
293:                   English is the default language.
294:                 */
295:                if (language.equals("default") == true) {
296:                    Locale l = Locale.getDefault();
297:                    String shortLanguage = l.getLanguage();
298:
299:                    for (int i = 0; i < languages.length; i++) {
300:                        if (shortLanguage.equals(languages[i][2]) == true) {
301:                            currentLanguage = languages[i][0];
302:                            locale = new Locale(languages[i][2],
303:                                    languages[i][3]);
304:                        }
305:                    }
306:
307:                } else {
308:                    // One of the known languages
309:                    for (int i = 0; i < languages.length; i++) {
310:                        if (language.equals(languages[i][0]) == true) {
311:                            currentLanguage = languages[i][0];
312:                            locale = new Locale(languages[i][2],
313:                                    languages[i][3]);
314:                        }
315:                    }
316:                }
317:
318:                // update UIManager
319:                UIManager.put("OptionPane.yesButtonText", getResource(
320:                        "com.memoire.vainstall.Language",
321:                        "Common_OptionPane.yesButtonText"));
322:                UIManager.put("OptionPane.noButtonText", getResource(
323:                        "com.memoire.vainstall.Language",
324:                        "Common_OptionPane.noButtonText"));
325:                UIManager.put("OptionPane.okButtonText", getResource(
326:                        "com.memoire.vainstall.Language",
327:                        "Common_OptionPane.okButtonText"));
328:                UIManager.put("OptionPane.cancelButtonText", getResource(
329:                        "com.memoire.vainstall.Language",
330:                        "Common_OptionPane.cancelButtonText"));
331:
332:            }
333:
334:            public static String[] getSupportedLanguages() {
335:                if (supportedLanguages == null) {
336:                    supportedLanguages = new String[languages.length];
337:                    for (int i = 0; i < languages.length; i++) {
338:                        supportedLanguages[i] = languages[i][1];
339:                    }
340:                }
341:                return supportedLanguages;
342:            }
343:
344:            public static String[] getAllSupportedLanguages() {
345:                if (allSupportedLanguages == null) {
346:                    allSupportedLanguages = new String[languages.length];
347:                    for (int i = 0; i < languages.length; i++) {
348:                        allSupportedLanguages[i] = languages[i][1];
349:                    }
350:                }
351:                return allSupportedLanguages;
352:            }
353:
354:            public static String getCurrentLanguage() {
355:                return currentLanguage;
356:            }
357:
358:            /**
359:             * Return an index that corresponds to the value of getSupportedLanguages
360:             * or getAllSupportedLanguages that matches the default locale.
361:             * If an exact match for the locale is not present,the value returned is
362:             * the first language in the list that matches the language of the default
363:             * locale.
364:             * 
365:             */
366:            public static int suggestLanguage() {
367:                Locale syslocale = Locale.getDefault();
368:                String syslang = syslocale.getLanguage();
369:                String syscountry = syslocale.getCountry();
370:                int langonly = -1;
371:                for (int idx = 0; idx < languages.length; idx++) {
372:                    if (syslang.equals(languages[idx][2])) {
373:                        if (syscountry.equals(languages[idx][3])) {
374:                            return idx;
375:                        } else {
376:                            if (langonly == -1)
377:                                langonly = idx;
378:                        }
379:                    }
380:                }
381:                if (langonly == -1)
382:                    langonly = 0;
383:                return langonly;
384:            }
385:
386:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.