Orientation orientation = verticalRightButton?Orientation.HORIZONTAL:Orientation.VERTICAL;
buttonsPane.getChildren().addAll(resultForm.getController().getContributedButtons(messageProvider));
buttonsPane.getChildren().add(new Separator(orientation));
MenuButton defaultFilterButton = new MenuButton("",new ImageView(new Image(getClass().getResourceAsStream("/de/scoopgmbh/copper/gui/icon/filter.png"))));
defaultFilterButton.setPrefWidth(20);
CustomMenuItem defaultFilterContent = new CustomMenuItem();
defaultFilterContent.setHideOnClick(false);
defaultFilterButton.getItems().add(defaultFilterContent);
defaultFilterContent.getStyleClass().setAll("noSelectAnimationMenueItem","menu-item");
buttonsPane.getChildren().add(defaultFilterButton);
if (filterForm.getController().createDefaultFilter()!=null){
defaultFilterContent.setContent(filterForm.getController().createDefaultFilter());
} else {
defaultFilterButton.setDisable(true);
}
buttonsPane.getChildren().add(new Separator(orientation));
final Button clearButton = new Button("",new ImageView(new Image(getClass().getResourceAsStream("/de/scoopgmbh/copper/gui/icon/clear.png"))));
clearButton.setTooltip(new Tooltip(messageProvider.getText(MessageKey.filterAbleForm_button_clear)));
clearButton.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent e) {
resultForm.getController().clear();
}
});
if(resultForm.getController().supportsClear()) {
buttonsPane.getChildren().add(clearButton);
}
final Button refreshButton = new Button("",new ImageView(new Image(getClass().getResourceAsStream("/de/scoopgmbh/copper/gui/icon/refresh.png"))));
refreshButton.setId(REFRESH_BUTTON_ID);
HBox.setMargin(refreshButton, new Insets(4,0,4,0));
refreshButton.setTooltip(new Tooltip(messageProvider.getText(MessageKey.filterAbleForm_button_refresh)));
refreshButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
refresh();
}
});
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;
}