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;
    }
  }
  public SQLHistorySearchCtrl(
      SQLTextAreaServices sqlTextAreaServices,
      Session session,
      ObservableList<SQLHistoryEntry> items) {
    _sqlTextAreaServices = sqlTextAreaServices;

    FxmlHelper<SQLHistorySearchView> fxmlHelper = new FxmlHelper<>(SQLHistorySearchView.class);
    _view = fxmlHelper.getView();

    _dialog = new Stage();
    _dialog.setTitle(
        new I18n(getClass())
            .t("SQLHistorySearchCtrl.title", session.getMainTabContext().getSessionTabTitle()));
    _dialog.initModality(Modality.WINDOW_MODAL);
    _dialog.initOwner(AppState.get().getPrimaryStage());
    Region region = fxmlHelper.getRegion();
    _dialog.setScene(new Scene(region));

    GuiUtils.makeEscapeClosable(region);

    new StageDimensionSaver(
        "sqlhistorysearch",
        _dialog,
        new Pref(getClass()),
        region.getPrefWidth(),
        region.getPrefHeight(),
        _dialog.getOwner());

    _view.cboFilterType.setItems(
        FXCollections.observableList(Arrays.asList(SqlHistoryFilterType.values())));
    _view.cboFilterType.getSelectionModel().selectFirst();

    _view.btnApply.setOnAction(e -> onApply());
    _view.chkFiltered.setOnAction(e -> onChkFiltered());

    _view.split.getItems().add(_tblHistory);
    _view.split.getItems().add(_txtSqlPreview);

    _originalTableLoader = new RowObjectTableLoader<>();
    _originalTableLoader.initColsByAnnotations(SQLHistoryEntry.class);
    _originalTableLoader.addRowObjects(items);
    _currentLoader = _originalTableLoader.cloneLoader();
    _currentLoader.load(_tblHistory);

    _tblHistory
        .getSelectionModel()
        .selectedItemProperty()
        .addListener((observable, oldValue, newValue) -> onTableSelectionChanged());

    _tblHistory.setOnMouseClicked(e -> onTblHistoryClicked(e));

    _txtSqlPreview.setEditable(false);

    _dialog.setOnCloseRequest(e -> close());

    _view.txtFilter.requestFocus();

    _splitPositionSaver.apply(_view.split);
    _dialog.showAndWait();
  }
  public static boolean display(String title, String message) {
    Stage window = new Stage();
    answer = false;

    // Block events to other windows. means don't allow control of the first window untill this
    // window is closed.
    window.initModality(Modality.APPLICATION_MODAL);
    window.setTitle(title);
    window.setMinWidth(250);

    Label label = new Label();
    label.setText(message);

    // Create two buttons
    Button yesButton = new Button("Yes");
    Button noButton = new Button("No");
    yesButton.setOnAction(
        e -> {
          answer = true;
          window.close();
        });
    noButton.setOnAction(e -> window.close());

    VBox layout = new VBox(10);
    layout.getChildren().addAll(label, yesButton, noButton);
    layout.setAlignment(Pos.CENTER);

    // Display window and wait for it to be closed before returning
    Scene scene = new Scene(layout);
    window.setScene(scene);
    //        window.show();
    window.showAndWait(); // show the window & wait unitl it's closed

    return answer;
  }
  private void showError(List<String> errorList) {
    String msg = "";
    if (errorList.isEmpty()) {
      msg = "No message to display.";
    } else {
      for (String s : errorList) {
        msg = msg + s + "\n";
      }
    }
    Label msgLbl = new Label(msg);
    Button okBtn = new Button("OK");
    VBox root = new VBox(new StackPane(msgLbl), new StackPane(okBtn));
    root.setSpacing(10);

    Scene scene = new Scene(root);
    Stage stage = new Stage(StageStyle.UTILITY);
    stage.initModality(Modality.WINDOW_MODAL);
    stage.setScene(scene);
    stage.initOwner(view.getScene().getWindow());

    // Set the Action listener for the OK button
    okBtn.setOnAction(e -> stage.close());

    stage.setTitle("Error");
    stage.sizeToScene();
    stage.showAndWait();
  }
Beispiel #5
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;
    }
  }
  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 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();
    }
  }
  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;
    }
  }
  @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();
    }
  }
