Example #1
0
  /**
   * Setup sort type for this column and recalculate sortOrder of other columns to hold consistent
   * state.
   *
   * @param sortType new sort type
   */
  public void setSortType(final DLSortType sortType) {
    // if there was setted NATURAL and won't be then active sort order
    if (DLSortType.NATURAL.equals(this.sortType) && !DLSortType.NATURAL.equals(sortType)) {
      sortOrder = columnModel.autoIncSortMaxIndex();
    }
    // if there wasn't setted NATURAL and will be then deactive sort order
    if (!DLSortType.NATURAL.equals(this.sortType) && DLSortType.NATURAL.equals(sortType)) {
      columnModel.autoDecSortMaxIndex();
      for (DLColumnUnitModel unit : columnModel.getColumnModels()) {
        unit.autodecrementSortOrder(sortOrder);
      }
      sortOrder = 0;
    }

    setSortTypeDirectly(sortType);
  }
Example #2
0
  public void setVisible(final boolean visible) {
    if (this.visible == visible) {
      return;
    }
    if (visible) { // if it is setted on visible true move it to the end
      if (order == 0) {
        order = columnModel.autoIncOrder();
      }
    } else { // if invisible is setting we have to remove a change order index of all other columns
      columnModel.autoDecOrder();
      for (DLColumnUnitModel unit : columnModel.getColumnModels()) {
        unit.autodecrementOrder(order);
      }
      order = 0;
    }

    this.visible = visible;
  }
Example #3
0
  /**
   * Order starts at 1, 0 off - hidden
   *
   * @param order show order
   */
  public void setOrder(final Integer order) {
    // move all columns which are behind me
    for (DLColumnUnitModel unit : columnModel.getColumnModels()) {
      unit.autodecrementOrder(this.order);
    }

    if (order > 0) { // if it is moving or inserting
      // move all which will be behind me
      for (DLColumnUnitModel unit : columnModel.getColumnModels()) {
        unit.autoincrementOrder(order);
      }

      // if it wasn't shown show it
      if (this.order == 0) {
        columnModel.autoIncOrder();
        visible = true;
      }
    } else {
      visible = false;
      columnModel.autoDecOrder();
    }

    this.order = order;
  }
Example #4
0
 /**
  * Unit Model is comperable by order.
  *
  * @param o order
  * @return -1 if first less then other, 0 if same, 1 otherwise.
  */
 public int compareTo(DLColumnUnitModel o) {
   if (o == null) return 0;
   return (getOrder() < o.getOrder()) ? -1 : getOrder() == o.getOrder() ? 0 : 1;
 }