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.sequences;
038:
039: import java.util.HashMap;
040: import java.util.List;
041: import java.util.Map;
042: import org.netbeans.installer.product.components.Product;
043: import org.netbeans.installer.product.Registry;
044: import org.netbeans.installer.utils.ErrorManager;
045: import org.netbeans.installer.utils.ResourceUtils;
046: import org.netbeans.installer.utils.helper.ExecutionMode;
047: import org.netbeans.installer.utils.helper.Platform;
048: import org.netbeans.installer.wizard.components.WizardSequence;
049: import org.netbeans.installer.wizard.components.actions.CreateBundleAction;
050: import org.netbeans.installer.wizard.components.actions.CreateMacOSAppLauncherAction;
051: import org.netbeans.installer.wizard.components.actions.CreateNativeLauncherAction;
052: import org.netbeans.installer.wizard.components.actions.DownloadConfigurationLogicAction;
053: import org.netbeans.installer.wizard.components.actions.DownloadInstallationDataAction;
054: import org.netbeans.installer.wizard.components.actions.InstallAction;
055: import org.netbeans.installer.wizard.components.actions.UninstallAction;
056: import org.netbeans.installer.wizard.components.panels.PostCreateBundleSummaryPanel;
057: import org.netbeans.installer.wizard.components.panels.PreCreateBundleSummaryPanel;
058: import org.netbeans.installer.wizard.components.panels.LicensesPanel;
059: import org.netbeans.installer.wizard.components.panels.PostInstallSummaryPanel;
060: import org.netbeans.installer.wizard.components.panels.PreInstallSummaryPanel;
061:
062: /**
063: *
064: * @author Kirill Sorokin
065: */
066: public class MainSequence extends WizardSequence {
067: private DownloadConfigurationLogicAction downloadConfigurationLogicAction;
068: private LicensesPanel licensesPanel;
069: private PreInstallSummaryPanel preInstallSummaryPanel;
070: private UninstallAction uninstallAction;
071: private DownloadInstallationDataAction downloadInstallationDataAction;
072: private InstallAction installAction;
073: private PostInstallSummaryPanel postInstallSummaryPanel;
074: private PreCreateBundleSummaryPanel preCreateBundleSummaryPanel;
075: private CreateBundleAction createBundleAction;
076: private CreateNativeLauncherAction createNativeLauncherAction;
077: private CreateMacOSAppLauncherAction createAppLauncherAction;
078: private PostCreateBundleSummaryPanel postCreateBundleSummaryPanel;
079:
080: private Map<Product, ProductWizardSequence> productSequences;
081:
082: public MainSequence() {
083: downloadConfigurationLogicAction = new DownloadConfigurationLogicAction();
084: licensesPanel = new LicensesPanel();
085: preInstallSummaryPanel = new PreInstallSummaryPanel();
086: uninstallAction = new UninstallAction();
087: downloadInstallationDataAction = new DownloadInstallationDataAction();
088: installAction = new InstallAction();
089: postInstallSummaryPanel = new PostInstallSummaryPanel();
090: preCreateBundleSummaryPanel = new PreCreateBundleSummaryPanel();
091: createBundleAction = new CreateBundleAction();
092: createNativeLauncherAction = new CreateNativeLauncherAction();
093: createAppLauncherAction = new CreateMacOSAppLauncherAction();
094: postCreateBundleSummaryPanel = new PostCreateBundleSummaryPanel();
095:
096: productSequences = new HashMap<Product, ProductWizardSequence>();
097: }
098:
099: public void executeForward() {
100: final Registry registry = Registry.getInstance();
101: final List<Product> toInstall = registry.getProductsToInstall();
102: final List<Product> toUninstall = registry
103: .getProductsToUninstall();
104:
105: // remove all current children (if there are any), as the components
106: // selection has probably changed and we need to rebuild from scratch
107: getChildren().clear();
108:
109: // the set of wizard components differs greatly depending on the execution
110: // mode - if we're installing, we ask for input, run a wizard sequence for
111: // each selected component and then download and install; if we're creating
112: // a bundle, we only need to download and package things
113: switch (ExecutionMode.getCurrentExecutionMode()) {
114: case NORMAL:
115: if (toInstall.size() > 0) {
116: addChild(downloadConfigurationLogicAction);
117: addChild(licensesPanel);
118:
119: for (Product product : toInstall) {
120: if (!productSequences.containsKey(product)) {
121: productSequences.put(product,
122: new ProductWizardSequence(product));
123: }
124:
125: addChild(productSequences.get(product));
126: }
127: }
128:
129: addChild(preInstallSummaryPanel);
130:
131: if (toUninstall.size() > 0) {
132: addChild(uninstallAction);
133: }
134:
135: if (toInstall.size() > 0) {
136: addChild(downloadInstallationDataAction);
137: addChild(installAction);
138: }
139:
140: addChild(postInstallSummaryPanel);
141: break;
142: case CREATE_BUNDLE:
143: addChild(preCreateBundleSummaryPanel);
144: addChild(downloadConfigurationLogicAction);
145: addChild(downloadInstallationDataAction);
146: addChild(createBundleAction);
147:
148: if (registry.getTargetPlatform().isCompatibleWith(
149: Platform.MACOSX)) {
150: addChild(createAppLauncherAction);
151: } else {
152: addChild(createNativeLauncherAction);
153: }
154: addChild(postCreateBundleSummaryPanel);
155: break;
156: default:
157: // there is no real way to recover from this fancy error, so we
158: // inform the user and die
159: ErrorManager.notifyCritical(ResourceUtils.getString(
160: MainSequence.class, ERROR_UKNOWN_MODE_KEY));
161: }
162:
163: super .executeForward();
164: }
165:
166: public boolean canExecuteForward() {
167: return true;
168: }
169:
170: private static final String ERROR_UKNOWN_MODE_KEY = "MS.error.mode"; //NOI18N
171: }
|