public boolean showChapitreAddDialog(Chapitre chapitre, int id) {
    try {
      // Load the fxml file and create a new stage for the popup dialog.
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(MainApp.class.getResource("/fxml/addChapitre.fxml"));
      AnchorPane page = (AnchorPane) loader.load();

      // Create the dialog Stage.
      Stage dialogStage = new Stage();
      dialogStage.setTitle("Ajouter un Cours");
      dialogStage.initModality(Modality.APPLICATION_MODAL);
      dialogStage.initStyle(StageStyle.UTILITY);
      dialogStage.initOwner(primaryStage);
      Scene scene = new Scene(page);
      dialogStage.setScene(scene);

      // Set the cours into the controller.
      AddChapitreController controller = loader.getController();
      controller.setDialogStage(dialogStage);
      controller.setChapitre(chapitre, id);

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

      return controller.isOkClicked();
    } catch (IOException e) {
      e.printStackTrace();
      return false;
    }
  }
Exemple #2
0
  @Override
  public void start(Stage primaryStage) throws Exception {

    DeleteController dCtrl = new DeleteController();

    Parent editAlbum = null;
    FXMLLoader editAlbumLoader = new FXMLLoader();
    editAlbum = editAlbumLoader.load(getClass().getResource("/fxml/editAlbum.fxml").openStream());
    EditAlbumController eACtrl = editAlbumLoader.getController();
    eACtrl.setParent(editAlbum);
    if (eACtrl == null) System.out.println("edit album controllern är null");

    Parent addAlbum = null;
    FXMLLoader addAlbumLoader = new FXMLLoader();
    addAlbum = addAlbumLoader.load(getClass().getResource("/fxml/addAlbum.fxml").openStream());
    AddAlbumController aACtrl = addAlbumLoader.getController();
    aACtrl.setParent(addAlbum);
    if (aACtrl == null) System.out.println("add album controllern är null");

    Parent root = null;
    FXMLLoader loader = new FXMLLoader();
    System.out.println(getClass().getResource("/fxml/main.fxml"));
    root = loader.load(getClass().getResource("/fxml/main.fxml").openStream());
    MainController mCtrl = loader.getController();
    if (mCtrl == null) System.out.println("main controllern är null");

    mCtrl.setControllers(aACtrl, eACtrl, dCtrl);

    primaryStage.setTitle("Media Center");
    primaryStage.setScene(new Scene(root, 1280, 720));
    primaryStage.show();
  }
