From 5d4ed1dcc0b01de1e8ee95898ab283ce676ab4c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Wed, 7 Dec 2022 19:24:15 +0100 Subject: [PATCH] Properly distinguish sprite in scripts section vs in sprites section --- .../decompiler/flash/gui/FolderListPanel.java | 12 +++++++++--- src/com/jpexs/decompiler/flash/gui/MainPanel.java | 14 +++++++++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/com/jpexs/decompiler/flash/gui/FolderListPanel.java b/src/com/jpexs/decompiler/flash/gui/FolderListPanel.java index 47735f4e9..1a83615f3 100644 --- a/src/com/jpexs/decompiler/flash/gui/FolderListPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/FolderListPanel.java @@ -45,6 +45,7 @@ import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JViewport; import javax.swing.SwingUtilities; +import javax.swing.tree.TreePath; import org.pushingpixels.substance.api.ColorSchemeAssociationKind; import org.pushingpixels.substance.api.ComponentState; import org.pushingpixels.substance.api.DecorationAreaType; @@ -56,7 +57,9 @@ import org.pushingpixels.substance.api.SubstanceSkin; * @author JPEXS */ public class FolderListPanel extends JPanel { - private List items; + private List items; + + private TreePath parentPath; private int selectedIndex = -1; @@ -110,7 +113,9 @@ public class FolderListPanel extends JPanel { public void mouseClicked(MouseEvent e) { if (e.getClickCount() > 1) { if (selectedIndex > -1) { - mainPanel.setTagTreeSelectedNode(mainPanel.getCurrentTree(), FolderListPanel.this.items.get(selectedIndex)); + TreeItem selectedItem = FolderListPanel.this.items.get(selectedIndex); + TreePath subPath = parentPath.pathByAddingChild(selectedItem); + mainPanel.getCurrentTree().setSelectionPath(subPath); } } } @@ -162,8 +167,9 @@ public class FolderListPanel extends JPanel { }); } - public synchronized void setItems(List items) { + public synchronized void setItems(TreePath parentPath, List items) { this.items = items; + this.parentPath = parentPath; revalidate(); repaint(); selectedItems.clear(); diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 9a1dbe8bd..7728a279b 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -4978,7 +4978,11 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se showPreview(treeItem, previewPanel, -1, null); showCard(CARDPREVIEWPANEL); } else if (!(treeItem instanceof ScriptPack)) { - showFolderList(treeItem); + if (treePath == null) { + showCard(CARDEMPTYPANEL); + } else { + showFolderList(treePath); + } } if (oldItem instanceof TreeRoot) { pinsPanel.setCurrent(null); @@ -5094,7 +5098,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se private void showFolderPreview(FolderItem item) { String folderName = item.getName(); if (TagTreeModel.FOLDER_OTHERS.equals(folderName) || TagTreeModel.FOLDER_SCRIPTS.equals(folderName)) { - showFolderList(item); + showFolderList(tagTree.getFullModel().getTreePath(item)); return; } List folderPreviewItems = new ArrayList<>(); @@ -5105,9 +5109,9 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se showCard(CARDFOLDERPREVIEWPANEL); } - private void showFolderList(TreeItem item) { - List items = new ArrayList<>(getCurrentTree().getFullModel().getAllChildren(item)); - folderListPanel.setItems(items); + private void showFolderList(TreePath path) { + List items = new ArrayList<>(getCurrentTree().getFullModel().getAllChildren((TreeItem)path.getLastPathComponent())); + folderListPanel.setItems(path, items); showCard(CARDFOLDERLISTPANEL); }