private void onShownHandler(WindowEvent windowEvent) {
   dialogStage.sizeToScene();
   Window parent = dialogStage.getOwner();
   dialogStage.setX(parent.getX() + parent.getWidth() / 2 - dialogStage.getWidth() / 2);
   dialogStage.setY(parent.getY() + parent.getHeight() / 2 - dialogStage.getHeight() / 2);
   dialogStage.requestFocus();
 }
  public ConfigurationsDialogBuilder setOwner(Window owner) {
    if (owner != null) {
      dialog.initOwner(owner);
      dialog.borderPanel.setMaxWidth(owner.getWidth());
      dialog.borderPanel.setMaxHeight(owner.getHeight());
    } else {
      dialog.setWidth(1000);
      dialog.setHeight(700);
    }

    return this;
  }
 /*     */ public WCRectangle getViewBounds() /*     */ {
   /*  71 */ WebView localWebView = this.accessor.getView();
   /*  72 */ Window localWindow = null;
   /*  73 */ if ((localWebView != null)
       && (localWebView.getScene() != null)
       && ((localWindow = localWebView.getScene().getWindow()) != null))
   /*     */ {
     /*  77 */ return new WCRectangle(
         (float) localWindow.getX(),
         (float) localWindow.getY(),
         (float) localWindow.getWidth(),
         (float) localWindow.getHeight());
     /*     */ }
   /*     */
   /*  81 */ return null;
   /*     */ }
  /**
   * Show this popup right below the given Node
   *
   * @param node
   */
  public void show(Node node) {

    if (node.getScene() == null || node.getScene().getWindow() == null)
      throw new IllegalStateException(
          "Can not show popup. The node must be attached to a scene/window."); //$NON-NLS-1$

    if (isShowing()) {
      return;
    }

    Window parent = node.getScene().getWindow();
    this.show(
        parent,
        parent.getX() + node.localToScene(0, 0).getX() + node.getScene().getX(),
        parent.getY() + node.localToScene(0, 0).getY() + node.getScene().getY() + TITLE_HEIGHT);
  }
 /*     */ public WCPoint windowToScreen(WCPoint paramWCPoint) /*     */ {
   /* 125 */ WebView localWebView = this.accessor.getView();
   /* 126 */ Scene localScene = localWebView.getScene();
   /* 127 */ Window localWindow = null;
   /*     */
   /* 129 */ if ((localScene != null) && ((localWindow = localScene.getWindow()) != null))
   /*     */ {
     /* 132 */ Point2D localPoint2D =
         localWebView.localToScene(paramWCPoint.getX(), paramWCPoint.getY());
     /* 133 */ return new WCPoint(
         (float) (localPoint2D.getX() + localScene.getX() + localWindow.getX()),
         (float) (localPoint2D.getY() + localScene.getY() + localWindow.getY()));
     /*     */ }
   /*     */
   /* 136 */ return new WCPoint(0.0F, 0.0F);
   /*     */ }
 /*     */ public WCPoint screenToWindow(WCPoint paramWCPoint) {
   /* 108 */ WebView localWebView = this.accessor.getView();
   /* 109 */ Scene localScene = localWebView.getScene();
   /* 110 */ Window localWindow = null;
   /*     */
   /* 112 */ if ((localScene != null) && ((localWindow = localScene.getWindow()) != null))
   /*     */ {
     /* 115 */ Point2D localPoint2D =
         localWebView.sceneToLocal(
             paramWCPoint.getX() - localWindow.getX() - localScene.getX(),
             paramWCPoint.getY() - localWindow.getY() - localScene.getY());
     /*     */
     /* 118 */ return new WCPoint((float) localPoint2D.getX(), (float) localPoint2D.getY());
     /*     */ }
   /* 120 */ return new WCPoint(0.0F, 0.0F);
   /*     */ }
Esempio n. 7
0
 private void onWindowChanged(Window oldValue, Window newValue) {
   if (oldValue != null) {
     oldValue.focusedProperty().removeListener(windowFocusedObserver);
   }
   if (newValue != null) {
     newValue.focusedProperty().addListener(windowFocusedObserver);
     // check if window is focused
     if (Boolean.TRUE.equals(newValue.focusedProperty().get())) {
       isWindowFocused = true;
       viewerFocusedPropertyBinding.invalidate();
     }
   } else {
     // window unfocused
     isInitialized = false;
     isWindowFocused = false;
     viewerFocusedPropertyBinding.invalidate();
   }
 }
Esempio n. 8
0
  /*
   * Show a dialog window with the given node as the root node, and perform
   * the given action when the dialog is shown.
   */
  private static void showDialog(Parent root, final OnShownAction onShown) {

    // Create an undecorated modal stage, with the main window as its owner,
    // and the given root as its content

    final Stage dialog = new Stage(StageStyle.UNDECORATED);
    dialog.initModality(Modality.WINDOW_MODAL);

    final Window owner = Model.getInstance().getMainWindow();
    dialog.initOwner(owner);

    dialog.setScene(new Scene(root));

    dialog.setOnShown(
        new EventHandler<WindowEvent>() {
          @Override
          public void handle(WindowEvent t) {

            // Center the dialog within the main window.
            dialog.setX(owner.getX() + owner.getWidth() / 2 - dialog.getWidth() / 2);
            dialog.setY(owner.getY() + owner.getHeight() / 2 - dialog.getHeight() / 2);

            // Perform the optional callback.
            if (onShown != null) {
              onShown.perform();
            }
          }
        });

    // Fade out the main window, show the dialog, wait for it the closed,
    // then fade the main window back in.

    FadeTransitionBuilder.create().node(owner.getScene().getRoot()).toValue(0.25).build().play();

    dialog.showAndWait();

    FadeTransitionBuilder.create().node(owner.getScene().getRoot()).toValue(1).build().play();
  }
  public static void closeApplicationWindows(final ClassLoader appClassLoader) {
    final List<Window> selectedWindows = new ArrayList<Window>();
    final Iterator<Window> allWindows = Window.impl_getWindows();
    while (allWindows.hasNext()) {
      final Window window = allWindows.next();
      if (matches(window, appClassLoader)) {
        selectedWindows.add(window);
      }
    }

    for (int i = selectedWindows.size() - 1; i >= 0; --i) {
      selectedWindows.get(i).hide();
    }
  }
Esempio n. 10
0
 /** Bounds of Window on Screen. */
 public static Bounds bounds(Window window) {
   return bounds(window.getX(), window.getY(), window.getWidth(), window.getHeight());
 }
Esempio n. 11
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));
  }