當前位置: 首頁>>代碼示例>>Java>>正文


Java Service.setOnCancelled方法代碼示例

本文整理匯總了Java中javafx.concurrent.Service.setOnCancelled方法的典型用法代碼示例。如果您正苦於以下問題:Java Service.setOnCancelled方法的具體用法?Java Service.setOnCancelled怎麽用?Java Service.setOnCancelled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.concurrent.Service的用法示例。


在下文中一共展示了Service.setOnCancelled方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleDownloadButtonAction

import javafx.concurrent.Service; //導入方法依賴的package包/類
@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);
    }
}
 
開發者ID:firm1,項目名稱:zest-writer,代碼行數:20,代碼來源:MenuController.java

示例2: handleDownloadArticleButtonAction

import javafx.concurrent.Service; //導入方法依賴的package包/類
@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");
    }
}
 
開發者ID:firm1,項目名稱:zest-writer,代碼行數:20,代碼來源:MenuController.java

示例3: handleDownloadTutorialButtonAction

import javafx.concurrent.Service; //導入方法依賴的package包/類
@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");
    }
}
 
開發者ID:firm1,項目名稱:zest-writer,代碼行數:20,代碼來源:MenuController.java

示例4: handleDownloadOpinionButtonAction

import javafx.concurrent.Service; //導入方法依賴的package包/類
@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");
    }
}
 
開發者ID:firm1,項目名稱:zest-writer,代碼行數:20,代碼來源:MenuController.java

示例5: handleUploadButtonAction

import javafx.concurrent.Service; //導入方法依賴的package包/類
@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();
    }
}
 
開發者ID:firm1,項目名稱:zest-writer,代碼行數:19,代碼來源:MenuController.java

示例6: handleSelectFileAction

import javafx.concurrent.Service; //導入方法依賴的package包/類
@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();
    }
}
 
開發者ID:firm1,項目名稱:zest-writer,代碼行數:19,代碼來源:ImageInputDialog.java

示例7: registerListeners

import javafx.concurrent.Service; //導入方法依賴的package包/類
/**
 * Registers a listener on the service to update the completableFuture.
 * @param service The service.
 * @param completableFuture	The future.
 * @param <T> The expected type.
 */
public static <T> void registerListeners(Service<T> service,
		CompletableFuture<T> completableFuture) {
	service.setOnSucceeded(e -> completableFuture.complete(service.getValue()));
	service.setOnFailed(e ->
		completableFuture.completeExceptionally(service.getException()));
	service.setOnCancelled(e -> completableFuture.cancel(true));
}
 
開發者ID:ProgrammingLife2015,項目名稱:dnainator,代碼行數:14,代碼來源:LoadServiceTestUtils.java


注:本文中的javafx.concurrent.Service.setOnCancelled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。