Changed #1996 Items are now exported in order of appearance in the tag tree (usually SWF order), previously was it in order of selection

This commit is contained in:
Jindra Petřík
2023-03-26 11:30:39 +02:00
parent 8aa3c1830a
commit ebe32074aa
4 changed files with 24 additions and 7 deletions

View File

@@ -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

View File

@@ -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();

View File

@@ -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<TreeItem> getAllSelected() {
TreeSelectionModel tsm = getSelectionModel();
TreePath[] tps = tsm.getSelectionPaths();
TreePath[] tps = getSelectionPathsSorted();
List<TreeItem> 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<TreePath>(){
@Override
public int compare(TreePath o1, TreePath o2) {
return getRowForPath(o1) - getRowForPath(o2);
}
});
return paths;
}
public List<TreeItem> getSelected() {
if (!mainPanel.folderPreviewPanel.selectedItems.isEmpty()) {
return new ArrayList<>(mainPanel.folderPreviewPanel.selectedItems.values());
}
TreeSelectionModel tsm = getSelectionModel();
TreePath[] tps = tsm.getSelectionPaths();
TreePath[] tps = getSelectionPathsSorted();
List<TreeItem> ret = new ArrayList<>();
if (tps == null) {
return ret;

View File

@@ -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;
}