diff --git a/src/com/jpexs/decompiler/flash/gui/ErrorLogFrame.java b/src/com/jpexs/decompiler/flash/gui/ErrorLogFrame.java index bc4850cee..d37d9439c 100644 --- a/src/com/jpexs/decompiler/flash/gui/ErrorLogFrame.java +++ b/src/com/jpexs/decompiler/flash/gui/ErrorLogFrame.java @@ -126,10 +126,7 @@ public class ErrorLogFrame extends AppFrame { clearButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - logViewInner.removeAll(); - Main.clearLogFile(); - revalidate(); - repaint(); + clearLog(); } }); buttonsPanel.add(clearButton); @@ -159,6 +156,13 @@ public class ErrorLogFrame extends AppFrame { }; handler.setLevel(Level.WARNING); } + + public void clearLog() { + logViewInner.removeAll(); + Main.clearLogFile(); + revalidate(); + repaint(); + } public void clearErrorState() { errorState = ErrorState.NO_ERROR; diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameClassicMenu.java b/src/com/jpexs/decompiler/flash/gui/MainFrameClassicMenu.java index ac57a4685..518dcbd13 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameClassicMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameClassicMenu.java @@ -16,7 +16,6 @@ */ package com.jpexs.decompiler.flash.gui; -import com.jpexs.decompiler.flash.ApplicationInfo; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.console.ContextMenuTools; @@ -53,7 +52,7 @@ public class MainFrameClassicMenu extends MainFrameMenu implements ActionListene private static final String ACTION_GOTO_DOCUMENT_CLASS = "GOTODOCUMENTCLASS"; private static final String ACTION_PARALLEL_SPEED_UP = "PARALLELSPEEDUP"; private static final String ACTION_INTERNAL_VIEWER_SWITCH = "INTERNALVIEWERSWITCH"; - private static final String ACTION_SEARCH_AS = "SEARCHAS"; + private static final String ACTION_SEARCH = "SEARCH"; private static final String ACTION_AUTO_DEOBFUSCATE = "AUTODEOBFUSCATE"; private static final String ACTION_EXIT = "EXIT"; @@ -97,8 +96,8 @@ public class MainFrameClassicMenu extends MainFrameMenu implements ActionListene private JMenuItem exportSelectionCommandButton; private JMenuItem reloadCommandButton; - private JMenuItem renameinvalidCommandButton; - private JMenuItem globalrenameCommandButton; + private JMenuItem renameInvalidCommandButton; + private JMenuItem globalRenameCommandButton; private JMenuItem deobfuscationCommandButton; private JMenuItem searchCommandButton; private JMenuItem gotoDocumentClassCommandButton; @@ -214,7 +213,7 @@ public class MainFrameClassicMenu extends MainFrameMenu implements ActionListene JMenuItem miSearchScript = new JMenuItem(translate("menu.tools.searchas")); miSearchScript.addActionListener(this); - miSearchScript.setActionCommand(ACTION_SEARCH_AS); + miSearchScript.setActionCommand(ACTION_SEARCH); miSearchScript.setIcon(View.getIcon("search16")); menuTools.add(miSearchScript); @@ -341,8 +340,8 @@ public class MainFrameClassicMenu extends MainFrameMenu implements ActionListene exportSelectionCommandButton.setEnabled(swfLoaded); reloadCommandButton.setEnabled(swfLoaded); - renameinvalidCommandButton.setEnabled(swfLoaded); - globalrenameCommandButton.setEnabled(swfLoaded); + renameInvalidCommandButton.setEnabled(swfLoaded); + globalRenameCommandButton.setEnabled(swfLoaded); deobfuscationCommandButton.setEnabled(swfLoaded); searchCommandButton.setEnabled(swfLoaded); @@ -354,18 +353,16 @@ public class MainFrameClassicMenu extends MainFrameMenu implements ActionListene public void actionPerformed(ActionEvent e) { switch (e.getActionCommand()) { case ACTION_RELOAD: - if (View.showConfirmDialog(null, translate("message.confirm.reload"), translate("message.warning"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) { - Main.reloadApp(); - } + reload(); break; case ACTION_ADVANCED_SETTINGS: - Main.advancedSettings(); + advancedSettings(); break; case ACTION_LOAD_MEMORY: - Main.loadFromMemory(); + loadFromMemory(); break; case ACTION_LOAD_CACHE: - Main.loadFromCache(); + loadFromCache(); break; case ACTION_GOTO_DOCUMENT_CLASS_ON_STARTUP: Configuration.gotoMainClassOnStartup.set(miGotoMainClassOnStartup.isSelected()); @@ -382,7 +379,7 @@ public class MainFrameClassicMenu extends MainFrameMenu implements ActionListene } break; case ACTION_SET_LANGUAGE: - new SelectLanguageDialog().display(); + setLanguage(); break; case ACTION_DISABLE_DECOMPILATION: Configuration.decompile.set(!miDecompile.isSelected()); @@ -394,13 +391,13 @@ public class MainFrameClassicMenu extends MainFrameMenu implements ActionListene } ContextMenuTools.addToContextMenu(miAssociate.isSelected(), false); - //Update checkbox menuitem accordingly (User can cancel rights elevation) + // Update checkbox menuitem accordingly (User can cancel rights elevation) new Timer().schedule(new TimerTask() { @Override public void run() { miAssociate.setSelected(ContextMenuTools.isAddedToContextMenu()); } - }, 1000); //It takes some time registry change to apply + }, 1000); // It takes some time registry change to apply break; case ACTION_GOTO_DOCUMENT_CLASS: mainFrame.getPanel().gotoDocumentClass(mainFrame.getPanel().getCurrentSwf()); @@ -422,7 +419,7 @@ public class MainFrameClassicMenu extends MainFrameMenu implements ActionListene Configuration.internalFlashViewer.set(miInternalViewer.isSelected()); mainFrame.getPanel().reload(true); break; - case ACTION_SEARCH_AS: + case ACTION_SEARCH: search(false); break; case ACTION_AUTO_DEOBFUSCATE: @@ -434,13 +431,7 @@ public class MainFrameClassicMenu extends MainFrameMenu implements ActionListene } break; case ACTION_EXIT: - mainFrame.getPanel().setVisible(false); - if (Main.proxyFrame != null) { - if (Main.proxyFrame.isVisible()) { - return; - } - } - Main.exit(); + exit(); break; } @@ -450,81 +441,63 @@ public class MainFrameClassicMenu extends MainFrameMenu implements ActionListene switch (e.getActionCommand()) { case ACTION_RENAME_ONE_IDENTIFIER: - mainFrame.getPanel().renameOneIdentifier(mainFrame.getPanel().getCurrentSwf()); - break; - case ACTION_ABOUT: - Main.about(); + renameOneIdentifier(); break; case ACTION_SHOW_PROXY: - Main.showProxy(); + showProxy(); break; case ACTION_SUB_LIMITER: - if (e.getSource() instanceof JCheckBoxMenuItem) { - Main.setSubLimiter(((JCheckBoxMenuItem) e.getSource()).getState()); - } + setSubLimiter(((JCheckBoxMenuItem) e.getSource()).isSelected()); break; case ACTION_SAVE: save(); break; - case ACTION_SAVE_AS: { - SWF swf = mainFrame.getPanel().getCurrentSwf(); - if (swf != null && saveAs(swf, SaveFileMode.SAVEAS)) { - swf.clearModified(); - } - } - break; - case ACTION_SAVE_AS_EXE: { - SWF swf = mainFrame.getPanel().getCurrentSwf(); - if (swf != null) { - saveAs(swf, SaveFileMode.EXE); - } - } - break; + case ACTION_SAVE_AS: + saveAs(); + break; + case ACTION_SAVE_AS_EXE: + saveAsExe(); + break; case ACTION_OPEN: open(); break; - case ACTION_EXPORT_FLA: - mainFrame.getPanel().exportFla(mainFrame.getPanel().getCurrentSwf()); - break; case ACTION_EXPORT_SEL: case ACTION_EXPORT: - boolean onlySel = e.getActionCommand().endsWith("SEL"); - mainFrame.getPanel().export(onlySel); + boolean onlySel = e.getActionCommand().equals(ACTION_EXPORT_SEL); + export(onlySel); + break; + case ACTION_EXPORT_FLA: + exportFla(); break; case ACTION_CHECK_UPDATES: - if (!Main.checkForUpdates()) { - View.showMessageDialog(null, translate("update.check.nonewversion"), translate("update.check.title"), JOptionPane.INFORMATION_MESSAGE); - } + checkUpdates(); break; case ACTION_HELP_US: - String helpUsURL = ApplicationInfo.PROJECT_PAGE + "/help_us.html"; - if (!View.navigateUrl(helpUsURL)) { - View.showMessageDialog(null, translate("message.helpus").replace("%url%", helpUsURL)); - } + helpUs(); break; case ACTION_HOMEPAGE: - String homePageURL = ApplicationInfo.PROJECT_PAGE; - if (!View.navigateUrl(homePageURL)) { - View.showMessageDialog(null, translate("message.homepage").replace("%url%", homePageURL)); - } + homePage(); + break; + case ACTION_ABOUT: + about(); break; case ACTION_RESTORE_CONTROL_FLOW: case ACTION_RESTORE_CONTROL_FLOW_ALL: - boolean all = e.getActionCommand().endsWith("ALL"); - mainFrame.getPanel().restoreControlFlow(all); + boolean all = e.getActionCommand().equals(ACTION_RESTORE_CONTROL_FLOW_ALL); + restoreControlFlow(all); break; case ACTION_RENAME_IDENTIFIERS: - mainFrame.getPanel().renameIdentifiers(mainFrame.getPanel().getCurrentSwf()); + renameIdentifiers(); break; case ACTION_DEOBFUSCATE: case ACTION_DEOBFUSCATE_ALL: - mainFrame.getPanel().deobfuscate(); + deobfuscate(); break; case ACTION_REMOVE_NON_SCRIPTS: - mainFrame.getPanel().removeNonScripts(mainFrame.getPanel().getCurrentSwf()); + removeNonScripts(); break; case ACTION_REFRESH_DECOMPILED: - mainFrame.getPanel().refreshDecompiled(); + refreshDecompiled(); break; } } diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java b/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java index d6b031a5e..f576ba33f 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java @@ -19,14 +19,23 @@ package com.jpexs.decompiler.flash.gui; import com.jpexs.decompiler.flash.ApplicationInfo; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.gui.helpers.CheckResources; import com.jpexs.helpers.ByteArrayRange; +import com.jpexs.helpers.utf8.Utf8Helper; +import java.awt.BorderLayout; +import java.awt.Container; +import java.awt.Dimension; import java.awt.KeyEventDispatcher; import java.awt.KeyboardFocusManager; +import java.awt.ScrollPane; import java.awt.event.KeyEvent; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.PrintStream; import java.util.logging.Level; import java.util.logging.Logger; +import javax.swing.JDialog; +import javax.swing.JEditorPane; import javax.swing.JFrame; import javax.swing.JOptionPane; @@ -50,12 +59,12 @@ public abstract class MainFrameMenu { return mainFrame.translate(key); } - protected void open() { + protected boolean open() { Main.openFileDialog(); + return true; } - protected void save() { - SWF swf = mainFrame.getPanel().getCurrentSwf(); + protected boolean save() { if (swf != null) { boolean saved = false; if (swf.binaryData != null) { @@ -82,20 +91,202 @@ public abstract class MainFrameMenu { if (saved) { swf.clearModified(); } + + return true; } + + return false; } - protected boolean saveAs(SWF swf, SaveFileMode mode) { + protected boolean saveAs() { + if (swf != null) { + if (saveAs(swf, SaveFileMode.SAVEAS)) { + swf.clearModified(); + } + + return true; + } + + return false; + } + + private boolean saveAs(SWF swf, SaveFileMode mode) { if (Main.saveFileDialog(swf, mode)) { mainFrame.setTitle(ApplicationInfo.applicationVerName + (Configuration.displayFileName.get() ? " - " + swf.getFileTitle() : "")); - updateComponents(mainFrame.getPanel().getCurrentSwf()); + updateComponents(swf); return true; } return false; } - protected void search(boolean searhInText) { - mainFrame.getPanel().searchInActionScriptOrText(searhInText); + protected void saveAsExe() { + if (swf != null) { + saveAs(swf, SaveFileMode.EXE); + } + } + + protected void close() { + Main.closeFile(mainFrame.getPanel().getCurrentSwfList()); + } + + protected boolean closeAll() { + if (swf != null) { + Main.closeAll(); + return true; + } + + return false; + } + + protected void importText() { + mainFrame.getPanel().importText(swf); + } + + protected boolean export(boolean onlySelected) { + if (swf != null) { + mainFrame.getPanel().export(onlySelected); + return true; + } + + return false; + } + + protected void exportFla() { + mainFrame.getPanel().exportFla(swf); + } + + protected boolean search(boolean searhInText) { + if (swf != null) { + mainFrame.getPanel().searchInActionScriptOrText(searhInText); + return true; + } + + return false; + } + + protected void restoreControlFlow(boolean all) { + mainFrame.getPanel().restoreControlFlow(all); + } + + protected void showProxy() { + Main.showProxy(); + } + + protected boolean clearLog() { + ErrorLogFrame.getInstance().clearLog(); + return true; + } + + protected void renameOneIdentifier() { + mainFrame.getPanel().renameOneIdentifier(swf); + } + + protected void renameIdentifiers() { + mainFrame.getPanel().renameIdentifiers(swf); + } + + protected void deobfuscate() { + mainFrame.getPanel().deobfuscate(); + } + + protected void setSubLimiter(boolean value) { + Main.setSubLimiter(value); + } + + protected void removeNonScripts() { + mainFrame.getPanel().removeNonScripts(swf); + } + + protected void refreshDecompiled() { + mainFrame.getPanel().refreshDecompiled(); + } + + protected void checkResources() { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + PrintStream stream = new PrintStream(os); + CheckResources.checkResources(stream); + final String str = new String(os.toByteArray(), Utf8Helper.charset); + JDialog dialog = new JDialog() { + + @Override + public void setVisible(boolean bln) { + setSize(new Dimension(800, 600)); + Container cnt = getContentPane(); + cnt.setLayout(new BorderLayout()); + ScrollPane scrollPane = new ScrollPane(); + JEditorPane editor = new JEditorPane(); + editor.setEditable(false); + editor.setText(str); + scrollPane.add(editor); + this.add(scrollPane, BorderLayout.CENTER); + this.setModal(true); + View.centerScreen(this); + super.setVisible(bln); + } + }; + dialog.setVisible(true); + } + + protected void checkUpdates() { + if (!Main.checkForUpdates()) { + View.showMessageDialog(null, translate("update.check.nonewversion"), translate("update.check.title"), JOptionPane.INFORMATION_MESSAGE); + } + } + + protected void helpUs() { + String helpUsURL = ApplicationInfo.PROJECT_PAGE + "/help_us.html"; + if (!View.navigateUrl(helpUsURL)) { + View.showMessageDialog(null, translate("message.helpus").replace("%url%", helpUsURL)); + } + } + + protected void homePage() { + String homePageURL = ApplicationInfo.PROJECT_PAGE; + if (!View.navigateUrl(homePageURL)) { + View.showMessageDialog(null, translate("message.homepage").replace("%url%", homePageURL)); + } + } + + protected void about() { + Main.about(); + } + + protected boolean reload() { + if (swf != null) { + if (View.showConfirmDialog(null, translate("message.confirm.reload"), translate("message.warning"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) { + Main.reloadApp(); + } + + return true; + } + + return false; + } + + protected void advancedSettings() { + Main.advancedSettings(); + } + + protected void loadFromMemory() { + Main.loadFromMemory(); + } + + protected void loadFromCache() { + Main.loadFromCache(); + } + + protected void setLanguage() { + new SelectLanguageDialog().display(); + } + + protected void exit() { + mainFrame.getPanel().setVisible(false); + if (Main.proxyFrame != null) { + if (Main.proxyFrame.isVisible()) { + return; + } + } + Main.exit(); } public void updateComponents(SWF swf) { @@ -110,30 +301,27 @@ public abstract class MainFrameMenu { @Override public boolean dispatchKeyEvent(KeyEvent e) { if (((JFrame) mainFrame).isActive()) { + int code = e.getKeyCode(); if (e.isControlDown() && e.isShiftDown()) { - int code = e.getKeyCode(); switch (code) { case KeyEvent.VK_O: - open(); - return true; + return open(); case KeyEvent.VK_S: - if (swf != null) { - save(); - return true; - } - break; + return save(); + case KeyEvent.VK_A: + return saveAs(); case KeyEvent.VK_F: - if (swf != null) { - search(false); - return true; - } - break; + return search(false); case KeyEvent.VK_T: - if (swf != null) { - search(true); - return true; - } - break; + return search(true); + case KeyEvent.VK_R: + return reload(); + case KeyEvent.VK_X: + return closeAll(); + case KeyEvent.VK_D: + return clearLog(); + case KeyEvent.VK_E: + return export(false); } } } diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java index 55c5ec840..571fb1548 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java @@ -16,32 +16,21 @@ */ package com.jpexs.decompiler.flash.gui; -import com.jpexs.decompiler.flash.ApplicationInfo; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.console.ContextMenuTools; -import com.jpexs.decompiler.flash.gui.helpers.CheckResources; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.helpers.Cache; -import com.jpexs.helpers.utf8.Utf8Helper; import com.jpexs.process.ProcessTools; import com.sun.jna.Platform; import java.awt.BorderLayout; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.ScrollPane; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; import java.util.ArrayList; import java.util.List; import java.util.Timer; import java.util.TimerTask; import javax.swing.JCheckBox; -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JDialog; -import javax.swing.JEditorPane; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.SwingUtilities; @@ -84,7 +73,6 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener private static final String ACTION_GOTO_DOCUMENT_CLASS = "GOTODOCUMENTCLASS"; private static final String ACTION_PARALLEL_SPEED_UP = "PARALLELSPEEDUP"; private static final String ACTION_INTERNAL_VIEWER_SWITCH = "INTERNALVIEWERSWITCH"; - private static final String ACTION_DUMP_VIEW_SWITCH = "DUMPVIEWSWITCH"; private static final String ACTION_SEARCH = "SEARCH"; private static final String ACTION_TIMELINE = "TIMELINE"; private static final String ACTION_AUTO_DEOBFUSCATE = "AUTODEOBFUSCATE"; @@ -120,8 +108,7 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener private static final String ACTION_CLEAR_RECENT_FILES = "CLEARRECENTFILES"; private static final String ACTION_CHECK_RESOURCES = "CHECKRESOURCES"; private static final String ACTION_VIEWMODE_RESOURCES = "VIEWMODERESOURCES"; - private static final String ACTION_VIEWMODE_HEX = "VIEWMODEHEX"; - private static final String ACTION_VIEWMODE_TIMELINE = "VIEWMODETIMELINE"; + private static final String ACTION_VIEWMODE_HEX_DUMP = "VIEWMODEHEXDUMP"; private static final String ACTION_DEOBFUSCATION_MODE_OLD = "DEOBFUSCATIONMODEOLD"; private static final String ACTION_DEOBFUSCATION_MODE_NEW = "DEOBFUSCATIONMODENEW"; @@ -129,7 +116,6 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener private JCheckBox miAutoDeobfuscation; private JCheckBox miInternalViewer; - private JCheckBox miDumpView; private JCheckBox miParallelSpeedUp; private JCheckBox miAssociate; private JCheckBox miDecompile; @@ -149,8 +135,8 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener private JCommandToggleButton deobfuscationModeNewToggleButton; private JCommandButton reloadCommandButton; - private JCommandButton renameinvalidCommandButton; - private JCommandButton globalrenameCommandButton; + private JCommandButton renameInvalidCommandButton; + private JCommandButton globalRenameCommandButton; private JCommandButton deobfuscationCommandButton; private JCommandButton searchCommandButton; private JCommandToggleButton timeLineToggleButton; @@ -367,7 +353,7 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener assignListener(viewModeResourcesToggleButton, ACTION_VIEWMODE_RESOURCES); viewModeHexToggleButton = new JCommandToggleButton(fixCommandTitle(translate("menu.file.view.hex")), View.getResizableIcon("viewhex16")); - assignListener(viewModeHexToggleButton, ACTION_VIEWMODE_HEX); + assignListener(viewModeHexToggleButton, ACTION_VIEWMODE_HEX_DUMP); viewModeToggleGroup.add(viewModeResourcesToggleButton); viewModeToggleGroup.add(viewModeHexToggleButton); @@ -411,7 +397,7 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener debuggerBand.addCommandButton(debuggerReplaceTraceCommandButton, RibbonElementPriority.MEDIUM); debuggerBand.addCommandButton(debuggerLogCommandButton, RibbonElementPriority.MEDIUM); - //----------------------------------------- TOOLS ----------------------------------- + // ----------------------------------------- TOOLS ----------------------------------- JRibbonBand toolsBand = new JRibbonBand(translate("menu.tools"), null); toolsBand.setResizePolicies(getResizePolicies(toolsBand)); @@ -450,14 +436,14 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener deobfuscationCommandButton = new JCommandButton(fixCommandTitle(translate("menu.tools.deobfuscation.pcode")), View.getResizableIcon("deobfuscate32")); assignListener(deobfuscationCommandButton, ACTION_DEOBFUSCATE); - globalrenameCommandButton = new JCommandButton(fixCommandTitle(translate("menu.tools.deobfuscation.globalrename")), View.getResizableIcon("rename16")); - assignListener(globalrenameCommandButton, ACTION_RENAME_ONE_IDENTIFIER); - renameinvalidCommandButton = new JCommandButton(fixCommandTitle(translate("menu.tools.deobfuscation.renameinvalid")), View.getResizableIcon("renameall16")); - assignListener(renameinvalidCommandButton, ACTION_RENAME_IDENTIFIERS); + globalRenameCommandButton = new JCommandButton(fixCommandTitle(translate("menu.tools.deobfuscation.globalrename")), View.getResizableIcon("rename16")); + assignListener(globalRenameCommandButton, ACTION_RENAME_ONE_IDENTIFIER); + renameInvalidCommandButton = new JCommandButton(fixCommandTitle(translate("menu.tools.deobfuscation.renameinvalid")), View.getResizableIcon("renameall16")); + assignListener(renameInvalidCommandButton, ACTION_RENAME_IDENTIFIERS); deobfuscationBand.addCommandButton(deobfuscationCommandButton, RibbonElementPriority.TOP); - deobfuscationBand.addCommandButton(globalrenameCommandButton, RibbonElementPriority.MEDIUM); - deobfuscationBand.addCommandButton(renameinvalidCommandButton, RibbonElementPriority.MEDIUM); + deobfuscationBand.addCommandButton(globalRenameCommandButton, RibbonElementPriority.MEDIUM); + deobfuscationBand.addCommandButton(renameInvalidCommandButton, RibbonElementPriority.MEDIUM); //JRibbonBand otherToolsBand = new JRibbonBand(translate("menu.tools.otherTools"), null); //otherToolsBand.setResizePolicies(getResizePolicies(otherToolsBand)); @@ -465,7 +451,7 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener } private RibbonTask createSettingsRibbonTask(boolean externalFlashPlayerUnavailable) { - //----------------------------------------- SETTINGS ----------------------------------- + // ----------------------------------------- SETTINGS ----------------------------------- JRibbonBand settingsBand = new JRibbonBand(translate("menu.settings"), null); settingsBand.setResizePolicies(getResizePolicies(settingsBand)); @@ -513,10 +499,6 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener miAutoRenameIdentifiers.setActionCommand(ACTION_AUTO_RENAME_IDENTIFIERS); miAutoRenameIdentifiers.addActionListener(this); - /*miDumpView = new JCheckBox(translate("menu.settings.dumpView")); - miDumpView.setSelected(Configuration.dumpView.get()); - miDumpView.setActionCommand(ACTION_DUMP_VIEW_SWITCH); - miDumpView.addActionListener(this);*/ settingsBand.addRibbonComponent(new JRibbonComponent(miAutoDeobfuscation)); settingsBand.addRibbonComponent(new JRibbonComponent(miInternalViewer)); settingsBand.addRibbonComponent(new JRibbonComponent(miParallelSpeedUp)); @@ -527,7 +509,6 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener settingsBand.addRibbonComponent(new JRibbonComponent(miCacheDisk)); settingsBand.addRibbonComponent(new JRibbonComponent(miGotoMainClassOnStartup)); settingsBand.addRibbonComponent(new JRibbonComponent(miAutoRenameIdentifiers)); - //settingsBand.addRibbonComponent(new JRibbonComponent(miDumpView)); JRibbonBand languageBand = new JRibbonBand(translate("menu.language"), null); List languageBandResizePolicies = getIconBandResizePolicies(languageBand); @@ -577,7 +558,7 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener } private RibbonTask createHelpRibbonTask() { - //----------------------------------------- HELP ----------------------------------- + // ----------------------------------------- HELP ----------------------------------- JRibbonBand helpBand = new JRibbonBand(translate("menu.help"), null); helpBand.setResizePolicies(getResizePolicies(helpBand)); @@ -599,7 +580,7 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener } private RibbonTask createDebugRibbonTask() { - //----------------------------------------- DEBUG ----------------------------------- + // ----------------------------------------- DEBUG ----------------------------------- JRibbonBand debugBand = new JRibbonBand("Debug", null); debugBand.setResizePolicies(getResizePolicies(debugBand)); @@ -645,8 +626,8 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener importTextCommandButton.setEnabled(swfLoaded); reloadCommandButton.setEnabled(swfLoaded); - renameinvalidCommandButton.setEnabled(swfLoaded); - globalrenameCommandButton.setEnabled(swfLoaded); + renameInvalidCommandButton.setEnabled(swfLoaded); + globalRenameCommandButton.setEnabled(swfLoaded); deobfuscationCommandButton.setEnabled(swfLoaded); searchCommandButton.setEnabled(swfLoaded); timeLineToggleButton.setEnabled(swfLoaded); @@ -688,18 +669,16 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener } break; case ACTION_RELOAD: - if (View.showConfirmDialog(null, translate("message.confirm.reload"), translate("message.warning"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) { - Main.reloadApp(); - } + reload(); break; case ACTION_ADVANCED_SETTINGS: - Main.advancedSettings(); + advancedSettings(); break; case ACTION_LOAD_MEMORY: - Main.loadFromMemory(); + loadFromMemory(); break; case ACTION_LOAD_CACHE: - Main.loadFromCache(); + loadFromCache(); break; case ACTION_GOTO_DOCUMENT_CLASS_ON_STARTUP: Configuration.gotoMainClassOnStartup.set(miGotoMainClassOnStartup.isSelected()); @@ -716,7 +695,7 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener } break; case ACTION_SET_LANGUAGE: - new SelectLanguageDialog().display(); + setLanguage(); break; case ACTION_DISABLE_DECOMPILATION: Configuration.decompile.set(!miDecompile.isSelected()); @@ -728,13 +707,13 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener } ContextMenuTools.addToContextMenu(miAssociate.isSelected(), false); - //Update checkbox menuitem accordingly (User can cancel rights elevation) + // Update checkbox menuitem accordingly (User can cancel rights elevation) new Timer().schedule(new TimerTask() { @Override public void run() { miAssociate.setSelected(ContextMenuTools.isAddedToContextMenu()); } - }, 1000); //It takes some time registry change to apply + }, 1000); // It takes some time registry change to apply break; case ACTION_GOTO_DOCUMENT_CLASS: mainFrame.getPanel().gotoDocumentClass(mainFrame.getPanel().getCurrentSwf()); @@ -763,7 +742,7 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener timeLineToggleGroup.setSelected(timeLineToggleButton, false); viewModeToggleGroup.setSelected(viewModeResourcesToggleButton, true); break; - case ACTION_VIEWMODE_HEX: + case ACTION_VIEWMODE_HEX_DUMP: Configuration.dumpView.set(true); mainFrame.getPanel().showView(MainPanel.VIEW_DUMP); timeLineToggleGroup.setSelected(timeLineToggleButton, false); @@ -812,13 +791,7 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener Configuration.recentFiles.set(null); break; case ACTION_EXIT: - mainFrame.getPanel().setVisible(false); - if (Main.proxyFrame != null) { - if (Main.proxyFrame.isVisible()) { - return; - } - } - Main.exit(); + exit(); break; } @@ -828,115 +801,75 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener switch (e.getActionCommand()) { case ACTION_RENAME_ONE_IDENTIFIER: - mainFrame.getPanel().renameOneIdentifier(mainFrame.getPanel().getCurrentSwf()); - break; - case ACTION_ABOUT: - Main.about(); + renameOneIdentifier(); break; case ACTION_SHOW_PROXY: - Main.showProxy(); + showProxy(); break; case ACTION_SUB_LIMITER: - if (e.getSource() instanceof JCheckBoxMenuItem) { - Main.setSubLimiter(((JCheckBoxMenuItem) e.getSource()).getState()); - } + setSubLimiter(((JCheckBox) e.getSource()).isSelected()); break; - case ACTION_SAVE: + case ACTION_SAVE: save(); break; - case ACTION_SAVE_AS: { - SWF swf = mainFrame.getPanel().getCurrentSwf(); - if (swf != null && saveAs(swf, SaveFileMode.SAVEAS)) { - swf.clearModified(); - } - } - break; - case ACTION_SAVE_AS_EXE: { - SWF swf = mainFrame.getPanel().getCurrentSwf(); - if (swf != null) { - saveAs(swf, SaveFileMode.EXE); - } - } - break; + case ACTION_SAVE_AS: + saveAs(); + break; + case ACTION_SAVE_AS_EXE: + saveAsExe(); + break; case ACTION_OPEN: open(); break; case ACTION_CLOSE: - Main.closeFile(mainFrame.getPanel().getCurrentSwfList()); + close(); break; case ACTION_CLOSE_ALL: - Main.closeAll(); - break; - case ACTION_EXPORT_FLA: - mainFrame.getPanel().exportFla(mainFrame.getPanel().getCurrentSwf()); + closeAll(); break; case ACTION_IMPORT_TEXT: - mainFrame.getPanel().importText(mainFrame.getPanel().getCurrentSwf()); + importText(); break; case ACTION_EXPORT_SEL: case ACTION_EXPORT: - boolean onlySel = e.getActionCommand().endsWith("SEL"); - mainFrame.getPanel().export(onlySel); + boolean onlySel = e.getActionCommand().equals(ACTION_EXPORT_SEL); + export(onlySel); + break; + case ACTION_EXPORT_FLA: + exportFla(); break; case ACTION_CHECK_UPDATES: - if (!Main.checkForUpdates()) { - View.showMessageDialog(null, translate("update.check.nonewversion"), translate("update.check.title"), JOptionPane.INFORMATION_MESSAGE); - } + checkUpdates(); break; case ACTION_HELP_US: - String helpUsURL = ApplicationInfo.PROJECT_PAGE + "/help_us.html"; - if (!View.navigateUrl(helpUsURL)) { - View.showMessageDialog(null, translate("message.helpus").replace("%url%", helpUsURL)); - } + helpUs(); break; case ACTION_HOMEPAGE: - String homePageURL = ApplicationInfo.PROJECT_PAGE; - if (!View.navigateUrl(homePageURL)) { - View.showMessageDialog(null, translate("message.homepage").replace("%url%", homePageURL)); - } + homePage(); + break; + case ACTION_ABOUT: + about(); break; case ACTION_RESTORE_CONTROL_FLOW: case ACTION_RESTORE_CONTROL_FLOW_ALL: - boolean all = e.getActionCommand().endsWith("ALL"); - mainFrame.getPanel().restoreControlFlow(all); + boolean all = e.getActionCommand().equals(ACTION_RESTORE_CONTROL_FLOW_ALL); + restoreControlFlow(all); break; case ACTION_RENAME_IDENTIFIERS: - mainFrame.getPanel().renameIdentifiers(mainFrame.getPanel().getCurrentSwf()); + renameIdentifiers(); break; case ACTION_DEOBFUSCATE: case ACTION_DEOBFUSCATE_ALL: - mainFrame.getPanel().deobfuscate(); + deobfuscate(); break; case ACTION_REMOVE_NON_SCRIPTS: - mainFrame.getPanel().removeNonScripts(mainFrame.getPanel().getCurrentSwf()); + removeNonScripts(); break; case ACTION_REFRESH_DECOMPILED: - mainFrame.getPanel().refreshDecompiled(); + refreshDecompiled(); break; case ACTION_CHECK_RESOURCES: - ByteArrayOutputStream os = new ByteArrayOutputStream(); - PrintStream stream = new PrintStream(os); - CheckResources.checkResources(stream); - final String str = new String(os.toByteArray(), Utf8Helper.charset); - JDialog dialog = new JDialog() { - - @Override - public void setVisible(boolean bln) { - setSize(new Dimension(800, 600)); - Container cnt = getContentPane(); - cnt.setLayout(new BorderLayout()); - ScrollPane scrollPane = new ScrollPane(); - JEditorPane editor = new JEditorPane(); - editor.setEditable(false); - editor.setText(str); - scrollPane.add(editor); - this.add(scrollPane, BorderLayout.CENTER); - this.setModal(true); - View.centerScreen(this); - super.setVisible(bln); - } - }; - dialog.setVisible(true); + checkResources(); break; } }