Search in sources :

Example 11 with ShowRowPositionsEvent

use of org.eclipse.nebula.widgets.nattable.hideshow.event.ShowRowPositionsEvent in project nebula.widgets.nattable by eclipse.

the class RowHideShowLayer method showAllRows.

@Override
public void showAllRows() {
    Collection<Integer> hiddenRows = new ArrayList<Integer>(this.hiddenRowIndexes);
    this.hiddenRowIndexes.clear();
    invalidateCache();
    fireLayerEvent(new ShowRowPositionsEvent(this, hiddenRows));
}
Also used : ArrayList(java.util.ArrayList) ShowRowPositionsEvent(org.eclipse.nebula.widgets.nattable.hideshow.event.ShowRowPositionsEvent)

Example 12 with ShowRowPositionsEvent

use of org.eclipse.nebula.widgets.nattable.hideshow.event.ShowRowPositionsEvent 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));
    }
}
Also used : HideRowPositionsEvent(org.eclipse.nebula.widgets.nattable.hideshow.event.HideRowPositionsEvent) Range(org.eclipse.nebula.widgets.nattable.coordinate.Range) ShowRowPositionsEvent(org.eclipse.nebula.widgets.nattable.hideshow.event.ShowRowPositionsEvent)

Example 13 with ShowRowPositionsEvent

use of org.eclipse.nebula.widgets.nattable.hideshow.event.ShowRowPositionsEvent in project nebula.widgets.nattable by eclipse.

the class TreeLayer method expandTreeRow.

/**
 * Expands the tree node for the given row index.
 *
 * @param parentIndex
 *            The index of the row that shows the node that should be
 *            expanded
 */
public void expandTreeRow(int parentIndex) {
    List<Integer> rowIndexes = this.treeRowModel.expand(parentIndex);
    // removeAll()
    for (final Integer expandedChildRowIndex : rowIndexes) {
        this.hiddenRowIndexes.remove(expandedChildRowIndex);
    }
    invalidateCache();
    fireLayerEvent(new ShowRowPositionsEvent(this, rowIndexes));
}
Also used : ShowRowPositionsEvent(org.eclipse.nebula.widgets.nattable.hideshow.event.ShowRowPositionsEvent)

Example 14 with ShowRowPositionsEvent

use of org.eclipse.nebula.widgets.nattable.hideshow.event.ShowRowPositionsEvent in project nebula.widgets.nattable by eclipse.

the class TreeLayer method expandAll.

/**
 * Expands all tree nodes in the tree.
 */
public void expandAll() {
    List<Integer> rowIndexes = this.treeRowModel.expandAll();
    this.hiddenRowIndexes.clear();
    invalidateCache();
    fireLayerEvent(new ShowRowPositionsEvent(this, rowIndexes));
}
Also used : ShowRowPositionsEvent(org.eclipse.nebula.widgets.nattable.hideshow.event.ShowRowPositionsEvent)

Example 15 with ShowRowPositionsEvent

use of org.eclipse.nebula.widgets.nattable.hideshow.event.ShowRowPositionsEvent in project nebula.widgets.nattable by eclipse.

the class TreeLayer method expandAllToLevel.

/**
 * Expands all tree nodes in the tree to a certain level.
 *
 * @param level
 *            The level to which the tree node should be expanded.
 */
public void expandAllToLevel(int level) {
    List<Integer> rowIndexes = this.treeRowModel.expandToLevel(level);
    // removeAll()
    for (final Integer expandedChildRowIndex : rowIndexes) {
        this.hiddenRowIndexes.remove(expandedChildRowIndex);
    }
    invalidateCache();
    fireLayerEvent(new ShowRowPositionsEvent(this, rowIndexes));
}
Also used : ShowRowPositionsEvent(org.eclipse.nebula.widgets.nattable.hideshow.event.ShowRowPositionsEvent)

Aggregations

ShowRowPositionsEvent (org.eclipse.nebula.widgets.nattable.hideshow.event.ShowRowPositionsEvent)15 Range (org.eclipse.nebula.widgets.nattable.coordinate.Range)5 HideRowPositionsEvent (org.eclipse.nebula.widgets.nattable.hideshow.event.HideRowPositionsEvent)5 ArrayList (java.util.ArrayList)4 TreeExpandCollapseCommand (org.eclipse.nebula.widgets.nattable.tree.command.TreeExpandCollapseCommand)4 Test (org.junit.Test)4 HashSet (java.util.HashSet)2 HierarchicalTreeNode (org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalTreeLayer.HierarchicalTreeNode)2 PositionCoordinate (org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate)1 ILayerCell (org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)1 ILayerEvent (org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent)1 IStructuralChangeEvent (org.eclipse.nebula.widgets.nattable.layer.event.IStructuralChangeEvent)1 SearchEvent (org.eclipse.nebula.widgets.nattable.search.event.SearchEvent)1 TreeCollapseAllCommand (org.eclipse.nebula.widgets.nattable.tree.command.TreeCollapseAllCommand)1 TreeExpandToLevelCommand (org.eclipse.nebula.widgets.nattable.tree.command.TreeExpandToLevelCommand)1