SEBSERV-427 - fix selection issue
This commit is contained in:
parent
25e9b9be1e
commit
34f8fa1e0a
1 changed files with 37 additions and 2 deletions
|
@ -431,7 +431,7 @@ public final class ClientConnectionTable implements FullPageMonitoringGUIUpdate
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sortTable() {
|
private void sortTable() {
|
||||||
// SEBSERV-427 get all selected indices here and store connectionTokens for selection in Set
|
Set<String> connectionTokens = getSelectedConnectionTokens();
|
||||||
|
|
||||||
this.sortList.clear();
|
this.sortList.clear();
|
||||||
this.sortList.addAll(this.tableMapping.values());
|
this.sortList.addAll(this.tableMapping.values());
|
||||||
|
@ -443,7 +443,10 @@ public final class ClientConnectionTable implements FullPageMonitoringGUIUpdate
|
||||||
this.tableMapping.put(item.connectionId, item);
|
this.tableMapping.put(item.connectionId, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SEBSERV-427 apply selected connectionTokens back to table index selection
|
if(!connectionTokens.isEmpty()){
|
||||||
|
this.table.deselectAll();
|
||||||
|
this.table.select(getSelectedTableIndices(connectionTokens));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notifySelectionChange() {
|
private void notifySelectionChange() {
|
||||||
|
@ -816,4 +819,36 @@ public final class ClientConnectionTable implements FullPageMonitoringGUIUpdate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Set<String> getSelectedConnectionTokens(){
|
||||||
|
final int[] selectionIndices = this.table.getSelectionIndices();
|
||||||
|
if (selectionIndices == null) {
|
||||||
|
return Collections.emptySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
final Set<String> result = new HashSet<>();
|
||||||
|
for (int i = 0; i < selectionIndices.length; i++) {
|
||||||
|
UpdatableTableItem item = this.tableMapping.values().stream().toList().get(selectionIndices[i]);
|
||||||
|
result.add(item.staticData.connectionToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int[] getSelectedTableIndices(Set<String> connectionTokens){
|
||||||
|
if(connectionTokens.isEmpty()){
|
||||||
|
return new int[]{};
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Integer> selectedTableIndices = new ArrayList<>();
|
||||||
|
int index = 0;
|
||||||
|
for (UpdatableTableItem item : this.tableMapping.values()) {
|
||||||
|
if (connectionTokens.contains(item.staticData.connectionToken)) {
|
||||||
|
selectedTableIndices.add(index);
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return selectedTableIndices.stream().mapToInt(i -> i).toArray();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue