});
buttonsPane.getChildren().add(refreshButton);
final ProgressIndicator repeatProgressIndicator = new ProgressBar();
progressbarDisplayTarget.getChildren().add(repeatProgressIndicator);
final ToggleButton toggleButton = new ToggleButton("",new ImageView(new Image(getClass().getResourceAsStream("/de/scoopgmbh/copper/gui/icon/repeat.png"))));
repeatProgressIndicator.setVisible(false);
repeatProgressIndicator.setPrefWidth(300);
repeatProgressIndicator.progressProperty().bind(repeatFilterService.progressProperty());
toggleButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
if (toggleButton.isSelected()){
repeatFilterService.setRefreshIntervall(Long.valueOf(refreshRateInMs.get()));
repeatFilterService.reset();
repeatFilterService.start();
} else {
repeatFilterService.cancel();
}
}
});
repeatFilterService.setOnCancelled(new EventHandler<WorkerStateEvent>() {
@Override
public void handle(WorkerStateEvent event) {
repeatProgressIndicator.setVisible(false);
}
});
repeatFilterService.stateProperty().addListener(new ChangeListener<State>() {
@Override
public void changed(ObservableValue<? extends State> observable, State oldValue, State newValue) {
if (newValue==State.CANCELLED || newValue == State.FAILED || newValue == State.SUCCEEDED){
repeatProgressIndicator.setVisible(false);
} else {
repeatProgressIndicator.setVisible(true);
}
}
});
repeatFilterService.runningProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
if (newValue!=null){
toggleButton.setSelected(newValue);
}
}
});
buttonsPane.getChildren().add(toggleButton);
MenuButton settings = new MenuButton("",new ImageView(new Image(getClass().getResourceAsStream("/de/scoopgmbh/copper/gui/icon/settings.png"))));
settings.setPrefWidth(20);
CustomMenuItem customMenuItem = new CustomMenuItem();
settings.getItems().add(customMenuItem);
customMenuItem.getStyleClass().setAll("noSelectAnimationMenueItem","menu-item");
HBox hbox = new HBox(3);
hbox.setAlignment(Pos.CENTER_LEFT);
hbox.getChildren().add(new Label("Refresh Interval"));
TextField interval = new NumberOnlyTextField();
interval.setPrefWidth(100);
interval.textProperty().bindBidirectional(refreshRateInMs);
hbox.getChildren().add(interval);
hbox.getChildren().add(new Label("ms"));
customMenuItem.setContent(hbox);
buttonsPane.getChildren().add(settings);
refreshButton.disableProperty().bind(toggleButton.selectedProperty());
clearButton.disableProperty().bind(toggleButton.selectedProperty());
filterContent.disableProperty().bind(toggleButton.selectedProperty());
leftFilterPart.disableProperty().bind(toggleButton.selectedProperty());
settings.disableProperty().bind(toggleButton.selectedProperty());
return buttonsPane;
}