mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-09-30 00:56:56 +13:00
Add select all option to scan dialog
This commit is contained in:
parent
b0881a2909
commit
069b681f21
4 changed files with 28 additions and 3 deletions
|
@ -1,15 +1,19 @@
|
|||
package io.xpipe.app.comp.base;
|
||||
|
||||
import io.xpipe.app.core.AppI18n;
|
||||
import io.xpipe.app.fxcomps.SimpleComp;
|
||||
import javafx.beans.property.ListProperty;
|
||||
import javafx.geometry.Orientation;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.control.Separator;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.scene.layout.VBox;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Value;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
|
@ -20,14 +24,17 @@ public class ListSelectorComp<T> extends SimpleComp {
|
|||
List<T> values;
|
||||
Function<T, String> toString;
|
||||
ListProperty<T> selected;
|
||||
boolean showAllSelector;
|
||||
|
||||
@Override
|
||||
protected Region createSimple() {
|
||||
var vbox = new VBox();
|
||||
vbox.setSpacing(8);
|
||||
vbox.getStyleClass().add("content");
|
||||
var cbs = new ArrayList<CheckBox>();
|
||||
for (var v : values) {
|
||||
var cb = new CheckBox(null);
|
||||
cbs.add(cb);
|
||||
cb.setSelected(selected.contains(v));
|
||||
cb.selectedProperty().addListener((c, o, n) -> {
|
||||
if (n) {
|
||||
|
@ -41,6 +48,21 @@ public class ListSelectorComp<T> extends SimpleComp {
|
|||
l.setOnMouseClicked(event -> cb.setSelected(!cb.isSelected()));
|
||||
vbox.getChildren().add(l);
|
||||
}
|
||||
|
||||
if (showAllSelector) {
|
||||
var allSelector = new CheckBox(null);
|
||||
allSelector.setSelected(values.size() == selected.size());
|
||||
allSelector.selectedProperty().addListener((observable, oldValue, newValue) -> {
|
||||
cbs.forEach(checkBox -> checkBox.setSelected(newValue));
|
||||
});
|
||||
var l = new Label(null, allSelector);
|
||||
l.textProperty().bind(AppI18n.observable("selectAll"));
|
||||
l.setGraphicTextGap(9);
|
||||
l.setOnMouseClicked(event -> allSelector.setSelected(!allSelector.isSelected()));
|
||||
vbox.getChildren().add(new Separator(Orientation.HORIZONTAL));
|
||||
vbox.getChildren().add(l);
|
||||
}
|
||||
|
||||
var sp = new ScrollPane(vbox);
|
||||
sp.setFitToWidth(true);
|
||||
return sp;
|
||||
|
|
|
@ -56,7 +56,8 @@ public class UserReportComp extends SimpleComp {
|
|||
|
||||
return file.getFileName().toString();
|
||||
},
|
||||
includedDiagnostics)
|
||||
includedDiagnostics,
|
||||
false)
|
||||
.styleClass("attachment-list");
|
||||
var tp = new TitledPaneComp(AppI18n.observable("additionalErrorAttachments"), list, 100)
|
||||
.apply(struc -> struc.get().setExpanded(true))
|
||||
|
|
|
@ -88,7 +88,7 @@ public class ScanAlert {
|
|||
busy)
|
||||
.createRegion();
|
||||
content.setPrefWidth(500);
|
||||
content.setPrefHeight(300);
|
||||
content.setPrefHeight(450);
|
||||
alert.getDialogPane().setContent(content);
|
||||
|
||||
// Custom behavior for ok button
|
||||
|
@ -133,7 +133,8 @@ public class ScanAlert {
|
|||
var r = new ListSelectorComp<>(
|
||||
a,
|
||||
scanOperation -> AppI18n.get(scanOperation.getNameKey()),
|
||||
selected)
|
||||
selected,
|
||||
a.size() > 3)
|
||||
.createRegion();
|
||||
((VBox) ((StackPane) alert.getDialogPane().getContent())
|
||||
.getChildren()
|
||||
|
|
|
@ -7,6 +7,7 @@ editorProgramDescription=The default text editor to use when editing any kind of
|
|||
useSystemFont=Use system font
|
||||
updates=Updates
|
||||
passwordKey=Password key
|
||||
selectAll=Select all
|
||||
command=Command
|
||||
advanced=Advanced
|
||||
thirdParty=Open source notices
|
||||
|
|
Loading…
Reference in a new issue