示例#1
0
  public static void showTaskProgressDialog(
      Window ownerWindow, Task task, boolean showTaskMessage) {
    final Stage dialog = new Stage();
    task.setOnSucceeded(event -> dialog.close());
    task.setOnCancelled(event -> dialog.close());
    dialog.initStyle(StageStyle.UTILITY);
    dialog.initModality(Modality.APPLICATION_MODAL);
    dialog.initOwner(ownerWindow);
    dialog.titleProperty().bind(task.titleProperty());
    //        dialog.setTitle(ResourceManager.getMessage("title.dialog.processing"));
    dialog.setOnCloseRequest(
        event ->
            Logger.getLogger(Dialogs.class)
                .info(ResourceManager.getMessage("notification.task.terminatedByUser")));

    ProgressBar progressBar = new ProgressBar(0);
    progressBar.progressProperty().bind(task.progressProperty());
    progressBar.setMaxWidth(Double.MAX_VALUE);
    progressBar.getStyleClass().add("dark");

    Label label = new Label(ResourceManager.getMessage("label.pleaseWaitWhile"));
    Label taskMessage = new Label();
    taskMessage.textProperty().bind(task.messageProperty());

    Button cancelButton = new Button(ResourceManager.getMessage("label.button.cancel"));
    cancelButton.setOnAction(
        event -> {
          task.cancel();
          Logger.getLogger(Dialogs.class)
              .info(ResourceManager.getMessage("notification.task.terminatedByUser"));
        });

    ButtonBar buttonBar = new ButtonBar();
    buttonBar.getButtons().add(cancelButton);

    VBox dialogVBox = new VBox();
    dialogVBox.setFillWidth(true);
    dialogVBox.setSpacing(5);
    dialogVBox.setPadding(new Insets(5));
    dialogVBox.setPrefSize(300, VBox.USE_COMPUTED_SIZE);
    dialogVBox.getChildren().add(label);
    if (showTaskMessage) {
      dialogVBox.getChildren().add(taskMessage);
    }
    dialogVBox.getChildren().add(progressBar);
    dialogVBox.getChildren().add(buttonBar);

    Scene dialogScene = new Scene(dialogVBox);
    dialogScene.getStylesheets().add(ResourceManager.getUIThemeStyle());
    dialog.setScene(dialogScene);
    dialog.setResizable(false);
    dialog.show();
  }
 @Override
 public void valueChanged(ListSelectionEvent e) {
   int[] selectedRows = headersPanel.getSelectedRows();
   buttonBar.setEnabledDeleteButton(selectedRows.length > 0);
   buttonBar.setEnabledEditButton(selectedRows.length == 1);
 }
示例#3
0
 protected void activeButton(ButtonBar bb) {
   if (currentButton != null) currentButton.setActive(false);
   currentButton = bb;
   currentButton.setActive(true);
 }