%s
%s :%s",
+ date,
+ text,
+ state));
+ return this;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/envoy/client/ui/SettingsScreen.java b/src/main/java/envoy/client/ui/SettingsScreen.java
new file mode 100644
index 0000000..7d5de28
--- /dev/null
+++ b/src/main/java/envoy/client/ui/SettingsScreen.java
@@ -0,0 +1,156 @@
+package envoy.client.ui;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.FlowLayout;
+
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JPanel;
+import javax.swing.border.EmptyBorder;
+
+/**
+ * Project: envoy-client %s %s",
+ status,
+ name));
+ break;
+
+ case OFFLINE:
+ setText(String.format(
+ " %s %s",
+ status,
+ name));
+ break;
+ }
+
+
+
+ return this;
+ }
+}
\ No newline at end of file
diff --git a/src/main/resources/client.properties b/src/main/resources/client.properties
new file mode 100644
index 0000000..2641927
--- /dev/null
+++ b/src/main/resources/client.properties
@@ -0,0 +1,3 @@
+server=http://kske.feste-ip.net
+port=43315
+localDB=.\\localDB
+ * File: SettingsScreen.java
+ * Created: 31 Oct 2019
+ *
+ * @author Leon Hofmeister
+ */
+public class SettingsScreen extends JDialog {
+
+ private static final long serialVersionUID = -4476913491263077107L;
+ private final JPanel contentPanel = new JPanel();
+ public static boolean enterToSend = true;
+
+ // TODO: Add a JPanel with all the Information necessary:
+ // change (Picture,Username, Email, Password) and toggle(light/dark mode,
+ // "ctrl+enter"/"enter"
+ // to send a message directly)
+ /**
+ * Open the Settings screen.
+ * Only suited for Dev/Error mode.
+ * Avoid usage.
+ *
+ * @since Envoy v0.1-alpha
+ */
+ public static void open() { open(new SettingsScreen()); }
+
+ /**
+ * Opens the Settings screen.
+ * Use preferably since everyone is already initialised.
+ * It personalises the screen more.
+ *
+ * @param username The name of the User
+ * @param Email The Email that is associated with that Account
+ * @since Envoy v0.1-alpha
+ */
+ public static void open(String username) {// , String Email) {AUSKLAMMERN, WENN ANMELDUNG PER
+ // EMAIL IMPLEMENTIERT IST!
+ open(new SettingsScreen(username));
+ }
+
+ public static void open(SettingsScreen dialog) {
+ dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
+ dialog.setModal(true);
+ dialog.setVisible(true);
+ }
+
+ /**
+ * Builds the Settings screen.
+ * Use only as Dev/Error Mode.
+ * Avoid usage.
+ *
+ * @since Envoy v0.1-alpha
+ */
+ public SettingsScreen() {
+ setBackground(Color.BLACK);
+ setBounds(100, 100, 450, 300);
+ getContentPane().setLayout(new BorderLayout());
+ contentPanel.setBackground(Color.BLACK);
+ contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
+ getContentPane().add(contentPanel, BorderLayout.CENTER);
+ contentPanel.setLayout(new BorderLayout(0, 0));
+ {
+ JPanel buttonPane = new JPanel();
+ buttonPane.setBackground(Color.BLACK);
+ getContentPane().add(buttonPane, BorderLayout.SOUTH);
+ buttonPane.setLayout(new BorderLayout(0, 0));
+ {
+ JButton okButton = new JButton("Save");
+ okButton.setActionCommand("OK");
+ buttonPane.add(okButton, BorderLayout.EAST);
+ getRootPane().setDefaultButton(okButton);
+ okButton.addActionListener((evt) -> {
+ // Hier später die Daten abspeichern, wenn Datenmodell implementiert ist
+ dispose();
+ });
+ }
+ {
+ JButton cancelButton = new JButton("Cancel");
+ cancelButton.setActionCommand("Cancel");
+ buttonPane.add(cancelButton, BorderLayout.WEST);
+
+ cancelButton.addActionListener((evt) -> { dispose(); });
+ }
+ }
+ }
+
+ /**
+ * Builds the Settings screen.
+ * Use preferreably since everyone is already initialised.
+ * It personalises the screen more.
+ *
+ * @param Username The name of the User
+ * @param Email The Email that is associated with that Account
+ * @since Envoy v0.1-alpha
+ */
+ public SettingsScreen(String Username) {// , String Email, String hashedPwd) {AUSKLAMMERN, WENN ANMELDUNG PER EMAIL
+ // IMPLEMENTIERT IST!
+ setBackground(Color.BLACK);
+ setBounds(100, 100, 450, 300);
+ getContentPane().setLayout(new BorderLayout());
+ contentPanel.setBackground(Color.BLACK);
+ contentPanel.setLayout(new FlowLayout());
+ contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
+ getContentPane().add(contentPanel, BorderLayout.CENTER);
+ {
+ JPanel buttonPane = new JPanel();
+ buttonPane.setBackground(Color.BLACK);
+ getContentPane().add(buttonPane, BorderLayout.SOUTH);
+ buttonPane.setLayout(new BorderLayout(0, 0));
+ {
+ JButton okButton = new JButton("Save");
+ okButton.setActionCommand("OK");
+ buttonPane.add(okButton, BorderLayout.EAST);
+ getRootPane().setDefaultButton(okButton);
+ okButton.addActionListener((evt) -> {
+ // Hier später die Daten abspeichern, wenn Datenmodell implementiert ist
+ dispose();
+ });
+ }
+ {
+ JButton cancelButton = new JButton("Cancel");
+ cancelButton.setActionCommand("Cancel");
+ buttonPane.add(cancelButton, BorderLayout.WEST);
+
+ cancelButton.addActionListener((evt) -> { dispose(); });
+ }
+ }
+ }
+
+ /**
+ * @return true if Enter should be used to send a message instead of ctrl+enter
+ * @since Envoy v0.1-alpha
+ */
+ public static boolean isEnterToSend() { return enterToSend; }
+
+ /**
+ * @param enterToSend
+ * toggles whether a message should be sent via
+ *
+ * buttonpress "enter" or "ctrl"+"enter"
+ * @since Envoy v0.1-alpha
+ */
+ public static void setEnterToSend(boolean enterForSend) { enterToSend = enterForSend; }
+ // TODO: Should be changed to private, but later to avoid warnings
+}
diff --git a/src/main/java/envoy/client/ui/Startup.java b/src/main/java/envoy/client/ui/Startup.java
new file mode 100644
index 0000000..c3a3baa
--- /dev/null
+++ b/src/main/java/envoy/client/ui/Startup.java
@@ -0,0 +1,73 @@
+package envoy.client.ui;
+
+import java.awt.EventQueue;
+import java.io.IOException;
+import java.util.Properties;
+
+import javax.swing.JOptionPane;
+
+import envoy.client.Client;
+import envoy.client.Config;
+import envoy.client.LocalDB;
+import envoy.exception.EnvoyException;
+
+/**
+ * Starts the Envoy client and prompts the user to enter their name.
+ *
+ * Project: envoy-client
+ * File: Startup.java
+ * Created: 12 Oct 2019
+ *
+ * @author Leon Hofmeister
+ * @author Maximilian Käfer
+ * @since Envoy v0.1-alpha
+ */
+public class Startup {
+
+ public static void main(String[] args) {
+ Config config = Config.getInstance();
+ if (args.length > 0) {
+ config.load(args);
+ } else {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ try {
+ Properties configProperties = new Properties();
+ configProperties.load(loader.getResourceAsStream("client.properties"));
+ config.load(configProperties);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ if (!config.isInitialized()) {
+ System.err.println("Server or port are not defined. Exiting...");
+ System.exit(1);
+ }
+
+ String userName = JOptionPane.showInputDialog("Please enter your username");
+ if (userName == null || userName.isEmpty()) {
+ System.err.println("User name is not set or empty. Exiting...");
+ System.exit(1);
+ }
+ Client client = new Client(config, userName);
+ LocalDB localDB = new LocalDB(client.getSender());
+ try {
+ localDB.initializeDBFile(config.getLocalDB());
+ } catch (EnvoyException e) {
+ e.printStackTrace();
+ JOptionPane.showMessageDialog(null,
+ "Error while loading local database: " + e.toString() + "\nChats will not be stored locally.",
+ "Local DB error",
+ JOptionPane.WARNING_MESSAGE);
+ }
+
+ EventQueue.invokeLater(() -> {
+ try {
+ ChatWindow frame = new ChatWindow(client, localDB);
+ frame.setVisible(true);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/envoy/client/ui/UserListRenderer.java b/src/main/java/envoy/client/ui/UserListRenderer.java
new file mode 100644
index 0000000..40bb2ad
--- /dev/null
+++ b/src/main/java/envoy/client/ui/UserListRenderer.java
@@ -0,0 +1,65 @@
+package envoy.client.ui;
+
+import java.awt.Component;
+
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.ListCellRenderer;
+
+import envoy.schema.User;
+import envoy.schema.User.UserStatus;
+
+/**
+ * Defines how the {@code UserList} is displayed.
+ *
+ * Project: envoy-client
+ * File: UserListRenderer.java
+ * Created: 12 Oct 2019
+ *
+ * @author Kai S. K. Engelbart
+ * @author Maximilian Käfer
+ * @since Envoy v0.1-alpha
+ */
+public class UserListRenderer extends JLabel implements ListCellRenderer