Beispiel #10
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();
    }
  }
  /** 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;
    }
  }
Beispiel #12
0
  public void storeLogin() {
    Stage window = new Stage();
    Button button;
    String password = "******";

    Label label = new Label("Please enter the store password");

    window.initModality(Modality.APPLICATION_MODAL);
    window.setTitle("Store Login");
    window.setWidth(300);
    window.setHeight(200);

    final TextField passWordInput = new TextField();
    button = new Button("Enter");
    button.setOnAction(
        e -> {
          String entry = passWordInput.getText();
          if (entry.equalsIgnoreCase(password)) {
            answer = true;
            window.close();
          } else {
            answer = false;
            window.close();
          }
        });

    VBox layout = new VBox(20);
    layout.getChildren().addAll(label, passWordInput, button);
    layout.setAlignment(Pos.CENTER);

    Scene scene = new Scene(layout);
    window.setScene(scene);
    window.showAndWait();
  }
  public static boolean display(String title, String message) {
    Stage window = new Stage();
    window.initModality(Modality.APPLICATION_MODAL);

    Label l1 = new Label(message);

    // Create 2 buttons
    Button yesBtn = new Button("Yes");
    Button noBtn = new Button("No");

    yesBtn.setOnAction(
        e -> {
          ans = true;
          window.close();
        });

    noBtn.setOnAction(
        e -> {
          ans = false;
          window.close();
        });

    HBox hbox = new HBox(10);
    hbox.getChildren().addAll(l1, yesBtn, noBtn);
    hbox.setAlignment(Pos.CENTER);

    Scene sc = new Scene(hbox);

    window.setScene(sc);
    window.setTitle(title);
    window.setMinWidth(250);
    window.showAndWait();

    return ans;
  }
Beispiel #14
0
  public void storeEntry() {
    Stage window = new Stage();
    Button button;

    Label label = new Label("Please enter the item UPC");
    Label label2 = new Label("Please enter the item's location");

    window.initModality(Modality.APPLICATION_MODAL);
    window.setTitle("Save an item");
    window.setWidth(300);
    window.setHeight(400);

    final TextField upcInput = new TextField();
    final TextField locationInput = new TextField();
    button = new Button("Save");
    button.setOnAction(
        e -> {
          try {
            itemUPC = Double.parseDouble(upcInput.getText());
            itemLOC = locationInput.getText();
          } catch (Exception f) {
            displaySimple("Bad input", "Please enter valid inputs");
            status = false;
          }
          window.close();
        });

    VBox layout = new VBox(20);
    layout.getChildren().addAll(label, upcInput, label2, locationInput, button);
    layout.setAlignment(Pos.CENTER);

    Scene scene = new Scene(layout);
    window.setScene(scene);
    window.showAndWait();
  }
Beispiel #15
0
  public void customerEntry() {
    Stage window = new Stage();
    Button button;

    Label label = new Label("Please enter the item you are searching for");
    window.initModality(Modality.APPLICATION_MODAL);
    window.setTitle("Find an item");
    window.setWidth(400);
    window.setHeight(400);

    final TextField nameInput = new TextField();
    button = new Button("Find");
    button.setOnAction(
        e -> {
          try {
            userEntry = nameInput.getText();
          } catch (Exception f) {
            displaySimple("Bad input", "Please enter valid inputs");
            status = false;
          }
          window.close();
        });

    VBox layout = new VBox(20);
    layout.getChildren().addAll(label, nameInput, button);
    layout.setAlignment(Pos.CENTER);

    Scene scene = new Scene(layout);
    window.setScene(scene);
    window.showAndWait();
  }
  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;
    }
  }
  /**
   * 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();
    }
  }
  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 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);
    }
  }
Beispiel #20
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;
    }
  }
Beispiel #21
0
  @Override
  public void handle(KeyEvent event) {
    if (!(event.getSource() instanceof TextArea)) {
      return;
    }
    if (System.currentTimeMillis() - lastCommandTime < 200) {
      return;
    }
    final Stage dialog = new Stage();
    final StackPane pane = new StackPane();
    dialog.setScene(new Scene(pane));
    final VBox vbox = new VBox();
    pane.getChildren().add(vbox);

    vbox.setAlignment(Pos.CENTER);
    vbox.getChildren().add(new Label());
    vbox.getChildren().add(new Label("   hey! ツラタン...   "));
    vbox.getChildren().add(new Label());
    final Button bottom = new Button();
    bottom.setText("OK");
    bottom.setOnAction(
        boxEvent -> {
          dialog.close();
        });
    vbox.getChildren().add(bottom);
    vbox.getChildren().add(new Label(""));
    dialog.showAndWait();
    lastCommandTime = System.currentTimeMillis();
  }
  /** Shows this Notifications popup */
  public void show() {
    // Use a gridpane to display the component
    GridPane pane = new GridPane();
    // Need a new scene to display the popup
    Scene scene = new Scene(pane);

    // Set the padding and gaps to 5px
    pane.setPadding(new Insets(5));
    pane.setHgap(5);
    pane.setVgap(5);

    // Add the message as a label if there is one
    if (message != null) {
      Label lblMsg = new Label(message);

      lblMsg.setPadding(new Insets(20));
      pane.add(lblMsg, 0, 0, 3, 1);
    }

    // Add the yes/no buttons if there are any
    if (yesNoBtns) {
      Button btnYes = new Button("Yes");
      Button btnNo = new Button("No");

      // Add the events and set as default/cancel buttons
      btnYes.setDefaultButton(true);
      btnYes.setOnAction(yesNoEvent);
      btnNo.setCancelButton(true);
      btnNo.setOnAction(yesNoEvent);

      // Align them to the right
      GridPane.setHalignment(btnNo, HPos.RIGHT);
      GridPane.setHalignment(btnYes, HPos.RIGHT);

      // Push the buttons to the right
      Region spacer = new Region();
      GridPane.setHgrow(spacer, Priority.ALWAYS);

      pane.add(spacer, 0, 1);
      pane.add(btnNo, 1, 1);
      pane.add(btnYes, 2, 1);
    }

    // Create a new stage to show the scene
    Stage stage = new Stage();

    stage.setScene(scene);
    // Don't want the popup to be resizable
    stage.setResizable(false);
    // Set the title if there is one
    if (title != null) {
      stage.setTitle(title);
    }
    // Resize it and show it
    stage.sizeToScene();
    stage.showAndWait();
  }
 // ao precionar o botão entrar
 public void entrarSistema(ActionEvent event) throws IOException {
   FXMLLoader fxmlLoader =
       new FXMLLoader(getClass().getResource("/application/JanelaInterna.fxml"));
   Parent root = fxmlLoader.load();
   Stage stage = new Stage();
   stage.initModality(Modality.APPLICATION_MODAL);
   stage.setOpacity(1);
   stage.setScene(new Scene(root));
   stage.showAndWait();
 }
 public void run(PrintFormBase pf, String title) {
   Stage printViewStage = new Stage(StageStyle.DECORATED);
   Scene printViewScene = new Scene(rootVBox);
   printForm = pf.getNode();
   stackPane.getChildren().add(printForm);
   printViewStage.setScene(printViewScene);
   printViewStage.setTitle(title);
   printViewStage.initModality(Modality.APPLICATION_MODAL);
   printViewStage.setResizable(false);
   printViewStage.showAndWait();
 }
  public void newStaff(ActionEvent actionEvent) {
    try {
      Stage dialog =
          EditStaffDialogController.newDialog(null, EditStaffDialogController.EditType.NEW);
      dialog.showAndWait();
    } catch (IOException e) {
      e.printStackTrace();
    }

    fillStaffTable(institutionID);
  }
  public void editStaff(ActionEvent actionEvent) {
    StaffVO staffVO = staff_TableView.getSelectionModel().getSelectedItem();
    try {
      Stage dialog =
          EditStaffDialogController.newDialog(staffVO, EditStaffDialogController.EditType.EDIT);
      dialog.showAndWait();
    } catch (IOException e) {
      e.printStackTrace();
    }

    fillStaffTable(institutionID);
  }
 // <editor-fold defaultstate="collapsed" desc="Region CONFIGS AND THREADS">
 private void showPopUpOpciones(PartidaController partidaController, Stage popUpStage) {
   Juego.setChild(popUpStage); // Seteo como padre a la ventana principal
   popUpStage.setScene(popUpScene); // Cargo la vista a la vetana
   popUpStage.initModality(
       Modality
           .APPLICATION_MODAL); // Seteo la ventana como MODAL, para que permanezca bloqueada hasta
                                // salir del popup
   /*popUpStage.setOnCloseRequest((WindowEvent event) -> {
       partidaController.start(3,"",null);                                                   //Por si cierran la ventana, en vez de dar Ok
   });*/
   popUpStage.showAndWait();
 }
 @FXML
 private void onLoginButtonClick(ActionEvent event) {
   String username = this.username.getText();
   String password = this.password.getText();
   DataBase db = new DataBase();
   Connection c = null;
   ResultSet rs = null;
   try {
     c = db.getConnection();
     rs =
         c.createStatement()
             .executeQuery(
                 "select * from users where username='******' and password='******'");
     boolean success = false;
     while (rs.next()) {
       success = true;
     }
     if (success) {
       try {
         this.password.getScene().getWindow().hide();
         Parent root;
         root = FXMLLoader.load(getClass().getResource("/view/WeightmentForm.fxml"));
         Scene scene = new Scene(root);
         Stage stage = new Stage();
         scene.setRoot(root);
         stage.setResizable(false);
         stage.setTitle("Empty Truck Weight");
         stage.setScene(scene);
         stage.showAndWait();
       } catch (IOException ex) {
         Logger.getLogger(LoginController.class.getName()).log(Level.SEVERE, null, ex);
       }
     } else {
       Msg.showError("Login Failed");
     }
   } catch (SQLException ex) {
     Logger.getLogger(LoginController.class.getName()).log(Level.SEVERE, null, ex);
   } catch (ClassNotFoundException ex) {
     Logger.getLogger(LoginController.class.getName()).log(Level.SEVERE, null, ex);
   } finally {
     try {
       rs.close();
       c.close();
     } catch (SQLException ex) {
       Logger.getLogger(LoginController.class.getName()).log(Level.SEVERE, null, ex);
     }
   }
 }
