1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 package org.mycompany.installer.wizard.components.sequences; 20 21 import org.netbeans.installer.wizard.components.sequences.ProductWizardSequence; 22 import java.util.HashMap; 23 import java.util.List; 24 import java.util.Map; 25 import org.mycompany.installer.wizard.components.panels.PostInstallSummaryPanel; 26 import org.mycompany.installer.wizard.components.panels.PreInstallSummaryPanel; 27 import org.netbeans.installer.product.components.Product; 28 import org.netbeans.installer.product.Registry; 29 import org.netbeans.installer.utils.ResourceUtils; 30 import org.netbeans.installer.utils.helper.ExecutionMode; 31 import org.netbeans.installer.wizard.components.WizardSequence; 32 import org.netbeans.installer.wizard.components.actions.DownloadConfigurationLogicAction; 33 import org.netbeans.installer.wizard.components.actions.DownloadInstallationDataAction; 34 import org.netbeans.installer.wizard.components.actions.InstallAction; 35 import org.netbeans.installer.wizard.components.actions.UninstallAction; 36 import org.netbeans.installer.wizard.components.panels.LicensesPanel; 37 38 public class MainSequence extends WizardSequence { 39 ///////////////////////////////////////////////////////////////////////////////// 40 // Instance 41 42 private DownloadConfigurationLogicAction downloadConfigurationLogicAction; 43 private LicensesPanel licensesPanel; 44 private PreInstallSummaryPanel preInstallSummaryPanel; 45 private UninstallAction uninstallAction; 46 private DownloadInstallationDataAction downloadInstallationDataAction; 47 private InstallAction installAction; 48 private PostInstallSummaryPanel postInstallSummaryPanel; 49 private Map<Product, ProductWizardSequence> productSequences; 50 MainSequence()51 public MainSequence() { 52 downloadConfigurationLogicAction = new DownloadConfigurationLogicAction(); 53 licensesPanel = new LicensesPanel(); 54 preInstallSummaryPanel = new PreInstallSummaryPanel(); 55 uninstallAction = new UninstallAction(); 56 downloadInstallationDataAction = new DownloadInstallationDataAction(); 57 installAction = new InstallAction(); 58 postInstallSummaryPanel = new PostInstallSummaryPanel(); 59 productSequences = new HashMap<Product, ProductWizardSequence>(); 60 61 installAction.setProperty(InstallAction.TITLE_PROPERTY, 62 DEFAULT_IA_TITLE); 63 installAction.setProperty(InstallAction.DESCRIPTION_PROPERTY, 64 DEFAULT_IA_DESCRIPTION); 65 } 66 67 @Override executeForward()68 public void executeForward() { 69 final Registry registry = Registry.getInstance(); 70 final List<Product> toInstall = registry.getProductsToInstall(); 71 final List<Product> toUninstall = registry.getProductsToUninstall(); 72 73 // remove all current children (if there are any), as the components 74 // selection has probably changed and we need to rebuild from scratch 75 getChildren().clear(); 76 77 // the set of wizard components differs greatly depending on the execution 78 // mode - if we're installing, we ask for input, run a wizard sequence for 79 // each selected component and then download and install; if we're creating 80 // a bundle, we only need to download and package things 81 82 if (toInstall.size() > 0) { 83 addChild(downloadConfigurationLogicAction); 84 addChild(licensesPanel); 85 86 for (Product product : toInstall) { 87 if (!productSequences.containsKey(product)) { 88 productSequences.put( 89 product, 90 new ProductWizardSequence(product)); 91 } 92 93 addChild(productSequences.get(product)); 94 } 95 } 96 97 addChild(preInstallSummaryPanel); 98 99 if (toUninstall.size() > 0) { 100 addChild(uninstallAction); 101 } 102 103 if (toInstall.size() > 0) { 104 addChild(downloadInstallationDataAction); 105 addChild(installAction); 106 } 107 108 addChild(postInstallSummaryPanel); 109 110 super.executeForward(); 111 } 112 113 @Override canExecuteForward()114 public boolean canExecuteForward() { 115 return ExecutionMode.NORMAL == ExecutionMode.getCurrentExecutionMode() && 116 (Registry.getInstance().getProductsToInstall().size() > 0 || 117 Registry.getInstance().getProductsToUninstall().size() > 0); 118 } 119 ///////////////////////////////////////////////////////////////////////////////// 120 // Constants 121 public static final String DEFAULT_IA_TITLE = 122 ResourceUtils.getString( 123 MainSequence.class, 124 "MS.IA.title"); // NOI18N 125 public static final String DEFAULT_IA_DESCRIPTION = 126 ResourceUtils.getString( 127 MainSequence.class, 128 "MS.IA.description"); // NOI18N 129 130 } 131