From 44f7b4922d4af4ccf4baeaac8788c12a73bf2c80 Mon Sep 17 00:00:00 2001 From: crschnick Date: Sun, 12 Feb 2023 16:48:07 +0000 Subject: [PATCH] Fix many small issues --- .../store/DsStoreProviderChoiceComp.java | 2 - .../comp/source/store/GuiDsStoreCreator.java | 11 +-- .../comp/storage/store/StoreEntryComp.java | 20 +++--- .../storage/store/StoreEntryListComp.java | 15 ++-- .../comp/storage/store/StoreEntryWrapper.java | 11 +++ .../store/StoreStorageEmptyIntroComp.java | 1 + .../java/io/xpipe/app/prefs/AppPrefs.java | 4 +- .../resources/lang/translations_en.properties | 1 + .../io/xpipe/app/resources/misc/eula.md | 6 +- .../io/xpipe/ext/base/LocalStoreProvider.java | 3 +- .../ext/base/actions/EditStoreAction.java | 70 +++++++++++++++++++ ext/base/src/main/java/module-info.java | 1 + .../resources/lang/translations_en.properties | 5 +- .../fxcomps/impl/DynamicOptionsComp.java | 6 +- .../xpipe/extension/util/ActionProvider.java | 4 ++ 15 files changed, 123 insertions(+), 37 deletions(-) create mode 100644 ext/base/src/main/java/io/xpipe/ext/base/actions/EditStoreAction.java diff --git a/app/src/main/java/io/xpipe/app/comp/source/store/DsStoreProviderChoiceComp.java b/app/src/main/java/io/xpipe/app/comp/source/store/DsStoreProviderChoiceComp.java index 1bb0bc4e7..960372df5 100644 --- a/app/src/main/java/io/xpipe/app/comp/source/store/DsStoreProviderChoiceComp.java +++ b/app/src/main/java/io/xpipe/app/comp/source/store/DsStoreProviderChoiceComp.java @@ -55,8 +55,6 @@ public class DsStoreProviderChoiceComp extends Comp @Override public CompStructure> createBase() { var comboBox = new CustomComboBoxBuilder<>(provider, this::createGraphic, createDefaultNode(), v -> true); - comboBox.add(null); - comboBox.addSeparator(); getProviders().stream() .filter(p -> AppPrefs.get().developerShowHiddenProviders().get() || p.shouldShow()) .forEach(comboBox::add); 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 7b99a29b3..dc2debcfe 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 @@ -195,21 +195,14 @@ public class GuiDsStoreCreator extends MultiStepComp.Step> { } var d = n.guiDialog(input); - - if (d == null || d.getComp() == null) { - layout.setCenter(null); - validator.setValue(new SimpleValidator()); - return; - } - var propVal = new SimpleValidator(); - var propR = createStoreProperties(d.getComp(), propVal); + var propR = createStoreProperties(d == null || d.getComp() == null ? null : d.getComp(), propVal); var box = new VBox(propR); box.setSpacing(7); layout.setCenter(box); - validator.setValue(new ChainedValidator(List.of(d.getValidator(), propVal))); + validator.setValue(new ChainedValidator(List.of(d != null && d.getValidator() != null ? d.getValidator() : new SimpleValidator(), propVal))); } else { layout.setCenter(null); validator.setValue(new SimpleValidator()); diff --git a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryComp.java b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryComp.java index df2b6f4e8..5fdc7704f 100644 --- a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryComp.java +++ b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryComp.java @@ -152,9 +152,14 @@ public class StoreEntryComp extends SimpleComp { button.setFocusTraversable(false); button.setOnAction(event -> { event.consume(); - if (entry.getEditable().get()) { - entry.editDialog(); - } + ThreadHelper.runFailableAsync(() -> { + var found = entry.getDefaultActionProvider().getValue(); + if (found != null) { + found.getDataStoreCallSite() + .createAction(entry.getEntry().getStore().asNeeded()) + .execute(); + } + }); }); return button; @@ -164,7 +169,7 @@ public class StoreEntryComp extends SimpleComp { var list = new ArrayList>(); for (var p : entry.getActionProviders().entrySet()) { var actionProvider = p.getKey().getDataStoreCallSite(); - if (!actionProvider.isMajor()) { + if (!actionProvider.isMajor() || p.getKey().equals(entry.getDefaultActionProvider().getValue())) { continue; } @@ -213,7 +218,7 @@ public class StoreEntryComp extends SimpleComp { settingsButton.apply(s -> { s.get().prefWidthProperty().bind(Bindings.divide(s.get().heightProperty(), 1.35)); }); - settingsButton.apply(new FancyTooltipAugment<>("entrySettings")); + settingsButton.apply(new FancyTooltipAugment<>("more")); return settingsButton; } @@ -263,11 +268,6 @@ public class StoreEntryComp extends SimpleComp { }); contextMenu.getItems().add(refresh); - var edit = new MenuItem(I18n.get("edit"), new FontIcon("mdal-edit")); - edit.disableProperty().bind(entry.getEditable().not()); - edit.setOnAction(event -> entry.editDialog()); - contextMenu.getItems().add(edit); - var del = new MenuItem(I18n.get("delete"), new FontIcon("mdal-delete_outline")); del.disableProperty().bind(entry.getDeletable().not()); del.setOnAction(event -> entry.delete()); diff --git a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryListComp.java b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryListComp.java index 765b7dacd..a2e7b0534 100644 --- a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryListComp.java +++ b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryListComp.java @@ -9,7 +9,7 @@ import javafx.beans.binding.Bindings; import javafx.beans.value.ObservableBooleanValue; import javafx.scene.layout.Region; -import java.util.Map; +import java.util.LinkedHashMap; public class StoreEntryListComp extends SimpleComp { @@ -28,13 +28,14 @@ public class StoreEntryListComp extends SimpleComp { @Override protected Region createSimple() { - var map = Map., ObservableBooleanValue>of( + var map = new LinkedHashMap, ObservableBooleanValue>(); + map.put( createList(), - BindingsHelper.persist(Bindings.and( - Bindings.not(StoreViewState.get().emptyProperty()), - Bindings.not(Bindings.isEmpty(StoreViewState.get().getShownEntries())))), - new StoreStorageEmptyIntroComp(), - StoreViewState.get().emptyProperty(), + BindingsHelper.persist( + Bindings.not(Bindings.isEmpty(StoreViewState.get().getShownEntries())))); + + map.put(new StoreStorageEmptyIntroComp(), StoreViewState.get().emptyProperty()); + map.put( new StoreNotFoundComp(), BindingsHelper.persist(Bindings.and( Bindings.not(Bindings.isEmpty(StoreViewState.get().getAllEntries())), diff --git a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryWrapper.java b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryWrapper.java index 147dc9730..f13a32c70 100644 --- a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryWrapper.java +++ b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryWrapper.java @@ -8,9 +8,11 @@ import io.xpipe.app.storage.DataStoreEntry; import io.xpipe.extension.event.ErrorEvent; import io.xpipe.extension.fxcomps.util.PlatformThread; import io.xpipe.extension.util.ActionProvider; +import javafx.beans.Observable; import javafx.beans.binding.Bindings; import javafx.beans.property.*; import javafx.beans.value.ObservableBooleanValue; +import javafx.beans.value.ObservableValue; import lombok.Getter; import java.time.Duration; @@ -30,6 +32,7 @@ public class StoreEntryWrapper implements StorageFilter.Filterable { private final StringProperty information = new SimpleStringProperty(); private final StringProperty summary = new SimpleStringProperty(); private final Map actionProviders; + private final ObservableValue defaultActionProvider; private final BooleanProperty editable = new SimpleBooleanProperty(); private final BooleanProperty renamable = new SimpleBooleanProperty(); private final BooleanProperty refreshable = new SimpleBooleanProperty(); @@ -65,6 +68,14 @@ public class StoreEntryWrapper implements StorageFilter.Filterable { lastAccess); actionProviders.put(dataStoreActionProvider, property); }); + this.defaultActionProvider = Bindings.createObjectBinding(() -> { + var found = actionProviders.entrySet().stream() + .filter(e -> e.getValue().get()) + .filter(e -> e.getKey().getDataStoreCallSite() != null + && e.getKey().getDataStoreCallSite().isDefault()) + .findFirst(); + return found.map(p -> p.getKey()).orElse(null); + }, actionProviders.values().toArray(Observable[]::new)); setupListeners(); update(); } diff --git a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreStorageEmptyIntroComp.java b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreStorageEmptyIntroComp.java index 523573427..7164ba768 100644 --- a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreStorageEmptyIntroComp.java +++ b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreStorageEmptyIntroComp.java @@ -80,6 +80,7 @@ public class StoreStorageEmptyIntroComp extends SimpleComp { var sp = new StackPane(v); sp.setAlignment(Pos.CENTER); + sp.setPickOnBounds(false); return sp; } } diff --git a/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java b/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java index ae578ac87..f17467609 100644 --- a/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java +++ b/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java @@ -30,7 +30,7 @@ public class AppPrefs { private static ObservableBooleanValue bindDeveloperTrue(ObservableBooleanValue o) { return Bindings.createBooleanBinding( () -> { - return AppPrefs.get().developerMode().getValue() || o.get(); + return AppPrefs.get().developerMode().getValue() && o.get(); }, o, AppPrefs.get().developerMode()); @@ -39,7 +39,7 @@ public class AppPrefs { private static ObservableBooleanValue bindDeveloperFalse(ObservableBooleanValue o) { return Bindings.createBooleanBinding( () -> { - return !AppPrefs.get().developerMode().getValue() || o.get(); + return !AppPrefs.get().developerMode().getValue() && o.get(); }, o, AppPrefs.get().developerMode()); diff --git a/app/src/main/resources/io/xpipe/app/resources/lang/translations_en.properties b/app/src/main/resources/io/xpipe/app/resources/lang/translations_en.properties index 7867dee53..880475fce 100644 --- a/app/src/main/resources/io/xpipe/app/resources/lang/translations_en.properties +++ b/app/src/main/resources/io/xpipe/app/resources/lang/translations_en.properties @@ -7,6 +7,7 @@ errorTypeOccured=An exception of type $TYPE$ was thrown errorDetails=Show details target=Target data=Data +more=More pipeDataSource=Pipe Data Source updateReadyTitle=Update Ready updateReadyHeader=An update is ready to be installed diff --git a/app/src/main/resources/io/xpipe/app/resources/misc/eula.md b/app/src/main/resources/io/xpipe/app/resources/misc/eula.md index 789fbcb3e..035112926 100644 --- a/app/src/main/resources/io/xpipe/app/resources/misc/eula.md +++ b/app/src/main/resources/io/xpipe/app/resources/misc/eula.md @@ -39,8 +39,8 @@ granted by this EULA. ### Privacy Notices -The Software automatically communicates with its server for three purposes: (1) updating the Software; (2) sending error -reports; and (3) sending anonymized usage data so we may improve the Software. If you would like to learn more about the +The Software automatically communicates with its server for two purposes: (1) updating the Software; (2) sending error +reports; If you would like to learn more about the specific information we send, please visit https://xpipe.io/privacy_policy. You may opt out of these features. 1. **Automatic Software Updates.** The Software communicates with its server (and sends information described at the URL @@ -48,7 +48,7 @@ specific information we send, please visit https://xpipe.io/privacy_policy. You Software. You agree that the Software may automatically install any such improvements to the Software on your computer without providing any further notice or receiving any additional consent. This feature may be disabled. 2. **Error Reports.** In order to help us improve the Software, when the Software encounters certain errors, it will - automatically send some information to its server about the error (as described at the URL above). This feature may + send some information to its server about the error (as described at the URL above). This feature may be disabled. ### Open-Source Notices diff --git a/ext/base/src/main/java/io/xpipe/ext/base/LocalStoreProvider.java b/ext/base/src/main/java/io/xpipe/ext/base/LocalStoreProvider.java index f2b83f4f2..36e39fd06 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/LocalStoreProvider.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/LocalStoreProvider.java @@ -45,9 +45,10 @@ public class LocalStoreProvider implements DataStoreProvider { e.setConfiguration(StorageElement.Configuration.builder() .deletable(false) .editable(false) - .refreshable(false) + .refreshable(true) .renameable(false) .build()); + e.refresh(true); } @Override diff --git a/ext/base/src/main/java/io/xpipe/ext/base/actions/EditStoreAction.java b/ext/base/src/main/java/io/xpipe/ext/base/actions/EditStoreAction.java new file mode 100644 index 000000000..322102724 --- /dev/null +++ b/ext/base/src/main/java/io/xpipe/ext/base/actions/EditStoreAction.java @@ -0,0 +1,70 @@ +package io.xpipe.ext.base.actions; + +import io.xpipe.app.comp.source.store.GuiDsStoreCreator; +import io.xpipe.app.storage.DataStorage; +import io.xpipe.app.storage.DataStoreEntry; +import io.xpipe.core.store.DataStore; +import io.xpipe.extension.I18n; +import io.xpipe.extension.util.ActionProvider; +import javafx.beans.value.ObservableValue; +import lombok.Value; + +public class EditStoreAction implements ActionProvider { + + @Value + static class Action implements ActionProvider.Action { + + DataStoreEntry store; + + @Override + public boolean requiresPlatform() { + return true; + } + + @Override + public void execute() throws Exception { + GuiDsStoreCreator.showEdit(store); + } + } + + @Override + public DataStoreCallSite getDataStoreCallSite() { + return new DataStoreCallSite() { + + @Override + public boolean isMajor() { + return true; + } + + @Override + public boolean showIfDisabled() { + return false; + } + + @Override + public ActionProvider.Action createAction(DataStore store) { + return new Action(DataStorage.get().getStore(store)); + } + + @Override + public Class getApplicableClass() { + return DataStore.class; + } + + @Override + public boolean isApplicable(DataStore o) throws Exception { + return DataStorage.get().getStore(o).getConfiguration().isEditable(); + } + + @Override + public ObservableValue getName(DataStore store) { + return I18n.observable("base.edit"); + } + + @Override + public String getIcon(DataStore store) { + return "mdal-edit"; + } + }; + } +} diff --git a/ext/base/src/main/java/module-info.java b/ext/base/src/main/java/module-info.java index d7c62320d..a75e590f6 100644 --- a/ext/base/src/main/java/module-info.java +++ b/ext/base/src/main/java/module-info.java @@ -23,6 +23,7 @@ open module io.xpipe.ext.base { provides ActionProvider with AddStoreAction, + EditStoreAction, StreamExportAction, ShareStoreAction, FileBrowseAction, diff --git a/ext/base/src/main/resources/io/xpipe/ext/base/resources/lang/translations_en.properties b/ext/base/src/main/resources/io/xpipe/ext/base/resources/lang/translations_en.properties index de01de598..631688c08 100644 --- a/ext/base/src/main/resources/io/xpipe/ext/base/resources/lang/translations_en.properties +++ b/ext/base/src/main/resources/io/xpipe/ext/base/resources/lang/translations_en.properties @@ -52,4 +52,7 @@ waitingForConsumer=Waiting for Consumer waitingForProducer=Waiting for Producer open=Open closed=Closed -internalStream.displayName=Internal Stream \ No newline at end of file +internalStream.displayName=Internal Stream +local.displayName=Local machine +local.displayDescription= +edit=Edit \ No newline at end of file diff --git a/extension/src/main/java/io/xpipe/extension/fxcomps/impl/DynamicOptionsComp.java b/extension/src/main/java/io/xpipe/extension/fxcomps/impl/DynamicOptionsComp.java index 0dfde6ae5..d2cb96177 100644 --- a/extension/src/main/java/io/xpipe/extension/fxcomps/impl/DynamicOptionsComp.java +++ b/extension/src/main/java/io/xpipe/extension/fxcomps/impl/DynamicOptionsComp.java @@ -86,8 +86,10 @@ public class DynamicOptionsComp extends Comp> { pane.getChildren().add(line); } else { - compRegions.add(compRegion); - pane.getChildren().add(compRegion); + if (compRegion != null) { + compRegions.add(compRegion); + pane.getChildren().add(compRegion); + } } } diff --git a/extension/src/main/java/io/xpipe/extension/util/ActionProvider.java b/extension/src/main/java/io/xpipe/extension/util/ActionProvider.java index 777ced850..d89aa0df3 100644 --- a/extension/src/main/java/io/xpipe/extension/util/ActionProvider.java +++ b/extension/src/main/java/io/xpipe/extension/util/ActionProvider.java @@ -78,6 +78,10 @@ public interface ActionProvider { Class getApplicableClass(); + default boolean isDefault() { + return false; + } + default boolean isMajor() { return false; }