From 0690a69efa247e09595ff334c16732be3d8af266 Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Mon, 10 Nov 2014 22:47:42 +0100 Subject: [PATCH] loading multiple embedded swfs: progress window fixed, allow to close embedded swf --- .../jpexs/decompiler/flash/gui/MainPanel.java | 29 +++++++++++++------ .../flash/gui/tagtree/TagTreeContextMenu.java | 20 ++++++++++--- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 459b64ff0..0d4a08c40 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -2216,6 +2216,10 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec } public void loadFromBinaryTag(final DefineBinaryDataTag binaryDataTag) { + loadFromBinaryTag(Arrays.asList(binaryDataTag)); + } + + public void loadFromBinaryTag(final List binaryDataTags) { if (Main.loadingDialog == null || Main.loadingDialog.getOwner() == null) { Main.loadingDialog = new LoadingDialog(mainFrame == null ? null : mainFrame.getWindow()); @@ -2227,19 +2231,26 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec @Override public void run() { try { - SWF bswf = new SWF(new ByteArrayInputStream(binaryDataTag.binaryData.getRangeData()), new ProgressListener() { + for (DefineBinaryDataTag binaryDataTag : binaryDataTags) { + try { + SWF bswf = new SWF(new ByteArrayInputStream(binaryDataTag.binaryData.getRangeData()), new ProgressListener() { - @Override - public void progress(int p) { - Main.loadingDialog.setPercent(p); + @Override + public void progress(int p) { + Main.loadingDialog.setPercent(p); + } + }, Configuration.parallelSpeedUp.get()); + bswf.fileTitle = "(SWF Data)"; + binaryDataTag.innerSwf = bswf; + bswf.binaryData = binaryDataTag; + } catch (IOException ex) { + //ignore } - }, Configuration.parallelSpeedUp.get()); - bswf.fileTitle = "(SWF Data)"; - binaryDataTag.innerSwf = bswf; - bswf.binaryData = binaryDataTag; - } catch (IOException | InterruptedException ex) { + } + } catch (InterruptedException ex) { //ignore } + Main.loadingDialog.setVisible(false); Main.stopWork(); } diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java index 7411911c3..6b2f8d821 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java @@ -194,8 +194,9 @@ public class TagTreeContextMenu extends JPopupMenu implements ActionListener { allSelectedIsSwf = false; break; } else if (item instanceof SWF) { + SWF swf = (SWF) item; // Do not allow to close SWF in bundle - if (((SWF) item).swfList.isBundle) { + if (swf.swfList != null &&swf.swfList.isBundle) { allSelectedIsSwf = false; } } @@ -328,11 +329,15 @@ public class TagTreeContextMenu extends JPopupMenu implements ActionListener { switch (e.getActionCommand()) { case ACTION_OPEN_SWFINSIDE: { List sel = tagTree.getSelected(tagTree); + List binaryDatas = new ArrayList<>(); for (TreeItem item : sel) { - if (item instanceof DefineBinaryDataTag) { - mainPanel.loadFromBinaryTag((DefineBinaryDataTag) item); + DefineBinaryDataTag binaryData = (DefineBinaryDataTag) item; + if (binaryData.isSwfData()) { + binaryDatas.add((DefineBinaryDataTag) item); } } + + mainPanel.loadFromBinaryTag(binaryDatas); } break; case ACTION_RAW_EDIT: { @@ -403,7 +408,14 @@ public class TagTreeContextMenu extends JPopupMenu implements ActionListener { List sel = tagTree.getSelected(tagTree); for (TreeItem item : sel) { if (item instanceof SWF) { - Main.closeFile(((SWF) item).swfList); + SWF swf = (SWF) item; + if (swf.binaryData != null) { + // embedded swf + swf.binaryData.innerSwf = null; + mainPanel.refreshTree(); + } else { + Main.closeFile(swf.swfList); + } } else if (item instanceof SWFList) { Main.closeFile((SWFList) item); }