From 99fa794a6f4d15168c63841d3a87a9388a4732cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Tue, 8 Nov 2022 21:23:32 +0100 Subject: [PATCH] Fixed On new SWF loading, do not expand all other SWFs nodes, only this one --- CHANGELOG.md | 1 + .../jpexs/decompiler/flash/gui/MainPanel.java | 34 +++++++++++++++++-- .../flash/gui/dumpview/DumpTree.java | 14 ++++++++ 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f7667791..72fe30e72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file. - [#1862], [#1735] Exporting selection to subfolders by SWFname when multiple SWFs selected - Java code export indentation - Java code does not export tags +- On new SWF loading, do not expand all other SWFs nodes, only this one ## [16.1.0] - 2022-11-06 ### Added diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 6b443658a..4b28557cb 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -90,6 +90,7 @@ import com.jpexs.decompiler.flash.gui.dumpview.DumpTree; import com.jpexs.decompiler.flash.gui.dumpview.DumpTreeModel; import com.jpexs.decompiler.flash.gui.dumpview.DumpViewPanel; import com.jpexs.decompiler.flash.gui.editor.LineMarkedEditorPane; +import com.jpexs.decompiler.flash.gui.helpers.CollectionChangedAction; import com.jpexs.decompiler.flash.gui.helpers.ObservableList; import com.jpexs.decompiler.flash.gui.player.FlashPlayerPanel; import com.jpexs.decompiler.flash.gui.taglistview.TagListTree; @@ -934,7 +935,17 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se } ttm.updateSwfs(e); tagTree.expandRoot(); - tagTree.expandFirstLevelNodes(); + if (e.getAction() == CollectionChangedAction.RESET) { + tagTree.expandFirstLevelNodes(); + } else if (e.getAction() == CollectionChangedAction.ADD) { + SWFList list = e.getNewItem(); + if (!list.isBundle() && list.swfs.size() == 1) { + tagTree.expandPath(tagTree.getModel().getTreePath(list.get(0))); + } else { + tagTree.expandPath(tagTree.getModel().getTreePath(e.getNewItem())); + } + } + } ttm = tagListTree.getModel(); if (ttm != null) { @@ -943,7 +954,17 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se } ttm.updateSwfs(e); tagListTree.expandRoot(); - tagListTree.expandFirstLevelNodes(); + + if (e.getAction() == CollectionChangedAction.RESET) { + tagListTree.expandFirstLevelNodes(); + } else if (e.getAction() == CollectionChangedAction.ADD) { + SWFList list = e.getNewItem(); + if (!list.isBundle() && list.swfs.size() == 1) { + tagListTree.expandPath(tagListTree.getModel().getTreePath(list.get(0))); + } else { + tagListTree.expandPath(tagListTree.getModel().getTreePath(e.getNewItem())); + } + } } DumpTreeModel dtm = dumpTree.getModel(); @@ -952,7 +973,14 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se dtm.updateSwfs(); View.expandTreeNodes(dumpTree, expandedNodes); dumpTree.expandRoot(); - dumpTree.expandFirstLevelNodes(); + if (e.getAction() == CollectionChangedAction.RESET) { + dumpTree.expandFirstLevelNodes(); + } else if (e.getAction() == CollectionChangedAction.ADD) { + SWFList list = e.getNewItem(); + for (SWF dswf : list) { + dumpTree.expandSwfNode(dswf); + } + } } if (swfs.isEmpty()) { diff --git a/src/com/jpexs/decompiler/flash/gui/dumpview/DumpTree.java b/src/com/jpexs/decompiler/flash/gui/dumpview/DumpTree.java index f1034c0d6..5f539edcc 100644 --- a/src/com/jpexs/decompiler/flash/gui/dumpview/DumpTree.java +++ b/src/com/jpexs/decompiler/flash/gui/dumpview/DumpTree.java @@ -590,6 +590,20 @@ public class DumpTree extends JTree { expandPath(new TreePath(new Object[]{root, dtm.getChild(root, i)})); } } + + public void expandSwfNode(SWF swf) { + DumpTreeModel dtm = getModel(); + DumpInfo root = dtm.getRoot(); + int childCount = dtm.getChildCount(root); + expandPath(new TreePath(new Object[]{root})); + for (int i = 0; i < childCount; i++) { + DumpInfoSwfNode swfNode = (DumpInfoSwfNode) dtm.getChild(root, i); + if (swfNode.getSwf() == swf) { + expandPath(new TreePath(new Object[]{root, dtm.getChild(root, i)})); + break; + } + } + } public void setSelectedTag(Tag tag) { ByteArrayRange range = tag.getOriginalRange();