Added controlsfx dependency and toast notifications for password copying.

This commit is contained in:
Andrew Lalis 2021-05-31 22:59:47 +02:00
parent f7b54dc182
commit 33e16e40aa
4 changed files with 18 additions and 16 deletions

View File

@ -80,6 +80,12 @@
<artifactId>javafx-fxml</artifactId> <artifactId>javafx-fxml</artifactId>
<version>${javafx.version}</version> <version>${javafx.version}</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.controlsfx/controlsfx -->
<dependency>
<groupId>org.controlsfx</groupId>
<artifactId>controlsfx</artifactId>
<version>11.1.0</version>
</dependency>
<dependency> <dependency>
<groupId>com.1stleg</groupId> <groupId>com.1stleg</groupId>
<artifactId>jnativehook</artifactId> <artifactId>jnativehook</artifactId>

View File

@ -2,6 +2,7 @@ module crystalkeep {
requires javafx.fxml; requires javafx.fxml;
requires javafx.controls; requires javafx.controls;
requires jnativehook; requires jnativehook;
requires org.controlsfx.controls;
opens nl.andrewlalis.crystalkeep.control; opens nl.andrewlalis.crystalkeep.control;
opens nl.andrewlalis.crystalkeep; opens nl.andrewlalis.crystalkeep;

View File

@ -8,6 +8,10 @@ import nl.andrewlalis.crystalkeep.model.CrystalItem;
import nl.andrewlalis.crystalkeep.view.ShardTreeItem; import nl.andrewlalis.crystalkeep.view.ShardTreeItem;
import nl.andrewlalis.crystalkeep.view.shard_details.ViewModels; 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<TreeItem<CrystalItem>> { public class ClusterTreeViewItemSelectionListener implements ChangeListener<TreeItem<CrystalItem>> {
private final VBox shardDetailContainer; private final VBox shardDetailContainer;

View File

@ -8,10 +8,9 @@ import javafx.scene.input.ClipboardContent;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox; import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane; import javafx.scene.layout.Pane;
import javafx.util.Duration;
import nl.andrewlalis.crystalkeep.model.shards.LoginCredentialsShard; import nl.andrewlalis.crystalkeep.model.shards.LoginCredentialsShard;
import org.jnativehook.GlobalScreen; import org.controlsfx.control.Notifications;
import org.jnativehook.keyboard.NativeKeyAdapter;
import org.jnativehook.keyboard.NativeKeyEvent;
public class LoginCredentialsViewModel extends ShardViewModel<LoginCredentialsShard> { public class LoginCredentialsViewModel extends ShardViewModel<LoginCredentialsShard> {
public LoginCredentialsViewModel(LoginCredentialsShard shard) { public LoginCredentialsViewModel(LoginCredentialsShard shard) {
@ -63,19 +62,11 @@ public class LoginCredentialsViewModel extends ShardViewModel<LoginCredentialsSh
ClipboardContent content = new ClipboardContent(); ClipboardContent content = new ClipboardContent();
content.putString(shard.getPassword()); content.putString(shard.getPassword());
Clipboard.getSystemClipboard().setContent(content); Clipboard.getSystemClipboard().setContent(content);
}); Notifications.create()
.text("Password copied to clipboard.")
var copyBothButton = new Button("Copy Username and Password"); .hideAfter(Duration.seconds(3))
copyBothButton.setOnAction(event -> { .owner(gp)
ClipboardContent content = new ClipboardContent(); .show();
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");
}
});
}); });
passwordActionsPane.getChildren().addAll(showPasswordCheckbox, copyPasswordButton); passwordActionsPane.getChildren().addAll(showPasswordCheckbox, copyPasswordButton);