From c82449b138c330896febe3ca78c95b123ceb5578 Mon Sep 17 00:00:00 2001 From: crschnick Date: Wed, 7 Jun 2023 15:02:19 +0000 Subject: [PATCH] Many small fixes [stage] --- .../source/store/DataStoreSelectorComp.java | 2 +- .../comp/source/store/GuiDsStoreCreator.java | 54 +++++++++---------- .../app/fxcomps/impl/FileStoreChoiceComp.java | 3 +- .../io/xpipe/app/fxcomps/impl/SvgView.java | 2 + .../io/xpipe/app/util/OptionsBuilder.java | 6 +++ dist/changelogs/1.1.1.md | 1 + 6 files changed, 39 insertions(+), 29 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/comp/source/store/DataStoreSelectorComp.java b/app/src/main/java/io/xpipe/app/comp/source/store/DataStoreSelectorComp.java index 9dc99db3..e3d692d9 100644 --- a/app/src/main/java/io/xpipe/app/comp/source/store/DataStoreSelectorComp.java +++ b/app/src/main/java/io/xpipe/app/comp/source/store/DataStoreSelectorComp.java @@ -32,7 +32,7 @@ public class DataStoreSelectorComp extends Comp> { button.setOnAction(e -> { GuiDsStoreCreator.show("inProgress", null, null, v -> v.getCategory().equals(category), entry -> { chosenStore.setValue(entry.getStore()); - }); + }, false); e.consume(); }); diff --git a/app/src/main/java/io/xpipe/app/comp/source/store/GuiDsStoreCreator.java b/app/src/main/java/io/xpipe/app/comp/source/store/GuiDsStoreCreator.java index ada80e59..15a2332e 100644 --- a/app/src/main/java/io/xpipe/app/comp/source/store/GuiDsStoreCreator.java +++ b/app/src/main/java/io/xpipe/app/comp/source/store/GuiDsStoreCreator.java @@ -42,7 +42,7 @@ public class GuiDsStoreCreator extends MultiStepComp.Step> { MultiStepComp parent; Property provider; - Property input; + Property store; Predicate filter; BooleanProperty busy = new SimpleBooleanProperty(); Property validator = new SimpleObjectProperty<>(new SimpleValidator()); @@ -51,20 +51,23 @@ public class GuiDsStoreCreator extends MultiStepComp.Step> { Property entry = new SimpleObjectProperty<>(); BooleanProperty changedSinceError = new SimpleBooleanProperty(); StringProperty name; + boolean exists; public GuiDsStoreCreator( MultiStepComp parent, Property provider, - Property input, + Property store, Predicate filter, - String initialName) { + String initialName, boolean exists + ) { super(null); this.parent = parent; this.provider = provider; - this.input = input; + this.store = store; this.filter = filter; this.name = new SimpleStringProperty(initialName != null && !initialName.isEmpty() ? initialName : null); - this.input.addListener((c, o, n) -> { + this.exists = exists; + this.store.addListener((c, o, n) -> { changedSinceError.setValue(true); }); this.name.addListener((c, o, n) -> { @@ -72,10 +75,10 @@ public class GuiDsStoreCreator extends MultiStepComp.Step> { }); this.provider.addListener((c, o, n) -> { - input.unbind(); - input.setValue(null); + store.unbind(); + store.setValue(null); if (n != null) { - input.setValue(n.defaultStore()); + store.setValue(n.defaultStore()); } }); @@ -100,7 +103,7 @@ public class GuiDsStoreCreator extends MultiStepComp.Step> { } DataStorage.get().refresh(); }); - }); + }, true); } public static void showCreation(Predicate filter) { @@ -111,7 +114,7 @@ public class GuiDsStoreCreator extends MultiStepComp.Step> { } catch (Exception ex) { ErrorEvent.fromThrowable(ex).handle(); } - }); + }, false); } public static void show( @@ -119,7 +122,8 @@ public class GuiDsStoreCreator extends MultiStepComp.Step> { DataStoreProvider provider, DataStore s, Predicate filter, - Consumer con) { + Consumer con, + boolean exists) { var prop = new SimpleObjectProperty(provider); var store = new SimpleObjectProperty(s); var loading = new SimpleBooleanProperty(); @@ -131,7 +135,7 @@ public class GuiDsStoreCreator extends MultiStepComp.Step> { return new MultiStepComp() { private final GuiDsStoreCreator creator = - new GuiDsStoreCreator(this, prop, store, filter, initialName); + new GuiDsStoreCreator(this, prop, store, filter, initialName, exists); @Override protected List setup() { @@ -167,18 +171,18 @@ public class GuiDsStoreCreator extends MultiStepComp.Step> { private Region createStoreProperties(Comp comp, Validator propVal) { return new OptionsBuilder() - .addComp(comp, input) + .addComp(comp, store) .name("connectionName") .description("connectionNameDescription") .addString(name, false) .nonNull(propVal) .bind( () -> { - if (name.getValue() == null || input.getValue() == null) { + if (name.getValue() == null || store.getValue() == null) { return null; } - return DataStoreEntry.createNew(UUID.randomUUID(), name.getValue(), input.getValue()); + return DataStoreEntry.createNew(UUID.randomUUID(), name.getValue(), store.getValue()); }, entry) .build(); @@ -210,7 +214,7 @@ public class GuiDsStoreCreator extends MultiStepComp.Step> { // return; // } - var d = n.guiDialog(input); + var d = n.guiDialog(store); var propVal = new SimpleValidator(); var propR = createStoreProperties(d == null || d.getComp() == null ? null : d.getComp(), propVal); layout.setCenter(propR); @@ -257,7 +261,7 @@ public class GuiDsStoreCreator extends MultiStepComp.Step> { return true; } - if (input.getValue() == null) { + if (store.getValue() == null) { return false; } @@ -267,16 +271,12 @@ public class GuiDsStoreCreator extends MultiStepComp.Step> { } } - if (DataStorage.get().getStoreEntryIfPresent(name.getValue()).isPresent()) { - messageProp.setValue("Store with name " + name.getValue() + " does already exist"); - changedSinceError.setValue(false); - return false; - } - - if (DataStorage.get().getStoreEntryIfPresent(entry.getValue().getStore()).isPresent()) { - messageProp.setValue("A store with the same configuration does already exist"); - changedSinceError.setValue(false); - return false; + if (!exists) { + if (name.getValue() != null && DataStorage.get().getStoreEntryIfPresent(name.getValue()).isPresent()) { + messageProp.setValue("Store with name " + name.getValue() + " does already exist"); + changedSinceError.setValue(false); + return false; + } } if (!validator.getValue().validate()) { diff --git a/app/src/main/java/io/xpipe/app/fxcomps/impl/FileStoreChoiceComp.java b/app/src/main/java/io/xpipe/app/fxcomps/impl/FileStoreChoiceComp.java index 53613014..d00b7866 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/impl/FileStoreChoiceComp.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/impl/FileStoreChoiceComp.java @@ -48,7 +48,8 @@ public class FileStoreChoiceComp extends SimpleComp { var fileNameComp = new TextFieldComp(fileProperty) .apply(struc -> HBox.setHgrow(struc.get(), Priority.ALWAYS)) - .styleClass(onlyLocal ? Styles.LEFT_PILL : Styles.CENTER_PILL); + .styleClass(onlyLocal ? Styles.LEFT_PILL : Styles.CENTER_PILL) + .grow(false, true); var fileBrowseButton = new ButtonComp(null, new FontIcon("mdi2f-folder-open-outline"), () -> { StandaloneFileBrowser.openSingleFile(selected); diff --git a/app/src/main/java/io/xpipe/app/fxcomps/impl/SvgView.java b/app/src/main/java/io/xpipe/app/fxcomps/impl/SvgView.java index 81075d72..e55dcb0b 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/impl/SvgView.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/impl/SvgView.java @@ -10,6 +10,7 @@ import javafx.collections.ListChangeListener; import javafx.css.Size; import javafx.css.SizeUnits; import javafx.geometry.Point2D; +import javafx.scene.AccessibleRole; import javafx.scene.Node; import javafx.scene.layout.StackPane; import javafx.scene.paint.Color; @@ -101,6 +102,7 @@ public class SvgView { wv.getEngine().setJavaScriptEnabled(false); wv.setContextMenuEnabled(false); wv.setFocusTraversable(false); + wv.setAccessibleRole(AccessibleRole.IMAGE_VIEW); wv.getEngine().loadContent(getHtml(svgContent.getValue())); svgContent.addListener((c, o, n) -> { diff --git a/app/src/main/java/io/xpipe/app/util/OptionsBuilder.java b/app/src/main/java/io/xpipe/app/util/OptionsBuilder.java index c29b513c..df5f2097 100644 --- a/app/src/main/java/io/xpipe/app/util/OptionsBuilder.java +++ b/app/src/main/java/io/xpipe/app/util/OptionsBuilder.java @@ -134,6 +134,12 @@ public class OptionsBuilder { return this; } + public OptionsBuilder addProperty(Property prop) { + props.add(prop); + return this; + } + + public OptionsBuilder addSecret(Property prop) { var comp = new SecretFieldComp(prop); pushComp(comp); diff --git a/dist/changelogs/1.1.1.md b/dist/changelogs/1.1.1.md index 0a1919cb..33cb65d8 100644 --- a/dist/changelogs/1.1.1.md +++ b/dist/changelogs/1.1.1.md @@ -2,6 +2,7 @@ - Improve startup time - Improve error messages when command or shell connection fails +- Fix self-updater not launching on Linux and macOS. Might require a reinstallation to get it working again - Fix file browser not working for some Alpine Linux distributions - Add support for Tabby terminals - Start up local and wsl sessions in user home directory