From 511146c98eeb037c858cebc544777206d54becb6 Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R Date: Wed, 12 Feb 2020 07:12:22 +0100 Subject: [PATCH] Clean-up, moved Settings and SettingsItem into the data package --- .../envoy/client/{ => data}/Settings.java | 3 +- .../envoy/client/{ => data}/SettingsItem.java | 2 +- .../event/HandshakeSuccessfulEvent.java | 2 +- src/main/java/envoy/client/ui/ChatWindow.java | 2 +- .../client/ui/ContactsSearchRenderer.java | 2 +- .../java/envoy/client/ui/LoginDialog.java | 29 ++++++++++--------- .../envoy/client/ui/MessageListRenderer.java | 2 +- .../envoy/client/ui/PrimaryScrollBar.java | 2 +- .../envoy/client/ui/PrimaryToggleSwitch.java | 4 +-- src/main/java/envoy/client/ui/Startup.java | 3 +- .../envoy/client/ui/UserListRenderer.java | 2 +- .../ui/settings/GeneralSettingsPanel.java | 4 +-- .../client/ui/settings/NewThemeScreen.java | 2 +- .../client/ui/settings/SettingsScreen.java | 2 +- .../ui/settings/ThemeCustomizationPanel.java | 2 +- 15 files changed, 31 insertions(+), 32 deletions(-) rename src/main/java/envoy/client/{ => data}/Settings.java (99%) rename src/main/java/envoy/client/{ => data}/SettingsItem.java (99%) diff --git a/src/main/java/envoy/client/Settings.java b/src/main/java/envoy/client/data/Settings.java similarity index 99% rename from src/main/java/envoy/client/Settings.java rename to src/main/java/envoy/client/data/Settings.java index c921605..8cf0283 100644 --- a/src/main/java/envoy/client/Settings.java +++ b/src/main/java/envoy/client/data/Settings.java @@ -1,4 +1,4 @@ -package envoy.client; +package envoy.client.data; import java.io.File; import java.io.IOException; @@ -6,7 +6,6 @@ import java.util.HashMap; import java.util.Map; import java.util.prefs.Preferences; -import envoy.client.data.Config; import envoy.client.ui.Color; import envoy.client.ui.Theme; import envoy.util.SerializationUtils; diff --git a/src/main/java/envoy/client/SettingsItem.java b/src/main/java/envoy/client/data/SettingsItem.java similarity index 99% rename from src/main/java/envoy/client/SettingsItem.java rename to src/main/java/envoy/client/data/SettingsItem.java index 4de2a47..57ba600 100644 --- a/src/main/java/envoy/client/SettingsItem.java +++ b/src/main/java/envoy/client/data/SettingsItem.java @@ -1,4 +1,4 @@ -package envoy.client; +package envoy.client.data; import java.io.Serializable; import java.util.HashMap; diff --git a/src/main/java/envoy/client/event/HandshakeSuccessfulEvent.java b/src/main/java/envoy/client/event/HandshakeSuccessfulEvent.java index 7c20760..9cafa48 100644 --- a/src/main/java/envoy/client/event/HandshakeSuccessfulEvent.java +++ b/src/main/java/envoy/client/event/HandshakeSuccessfulEvent.java @@ -12,7 +12,7 @@ import envoy.event.Event; * @author Leon Hofmeister * @since Envoy v0.3-alpha */ -public class HandshakeSuccessfulEvent implements Event { +public class HandshakeSuccessfulEvent extends Event.Valueless { private static final long serialVersionUID = -157972384126278855L; } diff --git a/src/main/java/envoy/client/ui/ChatWindow.java b/src/main/java/envoy/client/ui/ChatWindow.java index 5aa18c5..045bf9c 100644 --- a/src/main/java/envoy/client/ui/ChatWindow.java +++ b/src/main/java/envoy/client/ui/ChatWindow.java @@ -12,9 +12,9 @@ import javax.swing.border.EmptyBorder; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; -import envoy.client.Settings; import envoy.client.data.Chat; import envoy.client.data.LocalDb; +import envoy.client.data.Settings; import envoy.client.event.MessageCreationEvent; import envoy.client.event.ThemeChangeEvent; import envoy.client.net.Client; diff --git a/src/main/java/envoy/client/ui/ContactsSearchRenderer.java b/src/main/java/envoy/client/ui/ContactsSearchRenderer.java index f206c54..92f5204 100644 --- a/src/main/java/envoy/client/ui/ContactsSearchRenderer.java +++ b/src/main/java/envoy/client/ui/ContactsSearchRenderer.java @@ -6,7 +6,7 @@ import java.awt.Font; import javax.swing.*; -import envoy.client.Settings; +import envoy.client.data.Settings; import envoy.client.event.SendEvent; import envoy.client.ui.list.ComponentList; import envoy.client.ui.list.ComponentListCellRenderer; diff --git a/src/main/java/envoy/client/ui/LoginDialog.java b/src/main/java/envoy/client/ui/LoginDialog.java index 6e7f9a1..d9e4750 100644 --- a/src/main/java/envoy/client/ui/LoginDialog.java +++ b/src/main/java/envoy/client/ui/LoginDialog.java @@ -8,8 +8,8 @@ import java.util.Arrays; import javax.swing.*; import javax.swing.border.EmptyBorder; +import envoy.client.data.Settings; import envoy.client.event.HandshakeSuccessfulEvent; -import envoy.client.Settings; import envoy.data.LoginCredentials; import envoy.event.EventBus; import envoy.event.HandshakeRejectionEvent; @@ -26,20 +26,20 @@ import envoy.event.HandshakeRejectionEvent; public class LoginDialog extends JDialog { private final JPanel contentPanel; - private JTextField textField; - private JPasswordField passwordField; - private JPasswordField repeatPasswordField; + private JTextField textField; + private JPasswordField passwordField; + private JPasswordField repeatPasswordField; private JLabel lblUserName; private JLabel lblPassword; private JLabel lblRepeatPassword; - private JLabel errorMessage; - + private JLabel errorMessage; + private GridBagConstraints gbc_lblRepeatPassword; private GridBagConstraints gbc_repeatPasswordField; - private GridBagConstraints gbc_errorMessage; + private GridBagConstraints gbc_errorMessage; - private JPanel buttonPane; + private JPanel buttonPane; private JTextPane registerText; private JCheckBox registerCheckBox; private PrimaryButton okButton; @@ -48,6 +48,7 @@ public class LoginDialog extends JDialog { private LoginCredentials credentials; private static final long serialVersionUID = 352021600833907468L; + /** * Displays a dialog enabling the user to enter their user name and password. * @@ -68,7 +69,7 @@ public class LoginDialog extends JDialog { contentPanel.setLayout(gbl_contentPanel); { lblUserName = new JLabel("Username:"); - GridBagConstraints gbc_lblUserName = new GridBagConstraints(); + GridBagConstraints gbc_lblUserName = new GridBagConstraints(); gbc_lblUserName.anchor = GridBagConstraints.EAST; gbc_lblUserName.insets = new Insets(0, 0, 5, 5); gbc_lblUserName.gridx = 0; @@ -88,7 +89,7 @@ public class LoginDialog extends JDialog { } { lblPassword = new JLabel("Password:"); - GridBagConstraints gbc_lblPassword = new GridBagConstraints(); + GridBagConstraints gbc_lblPassword = new GridBagConstraints(); gbc_lblPassword.anchor = GridBagConstraints.EAST; gbc_lblPassword.insets = new Insets(0, 0, 0, 5); gbc_lblPassword.gridx = 0; @@ -124,8 +125,8 @@ public class LoginDialog extends JDialog { contentPanel.remove(errorMessage); clearPasswordFields(); // TODO delete - only for testing purposes - System.out.println("Caught HandshakeRejectionEvent with reason" + ((HandshakeRejectionEvent) evt).get()); - errorMessage = new JLabel(((HandshakeRejectionEvent) evt).get()); + System.out.println("Caught HandshakeRejectionEvent with reason" + evt.get()); + errorMessage = new JLabel(evt.get()); gbc_errorMessage = new GridBagConstraints(); gbc_errorMessage.gridx = 2; gbc_errorMessage.gridy = 0; @@ -201,11 +202,11 @@ public class LoginDialog extends JDialog { setModal(true); setVisible(true); - EventBus.getInstance().register(HandshakeSuccessfulEvent.class, evt -> this.dispose()); + EventBus.getInstance().register(HandshakeSuccessfulEvent.class, evt -> dispose()); } /** - * Resets the text stored by this + * Resets the text stored in the passwort fields. * * @since Envoy v0.3-alpha */ diff --git a/src/main/java/envoy/client/ui/MessageListRenderer.java b/src/main/java/envoy/client/ui/MessageListRenderer.java index 65ee63a..a069721 100644 --- a/src/main/java/envoy/client/ui/MessageListRenderer.java +++ b/src/main/java/envoy/client/ui/MessageListRenderer.java @@ -5,7 +5,7 @@ import java.text.SimpleDateFormat; import javax.swing.*; -import envoy.client.Settings; +import envoy.client.data.Settings; import envoy.client.ui.list.ComponentList; import envoy.client.ui.list.ComponentListCellRenderer; import envoy.data.Message; diff --git a/src/main/java/envoy/client/ui/PrimaryScrollBar.java b/src/main/java/envoy/client/ui/PrimaryScrollBar.java index a7cb8fc..8e8131c 100644 --- a/src/main/java/envoy/client/ui/PrimaryScrollBar.java +++ b/src/main/java/envoy/client/ui/PrimaryScrollBar.java @@ -12,7 +12,7 @@ import javax.swing.JComponent; import javax.swing.JScrollBar; import javax.swing.plaf.basic.BasicScrollBarUI; -import envoy.client.Settings; +import envoy.client.data.Settings; /** * Project: envoy-client
diff --git a/src/main/java/envoy/client/ui/PrimaryToggleSwitch.java b/src/main/java/envoy/client/ui/PrimaryToggleSwitch.java index 2882a05..3f58e2e 100644 --- a/src/main/java/envoy/client/ui/PrimaryToggleSwitch.java +++ b/src/main/java/envoy/client/ui/PrimaryToggleSwitch.java @@ -5,8 +5,8 @@ import java.awt.Graphics; import javax.swing.JButton; -import envoy.client.Settings; -import envoy.client.SettingsItem; +import envoy.client.data.Settings; +import envoy.client.data.SettingsItem; /** * This component can be used to toggle between two options. This will change diff --git a/src/main/java/envoy/client/ui/Startup.java b/src/main/java/envoy/client/ui/Startup.java index 24f6a9f..db55c53 100644 --- a/src/main/java/envoy/client/ui/Startup.java +++ b/src/main/java/envoy/client/ui/Startup.java @@ -11,7 +11,6 @@ import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; -import envoy.client.Settings; import envoy.client.data.*; import envoy.client.net.Client; import envoy.client.net.WriteProxy; @@ -79,7 +78,7 @@ public class Startup { LoginCredentials credentials = config.hasLoginCredentials() ? config.getLoginCredentials() : new LoginDialog().getCredentials(); if (credentials == null) { - logger.info("The login process has been aborted by the user. Exiting..."); + logger.info("The login process has been cancelled. Exiting..."); System.exit(0); } diff --git a/src/main/java/envoy/client/ui/UserListRenderer.java b/src/main/java/envoy/client/ui/UserListRenderer.java index 8c63ad7..c43eeb6 100644 --- a/src/main/java/envoy/client/ui/UserListRenderer.java +++ b/src/main/java/envoy/client/ui/UserListRenderer.java @@ -7,7 +7,7 @@ import javax.swing.JLabel; import javax.swing.JList; import javax.swing.ListCellRenderer; -import envoy.client.Settings; +import envoy.client.data.Settings; import envoy.data.User; import envoy.data.User.UserStatus; diff --git a/src/main/java/envoy/client/ui/settings/GeneralSettingsPanel.java b/src/main/java/envoy/client/ui/settings/GeneralSettingsPanel.java index adafc2e..a1b5966 100644 --- a/src/main/java/envoy/client/ui/settings/GeneralSettingsPanel.java +++ b/src/main/java/envoy/client/ui/settings/GeneralSettingsPanel.java @@ -10,8 +10,8 @@ import java.util.logging.Logger; import javax.swing.JComponent; import javax.swing.JTextPane; -import envoy.client.Settings; -import envoy.client.SettingsItem; +import envoy.client.data.Settings; +import envoy.client.data.SettingsItem; import envoy.client.ui.Theme; import envoy.client.util.EnvoyLog; diff --git a/src/main/java/envoy/client/ui/settings/NewThemeScreen.java b/src/main/java/envoy/client/ui/settings/NewThemeScreen.java index 3e259e4..02dd42a 100644 --- a/src/main/java/envoy/client/ui/settings/NewThemeScreen.java +++ b/src/main/java/envoy/client/ui/settings/NewThemeScreen.java @@ -7,7 +7,7 @@ import javax.swing.JDialog; import javax.swing.JPanel; import javax.swing.JTextPane; -import envoy.client.Settings; +import envoy.client.data.Settings; import envoy.client.ui.PrimaryButton; import envoy.client.ui.PrimaryTextArea; import envoy.client.ui.Theme; diff --git a/src/main/java/envoy/client/ui/settings/SettingsScreen.java b/src/main/java/envoy/client/ui/settings/SettingsScreen.java index af68e8e..df2fa2c 100644 --- a/src/main/java/envoy/client/ui/settings/SettingsScreen.java +++ b/src/main/java/envoy/client/ui/settings/SettingsScreen.java @@ -9,7 +9,7 @@ import java.util.logging.Logger; import javax.swing.*; -import envoy.client.Settings; +import envoy.client.data.Settings; import envoy.client.event.ThemeChangeEvent; import envoy.client.ui.PrimaryButton; import envoy.client.ui.Theme; diff --git a/src/main/java/envoy/client/ui/settings/ThemeCustomizationPanel.java b/src/main/java/envoy/client/ui/settings/ThemeCustomizationPanel.java index 8df3491..ed4be4f 100644 --- a/src/main/java/envoy/client/ui/settings/ThemeCustomizationPanel.java +++ b/src/main/java/envoy/client/ui/settings/ThemeCustomizationPanel.java @@ -9,7 +9,7 @@ import java.util.logging.Logger; import javax.swing.*; -import envoy.client.Settings; +import envoy.client.data.Settings; import envoy.client.event.ThemeChangeEvent; import envoy.client.ui.Color; import envoy.client.ui.Theme;