mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-21 23:20:23 +00:00
Various small fixes
This commit is contained in:
parent
782be482d0
commit
1ea4018379
5 changed files with 40 additions and 12 deletions
|
@ -8,6 +8,7 @@ import io.xpipe.app.fxcomps.impl.HorizontalComp;
|
|||
import io.xpipe.app.fxcomps.impl.VerticalComp;
|
||||
import io.xpipe.app.fxcomps.util.BindingsHelper;
|
||||
import io.xpipe.app.storage.DataStorage;
|
||||
import io.xpipe.app.storage.DataStoreEntry;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
|
@ -21,15 +22,21 @@ import java.util.List;
|
|||
|
||||
public class StoreEntrySection implements StorageFilter.Filterable {
|
||||
|
||||
private static final Comparator<StoreEntrySection> COMPARATOR = Comparator.<StoreEntrySection, Instant>comparing(
|
||||
o -> o.entry.getEntry().getState().equals(DataStoreEntry.State.COMPLETE_AND_VALID)
|
||||
? o.entry.getEntry().getLastAccess()
|
||||
: Instant.EPOCH).reversed()
|
||||
.thenComparing(
|
||||
storeEntrySection -> storeEntrySection.entry.getEntry().getName());
|
||||
|
||||
public StoreEntrySection(StoreEntryWrapper entry, ObservableList<StoreEntrySection> children) {
|
||||
this.entry = entry;
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public static ObservableList<StoreEntrySection> createTopLevels() {
|
||||
var filtered = BindingsHelper.filteredContentBinding(
|
||||
StoreViewState.get().getAllEntries(),
|
||||
storeEntryWrapper -> {
|
||||
var filtered =
|
||||
BindingsHelper.filteredContentBinding(StoreViewState.get().getAllEntries(), storeEntryWrapper -> {
|
||||
if (!storeEntryWrapper.getEntry().getState().isUsable()) {
|
||||
return true;
|
||||
}
|
||||
|
@ -38,14 +45,13 @@ public class StoreEntrySection implements StorageFilter.Filterable {
|
|||
.getEntry()
|
||||
.getProvider()
|
||||
.getParent(storeEntryWrapper.getEntry().getStore());
|
||||
return parent == null || (DataStorage.get().getStoreEntryIfPresent(parent).isEmpty());
|
||||
return parent == null
|
||||
|| (DataStorage.get().getStoreEntryIfPresent(parent).isEmpty());
|
||||
});
|
||||
var topLevel = BindingsHelper.mappedContentBinding(filtered, storeEntryWrapper -> create(storeEntryWrapper));
|
||||
var ordered = BindingsHelper.orderedContentBinding(
|
||||
topLevel,
|
||||
Comparator.<StoreEntrySection, Instant>comparing(storeEntrySection ->
|
||||
storeEntrySection.entry.lastAccessProperty().getValue())
|
||||
.reversed());
|
||||
COMPARATOR);
|
||||
return ordered;
|
||||
}
|
||||
|
||||
|
@ -65,9 +71,7 @@ public class StoreEntrySection implements StorageFilter.Filterable {
|
|||
var children = BindingsHelper.mappedContentBinding(filtered, entry1 -> create(entry1));
|
||||
var ordered = BindingsHelper.orderedContentBinding(
|
||||
children,
|
||||
Comparator.<StoreEntrySection, Instant>comparing(storeEntrySection ->
|
||||
storeEntrySection.entry.lastAccessProperty().getValue())
|
||||
.reversed());
|
||||
COMPARATOR);
|
||||
return new StoreEntrySection(e, ordered);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,18 +10,35 @@ import io.xpipe.core.util.SecretValue;
|
|||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.scene.control.Alert;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class AskpassExchangeImpl extends AskpassExchange
|
||||
implements MessageExchangeImpl<AskpassExchange.Request, AskpassExchange.Response> {
|
||||
|
||||
private final Map<String, String> requestToId = new HashMap<>();
|
||||
private final Map<String, SecretValue> passwords = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public Response handleRequest(BeaconHandler handler, Request msg) throws Exception {
|
||||
OperationMode.switchTo(OperationMode.GUI);
|
||||
if (OperationMode.get().equals(OperationMode.BACKGROUND)) {
|
||||
OperationMode.switchTo(OperationMode.TRAY);
|
||||
}
|
||||
|
||||
// SecretValue set = AppCache.get(msg.getId(), SecretValue.class, () -> null);
|
||||
// if (set != null) {
|
||||
// return Response.builder().value(set).build();
|
||||
// }
|
||||
|
||||
if (requestToId.containsKey(msg.getRequest())) {
|
||||
var id = requestToId.remove(msg.getRequest());
|
||||
passwords.remove(id);
|
||||
}
|
||||
|
||||
if (passwords.containsKey(msg.getId())) {
|
||||
return Response.builder().value(passwords.get(msg.getId()).getSecretValue()).build();
|
||||
}
|
||||
|
||||
var prop =
|
||||
new SimpleObjectProperty<SecretValue>();
|
||||
var r = AppWindowHelper.showBlockingAlert(alert -> {
|
||||
|
@ -39,6 +56,10 @@ public class AskpassExchangeImpl extends AskpassExchange
|
|||
return prop.getValue();
|
||||
})
|
||||
.orElse(null);
|
||||
|
||||
passwords.put(msg.getId(), r);
|
||||
requestToId.put(msg.getRequest(), msg.getId());
|
||||
|
||||
return Response.builder().value(r != null ? r.getSecretValue() : null).build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ public abstract class ScanProvider {
|
|||
@Value
|
||||
public static class ScanOperation {
|
||||
String nameKey;
|
||||
boolean defaultSelected;
|
||||
FailableRunnable<Exception> scanner;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ public class ScanAlert {
|
|||
}
|
||||
|
||||
var selected = new SimpleListProperty<ScanProvider.ScanOperation>(
|
||||
FXCollections.observableList(new ArrayList<>(applicable)));
|
||||
FXCollections.observableList(new ArrayList<>(applicable.stream().filter(scanOperation -> scanOperation.isDefaultSelected()).toList())));
|
||||
var busy = new SimpleBooleanProperty();
|
||||
AppWindowHelper.showAlert(
|
||||
alert -> {
|
||||
|
|
|
@ -20,6 +20,8 @@ public class AskpassExchange implements MessageExchange {
|
|||
public static class Request implements RequestMessage {
|
||||
@NonNull
|
||||
String id;
|
||||
@NonNull
|
||||
String request;
|
||||
String prompt;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue