Java Code Examples for javafx.concurrent.Service#setOnSucceeded()

The following examples show how to use javafx.concurrent.Service#setOnSucceeded() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MenuController.java    From zest-writer with GNU General Public License v3.0 6 votes vote down vote up
@FXML private void handleDownloadButtonAction(ActionEvent event){
    if(! MainApp.getZdsutils().isAuthenticated()){
        Service<Void> loginTask = handleLoginButtonAction(event);
        loginTask.setOnSucceeded(t -> downloadContents(null));
        loginTask.setOnCancelled(t -> {
            hBottomBox.getChildren().clear();
            Alert alert = new CustomAlert(AlertType.ERROR);
            alert.setTitle(Configuration.getBundle().getString("ui.dialog.auth.failed.title"));
            alert.setHeaderText(Configuration.getBundle().getString("ui.dialog.auth.failed.header"));
            alert.setContentText(Configuration.getBundle().getString("ui.dialog.auth.failed.text"));

            alert.showAndWait();
        });

        loginTask.start();
    }else{
        downloadContents(null);
    }
}
 
Example 2
Source File: MenuController.java    From zest-writer with GNU General Public License v3.0 6 votes vote down vote up
@FXML private void handleDownloadArticleButtonAction(ActionEvent event){
    if(! MainApp.getZdsutils().isAuthenticated()){
        Service<Void> loginTask = handleLoginButtonAction(event);
        loginTask.setOnSucceeded(t -> downloadContents("ARTICLE"));
        loginTask.setOnCancelled(t -> {
            hBottomBox.getChildren().clear();
            Alert alert = new CustomAlert(AlertType.ERROR);
            alert.setTitle(Configuration.getBundle().getString("ui.dialog.auth.failed.title"));
            alert.setHeaderText(Configuration.getBundle().getString("ui.dialog.auth.failed.header"));
            alert.setContentText(Configuration.getBundle().getString("ui.dialog.auth.failed.text"));

            alert.showAndWait();
        });

        loginTask.start();
    }else{
        downloadContents("ARTICLE");
    }
}
 
Example 3
Source File: MenuController.java    From zest-writer with GNU General Public License v3.0 6 votes vote down vote up
@FXML private void handleDownloadTutorialButtonAction(ActionEvent event){
    if(! MainApp.getZdsutils().isAuthenticated()){
        Service<Void> loginTask = handleLoginButtonAction(event);
        loginTask.setOnSucceeded(t -> downloadContents("TUTORIAL"));
        loginTask.setOnCancelled(t -> {
            hBottomBox.getChildren().clear();
            Alert alert = new CustomAlert(AlertType.ERROR);
            alert.setTitle(Configuration.getBundle().getString("ui.dialog.auth.failed.title"));
            alert.setHeaderText(Configuration.getBundle().getString("ui.dialog.auth.failed.header"));
            alert.setContentText(Configuration.getBundle().getString("ui.dialog.auth.failed.text"));

            alert.showAndWait();
        });

        loginTask.start();
    }else{
        downloadContents("TUTORIAL");
    }
}
 
Example 4
Source File: MenuController.java    From zest-writer with GNU General Public License v3.0 6 votes vote down vote up
@FXML private void handleDownloadOpinionButtonAction(ActionEvent event){
    if(! MainApp.getZdsutils().isAuthenticated()){
        Service<Void> loginTask = handleLoginButtonAction(event);
        loginTask.setOnSucceeded(t -> downloadContents("OPINION"));
        loginTask.setOnCancelled(t -> {
            hBottomBox.getChildren().clear();
            Alert alert = new CustomAlert(AlertType.ERROR);
            alert.setTitle(Configuration.getBundle().getString("ui.dialog.auth.failed.title"));
            alert.setHeaderText(Configuration.getBundle().getString("ui.dialog.auth.failed.header"));
            alert.setContentText(Configuration.getBundle().getString("ui.dialog.auth.failed.text"));

            alert.showAndWait();
        });

        loginTask.start();
    }else{
        downloadContents("OPINION");
    }
}
 
Example 5
Source File: MenuController.java    From zest-writer with GNU General Public License v3.0 6 votes vote down vote up
@FXML private void handleUploadButtonAction(ActionEvent event){
    if(! MainApp.getZdsutils().isAuthenticated()){
        Service<Void> loginTask = handleLoginButtonAction(event);
        loginTask.setOnCancelled(t -> {
            hBottomBox.getChildren().clear();
            Alert alert = new CustomAlert(AlertType.ERROR);
            alert.setTitle(Configuration.getBundle().getString("ui.dialog.upload.content.failed.title"));
            alert.setHeaderText(Configuration.getBundle().getString("ui.dialog.upload.content.failed.header"));
            alert.setContentText(Configuration.getBundle().getString("ui.dialog.upload.content.failed.text"));

            alert.showAndWait();
        });
        loginTask.setOnSucceeded(t -> uploadContents());
        loginTask.start();
    }else{
        uploadContents();
    }
}
 
Example 6
Source File: ImageInputDialog.java    From zest-writer with GNU General Public License v3.0 6 votes vote down vote up
@FXML private void handleSelectFileAction(){
    if(! zdsUtils.isAuthenticated()){
        Service<Void> loginTask = menuManager.handleLoginButtonAction(null);
        loginTask.setOnSucceeded(t -> selectAndUploadImage());
        loginTask.setOnCancelled(t -> {
            menuManager.getHBottomBox().getChildren().clear();
            Alert alert = new CustomAlert(AlertType.ERROR);
            alert.setTitle(Configuration.getBundle().getString("ui.dialog.auth.failed.title"));
            alert.setHeaderText(Configuration.getBundle().getString("ui.dialog.auth.failed.header"));
            alert.setContentText(Configuration.getBundle().getString("ui.dialog.auth.failed.text"));

            alert.showAndWait();
        });
        loginTask.start();
    }else{
        selectAndUploadImage();
    }
}