From f85383f6dddaae3409902bf489d52dd7b01b0987 Mon Sep 17 00:00:00 2001 From: SammyIAm Date: Tue, 1 May 2018 23:14:23 -0700 Subject: [PATCH] Attach Script names to enums, better defaults resolves #4 --- .../com/moppy/control/config/MoppyConfig.java | 8 ++++---- .../control/gui/mapperpanel/MapperPanel.java | 18 ++++++++--------- .../mapper/scripts/ConditionScripts.java | 20 ++++++++++++------- .../mapper/scripts/DeviceAddressScripts.java | 18 +++++++++++------ .../events/mapper/scripts/NoteScripts.java | 20 ++++++++++++------- .../mapper/scripts/SubAddressScripts.java | 16 ++++++++++----- 6 files changed, 62 insertions(+), 38 deletions(-) diff --git a/Java/MoppyControlGUI/src/main/java/com/moppy/control/config/MoppyConfig.java b/Java/MoppyControlGUI/src/main/java/com/moppy/control/config/MoppyConfig.java index 519bc80..e699112 100644 --- a/Java/MoppyControlGUI/src/main/java/com/moppy/control/config/MoppyConfig.java +++ b/Java/MoppyControlGUI/src/main/java/com/moppy/control/config/MoppyConfig.java @@ -18,13 +18,13 @@ public class MoppyConfig { @Data public static class MIDIScriptMapperConfig { - private String conditionChoice = "Custom"; + private String conditionChoice = ConditionScripts.ALL_EVENTS.displayName(); private String conditionCustomScript = ConditionScripts.ALL_EVENTS.toString(); - private String deviceAddressChoice = "Custom"; + private String deviceAddressChoice = DeviceAddressScripts.DEVICE_ONE.displayName(); private String deviceAddressCustomScript = DeviceAddressScripts.DEVICE_ONE.toString(); - private String subAddressChoice = "Custom"; + private String subAddressChoice = SubAddressScripts.SUB_ADDRESS_PER_CHANNEL.displayName(); private String subAddressCustomScript = SubAddressScripts.SUB_ADDRESS_PER_CHANNEL.toString(); - private String noteChoice = "Custom"; + private String noteChoice = NoteScripts.STRAIGHT_THROUGH.displayName(); private String noteCustomScript = NoteScripts.STRAIGHT_THROUGH.toString(); } } diff --git a/Java/MoppyControlGUI/src/main/java/com/moppy/control/gui/mapperpanel/MapperPanel.java b/Java/MoppyControlGUI/src/main/java/com/moppy/control/gui/mapperpanel/MapperPanel.java index 72e6f05..1744272 100644 --- a/Java/MoppyControlGUI/src/main/java/com/moppy/control/gui/mapperpanel/MapperPanel.java +++ b/Java/MoppyControlGUI/src/main/java/com/moppy/control/gui/mapperpanel/MapperPanel.java @@ -30,21 +30,21 @@ public class MapperPanel extends javax.swing.JPanel { private static final Map NOTE_MAP = new HashMap<>(); static { - CONDITION_MAP.put("All Events", ConditionScripts.ALL_EVENTS.toString()); - CONDITION_MAP.put("Channels 1-4", ConditionScripts.CHANNELS_ONE_TO_FOUR.toString()); - CONDITION_MAP.put("Only Supported Notes", ConditionScripts.ONLY_SUPPORTED_NOTES.toString()); + CONDITION_MAP.put(ConditionScripts.ALL_EVENTS.displayName(), ConditionScripts.ALL_EVENTS.toString()); + CONDITION_MAP.put(ConditionScripts.CHANNELS_ONE_TO_FOUR.displayName(), ConditionScripts.CHANNELS_ONE_TO_FOUR.toString()); + CONDITION_MAP.put(ConditionScripts.ONLY_SUPPORTED_NOTES.displayName(), ConditionScripts.ONLY_SUPPORTED_NOTES.toString()); CONDITION_MAP.put("Custom", ""); - DEVICEADDRESS_MAP.put("Device 1", DeviceAddressScripts.DEVICE_ONE.toString()); - DEVICEADDRESS_MAP.put("One Device per Channel", DeviceAddressScripts.ONE_DEVICE_PER_CHANNEL.toString()); + DEVICEADDRESS_MAP.put(DeviceAddressScripts.DEVICE_ONE.displayName(), DeviceAddressScripts.DEVICE_ONE.toString()); + DEVICEADDRESS_MAP.put(DeviceAddressScripts.ONE_DEVICE_PER_CHANNEL.displayName(), DeviceAddressScripts.ONE_DEVICE_PER_CHANNEL.toString()); DEVICEADDRESS_MAP.put("Custom", ""); - SUBADDRESS_MAP.put("Sub Address per Channel", SubAddressScripts.SUB_ADDRESS_PER_CHANNEL.toString()); + SUBADDRESS_MAP.put(SubAddressScripts.SUB_ADDRESS_PER_CHANNEL.displayName(), SubAddressScripts.SUB_ADDRESS_PER_CHANNEL.toString()); SUBADDRESS_MAP.put("Custom", ""); - NOTE_MAP.put("Force Into Range", NoteScripts.FORCE_INTO_RANGE.toString()); - NOTE_MAP.put("Ignore out of Range", NoteScripts.IGNORE_OUT_OF_RANGE.toString()); - NOTE_MAP.put("Straight Through", NoteScripts.STRAIGHT_THROUGH.toString()); + NOTE_MAP.put(NoteScripts.FORCE_INTO_RANGE.displayName(), NoteScripts.FORCE_INTO_RANGE.toString()); + NOTE_MAP.put(NoteScripts.IGNORE_OUT_OF_RANGE.displayName(), NoteScripts.IGNORE_OUT_OF_RANGE.toString()); + NOTE_MAP.put(NoteScripts.STRAIGHT_THROUGH.displayName(), NoteScripts.STRAIGHT_THROUGH.toString()); NOTE_MAP.put("Custom", ""); } diff --git a/Java/MoppyLib/src/main/java/com/moppy/core/events/mapper/scripts/ConditionScripts.java b/Java/MoppyLib/src/main/java/com/moppy/core/events/mapper/scripts/ConditionScripts.java index 1f84a6d..ef94116 100644 --- a/Java/MoppyLib/src/main/java/com/moppy/core/events/mapper/scripts/ConditionScripts.java +++ b/Java/MoppyLib/src/main/java/com/moppy/core/events/mapper/scripts/ConditionScripts.java @@ -4,14 +4,16 @@ * */ public enum ConditionScripts { - - ALL_EVENTS("true"), - CHANNELS_ONE_TO_FOUR("c>=1 && c<=4"), - ONLY_SUPPORTED_NOTES("n>22 && n<67"); - - private final String script; - private ConditionScripts(String s) { + ALL_EVENTS("All Events", "true"), + CHANNELS_ONE_TO_FOUR("Channels 1-4", "c>=1 && c<=4"), + ONLY_SUPPORTED_NOTES("Only Supported Notes", "n>22 && n<67"); + + private final String displayName; + private final String script; + + private ConditionScripts(String d, String s) { + displayName = d; script = s; } @@ -19,4 +21,8 @@ private ConditionScripts(String s) { public String toString() { return this.script; } + + public String displayName() { + return this.displayName; + } } diff --git a/Java/MoppyLib/src/main/java/com/moppy/core/events/mapper/scripts/DeviceAddressScripts.java b/Java/MoppyLib/src/main/java/com/moppy/core/events/mapper/scripts/DeviceAddressScripts.java index facfe14..d6444b4 100644 --- a/Java/MoppyLib/src/main/java/com/moppy/core/events/mapper/scripts/DeviceAddressScripts.java +++ b/Java/MoppyLib/src/main/java/com/moppy/core/events/mapper/scripts/DeviceAddressScripts.java @@ -4,13 +4,15 @@ * */ public enum DeviceAddressScripts { - - DEVICE_ONE("1"), - ONE_DEVICE_PER_CHANNEL("c+1"); - - private final String script; - private DeviceAddressScripts(String s) { + DEVICE_ONE("Device 1", "1"), + ONE_DEVICE_PER_CHANNEL("One Device per Channel", "c+1"); + + private final String displayName; + private final String script; + + private DeviceAddressScripts(String d, String s) { + displayName = d; script = s; } @@ -18,4 +20,8 @@ private DeviceAddressScripts(String s) { public String toString() { return this.script; } + + public String displayName() { + return this.displayName; + } } diff --git a/Java/MoppyLib/src/main/java/com/moppy/core/events/mapper/scripts/NoteScripts.java b/Java/MoppyLib/src/main/java/com/moppy/core/events/mapper/scripts/NoteScripts.java index dad0dd4..516ae3a 100644 --- a/Java/MoppyLib/src/main/java/com/moppy/core/events/mapper/scripts/NoteScripts.java +++ b/Java/MoppyLib/src/main/java/com/moppy/core/events/mapper/scripts/NoteScripts.java @@ -4,14 +4,16 @@ * */ public enum NoteScripts { - - STRAIGHT_THROUGH("n"), - IGNORE_OUT_OF_RANGE("(n>22 && n<67) ? n : null"), - FORCE_INTO_RANGE("((n-22)%48)+22"); - - private final String script; - private NoteScripts(String s) { + STRAIGHT_THROUGH("Straight Through", "n"), + IGNORE_OUT_OF_RANGE("Ignore out of Range", "(n>22 && n<67) ? n : null"), + FORCE_INTO_RANGE("Force into Range", "((n-22)%48)+22"); + + private final String displayName; + private final String script; + + private NoteScripts(String d, String s) { + displayName = d; script = s; } @@ -19,4 +21,8 @@ private NoteScripts(String s) { public String toString() { return this.script; } + + public String displayName() { + return this.displayName; + } } diff --git a/Java/MoppyLib/src/main/java/com/moppy/core/events/mapper/scripts/SubAddressScripts.java b/Java/MoppyLib/src/main/java/com/moppy/core/events/mapper/scripts/SubAddressScripts.java index 19ee246..67dc2bd 100644 --- a/Java/MoppyLib/src/main/java/com/moppy/core/events/mapper/scripts/SubAddressScripts.java +++ b/Java/MoppyLib/src/main/java/com/moppy/core/events/mapper/scripts/SubAddressScripts.java @@ -4,12 +4,14 @@ * */ public enum SubAddressScripts { - - SUB_ADDRESS_PER_CHANNEL("c+1"); - - private final String script; - private SubAddressScripts(String s) { + SUB_ADDRESS_PER_CHANNEL("Sub-address per Channel", "c+1"); + + private final String displayName; + private final String script; + + private SubAddressScripts(String d, String s) { + displayName = d; script = s; } @@ -17,4 +19,8 @@ private SubAddressScripts(String s) { public String toString() { return this.script; } + + public String displayName() { + return this.displayName; + } }