From 3b90e50345b24209a0e03b7750d72bd5afe49423 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sat, 21 Feb 2015 08:13:36 +0100 Subject: [PATCH] Export, import XML buttons to Ribbon menu, New import text icon, Save as exe moved to General band --- src/com/jpexs/decompiler/flash/gui/Main.java | 16 ++++- .../flash/gui/MainFrameRibbonMenu.java | 36 +++++++++-- .../jpexs/decompiler/flash/gui/MainPanel.java | 60 ++++++++++-------- .../flash/gui/graphics/exportxml32.png | Bin 0 -> 1522 bytes .../flash/gui/graphics/importtext32.png | Bin 0 -> 1895 bytes .../flash/gui/graphics/importxml32.png | Bin 0 -> 1510 bytes .../flash/gui/locales/MainFrame.properties | 3 + 7 files changed, 81 insertions(+), 34 deletions(-) create mode 100644 src/com/jpexs/decompiler/flash/gui/graphics/exportxml32.png create mode 100644 src/com/jpexs/decompiler/flash/gui/graphics/importtext32.png create mode 100644 src/com/jpexs/decompiler/flash/gui/graphics/importxml32.png diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index 5765de7ea..4ee80b9b3 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -641,7 +641,21 @@ public class Main { return AppStrings.translate("filter.swf"); } }; - if (!swf.gfx) { + + FileFilter exeFilter = new FileFilter() { + @Override + public boolean accept(File f) { + return (f.getName().toLowerCase().endsWith(".exe")) || (f.isDirectory()); + } + + @Override + public String getDescription() { + return AppStrings.translate("filter.exe"); + } + }; + if(mode == SaveFileMode.EXE){ + fc.setFileFilter(exeFilter); + } else if (!swf.gfx) { fc.setFileFilter(swfFilter); } else { fc.addChoosableFileFilter(swfFilter); diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java index 07dd674eb..a1424b416 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java @@ -134,7 +134,7 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener private static final String ACTION_EXPORT = "EXPORT"; - private static final String ACTION_IMPORT_TEXT = "IMPORTTEXT"; + private static final String ACTION_IMPORT_TEXT = "IMPORTTEXT"; private static final String ACTION_CHECK_UPDATES = "CHECKUPDATES"; @@ -199,6 +199,8 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener private JCommandButton exportSelectionCommandButton; private JCommandButton importTextCommandButton; + private JCommandButton importXmlCommandButton; + private JCommandButton exportXmlCommandButton; private JCommandToggleButton viewModeResourcesToggleButton; @@ -409,11 +411,15 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener reloadCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.reload")), View.getResizableIcon("reload16")); assignListener(reloadCommandButton, ACTION_RELOAD); + + saveasexeCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.saveasexe")), View.getResizableIcon("saveasexe16")); + assignListener(saveasexeCommandButton, ACTION_SAVE_AS_EXE); editBand.addCommandButton(openCommandButton, RibbonElementPriority.TOP); editBand.addCommandButton(saveCommandButton, RibbonElementPriority.TOP); editBand.addCommandButton(saveasCommandButton, RibbonElementPriority.MEDIUM); - editBand.addCommandButton(reloadCommandButton, RibbonElementPriority.MEDIUM); + editBand.addCommandButton(saveasexeCommandButton, RibbonElementPriority.MEDIUM); + editBand.addCommandButton(reloadCommandButton, RibbonElementPriority.MEDIUM); JRibbonBand exportBand = new JRibbonBand(translate("menu.export"), null); exportBand.setResizePolicies(getResizePolicies(exportBand)); @@ -423,20 +429,27 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener assignListener(exportAllCommandButton, ACTION_EXPORT); exportSelectionCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.export.selection")), View.getResizableIcon("exportsel16")); assignListener(exportSelectionCommandButton, ACTION_EXPORT_SEL); - saveasexeCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.saveasexe")), View.getResizableIcon("saveasexe16")); - assignListener(saveasexeCommandButton, ACTION_SAVE_AS_EXE); + + + exportXmlCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.export.xml")), View.getResizableIcon("exportxml32")); + assignListener(exportXmlCommandButton, ACTION_EXPORT_SWF_XML); exportBand.addCommandButton(exportFlaCommandButton, RibbonElementPriority.TOP); exportBand.addCommandButton(exportAllCommandButton, RibbonElementPriority.MEDIUM); exportBand.addCommandButton(exportSelectionCommandButton, RibbonElementPriority.MEDIUM); - exportBand.addCommandButton(saveasexeCommandButton, RibbonElementPriority.MEDIUM); + exportBand.addCommandButton(exportXmlCommandButton, RibbonElementPriority.MEDIUM); + JRibbonBand importBand = new JRibbonBand(translate("menu.import"), null); importBand.setResizePolicies(getResizePolicies(importBand)); - importTextCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.import.text")), View.getResizableIcon("import32")); + importTextCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.import.text")), View.getResizableIcon("importtext32")); assignListener(importTextCommandButton, ACTION_IMPORT_TEXT); + + importXmlCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.import.xml")), View.getResizableIcon("importxml32")); + assignListener(importXmlCommandButton, ACTION_IMPORT_SWF_XML); - importBand.addCommandButton(importTextCommandButton, RibbonElementPriority.TOP); + importBand.addCommandButton(importXmlCommandButton, RibbonElementPriority.TOP); + importBand.addCommandButton(importTextCommandButton, RibbonElementPriority.TOP); JRibbonBand viewBand = new JRibbonBand(translate("menu.view"), null); viewBand.setResizePolicies(getResizePolicies(viewBand)); @@ -721,8 +734,10 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener saveasexeCommandButton.setEnabled(swfLoaded); exportAllCommandButton.setEnabled(swfLoaded); exportFlaCommandButton.setEnabled(swfLoaded); + exportXmlCommandButton.setEnabled(swfLoaded); exportSelectionCommandButton.setEnabled(swfLoaded); importTextCommandButton.setEnabled(swfLoaded); + importXmlCommandButton.setEnabled(swfLoaded); reloadCommandButton.setEnabled(swfLoaded); renameInvalidCommandButton.setEnabled(swfLoaded); @@ -933,6 +948,13 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener case ACTION_IMPORT_TEXT: importText(); break; + + case ACTION_EXPORT_SWF_XML: + mainFrame.getPanel().exportSwfXml(); + break; + case ACTION_IMPORT_SWF_XML: + mainFrame.getPanel().importSwfXml(); + break; case ACTION_EXPORT_SEL: case ACTION_EXPORT: boolean onlySel = e.getActionCommand().equals(ACTION_EXPORT_SEL); diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index e21732b23..91395b52a 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -1704,18 +1704,21 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec public void exportSwfXml() { List sel = tagTree.getSelected(tagTree); + Set swfs = new HashSet<>(); + for (TreeItem item : sel) { - if (item instanceof SWF) { - SWF swf = (SWF) item; - final String selFile = selectExportDir(); - if (selFile != null) { - try { - File outFile = new File(selFile + File.separator + Helper.makeFileName("swf.xml")); - new SwfXmlExporter().exportXml(swf, outFile); - Main.stopWork(); - } catch (IOException ex) { - logger.log(Level.SEVERE, null, ex); - } + swfs.add(item.getSwf()); + } + + for (SWF swf : swfs) { + final String selFile = selectExportDir(); + if (selFile != null) { + try { + File outFile = new File(selFile + File.separator + Helper.makeFileName("swf.xml")); + new SwfXmlExporter().exportXml(swf, outFile); + Main.stopWork(); + } catch (IOException ex) { + logger.log(Level.SEVERE, null, ex); } } } @@ -1723,22 +1726,27 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec public void importSwfXml() { List sel = tagTree.getSelected(tagTree); + Set swfs = new HashSet<>(); for (TreeItem item : sel) { - if (item instanceof SWF) { - SWF swf = (SWF) item; - File selectedFile = showImportFileChooser("filter.xml|*.xml"); - if (selectedFile != null) { - File selfile = Helper.fixDialogFile(selectedFile); - String xml = Helper.readTextFile(selfile.getPath()); - try { - new SwfXmlImporter().importSwf(swf, xml); - swf.clearAllCache(); - swf.assignExportNamesToSymbols(); - swf.assignClassesToSymbols(); - refreshTree(); - } catch (IOException ex) { - logger.log(Level.SEVERE, null, ex); - } + swfs.add(item.getSwf()); + } + if (swfs.size() > 1) { + return; + } + + for (SWF swf : swfs) { + File selectedFile = showImportFileChooser("filter.xml|*.xml"); + if (selectedFile != null) { + File selfile = Helper.fixDialogFile(selectedFile); + String xml = Helper.readTextFile(selfile.getPath()); + try { + new SwfXmlImporter().importSwf(swf, xml); + swf.clearAllCache(); + swf.assignExportNamesToSymbols(); + swf.assignClassesToSymbols(); + refreshTree(); + } catch (IOException ex) { + logger.log(Level.SEVERE, null, ex); } } } diff --git a/src/com/jpexs/decompiler/flash/gui/graphics/exportxml32.png b/src/com/jpexs/decompiler/flash/gui/graphics/exportxml32.png new file mode 100644 index 0000000000000000000000000000000000000000..6f9da78cca5453728a34f9336386f541bf3cbfea GIT binary patch literal 1522 zcmVf9K5X%)l6 zm-MNYs7;?WP{j+NHR3ha;+@*4s6}0UK@DIl1g+AD3uR_^rVo381(e+w(=Yjw$(-+; z^FQC^f4&3%vj{-lf8fADgjnJ_4sJ@*T|gj(ARG=K`naN^0tlrFB4hu71MZ7TPfw3q z*U-=iD5-3&0*32G&fVV8i4Y?B^Sds&IaAnOU(fQ&N){Fum+x+9*tdMyvX6jpGHXac z#M~~WL`sRGDC26(7C=bJj{~V5JDiOLokY?D{rN>yngTQ2u7!SHaS^Dec85+Ox`))q=`blzox;bF_=9;!+U z$*XR~4%rbKMWhD6vMgrTTxWGjKF99#lCDcG-fp8N-@)(qf*!Ql;uxDQv_a3 zWp7J>U2{E%=oOt3fQVbO*-s3D`f-4?vnn zlA)_KUJ9_INFgUT7ch!9QP zd?SIRgb>utH~8fI4FGn|RmsW8VbY{YqX=toaFDPA@8nWyZQ$pV>qzJoMiG&r>tvcH z0;t!z0Py?$WcYmXxMui#Wc&Tp&mS5$O>@-d0O4>LD-7jtujOC&`*JpL>f|~W#ag!! zM5F*Nx^9q}nT5}n5zmj2RWN*9*L8kqT1rd%aU6$)zS4DJFa!<;@8wm3s9zwexOZX= zQviDu6AlkYjQPfr;p2UMeYCV6r}oRAcszIrP~tbGi%ZxEA>G#qbl3C#tj|HMoh+*8 zXj(%~A^=5@Vp|-Evo(n0z>~oT{ML3DG2-@#Tt`Qc9=Q3Smc_GHBGqkvWfNVA4aqa= zeLRhA77TZRhfyjt5FQXJxC*pAs-y7D>A3LvGeeNl<01;8-@T8bkA3&LPAt*EQ3q+c za}(KKG z9~_z=C9aTd4_x(qm*z=>w%c&-G}oe=-vfFD@G6iCOnhGJl*|ij461bjcgbcN=go(+ zr+Cz~o)3Ty;4u(ZfgsQh+5_y7O^ literal 0 HcmV?d00001 diff --git a/src/com/jpexs/decompiler/flash/gui/graphics/importtext32.png b/src/com/jpexs/decompiler/flash/gui/graphics/importtext32.png new file mode 100644 index 0000000000000000000000000000000000000000..0aa20e6de188f072eb183a7e85648a6bea77ed8b GIT binary patch literal 1895 zcmV-t2blPYP)X?6oPW4T2kZ}*;2$Pqm~>^OlrSh8 zwTM||ElLg}x2&pGewALriN zds|9Gm!0HE&VBFmKEI#u^Be(8TU*;3&bh_TSw4?PL?I$aT3cJcZ-At8ZgFdCD+9L& zKNkb;`$8FQZEcHzqyb8-jXl47`QLyb^51wNIOpz3am?MSvU09fll1j!1& z+oQEcYmK#*D2ndE5QjrzU0FX=kzgfgtx!rPC1VtcgwHdpnmFIrhcWuD{Dq{oLaSou zOmSFsQTRn98w~+m{>&H;&-3vUKF0WnggEE&RD3snVy`DgN{umCv@Y~i#3Smg*JxMr%v#TpZ^SSR8&;(?6WP*m^p)VI!$+1C%tdKjRP{7 z412n|iy|~30su->5mn8qX6X%VnJqv&*o>)R>=N=Lz3Ep|9mnBP{k@7y{1&Yk1Hf&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i90ys hfHW`)gg^!u`VV_*Hq;BFMw0*l002ovPDHLkV1jH)e18A{ literal 0 HcmV?d00001 diff --git a/src/com/jpexs/decompiler/flash/gui/graphics/importxml32.png b/src/com/jpexs/decompiler/flash/gui/graphics/importxml32.png new file mode 100644 index 0000000000000000000000000000000000000000..d194895be44ab1a3281dccbdb3c4bdb591e4522c GIT binary patch literal 1510 zcmVMM-?{ zL1VyZq7OchQfN1}w8Q{4AYTnaLWq1BO4q*d5%~z%MZ-!oyJTi|$A{fn==WAlJjqFR z_MW--f6w{<@0<(&vx!m9>h8UJ`w-$4Kbys$)>J+qkV25jWWIZ&rKJV%rVD7s?!9~c ze`|?E!td_s*#jt3EvSxqHhn+0?_aK7LkLm){(Yahm2>FYxsx@kSJPNu-`v&H^X-~d zt6m2(6TK%#mn2BLloBZ=ilR*EK`elfk~_&iC@U+YaoMuwuAZK6C(DGKkQ_oFr9=oZ zr3Y~VsZ7J*_HVyaUS2*Wh)DrV*8?*QjgV;;K)hIA-`w5XJ1&R`0Vs+@N>RKkqM!vu zQ7I`gu`R1mj^zyv%{{wz^^NA8Iu4sgWT1FG=VG6nKcDX2-h#e;Ae+td=IYhxy50nY zfIlY&P$+>M0l;w_p6&Pjbhcn;j0aD<&^NK#n{B z$8o4?zd*;zIzBjZ60Gpd?*?Km?OjBd<+7&u$#wwt*Mlg8o3NuZOt!EQ#ZmOlKeE`q%CgswE0Njkr zk{uU#uc4X)my?tjl2ey1vaLExc_e~mTL>u-QefE@<&g;6sILYEz|vKAorx1$sv(4&J^DA_7k4#B1P`=>$xtA+kT?uxrHc-AY`cQKR-lgji4eD z!M5z_0|?SuSy@S}R}fm+jb$wwrwgZD(HUx7MVqqH`b^y@!!&=^KtK`+k zzAPSqd_cRVVK6%!#Ze--@ynSqO~!`!FV*cJrxedqqH{0STr}u@=rPU zAc+5@AMiYn){ZBTdLQc=+Bq~7MQ9-PoC^&O4Mkbk&`#X~%3j*S)d0lA02EOm+GOr! zJl1zUPSyNjqV=C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