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

Commit 5a63f14

Browse files
committed
Partial fix issue #214 (persistent metric position)
Try to preserve metric column position after filter and derived metric)
1 parent 82b5ae8 commit 5a63f14

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

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

+35-2
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,41 @@ private Point getMetricColumnSize() {
512512

513513
@Override
514514
public void refresh() {
515-
if (natTable != null) {
516-
natTable.refresh();
515+
if (natTable == null) {
516+
return;
517+
}
518+
final var reorderLayer = bodyLayerStack.getColumnReorderLayer();
519+
final var listOrder = reorderLayer.getColumnIndexOrder();
520+
521+
natTable.refresh();
522+
523+
var newListOrder = reorderLayer.getColumnIndexOrder();
524+
int diff = newListOrder.size() - listOrder.size();
525+
526+
// Fix issue #214 (metric column position is accidentally reset)
527+
//
528+
// Let assume the tree column (index=0) is always constant
529+
// This means we need to move the column to the original order
530+
// plus the difference between old list and the new list
531+
// If the list of the original one:
532+
// [0, 3, 1, 4, 2]
533+
// and the new reset list:
534+
// [0, 1, 2, 3, 4, 5]
535+
// so the new position should be:
536+
// [0, 1, 4, 2, 5, 3]
537+
//
538+
// 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
541+
for(int i=1; i<listOrder.size(); i++) {
542+
int order1 = listOrder.get(i);
543+
int order2 = newListOrder.get(i + diff);
544+
545+
if (order2 == order1 + diff)
546+
continue;
547+
548+
reorderLayer.reorderColumnPosition(order1 + diff, order2);
549+
newListOrder = reorderLayer.getColumnIndexOrder();
517550
}
518551
}
519552

0 commit comments

Comments
 (0)