keep more ui code in fxml

This commit is contained in:
Sebastian Stenzel
2021-05-21 17:48:20 +02:00
parent 04e5170403
commit e134d2f422
2 changed files with 8 additions and 8 deletions

View File

@@ -21,6 +21,7 @@ import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.concurrent.Worker;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ListView;
@@ -55,7 +56,6 @@ public class CheckListController implements FxController {
private final BooleanProperty showResultScreen;
/* FXML */
public CheckBox selectAllBox;
public ListView<HealthCheckTask> checksListView;
@@ -96,13 +96,13 @@ public class CheckListController implements FxController {
}
}));
selectedTask.bind(checksListView.getSelectionModel().selectedItemProperty());
selectAllBox.selectedProperty().addListener(this::selectOrDeselectAll);
selectAllBox.visibleProperty().bind(showResultScreen.not());
selectAllBox.managedProperty().bind(showResultScreen.not());
}
public void selectOrDeselectAll(ObservableValue<? extends Boolean> observable, boolean oldValue, boolean newValue) {
listPickIndicators.forEach( (task, pickProperty) -> pickProperty.set(newValue));
@FXML
public void toggleSelectAll(ActionEvent event) {
if (event.getSource() instanceof CheckBox c) {
listPickIndicators.forEach( (task, pickProperty) -> pickProperty.set(c.isSelected()));
}
}
@FXML
@@ -113,9 +113,9 @@ public class CheckListController implements FxController {
batchService.setExecutor(executorService);
batchService.start();
runningTask.set(batchService);
checksListView.setCellFactory(view -> new CheckListCell());
showResultScreen.set(true);
checksListView.getSelectionModel().select(batch.get(0));
checksListView.setCellFactory(view -> new CheckListCell());
window.sizeToScene();
}

View File

@@ -25,7 +25,7 @@
<HBox spacing="12" VBox.vgrow="ALWAYS">
<VBox minWidth="80" maxWidth="200" spacing="6" HBox.hgrow="ALWAYS" >
<Label fx:id="listHeading" text="%health.check.listHeader"/>
<CheckBox fx:id="selectAllBox" text="FIX: SELECT ALL" />
<CheckBox onAction="#toggleSelectAll" text="FIX: SELECT ALL" visible="${!controller.showResultScreen}" managed="${!controller.showResultScreen}" />
<ListView fx:id="checksListView" VBox.vgrow="ALWAYS"/>
</VBox>
<StackPane visible="${controller.showResultScreen}" managed="${controller.showResultScreen}" HBox.hgrow="ALWAYS" >