From ebe32074aa914a1a04abf3fef457b4ee99e9df96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 26 Mar 2023 11:30:39 +0200 Subject: [PATCH] Changed #1996 Items are now exported in order of appearance in the tag tree (usually SWF order), previously was it in order of selection --- CHANGELOG.md | 4 ++++ .../jpexs/decompiler/flash/gui/MainPanel.java | 4 ++-- .../flash/gui/tagtree/AbstractTagTree.java | 21 +++++++++++++++---- .../flash/gui/tagtree/TagTreeContextMenu.java | 2 +- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a96d26b22..3b5bdc34e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ All notable changes to this project will be documented in this file. - Starting app with parameters causing wrong GUI init - [#1991] ConcurrentModificationException on clearing cache thread +### Changed +- [#1996] Items are now exported in order of appearance in the tag tree (usually SWF order), previously was it in order of selection + ## [18.4.0] - 2023-03-19 ### Added - AS3 support for logical AND/OR compound operator @@ -3021,6 +3024,7 @@ All notable changes to this project will be documented in this file. [#1994]: https://www.free-decompiler.com/flash/issues/1994 [#1477]: https://www.free-decompiler.com/flash/issues/1477 [#1991]: https://www.free-decompiler.com/flash/issues/1991 +[#1996]: https://www.free-decompiler.com/flash/issues/1996 [#1888]: https://www.free-decompiler.com/flash/issues/1888 [#1892]: https://www.free-decompiler.com/flash/issues/1892 [#355]: https://www.free-decompiler.com/flash/issues/355 diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 685880420..0a4681290 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -496,7 +496,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se items.addAll(folderListPanel.selectedItems.values()); } else { AbstractTagTree tree = (AbstractTagTree) e.getSource(); - TreePath[] paths = tree.getSelectionPaths(); + TreePath[] paths = tree.getSelectionPathsSorted(); if (paths != null) { for (TreePath treePath : paths) { TreeItem item = (TreeItem) treePath.getLastPathComponent(); @@ -583,7 +583,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se items.addAll(folderListPanel.selectedItems.values()); } else { AbstractTagTree tree = (AbstractTagTree) e.getSource(); - TreePath[] paths = tree.getSelectionPaths(); + TreePath[] paths = tree.getSelectionPathsSorted(); if (paths != null) { for (TreePath treePath : paths) { TreeItem item = (TreeItem) treePath.getLastPathComponent(); diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/AbstractTagTree.java b/src/com/jpexs/decompiler/flash/gui/tagtree/AbstractTagTree.java index 923bb3057..4cff75408 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/AbstractTagTree.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/AbstractTagTree.java @@ -102,6 +102,7 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.Arrays; +import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Locale; @@ -501,8 +502,7 @@ public abstract class AbstractTagTree extends JTree { } public List getAllSelected() { - TreeSelectionModel tsm = getSelectionModel(); - TreePath[] tps = tsm.getSelectionPaths(); + TreePath[] tps = getSelectionPathsSorted(); List ret = new ArrayList<>(); if (tps == null) { return ret; @@ -525,12 +525,25 @@ public abstract class AbstractTagTree extends JTree { return ret; } + public TreePath[] getSelectionPathsSorted() { + TreePath[] paths = getSelectionPaths(); + if (paths == null) { + return null; + } + Arrays.sort(paths, new Comparator(){ + @Override + public int compare(TreePath o1, TreePath o2) { + return getRowForPath(o1) - getRowForPath(o2); + } + }); + return paths; + } + public List getSelected() { if (!mainPanel.folderPreviewPanel.selectedItems.isEmpty()) { return new ArrayList<>(mainPanel.folderPreviewPanel.selectedItems.values()); } - TreeSelectionModel tsm = getSelectionModel(); - TreePath[] tps = tsm.getSelectionPaths(); + TreePath[] tps = getSelectionPathsSorted(); List ret = new ArrayList<>(); if (tps == null) { return ret; diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java index 4d1a4bdb2..7d2658d63 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java @@ -645,7 +645,7 @@ public class TagTreeContextMenu extends JPopupMenu { getTree().setSelectionRow(row); } - TreePath[] paths = getTree().getSelectionPaths(); + TreePath[] paths = getTree().getSelectionPathsSorted(); if (paths == null || paths.length == 0) { return; }