Clean-up, moved Settings and SettingsItem into the data package

This commit is contained in:
Kai S. K. Engelbart 2020-02-12 07:12:22 +01:00
parent 001b847155
commit 511146c98e
15 changed files with 31 additions and 32 deletions

View File

@ -1,4 +1,4 @@
package envoy.client; package envoy.client.data;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -6,7 +6,6 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.prefs.Preferences; import java.util.prefs.Preferences;
import envoy.client.data.Config;
import envoy.client.ui.Color; import envoy.client.ui.Color;
import envoy.client.ui.Theme; import envoy.client.ui.Theme;
import envoy.util.SerializationUtils; import envoy.util.SerializationUtils;

View File

@ -1,4 +1,4 @@
package envoy.client; package envoy.client.data;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;

View File

@ -12,7 +12,7 @@ import envoy.event.Event;
* @author Leon Hofmeister * @author Leon Hofmeister
* @since Envoy v0.3-alpha * @since Envoy v0.3-alpha
*/ */
public class HandshakeSuccessfulEvent implements Event<Void> { public class HandshakeSuccessfulEvent extends Event.Valueless {
private static final long serialVersionUID = -157972384126278855L; private static final long serialVersionUID = -157972384126278855L;
} }

View File

@ -12,9 +12,9 @@ import javax.swing.border.EmptyBorder;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import envoy.client.Settings;
import envoy.client.data.Chat; import envoy.client.data.Chat;
import envoy.client.data.LocalDb; import envoy.client.data.LocalDb;
import envoy.client.data.Settings;
import envoy.client.event.MessageCreationEvent; import envoy.client.event.MessageCreationEvent;
import envoy.client.event.ThemeChangeEvent; import envoy.client.event.ThemeChangeEvent;
import envoy.client.net.Client; import envoy.client.net.Client;

View File

@ -6,7 +6,7 @@ import java.awt.Font;
import javax.swing.*; import javax.swing.*;
import envoy.client.Settings; import envoy.client.data.Settings;
import envoy.client.event.SendEvent; import envoy.client.event.SendEvent;
import envoy.client.ui.list.ComponentList; import envoy.client.ui.list.ComponentList;
import envoy.client.ui.list.ComponentListCellRenderer; import envoy.client.ui.list.ComponentListCellRenderer;

View File

