Potential bug in SelectionModel.java [message #1771382] |
Thu, 24 August 2017 13:20 |
Wallace Lake Messages: 5 Registered: August 2017 |
Junior Member |
|
|
Hi,
I'm not sure whether this is the right forum for this, but I cannot verify the behavior that I don't know, as I only stumbled upon this line while browsing the code:
Line 660 in org\eclipse\nebula\widgets\nattable\selection\SelectionModel.java
Range changedRange = new Range(rectangle.y, rectangle.y + rectangle.height);
'rectangle.y' is used, as in line 685. However, line 660 is meant for column positions, so I would think 'rectangle.x' is the corresponding range.
Was that intentional?
Toggle Spoiler @Override
public void handleLayerEvent(IStructuralChangeEvent event) {
if (this.clearSelectionOnChange) {
if (event.isHorizontalStructureChanged()) {
if (event.getColumnDiffs() == null) {
Collection<Rectangle> rectangles = event.getChangedPositionRectangles();
for (Rectangle rectangle : rectangles) {
Range changedRange = new Range(rectangle.y, rectangle.y + rectangle.height);
if (selectedColumnModified(changedRange)) {
this.selectionLayer.clear();
break;
}
}
} else {
for (StructuralDiff diff : event.getColumnDiffs()) {
// DiffTypeEnum.CHANGE is used for resizing and
// shouldn't result in clearing the selection
if (diff.getDiffType() != DiffTypeEnum.CHANGE) {
if (selectedColumnModified(diff.getBeforePositionRange())) {
this.selectionLayer.clear();
break;
}
}
}
}
}
if (event.isVerticalStructureChanged()) {
// if there are no row diffs, it seems to be a complete refresh
if (event.getRowDiffs() == null) {
Collection<Rectangle> rectangles = event.getChangedPositionRectangles();
for (Rectangle rectangle : rectangles) {
Range changedRange = new Range(rectangle.y, rectangle.y + rectangle.height);
if (selectedRowModified(changedRange)) {
this.selectionLayer.clear();
break;
}
}
} else {
// there are row diffs so we try to determine the diffs to
// process
for (StructuralDiff diff : event.getRowDiffs()) {
// DiffTypeEnum.CHANGE is used for resizing and
// shouldn't result in clearing the selection
if (diff.getDiffType() != DiffTypeEnum.CHANGE) {
if (selectedRowModified(diff.getBeforePositionRange())) {
this.selectionLayer.clear();
break;
}
}
}
}
}
} else {
// keep the selection as is in case of changes
// Note:
// this is the the same code I posted in various forums as a
// workaround for the cleaning of the selection on changes
// search for PreserveSelectionStructuralChangeEventHandler to get
// more information on this
PositionCoordinate[] coords = this.selectionLayer.getSelectedCellPositions();
for (PositionCoordinate coord : coords) {
if (coord.getColumnPosition() >= this.selectionLayer.getColumnCount()
|| coord.getRowPosition() >= this.selectionLayer.getRowCount()) {
// if the coordinates of the selected cells are outside the
// valid range remove the selection
this.selectionLayer.clearSelection(
coord.getColumnPosition(),
coord.getRowPosition());
}
}
}
}
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03930 seconds