Skip to content

Commit

Permalink
Merge pull request #3162 from ControlSystemStudio/CSSTUDIO-2731
Browse files Browse the repository at this point in the history
CSSTUDIO-2731 Fix bugs in handling SplitPanes when splitting left/right or top/bottom.
  • Loading branch information
abrahamwolk authored Oct 11, 2024
2 parents e3333ee + 981677e commit 30b6a1d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
17 changes: 13 additions & 4 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 @@ -299,7 +300,7 @@ public void setDockParent(final Parent dock_parent)
if (dock_parent == null ||
dock_parent instanceof BorderPane ||
dock_parent instanceof SplitDock ||
dock_parent instanceof SplitPane) // "dock_parent instanceof SplitPane" is for the case of the Navigator application running
dock_parent instanceof SplitPane) // "dock_parent instanceof SplitPane" is for the case of the ESS-specific Navigator application running
this.dock_parent = dock_parent;
else
throw new IllegalArgumentException("Expected BorderPane or SplitDock or SplitPane, got " + dock_parent);
Expand Down Expand Up @@ -654,11 +655,17 @@ else if (dock_parent instanceof BorderPane)
// Place that new split in the border pane
parent.setCenter(split);
}
else if (dock_parent instanceof SplitPane)
else if (dock_parent instanceof SplitPane) // "dock_parent instanceof SplitPane" is for the case of the ESS-specific Navigator application running
{
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
10 changes: 6 additions & 4 deletions core/ui/src/main/java/org/phoebus/ui/docking/SplitDock.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,13 @@ else if (dock_parent instanceof SplitDock)
final boolean was_first = parent.removeItem(this);
parent.addItem(was_first, child);
}
else if (dock_parent instanceof SplitPane) {
else if (dock_parent instanceof SplitPane) { // "dock_parent instanceof SplitPane" is for the case of the ESS-specific Navigator application running
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) == (ESS-specific) Navigator application,
// when the (ESS-specific) Navigator is being displayed.
// parent.getItems().get(0) == this when (ESS-specific) 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 30b6a1d

Please sign in to comment.