コード例 #1
0
  /** displays the new character views */
  @FXML
  private void showNewChar() {
    try {
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(this.getClass().getResource("dialogs/NewCharacterDialog.fxml"));
      AnchorPane page = (AnchorPane) loader.load();

      // Create the dialog Stage.
      Stage dialogStage = new Stage();
      dialogStage.setTitle("Create New Character");
      dialogStage.initModality(Modality.WINDOW_MODAL);
      dialogStage.initStyle(StageStyle.UTILITY);
      dialogStage.initOwner(this.getInterface().getPrimaryStage());
      dialogStage.resizableProperty().set(false);
      Scene scene = new Scene(page);
      dialogStage.setScene(scene);

      // Set the person into the controller.
      NewCharacterController controller = loader.getController();
      controller.setDialogStage(dialogStage);
      controller.setInterface(getInterface());
      controller.loadPartials();
      dialogStage
          .onCloseRequestProperty()
          .set(
              (EventHandler<WindowEvent>)
                  (WindowEvent event) -> {
                    controller.handleCancel(null);
                  });

      // Show the dialog and wait until the user closes it
      dialogStage.showAndWait();

      if (controller.getCharacter() != null)
        ((RootController) this.getRoot()).setCharacter(controller.getCharacter());
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
コード例 #2
0
ファイル: JEConfig.java プロジェクト: AIT-GR/JEConfig
  /**
   * Build an new JEConfig Login and main frame/stage
   *
   * @param primaryStage
   */
  private void initGUI(Stage primaryStage) {
    Scene scene;
    LoginGlass login = new LoginGlass(primaryStage);

    AnchorPane jeconfigRoot = new AnchorPane();
    AnchorPane.setTopAnchor(jeconfigRoot, 0.0);
    AnchorPane.setRightAnchor(jeconfigRoot, 0.0);
    AnchorPane.setLeftAnchor(jeconfigRoot, 0.0);
    AnchorPane.setBottomAnchor(jeconfigRoot, 0.0);

    Screen screen = Screen.getPrimary();
    Rectangle2D bounds = screen.getVisualBounds();

    login
        .getLoginStatus()
        .addListener(
            new ChangeListener<Boolean>() {

              @Override
              public void changed(
                  ObservableValue<? extends Boolean> observable,
                  Boolean oldValue,
                  Boolean newValue) {
                if (newValue) {
                  System.out.println("after request");
                  _mainDS = login.getDataSource();
                  ds = _mainDS;
                  _currentUser = new User(ds);

                  Platform.runLater(
                      new Runnable() {
                        @Override
                        public void run() {
                          FadeTransition ft = new FadeTransition(Duration.millis(1500), login);
                          ft.setFromValue(1.0);
                          ft.setToValue(0);
                          ft.setCycleCount(1);
                          ft.play();
                        }
                      });

                  JEConfig.PROGRAMM_INFO.setJEVisAPI(ds.getInfo());
                  JEConfig.PROGRAMM_INFO.addLibrary(org.jevis.commons.application.Info.INFO);
                  JEConfig.PROGRAMM_INFO.addLibrary(org.jevis.application.Info.INFO);

                  preLodedClasses = login.getAllClasses();
                  preLodedRootObjects = login.getRootObjects();

                  PluginManager pMan = new PluginManager(ds);
                  GlobalToolBar toolbar = new GlobalToolBar(pMan);
                  pMan.addPluginsByUserSetting(null);

                  BorderPane border = new BorderPane();
                  VBox vbox = new VBox();
                  vbox.setStyle("-fx-background-color: black;");
                  //                    vbox.getChildren().addAll(new TopMenu(),
                  // toolbar.ToolBarFactory());
                  vbox.getChildren().addAll(new TopMenu(), pMan.getToolbar());
                  border.setTop(vbox);
                  border.setCenter(pMan.getView());

                  Statusbar statusBar = new Statusbar(ds);

                  border.setBottom(statusBar);

                  // Disable GUI is StatusBar note an disconnect
                  border.disableProperty().bind(statusBar.connectedProperty.not());

                  Platform.runLater(
                      new Runnable() {
                        @Override
                        public void run() {

                          AnchorPane.setTopAnchor(border, 0.0);
                          AnchorPane.setRightAnchor(border, 0.0);
                          AnchorPane.setLeftAnchor(border, 0.0);
                          AnchorPane.setBottomAnchor(border, 0.0);

                          jeconfigRoot.getChildren().setAll(border);
                          try {
                            WelcomePage welcome =
                                new WelcomePage(primaryStage, _config.getWelcomeURL());
                          } catch (URISyntaxException ex) {
                            Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex);
                          } catch (MalformedURLException ex) {
                            Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex);
                          }
                        }
                      });
                }
              }
            });

    AnchorPane.setTopAnchor(login, 0.0);
    AnchorPane.setRightAnchor(login, 0.0);
    AnchorPane.setLeftAnchor(login, 0.0);
    AnchorPane.setBottomAnchor(login, 0.0);

    scene = new Scene(jeconfigRoot, bounds.getWidth(), bounds.getHeight());
    scene.getStylesheets().add("/styles/Styles.css");
    primaryStage.getIcons().add(getImage("JEVisIconBlue.png"));

    primaryStage.setTitle("JEConfig");
    primaryStage.setScene(scene);
    primaryStage.setMaximized(true);
    //        maximize(primaryStage);
    primaryStage.show();

    jeconfigRoot.getChildren().setAll(login);

    primaryStage
        .onCloseRequestProperty()
        .addListener(
            new ChangeListener<EventHandler<WindowEvent>>() {

              @Override
              public void changed(
                  ObservableValue<? extends EventHandler<WindowEvent>> ov,
                  EventHandler<WindowEvent> t,
                  EventHandler<WindowEvent> t1) {
                try {
                  System.out.println("Disconnect");
                  ds.disconnect();
                } catch (JEVisException ex) {
                  Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex);
                }
              }
            });
  }