use of org.eclipse.nebula.widgets.nattable.coordinate.Range in project nebula.widgets.nattable by eclipse.
the class AbstractColumnHideShowLayer method underlyingToLocalColumnPositions.
@Override
public Collection<Range> underlyingToLocalColumnPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingColumnPositionRanges) {
Collection<Range> localColumnPositionRanges = new ArrayList<Range>(underlyingColumnPositionRanges.size());
for (Range underlyingColumnPositionRange : underlyingColumnPositionRanges) {
int startColumnPosition = getAdjustedUnderlyingToLocalStartPosition(sourceUnderlyingLayer, underlyingColumnPositionRange.start, underlyingColumnPositionRange.end);
int endColumnPosition = getAdjustedUnderlyingToLocalEndPosition(sourceUnderlyingLayer, underlyingColumnPositionRange.end, underlyingColumnPositionRange.start);
// returned.
if (startColumnPosition > -1) {
localColumnPositionRanges.add(new Range(startColumnPosition, endColumnPosition));
}
}
return localColumnPositionRanges;
}
use of org.eclipse.nebula.widgets.nattable.coordinate.Range in project nebula.widgets.nattable by eclipse.
the class ResizeColumnHideShowLayer method showColumnIndexes.
@Override
public void showColumnIndexes(Collection<Integer> columnIndexes) {
// On show we expect that all visible columns share the free
// space. To avoid that only the adjacent column is decreased, we
// disable fixColumnPercentageValuesOnResize in any case and restore it
// afterwards
boolean fix = this.bodyDataLayer.isFixColumnPercentageValuesOnResize();
this.bodyDataLayer.setFixColumnPercentageValuesOnResize(false);
List<Integer> processed = new ArrayList<Integer>();
for (Integer index : columnIndexes) {
ColumnSizeInfo info = this.hiddenColumns.remove(index);
if (info != null) {
processed.add(index);
// first make the column resizable
this.bodyDataLayer.setColumnPositionResizable(index, true);
// set the previous configured width
if (info.configuredPercentage && info.configuredPercentageValue >= 0) {
this.bodyDataLayer.setColumnWidthPercentageByPosition(index, info.configuredPercentageValue);
} else if (!info.configuredPercentage && info.configuredSize >= 0) {
this.bodyDataLayer.setColumnWidthByPosition(index, info.configuredSize, false);
} else {
this.bodyDataLayer.resetColumnWidth(index, false);
}
// set the configured resizable value
this.bodyDataLayer.setColumnPositionResizable(index, info.configuredResizable);
// set the previous configured min width
if (info.configuredMinWidth < 0) {
this.bodyDataLayer.resetMinColumnWidth(index, false);
} else {
this.bodyDataLayer.setMinColumnWidth(index, info.configuredMinWidth);
}
}
}
// reset the fixColumnPercentageValuesOnResize flag
this.bodyDataLayer.setFixColumnPercentageValuesOnResize(fix);
if (!processed.isEmpty()) {
List<Range> ranges = PositionUtil.getRanges(processed);
// fire events
for (Range range : ranges) {
this.bodyDataLayer.fireLayerEvent(new ColumnResizeEvent(this.bodyDataLayer, range));
}
}
}
use of org.eclipse.nebula.widgets.nattable.coordinate.Range in project nebula.widgets.nattable by eclipse.
the class ResizeColumnHideShowLayer method hideColumnPositions.
@Override
public void hideColumnPositions(Collection<Integer> columnPositions) {
Map<Integer, ColumnSizeInfo> positionsToHide = new TreeMap<Integer, ColumnSizeInfo>();
// On hide we expect that all remaining visible columns share the free
// space. To avoid that only the adjacent column is increased, we
// disable fixColumnPercentageValuesOnResize in any case and restore it
// afterwards
boolean fix = this.bodyDataLayer.isFixColumnPercentageValuesOnResize();
this.bodyDataLayer.setFixColumnPercentageValuesOnResize(false);
for (Integer columnPosition : columnPositions) {
// transform the position to index
int columnIndex = getColumnIndexByPosition(columnPosition);
// get the currently applied width of the column
int configuredWidth = this.bodyDataLayer.getConfiguredColumnWidthByPosition(columnIndex);
// get the currently applied min width of the column
int configuredMinWidth = this.bodyDataLayer.getConfiguredMinColumnWidthByPosition(columnIndex);
// get the currently applied resizable info
boolean configuredResizable = this.bodyDataLayer.isColumnPositionResizable(columnIndex);
// get the information if the column is configured for percentage
// sizing
boolean configuredPercentage = this.bodyDataLayer.isColumnPercentageSizing(columnIndex);
// get the currently applied percentage width of the column
double configuredPercentageValue = this.bodyDataLayer.getConfiguredColumnWidthPercentageByPosition(columnIndex);
positionsToHide.put(columnIndex, new ColumnSizeInfo(configuredWidth, configuredMinWidth, configuredResizable, configuredPercentage, configuredPercentageValue));
}
for (Integer columnIndex : positionsToHide.keySet()) {
// moment to make hiding work
if (!this.bodyDataLayer.isColumnPositionResizable(columnIndex)) {
this.bodyDataLayer.setColumnPositionResizable(columnIndex, true);
}
// if a min width is configured, set it to 0 to make hiding work
if (this.bodyDataLayer.isMinColumnWidthConfigured()) {
this.bodyDataLayer.setMinColumnWidth(columnIndex, 0);
}
// set the column width to 0
if (positionsToHide.get(columnIndex).configuredPercentage) {
this.bodyDataLayer.setColumnWidthPercentageByPosition(columnIndex, 0d);
} else {
this.bodyDataLayer.setColumnWidthByPosition(columnIndex, 0, false);
}
// make that column not resizable
this.bodyDataLayer.setColumnPositionResizable(columnIndex, false);
}
this.hiddenColumns.putAll(positionsToHide);
// reset the fixColumnPercentageValuesOnResize flag
this.bodyDataLayer.setFixColumnPercentageValuesOnResize(fix);
// fire events
List<Range> ranges = PositionUtil.getRanges(positionsToHide.keySet());
for (Range range : ranges) {
this.bodyDataLayer.fireLayerEvent(new ColumnResizeEvent(this.bodyDataLayer, range));
}
}
use of org.eclipse.nebula.widgets.nattable.coordinate.Range 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.coordinate.Range in project nebula.widgets.nattable by eclipse.
the class HideColumnPositionsEvent method getColumnDiffs.
@Override
public Collection<StructuralDiff> getColumnDiffs() {
Collection<StructuralDiff> columnDiffs = new ArrayList<StructuralDiff>(getColumnPositionRanges().size());
for (Range range : getColumnPositionRanges()) {
StructuralDiff diff = new StructuralDiff(DiffTypeEnum.DELETE, range, new Range(range.start, range.start));
columnDiffs.add(diff);
}
return columnDiffs;
}
Aggregations