From 02baf70d92105a17e55a80c8445c30fa1049cf26 Mon Sep 17 00:00:00 2001 From: kske Date: Fri, 20 Dec 2019 12:36:53 +0100 Subject: [PATCH] Fixed errors caused by preparing the merge into develop --- src/main/java/envoy/client/ui/ChatWindow.java | 2 +- .../java/envoy/client/ui/SettingsScreen.java | 9 +------- src/main/java/envoy/client/ui/Startup.java | 23 ++++++++----------- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/main/java/envoy/client/ui/ChatWindow.java b/src/main/java/envoy/client/ui/ChatWindow.java index 378c990..8814195 100644 --- a/src/main/java/envoy/client/ui/ChatWindow.java +++ b/src/main/java/envoy/client/ui/ChatWindow.java @@ -170,7 +170,7 @@ public class ChatWindow extends JFrame { settingsButton.addActionListener((evt) -> { try { new SettingsScreen().setVisible(true); - changeChatWindowColors(Settings.getInstance().getCurrentTheme()); + changeChatWindowColors(Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme())); } catch (Exception e) { logger.log(Level.WARNING, "An error occured while opening the settings screen", e); e.printStackTrace(); diff --git a/src/main/java/envoy/client/ui/SettingsScreen.java b/src/main/java/envoy/client/ui/SettingsScreen.java index d659beb..75ce884 100644 --- a/src/main/java/envoy/client/ui/SettingsScreen.java +++ b/src/main/java/envoy/client/ui/SettingsScreen.java @@ -64,17 +64,10 @@ public class SettingsScreen extends JDialog { private static int space = 5; - private Theme temporaryTheme; + private Theme temporaryTheme, selectedTheme; private static final Logger logger = EnvoyLog.getLogger(SettingsScreen.class.getSimpleName()); - private static SettingsScreen settingsScreen; - - // 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) - /** * Builds the settings screen. * diff --git a/src/main/java/envoy/client/ui/Startup.java b/src/main/java/envoy/client/ui/Startup.java index 9b69cd8..b9f9633 100644 --- a/src/main/java/envoy/client/ui/Startup.java +++ b/src/main/java/envoy/client/ui/Startup.java @@ -2,6 +2,7 @@ package envoy.client.ui; import java.awt.EventQueue; import java.io.IOException; +import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JFrame; @@ -10,9 +11,7 @@ import javax.swing.JOptionPane; import envoy.client.Client; import envoy.client.Config; import envoy.client.LocalDB; -import envoy.client.Settings; import envoy.client.util.EnvoyLog; - import envoy.exception.EnvoyException; import envoy.schema.User; @@ -57,7 +56,7 @@ public class Startup { logger.severe("User name is not set or empty. Exiting..."); System.exit(1); } - + // Initialize the local database LocalDB localDB; try { @@ -81,19 +80,18 @@ public class Startup { // Try entering offline mode localDB.loadUsers(); User clientUser = localDB.getUsers().get(userName); - if(clientUser == null) - throw new EnvoyException("Could not enter offline mode: user name unknown"); + if (clientUser == null) throw new EnvoyException("Could not enter offline mode: user name unknown"); client.setSender(clientUser); - } catch(Exception e2) { + } catch (Exception e2) { JOptionPane.showMessageDialog(null, e2.toString(), "Client error", JOptionPane.ERROR_MESSAGE); System.exit(1); return; } } - + // Set client user in local database localDB.setUser(client.getSender()); - + // Initialize chats in local database try { localDB.initializeDBFile(); @@ -105,13 +103,12 @@ public class Startup { "Local DB error", JOptionPane.WARNING_MESSAGE); } - + logger.info("Client user ID: " + client.getSender().getID()); // Save all users to the local database - if(client.isOnline()) - localDB.setUsers(client.getUsers()); - + if (client.isOnline()) localDB.setUsers(client.getUsers()); + EventQueue.invokeLater(() -> { try { ChatWindow chatWindow = new ChatWindow(client, localDB); @@ -119,7 +116,7 @@ public class Startup { try { new StatusTrayIcon(chatWindow).show(); - + // If the tray icon is supported, hide the chat window on close chatWindow.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); } catch (EnvoyException e) {