use of org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup in project nebula.widgets.nattable by eclipse.
the class ColumnGroupExpandCollapseLayer method getHiddenColumnIndexes.
@Override
public Collection<Integer> getHiddenColumnIndexes() {
Collection<Integer> hiddenColumnIndexes = new HashSet<Integer>();
IUniqueIndexLayer underlyingLayer = (IUniqueIndexLayer) getUnderlyingLayer();
int underlyingColumnCount = underlyingLayer.getColumnCount();
for (int i = 0; i < underlyingColumnCount; i++) {
int columnIndex = underlyingLayer.getColumnIndexByPosition(i);
for (ColumnGroupModel model : this.models) {
ColumnGroup columnGroup = model.getColumnGroupByIndex(columnIndex);
if (columnGroup != null && columnGroup.isCollapsed()) {
if (!ColumnGroupUtils.isStaticOrFirstVisibleColumn(columnIndex, underlyingLayer, underlyingLayer, model)) {
hiddenColumnIndexes.add(Integer.valueOf(columnIndex));
}
}
}
}
return hiddenColumnIndexes;
}
use of org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup in project nebula.widgets.nattable by eclipse.
the class ColumnGroupExpandCollapseLayer method isColumnIndexHidden.
// Expand/collapse
@Override
public boolean isColumnIndexHidden(int columnIndex) {
IUniqueIndexLayer underlyingLayer = (IUniqueIndexLayer) getUnderlyingLayer();
boolean isHiddeninUnderlyingLayer = ColumnGroupUtils.isColumnIndexHiddenInUnderLyingLayer(columnIndex, this, underlyingLayer);
if (isHiddeninUnderlyingLayer)
return true;
for (ColumnGroupModel model : this.models) {
ColumnGroup columnGroup = model.getColumnGroupByIndex(columnIndex);
boolean isCollapsedAndStaticColumn = columnGroup != null && columnGroup.isCollapsed() && !ColumnGroupUtils.isStaticOrFirstVisibleColumn(columnIndex, underlyingLayer, underlyingLayer, model);
if (isCollapsedAndStaticColumn)
return true;
}
return false;
}
use of org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup in project nebula.widgets.nattable by eclipse.
the class ColumnGroupGroupHeaderLayer method getStartPositionOfGroup.
/**
* Figures out the start position of the group.
*
* @param columnPosition
* of any column belonging to the group
* @return first position of the column group
*
* @since 1.6
*/
public int getStartPositionOfGroup(int columnPosition) {
int bodyColumnIndex = getColumnIndexByPosition(columnPosition);
ColumnGroup columnGroup = this.model.getColumnGroupByIndex(bodyColumnIndex);
if (columnGroup == null) {
// part of a group in this level
return this.columnGroupHeaderLayer.getStartPositionOfGroup(columnPosition);
}
int leastPossibleStartPositionOfGroup = columnPosition - columnGroup.getSize();
int i = 0;
for (i = leastPossibleStartPositionOfGroup; i < columnPosition; i++) {
if (ColumnGroupUtils.isInTheSameGroup(getColumnIndexByPosition(i), bodyColumnIndex, this.model)) {
break;
}
}
return i;
}
use of org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup in project nebula.widgets.nattable by eclipse.
the class ColumnGroupGroupHeaderLayer method getColumnSpan.
/**
* Calculates the span of a cell in a Column Group. Takes into account
* collapsing and hidden columns in the group.
*
* @param columnPosition
* position of any column belonging to the group
*
* @since 1.6
*/
public int getColumnSpan(int columnPosition) {
int columnIndex = getColumnIndexByPosition(columnPosition);
ColumnGroup columnGroup = this.model.getColumnGroupByIndex(columnIndex);
if (columnGroup == null) {
// part of a group in this level
return this.columnGroupHeaderLayer.getColumnSpan(columnPosition);
}
int sizeOfGroup = columnGroup.getSize();
if (columnGroup.isCollapsed()) {
int sizeOfStaticColumns = columnGroup.getStaticColumnIndexes().size();
if (sizeOfStaticColumns == 0) {
return 1;
} else {
sizeOfGroup = sizeOfStaticColumns;
}
}
int startPositionOfGroup = getStartPositionOfGroup(columnPosition);
int endPositionOfGroup = startPositionOfGroup + sizeOfGroup;
List<Integer> columnIndexesInGroup = columnGroup.getMembers();
for (int i = startPositionOfGroup; i < endPositionOfGroup; i++) {
int index = getColumnIndexByPosition(i);
if (!columnIndexesInGroup.contains(Integer.valueOf(index))) {
sizeOfGroup--;
}
}
return sizeOfGroup;
}
use of org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup in project nebula.widgets.nattable by eclipse.
the class ColumnGroupGroupHeaderLayer method getDataValueByPosition.
@Override
public Object getDataValueByPosition(int columnPosition, int rowPosition) {
int columnIndex = getColumnIndexByPosition(columnPosition);
ColumnGroup columnGroup = this.model.getColumnGroupByIndex(columnIndex);
if (rowPosition == 0) {
if (this.model.isPartOfAGroup(columnIndex)) {
return columnGroup.getName();
}
} else {
rowPosition--;
}
return this.columnGroupHeaderLayer.getDataValueByPosition(columnPosition, rowPosition);
}
Aggregations