From 6cc9e4ab6b22bd8eef8dceafd92075406bce3e64 Mon Sep 17 00:00:00 2001 From: crschnick Date: Wed, 21 Jan 2026 14:55:28 +0000 Subject: [PATCH] Fixes --- .../io/xpipe/app/comp/BaseRegionBuilder.java | 6 ++ app/src/main/java/io/xpipe/app/comp/README.md | 81 ------------------- .../app/pwman/BitwardenPasswordManager.java | 2 +- dist/licenses/fx-builders.license | 21 +++++ dist/licenses/fx-builders.properties | 4 + 5 files changed, 32 insertions(+), 82 deletions(-) delete mode 100644 app/src/main/java/io/xpipe/app/comp/README.md create mode 100644 dist/licenses/fx-builders.license create mode 100644 dist/licenses/fx-builders.properties diff --git a/app/src/main/java/io/xpipe/app/comp/BaseRegionBuilder.java b/app/src/main/java/io/xpipe/app/comp/BaseRegionBuilder.java index 39547de60..1fed99d5e 100644 --- a/app/src/main/java/io/xpipe/app/comp/BaseRegionBuilder.java +++ b/app/src/main/java/io/xpipe/app/comp/BaseRegionBuilder.java @@ -15,6 +15,12 @@ import java.util.function.Consumer; public abstract class BaseRegionBuilder> extends AbstractRegionBuilder { + public BaseRegionBuilder() { + apply(t -> { + BindingsHelper.preserve(t, this); + }); + } + public B hgrow() { apply(t -> HBox.setHgrow(t, Priority.ALWAYS)); return self(); diff --git a/app/src/main/java/io/xpipe/app/comp/README.md b/app/src/main/java/io/xpipe/app/comp/README.md deleted file mode 100644 index b83fc075e..000000000 --- a/app/src/main/java/io/xpipe/app/comp/README.md +++ /dev/null @@ -1,81 +0,0 @@ -# Compound Components - -As a basis, JavaFX nodes are created and manage via comps (compound components). - -## Principles - -#### A comp is a Node/Region factory, not just another fancy wrapper for existing classes - -It is advantageous to define a certain component to be a factory -that can create an instances of a JavaFX Node each time it is called. -By using this factory architecture, the scene contents can -be rebuilt entirely by invoking the root component factory. - -#### A comp should produce a transparent representation of Regions and Controls - -In JavaFX, using skins allows for flexibility when generating the look and feel for a control. -One limitation of this approach is that the generated node tree is not very transparent -for developers who are especially interested in styling it. -This is caused by the fact that a skin does not expose the information required to style -it completely or even alter it without creating a new Skin class. - -A comp should be designed to allow developers to easily expose as much information -about the produced node tree structure using the CompStructure class. -In case you don't want to expose the detailed structure of your comp, -you can also just use a very simple structure. - -#### A comp should produce a Region instead of a Node - -In practice, working with the very abstract node class comes with its fair share of limitations. -It is much easier to work with region instances, as they have various width and height properties. -Since pretty much every Node is also a Region, the main focus of comps are regions. -In case you are dealing with Nodes that are not Regions, like an ImageView or WebView, -you can still wrap them inside for example a StackPane to obtain a Region again that you can work with. - -#### The generation process of a comp can be augmented - -As comps are factories, any changes that should be applied to all produced -Node instances must be integrated into the factory pipeline. -This can be achieved with the Augment class, which allows you -to alter the produced node after the base factory has finished. - -#### Properties used by Comps should be managed by the user, not the Comp itself - -This allows Comps to only be a thin wrapper around already existing -Observables/Properties and gives the user the ability to complete control the handling of Properties. -This approach is also required for the next point. - -#### A comp should not break when used Observables are updated from a thread that is not the platform thread - -One common limitation of using JavaFX is that many things break when -calling any method from another thread that is not the platform thread. -While in many cases these issues can be mitigated by wrapping a problematic call in a Platform.runLater(...), -some problematic instances are harder to fix, for example Observable bindings. -In JavaFX, there is currently no way to propagate changes of an Observable -to other bound Observables only using the platform thread, when the original change was made from a different thread. -The FxComps library provides a solution with the PlatformThread.sync(...) methods and strongly encourages that -Comps make use of these methods in combination with user-managed properties -to allow for value changes for Observables from any thread without issue. - -## Hot reload - -The reason a Comp is designed to be a factory is to allow for hot -reloading your created GUI in conjunction with the hot-reload functionality in your IDE: - -````java - void setupReload(Scene scene, BaseRegionBuilder content) { - var contentR = content.build(); - scene.addEventHandler(KeyEvent.KEY_PRESSED, event -> { - if (event.getCode().equals(KeyCode.F5)) { - var newContentR = content.build(); - scene.setRoot(newContentR); - event.consume(); - } - }); - } -```` - -If you for example bind your IDE Hot Reload to F4 and your Scene reload listener to F5, -you can almost instantly apply any changes made to your GUI code without restarting. -You can also implement a similar solution to also reload your stylesheets and translations. - diff --git a/app/src/main/java/io/xpipe/app/pwman/BitwardenPasswordManager.java b/app/src/main/java/io/xpipe/app/pwman/BitwardenPasswordManager.java index 4c2e6bdf8..aec36f929 100644 --- a/app/src/main/java/io/xpipe/app/pwman/BitwardenPasswordManager.java +++ b/app/src/main/java/io/xpipe/app/pwman/BitwardenPasswordManager.java @@ -124,7 +124,7 @@ public class BitwardenPasswordManager implements PasswordManager { var password = login.required("password"); return new CredentialResult(user.isNull() ? null : user.asText(), InPlaceSecretValue.of(password.asText())); } catch (Exception ex) { - ErrorEventFactory.fromThrowable(ex).handle(); + ErrorEventFactory.fromThrowable(ex).expected().handle(); return null; } } diff --git a/dist/licenses/fx-builders.license b/dist/licenses/fx-builders.license new file mode 100644 index 000000000..b4dca4b60 --- /dev/null +++ b/dist/licenses/fx-builders.license @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 John Hendrikx + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/dist/licenses/fx-builders.properties b/dist/licenses/fx-builders.properties new file mode 100644 index 000000000..071a586bd --- /dev/null +++ b/dist/licenses/fx-builders.properties @@ -0,0 +1,4 @@ +name=fx-builders +version=0.4 +license=MIT License +link=https://github.com/int4-org/FX \ No newline at end of file