Exemplo n.º 1
0
  public PacksModel(InstallData idata) {
    this.installData = idata;
    this.rules = idata.getRules();
    try {
      this.messages = idata.getMessages().newMessages(PackHelper.LANG_FILE_NAME);
    } catch (com.izforge.izpack.api.exception.ResourceNotFoundException ex) {
      this.messages = idata.getMessages();
    }
    this.variables = idata.getVariables();
    this.packsToInstall = idata.getSelectedPacks();

    this.modifyInstallation = Boolean.valueOf(idata.getVariable(InstallData.MODIFY_INSTALLATION));
    this.installedPacks = loadInstallationInformation(modifyInstallation);

    this.packs = getVisiblePacks();
    this.hiddenPacks = getHiddenPacks();
    this.allPacks = idata.getAvailablePacks();
    this.nameToRow = getNametoRowMapping(packs);
    this.nameToPack = getNametoPackMapping(allPacks);

    this.packs = setPackProperties(packs, nameToPack);
    this.checkValues = initCheckValues(packs, packsToInstall);

    updateConditions(true);
    updatePacksToInstall();
  }
Exemplo n.º 2
0
  private Map<String, Pack> loadInstallationInformation(boolean modifyInstallation) {
    Map<String, Pack> installedpacks = new HashMap<String, Pack>();
    if (!modifyInstallation) {
      return installedpacks;
    }

    // installation shall be modified
    // load installation information
    ObjectInputStream oin = null;
    try {
      FileInputStream fin =
          new FileInputStream(
              new File(
                  installData.getInstallPath()
                      + File.separator
                      + InstallData.INSTALLATION_INFORMATION));
      oin = new ObjectInputStream(fin);
      List<Pack> packsinstalled = (List<Pack>) oin.readObject();
      for (Pack installedpack : packsinstalled) {
        installedpacks.put(installedpack.getName(), installedpack);
      }
      this.removeAlreadyInstalledPacks(installData.getSelectedPacks());
      logger.fine("Found " + packsinstalled.size() + " installed packs");

      Properties variables = (Properties) oin.readObject();

      for (Object key : variables.keySet()) {
        installData.setVariable((String) key, (String) variables.get(key));
      }
    } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (ClassNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } finally {
      if (oin != null) {
        try {
          oin.close();
        } catch (IOException e) {
        }
      }
    }
    return installedpacks;
  }