Exemple #3
0
  /**
   * Load a FXML component.
   *
   * <p>The fxml path could be :
   *
   * <ul>
   *   <li>Relative : fxml file will be loaded with the classloader of the given model class
   *   <li>Absolute : fxml file will be loaded with default thread class loader, packages must be
   *       separated by / character
   * </ul>
   *
   * @param model the model that will manage the fxml node
   * @param fxmlPath the fxml string path
   * @param bundlePath the bundle string path
   * @return a FXMLComponent object that wrap a fxml node with its controller
   * @param <M> the model type that will manage this fxml node
   */
  @SuppressWarnings("unchecked")
  public static <M extends Model> FXMLComponentBase loadFXML(
      final M model, final String fxmlPath, final String bundlePath) {

    final FXMLLoader fxmlLoader = new FXMLLoader();

    // Use Custom controller factory to attach the root model to the controller
    fxmlLoader.setControllerFactory(new DefaultFXMLControllerBuilder(model));

    fxmlLoader.setLocation(convertFxmlUrl(model, fxmlPath));

    try {
      if (bundlePath != null) {
        fxmlLoader.setResources(ResourceBundle.getBundle(bundlePath));
      }
    } catch (final MissingResourceException e) {
      LOGGER.log(MISSING_RESOURCE_BUNDLE, e, bundlePath);
    }

    Node node = null;
    boolean error = false;
    try {
      error = fxmlLoader.getLocation() == null;
      if (error) {
        node = TextBuilder.create().text(FXML_ERROR_NODE_LABEL.getText(fxmlPath)).build();
      } else {
        node = (Node) fxmlLoader.load(fxmlLoader.getLocation().openStream());
      }

    } catch (final IOException e) {
      throw new CoreRuntimeException(FXML_NODE_DOESNT_EXIST.getText(fxmlPath), e);
    }

    final FXMLController<M, ?> fxmlController = (FXMLController<M, ?>) fxmlLoader.getController();

    // It's tolerated to have a null controller for an fxml node
    if (fxmlController != null) {
      // The fxml controller must extends AbstractFXMLController
      if (!error && !(fxmlLoader.getController() instanceof AbstractFXMLController)) {
        throw new CoreRuntimeException(
            BAD_FXML_CONTROLLER_ANCESTOR.getText(
                fxmlLoader.getController().getClass().getCanonicalName()));
      }
      // Link the View component with the fxml controller
      fxmlController.setModel(model);
    }

    return new FXMLComponentBase(node, fxmlController);
  }
  @Override
  public IceApplicationProvider.IceApp create(ApplicationContext parentContext) throws IOException {
    FXMLLoader loader = new FXMLLoader(VitalMonitoring.class.getResource("VitalMonitoring.fxml"));
    final Parent ui = loader.load();
    final VitalMonitoring vitalMonitoring = loader.getController();
    vitalMonitoring.setup();

    return new IceApplicationProvider.IceApp() {

      @Override
      public IceApplicationProvider.AppType getDescriptor() {
        return PCAViz;
      }

      @Override
      public Parent getUI() {
        return ui;
      }

      @Override
      public void activate(ApplicationContext context) {
        VitalModel vitalModel = (VitalModel) context.getBean("vitalModel");
        vitalMonitoring.setModel(vitalModel);
      }

      @Override
      public void stop() {
        vitalMonitoring.setModel(null);
      }

      @Override
      public void destroy() {}
    };
  }
  @FXML
  void processNewGame(ActionEvent event) {
    GestorLogs.registrarLog("Creando nuevo Juego...");
    String fxml = ConstantesFXML.FXML_CREAR_JUEGO;

    try {
      Parent root;
      Stage stage = new Stage();
      FXMLLoader loader = ScreensFramework.getLoader(fxml);

      root = (Parent) loader.load();
      CrearJuegoController controller = (CrearJuegoController) loader.getController();
      controller.setPrevStage(currentStage);
      controller.setUsuarioLogueado(usuarioLogueado);

      Scene scene = new Scene(root);
      stage.setScene(scene);
      stage.setTitle("Monopoly - Nuevo Juego");
      stage.centerOnScreen();
      controller.setCurrentStage(stage);
      int senderId = ConnectionController.getInstance().getIdPlayer();
      ConnectionController.getInstance().send(new CreateGameMessage(senderId, usuarioLogueado));

    } catch (Exception ex) {
      GestorLogs.registrarException(ex);
    }
  }
  @FXML
  void processJoinGame(ActionEvent event) {
    GestorLogs.registrarLog("Creando nuevo Juego...");
    String fxml = ConstantesFXML.FXML_UNIRME_JUEGO;

    try {
      Parent root;
      Stage stage = new Stage();
      FXMLLoader loader = ScreensFramework.getLoader(fxml);

      root = (Parent) loader.load();
      UnirmeJuegoController controller = (UnirmeJuegoController) loader.getController();
      controller.setPrevStage(currentStage);
      controller.setUsuarioLogueado(usuarioLogueado);

      Scene scene = new Scene(root);
      stage.setScene(scene);
      stage.setTitle("Monopoly - Unirme a Juego");
      stage.centerOnScreen();
      controller.setCurrentStage(stage);
      // int senderId = ConnectionController.getInstance().getIdPlayer();
      // ConnectionController.getInstance().send(new
      // JoinGameMessage(senderId, usuarioLogueado));
      ConnectionController.getInstance().send(ConstantesMensaje.GET_PENDING_GAMES_MESSAGE);

    } catch (Exception ex) {
      GestorLogs.registrarException(ex);
    }
  }
  @FXML
  public void handleInspectionButton() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setInitialDirectory(new File("C:\\Users\\Christoph\\OneDrive\\newAnalysis"));
    fileChooser.setTitle("Choose Invariant File");
    fileChooser.getExtensionFilters().addAll(new ExtensionFilter("Invariant Files", "*.txt"));

    File selectedFile = fileChooser.showOpenDialog(stage);
    if (selectedFile != null) {
      try {
        FXMLLoader loader = new FXMLLoader();
        BorderPane root =
            (BorderPane)
                loader.load(getClass().getResource("InvariantInspectorTab.fxml").openStream());
        InvariantInspectorTabController controller =
            (InvariantInspectorTabController) loader.getController();
        controller.setPrimaryStage(stage);
        controller.loadData(selectedFile);

        Tab tab = new Tab();
        tab.setContent(root);

        tabPane.getTabs().add(tab);

      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
Exemple #8
0
  public StageLoader(String xmlPath, boolean isMainStageOwner) {
    try {
      FXMLLoader loader =
          new FXMLLoader(new File(Utils.getFullPath("./ui/" + xmlPath)).toURI().toURL());
      Parent root = loader.load();
      controller = loader.getController();

      Scene scene = new Scene(root);
      setScene(scene);

      if (isMainStageOwner) {
        initModality(Modality.NONE);
        initOwner(SingleObject.mainStage.getScene().getWindow());
      }

      getScene()
          .addEventHandler(
              KeyEvent.KEY_PRESSED,
              t -> {
                if (t.getCode() == KeyCode.ESCAPE) {
                  LogFiles.log.log(Level.INFO, "Exit " + getTitle());
                  ((Stage) ((Scene) t.getSource()).getWindow()).hide();
                } else if (t.getCode() == KeyCode.ENTER) {
                  runOnEnter(method);
                }
              });
    } catch (IOException e) {
      LogFiles.log.log(Level.SEVERE, e.getMessage(), e);
    }
  }
  public void onFilterActivated() {
    try {
      FXMLLoader filterDialogFile =
          new FXMLLoader(MainApp.class.getResource("view/FilterDialog.fxml"));
      ResourceBundleService.setResourceBundle(filterDialogFile);
      AnchorPane anchorPane = filterDialogFile.load();

      Stage stage = new Stage();
      stage.setResizable(false);
      stage.setTitle(_resources.getString("filter.dialog.title"));
      stage.getIcons().add(_mainApp.getApplicationIcon());
      stage.initModality(Modality.WINDOW_MODAL);
      stage.initOwner(_mainApp.getPrimaryStage());

      stage.setScene(new Scene(anchorPane));

      FilterDialogController controller = filterDialogFile.getController();
      controller.setMainApp(_mainApp);
      controller.setOwner(stage);

      stage.showAndWait();
    } catch (IOException ioEx) {
      ExceptionDialog.show(
          _resources.getString("app.error.dialog.title"),
          _resources.getString("app.error.dialog.header"),
          _resources.getString("app.error.dialog.content.filter"),
          ioEx,
          _mainApp);
    }
  }
  /**
   * Displays dialog that allows user to select local text file to display in TextArea
   *
   * @param ta - reference to TextArea to display loaded text file
   */
  public void showLoadFileDialog(AutoSpellingTextArea ta) {
    try {
      // Load the fxml file and create a new stage for the popup
      FXMLLoader loader = new FXMLLoader(MainApp.class.getResource("view/LoadFileLayout.fxml"));
      VBox page = (VBox) loader.load();
      Stage dialogStage = new Stage();
      dialogStage.setTitle("Load File");
      dialogStage.initModality(Modality.WINDOW_MODAL);
      dialogStage.initOwner(primaryStage);
      Scene scene = new Scene(page);
      dialogStage.setScene(scene);

      // Set reference to stage in controller
      LoadFileDialogController controller = loader.getController();
      controller.setDialogStage(dialogStage);

      // give controller reference to text area to load file into
      controller.setTextArea(ta);

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

    } catch (IOException e) {
      // Exception gets thrown if the fxml file could not be loaded
      e.printStackTrace();
    }
  }
  /**
   * Shows the progress dialog and start the progress of all the tasks while reading the file
   *
   * @param file
   */
  public void showProgressDialog(File file) {

    try {
      // Load the fxml file and create a new stage for the popup dialog.
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(SolarSizerAppMain.class.getResource("view/ProgressWindow.fxml"));
      AnchorPane page = (AnchorPane) loader.load();

      // Create the dialog Stage.
      progressDialogStage = new Stage();
      progressDialogStage.setTitle("Working...");
      progressDialogStage.initModality(Modality.WINDOW_MODAL);
      Scene scene = new Scene(page);
      progressDialogStage.setScene(scene);

      // Set the person into the controller.
      ProgressDialogController controller = loader.getController();
      controller.setFile(file);
      controller.setDataProcessedListener(this);
      // Show the dialog and wait until the user closes it
      progressDialogStage.show();
      // calls to process data
      controller.processData();

    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  public void showEditDistanceDialog(String selectedText) {
    try {
      // Load the fxml file and create a new stage for the popup
      FXMLLoader loader = new FXMLLoader(MainApp.class.getResource("view/EditDistanceLayout.fxml"));
      VBox page = (VBox) loader.load();
      Stage dialogStage = new Stage();
      dialogStage.setTitle("Calculate Edit Distance");
      dialogStage.initModality(Modality.WINDOW_MODAL);
      dialogStage.initOwner(primaryStage);
      Scene scene = new Scene(page);
      dialogStage.setScene(scene);

      // Set reference to stage in controller
      EditDistanceDialogController controller = loader.getController();
      controller.setDialogStage(dialogStage);
      controller.setMainApp(this);
      controller.setField(selectedText);

      // give controller reference to scene (cursor)

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

    } catch (IOException e) {
      // Exception gets thrown if the fxml file could not be loaded
      e.printStackTrace();
    }
  }
  public void showMarkovDialog(textgen.MarkovTextGenerator mtg) {
    try {
      // Load the fxml file and create a new stage for the popup
      FXMLLoader loader = new FXMLLoader(MainApp.class.getResource("view/MarkovLayout.fxml"));
      BorderPane page = (BorderPane) loader.load();
      Stage dialogStage = new Stage();
      dialogStage.setTitle("Markov Text Generator");
      // dialogStage.initModality(Modality.WINDOW_MODAL);
      dialogStage.initOwner(primaryStage);
      Scene scene = new Scene(page);
      dialogStage.setScene(scene);

      // Set reference to stage in controller
      // BUG -- when first displayed results don't show up until resize window
      MarkovController controller = loader.getController();
      // controller.setDialogStage(dialogStage);
      controller.setMainApp(this);
      controller.setMTG(mtg);

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

    } catch (IOException e) {
      // Exception gets thrown if the fxml file could not be loaded
      e.printStackTrace();
    }
  }
  @Override
  public void start(Stage stage) throws Exception {

    FXMLLoader LOADER = new FXMLLoader(getClass().getResource("/view/createServer.fxml"));

    // Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml")); -- original LOC
    // when framed

    Parent root = (Parent) LOADER.load();

    createServer_controller_no_use controller =
        (createServer_controller_no_use) LOADER.getController();

    controller.init(stage);

    Scene scene = new Scene(root);

    // stage.initStyle(StageStyle.UNDECORATED); -- Not to use all 3 buttons ->min,max,close
    // stage.initStyle(StageStyle.UTILITY); -- Only use close not min and max
    stage.resizableProperty().setValue(Boolean.FALSE); // Use min and close not max
    stage.setTitle("Jishnu Offline Typeracer");
    stage.setScene(scene);
    stage.getIcons().add(new Image("file:pics/server.png"));
    stage.show();
  }
  @FXML
  private void HandleFindReplaceDialog() {
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(MainApp.class.getResource("fxml/FindReplaceDialog.fxml"));

    try {
      AnchorPane optionsDialog = loader.load();

      Stage dialogStage = new Stage();
      dialogStage.setTitle("Rechecher / Remplacer");

      Scene scene = new Scene(optionsDialog);
      dialogStage.setScene(scene);
      dialogStage
          .getIcons()
          .add(new Image(MainApp.class.getResourceAsStream("assets/static/icons/logo.png")));
      dialogStage.setResizable(false);
      dialogStage.initModality(Modality.APPLICATION_MODAL);

      FindReplaceDialog findReplaceDialog = loader.getController();
      findReplaceDialog.setMainApp(mainApp);
      findReplaceDialog.setWindow(dialogStage);
      findReplaceDialog.setMdConvertController(this);

      dialogStage.show();
    } catch (IOException e) {
      logger.error(e.getMessage(), e);
    }
  }
Exemple #16
0
  public boolean showDbConnectDialog() {
    try {
      // Load the fxml file and create a new stage for the popup dialog.
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(Main.class.getResource("view/DbConnectDialog.fxml"));
      AnchorPane page = (AnchorPane) loader.load();

      // Create the dialog Stage.
      Stage dialogStage = new Stage();
      dialogStage.setTitle("Під'єднання до БД");
      dialogStage.initModality(Modality.WINDOW_MODAL);
      dialogStage.initOwner(primaryStage);
      Scene scene = new Scene(page);
      dialogStage.setScene(scene);

      // Set the person into the controller.
      sample.view.DbConnectDialogController controller = loader.getController();
      controller.setDialogStage(dialogStage);
      controller.setConnectField();

      // Set the dialog icon.
      dialogStage.getIcons().add(new Image("file:resources/images/edit.png"));

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

      return controller.isOkClicked();
    } catch (IOException e) {
      e.printStackTrace();
      return false;
    }
  }
  /**
   * Instancie un controleur secondaire pour la fenetre de consultation du mot à consulter
   *
   * @return
   */
  private Stage loadConsultation() {
    Stage stageConsultation = null;
    FXMLLoader fxmlLoader = new FXMLLoader(this.getClass().getResource("../dictionnaire_mot.fxml"));

    VBox rootConsultation = null;

    try {
      rootConsultation = (VBox) fxmlLoader.load();
      FXMLController_2 subController = (FXMLController_2) fxmlLoader.getController();

      subController.setController(this);
      subController.setMotAConsulter(model.motSelectionne);
      subController.setImage();
      subController.init();

      Scene sceneConsultation = new Scene(rootConsultation);
      stageConsultation = new Stage();
      stageConsultation.setScene(sceneConsultation);
      stageConsultation.setTitle("Consultation");

      setConsultWindowCloseHandler(stageConsultation, subController);

    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return stageConsultation;
  }
Exemple #18
0
  public DownloadDialogController showDownloadDialog(Modpack modpack) {
    try {
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(TRLauncher.class.getResource("view/downloaddialog/DownloadDialog.fxml"));

      AnchorPane pane = loader.load();

      Stage dialogStage = new Stage();
      dialogStage.setTitle("Downloading Modpack");
      dialogStage.initModality(Modality.WINDOW_MODAL);
      dialogStage.initOwner(primaryStage);
      Scene scene = new Scene(pane);
      dialogStage.setScene(scene);

      DownloadDialogController controller = loader.getController();
      controller.setDialogStage(dialogStage);
      controller.setModpack(modpack);

      controller.setDownloadingLabelText("Downloading " + modpack.getDisplayName());

      dialogStage.show();

      try {
        Thread.sleep(4000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }

      return controller;
    } catch (IOException e) {
      System.err.println("Couldn't find the specified layout");
      e.printStackTrace();
      return null;
    }
  }
  @Override
  @FXML
  protected void abrirModalCreate() {
    try {
      // Carrega o arquivo fxml e cria um novo stage para a janela popup.
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(getClass().getResource("fxml/dialog/dialogFuncionario.fxml"));
      GridPane page = (GridPane) loader.load();

      // Cria o palco dialogStage.
      Stage dialogStage = new Stage();
      dialogStage.initModality(Modality.WINDOW_MODAL);
      dialogStage.initOwner(ControllerTelas.stage);
      Scene scene = new Scene(page);
      dialogStage.setScene(scene);

      // Define a pessoa no controller.
      DialogController<Funcionario> controller = loader.getController();
      controller.setTipe(DialogController.CREATE_MODAL);
      controller.setDialogStage(dialogStage);
      dialogStage.setTitle(controller.getTitulo());
      dialogStage.setResizable(false);
      // Mostra a janela e espera até o usuário fechar.
      dialogStage.showAndWait();

      tabela.getItems().clear();
      atualizarLista();

    } catch (IOException e) {
      e.printStackTrace();
    }
  }
Exemple #20
0
  private void initialiseEditConnectionsWindow() {
    // This is a dirty way to reload connection settings :) possibly could be removed if all
    // connections are closed before loading a new config file
    if (editConnectionsController != null) {
      eventManager.deregisterConnectionStatusObserver(editConnectionsController);
    }

    final FXMLLoader loader =
        FxmlUtils.createFxmlLoaderForProjectFile("EditConnectionsWindow.fxml");
    final AnchorPane connectionWindow = FxmlUtils.loadAnchorPane(loader);
    editConnectionsController = ((EditConnectionsController) loader.getController());
    editConnectionsController.setMainController(this);
    editConnectionsController.setEventManager(eventManager);
    editConnectionsController.setConnectionManager(connectionManager);
    editConnectionsController.setConfigurationManager(configurationManager);
    editConnectionsController.init();

    Scene scene = new Scene(connectionWindow);
    scene.getStylesheets().addAll(mainPane.getScene().getStylesheets());

    editConnectionsStage = new Stage();
    editConnectionsStage.setTitle("Connection list");
    editConnectionsStage.initModality(Modality.WINDOW_MODAL);
    editConnectionsStage.initOwner(getParentWindow());
    editConnectionsStage.setScene(scene);
  }
 @FXML
 void gruppenWuerfelnClicked(ActionEvent e) throws IOException {
   addGruppenGroesse(); // Gruppengöße setzen
   setGroupCount(); // Gruppenanzahl setzen
   /**
    * if(Inputs.isUseGroupSize()) { Inputs.setAllGroups(RandomGroups.createRandomGroups("size",
    * Integer.parseInt(gruppenGroesseText.getText()), Inputs.getSelectedStudentClasses())); } else
    * { Inputs.setAllGroups(RandomGroups.createRandomGroups("count",
    * Integer.parseInt(groupCountField.getText()), Inputs.getSelectedStudentClasses())); }
    *
    * <p>for(int i = 0 ; i < Inputs.getAllGroups().size() ; i++) {
    * Inputs.getSaveGroups().put("GruppenID", Inputs.getSaveGroups().getGroupID());
    * Inputs.getSaveGroups().put("StudentenID",
    * Inputs.getSaveGroups().getMembers().getStudentID()); }
    *
    * <p>Inputs.database.insert("StudentenGruppen", Inputs.getSaveGroups());
    */
   FXMLLoader Loader = new FXMLLoader(getClass().getResource("gruppen.fxml"));
   Parent rootGroup = Loader.load();
   Scene sceneGroup = new Scene(rootGroup, 600, 450);
   stage.setTitle("Gruppenbildung");
   stage.setScene(sceneGroup);
   GruppenController controllerGroup = Loader.<GUI.GruppenController>getController();
   controllerGroup.setStage(stage);
 }
  private void showObjectifDialog(int id) {
    try {
      // Load the fxml file and create a new stage for the popup dialog.
      System.out.println("hello");
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(MainApp.class.getResource("/fxml/displayObjectif.fxml"));
      AnchorPane page = (AnchorPane) loader.load();

      // Create the dialog Stage.
      Stage dialogStage = new Stage();
      dialogStage.setTitle("Objectif");
      dialogStage.initModality(Modality.APPLICATION_MODAL);
      dialogStage.initStyle(StageStyle.UTILITY);
      dialogStage.initOwner(primaryStage);
      Scene scene = new Scene(page);
      dialogStage.setScene(scene);

      // Set the cours into the controller.
      DisplayObjectifController control = loader.getController();
      control.setDialogStage(dialogStage);
      control.setObjectif(id);

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

    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  public String showSetUsernameDialog() {
    try {
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(TRLauncher.class.getResource("view/account/SetUsername.fxml"));

      AnchorPane pane = loader.load();

      Stage dialogStage = MiscUtils.addIcons(new Stage());
      dialogStage.setTitle("Add Account");
      dialogStage.initModality(Modality.WINDOW_MODAL);
      dialogStage.initOwner(primaryStage);
      Scene scene = new Scene(pane);
      dialogStage.setScene(scene);

      SetUsernameController controller = loader.getController();
      controller.setDialogStage(dialogStage);

      dialogStage.showAndWait();

      return controller.getUsername();

    } catch (IOException e) {
      TRLauncher.log.error("Couldn't find the specified layout");
      TRLauncher.log.catching(e);
      Issues.create(null, e);
      return null;
    }
  }
Exemple #24
0
  public boolean showPersonEditDialog(Person person) {
    try {
      // Load the fxml file and create a new stage for the popup dialog.
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(MainApp.class.getResource("view/PersonEditDialog.fxml"));
      AnchorPane page = (AnchorPane) loader.load();

      // Create the dialog Stage.
      Stage dialogStage = new Stage();
      dialogStage.setTitle("Edit Person");
      dialogStage.initModality(Modality.WINDOW_MODAL);
      dialogStage.initOwner(primaryStage);
      Scene scene = new Scene(page);
      dialogStage.setScene(scene);

      // Set the person into the controller.
      PersonEditDialogController controller = loader.getController();
      controller.setDialogStage(dialogStage);
      controller.setPerson(person);

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

      return controller.isOkClicked();
    } catch (IOException e) {
      e.printStackTrace();
      return false;
    }
  }
  public PasswordRetryDialogController showPasswordDialog(String username, String failureMessage) {
    try {
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(
          TRLauncher.class.getResource("view/passworddialog/retry/PasswordRetryDialog.fxml"));

      AnchorPane pane = loader.load();

      Stage dialogStage = MiscUtils.addIcons(new Stage());
      dialogStage.setTitle("Login (Retry)");
      dialogStage.initModality(Modality.WINDOW_MODAL);
      dialogStage.initOwner(primaryStage);
      Scene scene = new Scene(pane);
      dialogStage.setScene(scene);

      PasswordRetryDialogController controller = loader.getController();
      controller.setDialogStage(dialogStage);
      controller.setUsername(username);
      controller.setFailureMessage(failureMessage);

      dialogStage.showAndWait();

      return controller;

    } catch (IOException e) {
      TRLauncher.log.error("Couldn't find the specified layout");
      TRLauncher.log.catching(e);
      Issues.create(null, e);
      return null;
    }
  }
  /** Opens the filter window to enable filters. */
  public boolean filters() {
    try {
      String filters = "/java_ebook_search/view/FiltersView.fxml";
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(getClass().getResource(filters));
      AnchorPane page = loader.load();
      Stage dialogStage = new Stage();
      dialogStage.setTitle("Filters");
      dialogStage.initModality(Modality.APPLICATION_MODAL);
      dialogStage.setResizable(false);
      dialogStage.initOwner(searchView.getParent().getScene().getWindow());
      Scene scene = new Scene(page);
      dialogStage.setScene(scene);

      // Set the Filter into the controller.
      FiltersController controller = loader.getController();
      controller.setDialogStage(dialogStage);
      if (null != filter) {
        controller.setFilter(filter);
      }

      // Show the dialog and wait until the user closes it
      dialogStage.showAndWait();
      // Set Filters
      this.filter = controller.getFilter();

      // Trigger search
      search();
      return controller.isOkClicked();
    } catch (IOException | ParseException e) {
      e.printStackTrace();
      return false;
    }
  }
  @FXML
  public void ProductDetails() {

    try {
      URL location = getClass().getResource("proTableview.fxml");

      FXMLLoader fxmlLoader = new FXMLLoader();
      fxmlLoader.setLocation(location);
      fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());

      Parent root1 = (Parent) fxmlLoader.load(location.openStream());

      proTableViewController ctr = (proTableViewController) fxmlLoader.getController();

      Scene scene = new Scene(root1);

      RuwanBook.getStage().setTitle("Product Details");
      RuwanBook.getStage().setScene(scene);

      RuwanBook.getStage().show();

    } catch (IOException ex) {
      Logger.getLogger(SupplierController.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
Exemple #28
0
  public static void showArchives(Stage s) {
    try {
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(ShowArchives.class.getResource("./fxml/archiveView.fxml"));

      Parent root = (Parent) loader.load();
      ShowArchives section = loader.getController();

      Scene scene = new Scene(root);

      Stage stage = new Stage();
      stage.setScene(scene);
      section.setParent(stage);
      section.loadInfo();

      stage.initOwner(s);
      stage.initModality(Modality.APPLICATION_MODAL);
      stage.setResizable(false);
      stage.initStyle(StageStyle.UTILITY);

      stage.showAndWait();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  @Override
  public void start(Stage stage) throws Exception {
    primaryStage = stage;

    primaryStage.setTitle("Générateur de trames de surveillances");

    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(Main.class.getResource("../../../zoo/generator/view/RootLayout.fxml"));

    try {
      rootLayout = loader.load();
      Scene scene = new Scene(rootLayout);
      primaryStage.setScene(scene);

      // Main panel
      FXMLLoader loader2 = new FXMLLoader();
      loader2.setLocation(Main.class.getResource("../../../zoo/generator/view/MainPanel.fxml"));
      BorderPane o = loader2.load();

      scene.setRoot(o);

      MainPanelController controller = loader2.getController();
      controller.setRandomGenerationService(RandomGenerationService.getInstance());

      primaryStage.show();

      primaryStage.setOnCloseRequest(
          new EventHandler<WindowEvent>() {

            @Override
            public void handle(WindowEvent event) {
              System.out.println("Arrêt des threads");
              Thread[] threads = new Thread[100];

              int n = Thread.enumerate(threads);

              for (int i = 0; i < n; i++) {
                System.out.println(threads[i]);
              }

              // 1. Stop random generation
              RandomGenerationService.getInstance().stop();

              // 2. Stop server thread
              Server.getInstance().stop();

              // 3. Stop client threads
              ClientHandler.stopAll();

              System.out.println("Après l'arrêt des threads");
            }
          });

      Server.getInstance().start();

    } catch (IOException e) {
      e.printStackTrace();
    }
  }
Exemple #30
0
  @Override
  public void start(Stage stage) throws Exception {
    FXMLLoader loader = getLoader();

    init(stage, loader);

    mount(loader.getController());
  }