Beispiel #29
0
  private void showEditConnectionsWindow(final boolean createNew) {
    if (editConnectionsController == null) {
      initialiseEditConnectionsWindow();
    }

    if (createNew) {
      editConnectionsController.newConnection();
    }

    editConnectionsController.updateSelected();
    editConnectionsStage.showAndWait();
    controlPanelPaneController.refreshConnectionsStatus();
  }
Beispiel #30
0
  public boolean isOkPressed(int typeSignal) {
    ((StageLoader) btnOK.getScene().getWindow()).setMethod(() -> btnOK());
    if (tuSignal == null) return false;
    Stage w = (Stage) btnOK.getScene().getWindow();

    if (typeSignal == 3) {
      List<SpTuCommand> tuCommands =
          SingleFromDB.spTuCommands
              .stream()
              .filter(f -> f.getObjref() == tuSignal.getStateref())
              .collect(Collectors.toList());
      ChoiceBox<SpTuCommand> chBox = new ChoiceBox<>();
      tuCommands.forEach(chBox.getItems()::add);
      chBox
          .getSelectionModel()
          .selectedItemProperty()
          .addListener(
              (observ, oldValue, newValue) -> {
                value = newValue.getVal() + "";
              });
      if (chBox.getItems().size() > 0) chBox.getSelectionModel().selectFirst();
      if (SingleObject.selectedShape.getValueProp().get()
          == chBox.getSelectionModel().getSelectedItem().getVal()) {
        chBox.getSelectionModel().selectNext();
      }
      Platform.runLater(() -> chBox.requestFocus());
      bpTU.setCenter(chBox);
    } else if (typeSignal == 1) {
      TextField txtField = new TextField();
      txtField.setText(SingleObject.selectedShape.getValueProp().get() + "");
      txtField
          .textProperty()
          .addListener(
              (observ, oldValue, newValue) -> {
                try {
                  Double.parseDouble(newValue);
                  value = newValue;
                } catch (Exception e) {
                  txtField.setText(oldValue);
                }
              });
      Platform.runLater(() -> txtField.requestFocus());
      bpTU.setCenter(txtField);
    } else {
      System.out.println("=====   This is not TU or TI   =====");
    }
    w.showAndWait();

    return isOkClicked;
  }