From 3020125334a2496c42b484cd5c85919f3ca4ae0a Mon Sep 17 00:00:00 2001 From: DieGurke <55625494+DieGurke@users.noreply.github.com> Date: Mon, 23 Dec 2019 15:20:20 +0100 Subject: [PATCH] Removed ON OFF Text --- .../envoy/client/ui/PrimaryToggleSwitch.java | 9 +- .../envoy/client/ui/settings/General.java | 90 +++---------------- 2 files changed, 14 insertions(+), 85 deletions(-) diff --git a/src/main/java/envoy/client/ui/PrimaryToggleSwitch.java b/src/main/java/envoy/client/ui/PrimaryToggleSwitch.java index 58bc817..7319fe6 100644 --- a/src/main/java/envoy/client/ui/PrimaryToggleSwitch.java +++ b/src/main/java/envoy/client/ui/PrimaryToggleSwitch.java @@ -25,7 +25,7 @@ public class PrimaryToggleSwitch extends JPanel { private boolean currentState; - private static final long serialVersionUID = -721155303106833184L; + private static final long serialVersionUID = -721155303106833184L; /** * This is the constructor for the PrimaryToggleSwitch. @@ -57,12 +57,7 @@ public class PrimaryToggleSwitch extends JPanel { setState(settingsItem.get()); - b.addActionListener((evt) -> { - settingsItem.set(!currentState); - setState(!currentState); - revalidate(); - repaint(); - }); + b.addActionListener((evt) -> { settingsItem.set(!currentState); setState(!currentState); revalidate(); repaint(); }); repaint(); } diff --git a/src/main/java/envoy/client/ui/settings/General.java b/src/main/java/envoy/client/ui/settings/General.java index 3d09993..e4b5ae3 100644 --- a/src/main/java/envoy/client/ui/settings/General.java +++ b/src/main/java/envoy/client/ui/settings/General.java @@ -28,10 +28,8 @@ import envoy.client.util.EnvoyLog; */ public class General extends SettingsPanel { - private Theme theme; - private boolean onCloseState = Settings.getInstance().getCurrentOnCloseMode(); - private boolean enterToSend = Settings.getInstance().isEnterToSend(); - + private Theme theme; + private static final Logger logger = EnvoyLog.getLogger(General.class.getSimpleName()); private static final long serialVersionUID = -7470848775130754239L; @@ -48,55 +46,20 @@ public class General extends SettingsPanel { GridBagLayout gbl_general = new GridBagLayout(); gbl_general.columnWidths = new int[] { 1, 1 }; - gbl_general.rowHeights = new int[] { 1, 1, 1, 1, 1 }; + gbl_general.rowHeights = new int[] { 1, 1, 1 }; gbl_general.columnWeights = new double[] { 1.0, 0.1 }; - gbl_general.rowWeights = new double[] { 0.02, 0.0005, 0.02, 0.0005, 1.0 }; + gbl_general.rowWeights = new double[] { 0.02, 0.02, 1.0 }; setLayout(gbl_general); - - createSettingElement(0, - (SettingsItem) Settings.getInstance().getItems().get("onCloseMode")); - createSettingElement(2, - (SettingsItem) Settings.getInstance().getItems().get("enterToSend")); - } + createSettingElement(0, (SettingsItem) Settings.getInstance().getItems().get("onCloseMode")); - // TODO: Move ON / OFF text to PrimaryToggleswitch - - /** - * This method changes the on close mode of the client. - * - * @param state This is the integer that defines weather the toggleSwitch is on - * or off. - * @since Envoy v0.3-alpha - */ - public void changeOnClose(boolean state) { - this.onCloseState = state; - - //onCloseModeStatePane.setText(state ? "ON" : "OFF"); - revalidate(); - repaint(); - } - - /** - * This method changes the enter to send a message setting. - * - * @param state This is the integer that defines weather the toggleSwitch is on - * or off. - * @since Envoy v0.3-alpha - */ - public void changeEnterToSend(boolean state) { - this.enterToSend = state; - - //enterToSendStatePane.setText(state ? "ON" : "OFF"); - revalidate(); - repaint(); + createSettingElement(1, (SettingsItem) Settings.getInstance().getItems().get("enterToSend")); } private void createSettingElement(int gridy, SettingsItem settingsItem) { - JTextPane stateText = new JTextPane(); JTextPane descriptionText = new JTextPane(); - + PrimaryToggleSwitch toggleSwitch = new PrimaryToggleSwitch(settingsItem); GridBagConstraints gbc_toggleSwitch = new GridBagConstraints(); @@ -105,49 +68,20 @@ public class General extends SettingsPanel { add(toggleSwitch, gbc_toggleSwitch); - stateText.setText(settingsItem.get() ? "ON" : "OFF"); - stateText.setBackground(theme.getCellColor()); - stateText.setForeground(theme.getUserNameColor()); - stateText.setEditable(false); - - GridBagConstraints gbc_stateText = new GridBagConstraints(); - gbc_stateText.anchor = GridBagConstraints.NORTH; - gbc_stateText.gridx = 1; - gbc_stateText.gridy = gridy + 1; - - add(stateText, gbc_stateText); - descriptionText.setText(settingsItem.getDescription()); descriptionText.setBackground(theme.getBackgroundColor()); descriptionText.setForeground(theme.getBackgroundColor().invert()); descriptionText.setEditable(false); GridBagConstraints gbc_descriptionText = new GridBagConstraints(); - gbc_descriptionText.fill = GridBagConstraints.BOTH; - gbc_descriptionText.gridx = 0; - gbc_descriptionText.gridy = gridy; - gbc_descriptionText.gridheight = 2; - gbc_descriptionText.insets = new Insets(5, 5, 5, 5); + gbc_descriptionText.fill = GridBagConstraints.BOTH; + gbc_descriptionText.gridx = 0; + gbc_descriptionText.gridy = gridy; + gbc_descriptionText.insets = new Insets(5, 5, 5, 5); add(descriptionText, gbc_descriptionText); } @Override - public ActionListener getOkButtonAction() { - return (evt) -> { - if (onCloseState != Settings.getInstance().getCurrentOnCloseMode()) try { - Settings.getInstance().setCurrentOnCloseMode(onCloseState); - JOptionPane.showMessageDialog(null, "The changes will take effect the next time the program is started."); - } catch (Exception e) { - logger.log(Level.WARNING, "Close mode could not be changed! ", e); - } - - if (enterToSend != Settings.getInstance().isEnterToSend()) try { - Settings.getInstance().setEnterToSend(enterToSend); - JOptionPane.showMessageDialog(null, "The changes will take effect the next time the program is started."); - } catch (Exception e) { - logger.log(Level.WARNING, "Enter to send mode could not be changed! ", e); - } - }; - } + public ActionListener getOkButtonAction() { return null; } } \ No newline at end of file