Beispiel #1
0
  private void setStageParams(Stage stage) {
    Controller ctrlr = MainStage.controller;
    ProgramSettings ps = SingleObject.getProgramSettings();
    WindowState ws = ps.getWinState();
    Window w = stage.getScene().getWindow();
    w.setX(ws.getX());
    w.setY(ws.getY());
    w.setWidth(ws.getWidth());
    w.setHeight(ws.getHeight());
    stage.setMaximized(ws.isMaximized());

    double oldDuration = ctrlr.getAlarmSplitPane().getDuration();
    ctrlr.getAlarmSplitPane().setDuration(0);
    ctrlr.getAlarmSplitPane().setExpandedSize(ws.getAlarmDividerPositions());
    if (ws.isAlarmsShowing()) {
      ctrlr.getAlarmSplitPane().showSide();
    } else {
      ctrlr.getAlarmSplitPane().hideSide();
    }
    ctrlr.getAlarmSplitPane().setDuration(oldDuration);

    ctrlr.getTreeSplitPane().setExpandedSize(ws.getTreeDividerPositions());
    oldDuration = ctrlr.getTreeSplitPane().getDuration();
    ctrlr.getTreeSplitPane().setDuration(0);
    if (ws.isTreeShowing()) {
      Platform.runLater(() -> ctrlr.getTreeSplitPane().showSide());
    } else {
      Platform.runLater(() -> ctrlr.getTreeSplitPane().hideSide());
    }
    ctrlr.getTreeSplitPane().setDuration(oldDuration);
    Platform.runLater(() -> ctrlr.getSpTreeController().getTvSchemes().requestFocus());

    ctrlr
        .getMainPane()
        .isShowingProperty()
        .bind(
            SingleObject.mainStage
                .fullScreenProperty()
                .isNotEqualTo(new SimpleBooleanProperty(true)));
    ctrlr.getvToolBarPane().isShowingProperty().bind(ctrlr.getMainPane().isShowingProperty());

    ctrlr
        .getMainPane()
        .getSideBar()
        .visibleProperty()
        .addListener(
            (observ, old, newValue) -> {
              if (newValue) {
                String[] state = ctrlr.getMainPane().getUserData().toString().split(";");
                if (Boolean.valueOf(state[0])) {
                  Platform.runLater(() -> ctrlr.getAlarmSplitPane().showSide());
                } else {
                  if (Boolean.valueOf(state[1]))
                    Platform.runLater(() -> ctrlr.getTreeSplitPane().showSide());
                }
              } else {
                ctrlr
                    .getMainPane()
                    .setUserData(
                        ctrlr.getAlarmSplitPane().isShowingProperty().get()
                            + ";"
                            + ctrlr.getTreeSplitPane().isShowingProperty().get());
                if (ctrlr.getAlarmSplitPane().isShowingProperty().get()) {
                  Platform.runLater(() -> ctrlr.getAlarmSplitPane().hideSide());
                } else {
                  Platform.runLater(() -> ctrlr.getTreeSplitPane().hideSide());
                }
              }
            });

    ctrlr
        .getAlarmSplitPane()
        .getSideBar()
        .visibleProperty()
        .addListener(
            (observ, old, newValue) -> {
              if (!ctrlr.getMainPane().isShowingProperty().get()) {
                Platform.runLater(() -> ctrlr.getTreeSplitPane().hideSide());
              } else {
                if (ctrlr.getMainPane().getUserData() != null) {
                  String[] state = ctrlr.getMainPane().getUserData().toString().split(";");
                  if (Boolean.valueOf(state[1]))
                    Platform.runLater(() -> ctrlr.getTreeSplitPane().showSide());
                  ctrlr.getMainPane().setUserData(null);
                }
              }
            });

    ctrlr
        .getAlarmSplitPane()
        .getSideBar()
        .visibleProperty()
        .addListener(
            (observ, old, newVal) -> {
              if (newVal) {
                ctrlr.getShowAlarm().getStyleClass().add("hide-down");
                ctrlr.getShowAlarm().getStyleClass().remove("show-up");
              } else {
                ctrlr.getShowAlarm().getStyleClass().remove("hide-down");
                ctrlr.getShowAlarm().getStyleClass().add("show-up");
              }
            });

    ctrlr.getToolBarController().getHideLeft().setGraphic(null);
    ctrlr
        .getTreeSplitPane()
        .isShowingProperty()
        .addListener(
            (observ, old, newValue) -> {
              if (newValue) {
                ctrlr.getToolBarController().getHideLeft().getStyleClass().add("hide-left");
                ctrlr.getToolBarController().getHideLeft().getStyleClass().remove("show-right");
              } else {
                ctrlr.getToolBarController().getHideLeft().getStyleClass().remove("hide-left");
                ctrlr.getToolBarController().getHideLeft().getStyleClass().add("show-right");
              }
            });

    ctrlr.getToolBarController().getFit().setGraphic(null);
    SingleObject.mainStage
        .fullScreenProperty()
        .addListener(
            (observ, old, newValue) -> {
              if (newValue) {
                ctrlr.getToolBarController().getFit().getStyleClass().add("full-screen-on");
                ctrlr.getToolBarController().getFit().getStyleClass().remove("full-screen-off");
              } else {
                ctrlr.getToolBarController().getFit().getStyleClass().remove("full-screen-on");
                ctrlr.getToolBarController().getFit().getStyleClass().add("full-screen-off");
              }
            });

    SchemeSettings ss = ps.getSchemeSettings();
    SingleObject.mainScheme.getRoot().setScaleX(ss.getSchemeScale());
    SingleObject.mainScheme.getRoot().setScaleY(ss.getSchemeScale());
    ctrlr.getMenuBarController().setLocaleName(ps.getLocaleName());

    ps.getHotkeys().forEach(e -> SingleObject.hotkeys.put(e.getIdCode(), e));
  }