Beispiel #1
0
  @Override
  public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
    if (columnIndex == 0) {
      if (aValue instanceof Integer) {
        Pack pack = packs.get(rowIndex);
        boolean packadded = false;
        if ((Integer) aValue == 1) {
          packadded = true;
          String packid = pack.getLangPackId(); // TODO - see IZPACK-799
          if (packid != null) {
            if (this.rules.canInstallPack(packid, this.variables)
                || this.rules.canInstallPackOptional(packid, this.variables)) {
              if (pack.isRequired()) {
                checkValues[rowIndex] = -1;
              } else {
                checkValues[rowIndex] = 1;
              }
            }
          } else {
            if (pack.isRequired()) {
              checkValues[rowIndex] = -1;
            } else {
              checkValues[rowIndex] = 1;
            }
          }
        } else {
          packadded = false;
          checkValues[rowIndex] = 0;
        }
        updateExcludes(rowIndex);
        updateDeps();

        if (packadded) {
          if (panel.getDebugger() != null) {
            panel.getDebugger().packSelectionChanged("after adding pack " + pack.getLangPackId());
          }
          // temporarily add pack to packstoinstall
          this.packsToInstall.add(pack);
        } else {
          if (panel.getDebugger() != null) {
            panel.getDebugger().packSelectionChanged("after removing pack " + pack.getLangPackId());
          }
          // temporarily remove pack from packstoinstall
          this.packsToInstall.remove(pack);
        }
        updateConditions();
        if (packadded) {
          // redo
          this.packsToInstall.remove(pack);
        } else {
          // redo
          this.packsToInstall.add(pack);
        }
        refreshPacksToInstall();
        updateBytes();
        fireTableDataChanged();
        panel.showSpaceRequired();
      }
    }
  }
Beispiel #2
0
 /**
  * This function updates the checkboxes after a change by disabling packs that cannot be installed
  * anymore and enabling those that can after the change. This is accomplished by running a search
  * that pinpoints the packs that must be disabled by a non-fullfiled dependency. TODO: Look into
  * "+2" and "-2", doesn't look safe
  */
 protected void updateDeps() {
   int[] statusArray = new int[packs.size()];
   for (int i = 0; i < statusArray.length; i++) {
     statusArray[i] = 0;
   }
   dfs(statusArray);
   for (int i = 0; i < statusArray.length; i++) {
     if (statusArray[i] == 0 && checkValues[i] < 0) {
       checkValues[i] += PARTIAL_SELECTED;
     }
     if (statusArray[i] == 1 && checkValues[i] >= 0) {
       checkValues[i] = DEPENDENT_DESELECTED;
     }
   }
   // The required ones must propagate their required status to all the ones that they depend on
   for (Pack pack : packs) {
     if (pack.isRequired()) {
       String name = pack.getName();
       if (!(!rules.canInstallPack(name, variables)
           && rules.canInstallPackOptional(name, variables))) {
         checkValues = propRequirement(name, checkValues);
       }
     }
   }
 }
Beispiel #3
0
  /**
   * Select/Deselect pack(s) based on packsData mapping. This is related to the onSelect and
   * onDeselect attributes for packs. User is not allowed to has a required pack for onSelect and
   * onDeselect.
   *
   * @param packsData
   */
  private void selectionUpdate(Map<String, String> packsData) {
    RulesEngine rules = installData.getRules();
    for (Map.Entry<String, String> packData : packsData.entrySet()) {
      int value, packPos;
      String packName = packData.getKey();
      String condition = packData.getValue();

      if (condition != null && !rules.isConditionTrue(condition)) {
        return; // Do nothing if condition is false
      }

      Pack pack;

      if (packName.startsWith("!")) {
        packName = packName.substring(1);
        pack = nameToPack.get(packName);
        packPos = getPos(packName);
        value = DESELECTED;
      } else {
        pack = nameToPack.get(packName);
        packPos = getPos(packName);
        value = SELECTED;
      }
      if (!pack.isRequired() && dependenciesResolved(pack)) {
        checkValues[packPos] = value;
      }
    }
  }
Beispiel #4
0
 /**
  * This function updates the checkboxes after a change by disabling packs that cannot be installed
  * anymore and enabling those that can after the change. This is accomplished by running a search
  * that pinpoints the packs that must be disabled by a non-fullfiled dependency.
  */
 private void updateDeps() {
   int[] statusArray = new int[packs.size()];
   for (int i = 0; i < statusArray.length; i++) {
     statusArray[i] = 0;
   }
   dfs(statusArray);
   for (int i = 0; i < statusArray.length; i++) {
     if (statusArray[i] == 0 && checkValues[i] < 0) {
       checkValues[i] += 2;
     }
     if (statusArray[i] == 1 && checkValues[i] >= 0) {
       checkValues[i] = -2;
     }
   }
   // The required ones must propagate their required status to all the
   // ones
   // that they depend on
   for (Pack pack : packs) {
     if (pack.isRequired()) {
       String packid = pack.getLangPackId();
       if (packid != null) {
         if (!(!this.rules.canInstallPack(packid, this.variables)
             && this.rules.canInstallPackOptional(packid, this.variables))) {
           propRequirement(pack.getName());
         }
       } else {
         propRequirement(pack.getName());
       }
     }
   }
 }
