ShowTweetsTask() { tweetsCreationTask = tweetSetData.getCreationTask(); tweetsUpdateTask = new TweetsUpdateTask(tweetSetData, wordle); tweetsSnapshotTask = new TweetsSnapshotTask(parents); setOnCancelled( e -> { tweetsCreationTask.cancel(); tweetsUpdateTask.cancel(); tweetsSnapshotTask.cancel(); }); }
public void setTask(Task<?> task) { if (_task != null) { _task.cancel(); _animation.stop(); visibleProperty().unbind(); log.info("Task Canceled"); } _task = task; if (_task != null) { visibleProperty().bind(task.runningProperty()); _task .runningProperty() .addListener( o -> { SimpleBooleanProperty running = (SimpleBooleanProperty) o; if (running.get()) { _animation.play(); } else { _animation.stop(); } }); task.setOnFailed( e -> { log.error(_task.getMessage()); setTask(null); }); } }
public static void showTaskProgressDialog( Window ownerWindow, Task task, boolean showTaskMessage) { final Stage dialog = new Stage(); task.setOnSucceeded(event -> dialog.close()); task.setOnCancelled(event -> dialog.close()); dialog.initStyle(StageStyle.UTILITY); dialog.initModality(Modality.APPLICATION_MODAL); dialog.initOwner(ownerWindow); dialog.titleProperty().bind(task.titleProperty()); // dialog.setTitle(ResourceManager.getMessage("title.dialog.processing")); dialog.setOnCloseRequest( event -> Logger.getLogger(Dialogs.class) .info(ResourceManager.getMessage("notification.task.terminatedByUser"))); ProgressBar progressBar = new ProgressBar(0); progressBar.progressProperty().bind(task.progressProperty()); progressBar.setMaxWidth(Double.MAX_VALUE); progressBar.getStyleClass().add("dark"); Label label = new Label(ResourceManager.getMessage("label.pleaseWaitWhile")); Label taskMessage = new Label(); taskMessage.textProperty().bind(task.messageProperty()); Button cancelButton = new Button(ResourceManager.getMessage("label.button.cancel")); cancelButton.setOnAction( event -> { task.cancel(); Logger.getLogger(Dialogs.class) .info(ResourceManager.getMessage("notification.task.terminatedByUser")); }); ButtonBar buttonBar = new ButtonBar(); buttonBar.getButtons().add(cancelButton); VBox dialogVBox = new VBox(); dialogVBox.setFillWidth(true); dialogVBox.setSpacing(5); dialogVBox.setPadding(new Insets(5)); dialogVBox.setPrefSize(300, VBox.USE_COMPUTED_SIZE); dialogVBox.getChildren().add(label); if (showTaskMessage) { dialogVBox.getChildren().add(taskMessage); } dialogVBox.getChildren().add(progressBar); dialogVBox.getChildren().add(buttonBar); Scene dialogScene = new Scene(dialogVBox); dialogScene.getStylesheets().add(ResourceManager.getUIThemeStyle()); dialog.setScene(dialogScene); dialog.setResizable(false); dialog.show(); }
public Status() { super(); _icon = GlyphRegistry.get(AwesomeIcon.REFRESH, "10px"); getChildren().add(_icon); _animation = new RotateTransition(Duration.millis(500), _icon); _animation.setFromAngle(0); _animation.setByAngle(360); _animation.setCycleCount(Animation.INDEFINITE); _animation.setInterpolator(Interpolator.LINEAR); setVisible(false); setOnMouseClicked(e -> _task.cancel()); }
public EventPopoverPage(final DataService dataService, final Event event, boolean showBack) { this.showBack = showBack; getStyleClass().add("event-popover-page"); final Session session = event.getSession(); scrollPane = new ScrollPane(); scrollPane.setFitToWidth(true); scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); content = session == null ? new EventContent(event, dataService) : new SessionContent(session, event, dataService); scrollPane.setContent(content); getChildren().add(scrollPane); if (CHECK_AVAIL_TASK != null) { CHECK_AVAIL_TASK.cancel(); } if (!ConferenceScheduleApp.getInstance().getSessionManagement().isGuestProperty().get() && content instanceof SessionContent) { CHECK_AVAIL_TASK = dataService.checkAvailability(event); CHECK_AVAIL_TASK.setOnSucceeded( new EventHandler<WorkerStateEvent>() { @Override public void handle(WorkerStateEvent event) { final SessionContent sc = (SessionContent) content; final Availability avail = CHECK_AVAIL_TASK.getValue(); if (!sc.fav) { sc.button.setText(avail.full ? "Session Full" : "Register"); full.set(avail.full); } } }); FILTER_EXECUTOR.submit(CHECK_AVAIL_TASK); } }
public void stopTask() { nfc.cancel(); task.cancel(); }