Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit 1849b26

Browse files
committed
Fix issue #214 (preserve column position after adding a new metric)
Fix the algorithm to preserve the metric columns' position
1 parent 5a63f14 commit 1849b26

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

edu.rice.cs.hpctree/src/edu/rice/cs/hpctree/ScopeTreeTable.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -533,19 +533,22 @@ public void refresh() {
533533
// and the new reset list:
534534
// [0, 1, 2, 3, 4, 5]
535535
// so the new position should be:
536+
// [0, 1, 4, 2, 3, 5]
536537
// [0, 1, 4, 2, 5, 3]
537538
//
538539
// Since the tree column is static (always 0 position)
539-
// then the index 3 (now its index is 4) has to move to position 2, and
540-
// index 4 moves to position 3
540+
// then the index 3 (now its index is 4) has to move to position 1+1, and
541+
// index 4 (now its index is 5) moves to position 3+1
541542
for(int i=1; i<listOrder.size(); i++) {
542543
int order1 = listOrder.get(i);
543-
int order2 = newListOrder.get(i + diff);
544+
545+
final var oldPosition = order1 + diff;
546+
final var newPosition = newListOrder.get(i + diff);
544547

545-
if (order2 == order1 + diff)
548+
if (newPosition == oldPosition)
546549
continue;
547550

548-
reorderLayer.reorderColumnPosition(order1 + diff, order2);
551+
reorderLayer.reorderColumnPosition(oldPosition, i+diff);
549552
newListOrder = reorderLayer.getColumnIndexOrder();
550553
}
551554
}

0 commit comments

Comments
 (0)