Beispiel #5
0
  private void initvalues() {
    // name to pack position map
    namesPos = new HashMap<String, Integer>();
    for (int i = 0; i < packs.size(); i++) {
      Pack pack = packs.get(i);
      namesPos.put(pack.getName(), i);
    }
    // Init to the first values
    for (int i = 0; i < packs.size(); i++) {
      Pack pack = packs.get(i);
      if (packsToInstall.contains(pack)) {
        checkValues[i] = 1;
      }
    }

    // Check out and disable the ones that are excluded by non fullfiled
    // deps
    for (int i = 0; i < packs.size(); i++) {
      Pack pack = packs.get(i);
      if (checkValues[i] == 0) {
        List<String> deps = pack.getDependants();
        for (int j = 0; deps != null && j < deps.size(); j++) {
          String name = deps.get(j);
          int pos = getPos(name);
          checkValues[pos] = -2;
        }
      }
      // for mutual exclusion, uncheck uncompatible packs too
      // (if available in the current installGroup)

      if (checkValues[i] > 0 && pack.getExcludeGroup() != null) {
        for (int q = 0; q < packs.size(); q++) {
          if (q != i) {
            Pack otherpack = packs.get(q);
            if (pack.getExcludeGroup().equals(otherpack.getExcludeGroup())) {
              if (checkValues[q] == 1) {
                checkValues[q] = 0;
              }
            }
          }
        }
      }
    }
    // The required ones must propagate their required status to all the
    // ones
    // that they depend on
    for (Pack pack : packs) {
      if (pack.isRequired()) {
        propRequirement(pack.getName());
      }
    }

    refreshPacksToInstall();
  }
  @Override
  public boolean runConsole(InstallData installData, Console console) {
    java.util.List<Pack> selectedPacks = new ArrayList<Pack>();
    String installationMode = null;

    do {
      installationMode =
          console.prompt("Do you to execute the defaut installation ? Y for yes, N for no", null);
    } while (!isGoodValue(installationMode));
    if (isYes(installationMode)) {
      for (Pack p : installData.getAvailablePacks()) {
        if (p.isRequired() || p.isPreselected()) {
          selectedPacks.add(p);
        }
      }
    } else if (isNo(installationMode)) {
      for (Pack p : installData.getAvailablePacks()) {

        if (p.isRequired()) {
          selectedPacks.add(p);
        } else {
          String packToInstall = null;

          do {
            packToInstall =
                console.prompt(
                    "Do you want to install  [" + p.getName() + "] Y for yes, N for no ", null);
          } while (!isGoodValue(packToInstall));

          if (isYes(packToInstall)) {
            selectedPacks.add(p);
          } else if (isNo(packToInstall)) {
            console.println("Installation of " + p.getName() + " skipped");
          }
        }
      }
    }
    installData.setSelectedPacks(selectedPacks);
    return promptEndPanel(installData, console);
  }
Beispiel #7
0
  /*
   * @see TableModel#setValueAt(Object, int, int)
   * Update the value of some checkbox
   */
  @Override
  public void setValueAt(Object checkValue, int rowIndex, int columnIndex) {
    if (columnIndex != 0 || !(checkValue instanceof Integer)) {
      return;
    } else {
      Pack pack = packs.get(rowIndex);

      boolean added;
      if ((Integer) checkValue == SELECTED) {
        added = true;
        String name = pack.getName();
        if (rules.canInstallPack(name, variables)
            || rules.canInstallPackOptional(name, variables)) {
          if (pack.isRequired()) {
            checkValues[rowIndex] = REQUIRED_SELECTED;
          } else {
            checkValues[rowIndex] = SELECTED;
          }
        }
      } else {
        added = false;
        checkValues[rowIndex] = DESELECTED;
      }

      updateExcludes(rowIndex);
      updateDeps();

      if (added) {
        onSelectionUpdate(rowIndex);
        this.packsToInstall.add(pack); // Temporarily add
        updateConditions();
        this.packsToInstall.remove(pack); // Redo
      } else {
        onDeselectionUpdate(rowIndex);
        this.packsToInstall.remove(pack); // Temporarily remove
        updateConditions();
        this.packsToInstall.add(pack); // Redo
      }

      updatePacksToInstall();

      if (pack.hasParent()) {
        updateParent(pack);
      } else if (pack.hasChildren()) {
        updateChildren(pack);
      }

      fireTableDataChanged();
    }
  }
Beispiel #8
0
  /**
   * Initialize the data that represented the checkbox states.
   *
   * @param packs
   * @param packsToInstall
   * @return
   */
  private int[] initCheckValues(List<Pack> packs, List<Pack> packsToInstall) {
    int[] checkValues = new int[packs.size()];

    // If a pack is indicated to be installed checkbox value should be SELECTED
    for (int i = 0; i < packs.size(); i++) {
      Pack pack = packs.get(i);
      if (packsToInstall.contains(pack)) {
        checkValues[i] = SELECTED;
      }
    }

    // If a packs dependency cannot be resolved checkboc value should be DEPENDENT_DESELECTED
    for (int i = 0; i < packs.size(); i++) {
      Pack pack = packs.get(i);
      if (checkValues[i] == DESELECTED) {
        List<String> deps = pack.getDependants();
        for (int j = 0; deps != null && j < deps.size(); j++) {
          String name = deps.get(j);
          int pos = getPos(name);
          checkValues[pos] = DEPENDENT_DESELECTED;
        }
      }

      // for mutual exclusion, uncheck uncompatible packs too
      // (if available in the current installGroup)
      if (checkValues[i] > 0 && pack.getExcludeGroup() != null) {
        for (int q = 0; q < packs.size(); q++) {
          if (q != i) {
            Pack otherPack = packs.get(q);
            if (pack.getExcludeGroup().equals(otherPack.getExcludeGroup())) {
              if (checkValues[q] == SELECTED) {
                checkValues[q] = DESELECTED;
              }
            }
          }
        }
      }
    }

    // Configure required packs
    for (Pack pack : packs) {
      if (pack.isRequired()) {
        checkValues = propRequirement(pack.getName(), checkValues);
      }
    }

    return checkValues;
  }