Source Code Cross Referenced for DownloadInstallationDataAction.java in  » IDE-Netbeans » nbi » org » netbeans » installer » wizard » components » actions » 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 » IDE Netbeans » nbi » org.netbeans.installer.wizard.components.actions 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         * 
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         * 
006:         * The contents of this file are subject to the terms of either the GNU General
007:         * Public License Version 2 only ("GPL") or the Common Development and Distribution
008:         * License("CDDL") (collectively, the "License"). You may not use this file except in
009:         * compliance with the License. You can obtain a copy of the License at
010:         * http://www.netbeans.org/cddl-gplv2.html or nbbuild/licenses/CDDL-GPL-2-CP. See the
011:         * License for the specific language governing permissions and limitations under the
012:         * License.  When distributing the software, include this License Header Notice in
013:         * each file and include the License file at nbbuild/licenses/CDDL-GPL-2-CP.  Sun
014:         * designates this particular file as subject to the "Classpath" exception as
015:         * provided by Sun in the GPL Version 2 section of the License file that
016:         * accompanied this code. If applicable, add the following below the License Header,
017:         * with the fields enclosed by brackets [] replaced by your own identifying
018:         * information: "Portions Copyrighted [year] [name of copyright owner]"
019:         * 
020:         * Contributor(s):
021:         * 
022:         * The Original Software is NetBeans. The Initial Developer of the Original Software
023:         * is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun Microsystems, Inc. All
024:         * Rights Reserved.
025:         * 
026:         * If you wish your version of this file to be governed by only the CDDL or only the
027:         * GPL Version 2, indicate your decision by adding "[Contributor] elects to include
028:         * this software in this distribution under the [CDDL or GPL Version 2] license." If
029:         * you do not indicate a single choice of license, a recipient has the option to
030:         * distribute your version of this file under either the CDDL, the GPL Version 2 or
031:         * to extend the choice of license to its licensees as provided above. However, if
032:         * you add GPL Version 2 code and therefore, elected the GPL Version 2 license, then
033:         * the option applies only if the new code is made subject to such option by the
034:         * copyright holder.
035:         */
036:
037:        package org.netbeans.installer.wizard.components.actions;
038:
039:        import java.util.List;
040:        import org.netbeans.installer.product.components.Product;
041:        import org.netbeans.installer.product.Registry;
042:        import org.netbeans.installer.product.RegistryType;
043:        import org.netbeans.installer.utils.helper.Status;
044:        import org.netbeans.installer.utils.helper.ErrorLevel;
045:        import org.netbeans.installer.utils.LogManager;
046:        import org.netbeans.installer.utils.ResourceUtils;
047:        import org.netbeans.installer.utils.StringUtils;
048:        import org.netbeans.installer.utils.SystemUtils;
049:        import org.netbeans.installer.utils.exceptions.DownloadException;
050:        import org.netbeans.installer.utils.exceptions.InstallationException;
051:        import org.netbeans.installer.utils.progress.CompositeProgress;
052:        import org.netbeans.installer.utils.progress.Progress;
053:        import org.netbeans.installer.wizard.components.WizardAction;
054:
055:        public class DownloadInstallationDataAction extends WizardAction {
056:            /////////////////////////////////////////////////////////////////////////////////
057:            // Constants
058:            public static final String DEFAULT_TITLE = ResourceUtils.getString(
059:                    DownloadInstallationDataAction.class, "DIDA.title"); // NOI18N
060:            public static final String DEFAULT_DESCRIPTION = ResourceUtils
061:                    .getString(DownloadInstallationDataAction.class,
062:                            "DIDA.description"); // NOI18N
063:
064:            public static final String DEFAULT_PROGRESS_TITLE_LOCAL = ResourceUtils
065:                    .getString(DownloadInstallationDataAction.class,
066:                            "DIDA.progress.local.title"); //NOI18N
067:            public static final String PROGRESS_TITLE_LOCAL_PROPERTY = "progress.title.local";//NOI18N
068:
069:            public static final String DEFAULT_PROGRESS_TITLE_REMOTE = ResourceUtils
070:                    .getString(DownloadInstallationDataAction.class,
071:                            "DIDA.progress.remote.title"); //NOI18N
072:            public static final String PROGRESS_TITLE_REMOTE_PROPERTY = "progress.title.remote";//NOI18N
073:
074:            public static final String DEFAULT_DOWNLOAD_FAILED_EXCEPTION = ResourceUtils
075:                    .getString(DownloadInstallationDataAction.class,
076:                            "DIDA.failed"); //NOI18N
077:            public static final String DOWNLOAD_FAILED_EXCEPTION_PROPERTY = "download.failed";//NOI18N
078:
079:            public static final String DEFAULT_DEPENDENT_FAILED_EXCEPTION = ResourceUtils
080:                    .getString(DownloadInstallationDataAction.class,
081:                            "DIDA.dependent.failed"); //NOI18N    
082:            public static final String DEPENDENT_FAILED_EXCEPTION_PROPERTY = "download.dependent.failed"; //NOI18N
083:
084:            /////////////////////////////////////////////////////////////////////////////////
085:            // Instance
086:            private CompositeProgress overallProgress;
087:            private Progress currentProgress;
088:
089:            public DownloadInstallationDataAction() {
090:                setProperty(TITLE_PROPERTY, DEFAULT_TITLE);
091:                setProperty(DESCRIPTION_PROPERTY, DEFAULT_DESCRIPTION);
092:                setProperty(PROGRESS_TITLE_LOCAL_PROPERTY,
093:                        DEFAULT_PROGRESS_TITLE_LOCAL);
094:                setProperty(PROGRESS_TITLE_REMOTE_PROPERTY,
095:                        DEFAULT_PROGRESS_TITLE_REMOTE);
096:                setProperty(DOWNLOAD_FAILED_EXCEPTION_PROPERTY,
097:                        DEFAULT_DOWNLOAD_FAILED_EXCEPTION);
098:                setProperty(DEPENDENT_FAILED_EXCEPTION_PROPERTY,
099:                        DEFAULT_DEPENDENT_FAILED_EXCEPTION);
100:            }
101:
102:            public void execute() {
103:                LogManager.logEntry("getting all installation data");
104:                final Registry registry = Registry.getInstance();
105:                final List<Product> products = registry.getProductsToInstall();
106:                final int percentageChunk = Progress.COMPLETE / products.size();
107:                final int percentageLeak = Progress.COMPLETE % products.size();
108:
109:                overallProgress = new CompositeProgress();
110:                overallProgress.setPercentage(percentageLeak);
111:                overallProgress.synchronizeDetails(true);
112:
113:                getWizardUi().setProgress(overallProgress);
114:                for (int i = 0; i < products.size(); i++) {
115:                    // get the handle of the current item
116:                    final Product product = products.get(i);
117:
118:                    // initiate the progress for the current element
119:                    currentProgress = new Progress();
120:
121:                    overallProgress.addChild(currentProgress, percentageChunk);
122:                    try {
123:                        String prop = product.getRegistryType() == RegistryType.REMOTE ? PROGRESS_TITLE_REMOTE_PROPERTY
124:                                : PROGRESS_TITLE_LOCAL_PROPERTY;
125:                        String overallProgressTitle = StringUtils.format(
126:                                getProperty(prop), product.getDisplayName());
127:                        overallProgress.setTitle(overallProgressTitle);
128:
129:                        product.downloadData(currentProgress);
130:
131:                        // check for cancel status
132:                        if (isCanceled())
133:                            return;
134:
135:                        // sleep a little so that the user can perceive that something
136:                        // is happening
137:                        SystemUtils.sleep(200);
138:                    } catch (DownloadException e) {
139:                        // wrap the download exception with a more user-friendly one
140:                        InstallationException error = new InstallationException(
141:                                StringUtils
142:                                        .format(
143:                                                getProperty(DOWNLOAD_FAILED_EXCEPTION_PROPERTY),
144:                                                product.getDisplayName()), e);
145:
146:                        // adjust the product's status and save this error - it will
147:                        // be reused later at the PostInstallSummary
148:                        product.setStatus(Status.NOT_INSTALLED);
149:                        product.setInstallationError(error);
150:
151:                        // since the installation data for the current product failed to
152:                        // be downloaded, we should cancel the installation of the products
153:                        // that may require this one
154:                        for (Product dependent : registry.getProducts()) {
155:                            if ((dependent.getStatus() == Status.TO_BE_INSTALLED)
156:                                    && registry.satisfiesRequirement(product,
157:                                            dependent)) {
158:                                String exString = StringUtils
159:                                        .format(
160:                                                getProperty(DEPENDENT_FAILED_EXCEPTION_PROPERTY),
161:                                                dependent.getDisplayName(),
162:                                                product.getDisplayName());
163:
164:                                final InstallationException dependentError = new InstallationException(
165:                                        exString, error);
166:
167:                                dependent.setStatus(Status.NOT_INSTALLED);
168:                                dependent.setInstallationError(dependentError);
169:
170:                                products.remove(dependent);
171:                            }
172:                        }
173:
174:                        // finally notify the user of what has happened
175:                        LogManager.log(ErrorLevel.ERROR, error);
176:                    }
177:                }
178:                LogManager
179:                        .logExit("... finished getting of the installation data");
180:            }
181:
182:            public void cancel() {
183:                if (currentProgress != null) {
184:                    currentProgress.setCanceled(true);
185:                }
186:
187:                if (overallProgress != null) {
188:                    overallProgress.setCanceled(true);
189:                }
190:
191:                super .cancel();
192:            }
193:
194:            public boolean canExecuteForward() {
195:                return Registry.getInstance().getProductsToInstall().size() > 0;
196:            }
197:
198:            public boolean isPointOfNoReturn() {
199:                return true;
200:            }
201:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.