From e367e5d57d88dbfbbf7e4d8eb8877a185aa99a7f Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R Date: Sat, 21 Dec 2019 07:54:15 +0100 Subject: [PATCH] Added custom import organization preferences Imports are converted to .* after 4 imports from the same package, static imports are converted to .* after 2 imports from the same type --- .settings/org.eclipse.jdt.ui.prefs | 5 +++ src/main/java/envoy/client/Settings.java | 7 +---- src/main/java/envoy/client/ui/ChatWindow.java | 23 ++------------ .../client/ui/settings/SettingsScreen.java | 31 ++++++++----------- .../ui/settings/ThemeCustomizationPanel.java | 28 ++++------------- 5 files changed, 28 insertions(+), 66 deletions(-) create mode 100644 .settings/org.eclipse.jdt.ui.prefs diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000..cdb456a --- /dev/null +++ b/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.ui.ignorelowercasenames=true +org.eclipse.jdt.ui.importorder=java;javax;org;com; +org.eclipse.jdt.ui.ondemandthreshold=4 +org.eclipse.jdt.ui.staticondemandthreshold=2 diff --git a/src/main/java/envoy/client/Settings.java b/src/main/java/envoy/client/Settings.java index 75a4355..d7e01de 100644 --- a/src/main/java/envoy/client/Settings.java +++ b/src/main/java/envoy/client/Settings.java @@ -1,12 +1,7 @@ package envoy.client; import java.awt.Color; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; +import java.io.*; import java.util.HashMap; import java.util.Map; import java.util.prefs.Preferences; diff --git a/src/main/java/envoy/client/ui/ChatWindow.java b/src/main/java/envoy/client/ui/ChatWindow.java index 8b1c60c..50b40bc 100644 --- a/src/main/java/envoy/client/ui/ChatWindow.java +++ b/src/main/java/envoy/client/ui/ChatWindow.java @@ -1,32 +1,15 @@ package envoy.client.ui; -import java.awt.ComponentOrientation; -import java.awt.Font; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.Toolkit; +import java.awt.*; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.util.logging.Level; import java.util.logging.Logger; -import javax.swing.DefaultListModel; -import javax.swing.JFrame; -import javax.swing.JList; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JTextPane; -import javax.swing.ListSelectionModel; -import javax.swing.SwingUtilities; -import javax.swing.Timer; +import javax.swing.*; import javax.swing.border.EmptyBorder; -import envoy.client.Chat; -import envoy.client.Client; -import envoy.client.Config; -import envoy.client.LocalDB; -import envoy.client.Settings; +import envoy.client.*; import envoy.client.event.EventBus; import envoy.client.event.ThemeChangeEvent; import envoy.client.ui.settings.SettingsScreen; diff --git a/src/main/java/envoy/client/ui/settings/SettingsScreen.java b/src/main/java/envoy/client/ui/settings/SettingsScreen.java index d34eee4..65cacac 100644 --- a/src/main/java/envoy/client/ui/settings/SettingsScreen.java +++ b/src/main/java/envoy/client/ui/settings/SettingsScreen.java @@ -1,22 +1,13 @@ package envoy.client.ui.settings; -import java.awt.BorderLayout; -import java.awt.Font; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; +import java.awt.*; import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; -import javax.swing.DefaultListModel; -import javax.swing.JButton; -import javax.swing.JDialog; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.ListSelectionModel; +import javax.swing.*; import envoy.client.Settings; import envoy.client.event.EventBus; @@ -50,7 +41,7 @@ public class SettingsScreen extends JDialog { private final JButton okButton = new JButton("Save"); private final JButton cancelButton = new JButton("Cancel"); - private final int space = 5; + private final Insets insets = new Insets(5, 5, 5, 5); private SettingsPanel settingsPanel; @@ -62,8 +53,7 @@ public class SettingsScreen extends JDialog { * @since Envoy v0.1-alpha */ public SettingsScreen() { - logger.info("Currently selected theme: " + Settings.getInstance().getCurrentTheme()); - + // Initialize settings pages Map> panels = new HashMap<>(); panels.put("Color Themes", ThemeCustomizationPanel.class); @@ -112,7 +102,7 @@ public class SettingsScreen extends JDialog { gbc_optionsList.gridx = 0; gbc_optionsList.gridy = 0; gbc_optionsList.anchor = GridBagConstraints.PAGE_START; - gbc_optionsList.insets = new Insets(space, space, space, space); + gbc_optionsList.insets = insets; panels.keySet().forEach(name -> optionsListModel.addElement(name)); contentPanel.add(options, gbc_optionsList); @@ -131,7 +121,7 @@ public class SettingsScreen extends JDialog { cancelButton.setBorderPainted(false); GridBagConstraints gbc_cancelButton = new GridBagConstraints(); gbc_cancelButton.anchor = GridBagConstraints.NORTHWEST; - gbc_cancelButton.insets = new Insets(space, space, space, space); + gbc_cancelButton.insets = insets; gbc_cancelButton.gridx = 0; gbc_cancelButton.gridy = 0; buttonPane.add(cancelButton, gbc_cancelButton); @@ -144,7 +134,7 @@ public class SettingsScreen extends JDialog { GridBagConstraints gbc_okButton = new GridBagConstraints(); gbc_okButton.anchor = GridBagConstraints.NORTHEAST; gbc_okButton.fill = GridBagConstraints.EAST; - gbc_okButton.insets = new Insets(space, space, space, space); + gbc_okButton.insets = insets; gbc_okButton.gridx = 2; gbc_okButton.gridy = 0; buttonPane.add(okButton, gbc_okButton); @@ -166,18 +156,23 @@ public class SettingsScreen extends JDialog { } private void applyTheme(Theme theme) { - // whole JDialog + // JDialog setBackground(theme.getBackgroundColor()); + // contentPanel contentPanel.setBackground(theme.getBackgroundColor()); + // buttonPane buttonPane.setBackground(theme.getCellColor()); + // cancelButton cancelButton.setBackground(theme.getInteractableBackgroundColor()); cancelButton.setForeground(theme.getInteractableForegroundColor()); + // okButton okButton.setBackground(theme.getInteractableBackgroundColor()); okButton.setForeground(theme.getInteractableForegroundColor()); + // options options.setSelectionForeground(theme.getUserNameColor()); options.setSelectionBackground(theme.getSelectionColor()); diff --git a/src/main/java/envoy/client/ui/settings/ThemeCustomizationPanel.java b/src/main/java/envoy/client/ui/settings/ThemeCustomizationPanel.java index 61e484b..ed9c5db 100644 --- a/src/main/java/envoy/client/ui/settings/ThemeCustomizationPanel.java +++ b/src/main/java/envoy/client/ui/settings/ThemeCustomizationPanel.java @@ -1,12 +1,6 @@ package envoy.client.ui.settings; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; +import java.awt.*; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; @@ -14,13 +8,7 @@ import java.util.Arrays; import java.util.logging.Level; import java.util.logging.Logger; -import javax.swing.BoxLayout; -import javax.swing.JButton; -import javax.swing.JColorChooser; -import javax.swing.JComboBox; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JTextPane; +import javax.swing.*; import envoy.client.Settings; import envoy.client.event.EventBus; @@ -119,15 +107,11 @@ public class ThemeCustomizationPanel extends SettingsPanel { createNewThemeButton.addActionListener((evt) -> { try { - String s = JOptionPane.showInputDialog("Enter a name for the new theme"); - logger.log(Level.FINEST, s); - Settings.getInstance() - .addNewThemeToMap(new Theme(s, temporaryTheme.getBackgroundColor(), temporaryTheme.getCellColor(), - temporaryTheme.getInteractableForegroundColor(), temporaryTheme.getInteractableBackgroundColor(), - temporaryTheme.getMessageColorChat(), temporaryTheme.getDateColorChat(), temporaryTheme.getSelectionColor(), - temporaryTheme.getTypingMessageColor(), temporaryTheme.getUserNameColor())); + String name = JOptionPane.showInputDialog("Enter a name for the new theme"); + logger.log(Level.FINEST, name); + Settings.getInstance().addNewThemeToMap(new Theme(name, temporaryTheme)); themeArray = Arrays.copyOf(themeArray, themeArray.length + 1); - themeArray[themeArray.length - 1] = Settings.getInstance().getThemes().get(s).getThemeName(); + themeArray[themeArray.length - 1] = Settings.getInstance().getThemes().get(name).getThemeName(); temporaryTheme = new Theme("temporaryTheme", Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()));