Beispiel #1
0
  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append(String.format("Name      : %s\n", getGroupName())); // $NON-NLS-1$
    sb.append(String.format("Collapsed : %s\n", isCollapsed())); // $NON-NLS-1$
    sb.append("Members   : \n"); // $NON-NLS-1$

    for (T row : getOwnMemberRows(false)) {
      sb.append(String.format("%s", row.toString())); // $NON-NLS-1$
    }

    for (T row : getOwnStaticMemberRows()) {
      sb.append(String.format("*%s", row.toString())); // $NON-NLS-1$
    }

    if (this.childGroups.size() > 0) {
      sb.append(String.format("Start Child Groups for [%s] :- \n", getGroupName())); // $NON-NLS-1$
      for (final IRowGroup<T> rowGroup : this.childGroups) {
        sb.append(rowGroup.toString());
      }
      sb.append(String.format("End Child Groups for [%s]\n", getGroupName())); // $NON-NLS-1$
    }

    return sb.toString();
  }
Beispiel #2
0
 /* (non-Javadoc)
  * @see com.gresham.darwin.ui.widgets.grid.data.rowgroups.IRowGroup#removeMemberRowGroup(com.gresham.darwin.ui.widgets.grid.data.rowgroups.IRowGroup)
  */
 public boolean removeRowGroup(final IRowGroup<T> rowGroup) {
   // Remove all members in the group.
   rowGroup.setParentGroup(null);
   rowGroup.clear();
   boolean removed = this.childGroups.remove(rowGroup);
   rowGroupModel.notifyListeners();
   return removed;
 }
Beispiel #3
0
  public boolean isEmpty() {

    boolean empty = true;

    synchronized (this.childGroups) {
      for (final IRowGroup<T> rowGroup : this.childGroups) {
        empty &= rowGroup.isEmpty();
      }
    }

    return (empty && ((rowMembers.size() + staticRowMembers.size()) == 0));
  }
Beispiel #4
0
  private boolean removeMemberRowFromCache(final T row) {
    boolean removed = false;

    // Remove the row from our group.
    if (row != null) {
      removed = this.rowMembers.remove(row);

      // Try removing a static row instead.
      if (!removed) {
        removed = this.staticRowMembers.remove(row);
      }

      if (removed) {
        // Bump row positions to compensate.
        this.rowGroupModel.removeMemberRow(row);

        if ((getOwnMemberRows(false).size() == 0) && (getRowGroups().size() == 0)) {
          // If there are no more member rows, then clean-up any static rows and remove the group
          // from the model.
          for (T staticRow : this.getOwnStaticMemberRows()) {
            this.rowGroupModel.removeMemberRow(staticRow);
          }

          this.staticRowMembers.clear();
          this.rowGroupModel.removeRowGroup(this);

          if (this.parentGroup != null) {
            this.parentGroup.removeRowGroup(this);
          }
        }

      } else {
        // Try sub-groups.
        synchronized (this.childGroups) {
          for (final IRowGroup<T> rowGroup : this.childGroups) {
            removed = ((RowGroup<T>) rowGroup).removeMemberRow(row);

            if (removed) {
              // Remove empty child groups from the model.
              if (rowGroup.getOwnMemberRows(false).size() == 0) {
                childGroups.remove(rowGroup);
              }
              break;
            }
          }
        }
      }
    }

    return removed;
  }
Beispiel #5
0
  public List<T> getStaticMemberRows() {
    final List<T> staticMemberRows = new ArrayList<T>();

    // Return all the member rows from nested groups.
    synchronized (this.childGroups) {
      for (final IRowGroup<T> rowGroup : this.childGroups) {
        staticMemberRows.addAll(rowGroup.getStaticMemberRows());
      }
    }

    // Add all of our immediate child rows.
    staticMemberRows.addAll(getOwnStaticMemberRows());

    return Collections.unmodifiableList(staticMemberRows);
  }
Beispiel #6
0
  public void clear() {
    synchronized (this.childGroups) {
      for (final IRowGroup<T> rowGroup : this.childGroups) {
        rowGroup.clear();
      }
    }

    synchronized (rowMembers) {
      for (T row : new ArrayList<T>(this.rowMembers)) {
        removeMemberRow(row);
      }
    }

    synchronized (staticRowMembers) {
      for (T row : new ArrayList<T>(this.staticRowMembers)) {
        removeMemberRow(row);
      }
    }
  }
Beispiel #7
0
  public IRowGroup<T> getRowGroupForRow(final T row) {
    IRowGroup<T> group = null;

    if (getOwnMemberRows(true).contains(row)) {
      group = this;

    } else {
      synchronized (this.childGroups) {
        for (final IRowGroup<T> rowGroup : this.childGroups) {
          group = rowGroup.getRowGroupForRow(row);

          if (group != null) {
            break;
          }
        }
      }
    }

    return group;
  }
Beispiel #8
0
 /* (non-Javadoc)
  * @see com.gresham.darwin.ui.widgets.grid.data.rowgroups.IRowGroup#addMemberRowGroup(com.gresham.darwin.ui.widgets.grid.data.rowgroups.IRowGroup)
  */
 public void addRowGroup(final IRowGroup<T> rowGroup) {
   rowGroup.setParentGroup(this);
   this.childGroups.add(rowGroup);
   rowGroupModel.notifyListeners();
 }