Skip to content

Commit

Permalink
Partial fix issue #214 (persistent metric position)
Browse files Browse the repository at this point in the history
Try to preserve metric column position after filter and derived metric)
  • Loading branch information
laksono committed Jun 13, 2022
1 parent 82b5ae8 commit 5a63f14
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions edu.rice.cs.hpctree/src/edu/rice/cs/hpctree/ScopeTreeTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,41 @@ private Point getMetricColumnSize() {

@Override
public void refresh() {
if (natTable != null) {
natTable.refresh();
if (natTable == null) {
return;
}
final var reorderLayer = bodyLayerStack.getColumnReorderLayer();
final var listOrder = reorderLayer.getColumnIndexOrder();

natTable.refresh();

var newListOrder = reorderLayer.getColumnIndexOrder();
int diff = newListOrder.size() - listOrder.size();

// Fix issue #214 (metric column position is accidentally reset)
//
// Let assume the tree column (index=0) is always constant
// This means we need to move the column to the original order
// plus the difference between old list and the new list
// If the list of the original one:
// [0, 3, 1, 4, 2]
// and the new reset list:
// [0, 1, 2, 3, 4, 5]
// so the new position should be:
// [0, 1, 4, 2, 5, 3]
//
// Since the tree column is static (always 0 position)
// then the index 3 (now its index is 4) has to move to position 2, and
// index 4 moves to position 3
for(int i=1; i<listOrder.size(); i++) {
int order1 = listOrder.get(i);
int order2 = newListOrder.get(i + diff);

if (order2 == order1 + diff)
continue;

reorderLayer.reorderColumnPosition(order1 + diff, order2);
newListOrder = reorderLayer.getColumnIndexOrder();
}
}

Expand Down

0 comments on commit 5a63f14

Please sign in to comment.