Exemplo n.º 1
0
 public void setMitjas(String tipus, double result, String unitats) {
   mitjas.setHeaderText("Càlcul de la mitja de la " + tipus);
   Label label1 = new Label(String.format("%.2f", result) + " " + unitats);
   GridPane grid = new GridPane();
   grid.add(label1, 1, 1);
   mitjas.getDialogPane().setContent(grid);
 }
  public void setupDialog(Dialog<String> urlInputDialog) {
    urlInputDialog
        .getDialogPane()
        .getButtonTypes()
        .add(new ButtonType("Open...", ButtonData.OK_DONE));
    urlInputDialog.getDialogPane().getButtonTypes().add(ButtonType.CANCEL);

    urlInputDialog.setResultConverter(
        b -> {
          if (b.getButtonData() == ButtonData.OK_DONE && urlCombo.getValue() != null) {
            if (!recentItems.contains(urlCombo.getValue())) {
              recentItems.add(urlCombo.getValue());
            }

            return urlCombo.getValue();
          }
          return null;
        });
  }
Exemplo n.º 3
0
 private void inicialitzarDialog() {
   // Definició d'un diàleg usant la classe Dialog
   dialog = new Dialog();
   dialog.setTitle("Diàleg");
   dialog.setHeaderText("This is a custom dialog");
   dialog.setResizable(true);
   ButtonType buttonTypeOk = new ButtonType("Okay", ButtonBar.ButtonData.OK_DONE);
   dialog.getDialogPane().getButtonTypes().add(buttonTypeOk);
   // Definició d'un diàleg usant la classe Dialog
   mitjas = new Dialog();
   mitjas.setTitle("Diàleg");
   mitjas.setResizable(true);
   mitjas.getDialogPane().getButtonTypes().add(buttonTypeOk);
 }
Exemplo n.º 4
0
 private void createDialog(String icon, String temps) {
   Label label1 = new Label("Predicció: ");
   ImageView img1 = new ImageView("icons/" + icon + ".png");
   Label label2 = null;
   switch (temps) {
     case "sky is clear":
       label2 = new Label("Sol");
       break;
     case "light rain":
       label2 = new Label("Lluvia");
       break;
   }
   GridPane grid = new GridPane();
   grid.add(label1, 1, 1);
   grid.add(img1, 1, 2);
   grid.add(label2, 2, 2);
   dialog.getDialogPane().setContent(grid);
 }
Exemplo n.º 5
0
  private void initDialog() {
    dialog.initOwner(mainApp.getPrimaryStage());
    dialog.initModality(Modality.APPLICATION_MODAL);
    dialog.initStyle(StageStyle.DECORATED);
    dialog.setResizable(true);
    dialog.setTitle("Recordings Already Exist");
    dialog.setHeaderText("Replace or rename recordings?");
    dialog.getDialogPane().setPadding(new Insets(10));

    VBox vbox = new VBox();
    vbox.setSpacing(10);
    dialog.getDialogPane().setContent(vbox);

    Label label =
        new Label(
            "Archiving the following recordings will replace files on your computer unless you rename them:");
    vbox.getChildren().add(label);

    VBox recordingBox = new VBox();
    recordingBox.setSpacing(20);
    for (Recording recording : recordingsToDisplay) {
      recording.setFileExistsAction(Recording.FileExistsAction.REPLACE);
      recordingBox.getChildren().add(buildRecordingGrid(recording));
    }

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.getStyleClass().add("recording-exists-list");
    scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
    scrollPane.setFitToWidth(true);
    scrollPane.setFitToHeight(true);
    scrollPane.setContent(recordingBox);
    scrollPane.setPadding(new Insets(10));
    vbox.getChildren().add(scrollPane);

    dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
  }
  public static Dialog<Boolean> cancellableDialog(String title, String headerText) {
    Dialog<Boolean> dialog = new Dialog<>();
    dialog.setTitle(title);
    dialog.setHeaderText(headerText);
    dialog.getDialogPane().getButtonTypes().addAll(ButtonType.CANCEL);
    VBox vbox = new VBox();
    vbox.getChildren().add(new ProgressIndicator());
    dialog.getDialogPane().setContent(vbox);
    dialog.setResultConverter(
        dialogButton -> {
          return true;
        });

    return dialog;
  }
  @FXML
  void updateAdminDetails(ActionEvent event) {
    try {
      TextField mobileNum = new TextField();
      TextField agencyName = new TextField();
      TextField addr = new TextField();

      Connection con = Main.dbConnection;
      if (!con.isValid(0)) {
        con = Main.reconnect();
      }
      String query =
          "select company_name,company_mobile,company_addr from admin_login where username ='******' ";
      PreparedStatement stmt = con.prepareStatement(query);
      //			stmt.setString(1, HawkerLoginController.loggedInHawker.getPointName());
      ResultSet rs = stmt.executeQuery();
      if (rs.next()) {
        agencyName.setText(rs.getString(1));
        mobileNum.setText(rs.getString(2));
        addr.setText(rs.getString(3));
      }
      rs.close();
      stmt.close();

      Dialog<ButtonType> deleteWarning = new Dialog<ButtonType>();
      deleteWarning.setTitle("Update Admin Details");
      deleteWarning.setHeaderText("Update admin details below.");
      ButtonType saveButtonType = new ButtonType("Save", ButtonData.OK_DONE);
      deleteWarning.getDialogPane().getButtonTypes().addAll(saveButtonType, ButtonType.CANCEL);

      GridPane grid = new GridPane();
      grid.setHgap(10);
      grid.setVgap(10);
      grid.setPadding(new Insets(20, 150, 10, 10));

      grid.add(new Label("Agency Name"), 0, 0);
      grid.add(new Label("Mobile"), 0, 1);
      grid.add(new Label("Address"), 0, 2);
      grid.add(agencyName, 1, 1);
      grid.add(mobileNum, 1, 0);
      grid.add(addr, 1, 2);
      deleteWarning.getDialogPane().setContent(grid);
      Optional<ButtonType> result = deleteWarning.showAndWait();
      if (result.isPresent() && result.get() == saveButtonType) {
        PreparedStatement updateStmt =
            con.prepareStatement(
                "update admin_login set company_name=?, company_mobile=?, company_addr=?");
        updateStmt.setString(1, agencyName.getText());
        updateStmt.setString(2, mobileNum.getText());
        updateStmt.setString(3, addr.getText());
        updateStmt.executeUpdate();
      }
    } catch (SQLException e) {

      Main._logger.debug("Error :", e);
      e.printStackTrace();
    } catch (Exception e) {

      Main._logger.debug("Error :", e);
      e.printStackTrace();
    }
  }
