diff --git a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java index 542a4bbb4..35033add3 100644 --- a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java +++ b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java @@ -69,6 +69,7 @@ import com.jpexs.decompiler.flash.exporters.settings.SoundExportSettings; import com.jpexs.decompiler.flash.exporters.settings.TextExportSettings; import com.jpexs.decompiler.flash.exporters.swf.SwfXmlExporter; import com.jpexs.decompiler.flash.gui.Main; +import com.jpexs.decompiler.flash.gui.helpers.CheckResources; import com.jpexs.decompiler.flash.helpers.FileTextWriter; import com.jpexs.decompiler.flash.importers.BinaryDataImporter; import com.jpexs.decompiler.flash.importers.ImageImporter; @@ -398,9 +399,12 @@ public class CommandLineArgumentParser { } Configuration.debugMode.set(true); break; - case "-debugtool": + case "--debugtool": parseDebugTool(args); break; + case "--compareresources": + parseCompareResources(args); + break; default: break OUTER; } @@ -836,6 +840,16 @@ public class CommandLineArgumentParser { } } + private static void parseCompareResources(Stack args) { + String revision = args.pop().toLowerCase(); + String revision2 = null; + if (!args.isEmpty()) { + revision2 = args.pop(); + } + + CheckResources.compareResources(System.out, revision, revision2); + } + private static void parseProxy(Stack args) { int port = 55555; String portStr = args.peek(); diff --git a/src/com/jpexs/decompiler/flash/gui/helpers/CheckResources.java b/src/com/jpexs/decompiler/flash/gui/helpers/CheckResources.java index 89e71aecc..0565d32f1 100644 --- a/src/com/jpexs/decompiler/flash/gui/helpers/CheckResources.java +++ b/src/com/jpexs/decompiler/flash/gui/helpers/CheckResources.java @@ -40,10 +40,15 @@ import com.jpexs.decompiler.flash.gui.abc.DeobfuscationDialog; import com.jpexs.decompiler.flash.gui.abc.NewTraitDialog; import com.jpexs.decompiler.flash.gui.abc.UsageFrame; import com.jpexs.decompiler.flash.gui.proxy.ProxyFrame; +import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import java.io.PrintStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; import java.util.HashMap; import java.util.Map; import java.util.Properties; @@ -57,38 +62,7 @@ import java.util.logging.Logger; public class CheckResources { public static void checkResources(PrintStream stream) { - Class[] classes = new Class[]{ - AboutDialog.class, - AdvancedSettingsDialog.class, - DebugLogDialog.class, - ErrorLogFrame.class, - ExportDialog.class, - FontEmbedDialog.class, - FontPreviewDialog.class, - GraphDialog.class, - // GraphTreeFrame.class, // empty - LoadFromCacheFrame.class, - LoadFromMemoryFrame.class, - LoadingDialog.class, - MainFrame.class, - ModeFrame.class, - NewVersionDialog.class, - RenameDialog.class, - ReplaceCharacterDialog.class, - ReplaceTraceDialog.class, - SearchDialog.class, - SearchResultsDialog.class, - SelectLanguageDialog.class, - // ABC - DeobfuscationDialog.class, - NewTraitDialog.class, - UsageFrame.class, - // Proxy - ProxyFrame.class,}; - checkResources(classes, stream); - } - - private static void checkResources(Class[] classes, PrintStream stream) { + Class[] classes = getClasses(); try { String[] languages = SelectLanguageDialog.getAvailableLanguages(); Map properties = new HashMap<>(); @@ -151,6 +125,85 @@ public class CheckResources { } } + public static void compareResources(PrintStream stream, String revision, String revision2) { + String rootUrl = "https://raw.githubusercontent.com/jindrapetrik/jpexs-decompiler/"; + Class[] classes = getClasses(); + for (Class clazz : classes) { + try { + String resPath = "/src" + getResourcePath(clazz, null); + URLConnection uc; + URL latestUrl = new URL(rootUrl + (revision2 == null ? "master" : revision2) + resPath); + URL prevUrl = new URL(rootUrl + revision + resPath); + + Properties latestProp = new Properties(); + try { + uc = latestUrl.openConnection(); + latestProp.load(new BufferedReader(new InputStreamReader(uc.getInputStream()))); + } catch (IOException ex) { + Logger.getLogger(CheckResources.class.getName()).log(Level.SEVERE, null, ex); + } + + Properties prevProp = new Properties(); + try { + uc = prevUrl.openConnection(); + prevProp.load(new BufferedReader(new InputStreamReader(uc.getInputStream()))); + } catch (IOException ex) { + Logger.getLogger(CheckResources.class.getName()).log(Level.SEVERE, null, ex); + } + + 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)); + } + } + + for (Object key : prevProp.keySet()) { + String keyStr = (String) key; + String value = latestProp.getProperty(keyStr); + if (value == null) { + stream.println(clazz.getSimpleName() + ", property: " + key + " was removed"); + } + } + } catch (MalformedURLException ex) { + throw new Error(ex); + } + } + } + + private static Class[] getClasses() { + Class[] classes = new Class[]{ + AboutDialog.class, + AdvancedSettingsDialog.class, + DebugLogDialog.class, + ErrorLogFrame.class, + ExportDialog.class, + FontEmbedDialog.class, + FontPreviewDialog.class, + GraphDialog.class, + // GraphTreeFrame.class, // empty + LoadFromCacheFrame.class, + LoadFromMemoryFrame.class, + LoadingDialog.class, + MainFrame.class, + ModeFrame.class, + NewVersionDialog.class, + RenameDialog.class, + ReplaceCharacterDialog.class, + ReplaceTraceDialog.class, + SearchDialog.class, + SearchResultsDialog.class, + SelectLanguageDialog.class, + // ABC + DeobfuscationDialog.class, + NewTraitDialog.class, + UsageFrame.class, + // Proxy + ProxyFrame.class,}; + return classes; + } + private static String getResourcePath(Class cls, String lang) { String name = cls.getName(); if (name.startsWith("com.jpexs.decompiler.flash.gui.")) {