From 2148b7f79f7ff1d3bbeea7fc6d1ca1f94dffe2f4 Mon Sep 17 00:00:00 2001 From: Leo40Git Date: Fri, 27 Apr 2018 19:13:25 +0300 Subject: [PATCH] Hotfix 1.0.3 --- .version | 6 +++- src/main/java/com/leo/orgadder/Main.java | 2 +- src/main/java/com/leo/orgadder/MainAL.java | 41 ++++++++++++++-------- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/.version b/.version index fbdffad..823f3ae 100644 --- a/.version +++ b/.version @@ -1,4 +1,8 @@ -1.0.2 +1.0.3 +Hotfix 1.0.3 +- Disallow empty ORG names +- Fix "Save EXE As..." not working +- Add IDs next to ORG names Hotfix 1.0.2 - App is no longer confused about what it is - Fix error when adding/editing ORGs diff --git a/src/main/java/com/leo/orgadder/Main.java b/src/main/java/com/leo/orgadder/Main.java index cff49b3..0d78f90 100644 --- a/src/main/java/com/leo/orgadder/Main.java +++ b/src/main/java/com/leo/orgadder/Main.java @@ -50,7 +50,7 @@ public class Main { public static final Logger LOGGER = LogManager.getLogger("OrgAdder"); - public static final Version VERSION = new Version("1.0.2"); + public static final Version VERSION = new Version("1.0.3"); public static final String UPDATE_CHECK_SITE = "https://raw.githubusercontent.com/Leo40Git/OrgAdder/master/.version"; public static final String DOWNLOAD_SITE = "https://github.com/Leo40Git/OrgAdder/releases/latest/"; public static final String ISSUES_SITE = "https://github.com/Leo40Git/OrgAdder/issues"; diff --git a/src/main/java/com/leo/orgadder/MainAL.java b/src/main/java/com/leo/orgadder/MainAL.java index cf0e571..07e3372 100644 --- a/src/main/java/com/leo/orgadder/MainAL.java +++ b/src/main/java/com/leo/orgadder/MainAL.java @@ -164,7 +164,10 @@ public static boolean loadOrgList() { JOptionPane.INFORMATION_MESSAGE); } else modified = false; - orgList = new LinkedList<>(ONTHandler.getOrgNames()); + Vector orgNames = ONTHandler.getOrgNames(); + orgList = new LinkedList<>(); + for (int i = 0; i < orgNames.size(); i++) + orgList.add(num2TSCParam(i) + " - " + orgNames.get(i)); createOrgListModel(); orgListComp.setEnabled(true); orgListComp.setSelectedValue(MainAL.orgList.get(0), true); @@ -177,9 +180,8 @@ public static boolean loadOrgList() { public static boolean saveOrgListAs() { File saveFile = DialogUtil.openFileDialog(true, window, "Save EXE", FF_EXE, srcFile); if (saveFile == null) - if (srcFile == null) - return true; - saveFile = srcFile; + return true; + srcFile = saveFile; return saveOrgList0(); } @@ -193,7 +195,7 @@ private static boolean saveOrgList0() { Vector orgNames = ONTHandler.getOrgNames(); orgNames.clear(); for (String name : orgList) - orgNames.add(name); + orgNames.add(name.substring(7)); byte[] b = ONTHandler.write(peData); try { FileOutputStream oStream = new FileOutputStream(srcFile); @@ -208,6 +210,16 @@ private static boolean saveOrgList0() { modified = false; return true; } + + public static String num2TSCParam(long p) { + String ret = ""; + for (int j = 0; j < 3; j++) { + ret = (char) ('0' + p % 10) + ret; + p /= 10; + } + ret = (char) ('0' + p) + ret; + return ret; + } @Override public void actionPerformed(ActionEvent ae) { @@ -247,11 +259,11 @@ public void actionPerformed(ActionEvent ae) { break; case AC_ADD: String newName = DialogUtil.showInputDialog(window, "Enter new ORG name:", "Add ORG", "NEWDATA"); - if (newName == null) + if (newName == null || newName.isEmpty()) break; hit = false; for (int i = 0; i < orgList.size(); i++) { - String otherName = orgList.get(i); + String otherName = orgList.get(i).substring(7); if (newName.equalsIgnoreCase(otherName)) { JOptionPane.showMessageDialog(window, "The name \"" + newName + "\" already exists!", "Add ORG failure", JOptionPane.ERROR_MESSAGE); @@ -262,7 +274,7 @@ public void actionPerformed(ActionEvent ae) { if (hit) break; currentOrg = orgList.size(); - orgList.add(currentOrg, newName); + orgList.add(currentOrg, num2TSCParam(currentOrg) + " - " + newName); createOrgListModel(); modified = true; break; @@ -273,8 +285,7 @@ public void actionPerformed(ActionEvent ae) { break; } orgList.remove(currentOrg); - if (currentOrg == orgList.size()) - currentOrg--; + currentOrg--; if (currentOrg < 0) currentOrg = 0; createOrgListModel(); @@ -282,14 +293,16 @@ public void actionPerformed(ActionEvent ae) { break; case AC_EDIT: String orgName = orgList.get(currentOrg); + orgName = orgName.substring(7); int oldHash = orgName.hashCode(); orgName = DialogUtil.showInputDialog(window, "Enter new ORG name:", "Edit ORG", orgName); - if (orgName == null) + if (orgName == null || orgName.isEmpty()) break; - if (oldHash != orgName.hashCode()) { + String actualOrgName = num2TSCParam(currentOrg) + " - " + orgName; + if (oldHash != actualOrgName.hashCode()) { hit = false; for (int i = 0; i < orgList.size(); i++) { - String otherName = orgList.get(i); + String otherName = orgList.get(i).substring(7); if (orgName.equalsIgnoreCase(otherName)) { JOptionPane.showMessageDialog(window, "The name \"" + orgName + "\" already exists!", "Edit ORG failure", JOptionPane.ERROR_MESSAGE); @@ -299,7 +312,7 @@ public void actionPerformed(ActionEvent ae) { } if (hit) break; - orgList.set(currentOrg, orgName); + orgList.set(currentOrg, actualOrgName); createOrgListModel(); modified = true; }