Source Code Cross Referenced for CreateUIFilter.java in  » Installer » AntInstaller » org » tp23 » antinstaller » runtime » exe » 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 » AntInstaller » org.tp23.antinstaller.runtime.exe 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * Copyright 2005 Paul Hinds
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         * http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package org.tp23.antinstaller.runtime.exe;
017:
018:        import java.io.IOException;
019:        import java.util.StringTokenizer;
020:
021:        import org.tp23.antinstaller.InstallException;
022:        import org.tp23.antinstaller.InstallerContext;
023:        import org.tp23.antinstaller.renderer.swing.plaf.LookAndFeelFactory;
024:        import org.tp23.antinstaller.runtime.AutoSwingRunner;
025:        import org.tp23.antinstaller.runtime.AutoTextRunner;
026:        import org.tp23.antinstaller.runtime.Runner;
027:        import org.tp23.antinstaller.runtime.SwingRunner;
028:        import org.tp23.antinstaller.runtime.TextRunner;
029:
030:        /**
031:         * Creates the Runner instance for the execution UI and sets up an appropriate
032:         * message renderer.
033:         * @author Paul Hinds
034:         * @version $Id: CreateUIFilter.java,v 1.7 2007/01/28 17:49:15 teknopaul Exp $
035:         */
036:        public class CreateUIFilter implements  ExecuteFilter {
037:
038:            /**
039:             * @see org.tp23.antinstaller.runtime.exe.ExecuteFilter#exec(org.tp23.antinstaller.InstallerContext)
040:             */
041:            public void exec(InstallerContext ctx) throws InstallException {
042:                try {
043:                    if (ctx.getInstaller().isVerbose()) {
044:                        ctx.log("Creating UI classes");
045:                    }
046:                    ctx.setRunner(getRunner(ctx));
047:                    ctx.log("Created UI classes");
048:                } catch (IOException e) {
049:                    throw new InstallException(
050:                            "Unable to create the user interface", e);
051:                } catch (InstallException e) {
052:                    throw new InstallException(e.getMessage(), e);
053:                }
054:            }
055:
056:            /**
057:             * Determines which Runner to use text or swing or "auto" UIs which skip past the properties sreens.
058:             * @param override String if this paramter is not null it will be used. If
059:             * swing and there is no graphics environment the install will fail, if it is left
060:             * as null a check is made to see if there is a Graphics Environment and swing is used
061:             * if there are no errors, if there are errors the system falls back to the text console
062:             *
063:             * @throws IOException
064:             * @return Runner
065:             */
066:            protected Runner getRunner(InstallerContext ctx)
067:                    throws IOException, InstallException {
068:
069:                if (ctx.getUIOverride() != null) {
070:                    if (ctx.getUIOverride().equalsIgnoreCase("swing")) {
071:                        if (isUi("swing", ctx.getInstaller().getUi())) {
072:                            new LookAndFeelFactory(ctx).setLAF();
073:                            ctx.setGui(true);
074:                            return new SwingRunner(ctx);
075:                        } else {
076:                            throw new InstallException(
077:                                    "Not a permited UI override, swing is not allowed");
078:                        }
079:                    }
080:
081:                    if (ctx.getUIOverride().equalsIgnoreCase("text")) {
082:                        if (isUi("text", ctx.getInstaller().getUi())) {
083:                            ctx.setGui(false);
084:                            return new TextRunner(ctx);
085:                        } else {
086:                            throw new InstallException(
087:                                    "Not a permited UI override, text is not allowed");
088:                        }
089:                    }
090:
091:                    if (ctx.getUIOverride().equalsIgnoreCase("swing-auto")) {
092:                        if (isUi("swing-auto", ctx.getInstaller().getUi())) {
093:                            new LookAndFeelFactory(ctx).setLAF();
094:                            ctx.setGui(true);
095:                            return new AutoSwingRunner(ctx);
096:                        } else {
097:                            throw new InstallException(
098:                                    "Not a permited UI override, swing-auto is not allowed");
099:                        }
100:                    }
101:
102:                    if (ctx.getUIOverride().equalsIgnoreCase("text-auto")) {
103:                        if (isUi("text-auto", ctx.getInstaller().getUi())) {
104:                            ctx.setGui(false);
105:                            return new AutoTextRunner(ctx);
106:                        } else {
107:                            throw new InstallException(
108:                                    "Not a permited UI override, text-auto is not allowed");
109:                        }
110:                    }
111:
112:                }
113:                //else do stuff to work out if there is a graphics context
114:                try {
115:                    java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment();
116:                    /*
117:                     * Above test is not enough to be sure that we can use the graphics env
118:                     * so do remaining setup within try/catch block
119:                     */
120:                    new LookAndFeelFactory(ctx).setLAF();
121:                    ctx.setGui(true);
122:                    return new SwingRunner(ctx);
123:                } catch (Throwable e) {
124:                    System.out
125:                            .println("No graphics environment available, reverting to text");
126:                    System.out.println();
127:                    ctx.setGui(false);
128:                    return new TextRunner(ctx);
129:                }
130:            }
131:
132:            public static boolean isUi(String ui, String commaSeparatedUiList) {
133:                StringTokenizer st = new StringTokenizer(commaSeparatedUiList,
134:                        ",");
135:                while (st.hasMoreTokens()) {
136:                    if (st.nextToken().equals(ui)) {
137:                        return true;
138:                    }
139:                }
140:                return false;
141:            }
142:
143:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.