mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-06-04 21:58:02 -04:00
Rework
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user