Source Code Cross Referenced for SplashCompiler.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:         * SplashCompiler.java
003:         * ****************************************************************************/
004:
005:        /* J_LZ_COPYRIGHT_BEGIN *******************************************************
006:         * Copyright 2001-2006 Laszlo Systems, Inc.  All Rights Reserved.              *
007:         * Use is subject to license terms.                                            *
008:         * J_LZ_COPYRIGHT_END *********************************************************/
009:
010:        package org.openlaszlo.compiler;
011:
012:        import java.io.*;
013:        import java.util.*;
014:
015:        import org.apache.log4j.*;
016:        import org.jdom.Element;
017:
018:        /** Compiler for <code>preloader</code> elements.
019:         *
020:         */
021:        class SplashCompiler extends ElementCompiler {
022:            /** Logger */
023:            private static Logger mLogger = org.apache.log4j.Logger
024:                    .getLogger(SplashCompiler.class);
025:            private ViewSchema mSchema;
026:            private static final String VIEW_INSTANTIATION_FNAME = "_root.lzpreloader.create";
027:
028:            SplashCompiler(CompilationEnvironment env) {
029:                super (env);
030:                mSchema = env.getSchema();
031:            }
032:
033:            /** Returns true iff this class applies to this element.
034:             * @param element an element
035:             * @return see doc
036:             */
037:            static boolean isElement(Element element) {
038:                return element.getName().equals("splash")
039:                        || element.getName().equals("preloader");
040:            }
041:
042:            public void compile(Element element) throws CompilationError {
043:                if (mEnv.isDHTML())
044:                    return;
045:
046:                ViewCompiler viewCompiler = new ViewCompiler(mEnv);
047:                ResourceCompiler res = new ResourceCompiler(mEnv);
048:                StringBuffer script = new StringBuffer();
049:
050:                boolean persistent = "true".equals(element
051:                        .getAttributeValue("persistent"));
052:                element.removeAttribute("persistent");
053:                String hideafterinit = new Boolean(!persistent).toString();
054:                element.setAttribute("hideafterinit", hideafterinit);
055:
056:                if (element.getChild("view", element.getNamespace()) == null) {
057:                    // Add default preloader
058:
059:                    ElementWithLocationInfo child = new ElementWithLocationInfo(
060:                            "view", element.getNamespace());
061:                    child.initSourceLocator(((ElementWithLocationInfo) element)
062:                            .getSourceLocator());
063:                    child.setAttribute("hideafterinit", hideafterinit);
064:                    child.setAttribute("resource", "defaultpreloader.swf");
065:                    child.setAttribute("center", "true");
066:                    child.setAttribute("ratio", "100%");
067:                    child.setAttribute("name", "lzprelresource");
068:                    child.setAttribute("resourcename", "lzprelresource");
069:                    element.addContent(child);
070:                }
071:
072:                ObjectWriter sw = mEnv.getGenerator();
073:                sw.addPreloader(mEnv);
074:
075:                for (Iterator iter = element.getChildren("view",
076:                        element.getNamespace()).iterator(); iter.hasNext();) {
077:                    Element child = (Element) iter.next();
078:                    // Change the child into the format that the runtime expects
079:                    // TODO: [2003-01-13 ows] change the runtime to expect the
080:                    // format that the schema defines instead
081:                    child.setName("preloadresource");
082:                    if (child.getAttribute("ratio") != null) {
083:                        String str = child.getAttributeValue("ratio").trim();
084:                        double value = 1;
085:                        if (str.endsWith("%")) {
086:                            str = str.substring(0, str.length() - 1);
087:                            value = Float.parseFloat(str) / 100;
088:                        } else {
089:                            try {
090:                                value = Float.parseFloat(str);
091:                            } catch (NumberFormatException e) {
092:                                throw new CompilationError(child, e);
093:                            }
094:                        }
095:                        child.setAttribute("synctoload", "true");
096:                        child.setAttribute("lastframe", "" + value);
097:                        child.removeAttribute("ratio");
098:                    }
099:                    if (child.getAttribute("resource") != null) {
100:                        File file = mEnv.resolveReference(child, "resource");
101:                        String rname = child.getAttributeValue("resourcename");
102:                        if (rname == null) {
103:                            rname = child.getAttributeValue("name");
104:                            if (rname == null) {
105:                                rname = sw.createName();
106:                            }
107:                            child.setAttribute("name", rname);
108:                        }
109:                        try {
110:                            sw.importPreloadResource(file.toString(), rname);
111:                        } catch (SWFWriter.ImportResourceError e) {
112:                            mEnv.warn(e, element);
113:                        }
114:                        child.setAttribute("resourcename", rname);
115:                        child.removeAttribute("resource");
116:                    }
117:                    if (child.getAttribute("synchronized") != null) {
118:                        child.setAttribute("synctoload", child
119:                                .getAttributeValue("synchronized"));
120:                        child.removeAttribute("synchronized");
121:                    }
122:                }
123:                NodeModel model = NodeModel.elementAsModel(element, mSchema,
124:                        mEnv);
125:                script.append(VIEW_INSTANTIATION_FNAME + "("
126:                        + model.asJavascript() + ");");
127:
128:                String scriptstr = script.toString();
129:                if (scriptstr != "") {
130:                    try {
131:                        sw.addPreloaderScript(scriptstr);
132:                    } catch (org.openlaszlo.sc.CompilerException e) {
133:                        throw new CompilationError(element, e);
134:                    }
135:                    mLogger.debug("Adding preloader script: " + script);
136:                }
137:            }
138:
139:            private String[] getBlogList() {
140:                return new String[] { "http://wetmachine.com/",
141:                        "http://osteele.com/", "http://www.davidtemkin.com/",
142:                        "http://www.ultrasaurus.com/",
143:                        "http://pt.withy.org/ptalk/" };
144:            }
145:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.