Skip to content

Commit

Permalink
Fix exception when docking floating window. Refs #8
Browse files Browse the repository at this point in the history
  • Loading branch information
ricemery committed Feb 9, 2017
1 parent fe506ad commit 6614eae
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ abstract class AbstractSide extends Pane {
private final Region insertionSpacer = new Region();

private boolean allowMultipleOpenDrawers = true;
private boolean floatingSelectedChanged = false;

AbstractSide(final Position position,
final DragState dragState) {
Expand Down Expand Up @@ -436,6 +437,8 @@ private ContextMenu createButtonContextMenu(final DrawerNode node) {
floatingMenuItem.setSelected(node.isFloating());
floatingMenuItem.selectedProperty()
.addListener((observable, oldValue, newValue) -> {
floatingSelectedChanged = !newValue;

if (oldValue == newValue) {
return;
}
Expand All @@ -451,6 +454,8 @@ private ContextMenu createButtonContextMenu(final DrawerNode node) {
showNodeInternal(node);
}
});

floatingSelectedChanged = false;
});


Expand Down Expand Up @@ -495,8 +500,14 @@ private void floatWindow(final DrawerNode node) {
node.getFloatingX().ifPresent(floatingWindow::setX);
node.getFloatingY().ifPresent(floatingWindow::setY);
floatingWindow.setOnCloseRequest(event -> {
findButton(node).ifPresent(toggleButton -> toggleButton.setSelected(false));
((Pane)node.getParent()).getChildren().clear();
if (!floatingSelectedChanged) {
findButton(node).ifPresent(toggleButton -> toggleButton.setSelected(false));
}

final Pane parent = (Pane) node.getParent();
if (parent != null) {
parent.getChildren().clear();
}
});
floatingWindow.xProperty().addListener((observable, oldValue, newValue)
-> node.setFloatingX(newValue.doubleValue()));
Expand Down

0 comments on commit 6614eae

Please sign in to comment.