Bug 571631: [WaLTable] Improve selection behaviour on structural row
changes
Change-Id: I52ff4d18cd144377fba9c38cfda9e2f48946a017
diff --git a/ecommons.waltable/org.eclipse.statet.ecommons.waltable.core/src/org/eclipse/statet/ecommons/waltable/selection/SelectionLayerStructuralChangeEventHandler.java b/ecommons.waltable/org.eclipse.statet.ecommons.waltable.core/src/org/eclipse/statet/ecommons/waltable/selection/SelectionLayerStructuralChangeEventHandler.java
index bec7557..bcd4060 100644
--- a/ecommons.waltable/org.eclipse.statet.ecommons.waltable.core/src/org/eclipse/statet/ecommons/waltable/selection/SelectionLayerStructuralChangeEventHandler.java
+++ b/ecommons.waltable/org.eclipse.statet.ecommons.waltable.core/src/org/eclipse/statet/ecommons/waltable/selection/SelectionLayerStructuralChangeEventHandler.java
@@ -43,6 +43,8 @@
public void handleLayerEvent(final IStructuralChangeEvent event) {
if (event.isHorizontalStructureChanged()) {
// TODO handle column deletion
+ this.selectionLayer.clear();
+ return;
}
if (event.isVerticalStructureChanged()) {
@@ -52,8 +54,17 @@
for (final LRectangle lRectangle : lRectangles) {
final LRange changedRange= new LRange(lRectangle.y, lRectangle.y + lRectangle.height);
if (selectedRowModified(changedRange)) {
- this.selectionLayer.clear();
- break;
+ if (this.selectionLayer.getRowCount() > 0) {
+ long columnPosition= this.selectionLayer.getSelectionAnchor().columnPosition;
+ if (columnPosition == SelectionLayer.NO_SELECTION) {
+ columnPosition= 0;
+ }
+ this.selectionLayer.setSelectionToCell(columnPosition, 0, false);
+ }
+ else {
+ this.selectionLayer.clear();
+ }
+ return;
}
}
}
@@ -64,7 +75,7 @@
if (diff.getDiffType() != DiffTypeEnum.CHANGE) {
if (selectedRowModified(diff.getBeforePositionRange())) {
this.selectionLayer.clear();
- break;
+ return;
}
}
}