Change reuse/append display to choose a display that is currently visible. This will be the one in the open tab.

This commit is contained in:
tom
2020-05-19 07:40:01 -04:00
parent e08efb1504
commit c999cfc308

View File

@@ -51,7 +51,7 @@ public class DefaultGraphDisplayProvider implements GraphDisplayProvider {
TaskMonitor monitor) {
if (reuseGraph && !displays.isEmpty()) {
return getExistingGraph();
return getVisibleGraph();
}
DefaultGraphDisplay display =
@@ -66,9 +66,16 @@ public class DefaultGraphDisplayProvider implements GraphDisplayProvider {
this.options = graphOptions;
}
private GraphDisplay getExistingGraph() {
DefaultGraphDisplay display = displays.iterator().next();
return display;
/**
* Get a {@code GraphDisplay} that is 'showing', assuming that is the one the user
* wishes to append to.
* Called only when displays is not empty. If there are no 'showing' displays,
* return one from the Set via its iterator
* @return a display that is showing
*/
private GraphDisplay getVisibleGraph() {
return displays.stream().filter(d -> d.getComponent().isShowing())
.findAny().orElse(displays.iterator().next());
}
@Override