Browse Source

add select all checkbox

Armin Schrenk 4 years ago
parent
commit
c01c405f20

+ 10 - 0
main/ui/src/main/java/org/cryptomator/ui/health/CheckListController.java

@@ -16,10 +16,12 @@ import javafx.beans.property.ObjectProperty;
 import javafx.beans.property.SimpleBooleanProperty;
 import javafx.beans.property.SimpleIntegerProperty;
 import javafx.beans.property.SimpleObjectProperty;
+import javafx.beans.value.ObservableValue;
 import javafx.collections.FXCollections;
 import javafx.collections.ObservableList;
 import javafx.concurrent.Worker;
 import javafx.fxml.FXML;
+import javafx.scene.control.CheckBox;
 import javafx.scene.control.ListView;
 import javafx.scene.control.cell.CheckBoxListCell;
 import javafx.stage.Stage;
@@ -51,6 +53,7 @@ public class CheckListController implements FxController {
 	private final BooleanProperty showResultScreen;
 
 	/* FXML */
+	public CheckBox selectAllBox;
 	public ListView<HealthCheckTask> checksListView;
 
 
@@ -90,6 +93,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

+ 2 - 0
main/ui/src/main/resources/fxml/health_check_list.fxml

@@ -9,6 +9,7 @@
 <?import javafx.scene.layout.VBox?>
 <?import java.lang.Integer?>
 <?import javafx.scene.layout.StackPane?>
+<?import javafx.scene.control.CheckBox?>
 <VBox xmlns:fx="http://javafx.com/fxml"
 	  xmlns="http://javafx.com/javafx"
 	  fx:controller="org.cryptomator.ui.health.CheckListController"
@@ -25,6 +26,7 @@
 			<VBox minWidth="80" maxWidth="200" spacing="6" HBox.hgrow="ALWAYS" >
 				<Label fx:id="listHeading" text="%health.check.listHeader"/>
 				<!-- TODO:HEADER with select all checkbox -->
+				<CheckBox fx:id="selectAllBox" text="FIX: SELECT ALL" />
 				<ListView fx:id="checksListView" VBox.vgrow="ALWAYS"/>
 			</VBox>
 			<StackPane visible="${controller.showResultScreen}" managed="${controller.showResultScreen}" HBox.hgrow="ALWAYS" >