Try again when decorator is not initialized.

This commit is contained in:
huanghongxun
2018-09-17 16:28:52 +08:00
parent efb14572d6
commit 9d5da5a39d

View File

@@ -22,6 +22,7 @@ import javafx.animation.Interpolator;
import javafx.animation.KeyFrame; import javafx.animation.KeyFrame;
import javafx.animation.KeyValue; import javafx.animation.KeyValue;
import javafx.animation.Timeline; import javafx.animation.Timeline;
import javafx.application.Platform;
import javafx.beans.binding.Bindings; import javafx.beans.binding.Bindings;
import javafx.event.EventHandler; import javafx.event.EventHandler;
import javafx.geometry.Insets; import javafx.geometry.Insets;
@@ -277,12 +278,17 @@ public class DecoratorController {
FXUtils.checkFxUserThread(); FXUtils.checkFxUserThread();
if (dialog == null) { if (dialog == null) {
if (decorator.getDrawerWrapper() == null) {
// Sometimes showDialog will be invoked before decorator was initialized.
// Keep trying again.
Platform.runLater(() -> showDialog(node));
return;
}
dialog = new JFXDialog(); dialog = new JFXDialog();
dialogPane = new StackContainerPane(); dialogPane = new StackContainerPane();
dialog.setContent(dialogPane); dialog.setContent(dialogPane);
if (decorator.getDrawerWrapper() == null)
throw new IllegalStateException("Decorator has not been initialized");
dialog.setDialogContainer(decorator.getDrawerWrapper()); dialog.setDialogContainer(decorator.getDrawerWrapper());
dialog.setOverlayClose(false); dialog.setOverlayClose(false);
dialog.show(); dialog.show();