use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.
the class CompositeFreezeLayer method saveState.
// Persistence
@Override
public void saveState(String prefix, Properties properties) {
PositionCoordinate coord = this.freezeLayer.getTopLeftPosition();
properties.setProperty(prefix + FreezeLayer.PERSISTENCE_TOP_LEFT_POSITION, coord.columnPosition + IPersistable.VALUE_SEPARATOR + coord.rowPosition);
coord = this.freezeLayer.getBottomRightPosition();
properties.setProperty(prefix + FreezeLayer.PERSISTENCE_BOTTOM_RIGHT_POSITION, coord.columnPosition + IPersistable.VALUE_SEPARATOR + coord.rowPosition);
super.saveState(prefix, properties);
}
use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.
the class FreezeHelper method resetViewport.
/**
* Helper method to reset the origin coordinates of the viewport. Is needed
* to perform an unfreeze or to override a current frozen state.
*
* @param freezeLayer
* The FreezeLayer of the grid to perform the freeze action.
* @param viewportLayer
* The ViewportLayer of the grid to perform the freeze action.
*/
public static void resetViewport(FreezeLayer freezeLayer, ViewportLayer viewportLayer) {
PositionCoordinate topLeftPosition = freezeLayer.getTopLeftPosition();
viewportLayer.resetOrigin(viewportLayer.getScrollableLayer().getStartXOfColumnPosition(Math.max(0, topLeftPosition.columnPosition)), viewportLayer.getScrollableLayer().getStartYOfRowPosition(Math.max(0, topLeftPosition.rowPosition)));
}
use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.
the class FreezeSelectionStrategy method getTopLeftPosition.
@Override
public PositionCoordinate getTopLeftPosition() {
PositionCoordinate lastSelectedCellPosition = this.selectionLayer.getLastSelectedCellPosition();
if (lastSelectedCellPosition == null) {
return null;
}
ILayerCell lastSelectedCell = this.selectionLayer.getCellByPosition(lastSelectedCellPosition.columnPosition, lastSelectedCellPosition.rowPosition);
int columnPosition = this.viewportLayer.getScrollableLayer().getColumnPositionByX(this.viewportLayer.getOrigin().getX());
if (columnPosition > 0 && columnPosition >= lastSelectedCellPosition.columnPosition) {
if (!this.include) {
columnPosition = lastSelectedCellPosition.columnPosition - 1;
} else {
columnPosition = lastSelectedCellPosition.columnPosition + lastSelectedCell.getColumnSpan() - 1;
}
}
int rowPosition = this.viewportLayer.getScrollableLayer().getRowPositionByY(this.viewportLayer.getOrigin().getY());
if (rowPosition > 0 && rowPosition >= lastSelectedCellPosition.rowPosition) {
if (!this.include) {
rowPosition = lastSelectedCellPosition.rowPosition - 1;
} else {
rowPosition = lastSelectedCellPosition.rowPosition - lastSelectedCell.getRowSpan() - 1;
}
}
return new PositionCoordinate(this.freezeLayer, columnPosition, rowPosition);
}
use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.
the class HierarchicalTreeLayer method handleLayerEvent.
@Override
public void handleLayerEvent(ILayerEvent event) {
if (event instanceof IStructuralChangeEvent) {
IStructuralChangeEvent structuralChangeEvent = (IStructuralChangeEvent) event;
if (structuralChangeEvent.isVerticalStructureChanged()) {
// recalculate node row indexes
// build a new collection of nodes to avoid duplication clashes
// as nodes are equal per column and row index
int negativeIndex = -1;
Set<HierarchicalTreeNode> updatedCollapsedNodes = new HashSet<HierarchicalTreeNode>();
for (HierarchicalTreeNode node : this.collapsedNodes) {
int newRowIndex = findTopRowIndex(node.columnIndex, node.rowObject);
// the underlying collection
if (newRowIndex >= 0) {
updatedCollapsedNodes.add(new HierarchicalTreeNode(node.columnIndex, newRowIndex, this.underlyingList.get(newRowIndex)));
} else if (this.retainRemovedRowObjectNodes) {
updatedCollapsedNodes.add(new HierarchicalTreeNode(node.columnIndex, negativeIndex, node.rowObject));
negativeIndex--;
}
}
this.collapsedNodes.clear();
this.collapsedNodes.addAll(updatedCollapsedNodes);
// recalculate hidden rows based on updated collapsed nodes
Set<Integer> updatedHiddenRows = new HashSet<Integer>();
for (HierarchicalTreeNode node : this.collapsedNodes) {
updatedHiddenRows.addAll(getChildIndexes(node.columnIndex, node.rowIndex));
}
getHiddenRowIndexes().clear();
getHiddenRowIndexes().addAll(updatedHiddenRows);
}
} else if (event instanceof SearchEvent) {
PositionCoordinate coord = ((SearchEvent) event).getCellCoordinate();
if (coord != null) {
Integer foundIndex = coord.getLayer().getRowIndexByPosition(coord.rowPosition);
if (getHiddenRowIndexes().contains(foundIndex)) {
if (this.expandOnSearch) {
// not collapsible
for (int level = this.nodeColumnMapping.size() - 2; level >= 0; level--) {
ILayerCell nodeCell = coord.getLayer().getCellByPosition(this.nodeColumnMapping.get(level), coord.rowPosition);
int colIdx = coord.getLayer().getColumnIndexByPosition(nodeCell.getOriginColumnPosition());
int rowIdx = coord.getLayer().getRowIndexByPosition(nodeCell.getOriginRowPosition());
if (this.collapsedNodes.contains(new HierarchicalTreeNode(colIdx, rowIdx, null))) {
expandOrCollapse(colIdx, rowIdx);
}
}
} else {
// only make the single row visible again
getHiddenRowIndexes().remove(foundIndex);
}
}
invalidateCache();
fireLayerEvent(new ShowRowPositionsEvent(this, Arrays.asList(foundIndex)));
}
}
super.handleLayerEvent(event);
}
use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.
the class SelectionLayer method getSelectedCellPositions.
public PositionCoordinate[] getSelectedCellPositions() {
int[] selectedColumnPositions = getSelectedColumnPositions();
Set<Range> selectedRowPositions = getSelectedRowPositions();
List<PositionCoordinate> selectedCells = new LinkedList<PositionCoordinate>();
for (int columnPositionIndex = 0; columnPositionIndex < selectedColumnPositions.length; columnPositionIndex++) {
final int columnPosition = selectedColumnPositions[columnPositionIndex];
for (Range rowIndexRange : selectedRowPositions) {
for (int rowPositionIndex = rowIndexRange.start; rowPositionIndex < rowIndexRange.end; rowPositionIndex++) {
if (this.selectionModel.isCellPositionSelected(columnPosition, rowPositionIndex)) {
selectedCells.add(new PositionCoordinate(this, columnPosition, rowPositionIndex));
}
}
}
}
return selectedCells.toArray(new PositionCoordinate[0]);
}
Aggregations