예제 #1
0
  /**
   * Set the value of the parent pack of the given pack to SELECTED, PARTIAL_SELECT, or DESELECTED.
   * Value of the pack is dependent of its children values.
   *
   * @param childPack
   */
  private void updateParent(Pack childPack) {
    String parentName = childPack.getParent();
    Pack parentPack = nameToPack.get(parentName);
    int parentPosition = nameToRow.get(parentName);

    int childrenSelected = 0;
    for (String childName : parentPack.getChildren()) {
      int childPosition = nameToRow.get(childName);
      if (isChecked(childPosition)) {
        childrenSelected += 1;
      }
    }

    if (parentPack.getChildren().size() == childrenSelected) {
      if (checkValues[parentPosition] < 0) {
        checkValues[parentPosition] = REQUIRED_SELECTED;
      } else {
        checkValues[parentPosition] = SELECTED;
      }
    } else if (childrenSelected > 0) {

      if (checkValues[parentPosition] < 0) {
        checkValues[parentPosition] = REQUIRED_PARTIAL_SELECTED;
      } else {
        checkValues[parentPosition] = PARTIAL_SELECTED;
      }
    } else {
      if (checkValues[parentPosition] < 0) {
        checkValues[parentPosition] = REQUIRED_DESELECTED;
      } else {
        checkValues[parentPosition] = DESELECTED;
      }
    }
  }
예제 #2
0
  /**
   * Set the value of children packs to the same value as the parent pack.
   *
   * @param parentPack
   */
  private void updateChildren(Pack parentPack) {
    String parentName = parentPack.getName();
    int parentPosition = nameToRow.get(parentName);
    int parentValue = checkValues[parentPosition];

    for (String childName : parentPack.getChildren()) {
      int childPosition = nameToRow.get(childName);
      checkValues[childPosition] = parentValue;
    }
  }