From 2b09a2dbde8ba9b661b06719a3bc2c525807632e Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R Date: Fri, 10 Apr 2020 11:01:03 +0200 Subject: [PATCH] Moved the LoginDialogController class inside the LoginDialog class --- src/main/java/envoy/client/net/Client.java | 20 ++--- .../java/envoy/client/ui/LoginDialog.fxml | 84 ++++++++----------- .../java/envoy/client/ui/LoginDialog.java | 70 ++++++++++++++++ .../client/ui/LoginDialogController.java | 53 ------------ src/main/java/envoy/client/ui/Startup.java | 19 +++-- 5 files changed, 125 insertions(+), 121 deletions(-) create mode 100644 src/main/java/envoy/client/ui/LoginDialog.java delete mode 100644 src/main/java/envoy/client/ui/LoginDialogController.java diff --git a/src/main/java/envoy/client/net/Client.java b/src/main/java/envoy/client/net/Client.java index 9ae69fb..50019f4 100644 --- a/src/main/java/envoy/client/net/Client.java +++ b/src/main/java/envoy/client/net/Client.java @@ -46,9 +46,10 @@ public class Client implements Closeable { private volatile Set contacts; private volatile boolean rejected; - // Configuration and logging - private static final ClientConfig config = ClientConfig.getInstance(); - private static final Logger logger = EnvoyLog.getLogger(Client.class); + // Configuration, logging and event management + private static final ClientConfig config = ClientConfig.getInstance(); + private static final Logger logger = EnvoyLog.getLogger(Client.class); + private static final EventBus eventBus = EventBus.getInstance(); /** * Enters the online mode by acquiring a user ID from the server. As a @@ -80,7 +81,7 @@ public class Client implements Closeable { // Register user creation processor, contact list processor and message cache receiver.registerProcessor(User.class, sender -> { this.sender = sender; contacts = sender.getContacts(); }); receiver.registerProcessor(Message.class, receivedMessageCache); - receiver.registerProcessor(HandshakeRejectionEvent.class, evt -> { rejected = true; EventBus.getInstance().dispatch(evt); }); + receiver.registerProcessor(HandshakeRejectionEvent.class, evt -> { rejected = true; eventBus.dispatch(evt); }); rejected = false; @@ -146,20 +147,19 @@ public class Client implements Closeable { receiver.registerProcessor(IDGenerator.class, localDB::setIDGenerator); // Process name changes - receiver.registerProcessor(NameChangeEvent.class, evt -> { localDB.replaceContactName(evt); EventBus.getInstance().dispatch(evt); }); + receiver.registerProcessor(NameChangeEvent.class, evt -> { localDB.replaceContactName(evt); eventBus.dispatch(evt); }); // Process contact searches - receiver.registerProcessor(ContactSearchResult.class, EventBus.getInstance()::dispatch); + receiver.registerProcessor(ContactSearchResult.class, eventBus::dispatch); receiver.registerProcessor(Contact.class, - contacts -> EventBus.getInstance() - .dispatch(new ContactOperationEvent(contacts.getContacts().iterator().next(), ElementOperation.ADD))); + contacts -> eventBus.dispatch(new ContactOperationEvent(contacts.getContacts().iterator().next(), ElementOperation.ADD))); // Process group size changes - receiver.registerProcessor(GroupResizeEvent.class, evt -> { localDB.updateGroup(evt); EventBus.getInstance().dispatch(evt); }); + receiver.registerProcessor(GroupResizeEvent.class, evt -> { localDB.updateGroup(evt); eventBus.dispatch(evt); }); // Send event - EventBus.getInstance().register(SendEvent.class, evt -> { + eventBus.register(SendEvent.class, evt -> { try { sendEvent(evt.get()); } catch (IOException e) { diff --git a/src/main/java/envoy/client/ui/LoginDialog.fxml b/src/main/java/envoy/client/ui/LoginDialog.fxml index 45b2d60..30020e9 100644 --- a/src/main/java/envoy/client/ui/LoginDialog.fxml +++ b/src/main/java/envoy/client/ui/LoginDialog.fxml @@ -2,6 +2,7 @@ + @@ -12,52 +13,37 @@ - - - - - - - - - - - - - - - - - - - -