本文整理汇总了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);
}
}
示例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");
}
}
示例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");
}
}
示例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");
}
}
示例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();
}
}
示例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();
}
}
示例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));
}