Skip to content

Commit

Permalink
CSSTUDIO-2731 Fix bugs in handling SplitPanes when splitting left/rig…
Browse files Browse the repository at this point in the history
…ht or top/bottom.
  • Loading branch information
abrahamwolk committed Oct 10, 2024
1 parent e3333ee commit 974bf1b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
13 changes: 11 additions & 2 deletions core/ui/src/main/java/org/phoebus/ui/docking/DockPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Consumer;
import java.util.logging.Level;
Expand Down Expand Up @@ -658,7 +659,13 @@ else if (dock_parent instanceof SplitPane)
{
final SplitPane parent = (SplitPane) dock_parent;
// Remove this dock pane from BorderPane
double dividerPosition = parent.getDividerPositions()[0];
Optional<Double> dividerPosition;
if (parent.getDividerPositions().length > 1) {
dividerPosition = Optional.of(parent.getDividerPositions()[0]);
}
else {
dividerPosition = Optional.empty();
}
parent.getItems().remove(this);
// Place in split alongside a new dock pane
final DockPane new_pane = new DockPane();
Expand All @@ -668,7 +675,9 @@ else if (dock_parent instanceof SplitPane)
new_pane.setDockParent(split);
// Place that new split in the border pane
parent.getItems().add(split);
parent.setDividerPosition(0, dividerPosition);
if (dividerPosition.isPresent()) {
parent.setDividerPosition(0, dividerPosition.get());
}
}
else
throw new IllegalStateException("Cannot split, dock_parent is " + dock_parent);
Expand Down
8 changes: 5 additions & 3 deletions core/ui/src/main/java/org/phoebus/ui/docking/SplitDock.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,11 @@ else if (dock_parent instanceof SplitDock)
}
else if (dock_parent instanceof SplitPane) {
final SplitPane parent = (SplitPane) dock_parent;
// parent.getItems().get(1) == this, parent.getItems().get(0) == Navigator application
// No need to remove 'this' from parent, just update parent.getItems().get(1) to child
parent.getItems().set(1, child);
// parent.getItems().get(1) == this, parent.getItems().get(0) == Navigator application,
// when Navigator is being displayed.
// parent.getItems().get(0) == this when Navigator is not being displayed.
// No need to remove 'this' from parent, just update parent.getItems().get(last index) to child
parent.getItems().set(parent.getItems().size()-1, child);
}
else
{
Expand Down

0 comments on commit 974bf1b

Please sign in to comment.