Exemplo n.º 8
0
  public static Range showRangeDialog(String title, String header) {
    final Range[] retVal = {null};

    Dialog<Range> dialog = new Dialog<>();
    dialog.setTitle(title);
    dialog.setHeaderText(header);

    IntegerProperty fromFieldProperty = new SimpleIntegerProperty(),
        toFieldProperty = new SimpleIntegerProperty();

    //        dialog.setGraphic(new ImageView(this.getClass().getResource("login.png").toString()));

    // Set the button types.
    ButtonType generateButtonType =
        new ButtonType(ResourceManager.getMessage("label.button.ok"), ButtonBar.ButtonData.OK_DONE);
    dialog.getDialogPane().getButtonTypes().addAll(generateButtonType, ButtonType.CANCEL);

    // Create the username and password labels and fields.
    GridPane grid = new GridPane();
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(20, 150, 10, 10));

    TextField fromTextField = new TextField();
    fromTextField.textProperty().bindBidirectional(fromFieldProperty, new NumberStringConverter());

    TextField toTextField = new TextField();
    toTextField.textProperty().bindBidirectional(toFieldProperty, new NumberStringConverter());

    grid.add(new Label("From:"), 0, 0);
    grid.add(fromTextField, 1, 0);
    grid.add(new Label("To:"), 0, 1);
    grid.add(toTextField, 1, 1);

    // Enable/Disable login button depending on whether a username was entered.
    Node loginButton = dialog.getDialogPane().lookupButton(generateButtonType);
    loginButton.setDisable(true);

    // Do some validation (using the Java 8 lambda syntax).
    fromTextField
        .textProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              loginButton.setDisable(
                  newValue.trim().isEmpty()
                      || toTextField.getText().trim().isEmpty()
                      || Integer.valueOf(newValue.trim())
                              .compareTo(Integer.valueOf(toTextField.getText().trim()))
                          > 0);
            });

    toTextField
        .textProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              loginButton.setDisable(
                  fromTextField.getText().trim().isEmpty()
                      || newValue.trim().isEmpty()
                      || Integer.valueOf(fromTextField.getText().trim())
                              .compareTo(Integer.valueOf(newValue.trim()))
                          > 0);
            });

    dialog.getDialogPane().setContent(grid);

    // Request focus on the username field by default.
    Platform.runLater(() -> fromTextField.requestFocus());

    // Convert the result to a username-password-pair when the login button is clicked.
    dialog.setResultConverter(
        dialogButton -> {
          if (dialogButton == generateButtonType) {
            return new IntegerRange(fromFieldProperty.get(), toFieldProperty.get());
          }
          return null;
        });

    Optional<Range> result = dialog.showAndWait();

    result.ifPresent(range -> retVal[0] = range);

    return retVal[0];
  }
Exemplo n.º 9
0
 public void calculMitjaPressure(ActionEvent actionEvent) {
   double pressio = temp.mitjaPressure();
   setMitjas("Pressió:", pressio, "hPa");
   mitjas.show();
 }
Exemplo n.º 10
0
 public void calculMitjaHumidity(ActionEvent actionEvent) {
   double humitat = temp.mitjaHumidity();
   setMitjas("Humitat:", humitat, "%");
   mitjas.show();
 }
Exemplo n.º 11
0
 public void calculMitjaTempsMax(ActionEvent actionEvent) {
   double max = temp.mitjaTempsMax();
   String unitats = (units == 0) ? "ºC" : "ºF";
   setMitjas("Temperatura Màxima:", max, unitats);
   mitjas.show();
 }
Exemplo n.º 12
0
 public void calculMitjaTempsMin(ActionEvent actionEvent) {
   double min = temp.mitjaTempsMin();
   String unitats = (units == 0) ? "ºC" : "ºF";
   setMitjas("Temperatura Mínima:", min, unitats);
   mitjas.show();
 }
Exemplo n.º 13
0
 public void listViewClick(Event event) {
   event.getSource();
   dialog.show();
 }
Exemplo n.º 14
0
 public boolean showAndWait() {
   Optional<ButtonType> response = dialog.showAndWait();
   response.filter(r -> r == ButtonType.CANCEL).ifPresent(r -> clearRecordingList());
   response.filter(r -> r == ButtonType.OK).ifPresent(r -> clearCanceledRecordings());
   return (response.isPresent() && response.get() == ButtonType.OK);
 }