This commit is contained in:
crschnick
2026-05-07 20:53:43 +00:00
parent cf1e36d1f6
commit ab2fd6f9a2
3 changed files with 59 additions and 0 deletions

View File

@@ -50,6 +50,27 @@ public class ChoiceComp<T> extends RegionBuilder<ComboBox<T>> {
public ComboBox<T> createSimple() {
var cb = MenuHelper.<T>createComboBox();
cb.setConverter(new StringConverter<>() {
@Override
public String toString(T object) {
if (object == null) {
return AppI18n.get("none");
}
var found = range.getValue().get(object);
if (found == null) {
return "";
}
return found.getValue();
}
@Override
public T fromString(String string) {
throw new UnsupportedOperationException();
}
});
// Reset converter on language change to force an update
// This does not work properly in older JFX versions, see JDK-8384006
var ref = new WeakReference<>(cb);

View File

@@ -49,6 +49,22 @@ public class ChoicePaneComp extends RegionBuilder<VBox> {
});
cb.getSelectionModel().select(selected.getValue());
cb.setConverter(new StringConverter<>() {
@Override
public String toString(Entry object) {
if (object == null || object.name() == null) {
return "";
}
return object.name().getValue();
}
@Override
public Entry fromString(String string) {
throw new UnsupportedOperationException();
}
});
// Reset converter on language change to force an update
// This does not work properly in older JFX versions, see JDK-8384006
var ref = new WeakReference<>(cb);

View File

@@ -4,6 +4,7 @@ import io.xpipe.app.comp.base.*;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.core.AppSystemInfo;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.ext.ShellStore;
import io.xpipe.app.ext.ValidationException;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.platform.ClipboardHelper;
@@ -140,6 +141,27 @@ public class KeyFileStrategy implements SshIdentityStrategy {
var publicKeyBox = new InputGroupComp(List.of(publicKeyField, copyButton, generateButton));
publicKeyBox.setMainReference(publicKeyField);
keyPath.addListener((observable, oldValue, newValue) -> {
if (newValue == null) {
return;
}
ThreadHelper.runFailableAsync(() -> {
var pubFile = SshIdentityStrategy.getPublicKeyPath(newValue);
var fs =
config.getFileSystem() != null && config.getFileSystem().getValue() != null
? config.getFileSystem().getValue().getStore()
: (ShellStore) DataStorage.get().local().getStore();
var ex = fs.getOrStartSession().view().fileExists(pubFile);
if (ex) {
var contents = fs.getOrStartSession().view().readTextFile(pubFile).strip();
Platform.runLater(() -> {
publicKey.set(contents);
});
}
});
});
return new OptionsBuilder()
.name("location")
.description("locationDescription")