Example usage for javafx.scene.control ProgressIndicator progressProperty

List of usage examples for javafx.scene.control ProgressIndicator progressProperty

Introduction

In this page you can find the example usage for javafx.scene.control ProgressIndicator progressProperty.

Prototype

public final DoubleProperty progressProperty() 

Source Link

Usage

From source file:Main.java

private static Node createProgressPanel() {
    final Slider slider = new Slider();

    final ProgressIndicator progressIndicator = new ProgressIndicator(0);
    progressIndicator.progressProperty().bind(Bindings.divide(slider.valueProperty(), slider.maxProperty()));

    final HBox panel = createHBox(6, new Label("Progress:"), slider, progressIndicator);
    configureBorder(panel);//  w  ww  . ja v a 2  s . c om

    return panel;
}

From source file:caillou.company.clonemanager.gui.handler.AfterPartialHashTaskHandler.java

@Override
public void handle(WorkerStateEvent event) {
    FilterStrategy<String, ApplicationFile> fullHashStrategy = null;
    boolean detectDoublonOperation = false;
    final TaskModel.TASK currentTask = mainModel.getTaskModel().getCurrentTask();
    final LocationsModel locationsModel = mainModel.getLocationsModel();
    switch (currentTask) {
    case DETECT_DOUBLONS:
        if (locationsModel.isDetectsIdentiqueFilesWithinALocation()) {
            fullHashStrategy = new DoublonsFullHashStrategy();
        } else {//from   www .j a va 2s. com
            fullHashStrategy = new DoublonsPlusGroupFullHashStrategy();
        }
        detectDoublonOperation = true;
        break;
    case DETECT_MISSING:
        fullHashStrategy = new MissingFullHashStrategy();
        break;
    }
    Analyse<String, ApplicationFile> previousAnalyse = (Analyse<String, ApplicationFile>) event.getSource()
            .getValue();
    fullHashTask.setFilterStrategy(fullHashStrategy);
    fullHashTask.setInputData(previousAnalyse);
    fullHashTask.setDoCssStuff(detectDoublonOperation);
    ProgressIndicator fullHashTaskProgress = transitionController.getProgressBarFullHashId();
    fullHashTaskProgress.progressProperty().bind(fullHashTask.progressProperty());
    resultController.valuesProperty().bind(fullHashTask.valueProperty());
    fullHashTask.setOnSucceeded(afterFullHashTaskHandler);
    new Thread(fullHashTask).start();
}

From source file:caillou.company.clonemanager.gui.handler.AfterEnqueueHandler.java

@Override
public void handle(WorkerStateEvent event) {
    VisitDirectoriesResult visitDirectoriesResult = (VisitDirectoriesResult) event.getSource().getValue();
    Long byteToTreat = visitDirectoriesResult.getByteToTreat();
    FilterStrategy<String, ApplicationFile> partialHashStrategy = null;
    final LocationsModel locationsModel = mainModel.getLocationsModel();

    final TaskModel.TASK currentTask = mainModel.getTaskModel().getCurrentTask();
    switch (currentTask) {
    case DETECT_DOUBLONS:
        if (locationsModel.isDetectsIdentiqueFilesWithinALocation()) {
            partialHashStrategy = new DoublonsPartialHashStrategy();
        } else {/*from   w ww .  j av  a2s.com*/
            partialHashStrategy = new DoublonsPlusGroupPartialHashStrategy();
        }

        break;
    case DETECT_MISSING:
        partialHashStrategy = new MissingPartialHashStrategy();
        break;
    }

    partialHashTask.setFilterStrategy(partialHashStrategy);
    partialHashTask.setBytesToTreat(byteToTreat);
    partialHashTask.setMyFilesToTreat(visitDirectoriesResult.getFilesToTreat());

    // Attach the progress bar to that task
    ProgressIndicator partialTaskProgress = transitionController.getProgressBarPartialHashId();
    partialTaskProgress.progressProperty().bind(partialHashTask.progressProperty());

    afterPartialHashTaskHandler.setTransitionController(transitionController);
    partialHashTask.setOnSucceeded(afterPartialHashTaskHandler);
    new Thread(partialHashTask).start();
}

From source file:caillou.company.clonemanager.gui.customComponent.search.SearchController.java

@FXML
private void searchAction(ActionEvent event) {
    this.cloneManagerIOExceptionBean.clear();
    buildTransitionPopup();//from w  ww. ja v  a2s. co  m
    enqueueService = SpringFxmlLoader.getBean(EnqueueTask.class);
    AfterEnqueueHandler afterEnqueueHandler = SpringFxmlLoader.getBean(AfterEnqueueHandler.class);
    ProgressIndicator scanningTaskProgress = transitionController.getProgressScanningFiles();
    scanningTaskProgress.progressProperty().bind(enqueueService.progressProperty());
    afterEnqueueHandler.setTransitionController(transitionController);
    enqueueService.setOnSucceeded(afterEnqueueHandler);
    new Thread(enqueueService).start();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    final Label label = new Label("Progress:");
    final ProgressBar progressBar = new ProgressBar(0);
    final ProgressIndicator progressIndicator = new ProgressIndicator(0);

    final Button startButton = new Button("Start");
    final Button cancelButton = new Button("Cancel");
    final TextArea textArea = new TextArea();

    startButton.setOnAction((ActionEvent event) -> {
        startButton.setDisable(true);// ww w. jav  a  2  s .c o  m

        progressBar.setProgress(0);
        progressIndicator.setProgress(0);

        textArea.setText("");
        cancelButton.setDisable(false);

        copyWorker = createWorker(numFiles);

        progressBar.progressProperty().unbind();
        progressBar.progressProperty().bind(copyWorker.progressProperty());
        progressIndicator.progressProperty().unbind();
        progressIndicator.progressProperty().bind(copyWorker.progressProperty());

        copyWorker.messageProperty().addListener(
                (ObservableValue<? extends String> observable, String oldValue, String newValue) -> {
                    textArea.appendText(newValue + "\n");
                });

        new Thread(copyWorker).start();
    });

    cancelButton.setOnAction((ActionEvent event) -> {
        startButton.setDisable(false);
        cancelButton.setDisable(true);
        copyWorker.cancel(true);

        progressBar.progressProperty().unbind();
        progressBar.setProgress(0);
        progressIndicator.progressProperty().unbind();
        progressIndicator.setProgress(0);
        textArea.appendText("File transfer was cancelled.");
    });

    BorderPane root = new BorderPane();
    Scene scene = new Scene(root, 500, 250, javafx.scene.paint.Color.WHITE);

    FlowPane topPane = new FlowPane(5, 5);
    topPane.setPadding(new Insets(5));
    topPane.setAlignment(Pos.CENTER);
    topPane.getChildren().addAll(label, progressBar, progressIndicator);

    GridPane middlePane = new GridPane();
    middlePane.setPadding(new Insets(5));
    middlePane.setHgap(20);
    middlePane.setVgap(20);
    ColumnConstraints column1 = new ColumnConstraints(300, 400, Double.MAX_VALUE);
    middlePane.getColumnConstraints().addAll(column1);
    middlePane.setAlignment(Pos.CENTER);
    middlePane.add(textArea, 0, 0);

    FlowPane bottomPane = new FlowPane(5, 5);
    bottomPane.setPadding(new Insets(5));
    bottomPane.setAlignment(Pos.CENTER);
    bottomPane.getChildren().addAll(startButton, cancelButton);

    root.setTop(topPane);
    root.setCenter(middlePane);
    root.setBottom(bottomPane);

    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Background Processes");
    Group root = new Group();
    Scene scene = new Scene(root, 330, 120, Color.WHITE);

    BorderPane mainPane = new BorderPane();
    root.getChildren().add(mainPane);// w  w w . j  av  a2s.c  o  m

    final Label label = new Label("Files Transfer:");
    final ProgressIndicator progressIndicator = new ProgressIndicator(0);

    final HBox hb = new HBox();
    hb.setSpacing(5);
    hb.setAlignment(Pos.CENTER);
    hb.getChildren().addAll(label, progressIndicator);
    mainPane.setTop(hb);

    final Button startButton = new Button("Start");
    final Button cancelButton = new Button("Cancel");
    final HBox hb2 = new HBox();
    hb2.setSpacing(5);
    hb2.setAlignment(Pos.CENTER);
    hb2.getChildren().addAll(startButton, cancelButton);
    mainPane.setBottom(hb2);

    startButton.setOnAction(new EventHandler<ActionEvent>() {

        public void handle(ActionEvent event) {
            startButton.setDisable(true);
            progressIndicator.setProgress(0);
            cancelButton.setDisable(false);
            copyWorker = createWorker();

            progressIndicator.progressProperty().unbind();
            progressIndicator.progressProperty().bind(copyWorker.progressProperty());

            copyWorker.messageProperty().addListener(new ChangeListener<String>() {
                public void changed(ObservableValue<? extends String> observable, String oldValue,
                        String newValue) {
                    System.out.println(newValue);
                }
            });

            new Thread(copyWorker).start();
        }
    });
    cancelButton.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent event) {
            startButton.setDisable(false);
            cancelButton.setDisable(true);
            copyWorker.cancel(true);
            progressIndicator.progressProperty().unbind();
            progressIndicator.setProgress(0);
            System.out.println("cancelled.");
        }
    });
    primaryStage.setScene(scene);
    primaryStage.show();
}