Source Code Cross Referenced for MyGWT.java in  » Ajax » MyGWT » net » mygwt » ui » client » 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 » Ajax » MyGWT » net.mygwt.ui.client 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * MyGWT Widget Library
003:         * Copyright(c) 2007, MyGWT.
004:         * licensing@mygwt.net
005:         * 
006:         * http://mygwt.net/license
007:         */
008:        package net.mygwt.ui.client;
009:
010:        import net.mygwt.ui.client.fx.FXStyle;
011:        import net.mygwt.ui.client.messages.MyMessages;
012:        import net.mygwt.ui.client.state.CookieProvider;
013:        import net.mygwt.ui.client.state.StateManager;
014:        import net.mygwt.ui.client.util.CSS;
015:
016:        import com.google.gwt.core.client.GWT;
017:        import com.google.gwt.user.client.DOM;
018:        import com.google.gwt.user.client.Element;
019:
020:        /**
021:         * MyGWT core utilities and functions.
022:         */
023:        public class MyGWT {
024:
025:            /**
026:             * MyGWT messages.
027:             */
028:            public static MyMessages MESSAGES = (MyMessages) GWT
029:                    .create(MyMessages.class);
030:
031:            /**
032:             * defaultTheme specifies the default theme. Supported theme names are "gray"
033:             * and "default". Default value is "default".
034:             */
035:            public static String defaultTheme = "default";
036:
037:            /**
038:             * <code>true</code> if the browser is safari.
039:             */
040:            public static boolean isSafari;
041:
042:            /**
043:             * <code>true</code> if the browser is opera.
044:             */
045:            public static boolean isOpera;
046:
047:            /**
048:             * <code>true</code> if the browser is ie.
049:             */
050:            public static boolean isIE;
051:
052:            /**
053:             * <code>true</code> if the browser is ie7.
054:             */
055:            public static boolean isIE7;
056:
057:            /**
058:             * <code>true</code> if the browser is gecko.
059:             */
060:            public static boolean isGecko;
061:
062:            /**
063:             * <code>true</code> if the browser is in strict mode.
064:             */
065:            public static boolean isStrict;
066:
067:            /**
068:             * <code>true</code> if using https.
069:             */
070:            public static boolean isSecure;
071:
072:            /**
073:             * <code>true</code> if mac os.
074:             */
075:            public static boolean isMac;
076:
077:            /**
078:             * <code>true</code> if linux os.
079:             */
080:            public static boolean isLinux;
081:
082:            /**
083:             * URL to a blank file used by MyGWT when in secure mode for iframe src to
084:             * prevent the IE insecure content. Default value is 'blank.html'.
085:             */
086:            public static String SSL_SECURE_URL = GWT.getModuleBaseURL()
087:                    + "blank.html";
088:
089:            /**
090:             * URL to a 1x1 transparent gif image used by MyGWT to create inline icons
091:             * with CSS background images. Default value is
092:             * 'images/default/shared/clear.gif';
093:             */
094:            public static String BLANK_IMAGE_URL = GWT.getModuleBaseURL()
095:                    + "images/default/shared/clear.gif";
096:
097:            private static boolean initialized;
098:
099:            /**
100:             * Returns the browser's user agent.
101:             * 
102:             * @return the user agent
103:             */
104:            public native static String getUserAgent() /*-{
105:               return $wnd.navigator.userAgent.toLowerCase();
106:             }-*/;
107:
108:            /**
109:             * Sets whether the html used in MyDOM.setInnerHTML is escaped for cross-site
110:             * scripting (XSS) exploits. Enabling will effect performance as all HTML must
111:             * be parsed. Default value is <code>false</code>.
112:             * 
113:             * @param escape <code>true</code> to escape html
114:             */
115:            public native static void enableEscapeHTML(boolean escape) /*-{
116:               $wnd.escapeFlag = escape;
117:             }-*/;
118:
119:            /**
120:             * Changes the theme. Supported theme names are "gray" and "default".
121:             * 
122:             * @param theme the new theme name.
123:             */
124:            public static void switchTheme(String theme) {
125:                if (theme.equals("gray")) {
126:                    CSS.addStyleSheet("mygwt-all-gray", "mygwt-all-gray.css");
127:                } else {
128:                    CSS.removeStyleSheet("mygwt-all-gray");
129:                }
130:                StateManager.set("theme", theme.equals("gray") ? "gray"
131:                        : "default");
132:            }
133:
134:            /**
135:             * Returns the current theme.
136:             * 
137:             * @return the theme
138:             */
139:            public static String getTheme() {
140:                return StateManager.getString("theme");
141:            }
142:
143:            /**
144:             * Hides the loading panel.
145:             * 
146:             * @param id the loading panel id
147:             */
148:            public static void hideLoadingPanel(String id) {
149:                final Element loading = DOM.getElementById(id);
150:                if (loading != null) {
151:                    FXStyle fx = new FXStyle(loading);
152:                    fx.duration = 300;
153:                    fx.hideOnComplete = true;
154:                    fx.fadeOut();
155:                }
156:            }
157:
158:            /**
159:             * Initializes MyGWT.
160:             */
161:            public static void init() {
162:                if (initialized) {
163:                    return;
164:                }
165:                initialized = true;
166:                String ua = getUserAgent();
167:                isSafari = ua.indexOf("webkit") != -1;
168:                isOpera = ua.indexOf("opera") != -1;
169:                isIE = ua.indexOf("msie") != -1;
170:                isIE7 = ua.indexOf("msie 7") != -1;
171:                isGecko = ua.indexOf("gecko") != -1;
172:                isMac = ua.indexOf("macintosh") != -1
173:                        || ua.indexOf("mac os x") != -1;
174:                isLinux = ua.indexOf("linux") != -1;
175:
176:                String mode = DOM.getElementProperty(MyDOM.getDocument(),
177:                        "compatMode");
178:                isStrict = mode != null ? mode.equals("CSS1Compat") : false;
179:
180:                isSecure = isSecure();
181:
182:                String cls = "";
183:                if (isIE) {
184:                    cls = "ext-ie";
185:                } else if (isGecko) {
186:                    cls = "ext-gecko";
187:                } else if (isOpera) {
188:                    cls = "ext-opera";
189:                } else if (isSafari) {
190:                    cls = "ext-safari";
191:                }
192:
193:                if (isMac) {
194:                    cls += " ext-mac";
195:                }
196:
197:                if (isLinux) {
198:                    cls += " ext-linux";
199:                }
200:
201:                MyDOM.setStyleName(MyDOM.getBody(), cls);
202:
203:                CookieProvider provider = new CookieProvider("/", null, null,
204:                        false);
205:                StateManager.setProvider(provider);
206:
207:                String theme = StateManager.getString("theme");
208:                if (theme == null || theme.equals("")) {
209:                    theme = defaultTheme;
210:                }
211:
212:                initInternal(theme);
213:            }
214:
215:            private static native void initInternal(String theme) /*-{
216:              var links = $doc.getElementsByTagName('link');
217:              for (var i = 0; i < links.length; i++) {
218:              var link = links[i];
219:              var href = link.href;
220:              href = href.substring(href.lastIndexOf('/') + 1, href.length);
221:              if (href == 'mygwt-all.css') {
222:              link.setAttribute('id','mygwt-all');
223:              }
224:              if (href == 'mygwt-all-gray.css') {
225:              link.setAttribute('id','mygwt-all-gray');
226:              if (theme != 'gray') {
227:              link.setAttribute('disabled', true);
228:              link.parentNode.removeChild(link);
229:              }
230:              }
231:              }
232:              }-*/;
233:
234:            private static native boolean isSecure() /*-{
235:              return $wnd.location.href.toLowerCase().indexOf("https") === 0;
236:              }-*/;
237:
238:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.