From 5a63f144fe8f6c8c3bc621fbff315fcdf9aa1732 Mon Sep 17 00:00:00 2001 From: Laksono Adhianto Date: Mon, 13 Jun 2022 15:16:57 -0500 Subject: [PATCH] Partial fix issue #214 (persistent metric position) Try to preserve metric column position after filter and derived metric) --- .../edu/rice/cs/hpctree/ScopeTreeTable.java | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/edu.rice.cs.hpctree/src/edu/rice/cs/hpctree/ScopeTreeTable.java b/edu.rice.cs.hpctree/src/edu/rice/cs/hpctree/ScopeTreeTable.java index d2593c598..6f480dd00 100644 --- a/edu.rice.cs.hpctree/src/edu/rice/cs/hpctree/ScopeTreeTable.java +++ b/edu.rice.cs.hpctree/src/edu/rice/cs/hpctree/ScopeTreeTable.java @@ -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