Source Code Cross Referenced for Canvas.java in  » Ajax » Laszlo-4.0.10 » org » openlaszlo » compiler » 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 » Laszlo 4.0.10 » org.openlaszlo.compiler 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* *****************************************************************************
002:         * Canvas.java
003:         * ****************************************************************************/
004:
005:        /* J_LZ_COPYRIGHT_BEGIN *******************************************************
006:         * Copyright 2001-2007 Laszlo Systems, Inc.  All Rights Reserved.              *
007:         * Use is subject to license terms.                                            *
008:         * J_LZ_COPYRIGHT_END *********************************************************/
009:
010:        /**
011:         * A <code>Canvas</code> represents the underlying
012:         * area in which a compiled app will run
013:         */package org.openlaszlo.compiler;
014:
015:        import java.util.HashSet;
016:        import java.util.Hashtable;
017:        import java.util.List;
018:        import java.util.Map;
019:        import java.util.Set;
020:        import java.io.File;
021:        import org.jdom.Element;
022:        import org.jdom.output.Format.TextMode;
023:        import org.openlaszlo.server.Configuration;
024:        import org.openlaszlo.server.LPS;
025:        import org.openlaszlo.xml.internal.XMLUtils;
026:        import org.apache.log4j.Logger;
027:
028:        public class Canvas implements  java.io.Serializable {
029:
030:            // TODO: [old ebloch] change these to properties
031:            // TODO: [2003-10-25 bloch] or better yet derrive them from the schema
032:
033:            private static Logger mLogger = Logger.getLogger(Canvas.class);
034:
035:            /** Default canvas width for compilation */
036:            private static final int DEFAULT_WIDTH = 500;
037:
038:            /** Default canvas height for compilation */
039:            private static final int DEFAULT_HEIGHT = 400;
040:
041:            /** Default canvas backgorund color */
042:            private static final int DEFAULT_BGCOLOR = 0xFFFFFF;
043:
044:            /** Default canvas backgorund color */
045:            private static final String DEFAULT_TITLE = "OpenLaszlo Application";
046:
047:            /** Default canvas id */
048:            private static final String DEFAULT_ID = "lzapp";
049:
050:            /** Default canvas accessibility */
051:            private static final boolean DEFAULT_ACCESSIBLE = false;
052:
053:            /** Default canvas font info */
054:            // TODO: [2003-10-25 bloch] this should come from the build system
055:            public static final String DEFAULT_VERSION = "1.1";
056:
057:            // TODO: [2003-10-25 bloch] these should come from a properties file
058:            public static final String DEFAULT_FONT = "Verdana,Vera,sans-serif";
059:
060:            public static final String DEFAULT_FONT_FILENAME = "verity"
061:                    + File.separator + "verity11.ttf";
062:            public static final String DEFAULT_BOLD_FONT_FILENAME = "verity"
063:                    + File.separator + "verity11bold.ttf";
064:            public static final String DEFAULT_ITALIC_FONT_FILENAME = "verity"
065:                    + File.separator + "verity11italic.ttf";
066:            public static final String DEFAULT_BOLD_ITALIC_FONT_FILENAME = "verity"
067:                    + File.separator + "verity11bolditalic.ttf";
068:
069:            public String defaultFont() {
070:                return DEFAULT_FONT;
071:            }
072:
073:            public String defaultFontsize() {
074:                return DEFAULT_FONTSIZE;
075:            }
076:
077:            public static final String DEFAULT_FONTSIZE = "11";
078:            public static final String DEFAULT_FONTSTYLE = "plain";
079:
080:            /** Default persistent connection parameters */
081:            private static final long DEFAULT_HEARTBEAT = 5000; // 5 seconds
082:            private static final boolean DEFAULT_SENDUSERDISCONNECT = false;
083:
084:            public String defaultFont = DEFAULT_FONT;
085:            public String defaultFontFilename = DEFAULT_FONT_FILENAME;
086:            public String defaultBoldFontFilename = DEFAULT_BOLD_FONT_FILENAME;
087:            public String defaultItalicFontFilename = DEFAULT_ITALIC_FONT_FILENAME;
088:            public String defaultBoldItalicFontFilename = DEFAULT_BOLD_ITALIC_FONT_FILENAME;
089:
090:            /** File path relative to webapp. */
091:            private String mFilePath = null;
092:            /** Width of the canvas. */
093:            private int mWidth = DEFAULT_WIDTH;
094:            /** Height of the canvas. */
095:            private int mHeight = DEFAULT_HEIGHT;
096:            /** Background color of the canvas. */
097:            private int mBGColor = DEFAULT_BGCOLOR;
098:
099:            // Dimension strings
100:            private String mWidthString = "100%";
101:            private String mHeightString = "100%";
102:
103:            // Default to proxied deployment
104:            private boolean mProxied = true;
105:
106:            /** FontInfo for the canvas. */
107:            private FontInfo mFontInfo = null;
108:
109:            /** Title for the canvas. */
110:            private String mTitle = DEFAULT_TITLE;
111:
112:            /** Version of the flash player file format which we compile to **/
113:            private String mRuntime = LPS.getProperty(
114:                    "compiler.runtime.default", LPS.getRuntimeDefault());
115:
116:            /** computed debug flag, based on canvas 'debug' attribute + compilation request args **/
117:            private boolean mDebug = false;
118:
119:            /** computed backtrace flag, based on canvas 'backtrace' attribute + compilation request args **/
120:            private boolean mBacktrace = false;
121:
122:            /** computed profile flag from request args **/
123:            private boolean mProfile = false;
124:
125:            /** ID for the canvas. */
126:            private String mID = DEFAULT_ID;
127:
128:            /** accessibility for the canvas. */
129:            private boolean mAccessible = DEFAULT_ACCESSIBLE;
130:
131:            /** Persistent connection parameters. */
132:            private boolean mIsConnected = false;
133:            private boolean mSendUserDisconnect = false;
134:            private long mHeartbeat = 0;
135:            private String mAuthenticator = null;
136:            private String mGroup = null;
137:            private Set mAgents = null;
138:
139:            private final Map mSecurityOptions = new Hashtable();
140:
141:            private String mCompilationWarningText = null;
142:            private String mCompilationWarningXML = null;
143:            private Element mInfo = new org.jdom.Element("stats");
144:
145:            public void setCompilationWarningText(String text) {
146:                mCompilationWarningText = text;
147:            }
148:
149:            public void setCompilationWarningXML(String xml) {
150:                mCompilationWarningXML = xml;
151:            }
152:
153:            public void setRuntime(String text) {
154:                mRuntime = text;
155:            }
156:
157:            public String getRuntime() {
158:                return mRuntime;
159:            }
160:
161:            public void setDebug(boolean val) {
162:                mDebug = val;
163:            }
164:
165:            public boolean getDebug() {
166:                return (mDebug);
167:            }
168:
169:            public void setBacktrace(boolean val) {
170:                mBacktrace = val;
171:            }
172:
173:            public boolean getBacktrace() {
174:                return (mBacktrace);
175:            }
176:
177:            public void setProfile(boolean val) {
178:                mProfile = val;
179:            }
180:
181:            public boolean getProfile() {
182:                return (mProfile);
183:            }
184:
185:            public void addInfo(Element info) {
186:                mInfo.addContent(info);
187:            }
188:
189:            public String getCompilationWarningText() {
190:                return mCompilationWarningText;
191:            }
192:
193:            public void setFontInfo(FontInfo info) {
194:                mFontInfo = info;
195:            }
196:
197:            public String getInfoAsString() {
198:                org.jdom.output.XMLOutputter outputter = new org.jdom.output.XMLOutputter();
199:                outputter.getFormat().setTextMode(TextMode.NORMALIZE);
200:                return outputter.outputString(mInfo);
201:            }
202:
203:            /** @return file path */
204:            public String getFilePath() {
205:                return mFilePath;
206:            }
207:
208:            /** @param filePath */
209:            public void setFilePath(String filePath) {
210:                mFilePath = filePath;
211:            }
212:
213:            /** @return width */
214:            public int getWidth() {
215:                return mWidth;
216:            }
217:
218:            /** @return width */
219:            public String getWidthXML() {
220:                if (mWidthString == null)
221:                    return "" + mWidth;
222:                else
223:                    return mWidthString;
224:            }
225:
226:            /** @param w */
227:            public void setWidth(int w) {
228:                mWidth = w;
229:                mWidthString = null;
230:            }
231:
232:            /** @param w */
233:            public void setWidthString(String w) {
234:                mWidthString = w;
235:            }
236:
237:            /** @return height */
238:            public int getHeight() {
239:                return mHeight;
240:            }
241:
242:            /** @return width */
243:            public String getHeightXML() {
244:                if (mHeightString == null)
245:                    return "" + mHeight;
246:                else
247:                    return mHeightString;
248:            }
249:
250:            /** @param h */
251:            public void setHeight(int h) {
252:                mHeight = h;
253:                mHeightString = null;
254:            }
255:
256:            /** @param h */
257:            public void setHeightString(String h) {
258:                mHeightString = h;
259:            }
260:
261:            /** @return Background color */
262:            public int getBGColor() {
263:                return mBGColor;
264:            }
265:
266:            /** @return Returns bgcolor as a hexadecimal string */
267:            // TODO: [12-21-2002 ows] This belongs in a utility library.
268:            public String getBGColorString() {
269:                String red = Integer.toHexString((mBGColor >> 16) & 0xff);
270:                String green = Integer.toHexString((mBGColor >> 8) & 0xff);
271:                String blue = Integer.toHexString(mBGColor & 0xff);
272:                if (red.length() == 1)
273:                    red = "0" + red;
274:                if (green.length() == 1)
275:                    green = "0" + green;
276:                if (blue.length() == 1)
277:                    blue = "0" + blue;
278:                return "#" + red + green + blue;
279:            }
280:
281:            /** @param BGColor  Background color */
282:            public void setBGColor(int BGColor) {
283:                mBGColor = BGColor;
284:            }
285:
286:            /** @return Title */
287:            public String getTitle() {
288:                return mTitle;
289:
290:            }
291:
292:            /** @return ID */
293:            public String getID() {
294:                return mID;
295:
296:            }
297:
298:            /** @return accessible */
299:            public boolean getAccessible() {
300:                return mAccessible;
301:            }
302:
303:            public String getISBN() {
304:                return "192975213X";
305:            }
306:
307:            /** @param t */
308:            public void setTitle(String t) {
309:                mTitle = t;
310:            }
311:
312:            /** @param id */
313:            public void setID(String id) {
314:                mID = id;
315:            }
316:
317:            /** @param accessible */
318:            public void setAccessible(boolean accessible) {
319:                mAccessible = accessible;
320:            }
321:
322:            /** @return Heartbeat */
323:            public long getHeartbeat() {
324:                return mHeartbeat;
325:
326:            }
327:
328:            /** @param heartbeat */
329:            public void setHeartbeat(long heartbeat) {
330:                mHeartbeat = heartbeat;
331:            }
332:
333:            /** @return Group */
334:            public String getGroup() {
335:                return mGroup;
336:
337:            }
338:
339:            /** @param g */
340:            public void setGroup(String g) {
341:                mGroup = g;
342:            }
343:
344:            /** @return Authenticator */
345:            public String getAuthenticator() {
346:                return mAuthenticator;
347:
348:            }
349:
350:            /** @param a */
351:            public void setAuthenticator(String a) {
352:                mAuthenticator = a;
353:            }
354:
355:            /** @return send user disconnect */
356:            public boolean doSendUserDisconnect() {
357:                return mSendUserDisconnect;
358:            }
359:
360:            /** @param sud */
361:            public void setSendUserDisconnect(boolean sud) {
362:                mSendUserDisconnect = sud;
363:            }
364:
365:            /** @param val */
366:            public void setProxied(boolean val) {
367:                mProxied = val;
368:            }
369:
370:            /** @return is this app compiling for serverless deployment */
371:            public boolean isProxied() {
372:                return mProxied;
373:            }
374:
375:            /** @return is connected */
376:            public boolean isConnected() {
377:                return mIsConnected;
378:            }
379:
380:            /** @param isConnected */
381:            public void setIsConnected(boolean isConnected) {
382:                mIsConnected = isConnected;
383:            }
384:
385:            /** @return agents */
386:            public Set getAgents() {
387:                return mAgents;
388:            }
389:
390:            /** @param agent agent's URL */
391:            public void addAgent(String agent) {
392:                if (mAgents == null)
393:                    mAgents = new HashSet();
394:                mAgents.add(agent);
395:            }
396:
397:            /** @return font info */
398:            public FontInfo getFontInfo() {
399:                return mFontInfo;
400:            }
401:
402:            /** @return security options */
403:            public Map getSecurityOptions() {
404:                return mSecurityOptions;
405:            }
406:
407:            /** @param element */
408:            public void setSecurityOptions(Element element) {
409:                Configuration.addOption(mSecurityOptions, element);
410:            }
411:
412:            public String getXML(String content) {
413:                StringBuffer buffer = new StringBuffer();
414:                buffer
415:                        .append("<canvas " + "title='"
416:                                + XMLUtils.escapeXml(getTitle())
417:                                + "' "
418:                                + "bgcolor='"
419:                                + getBGColorString()
420:                                + "' "
421:                                + "width='"
422:                                + getWidthXML()
423:                                + "' "
424:                                + "height='"
425:                                + getHeightXML()
426:                                + "' "
427:                                + "proxied='"
428:                                + isProxied()
429:                                + "' "
430:                                + "runtime='"
431:                                + getRuntime()
432:                                + "' "
433:                                + "lfc='"
434:                                + LPS.getProperty("compiler.runtime.dir")
435:                                + "/"
436:                                + LPS.getLFCname(getRuntime(), mDebug,
437:                                        mProfile, mBacktrace) + "' "
438:                                + "debug='" + mDebug + "' " + "id='"
439:                                + XMLUtils.escapeXml(getID()) + "' "
440:                                + "accessible='"
441:                                + XMLUtils.escapeXml(getAccessible() + "")
442:                                + "' " + ">");
443:                buffer.append(content);
444:                buffer.append(getInfoAsString());
445:                if (mCompilationWarningXML != null)
446:                    buffer.append("<warnings>" + mCompilationWarningXML
447:                            + "</warnings>");
448:                buffer.append("</canvas>");
449:                return buffer.toString();
450:            }
451:
452:            /** 
453:             * Initialize persistent connection values.
454:             */
455:            protected void initializeConnection(Element elt) {
456:                // TODO: [2003-10-16 pkang] Create and move this function into
457:                // ConnectionCompiler.java
458:                Element eltConnection = elt.getChild("connection", elt
459:                        .getNamespace());
460:                if (eltConnection != null) {
461:
462:                    setIsConnected(true);
463:                    setSendUserDisconnect(DEFAULT_SENDUSERDISCONNECT);
464:                    setHeartbeat(DEFAULT_HEARTBEAT);
465:
466:                    String heartbeat = eltConnection
467:                            .getAttributeValue("heartbeat");
468:                    if (heartbeat != null) {
469:                        try {
470:                            setHeartbeat(Long.parseLong(heartbeat));
471:                        } catch (NumberFormatException e) {
472:                            throw new CompilationError(elt, "heartbeat", e);
473:                        }
474:                    }
475:
476:                    String sendUserDisconnect = eltConnection
477:                            .getAttributeValue("receiveuserdisconnect");
478:                    if (sendUserDisconnect != null) {
479:                        setSendUserDisconnect(Boolean.valueOf(
480:                                sendUserDisconnect).booleanValue());
481:                    }
482:
483:                    String group = eltConnection.getAttributeValue("group");
484:                    if (group != null) {
485:                        setGroup(group);
486:                    }
487:
488:                    // Don't set a default authenticator in canvas. We want to be able
489:                    // to override this through lps.properties. Return null if one does
490:                    // not exist.
491:                    String authenticator = eltConnection
492:                            .getAttributeValue("authenticator");
493:                    if (authenticator != null) {
494:                        setAuthenticator(authenticator);
495:                    }
496:
497:                    List agents = eltConnection.getChildren("agent", elt
498:                            .getNamespace());
499:                    for (int i = 0; i < agents.size(); i++) {
500:                        Element eltAgent = (Element) agents.get(i);
501:                        String url = eltAgent.getAttributeValue("url");
502:                        if (url != null || !url.equals(""))
503:                            addAgent(url);
504:                    }
505:                }
506:            }
507:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.