Source Code Cross Referenced for Installer.java in  » Installer » AntInstaller » org » tp23 » antinstaller » 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 
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;
017:
018:        import java.util.List;
019:        import java.util.Vector;
020:
021:        import org.tp23.antinstaller.input.OutputField;
022:        import org.tp23.antinstaller.input.ResultContainer;
023:        import org.tp23.antinstaller.page.Page;
024:        import org.tp23.antinstaller.renderer.AILanguagePack;
025:        import org.tp23.antinstaller.renderer.swing.SizeConstants;
026:        import org.tp23.antinstaller.runtime.IfPropertyHelper;
027:        import org.tp23.antinstaller.runtime.exe.ExecuteRunnerFilter.AbortException;
028:
029:        /**
030:         * <p>Object representation of the Installer element in the config. </p>
031:         * <p>This object holds the reference to all the Pages which in tern hold references
032:         * to the InputFields,  All the properties in the Installer element are held at this level
033:         * as is the ResultContainer</p>
034:         * @author Paul Hinds
035:         * @version $Id: Installer.java,v 1.9 2007/01/28 08:44:41 teknopaul Exp $
036:         */
037:        public class Installer {
038:
039:            private static final AILanguagePack langPack = new AILanguagePack();
040:
041:            private static final String BACKGROUND_RESOURCE = "/resources/background-image.png";
042:            private String name;
043:            private String minJavaVersion = "1.4";
044:            private String ui;// permitted UI override values
045:            private boolean verbose;
046:            private boolean debug;
047:            private String lookAndFeel;
048:            private String wide;
049:            private String high;
050:            private String windowIcon;
051:            private String defaultImageResource;
052:            private String finishButtonText = "Install";
053:            private String antialiased;
054:            private String loadDefaults;
055:            private String version = "0.0";
056:
057:            private Page[] pages;
058:            private boolean hasPostDisplayTargets = false;
059:
060:            private Page langPage;
061:            private ResultContainer resultContainer = new ResultContainer();
062:
063:            public Installer() {
064:            }
065:
066:            public String getName() {
067:                return name;
068:            }
069:
070:            public void setName(String name) {
071:                this .name = name;
072:            }
073:
074:            public String getMinJavaVersion() {
075:                return minJavaVersion;
076:            }
077:
078:            public void setMinJavaVersion(String minJavaVersion)
079:                    throws AbortException {
080:                this .minJavaVersion = minJavaVersion;
081:            }
082:
083:            public Page[] getPages() {
084:                return pages;
085:            }
086:
087:            public void setPages(Page[] pages) {
088:                this .pages = pages;
089:                for (int i = 0; i < pages.length; i++) {
090:                    if (pages[i].getPostDisplayTarget() != null) {
091:                        setHasPostDisplayTargets(true);
092:                        return;
093:                    }
094:                }
095:            }
096:
097:            /**
098:             * returns full ui attribute with spaces removed (the string is not parsed into tokens).
099:             * e.g.  "text,swint,swing-auto"
100:             * @return ui attribute
101:             */
102:            public String getUi() {
103:                return ui;
104:            }
105:
106:            /**
107:             * Sets the ui attrribute removing any whitespace
108:             * @param ui string containing one or more permitted user interface types
109:             */
110:            public void setUi(String ui) {
111:                this .ui = ui.replaceAll("\\s", "");
112:            }
113:
114:            public boolean supportsAutoBuild() {
115:                return ui != null && ui.indexOf("-auto") > -1;
116:            }
117:
118:            public boolean isVerbose() {
119:                return verbose;
120:            }
121:
122:            public void setVerbose(boolean verbose) {
123:                this .verbose = verbose;
124:            }
125:
126:            public void setVerbose(String strVerbose) {
127:                this .verbose = OutputField.isTrue(strVerbose);
128:            }
129:
130:            public boolean isDebug() {
131:                return debug;
132:            }
133:
134:            public void setDebug(boolean debug) {
135:                this .debug = debug;
136:            }
137:
138:            public void setDebug(String strDebug) {
139:                this .debug = OutputField.isTrue(strDebug);
140:            }
141:
142:            public String getLookAndFeel() {
143:                return lookAndFeel;
144:            }
145:
146:            public void setLookAndFeel(String lookAndFeel) {
147:                this .lookAndFeel = lookAndFeel;
148:            }
149:
150:            public String getWindowIcon() {
151:                return windowIcon;
152:            }
153:
154:            public void setWindowIcon(String windowIcon) {
155:                this .windowIcon = windowIcon;
156:            }
157:
158:            public String getDefaultImageResource() {
159:                return defaultImageResource;
160:            }
161:
162:            public void setDefaultImageResource(String defaultImageResource) {
163:                this .defaultImageResource = defaultImageResource;
164:            }
165:
166:            public String getFinishButtonText() {
167:                if (AILanguagePack.isI18n()) {
168:                    return langPack.getString("finishButtonText");
169:                }
170:                return finishButtonText;
171:            }
172:
173:            public void setFinishButtonText(String finishButtonText) {
174:                this .finishButtonText = finishButtonText;
175:            }
176:
177:            public ResultContainer getResultContainer() {
178:                return resultContainer;
179:            }
180:
181:            public String getAntialiased() {
182:                return antialiased;
183:            }
184:
185:            public void setAntialiased(String antialiased) {
186:                this .antialiased = antialiased;
187:            }
188:
189:            public String getWide() {
190:                return wide;
191:            }
192:
193:            public void setWide(String wide) {
194:                try {
195:                    this .wide = wide;
196:                    parseWideValue(wide);
197:                } catch (Exception e) {
198:                    // ignore use defaults
199:                }
200:            }
201:
202:            public void parseWideValue(String wide)
203:                    throws NumberFormatException,
204:                    StringIndexOutOfBoundsException {
205:                int pageWidth = Integer.parseInt(wide.substring(0, wide
206:                        .indexOf(':')));
207:                int labelWidth = Integer.parseInt(wide.substring(wide
208:                        .indexOf(':') + 1, wide.length()));
209:                SizeConstants.PAGE_WIDTH = pageWidth;
210:                SizeConstants.LABEL_WIDTH = labelWidth;
211:                SizeConstants.recalculate();
212:            }
213:
214:            public String getHigh() {
215:                return high;
216:            }
217:
218:            public void setHigh(String high) {
219:                try {
220:                    this .high = high;
221:                    SizeConstants.PAGE_HEIGHT = Integer.parseInt(high);
222:                    SizeConstants.recalculate();
223:                } catch (Exception e) {
224:                    // ignore use defaults
225:                }
226:            }
227:
228:            public String getLoadDefaults() {
229:                return loadDefaults;
230:            }
231:
232:            public void setLoadDefaults(String loadDefaults) {
233:                this .loadDefaults = loadDefaults;
234:            }
235:
236:            /**
237:             * Returns the list of selected targets from the installer obeying
238:             * page order. This method is
239:             * probably only usefull after the UI screens have finished.  Using prior to that
240:             * bear in mind that the user in the Swing GUI can go back and reselect
241:             * targets that were not selected previously.
242:             * Page targets for pages that were not shown are not returned in the list
243:             *
244:             * @param ctx Installer context
245:             * @return Returns a Vector since Ant requires this for the Project class (Should be a List)
246:             */
247:            public Vector getTargets(InstallerContext ctx) {
248:                Vector argsList = new Vector();
249:                for (int i = 0; i < getPages().length; i++) {
250:                    Page page = getPages()[i];
251:                    List pageTargets = page.getPageTargets();
252:                    boolean shown = conditionalDisplay(page, ctx);
253:                    for (int pt = 0; pt < pageTargets.size(); pt++) {
254:                        Page.IndexedTarget target = (Page.IndexedTarget) pageTargets
255:                                .get(pt);
256:                        if (!argsList.contains(target.getTarget()) && shown) {
257:                            argsList.add(target.getTarget());
258:                        }
259:                    }
260:                    List elementTargets = page.getElementTargets();
261:                    for (int pt = 0; pt < elementTargets.size(); pt++) {
262:                        Page.IndexedTarget target = (Page.IndexedTarget) elementTargets
263:                                .get(pt);
264:                        if (!argsList.contains(target.getTarget())) {
265:                            argsList.add(target.getTarget());
266:                        }
267:                    }
268:                }
269:                return argsList;
270:            }
271:
272:            /**
273:             * @param page page to be checked for display
274:             * @param ctx installer context
275:             * @return boolean true if the page was to be shown
276:             */
277:            private boolean conditionalDisplay(Page page, InstallerContext ctx) {
278:                try {
279:                    IfPropertyHelper helper = new IfPropertyHelper(ctx);
280:                    return helper.ifProperty(page)
281:                            && helper.ifTarget(page, ctx.getInstaller()
282:                                    .getPages());
283:                } catch (InstallException e) {
284:                    throw new RuntimeException("ifProperty runtime exception");
285:                }
286:            }
287:
288:            public String getVersion() {
289:                return version;
290:            }
291:
292:            public void setVersion(String version) {
293:                this .version = version;
294:            }
295:
296:            public String getBackground() {
297:                return BACKGROUND_RESOURCE;
298:            }
299:
300:            public Page getLangPage() {
301:                return langPage;
302:            }
303:
304:            public void setLangPage(Page prePage) {
305:                this .langPage = prePage;
306:            }
307:
308:            public boolean hasPostDisplayTargets() {
309:                return hasPostDisplayTargets;
310:            }
311:
312:            public void setHasPostDisplayTargets(boolean hasPostDisplayTargets) {
313:                this.hasPostDisplayTargets = hasPostDisplayTargets;
314:            }
315:
316:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.