Esempio n. 1
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();
  }
Esempio n. 2
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;
  }
Esempio n. 3
0
 /*
  * Sees which packs (if any) should be unchecked and updates checkValues
  */
 protected void updateExcludes(int rowindex) {
   int value = checkValues[rowindex];
   Pack pack = packs.get(rowindex);
   if (value > 0 && pack.getExcludeGroup() != null) {
     for (int q = 0; q < packs.size(); q++) {
       if (rowindex != q) {
         Pack otherPack = packs.get(q);
         String name1 = otherPack.getExcludeGroup();
         String name2 = pack.getExcludeGroup();
         if (name2.equals(name1)) {
           if (checkValues[q] == SELECTED) {
             checkValues[q] = DESELECTED;
           }
         }
       }
     }
   }
 }