Skip to content
This repository has been archived by the owner on Oct 18, 2019. It is now read-only.

Commit

Permalink
Hotfix 1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo40Git committed Apr 27, 2018
1 parent 24cc4e2 commit 2148b7f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
6 changes: 5 additions & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/leo/orgadder/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
41 changes: 27 additions & 14 deletions src/main/java/com/leo/orgadder/MainAL.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@ public static boolean loadOrgList() {
JOptionPane.INFORMATION_MESSAGE);
} else
modified = false;
orgList = new LinkedList<>(ONTHandler.getOrgNames());
Vector<String> 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);
Expand All @@ -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();
}

Expand All @@ -193,7 +195,7 @@ private static boolean saveOrgList0() {
Vector<String> 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);
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -273,23 +285,24 @@ public void actionPerformed(ActionEvent ae) {
break;
}
orgList.remove(currentOrg);
if (currentOrg == orgList.size())
currentOrg--;
currentOrg--;
if (currentOrg < 0)
currentOrg = 0;
createOrgListModel();
modified = true;
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);
Expand All @@ -299,7 +312,7 @@ public void actionPerformed(ActionEvent ae) {
}
if (hit)
break;
orgList.set(currentOrg, orgName);
orgList.set(currentOrg, actualOrgName);
createOrgListModel();
modified = true;
}
Expand Down

0 comments on commit 2148b7f

Please sign in to comment.