Added controlsfx dependency and toast notifications for password copying.
This commit is contained in:
parent
f7b54dc182
commit
33e16e40aa
6
pom.xml
6
pom.xml
|
@ -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>
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue