use of org.eclipse.nebula.widgets.nattable.hideshow.event.HideRowPositionsEvent in project nebula.widgets.nattable by eclipse.
the class RowHideShowLayer method hideRowIndexes.
@Override
public void hideRowIndexes(Collection<Integer> rowIndexes) {
Set<Integer> rowPositions = new HashSet<Integer>();
for (Integer rowIndex : rowIndexes) {
rowPositions.add(getRowPositionByIndex(rowIndex));
}
this.hiddenRowIndexes.addAll(rowIndexes);
invalidateCache();
fireLayerEvent(new HideRowPositionsEvent(this, rowPositions));
}
use of org.eclipse.nebula.widgets.nattable.hideshow.event.HideRowPositionsEvent in project nebula.widgets.nattable by eclipse.
the class RowHideShowLayer method hideRowPositions.
@Override
public void hideRowPositions(Collection<Integer> rowPositions) {
Set<Integer> rowIndexes = new HashSet<Integer>();
for (Integer rowPosition : rowPositions) {
rowIndexes.add(getRowIndexByPosition(rowPosition));
}
this.hiddenRowIndexes.addAll(rowIndexes);
invalidateCache();
fireLayerEvent(new HideRowPositionsEvent(this, rowPositions));
}
use of org.eclipse.nebula.widgets.nattable.hideshow.event.HideRowPositionsEvent in project nebula.widgets.nattable by eclipse.
the class HierarchicalTreeLayer method expandOrCollapse.
/**
* Expands or collapses the node at the given index coordinates according to
* its current state. Expands to the given level, e.g. if toLevel 0 is
* given, only the first level of a row is expanded, given toLevel is 1 and
* a node in the first level should be expanded, that node will be expanded
* as well as all collapsed nodes in the second level for this object.
*
* @param columnIndex
* The column index of the node to handle.
* @param rowIndex
* The row index of the node to handle.
* @param toLevel
* 0 based hierarchy level to expand to. Will be ignored on
* collapse or if value is -1.
* <p>
* <b>Note:</b> This is the level to expand to, not the number of
* levels to expand from the expanded level.
* </p>
*/
public void expandOrCollapse(int columnIndex, int rowIndex, int toLevel) {
List<Integer> toProcess = getChildIndexes(columnIndex, rowIndex);
HierarchicalTreeNode coord = new HierarchicalTreeNode(columnIndex, rowIndex, null);
if (this.collapsedNodes.contains(coord)) {
this.collapsedNodes.remove(coord);
// ensure that deeper level collapsed rows are not shown again
Range children = new Range(rowIndex, toProcess.get(toProcess.size() - 1));
int toLevelColumnIndex = (toLevel >= 0) ? this.nodeColumnMapping.get(toLevel) : -1;
for (Iterator<HierarchicalTreeNode> it = this.collapsedNodes.iterator(); it.hasNext(); ) {
HierarchicalTreeNode p = it.next();
// and coord column is bigger than the toLevel
if (children.contains(p.rowIndex)) {
if (p.columnIndex > toLevelColumnIndex) {
toProcess.removeAll(getChildIndexes(p.columnIndex, p.rowIndex));
} else {
// we also remove the coord in case it will be expanded
it.remove();
}
}
}
this.getHiddenRowIndexes().removeAll(toProcess);
invalidateCache();
fireLayerEvent(new ShowRowPositionsEvent(this, toProcess));
} else {
coord.rowObject = this.underlyingList.get(coord.rowIndex);
this.collapsedNodes.add(coord);
this.getHiddenRowIndexes().addAll(toProcess);
invalidateCache();
fireLayerEvent(new HideRowPositionsEvent(this, toProcess));
}
}
use of org.eclipse.nebula.widgets.nattable.hideshow.event.HideRowPositionsEvent in project nebula.widgets.nattable by eclipse.
the class HierarchicalTreeLayer method collapseAll.
/**
* Collapses all tree nodes.
*/
public void collapseAll() {
List<Integer> rowsToHide = new ArrayList<Integer>();
Integer[] nodeColumns = this.nodeColumnMapping.values().toArray(new Integer[0]);
Arrays.sort(nodeColumns);
int columnIndex = nodeColumns[0];
int columnPosition = getColumnPositionByIndex(columnIndex);
ILayerCell cell = null;
for (int row = 0; row < getRowCount(); row++) {
cell = getCellByPosition(columnPosition, row);
if (cell.getRowSpan() > 1) {
int rowIndex = getRowIndexByPosition(row);
this.collapsedNodes.add(new HierarchicalTreeNode(columnIndex, rowIndex, this.underlyingList.get(rowIndex)));
rowsToHide.addAll(getChildIndexes(columnIndex, rowIndex));
row += (cell.getRowSpan()) - 1;
}
}
// search for node coords in deeper levels, except the leaf
for (int col = 1; col < (nodeColumns.length - 1); col++) {
columnIndex = nodeColumns[col];
columnPosition = getColumnPositionByIndex(columnIndex);
for (int row = 0; row < getRowCount(); row++) {
cell = getCellByPosition(columnPosition, row);
if (cell.getRowSpan() > 1) {
// only collect the coordinates, the rows are already hidden
// by the first level
int rowIndex = getRowIndexByPosition(row);
this.collapsedNodes.add(new HierarchicalTreeNode(columnIndex, rowIndex, this.underlyingList.get(rowIndex)));
row += (cell.getRowSpan()) - 1;
}
}
}
this.getHiddenRowIndexes().addAll(rowsToHide);
invalidateCache();
fireLayerEvent(new HideRowPositionsEvent(this, rowsToHide));
}
Aggregations