From a54392e3f51d43e3665e1ca044f729dcdaa45603 Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Tue, 26 May 2015 19:56:28 +0200 Subject: [PATCH] show resources in order --- .../flash/gui/helpers/CheckResources.java | 64 +++++++++++++++++-- .../locales/AdvancedSettingsDialog.properties | 8 +-- 2 files changed, 61 insertions(+), 11 deletions(-) diff --git a/src/com/jpexs/decompiler/flash/gui/helpers/CheckResources.java b/src/com/jpexs/decompiler/flash/gui/helpers/CheckResources.java index cb7f57a3d..cc8805ccf 100644 --- a/src/com/jpexs/decompiler/flash/gui/helpers/CheckResources.java +++ b/src/com/jpexs/decompiler/flash/gui/helpers/CheckResources.java @@ -49,9 +49,14 @@ import java.io.PrintStream; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; +import java.util.Collections; +import java.util.Enumeration; import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.Map; import java.util.Properties; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -73,7 +78,7 @@ public class CheckResources { stream.println("Resource file not found: " + resourcePath); return; } - Properties prop = new Properties(); + Properties prop = new LinkedProperties(); prop.load(is); properties.put(clazz, prop); } @@ -86,7 +91,7 @@ public class CheckResources { boolean firstMissing = true; for (Class clazz : classes) { Properties prop = properties.get(clazz); - Properties prop2 = new Properties(); + Properties prop2 = new LinkedProperties(); String resourcePath = getResourcePath(clazz, lang); InputStream is = CheckResources.class.getResourceAsStream(resourcePath); if (is == null) { @@ -99,6 +104,7 @@ public class CheckResources { Logger.getLogger(CheckResources.class.getName()).log(Level.SEVERE, "Cannot load resource:" + clazz.getSimpleName() + " " + lang, ex); } + boolean firstMissing2 = true; for (Object key : prop.keySet()) { String keyStr = (String) key; String value = prop2.getProperty(keyStr); @@ -109,7 +115,12 @@ public class CheckResources { firstMissing = false; } - stream.println(clazz.getSimpleName() + ", property: " + key + "=" + prop.getProperty(keyStr)); + if (firstMissing2) { + stream.println(clazz.getSimpleName()); + firstMissing2 = false; + } + + stream.println(key + " = " + prop.getProperty(keyStr)); } } } @@ -135,25 +146,31 @@ public class CheckResources { URL latestUrl = new URL(rootUrl + (revision2 == null ? "master" : revision2) + resPath); URL prevUrl = new URL(rootUrl + revision + resPath); - Properties latestProp = new Properties(); + Properties latestProp = new LinkedProperties(); try { uc = latestUrl.openConnection(); latestProp.load(new BufferedReader(new InputStreamReader(uc.getInputStream()))); } catch (IOException ex) { } - Properties prevProp = new Properties(); + Properties prevProp = new LinkedProperties(); try { uc = prevUrl.openConnection(); prevProp.load(new BufferedReader(new InputStreamReader(uc.getInputStream()))); } catch (IOException ex) { } + boolean firstMissing2 = true; for (Object key : latestProp.keySet()) { String keyStr = (String) key; String value = prevProp.getProperty(keyStr); if (value == null) { - stream.println(clazz.getSimpleName() + ", property: " + key + "=" + latestProp.getProperty(keyStr)); + if (firstMissing2) { + stream.println(clazz.getSimpleName()); + firstMissing2 = false; + } + + stream.println(key + " = " + latestProp.getProperty(keyStr)); } } @@ -161,7 +178,12 @@ public class CheckResources { String keyStr = (String) key; String value = latestProp.getProperty(keyStr); if (value == null) { - stream.println(clazz.getSimpleName() + ", property: " + key + " was removed"); + if (firstMissing2) { + stream.println(clazz.getSimpleName()); + firstMissing2 = false; + } + + stream.println(key + " was removed. Last value: " + prevProp.getProperty(keyStr)); } } } catch (MalformedURLException ex) { @@ -214,4 +236,32 @@ public class CheckResources { } return name; } + + private static class LinkedProperties extends Properties { + + private final HashSet keys = new LinkedHashSet<>(); + + public LinkedProperties() { + } + + public Iterable orderedKeys() { + return Collections.list(keys()); + } + + @Override + public Enumeration keys() { + return Collections.enumeration(keys); + } + + @Override + public Set keySet() { + return keys; + } + + @Override + public Object put(Object key, Object value) { + keys.add(key); + return super.put(key, value); + } + } } diff --git a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties index 82fe8c5cc..9072a1c4a 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties @@ -36,7 +36,7 @@ config.group.name.limit = Limits config.group.description.limit = Decompilation limits for obfuscated code, etc. config.group.name.ui = Interface -config.group.description.ui = User intercace configuration +config.group.description.ui = User interface configuration config.group.name.debug = Debug config.group.description.debug = Debugging settings @@ -292,7 +292,7 @@ config.name.tagTreeShowEmptyFolders = Show empty folders config.description.tagTreeShowEmptyFolders = Show empty folders in tag tree. config.name.autoLoadEmbeddedSwfs = Auto load embedded SWFs -config.description.autoLoadEmbeddedSwfs = Automaticaly load the embedded SWFs from DefineBinaryData tags. +config.description.autoLoadEmbeddedSwfs = Automatically load the embedded SWFs from DefineBinaryData tags. config.name.overrideTextExportFileName = Override text export filename config.description.overrideTextExportFileName = You can customize the filename of the exported text. Use {filename} placeholder to use the filename of current SWF. @@ -319,9 +319,9 @@ config.name.updateProxyAddress = Http Proxy address for checking updates config.description.updateProxyAddress = Http Proxy address for checking updates. Format: example.com:8080 config.name.editorMode = Editor Mode -config.description.editorMode = Make text areas edittable automatically when you select a Text or Script node +config.description.editorMode = Make text areas editable automatically when you select a Text or Script node -config.name.autoSaveTagModifications = Auto save tag modificatios +config.name.autoSaveTagModifications = Auto save tag modifications config.description.autoSaveTagModifications = Save the changes when you select a new tag in the tree config.name.saveSessionOnExit = Save session on exit