From 33e16e40aabac2f6e8c2c3e4c63da805d59c76cb Mon Sep 17 00:00:00 2001 From: Andrew Lalis Date: Mon, 31 May 2021 22:59:47 +0200 Subject: [PATCH] Added controlsfx dependency and toast notifications for password copying. --- pom.xml | 6 +++++ src/main/java/module-info.java | 1 + .../ClusterTreeViewItemSelectionListener.java | 4 ++++ .../LoginCredentialsViewModel.java | 23 ++++++------------- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index f376f07..413f33d 100644 --- a/pom.xml +++ b/pom.xml @@ -80,6 +80,12 @@ javafx-fxml ${javafx.version} + + + org.controlsfx + controlsfx + 11.1.0 + com.1stleg jnativehook diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 10f6a58..8cb2fb3 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -2,6 +2,7 @@ module crystalkeep { requires javafx.fxml; requires javafx.controls; requires jnativehook; + requires org.controlsfx.controls; opens nl.andrewlalis.crystalkeep.control; opens nl.andrewlalis.crystalkeep; diff --git a/src/main/java/nl/andrewlalis/crystalkeep/control/ClusterTreeViewItemSelectionListener.java b/src/main/java/nl/andrewlalis/crystalkeep/control/ClusterTreeViewItemSelectionListener.java index 318716a..eee88e9 100644 --- a/src/main/java/nl/andrewlalis/crystalkeep/control/ClusterTreeViewItemSelectionListener.java +++ b/src/main/java/nl/andrewlalis/crystalkeep/control/ClusterTreeViewItemSelectionListener.java @@ -8,6 +8,10 @@ import nl.andrewlalis.crystalkeep.model.CrystalItem; import nl.andrewlalis.crystalkeep.view.ShardTreeItem; import nl.andrewlalis.crystalkeep.view.shard_details.ViewModels; +/** + * This listener will update the shard detail container pane (the main center + * content of the application) to show the contents of a selected shard. + */ public class ClusterTreeViewItemSelectionListener implements ChangeListener> { private final VBox shardDetailContainer; diff --git a/src/main/java/nl/andrewlalis/crystalkeep/view/shard_details/LoginCredentialsViewModel.java b/src/main/java/nl/andrewlalis/crystalkeep/view/shard_details/LoginCredentialsViewModel.java index 8a0a97f..c943b8a 100644 --- a/src/main/java/nl/andrewlalis/crystalkeep/view/shard_details/LoginCredentialsViewModel.java +++ b/src/main/java/nl/andrewlalis/crystalkeep/view/shard_details/LoginCredentialsViewModel.java @@ -8,10 +8,9 @@ import javafx.scene.input.ClipboardContent; import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; +import javafx.util.Duration; import nl.andrewlalis.crystalkeep.model.shards.LoginCredentialsShard; -import org.jnativehook.GlobalScreen; -import org.jnativehook.keyboard.NativeKeyAdapter; -import org.jnativehook.keyboard.NativeKeyEvent; +import org.controlsfx.control.Notifications; public class LoginCredentialsViewModel extends ShardViewModel { public LoginCredentialsViewModel(LoginCredentialsShard shard) { @@ -63,19 +62,11 @@ public class LoginCredentialsViewModel extends ShardViewModel { - ClipboardContent content = new ClipboardContent(); - content.putString(shard.getUsername()); - final Clipboard c = Clipboard.getSystemClipboard(); - c.setContent(content); - var t = new Thread(() -> { - while (c.getString().equals(shard.getUsername())) { - System.out.println("User hasn't pasted yet"); - } - }); + Notifications.create() + .text("Password copied to clipboard.") + .hideAfter(Duration.seconds(3)) + .owner(gp) + .show(); }); passwordActionsPane.getChildren().addAll(showPasswordCheckbox, copyPasswordButton);