diff --git a/src/com/jpexs/decompiler/flash/gui/AdvancedSettingsDialog.java b/src/com/jpexs/decompiler/flash/gui/AdvancedSettingsDialog.java index cc739ac23..af5fc0a93 100644 --- a/src/com/jpexs/decompiler/flash/gui/AdvancedSettingsDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/AdvancedSettingsDialog.java @@ -40,10 +40,14 @@ import java.lang.reflect.Field; import java.lang.reflect.ParameterizedType; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; +import java.util.Collections; +import java.util.Comparator; import java.util.EnumSet; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.ResourceBundle; @@ -91,8 +95,8 @@ public class AdvancedSettingsDialog extends AppDialog { /** * Creates new form AdvancedSettingsDialog */ - public AdvancedSettingsDialog() { - initComponents(); + public AdvancedSettingsDialog(String selectedCategory) { + initComponents(selectedCategory); View.centerScreen(this); View.setWindowIcon(this); @@ -150,7 +154,7 @@ public class AdvancedSettingsDialog extends AppDialog { } } - private void initComponents() { + private void initComponents(String selectedCategory) { okButton = new JButton(); cancelButton = new JButton(); resetButton = new JButton(); @@ -260,6 +264,9 @@ public class AdvancedSettingsDialog extends AppDialog { tabPane.add(translate("config.group.name." + cat), tabs.get(cat)); tabPane.setToolTipTextAt(tabPane.getTabCount() - 1, translate("config.group.description." + cat)); } + if (selectedCategory != null && tabs.containsKey(selectedCategory)) { + tabPane.setSelectedComponent(tabs.get(selectedCategory)); + } cnt.add(tabPane, BorderLayout.CENTER); pack(); @@ -321,7 +328,14 @@ public class AdvancedSettingsDialog extends AppDialog { for (String cat : categorized.keySet()) { JPanel configPanel = new JPanel(new SpringLayout()); int itemCount = 0; - for (String name : categorized.get(cat).keySet()) { + List names = new ArrayList<>(categorized.get(cat).keySet()); + Collections.sort(names, new Comparator() { + @Override + public int compare(String name1, String name2) { + return resourceBundle.getString("config.name." + name1).compareTo(resourceBundle.getString("config.name." + name2)); + } + }); + for (String name : names) { Field field = categorized.get(cat).get(name); String locName = resourceBundle.getString("config.name." + name); @@ -440,6 +454,27 @@ public class AdvancedSettingsDialog extends AppDialog { itemCount, 2, //rows, cols 6, 6, //initX, initY 6, 6); //xPad, yPad + //https://www.adobe.com/support/flashplayer/debug_downloads.html + if (resourceBundle.containsKey("config.group.tip." + cat)) { + String tip = resourceBundle.getString("config.group.tip." + cat); + String url = null; + if (resourceBundle.containsKey("config.group.link." + cat)) { + url = resourceBundle.getString("config.group.link." + cat); + } + JPanel p = new JPanel(new BorderLayout()); + p.add(configPanel, BorderLayout.CENTER); + JPanel tipPanel = new JPanel(new FlowLayout()); + tipPanel.add(new JLabel("" + resourceBundle.getString("tip") + "" + tip + "")); + if (url != null) { + String linkText = url; + if (resourceBundle.containsKey("config.group.linkText." + cat)) { + linkText = resourceBundle.getString("config.group.linkText." + cat); + } + tipPanel.add(new LinkLabel(linkText, url)); + } + p.add(tipPanel, BorderLayout.SOUTH); + configPanel = p; + } tabs.put(cat, new JScrollPane(configPanel)); } } diff --git a/src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java b/src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java index bfc2e03fc..c2cc2a1c3 100644 --- a/src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java +++ b/src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java @@ -36,6 +36,7 @@ import com.jpexs.debugger.flash.messages.in.InVersion; import com.jpexs.debugger.flash.messages.out.OutGetBreakReason; import com.jpexs.decompiler.flash.abc.ClassPath; import com.jpexs.decompiler.flash.abc.ScriptPack; +import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.graph.DottedChain; import java.io.IOException; import java.util.ArrayList; @@ -63,14 +64,42 @@ public class DebuggerHandler implements DebugConnectionListener { private InFrame frame; + private InBreakAtExt breakInfo; + private InBreakReason breakReason; + + private final List listeners = new ArrayList<>(); + + private final List clisteners = new ArrayList<>(); + + public String moduleToString(int file) { + if (!modulePaths.containsKey(file)) { + return "unknown"; + } + return modulePaths.get(file).toString(); + } + + public InBreakAtExt getBreakInfo() { + return breakInfo; + } + + public InBreakReason getBreakReason() { + return breakReason; + } + + public static interface ConnectionListener { + + public void connected(); + + public void disconnected(); + + } + public static interface VariableChangedListener { public void variablesChanged(); } - private List listeners = new ArrayList<>(); - public void addVariableChangedListener(VariableChangedListener l) { listeners.add(l); } @@ -79,41 +108,16 @@ public class DebuggerHandler implements DebugConnectionListener { listeners.remove(l); } - public void setVariableValue(int index, String value) { - //variables.get(index).value = value - //TODO: + public void addConnectionListener(ConnectionListener l) { + clisteners.add(l); } - public int getNumVariables() { - if (frame == null) { - return 0; - } - return frame.variables.size(); + public void removeConnectionListener(ConnectionListener l) { + clisteners.remove(l); } - public Variable getFrameVariable() { - if (frame == null) { - return null; - } - return frame.frame; - } - - public Variable getVariable(int index) { - if (frame == null) { - return null; - } - return frame.variables.get(index); - } - - public int getNumRegisters() { - if (frame == null) { - return 0; - } - return frame.registers.size(); - } - - public Variable getRegister(int index) { - return frame.registers.get(index); + public InFrame getFrame() { + return frame; } public int moduleIdOf(ScriptPack pack) { @@ -132,11 +136,20 @@ public class DebuggerHandler implements DebugConnectionListener { } public void disconnect() { + frame = null; + breakInfo = null; + breakReason = null; connected = false; if (commands != null) { commands.disconnect(); } commands = null; + for (ConnectionListener l : clisteners) { + l.disconnected(); + } + for (VariableChangedListener l : listeners) { + l.variablesChanged(); + } } public boolean isConnected() { @@ -243,10 +256,13 @@ public class DebuggerHandler implements DebugConnectionListener { if (!modulePaths.containsKey(message.file)) { return; } + String cls = modulePaths.get(message.file).toString(); + Main.startWork(AppStrings.translate("work.breakat") + cls + ":" + message.line, null); + try { - InBreakAtExt bex = con.getMessage(InBreakAtExt.class); - InBreakReason ibr = con.sendMessage(new OutGetBreakReason(con), InBreakReason.class); + breakInfo = con.getMessage(InBreakAtExt.class); + breakReason = con.sendMessage(new OutGetBreakReason(con), InBreakReason.class); frame = commands.getFrame(0); for (VariableChangedListener l : listeners) { @@ -281,6 +297,17 @@ public class DebuggerHandler implements DebugConnectionListener { Main.getMainFrame() .getPanel().refreshBreakPoints(); connected = true; + + for (ConnectionListener l : clisteners) { + l.connected(); + } + + if (Configuration.debugHalt.get()) { + Main.startWork(AppStrings.translate("work.halted"), null); + } else { + commands.sendContinue(); + } + } catch (IOException ex) { connected = false; } diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index 7e90e3483..973000d5b 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -1504,6 +1504,7 @@ public class Main { Configuration.saveConfig(); if (mainFrame != null && mainFrame.getPanel() != null) { mainFrame.getPanel().unloadFlashPlayer(); + mainFrame.dispose(); } System.exit(0); } @@ -1513,7 +1514,11 @@ public class Main { } public static void advancedSettings() { - (new AdvancedSettingsDialog()).setVisible(true); + advancedSettings(null); + } + + public static void advancedSettings(String category) { + (new AdvancedSettingsDialog(category)).setVisible(true); } public static void autoCheckForUpdates() { diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameClassicMenu.java b/src/com/jpexs/decompiler/flash/gui/MainFrameClassicMenu.java index 5d45776fd..6c41bfd53 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameClassicMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameClassicMenu.java @@ -24,6 +24,7 @@ import java.util.Map; import java.util.Set; import javax.swing.ButtonGroup; import javax.swing.JCheckBoxMenuItem; +import javax.swing.JComponent; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; @@ -98,7 +99,7 @@ public class MainFrameClassicMenu extends MainFrameMenu { } @Override - public void addMenuItem(String path, String title, String icon, ActionListener action, int priority, final ActionListener subLoader, boolean isLeaf, HotKey key) { + public void addMenuItem(String path, String title, String icon, ActionListener action, int priority, final ActionListener subLoader, boolean isLeaf, HotKey key, boolean isOptional) { path = mapping(path); menuHotkeys.put(path, key); @@ -359,4 +360,18 @@ public class MainFrameClassicMenu extends MainFrameMenu { } return s; } + + @Override + public void hilightPath(String path) { + //TODO + } + + @Override + public void setPathVisible(String path, boolean val) { + MenuElement me = menuElements.get(path); + if (me instanceof JComponent) { + ((JComponent) me).setVisible(val); + } + } + } diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java b/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java index bc5d64862..6c00660e8 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java @@ -28,6 +28,7 @@ import com.jpexs.decompiler.flash.gui.helpers.CheckResources; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.helpers.ByteArrayRange; import com.jpexs.helpers.Cache; +import com.jpexs.helpers.CancellableWorker; import com.jpexs.helpers.Helper; import com.jpexs.helpers.utf8.Utf8Helper; import com.sun.jna.Platform; @@ -723,17 +724,21 @@ public abstract class MainFrameMenu implements MenuBuilder { setMenuEnabled("_/about", !isWorking); setMenuEnabled("/help/about", !isWorking); - setMenuEnabled("/execution/start/run", swfSelected && !isRunningOrDebugging); - setMenuEnabled("/execution/start/debug", !isRunningOrDebugging); - setMenuEnabled("/execution/start/stop", isRunningOrDebugging); - setMenuEnabled("/execution/debug", isDebugRunning); - //setMenuEnabled("/execution/debug/pause", isDebugRunning); - setMenuEnabled("/execution/debug/stepOver", isDebugPaused); - setMenuEnabled("/execution/debug/stepInto", isDebugPaused); - setMenuEnabled("/execution/debug/stepOut", isDebugPaused); - setMenuEnabled("/execution/debug/continue", isDebugPaused); - setMenuEnabled("/execution/debug/stack", isDebugPaused); - setMenuEnabled("/execution/debug/watch", isDebugPaused); + setMenuEnabled("/file/start/run", swfSelected && !isRunningOrDebugging); + setMenuEnabled("/file/start/debug", !isRunningOrDebugging); + + setMenuEnabled("/file/start/stop", isRunningOrDebugging); + setMenuEnabled("/debugging/debug/stop", isRunningOrDebugging); //same as previous + + setPathVisible("/debugging", isDebugRunning); + setMenuEnabled("/debugging/debug", isDebugRunning); + //setMenuEnabled("/debugging/debug/pause", isDebugRunning); + setMenuEnabled("/debugging/debug/stepOver", isDebugPaused); + setMenuEnabled("/debugging/debug/stepInto", isDebugPaused); + setMenuEnabled("/debugging/debug/stepOut", isDebugPaused); + setMenuEnabled("/debugging/debug/continue", isDebugPaused); + //setMenuEnabled("/debugging/debug/stack", isDebugPaused); + //setMenuEnabled("/debugging/debug/watch", isDebugPaused); } @@ -747,66 +752,72 @@ public abstract class MainFrameMenu implements MenuBuilder { initMenu(); if (supportsAppMenu()) { - addMenuItem("_", null, null, null, 0, null, false, null); - addMenuItem("_/open", translate("menu.file.open"), "open32", this::openActionPerformed, PRIORITY_TOP, this::loadRecent, false, null); - addMenuItem("_/save", translate("menu.file.save"), "save32", this::saveActionPerformed, PRIORITY_TOP, null, true, null); - addMenuItem("_/saveAs", translate("menu.file.saveas"), "saveas32", this::saveAsActionPerformed, PRIORITY_TOP, null, true, null); + addMenuItem("_", null, null, null, 0, null, false, null, false); + addMenuItem("_/open", translate("menu.file.open"), "open32", this::openActionPerformed, PRIORITY_TOP, this::loadRecent, false, null, false); + addMenuItem("_/save", translate("menu.file.save"), "save32", this::saveActionPerformed, PRIORITY_TOP, null, true, null, false); + addMenuItem("_/saveAs", translate("menu.file.saveas"), "saveas32", this::saveAsActionPerformed, PRIORITY_TOP, null, true, null, false); addSeparator("_"); - addMenuItem("_/exportFla", translate("menu.file.export.fla"), "exportfla32", this::exportFlaActionPerformed, PRIORITY_TOP, null, true, null); - addMenuItem("_/exportAll", translate("menu.file.export.all"), "export32", this::exportAllActionPerformed, PRIORITY_TOP, null, true, null); - addMenuItem("_/exportSelected", translate("menu.file.export.selection"), "exportsel32", this::exportSelectedActionPerformed, PRIORITY_TOP, null, true, null); + addMenuItem("_/exportFla", translate("menu.file.export.fla"), "exportfla32", this::exportFlaActionPerformed, PRIORITY_TOP, null, true, null, false); + addMenuItem("_/exportAll", translate("menu.file.export.all"), "export32", this::exportAllActionPerformed, PRIORITY_TOP, null, true, null, false); + addMenuItem("_/exportSelected", translate("menu.file.export.selection"), "exportsel32", this::exportSelectedActionPerformed, PRIORITY_TOP, null, true, null, false); addSeparator("_"); - addMenuItem("_/checkUpdates", translate("menu.help.checkupdates"), "update32", this::checkUpdatesActionPerformed, PRIORITY_TOP, null, true, null); - addMenuItem("_/about", translate("menu.help.about"), "about32", this::aboutActionPerformed, PRIORITY_TOP, null, true, null); - addMenuItem("_/close", translate("menu.file.close"), "close32", this::closeActionPerformed, PRIORITY_TOP, null, true, null); - addMenuItem("_/closeAll", translate("menu.file.closeAll"), "closeall32", this::closeAllActionPerformed, PRIORITY_TOP, null, true, null); - addMenuItem("_/$exit", translate("menu.file.exit"), "exit32", this::exitActionPerformed, PRIORITY_TOP, null, true, null); + addMenuItem("_/checkUpdates", translate("menu.help.checkupdates"), "update32", this::checkUpdatesActionPerformed, PRIORITY_TOP, null, true, null, false); + addMenuItem("_/about", translate("menu.help.about"), "about32", this::aboutActionPerformed, PRIORITY_TOP, null, true, null, false); + addMenuItem("_/close", translate("menu.file.close"), "close32", this::closeActionPerformed, PRIORITY_TOP, null, true, null, false); + addMenuItem("_/closeAll", translate("menu.file.closeAll"), "closeall32", this::closeAllActionPerformed, PRIORITY_TOP, null, true, null, false); + addMenuItem("_/$exit", translate("menu.file.exit"), "exit32", this::exitActionPerformed, PRIORITY_TOP, null, true, null, false); finishMenu("_"); } - addMenuItem("/file", translate("menu.file"), null, null, 0, null, false, null); - addMenuItem("/file/open", translate("menu.file.open"), "open32", this::openActionPerformed, PRIORITY_TOP, this::loadRecent, !supportsMenuAction(), new HotKey("CTRL+SHIFT+O")); + addMenuItem("/file", translate("menu.file"), null, null, 0, null, false, null, false); + addMenuItem("/file/open", translate("menu.file.open"), "open32", this::openActionPerformed, PRIORITY_TOP, this::loadRecent, !supportsMenuAction(), new HotKey("CTRL+SHIFT+O"), false); if (!supportsMenuAction()) { - addMenuItem("/file/recent", translate("menu.recentFiles"), null, null, 0, this::loadRecent, false, null); + addMenuItem("/file/recent", translate("menu.recentFiles"), null, null, 0, this::loadRecent, false, null, false); finishMenu("/file/recent"); } else { finishMenu("/file/open"); } - addMenuItem("/file/save", translate("menu.file.save"), "save32", this::saveActionPerformed, PRIORITY_TOP, null, true, new HotKey("CTRL+SHIFT+S")); - addMenuItem("/file/saveAs", translate("menu.file.saveas"), "saveas16", this::saveAsActionPerformed, PRIORITY_MEDIUM, null, true, new HotKey("CTRL+SHIFT+A")); - addMenuItem("/file/saveAsExe", translate("menu.file.saveasexe"), "saveasexe16", this::saveAsExeActionPerformed, PRIORITY_MEDIUM, null, true, null); - addMenuItem("/file/reload", translate("menu.file.reload"), "reload16", this::reloadActionPerformed, PRIORITY_MEDIUM, null, true, new HotKey("CTRL+SHIFT+R")); + addMenuItem("/file/save", translate("menu.file.save"), "save32", this::saveActionPerformed, PRIORITY_TOP, null, true, new HotKey("CTRL+SHIFT+S"), false); + addMenuItem("/file/saveAs", translate("menu.file.saveas"), "saveas16", this::saveAsActionPerformed, PRIORITY_MEDIUM, null, true, new HotKey("CTRL+SHIFT+A"), false); + addMenuItem("/file/saveAsExe", translate("menu.file.saveasexe"), "saveasexe16", this::saveAsExeActionPerformed, PRIORITY_MEDIUM, null, true, null, false); + addMenuItem("/file/reload", translate("menu.file.reload"), "reload16", this::reloadActionPerformed, PRIORITY_MEDIUM, null, true, new HotKey("CTRL+SHIFT+R"), false); addSeparator("/file"); - addMenuItem("/file/export", translate("menu.export"), null, null, 0, null, false, null); - addMenuItem("/file/export/exportFla", translate("menu.file.export.fla"), "exportfla32", this::exportFlaActionPerformed, PRIORITY_TOP, null, true, null); - addMenuItem("/file/export/exportXml", translate("menu.file.export.xml"), "exportxml32", this::exportXmlActionPerformed, PRIORITY_MEDIUM, null, true, null); - addMenuItem("/file/export/exportAll", translate("menu.file.export.all"), "export16", this::exportAllActionPerformed, PRIORITY_MEDIUM, null, true, new HotKey("CTRL+SHIFT+E")); - addMenuItem("/file/export/exportSelected", translate("menu.file.export.selection"), "exportsel16", this::exportSelectedActionPerformed, PRIORITY_MEDIUM, null, true, null); + addMenuItem("/file/export", translate("menu.export"), null, null, 0, null, false, null, false); + addMenuItem("/file/export/exportFla", translate("menu.file.export.fla"), "exportfla32", this::exportFlaActionPerformed, PRIORITY_TOP, null, true, null, false); + addMenuItem("/file/export/exportXml", translate("menu.file.export.xml"), "exportxml32", this::exportXmlActionPerformed, PRIORITY_MEDIUM, null, true, null, false); + addMenuItem("/file/export/exportAll", translate("menu.file.export.all"), "export16", this::exportAllActionPerformed, PRIORITY_MEDIUM, null, true, new HotKey("CTRL+SHIFT+E"), false); + addMenuItem("/file/export/exportSelected", translate("menu.file.export.selection"), "exportsel16", this::exportSelectedActionPerformed, PRIORITY_MEDIUM, null, true, null, false); finishMenu("/file/export"); - addMenuItem("/file/import", translate("menu.import"), null, null, 0, null, false, null); - addMenuItem("/file/import/importXml", translate("menu.file.import.xml"), "importxml32", this::importXmlActionPerformed, PRIORITY_TOP, null, true, null); - addMenuItem("/file/import/importText", translate("menu.file.import.text"), "importtext32", this::importTextActionPerformed, PRIORITY_MEDIUM, null, true, null); - addMenuItem("/file/import/importScript", translate("menu.file.import.script"), "importscript32", this::importScriptActionPerformed, PRIORITY_MEDIUM, null, true, null); - addMenuItem("/file/import/importSymbolClass", translate("menu.file.import.symbolClass"), "importsymbolclass32", this::importSymbolClassActionPerformed, PRIORITY_MEDIUM, null, true, null); + addMenuItem("/file/import", translate("menu.import"), null, null, 0, null, false, null, false); + addMenuItem("/file/import/importXml", translate("menu.file.import.xml"), "importxml32", this::importXmlActionPerformed, PRIORITY_TOP, null, true, null, false); + addMenuItem("/file/import/importText", translate("menu.file.import.text"), "importtext32", this::importTextActionPerformed, PRIORITY_MEDIUM, null, true, null, false); + addMenuItem("/file/import/importScript", translate("menu.file.import.script"), "importscript32", this::importScriptActionPerformed, PRIORITY_MEDIUM, null, true, null, false); + addMenuItem("/file/import/importSymbolClass", translate("menu.file.import.symbolClass"), "importsymbolclass32", this::importSymbolClassActionPerformed, PRIORITY_MEDIUM, null, true, null, false); finishMenu("/file/import"); - addMenuItem("/file/view", translate("menu.view"), null, null, 0, null, false, null); + addMenuItem("/file/start", translate("menu.file.start"), null, null, 0, null, false, null, false); + addMenuItem("/file/start/run", translate("menu.file.start.run"), "play32", this::runActionPerformed, PRIORITY_TOP, null, true, new HotKey("F6"), false); + addMenuItem("/file/start/debug", translate("menu.file.start.debug"), "debug32", this::debugActionPerformed, PRIORITY_TOP, null, true, new HotKey("CTRL+F5"), false); + addMenuItem("/file/start/stop", translate("menu.file.start.stop"), "stop32", this::stopActionPerformed, PRIORITY_TOP, null, true, null, false); + finishMenu("/file/start"); + + addMenuItem("/file/view", translate("menu.view"), null, null, 0, null, false, null, false); addToggleMenuItem("/file/view/viewResources", translate("menu.file.view.resources"), "view", "viewresources16", this::viewResourcesActionPerformed, PRIORITY_MEDIUM, null); addToggleMenuItem("/file/view/viewHex", translate("menu.file.view.hex"), "view", "viewhex16", this::viewHexActionPerformed, PRIORITY_MEDIUM, null); finishMenu("/file/view"); addSeparator("/file"); - addMenuItem("/file/close", translate("menu.file.close"), "close32", this::closeActionPerformed, PRIORITY_MEDIUM, null, true, null); - addMenuItem("/file/closeAll", translate("menu.file.closeAll"), "closeall32", this::closeAllActionPerformed, PRIORITY_MEDIUM, null, true, new HotKey("CTRL+SHIFT+X")); + addMenuItem("/file/close", translate("menu.file.close"), "close32", this::closeActionPerformed, PRIORITY_MEDIUM, null, true, null, false); + addMenuItem("/file/closeAll", translate("menu.file.closeAll"), "closeall32", this::closeAllActionPerformed, PRIORITY_MEDIUM, null, true, new HotKey("CTRL+SHIFT+X"), false); if (!supportsAppMenu()) { addSeparator("/file"); - addMenuItem("/file/exit", translate("menu.file.exit"), "exit32", this::exitActionPerformed, PRIORITY_TOP, null, true, null); + addMenuItem("/file/exit", translate("menu.file.exit"), "exit32", this::exitActionPerformed, PRIORITY_TOP, null, true, null, false); } finishMenu("/file"); @@ -818,63 +829,61 @@ public abstract class MainFrameMenu implements MenuBuilder { } /* - menu.execution = Execution - menu.execution.start.run = Run - menu.execution.start.debug = Debug - menu.execution.start.stop = Stop - menu.execution.debug.pause = Pause - menu.execution.debug.stepOver = Step over - menu.execution.debug.stepInto = Step into - menu.execution.debug.stepOut = Step out - menu.execution.debug.continue = Continue - menu.execution.debug.stack = Stack... - menu.execution.debug.watch = New watch... + menu.file.start = Start + menu.file.start.run = Run + menu.file.start.stop = Stop + menu.file.start.debug = Debug + menu.debugging = Debugging + menu.debugging.debug = Debug + menu.debugging.debug.stop = Stop + menu.debugging.debug.pause = Pause + menu.debugging.debug.stepOver = Step over + menu.debugging.debug.stepInto = Step into + menu.debugging.debug.stepOut = Step out + menu.debugging.debug.continue = Continue + menu.debugging.debug.stack = Stack... + menu.debugging.debug.watch = New watch... */ - addMenuItem("/execution", translate("menu.execution"), null, null, 0, null, false, null); - addMenuItem("/execution/start", translate("menu.execution.start"), null, null, 0, null, false, null); - addMenuItem("/execution/start/run", translate("menu.execution.start.run"), "play32", this::runActionPerformed, PRIORITY_TOP, null, true, new HotKey("F6")); - addMenuItem("/execution/start/debug", translate("menu.execution.start.debug"), "debug32", this::debugActionPerformed, PRIORITY_TOP, null, true, new HotKey("CTRL+F6")); - addMenuItem("/execution/start/stop", translate("menu.execution.start.stop"), "stop32", this::stopActionPerformed, PRIORITY_TOP, null, true, null); - finishMenu("/execution/start"); + addMenuItem("/debugging", translate("menu.debugging"), null, null, 0, null, false, null, true); + addMenuItem("/debugging/debug", translate("menu.debugging.debug"), null, null, 0, null, false, null, false); + addMenuItem("/debugging/debug/stop", translate("menu.file.start.stop"), "stop32", this::stopActionPerformed, PRIORITY_TOP, null, true, null, false); + //addMenuItem("/debugging/debug/pause", translate("menu.debugging.debug.pause"), "pause32", this::pauseActionPerformed, PRIORITY_TOP, null, true,false); + addMenuItem("/debugging/debug/continue", translate("menu.debugging.debug.continue"), "continue32", this::continueActionPerformed, PRIORITY_TOP, null, true, new HotKey("F5"), false); + addMenuItem("/debugging/debug/stepOver", translate("menu.debugging.debug.stepOver"), "stepover32", this::stepOverActionPerformed, PRIORITY_MEDIUM, null, true, new HotKey("F8"), false); + addMenuItem("/debugging/debug/stepInto", translate("menu.debugging.debug.stepInto"), "stepinto32", this::stepIntoActionPerformed, PRIORITY_MEDIUM, null, true, new HotKey("F7"), false); + addMenuItem("/debugging/debug/stepOut", translate("menu.debugging.debug.stepOut"), "stepout32", this::stepOutActionPerformed, PRIORITY_MEDIUM, null, true, new HotKey("CTRL+F7"), false); + //addMenuItem("/debugging/debug/stack", translate("menu.debugging.debug.stack"), "stack32", this::stackActionPerformed, PRIORITY_MEDIUM, null, true, null, false); + //addMenuItem("/debugging/debug/watch", translate("menu.debugging.debug.watch"), "watch32", this::watchActionPerformed, PRIORITY_MEDIUM, null, true, null, false); + finishMenu("/debugging/debug"); + finishMenu("/debugging"); - addMenuItem("/execution/debug", translate("menu.execution.debug"), null, null, 0, null, false, null); - //addMenuItem("/execution/debug/pause", translate("menu.execution.debug.pause"), "pause32", this::pauseActionPerformed, PRIORITY_TOP, null, true); - addMenuItem("/execution/debug/continue", translate("menu.execution.debug.continue"), "continue32", this::continueActionPerformed, PRIORITY_TOP, null, true, new HotKey("F5")); - addMenuItem("/execution/debug/stepOver", translate("menu.execution.debug.stepOver"), "stepover32", this::stepOverActionPerformed, PRIORITY_MEDIUM, null, true, new HotKey("F8")); - addMenuItem("/execution/debug/stepInto", translate("menu.execution.debug.stepInto"), "stepinto32", this::stepIntoActionPerformed, PRIORITY_MEDIUM, null, true, new HotKey("F7")); - addMenuItem("/execution/debug/stepOut", translate("menu.execution.debug.stepOut"), "stepout32", this::stepOutActionPerformed, PRIORITY_MEDIUM, null, true, new HotKey("CTRL+F7")); - addMenuItem("/execution/debug/stack", translate("menu.execution.debug.stack"), "stack32", this::stackActionPerformed, PRIORITY_MEDIUM, null, true, null); - addMenuItem("/execution/debug/watch", translate("menu.execution.debug.watch"), "watch32", this::watchActionPerformed, PRIORITY_MEDIUM, null, true, null); - finishMenu("/execution/debug"); - finishMenu("/execution"); + addMenuItem("/tools", translate("menu.tools"), null, null, 0, null, false, null, false); + addMenuItem("/tools/search", translate("menu.tools.search"), "search16", this::searchActionPerformed, PRIORITY_TOP, null, true, null, false); - addMenuItem("/tools", translate("menu.tools"), null, null, 0, null, false, null); - addMenuItem("/tools/search", translate("menu.tools.search"), "search16", this::searchActionPerformed, PRIORITY_TOP, null, true, null); - - addMenuItem("/tools/replace", translate("menu.tools.replace"), "replace32", this::replaceActionPerformed, PRIORITY_TOP, null, true, null); + addMenuItem("/tools/replace", translate("menu.tools.replace"), "replace32", this::replaceActionPerformed, PRIORITY_TOP, null, true, null, false); addToggleMenuItem("/tools/timeline", translate("menu.tools.timeline"), null, "timeline32", this::timelineActionPerformed, PRIORITY_TOP, null); - addMenuItem("/tools/showProxy", translate("menu.tools.proxy"), "proxy16", this::showProxyActionPerformed, PRIORITY_MEDIUM, null, true, null); - addMenuItem("/tools/searchMemory", translate("menu.tools.searchMemory"), "loadmemory16", this::searchMemoryActionPerformed, PRIORITY_MEDIUM, null, true, null); + addMenuItem("/tools/showProxy", translate("menu.tools.proxy"), "proxy16", this::showProxyActionPerformed, PRIORITY_MEDIUM, null, true, null, false); + addMenuItem("/tools/searchMemory", translate("menu.tools.searchMemory"), "loadmemory16", this::searchMemoryActionPerformed, PRIORITY_MEDIUM, null, true, null, false); //addMenuItem("/tools/searchCache", translate("menu.tools.searchCache"), "loadcache16", this::searchCacheActionPerformed, PRIORITY_MEDIUM, null, true, null); - addMenuItem("/tools/deobfuscation", translate("menu.tools.deobfuscation"), "deobfuscate16", null, 0, null, false, null); - addMenuItem("/tools/deobfuscation/renameOneIdentifier", translate("menu.tools.deobfuscation.globalrename"), "rename16", this::renameOneIdentifier, PRIORITY_MEDIUM, null, true, null); - addMenuItem("/tools/deobfuscation/renameInvalidIdentifiers", translate("menu.tools.deobfuscation.renameinvalid"), "renameall16", this::renameInvalidIdentifiers, PRIORITY_MEDIUM, null, true, null); - addMenuItem("/tools/deobfuscation/deobfuscation", translate("menu.tools.deobfuscation.pcode"), "deobfuscate32", this::deobfuscationActionPerformed, PRIORITY_TOP, null, true, null); + addMenuItem("/tools/deobfuscation", translate("menu.tools.deobfuscation"), "deobfuscate16", null, 0, null, false, null, false); + addMenuItem("/tools/deobfuscation/renameOneIdentifier", translate("menu.tools.deobfuscation.globalrename"), "rename16", this::renameOneIdentifier, PRIORITY_MEDIUM, null, true, null, false); + addMenuItem("/tools/deobfuscation/renameInvalidIdentifiers", translate("menu.tools.deobfuscation.renameinvalid"), "renameall16", this::renameInvalidIdentifiers, PRIORITY_MEDIUM, null, true, null, false); + addMenuItem("/tools/deobfuscation/deobfuscation", translate("menu.tools.deobfuscation.pcode"), "deobfuscate32", this::deobfuscationActionPerformed, PRIORITY_TOP, null, true, null, false); finishMenu("/tools/deobfuscation"); - /*addMenuItem("/tools/debugger", translate("menu.debugger"), null, null, 0, null, false, null); - addToggleMenuItem("/tools/debugger/debuggerSwitch", translate("menu.debugger.switch"), null, "debugger32", this::debuggerSwitchActionPerformed, PRIORITY_TOP, null); - addMenuItem("/tools/debugger/debuggerReplaceTrace", translate("menu.debugger.replacetrace"), "debuggerreplace16", this::debuggerReplaceTraceCallsActionPerformed, PRIORITY_MEDIUM, null, true, null); - //addMenuItem("/tools/debugger/debuggerInjectLoader", "Inject Loader", "debuggerreplace16", this::debuggerInjectLoader, PRIORITY_MEDIUM, null, true); - addMenuItem("/tools/debugger/debuggerShowLog", translate("menu.debugger.showlog"), "debuggerlog16", this::debuggerShowLogActionPerformed, PRIORITY_MEDIUM, null, true, null); + /*addMenuItem("/tools/debugger", translate("menu.debugger"), null, null, 0, null, false, null,false); + addToggleMenuItem("/tools/debugger/debuggerSwitch", translate("menu.debugger.switch"), null, "debugger32", this::debuggerSwitchActionPerformed, PRIORITY_TOP, null,false); + addMenuItem("/tools/debugger/debuggerReplaceTrace", translate("menu.debugger.replacetrace"), "debuggerreplace16", this::debuggerReplaceTraceCallsActionPerformed, PRIORITY_MEDIUM, null, true, null,false); + //addMenuItem("/tools/debugger/debuggerInjectLoader", "Inject Loader", "debuggerreplace16", this::debuggerInjectLoader, PRIORITY_MEDIUM, null, true,false); + addMenuItem("/tools/debugger/debuggerShowLog", translate("menu.debugger.showlog"), "debuggerlog16", this::debuggerShowLogActionPerformed, PRIORITY_MEDIUM, null, true, null,false); finishMenu("/tools/debugger");*/ - addMenuItem("/tools/gotoDocumentClass", translate("menu.tools.gotoDocumentClass"), "gotomainclass32", this::gotoDucumentClassActionPerformed, PRIORITY_TOP, null, true, null); + addMenuItem("/tools/gotoDocumentClass", translate("menu.tools.gotoDocumentClass"), "gotomainclass32", this::gotoDucumentClassActionPerformed, PRIORITY_TOP, null, true, null, false); finishMenu("/tools"); //Settings - addMenuItem("/settings", translate("menu.settings"), null, null, 0, null, false, null); + addMenuItem("/settings", translate("menu.settings"), null, null, 0, null, false, null, false); addToggleMenuItem("/settings/autoDeobfuscation", translate("menu.settings.autodeobfuscation"), null, null, this::autoDeobfuscationActionPerformed, 0, null); addToggleMenuItem("/settings/internalViewer", translate("menu.settings.internalflashviewer"), null, null, this::internalViewerSwitchActionPerformed, 0, null); @@ -888,11 +897,11 @@ public abstract class MainFrameMenu implements MenuBuilder { addToggleMenuItem("/settings/associate", translate("menu.settings.addtocontextmenu"), null, null, this::associateActionPerformed, 0, null); } - addMenuItem("/settings/language", translate("menu.language"), null, null, 0, null, false, null); - addMenuItem("/settings/language/setLanguage", translate("menu.settings.language"), "setlanguage32", this::setLanguageActionPerformed, PRIORITY_TOP, null, true, null); + addMenuItem("/settings/language", translate("menu.language"), null, null, 0, null, false, null, false); + addMenuItem("/settings/language/setLanguage", translate("menu.settings.language"), "setlanguage32", this::setLanguageActionPerformed, PRIORITY_TOP, null, true, null, false); finishMenu("/settings/language"); - /*addMenuItem("/settings/deobfuscation", translate("menu.deobfuscation"), null, null, 0, null, false); + /*addMenuItem("/settings/deobfuscation", translate("menu.deobfuscation"), null, null, 0, null, false,false); addToggleMenuItem("/settings/deobfuscation/old", translate("menu.file.deobfuscation.old"), "deobfuscation", "deobfuscateold16", (ActionEvent e) -> { deobfuscationMode(e, 0); }, 0); @@ -901,9 +910,9 @@ public abstract class MainFrameMenu implements MenuBuilder { }, 0); finishMenu("/settings/deobfuscation");*/ - addMenuItem("/settings/advancedSettings", translate("menu.advancedsettings.advancedsettings"), null, null, 0, null, false, null); - addMenuItem("/settings/advancedSettings/advancedSettings", translate("menu.advancedsettings.advancedsettings"), "settings32", this::advancedSettingsActionPerformed, PRIORITY_TOP, null, true, null); - addMenuItem("/settings/advancedSettings/clearRecentFiles", translate("menu.tools.otherTools.clearRecentFiles"), "clearrecent16", this::clearRecentFilesActionPerformed, PRIORITY_MEDIUM, null, true, null); + addMenuItem("/settings/advancedSettings", translate("menu.advancedsettings.advancedsettings"), null, null, 0, null, false, null, false); + addMenuItem("/settings/advancedSettings/advancedSettings", translate("menu.advancedsettings.advancedsettings"), "settings32", this::advancedSettingsActionPerformed, PRIORITY_TOP, null, true, null, false); + addMenuItem("/settings/advancedSettings/clearRecentFiles", translate("menu.tools.otherTools.clearRecentFiles"), "clearrecent16", this::clearRecentFilesActionPerformed, PRIORITY_MEDIUM, null, true, null, false); finishMenu("/settings/advancedSettings"); finishMenu("/settings"); @@ -962,27 +971,27 @@ public abstract class MainFrameMenu implements MenuBuilder { } //Help - addMenuItem("/help", translate("menu.help"), null, null, 0, null, false, null); - addMenuItem("/help/helpUs", translate("menu.help.helpus"), "donate32", this::helpUsActionPerformed, PRIORITY_TOP, null, true, null); - addMenuItem("/help/homePage", translate("menu.help.homepage"), "homepage16", this::homePageActionPerformed, PRIORITY_MEDIUM, null, true, null); + addMenuItem("/help", translate("menu.help"), null, null, 0, null, false, null, false); + addMenuItem("/help/helpUs", translate("menu.help.helpus"), "donate32", this::helpUsActionPerformed, PRIORITY_TOP, null, true, null, false); + addMenuItem("/help/homePage", translate("menu.help.homepage"), "homepage16", this::homePageActionPerformed, PRIORITY_MEDIUM, null, true, null, false); addSeparator("/help"); - addMenuItem("/help/checkUpdates", translate("menu.help.checkupdates"), "update16", this::checkUpdatesActionPerformed, PRIORITY_MEDIUM, null, true, null); - addMenuItem("/help/about", translate("menu.help.about"), "about32", this::aboutActionPerformed, PRIORITY_TOP, null, true, null); + addMenuItem("/help/checkUpdates", translate("menu.help.checkupdates"), "update16", this::checkUpdatesActionPerformed, PRIORITY_MEDIUM, null, true, null, false); + addMenuItem("/help/about", translate("menu.help.about"), "about32", this::aboutActionPerformed, PRIORITY_TOP, null, true, null, false); finishMenu("/help"); if (Configuration.showDebugMenu.get() || Configuration.debugMode.get()) { - addMenuItem("/debug", "Debug", null, null, 0, null, false, null); - addMenuItem("/debug/removeNonScripts", "Remove non scripts", "update16", e -> removeNonScripts(), PRIORITY_MEDIUM, null, true, null); - addMenuItem("/debug/refreshDecompiled", "Refresh decompiled script", "update16", e -> refreshDecompiled(), PRIORITY_MEDIUM, null, true, null); - addMenuItem("/debug/checkResources", "Check resources", "update16", e -> checkResources(), PRIORITY_MEDIUM, null, true, null); - addMenuItem("/debug/callGc", "Call System.gc()", "update16", e -> System.gc(), PRIORITY_MEDIUM, null, true, null); + addMenuItem("/debug", "Debug", null, null, 0, null, false, null, false); + addMenuItem("/debug/removeNonScripts", "Remove non scripts", "update16", e -> removeNonScripts(), PRIORITY_MEDIUM, null, true, null, false); + addMenuItem("/debug/refreshDecompiled", "Refresh decompiled script", "update16", e -> refreshDecompiled(), PRIORITY_MEDIUM, null, true, null, false); + addMenuItem("/debug/checkResources", "Check resources", "update16", e -> checkResources(), PRIORITY_MEDIUM, null, true, null, false); + addMenuItem("/debug/callGc", "Call System.gc()", "update16", e -> System.gc(), PRIORITY_MEDIUM, null, true, null, false); addMenuItem("/debug/emptyCache", "Empty cache", "update16", e -> { SWF nswf = mainFrame.getPanel().getCurrentSwf(); if (nswf != null) { nswf.clearAllCache(); } - }, PRIORITY_MEDIUM, null, true, null); + }, PRIORITY_MEDIUM, null, true, null, false); addMenuItem("/debug/memoryInformation", "Memory information", "update16", e -> { String architecture = System.getProperty("sun.arch.data.model"); Runtime runtime = Runtime.getRuntime(); @@ -995,13 +1004,13 @@ public abstract class MainFrameMenu implements MenuBuilder { if (nswf != null) { nswf.clearAllCache(); } - }, PRIORITY_MEDIUM, null, true, null); + }, PRIORITY_MEDIUM, null, true, null, false); addMenuItem("/debug/fixAs3Code", "Fix AS3 code", "update16", e -> { SWF nswf = mainFrame.getPanel().getCurrentSwf(); if (nswf != null) { nswf.fixAS3Code(); } - }, PRIORITY_MEDIUM, null, true, null); + }, PRIORITY_MEDIUM, null, true, null, false); addMenuItem("/debug/openTestSwfs", "Open test SWFs", "update16", e -> { String path; @@ -1012,7 +1021,7 @@ public abstract class MainFrameMenu implements MenuBuilder { path = mainPath + "\\..\\..\\libsrc\\ffdec_lib\\testdata\\as3\\as3.swf"; sourceInfos[1] = new SWFSourceInfo(null, path, null); Main.openFile(sourceInfos); - }, PRIORITY_MEDIUM, null, true, null); + }, PRIORITY_MEDIUM, null, true, null, false); finishMenu("/debug"); } @@ -1077,8 +1086,8 @@ public abstract class MainFrameMenu implements MenuBuilder { } } }; - addMenuItem("/file/" + (supportsMenuAction() ? "open" : "recent") + "/" + i, f, null, a, 0, null, true, null); - addMenuItem("_/open/" + i, f, null, a, 0, null, true, null); + addMenuItem("/file/" + (supportsMenuAction() ? "open" : "recent") + "/" + i, f, null, a, 0, null, true, null, false); + addMenuItem("_/open/" + i, f, null, a, 0, null, true, null, false); } finishMenu("/file/" + (supportsMenuAction() ? "open" : "recent")); @@ -1088,6 +1097,14 @@ public abstract class MainFrameMenu implements MenuBuilder { public void dispose() { KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); manager.removeKeyEventDispatcher(keyEventDispatcher); + + if (runProcess != null) { + try { + runProcess.destroy(); + } catch (Exception ex) { + + } + } } private Process runProcess; @@ -1119,43 +1136,79 @@ public abstract class MainFrameMenu implements MenuBuilder { } } - private void runPlayer(String exePath, String file, String flashVars) { - if (!new File(file).exists()) { - return; - } - final Process proc; + private void runPlayer(String title, final String exePath, String file, String flashVars) { if (flashVars != null && !flashVars.isEmpty()) { file += "?" + flashVars; } - try { - proc = Runtime.getRuntime().exec("\"" + exePath + "\" \"file://" + file + "\""); - - } catch (IOException ex) { - Logger.getLogger(MainFrameMenu.class - .getName()).log(Level.SEVERE, null, ex); - + if (!new File(file).exists()) { return; } - Thread t = new Thread() { + + final String ffile = file; + + CancellableWorker runWorker = new CancellableWorker() { @Override - public void run() { + protected Object doInBackground() throws Exception { + Process proc; try { - proc.waitFor(); + proc = Runtime.getRuntime().exec("\"" + exePath + "\" \"file://" + ffile + "\""); + } catch (IOException ex) { + Logger.getLogger(MainFrameMenu.class.getName()).log(Level.SEVERE, null, ex); + return null; + } + synchronized (this) { + runProcess = proc; + } + if (runProcessDebug) { + hilightPath("/debugging"); + } + updateComponents(); + try { + if (proc != null) { + proc.waitFor(); + } } catch (InterruptedException ex) { - //ignore + if (proc != null) { + try { + proc.destroy(); + } catch (Exception ex2) { + //ignore + } + } + } + freeRun(); + updateComponents(); + return null; + } + + @Override + protected void done() { + Main.stopWork(); + } + + @Override + public void workerCancelled() { + Main.stopWork(); + synchronized (MainFrameMenu.this) { + if (runProcess != null) { + try { + runProcess.destroy(); + } catch (Exception ex) { + + } + } } freeRun(); updateComponents(); } }; - t.start(); - synchronized (this) { - runProcess = proc; - } + updateComponents(); + Main.startWork(title + "...", runWorker); + runWorker.execute(); } public boolean runActionPerformed(ActionEvent evt) { @@ -1163,6 +1216,7 @@ public abstract class MainFrameMenu implements MenuBuilder { String playerLocation = Configuration.playerLocation.get(); if (playerLocation.isEmpty() || (!new File(playerLocation).exists())) { View.showMessageDialog(null, AppStrings.translate("message.playerpath.notset"), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); + Main.advancedSettings("paths"); return true; } if (swf == null) { @@ -1184,7 +1238,7 @@ public abstract class MainFrameMenu implements MenuBuilder { runTempFile = tempFile; runProcessDebug = false; } - runPlayer(playerLocation, tempFile.getAbsolutePath(), flashVars); + runPlayer(AppStrings.translate("work.running"), playerLocation, tempFile.getAbsolutePath(), flashVars); } return true; } @@ -1194,47 +1248,69 @@ public abstract class MainFrameMenu implements MenuBuilder { String playerLocation = Configuration.playerDebugLocation.get(); if (playerLocation.isEmpty() || (!new File(playerLocation).exists())) { View.showMessageDialog(null, AppStrings.translate("message.playerpath.debug.notset"), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); + Main.advancedSettings("paths"); return true; } if (swf == null) { return true; } - File tempFile; + File tempFile = null; + try { tempFile = File.createTempFile("ffdec_debug_", ".swf"); + } catch (Exception ex) { - try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(tempFile))) { - swf.saveTo(fos); - } - //Inject Loader - SWF instrSWF = null; - try (FileInputStream fis = new FileInputStream(tempFile)) { - instrSWF = new SWF(fis, false, false); + } + if (tempFile != null) { + final File fTempFile = tempFile; + CancellableWorker instrumentWorker = new CancellableWorker() { - } catch (InterruptedException ex) { - Logger.getLogger(MainFrameMenu.class - .getName()).log(Level.SEVERE, null, ex); - } - if (instrSWF != null) { - instrSWF.enableDebugging(true, new File(".")); - try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(tempFile))) { - instrSWF.saveTo(fos); + @Override + protected Object doInBackground() throws Exception { + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(fTempFile))) { + swf.saveTo(fos); + } + //Inject Loader + SWF instrSWF = null; + try (FileInputStream fis = new FileInputStream(fTempFile)) { + instrSWF = new SWF(fis, false, false); + + } catch (InterruptedException ex) { + Logger.getLogger(MainFrameMenu.class + .getName()).log(Level.SEVERE, null, ex); + } + if (instrSWF != null) { + instrSWF.enableDebugging(true, new File(".")); + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(fTempFile))) { + instrSWF.saveTo(fos); + } + } + return null; } - } - } catch (IOException ex) { - Logger.getLogger(MainFrameMenu.class - .getName()).log(Level.SEVERE, "Cannot inject debug info", ex); + @Override + public void workerCancelled() { + Main.stopWork(); + } - return true; + @Override + protected void done() { + synchronized (MainFrameMenu.this) { + runTempFile = fTempFile; + runProcessDebug = true; + } + Main.stopWork(); + runPlayer(AppStrings.translate("work.debugging"), playerLocation, fTempFile.getAbsolutePath(), flashVars); + } + + }; + + Main.startWork(AppStrings.translate("work.debugging.instrumenting"), instrumentWorker); + instrumentWorker.execute(); } - synchronized (this) { - runTempFile = tempFile; - runProcessDebug = true; - } - runPlayer(playerLocation, tempFile.getAbsolutePath(), flashVars); return true; + } public boolean stopActionPerformed(ActionEvent evt) { @@ -1267,6 +1343,8 @@ public abstract class MainFrameMenu implements MenuBuilder { DebuggerCommands cmd = Main.getDebugHandler().getCommands(); mainFrame.getPanel().clearDebuggerColors(); + Main.startWork(AppStrings.translate("work.debugging") + "...", null); + cmd.stepOver(); } catch (IOException ex) { Main.getDebugHandler().disconnect(); @@ -1279,6 +1357,8 @@ public abstract class MainFrameMenu implements MenuBuilder { try { DebuggerCommands cmd = Main.getDebugHandler().getCommands(); mainFrame.getPanel().clearDebuggerColors(); + Main.startWork(AppStrings.translate("work.debugging") + "...", null); + cmd.stepInto(); } catch (IOException ex) { Main.getDebugHandler().disconnect(); @@ -1292,7 +1372,7 @@ public abstract class MainFrameMenu implements MenuBuilder { try { DebuggerCommands cmd = Main.getDebugHandler().getCommands(); mainFrame.getPanel().clearDebuggerColors(); - + Main.startWork(AppStrings.translate("work.debugging") + "...", null); cmd.stepOut(); } catch (IOException ex) { Main.getDebugHandler().disconnect(); @@ -1306,6 +1386,8 @@ public abstract class MainFrameMenu implements MenuBuilder { try { DebuggerCommands cmd = Main.getDebugHandler().getCommands(); mainFrame.getPanel().clearDebuggerColors(); + Main.startWork(AppStrings.translate("work.debugging") + "...", null); + cmd.sendContinue(); } catch (IOException ex) { Main.getDebugHandler().disconnect(); @@ -1362,4 +1444,8 @@ public abstract class MainFrameMenu implements MenuBuilder { return false; } + + public abstract void hilightPath(String path); + + public abstract void setPathVisible(String path, boolean val); } diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java index 15b941bfa..13bc79a8c 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java @@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.gui; import com.jpexs.decompiler.flash.configuration.Configuration; import java.awt.BorderLayout; +import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; @@ -46,6 +47,7 @@ import org.pushingpixels.flamingo.api.ribbon.JRibbonComponent; import org.pushingpixels.flamingo.api.ribbon.RibbonApplicationMenu; import org.pushingpixels.flamingo.api.ribbon.RibbonApplicationMenuEntryFooter; import org.pushingpixels.flamingo.api.ribbon.RibbonApplicationMenuEntryPrimary; +import org.pushingpixels.flamingo.api.ribbon.RibbonContextualTaskGroup; import org.pushingpixels.flamingo.api.ribbon.RibbonElementPriority; import org.pushingpixels.flamingo.api.ribbon.RibbonTask; import org.pushingpixels.flamingo.api.ribbon.resize.BaseRibbonBandResizePolicy; @@ -66,6 +68,8 @@ public class MainFrameRibbonMenu extends MainFrameMenu { private final Map menuTitles = new HashMap<>(); + private final Map menuOptional = new HashMap<>(); + private final Map menuIcons = new HashMap<>(); private final Map menuLoaders = new HashMap<>(); @@ -88,6 +92,8 @@ public class MainFrameRibbonMenu extends MainFrameMenu { private static final int TYPE_TOGGLEMENUITEM = 3; + private Map optinalGroups = new HashMap<>(); + public MainFrameRibbonMenu(MainFrameRibbon mainFrame, JRibbon ribbon, boolean externalFlashPlayerUnavailable) { super(mainFrame, externalFlashPlayerUnavailable); this.ribbon = ribbon; @@ -268,6 +274,12 @@ public class MainFrameRibbonMenu extends MainFrameMenu { String subIcon = menuIcons.get(sub); String subGroup = menuGroup.get(sub); HotKey subKey = menuHotkeys.get(sub); + if (subKey != null) { + String keyStr = subKey.toString(); + if (keyStr.length() < 8) { + subTitle += " (" + keyStr + ")"; + } + } int subPriority = menuPriorities.get(sub); final ActionListener subLoader = menuLoaders.get(sub); AbstractCommandButton but = null; @@ -381,7 +393,15 @@ public class MainFrameRibbonMenu extends MainFrameMenu { continue; } if (menuItems.get(sub) instanceof RibbonTask) { - ribbon.addTask((RibbonTask) menuItems.get(sub)); + RibbonTask rt = (RibbonTask) menuItems.get(sub); + if (menuOptional.get(sub)) { + RibbonContextualTaskGroup rct = new RibbonContextualTaskGroup("", new Color(128, 0, 0), rt); + ribbon.addContextualTaskGroup(rct); + optinalGroups.put(sub, rct); + //ribbon.setVisible(rct, false); + } else { + ribbon.addTask(rt); + } } } } else if (parts.length == 2) { //2nd level - it's a Task! @@ -413,11 +433,12 @@ public class MainFrameRibbonMenu extends MainFrameMenu { } @Override - public void addMenuItem(String path, String title, String icon, ActionListener action, int priority, ActionListener subLoader, boolean isLeaf, HotKey key) { + public void addMenuItem(String path, String title, String icon, ActionListener action, int priority, ActionListener subLoader, boolean isLeaf, HotKey key, boolean isOptional) { String parentPath = path.contains("/") ? path.substring(0, path.lastIndexOf('/')) : ""; if (!menuSubs.containsKey(parentPath)) { throw new IllegalArgumentException("No parent menu exists: " + parentPath); } + menuOptional.put(path, isOptional); menuHotkeys.put(path, key); menuSubs.get(parentPath).add(path); if (!isLeaf) { @@ -433,7 +454,7 @@ public class MainFrameRibbonMenu extends MainFrameMenu { @Override public void addToggleMenuItem(String path, String title, String group, String icon, ActionListener action, int priority, HotKey key) { - addMenuItem(path, title, icon, action, priority, action, true, key); + addMenuItem(path, title, icon, action, priority, action, true, key, false); menuType.put(path, TYPE_TOGGLEMENUITEM); menuGroup.put(path, group); if (group == null) { @@ -561,4 +582,41 @@ public class MainFrameRibbonMenu extends MainFrameMenu { return true; } + @Override + public void setPathVisible(String path, boolean val) { + Object o = menuItems.get(path); + if (o instanceof RibbonTask) { + if (menuOptional.get(path)) { + RibbonContextualTaskGroup rg = optinalGroups.get(path); + + if (ribbon.isVisible(rg) != val) { + View.execInEventDispatch(new Runnable() { + + @Override + public void run() { + ribbon.setVisible(rg, val); + } + }); + + } + } + } + } + + @Override + public void hilightPath(String path) { + Object o = menuItems.get(path); + if (o instanceof RibbonTask) { + RibbonTask rt = (RibbonTask) o; + View.execInEventDispatch(new Runnable() { + + @Override + public void run() { + ribbon.setSelectedTask(rt); + } + }); + + } + } + } diff --git a/src/com/jpexs/decompiler/flash/gui/MenuBuilder.java b/src/com/jpexs/decompiler/flash/gui/MenuBuilder.java index fb6150dfc..12c4a4c91 100644 --- a/src/com/jpexs/decompiler/flash/gui/MenuBuilder.java +++ b/src/com/jpexs/decompiler/flash/gui/MenuBuilder.java @@ -195,7 +195,7 @@ public interface MenuBuilder { * @param subloader Action which loads menu inside * @param isLeaf Has no subitems? */ - public void addMenuItem(String path, String title, String icon, ActionListener action, int priority, ActionListener subloader, boolean isLeaf, HotKey key); + public void addMenuItem(String path, String title, String icon, ActionListener action, int priority, ActionListener subloader, boolean isLeaf, HotKey key, boolean isOptional); /** * Adds toggle item (radio/checkbox) diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java index a0e0f1f54..d2c7a4bfb 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java @@ -17,6 +17,9 @@ package com.jpexs.decompiler.flash.gui.abc; import com.jpexs.debugger.flash.Variable; +import com.jpexs.debugger.flash.messages.in.InBreakAtExt; +import com.jpexs.debugger.flash.messages.in.InBreakReason; +import com.jpexs.debugger.flash.messages.in.InFrame; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.ClassPath; @@ -149,7 +152,16 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener tableListeners = new ArrayList<>(); + private List vars; - public VariablesTableModel() { - varChangeListener = new DebuggerHandler.VariableChangedListener() { - private int oldNum = 0; - - @Override - public void variablesChanged() { - for (int i = 0; i < oldNum; i++) { - for (TableModelListener l : tableListeners) { - l.tableChanged(new TableModelEvent(VariablesTableModel.this, i, i, 0, TableModelEvent.DELETE)); - } - } - oldNum = 1 + Main.getDebugHandler().getNumVariables() + Main.getDebugHandler().getNumRegisters(); - for (TableModelListener l : tableListeners) { - l.tableChanged(new TableModelEvent(VariablesTableModel.this, 0, oldNum - 1, 0, TableModelEvent.INSERT)); - } - - } - }; - Main.getDebugHandler().addVariableChangedListener(varChangeListener); + public VariablesTableModel(List vars) { + this.vars = vars; } @Override public int getRowCount() { - return (Main.getDebugHandler().getFrameVariable() == null ? 0 : 1) + Main.getDebugHandler().getNumRegisters() + Main.getDebugHandler().getNumVariables(); + return vars.size(); } @Override @@ -305,11 +300,11 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener= numReg + 1) { - v = Main.getDebugHandler().getVariable(rowIndex - 1 - numReg); - } else { - v = Main.getDebugHandler().getRegister(rowIndex - 1); - } + Variable v = vars.get(rowIndex); switch (columnIndex) { case 0: @@ -357,7 +344,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener())); + debugLocalsTable = new JTable(new VariablesTableModel(new ArrayList<>())); + //debugArgumentsTable = new JTable(new VariablesTableModel(new ArrayList<>())); + debugScopeTable = new JTable(new VariablesTableModel(new ArrayList<>())); + callStackTable = new JTable(); + stackTable = new JTable(); + + Main.getDebugHandler().addVariableChangedListener(new DebuggerHandler.VariableChangedListener() { + + @Override + public void variablesChanged() { + InFrame f = Main.getDebugHandler().getFrame(); + if (f != null) { + debugRegistersTable.setModel(new VariablesTableModel(f.registers)); + List locals = new ArrayList<>(); + locals.addAll(f.arguments); + locals.addAll(f.variables); + debugLocalsTable.setModel(new VariablesTableModel(locals)); + //debugArgumentsTable.setModel(new VariablesTableModel(f.arguments)); + debugScopeTable.setModel(new VariablesTableModel(f.scopeChain)); + debugPanel.setVisible(true); + } else { + debugPanel.setVisible(false); + return; + } + InBreakAtExt info = Main.getDebugHandler().getBreakInfo(); + if (info != null) { + //InBreakReason reason = Main.getDebugHandler().getBreakReason(); + List callStackFiles = new ArrayList<>(); + List callStackLines = new ArrayList<>(); + + callStackFiles.add(Main.getDebugHandler().moduleToString(info.file)); + callStackLines.add(info.line); + + for (int i = 0; i < info.files.size(); i++) { + callStackFiles.add(Main.getDebugHandler().moduleToString(info.files.get(i))); + callStackLines.add(info.lines.get(i)); + } + Object[][] data = new Object[callStackFiles.size()][2]; + for (int i = 0; i < callStackFiles.size(); i++) { + data[i][0] = callStackFiles.get(i); + data[i][1] = callStackLines.get(i); + } + + DefaultTableModel tm = new DefaultTableModel(data, new Object[]{ + AppStrings.translate("callStack.header.file"), + AppStrings.translate("callStack.header.line") + }); + callStackTable.setModel(tm); + + Object[][] data2 = new Object[info.stacks.size()][1]; + for (int i = 0; i < info.stacks.size(); i++) { + data2[i][0] = info.stacks.get(i); + } + stackTable.setModel(new DefaultTableModel(data2, new Object[]{AppStrings.translate("stack.header.item")})); + } else { + callStackTable.setModel(new DefaultTableModel()); + stackTable.setModel(new DefaultTableModel()); + } + + varTabs.removeAll(); + JPanel pa; + if (debugRegistersTable.getRowCount() > 0) { + pa = new JPanel(new BorderLayout()); + pa.add(new JScrollPane(debugRegistersTable), BorderLayout.CENTER); + varTabs.addTab(AppStrings.translate("variables.header.registers"), pa); + } + if (debugLocalsTable.getRowCount() > 0) { + pa = new JPanel(new BorderLayout()); + pa.add(new JScrollPane(debugLocalsTable), BorderLayout.CENTER); + varTabs.addTab(AppStrings.translate("variables.header.locals"), pa); + } + + if (debugScopeTable.getRowCount() > 0) { + pa = new JPanel(new BorderLayout()); + pa.add(new JScrollPane(debugScopeTable), BorderLayout.CENTER); + varTabs.addTab(AppStrings.translate("variables.header.scopeChain"), pa); + } + + if (callStackTable.getRowCount() > 0) { + pa = new JPanel(new BorderLayout()); + pa.add(new JScrollPane(callStackTable), BorderLayout.CENTER); + varTabs.addTab(AppStrings.translate("callStack.header"), pa); + } + if (stackTable.getRowCount() > 0) { + pa = new JPanel(new BorderLayout()); + pa.add(new JScrollPane(stackTable), BorderLayout.CENTER); + varTabs.addTab(AppStrings.translate("stack.header"), pa); + } + varTabs.setSelectedIndex(0); + + } + }); + + varTabs = new JTabbedPane(); + + debugPanel.add(new HeaderLabel(AppStrings.translate("debugpanel.header")), BorderLayout.NORTH); + debugPanel.add(new JScrollPane(varTabs), BorderLayout.CENTER); + + JPersistentSplitPane sp2; + + panB.add(sp2 = new JPersistentSplitPane(JSplitPane.VERTICAL_SPLIT, decPanel, debugPanel, Configuration.guiAvm2VarsSplitPaneDividerLocationPercent), BorderLayout.CENTER); + sp2.setContinuousLayout(true); + + debugPanel.setVisible(false); + decLabel.setHorizontalAlignment(SwingConstants.CENTER); //decLabel.setBorder(new BevelBorder(BevelBorder.RAISED)); splitPane = new JPersistentSplitPane(JSplitPane.HORIZONTAL_SPLIT, panB, detailPanel, Configuration.guiAvm2SplitPaneDividerLocationPercent); @@ -813,23 +917,14 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener