本文整理匯總了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));
}