use of au.gov.asd.tac.constellation.views.tableview.tasks.TriggerDataUpdateTask in project constellation by constellation-app.
the class TableViewTopComponent method handleNewGraph.
/**
* Update the current state with the new state pulled from the passed
* graph's attributes and update the attribute handlers so that the table is
* only notified for attribute changes that it cares about. Then trigger a
* table refresh using the new graph as its source of truth.
*
* @param graph the new graph
*/
@Override
protected void handleNewGraph(final Graph graph) {
if (!needsUpdate()) {
return;
}
// Take a copy of the current state that is associated with the current graph
final TableViewState previousState = currentState;
// Update the current state by pulling the table state attribute from
// the new graph
updateState(graph);
// Determine the visible column changes
final Set<Tuple<String, Attribute>> removedColumnAttributes = getRemovedAttributes(previousState, currentState);
final Set<Tuple<String, Attribute>> addedColumnAttributes = getAddedAttributes(previousState, currentState);
// with the state associated with the new graph
if (columnAttributeMonitors != null && !removedColumnAttributes.isEmpty()) {
final Set<AttributeValueMonitor> removeMonitors = columnAttributeMonitors.stream().filter(monitor -> removedColumnAttributes.stream().anyMatch(columnAttributeTuple -> columnAttributeTuple.getSecond().getElementType() == monitor.getElementType() && columnAttributeTuple.getSecond().getName().equals(monitor.getName()))).collect(Collectors.toSet());
removeMonitors.forEach(monitor -> {
removeAttributeValueChangeHandler(monitor);
columnAttributeMonitors.remove(monitor);
});
}
// Update the table data, columns and selection with the new graph
pane.updateTable(graph, currentState);
// the table should have its data refreshed
if (currentState != null && currentState.getColumnAttributes() != null && !addedColumnAttributes.isEmpty()) {
addedColumnAttributes.forEach(attributeTuple -> columnAttributeMonitors.add(addAttributeValueChangeHandler(attributeTuple.getSecond().getElementType(), attributeTuple.getSecond().getName(), g -> executorService.submit(new TriggerDataUpdateTask(pane, g, getCurrentState())))));
}
}
Aggregations