mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-07-02 21:11:03 +12:00
Show unavailable scan targets
This commit is contained in:
parent
575cea68e3
commit
c40c9c1f84
|
@ -16,6 +16,7 @@ import lombok.Value;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
@Value
|
@Value
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ -24,6 +25,7 @@ public class ListSelectorComp<T> extends SimpleComp {
|
||||||
List<T> values;
|
List<T> values;
|
||||||
Function<T, String> toString;
|
Function<T, String> toString;
|
||||||
ListProperty<T> selected;
|
ListProperty<T> selected;
|
||||||
|
Predicate<T> disable;
|
||||||
boolean showAllSelector;
|
boolean showAllSelector;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -34,6 +36,9 @@ public class ListSelectorComp<T> extends SimpleComp {
|
||||||
var cbs = new ArrayList<CheckBox>();
|
var cbs = new ArrayList<CheckBox>();
|
||||||
for (var v : values) {
|
for (var v : values) {
|
||||||
var cb = new CheckBox(null);
|
var cb = new CheckBox(null);
|
||||||
|
if (disable.test(v)) {
|
||||||
|
cb.setDisable(true);
|
||||||
|
}
|
||||||
cbs.add(cb);
|
cbs.add(cb);
|
||||||
cb.setAccessibleText(toString.apply(v));
|
cb.setAccessibleText(toString.apply(v));
|
||||||
cb.setSelected(selected.contains(v));
|
cb.setSelected(selected.contains(v));
|
||||||
|
@ -46,15 +51,29 @@ public class ListSelectorComp<T> extends SimpleComp {
|
||||||
});
|
});
|
||||||
var l = new Label(toString.apply(v), cb);
|
var l = new Label(toString.apply(v), cb);
|
||||||
l.setGraphicTextGap(9);
|
l.setGraphicTextGap(9);
|
||||||
l.setOnMouseClicked(event -> cb.setSelected(!cb.isSelected()));
|
l.setOnMouseClicked(event -> {
|
||||||
|
if (disable.test(v)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cb.setSelected(!cb.isSelected());
|
||||||
|
event.consume();
|
||||||
|
});
|
||||||
|
l.opacityProperty().bind(cb.opacityProperty());
|
||||||
vbox.getChildren().add(l);
|
vbox.getChildren().add(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showAllSelector) {
|
if (showAllSelector) {
|
||||||
var allSelector = new CheckBox(null);
|
var allSelector = new CheckBox(null);
|
||||||
allSelector.setSelected(values.size() == selected.size());
|
allSelector.setSelected(values.stream().filter(t -> !disable.test(t)).count() == selected.size());
|
||||||
allSelector.selectedProperty().addListener((observable, oldValue, newValue) -> {
|
allSelector.selectedProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
cbs.forEach(checkBox -> checkBox.setSelected(newValue));
|
cbs.forEach(checkBox -> {
|
||||||
|
if (checkBox.isDisabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
checkBox.setSelected(newValue);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
var l = new Label(null, allSelector);
|
var l = new Label(null, allSelector);
|
||||||
l.textProperty().bind(AppI18n.observable("selectAll"));
|
l.textProperty().bind(AppI18n.observable("selectAll"));
|
||||||
|
|
|
@ -17,6 +17,7 @@ public abstract class ScanProvider {
|
||||||
@Value
|
@Value
|
||||||
public static class ScanOperation {
|
public static class ScanOperation {
|
||||||
String nameKey;
|
String nameKey;
|
||||||
|
boolean disabled;
|
||||||
boolean defaultSelected;
|
boolean defaultSelected;
|
||||||
FailableRunnable<Exception> scanner;
|
FailableRunnable<Exception> scanner;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,7 @@ public class UserReportComp extends SimpleComp {
|
||||||
return file.getFileName().toString();
|
return file.getFileName().toString();
|
||||||
},
|
},
|
||||||
includedDiagnostics,
|
includedDiagnostics,
|
||||||
|
file -> false,
|
||||||
false)
|
false)
|
||||||
.styleClass("attachment-list");
|
.styleClass("attachment-list");
|
||||||
return new TitledPaneComp(AppI18n.observable("additionalErrorAttachments"), list, 100)
|
return new TitledPaneComp(AppI18n.observable("additionalErrorAttachments"), list, 100)
|
||||||
|
|
|
@ -35,10 +35,12 @@ public class AskpassAlert {
|
||||||
var r = AppWindowHelper.showBlockingAlert(alert -> {
|
var r = AppWindowHelper.showBlockingAlert(alert -> {
|
||||||
alert.setTitle(AppI18n.get("askpassAlertTitle"));
|
alert.setTitle(AppI18n.get("askpassAlertTitle"));
|
||||||
alert.setHeaderText(prompt);
|
alert.setHeaderText(prompt);
|
||||||
// alert.getDialogPane().setHeader(
|
|
||||||
// AppWindowHelper.alertContentText(prompt));
|
|
||||||
alert.setAlertType(Alert.AlertType.CONFIRMATION);
|
alert.setAlertType(Alert.AlertType.CONFIRMATION);
|
||||||
|
|
||||||
|
// alert.getDialogPane().getScene().getWindow().setOnShown(event -> {
|
||||||
|
// ((Stage) alert.getDialogPane().getScene().getWindow()).setAlwaysOnTop(true);
|
||||||
|
// });
|
||||||
|
|
||||||
var text = new SecretFieldComp(prop).createRegion();
|
var text = new SecretFieldComp(prop).createRegion();
|
||||||
alert.getDialogPane().setContent(new StackPane(text));
|
alert.getDialogPane().setContent(new StackPane(text));
|
||||||
})
|
})
|
||||||
|
|
|
@ -114,8 +114,10 @@ public class ScanAlert {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
selected.setAll(a.stream().filter(scanOperation -> scanOperation.isDefaultSelected()).toList());
|
selected.setAll(a.stream().filter(scanOperation -> scanOperation.isDefaultSelected() && !scanOperation.isDisabled()).toList());
|
||||||
var r = new ListSelectorComp<>(a, scanOperation -> AppI18n.get(scanOperation.getNameKey()), selected,
|
var r = new ListSelectorComp<ScanProvider.ScanOperation>(a,
|
||||||
|
scanOperation -> AppI18n.get(scanOperation.getNameKey()),
|
||||||
|
selected,scanOperation -> scanOperation.isDisabled(),
|
||||||
a.size() > 3).createRegion();
|
a.size() > 3).createRegion();
|
||||||
stackPane.getChildren().add(r);
|
stackPane.getChildren().add(r);
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,6 +7,7 @@ import lombok.NonNull;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
@ -108,6 +109,13 @@ public interface ShellControl extends ProcessControl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default Optional<String> executeSimpleStringCommandAndCheck(String command) throws Exception {
|
||||||
|
try (CommandControl c = command(command).start()) {
|
||||||
|
var out = c.readStdoutDiscardErr();
|
||||||
|
return c.getExitCode() == 0 ? Optional.of(out) : Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
default boolean executeSimpleBooleanCommand(String command) throws Exception {
|
default boolean executeSimpleBooleanCommand(String command) throws Exception {
|
||||||
try (CommandControl c = command(command).start()) {
|
try (CommandControl c = command(command).start()) {
|
||||||
return c.discardAndCheckExit();
|
return c.discardAndCheckExit();
|
||||||
|
|
Loading…
Reference in a new issue