@ -8,8 +8,8 @@ import java.util.Arrays;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import envoy.client.data.Settings;
import envoy.client.event.HandshakeSuccessfulEvent; import envoy.client.event.HandshakeSuccessfulEvent;
import envoy.client.Settings;
import envoy.data.LoginCredentials; import envoy.data.LoginCredentials;
import envoy.event.EventBus; import envoy.event.EventBus;
import envoy.event.HandshakeRejectionEvent; import envoy.event.HandshakeRejectionEvent;
@ -26,20 +26,20 @@ import envoy.event.HandshakeRejectionEvent;
public class LoginDialog extends JDialog { public class LoginDialog extends JDialog {
private final JPanel contentPanel; private final JPanel contentPanel;
private JTextField textField; private JTextField textField;
private JPasswordField passwordField; private JPasswordField passwordField;
private JPasswordField repeatPasswordField; private JPasswordField repeatPasswordField;
private JLabel lblUserName; private JLabel lblUserName;
private JLabel lblPassword; private JLabel lblPassword;
private JLabel lblRepeatPassword; private JLabel lblRepeatPassword;
private JLabel errorMessage; private JLabel errorMessage;
private GridBagConstraints gbc_lblRepeatPassword; private GridBagConstraints gbc_lblRepeatPassword;
private GridBagConstraints gbc_repeatPasswordField; private GridBagConstraints gbc_repeatPasswordField;
private GridBagConstraints gbc_errorMessage; private GridBagConstraints gbc_errorMessage;
private JPanel buttonPane; private JPanel buttonPane;
private JTextPane registerText; private JTextPane registerText;
private JCheckBox registerCheckBox; private JCheckBox registerCheckBox;
private PrimaryButton okButton; private PrimaryButton okButton;
@ -48,6 +48,7 @@ public class LoginDialog extends JDialog {
private LoginCredentials credentials; private LoginCredentials credentials;
private static final long serialVersionUID = 352021600833907468L; private static final long serialVersionUID = 352021600833907468L;
/** /**
* Displays a dialog enabling the user to enter their user name and password. * 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); contentPanel.setLayout(gbl_contentPanel);
{ {
lblUserName = new JLabel("Username:"); lblUserName = new JLabel("Username:");
GridBagConstraints gbc_lblUserName = new GridBagConstraints(); GridBagConstraints gbc_lblUserName = new GridBagConstraints();
gbc_lblUserName.anchor = GridBagConstraints.EAST; gbc_lblUserName.anchor = GridBagConstraints.EAST;
gbc_lblUserName.insets = new Insets(0, 0, 5, 5); gbc_lblUserName.insets = new Insets(0, 0, 5, 5);
gbc_lblUserName.gridx = 0; gbc_lblUserName.gridx = 0;
@ -88,7 +89,7 @@ public class LoginDialog extends JDialog {
} }
{ {
lblPassword = new JLabel("Password:"); lblPassword = new JLabel("Password:");
GridBagConstraints gbc_lblPassword = new GridBagConstraints(); GridBagConstraints gbc_lblPassword = new GridBagConstraints();
gbc_lblPassword.anchor = GridBagConstraints.EAST; gbc_lblPassword.anchor = GridBagConstraints.EAST;
gbc_lblPassword.insets = new Insets(0, 0, 0, 5); gbc_lblPassword.insets = new Insets(0, 0, 0, 5);
gbc_lblPassword.gridx = 0; gbc_lblPassword.gridx = 0;
@ -124,8 +125,8 @@ public class LoginDialog extends JDialog {
contentPanel.remove(errorMessage); contentPanel.remove(errorMessage);
clearPasswordFields(); clearPasswordFields();
// TODO delete - only for testing purposes // TODO delete - only for testing purposes
System.out.println("Caught HandshakeRejectionEvent with reason" + ((HandshakeRejectionEvent) evt).get()); System.out.println("Caught HandshakeRejectionEvent with reason" + evt.get());
errorMessage = new JLabel(((HandshakeRejectionEvent) evt).get()); errorMessage = new JLabel(evt.get());
gbc_errorMessage = new GridBagConstraints(); gbc_errorMessage = new GridBagConstraints();
gbc_errorMessage.gridx = 2; gbc_errorMessage.gridx = 2;
gbc_errorMessage.gridy = 0; gbc_errorMessage.gridy = 0;
@ -201,11 +202,11 @@ public class LoginDialog extends JDialog {
setModal(true); setModal(true);
setVisible(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 * @since Envoy v0.3-alpha
*/ */

View File

@ -5,7 +5,7 @@ import java.text.SimpleDateFormat;
import javax.swing.*; import javax.swing.*;
import envoy.client.Settings; import envoy.client.data.Settings;
import envoy.client.ui.list.ComponentList; import envoy.client.ui.list.ComponentList;
import envoy.client.ui.list.ComponentListCellRenderer; import envoy.client.ui.list.ComponentListCellRenderer;
import envoy.data.Message; import envoy.data.Message;

View File

@ -12,7 +12,7 @@ import javax.swing.JComponent;
import javax.swing.JScrollBar; import javax.swing.JScrollBar;
import javax.swing.plaf.basic.BasicScrollBarUI; import javax.swing.plaf.basic.BasicScrollBarUI;
import envoy.client.Settings; import envoy.client.data.Settings;
/** /**
* Project: <strong>envoy-client</strong><br> * Project: <strong>envoy-client</strong><br>

View File

@ -5,8 +5,8 @@ import java.awt.Graphics;
import javax.swing.JButton; import javax.swing.JButton;
import envoy.client.Settings; import envoy.client.data.Settings;
import envoy.client.SettingsItem; import envoy.client.data.SettingsItem;
/** /**
* This component can be used to toggle between two options. This will change * This component can be used to toggle between two options. This will change

View File

@ -11,7 +11,6 @@ import javax.swing.JFrame;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import envoy.client.Settings;
import envoy.client.data.*; import envoy.client.data.*;
import envoy.client.net.Client; import envoy.client.net.Client;
import envoy.client.net.WriteProxy; import envoy.client.net.WriteProxy;
@ -79,7 +78,7 @@ public class Startup {
LoginCredentials credentials = config.hasLoginCredentials() ? config.getLoginCredentials() : new LoginDialog().getCredentials(); LoginCredentials credentials = config.hasLoginCredentials() ? config.getLoginCredentials() : new LoginDialog().getCredentials();
if (credentials == null) { 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); System.exit(0);
} }

View File

@ -7,7 +7,7 @@ import javax.swing.JLabel;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.ListCellRenderer; import javax.swing.ListCellRenderer;
import envoy.client.Settings; import envoy.client.data.Settings;
import envoy.data.User; import envoy.data.User;
import envoy.data.User.UserStatus; import envoy.data.User.UserStatus;

View File

@ -10,8 +10,8 @@ import java.util.logging.Logger;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JTextPane; import javax.swing.JTextPane;
import envoy.client.Settings; import envoy.client.data.Settings;
import envoy.client.SettingsItem; import envoy.client.data.SettingsItem;
import envoy.client.ui.Theme; import envoy.client.ui.Theme;
import envoy.client.util.EnvoyLog; import envoy.client.util.EnvoyLog;

View File

@ -7,7 +7,7 @@ import javax.swing.JDialog;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JTextPane; import javax.swing.JTextPane;
import envoy.client.Settings; import envoy.client.data.Settings;
import envoy.client.ui.PrimaryButton; import envoy.client.ui.PrimaryButton;
import envoy.client.ui.PrimaryTextArea; import envoy.client.ui.PrimaryTextArea;
import envoy.client.ui.Theme; import envoy.client.ui.Theme;

View File

@ -9,7 +9,7 @@ import java.util.logging.Logger;
import javax.swing.*; import javax.swing.*;
import envoy.client.Settings; import envoy.client.data.Settings;
import envoy.client.event.ThemeChangeEvent; import envoy.client.event.ThemeChangeEvent;
import envoy.client.ui.PrimaryButton; import envoy.client.ui.PrimaryButton;
import envoy.client.ui.Theme; import envoy.client.ui.Theme;

View File

@ -9,7 +9,7 @@ import java.util.logging.Logger;
import javax.swing.*; import javax.swing.*;
import envoy.client.Settings; import envoy.client.data.Settings;
import envoy.client.event.ThemeChangeEvent; import envoy.client.event.ThemeChangeEvent;
import envoy.client.ui.Color; import envoy.client.ui.Color;
import envoy.client.ui.Theme; import envoy.client.ui.Theme;