From 74ff118c2226fd78f3e19cee2c0f65aca7fcd91f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 30 Oct 2022 10:47:28 +0100 Subject: [PATCH] Tag list view - saving last selected items Saving last selected view --- .../flash/configuration/Configuration.java | 31 +++++++++++- .../SwfSpecificConfiguration.java | 5 +- .../SwfSpecificCustomConfiguration.java | 46 ++++++++++++++++++ .../flash/gui/FolderPreviewPanel.java | 2 +- src/com/jpexs/decompiler/flash/gui/Main.java | 24 +++++++--- .../decompiler/flash/gui/MainFrameMenu.java | 14 ++++-- .../decompiler/flash/gui/MainFrameRibbon.java | 10 ++-- .../jpexs/decompiler/flash/gui/MainPanel.java | 48 ++++++++++--------- .../decompiler/flash/gui/PreviewPanel.java | 4 +- .../decompiler/flash/gui/TagInfoPanel.java | 2 +- .../flash/gui/dumpview/DumpTree.java | 2 +- .../locales/AdvancedSettingsDialog.properties | 9 ++++ .../gui/taglistview/TagListTreeRoot.java | 5 ++ .../flash/gui/tagtree/AbstractTagTree.java | 20 +++++++- .../decompiler/flash/gui/tagtree/TagTree.java | 18 +------ .../flash/gui/tagtree/TagTreeContextMenu.java | 2 +- 16 files changed, 179 insertions(+), 63 deletions(-) create mode 100644 libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/SwfSpecificCustomConfiguration.java diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java index ee896470a..bbe8c2fae 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java @@ -279,7 +279,10 @@ public final class Configuration { public static ConfigurationItem> fontPairingMap = null; public static ConfigurationItem> swfSpecificConfigs = null; - + + public static ConfigurationItem> swfSpecificCustomConfigs = null; + + @ConfigurationDefaultCalendar(0) public static ConfigurationItem lastUpdatesCheckDate = null; @@ -525,6 +528,11 @@ public final class Configuration { public static ConfigurationItem lastSessionFileTitles = null; public static ConfigurationItem lastSessionSelection = null; + + public static ConfigurationItem lastSessionTagListSelection = null; + + @ConfigurationDefaultInt(0) + public static ConfigurationItem lastView = null; @ConfigurationDefaultBoolean(true) @ConfigurationCategory("ui") @@ -897,6 +905,26 @@ public final class Configuration { return swfConf; } + + public static SwfSpecificCustomConfiguration getSwfSpecificCustomConfiguration(String fileName) { + HashMap map = swfSpecificCustomConfigs.get(); + if (map == null) { + map = new HashMap<>(); + swfSpecificCustomConfigs.set(map); + } + + return map.get(fileName); + } + + public static SwfSpecificCustomConfiguration getOrCreateSwfSpecificCustomConfiguration(String fileName) { + SwfSpecificCustomConfiguration swfConf = getSwfSpecificCustomConfiguration(fileName); + if (swfConf == null) { + swfConf = new SwfSpecificCustomConfiguration(); + swfSpecificCustomConfigs.get().put(fileName, swfConf); + } + + return swfConf; + } private static String getConfigFile() throws IOException { return getFFDecHome() + CONFIG_NAME; @@ -933,6 +961,7 @@ public final class Configuration { oos.writeObject(config); } catch (IOException ex) { //TODO: move this to GUI + ex.printStackTrace(); JOptionPane.showMessageDialog(null, "Cannot save configuration.", "Error", JOptionPane.ERROR_MESSAGE); Logger.getLogger(Configuration.class.getName()).severe("Configuration directory is read only."); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/SwfSpecificConfiguration.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/SwfSpecificConfiguration.java index 04bc0b545..d1c143398 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/SwfSpecificConfiguration.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/SwfSpecificConfiguration.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.configuration; import java.io.Serializable; @@ -27,5 +28,5 @@ public class SwfSpecificConfiguration implements Serializable { public Map fontPairingMap = new HashMap<>(); - public String lastSelectedPath = null; + public String lastSelectedPath = null; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/SwfSpecificCustomConfiguration.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/SwfSpecificCustomConfiguration.java new file mode 100644 index 000000000..b72bd2366 --- /dev/null +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/SwfSpecificCustomConfiguration.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2010-2022 JPEXS, All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. + */ + +package com.jpexs.decompiler.flash.configuration; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +/** + * + * @author JPEXS + */ +public class SwfSpecificCustomConfiguration implements Serializable { + + private Map customData = new HashMap<>(); + + public static final String KEY_LAST_SELECTED_PATH_RESOURCES = "lastSelectedPath.resources"; + public static final String KEY_LAST_SELECTED_PATH_TAGLIST = "lastSelectedPath.taglist"; + + public String getCustomData(String key, String defaultValue) { + if (customData.containsKey(key)) { + return customData.get(key); + } + + return defaultValue; + } + + public void setCustomData(String key, String value) { + customData.put(key, value); + } +} diff --git a/src/com/jpexs/decompiler/flash/gui/FolderPreviewPanel.java b/src/com/jpexs/decompiler/flash/gui/FolderPreviewPanel.java index f7eb7c034..81e91eb23 100644 --- a/src/com/jpexs/decompiler/flash/gui/FolderPreviewPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/FolderPreviewPanel.java @@ -105,7 +105,7 @@ public class FolderPreviewPanel extends JPanel { public void mouseClicked(MouseEvent e) { if (e.getClickCount() > 1) { if (selectedIndex > -1) { - mainPanel.setTagTreeSelectedNode(FolderPreviewPanel.this.items.get(selectedIndex)); + mainPanel.setTagTreeSelectedNode(mainPanel.getCurrentTree(), FolderPreviewPanel.this.items.get(selectedIndex)); } } } diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index b63288e56..2bca689a0 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -37,6 +37,7 @@ import com.jpexs.decompiler.flash.Version; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.configuration.SwfSpecificConfiguration; +import com.jpexs.decompiler.flash.configuration.SwfSpecificCustomConfiguration; import com.jpexs.decompiler.flash.console.CommandLineArgumentParser; import com.jpexs.decompiler.flash.console.ContextMenuTools; import com.jpexs.decompiler.flash.exporters.modes.ExeExportMode; @@ -1310,13 +1311,23 @@ public class Main { if (mainFrame != null && fswf != null) { SwfSpecificConfiguration swfConf = Configuration.getSwfSpecificConfiguration(fswf.getShortFileName()); + String resourcesPathStr = null; + String tagListPathStr = null; if (swfConf != null) { - String pathStr = swfConf.lastSelectedPath; - if (isInited()) { - mainFrame.getPanel().tagTree.setSelectionPathString(pathStr); - } else { - mainFrame.getPanel().tagTree.setExpandPathString(pathStr); - } + resourcesPathStr = swfConf.lastSelectedPath; + } + SwfSpecificCustomConfiguration swfCustomConf = Configuration.getSwfSpecificCustomConfiguration(fswf.getShortFileName()); + if (swfCustomConf != null) { + resourcesPathStr = swfCustomConf.getCustomData(SwfSpecificCustomConfiguration.KEY_LAST_SELECTED_PATH_RESOURCES, resourcesPathStr); + tagListPathStr = swfCustomConf.getCustomData(SwfSpecificCustomConfiguration.KEY_LAST_SELECTED_PATH_TAGLIST, null); + } + + if (isInited()) { + mainFrame.getPanel().tagTree.setSelectionPathString(resourcesPathStr); + mainFrame.getPanel().tagListTree.setSelectionPathString(tagListPathStr); + } else { + mainFrame.getPanel().tagTree.setExpandPathString(resourcesPathStr); + mainFrame.getPanel().tagListTree.setExpandPathString(tagListPathStr); } } @@ -2327,6 +2338,7 @@ public class Main { openingFiles = true; openFile(sourceInfos, () -> { mainFrame.getPanel().tagTree.setSelectionPathString(Configuration.lastSessionSelection.get()); + mainFrame.getPanel().tagListTree.setSelectionPathString(Configuration.lastSessionTagListSelection.get()); setSessionLoaded(true); }); } diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java b/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java index 7add3f01a..5ebda73c8 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java @@ -878,10 +878,16 @@ public abstract class MainFrameMenu implements MenuBuilder { finishMenu("/file"); - if (Configuration.dumpView.get()) { - setGroupSelection("view", "/file/view/viewHex"); - } else { - setGroupSelection("view", "/file/view/viewResources"); + switch(Configuration.lastView.get()){ + case MainPanel.VIEW_RESOURCES: + setGroupSelection("view", "/file/view/viewResources"); + break; + case MainPanel.VIEW_TAGLIST: + setGroupSelection("view", "/file/view/viewTagList"); + break; + case MainPanel.VIEW_DUMP: + setGroupSelection("view", "/file/view/viewHex"); + break; } /* diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java index 8222e2b35..247f76869 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java @@ -146,9 +146,13 @@ public final class MainFrameRibbon extends AppRibbonFrame { Configuration.lastSessionFiles.set(sb.toString()); Configuration.lastSessionFileTitles.set(sbt.toString()); - String path = panel.tagTree.getSelectionPathString(); - if (path != null) { - Configuration.lastSessionSelection.set(path); + String pathResources = panel.tagTree.getSelectionPathString(); + if (pathResources != null) { + Configuration.lastSessionSelection.set(pathResources); + } + String pathTagList = panel.tagListTree.getSelectionPathString(); + if (pathTagList != null) { + Configuration.lastSessionTagListSelection.set(pathTagList); } } diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 0692e674e..407812f25 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -34,6 +34,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.configuration.ConfigurationItem; import com.jpexs.decompiler.flash.configuration.SwfSpecificConfiguration; +import com.jpexs.decompiler.flash.configuration.SwfSpecificCustomConfiguration; import com.jpexs.decompiler.flash.dumpview.DumpInfo; import com.jpexs.decompiler.flash.dumpview.DumpInfoSwfNode; import com.jpexs.decompiler.flash.exporters.BinaryDataExporter; @@ -704,11 +705,9 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se dumpTree = new DumpTree(null, this); dumpTree.addTreeSelectionListener(this); dumpTree.createContextMenu(); - - if (Configuration.dumpView.get()) { - currentView = VIEW_DUMP; - } - + + currentView = Configuration.lastView.get(); + statusPanel = new MainFrameStatusPanel(this); add(statusPanel, BorderLayout.SOUTH); @@ -1800,7 +1799,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se Timelined t = (Timelined) treeItem; Frame f = tagTree.getModel().getFrame(treeItem.getSwf(), t, frame); if (f != null) { - setTagTreeSelectedNode(f); + setTagTreeSelectedNode(getCurrentTree(), f); } } } @@ -2265,7 +2264,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se public void updateSearchPos(String searchedText, boolean ignoreCase, boolean regExp, TextTag item) { View.checkAccess(); - setTagTreeSelectedNode(item); + setTagTreeSelectedNode(getCurrentTree(), item); previewPanel.getTextPanel().updateSearchPos(); } @@ -2280,11 +2279,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se } } - public void setTagTreeSelectedNode(TreeItem treeItem) { - if (currentView != VIEW_RESOURCES && currentView != VIEW_TAGLIST) { - return; - } - AbstractTagTree tree = getCurrentTree(); + public void setTagTreeSelectedNode(AbstractTagTree tree, TreeItem treeItem) { AbstractTagTreeModel ttm = tree.getModel(); TreePath tp = ttm.getTreePath(treeItem); if (tp != null) { @@ -3018,7 +3013,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se if (swf != null) { SWF treeItemSwf = swf.getRootSwf(); if (this.swfs.contains(treeItemSwf.swfList)) { - setTagTreeSelectedNode(treeItem); + setTagTreeSelectedNode(getCurrentTree(), treeItem); } } } @@ -3046,7 +3041,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se if (swf != null) { SWF treeItemSwf = swf.getRootSwf(); if (this.swfs.contains(treeItemSwf.swfList)) { - setTagTreeSelectedNode(treeItem); + setTagTreeSelectedNode(getCurrentTree(), treeItem); } } } @@ -3233,7 +3228,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se SWF swf = it.getSwf(); if (newTag != null) { refreshTree(swf); - setTagTreeSelectedNode(newTag); + setTagTreeSelectedNode(getCurrentTree(), newTag); } swf.clearImageCache(); } catch (IOException ex) { @@ -3260,7 +3255,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se SWF swf = st.getSwf(); if (newTag != null) { refreshTree(swf); - setTagTreeSelectedNode(newTag); + setTagTreeSelectedNode(getCurrentTree(), newTag); } swf.clearImageCache(); @@ -3315,7 +3310,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se SWF swf = st.getSwf(); if (newTag != null) { refreshTree(swf); - setTagTreeSelectedNode(newTag); + setTagTreeSelectedNode(getCurrentTree(), newTag); } swf.clearImageCache(); @@ -3622,14 +3617,14 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se dumpTree.expandFirstLevelNodes(); } break; - case VIEW_RESOURCES: + case VIEW_RESOURCES: + case VIEW_TAGLIST: if (tagTree.getModel() == null) { TagTreeModel ttm = new TagTreeModel(swfs, Configuration.tagTreeShowEmptyFolders.get()); tagTree.setModel(ttm); tagTree.expandFirstLevelNodes(); - } - break; - case VIEW_TAGLIST: + } + if (tagListTree.getModel() == null) { TagListTreeModel ttm = new TagListTreeModel(swfs); tagListTree.setModel(ttm); @@ -3675,6 +3670,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se switch (view) { case VIEW_DUMP: currentView = view; + Configuration.lastView.set(currentView); if (!isWelcomeScreen) { showContentPanelCard(SPLIT_PANE1); } @@ -3685,6 +3681,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se return true; case VIEW_RESOURCES: currentView = view; + Configuration.lastView.set(currentView); if (!isWelcomeScreen) { showContentPanelCard(SPLIT_PANE1); } @@ -3703,6 +3700,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se return true; case VIEW_TIMELINE: currentView = view; + Configuration.lastView.set(currentView); final SWF swf = getCurrentSwf(); if (swf != null) { TreeItem item = getCurrentTree().getCurrentTreeItem(); @@ -3722,6 +3720,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se return false; case VIEW_TAGLIST: currentView = view; + Configuration.lastView.set(currentView); if (!isWelcomeScreen) { showContentPanelCard(SPLIT_PANE1); } @@ -3924,8 +3923,11 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se } if (swf != null) { - SwfSpecificConfiguration swfConf = Configuration.getOrCreateSwfSpecificConfiguration(swf.getShortFileName()); - swfConf.lastSelectedPath = tagTree.getSelectionPathString(); + SwfSpecificCustomConfiguration swfCustomConf = Configuration.getOrCreateSwfSpecificCustomConfiguration(swf.getShortFileName()); + //swfConf.lastSelectedPath = tagTree.getSelectionPathString(); + swfCustomConf.setCustomData(SwfSpecificCustomConfiguration.KEY_LAST_SELECTED_PATH_RESOURCES, tagTree.getSelectionPathString()); + swfCustomConf.setCustomData(SwfSpecificCustomConfiguration.KEY_LAST_SELECTED_PATH_TAGLIST, tagListTree.getSelectionPathString()); + } } diff --git a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java index 5cf359df2..092a98fc2 100644 --- a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java @@ -918,7 +918,7 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel swf.assignClassesToSymbols(); swf.assignExportNamesToSymbols(); mainPanel.refreshTree(swf); - mainPanel.setTagTreeSelectedNode(tag); + mainPanel.setTagTreeSelectedNode(mainPanel.getCurrentTree(), tag); genericEditButton.setVisible(true); genericSaveButton.setVisible(false); genericCancelButton.setVisible(false); @@ -949,7 +949,7 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel SWF swf = tag.getSwf(); tag.getTimelined().resetTimeline(); mainPanel.refreshTree(swf); - mainPanel.setTagTreeSelectedNode(tag); + mainPanel.setTagTreeSelectedNode(mainPanel.getCurrentTree(), tag); } placeGenericPanel.setEditMode(false, null); } diff --git a/src/com/jpexs/decompiler/flash/gui/TagInfoPanel.java b/src/com/jpexs/decompiler/flash/gui/TagInfoPanel.java index 7afe5b73b..34b8dfd66 100644 --- a/src/com/jpexs/decompiler/flash/gui/TagInfoPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/TagInfoPanel.java @@ -83,7 +83,7 @@ public class TagInfoPanel extends JPanel { } else if ("frame".equals(scheme)) { item = swf.getTimeline().getFrame(id); } - mainPanel.setTagTreeSelectedNode(item); + mainPanel.setTagTreeSelectedNode(mainPanel.getCurrentTree(), item); } } diff --git a/src/com/jpexs/decompiler/flash/gui/dumpview/DumpTree.java b/src/com/jpexs/decompiler/flash/gui/dumpview/DumpTree.java index 0201a6165..e7f9dc9a9 100644 --- a/src/com/jpexs/decompiler/flash/gui/dumpview/DumpTree.java +++ b/src/com/jpexs/decompiler/flash/gui/dumpview/DumpTree.java @@ -491,7 +491,7 @@ public class DumpTree extends JTree { if (foundTag != null) { mainPanel.getMainFrame().getMenu().showResourcesView(); - mainPanel.setTagTreeSelectedNode(foundTag); + mainPanel.setTagTreeSelectedNode(mainPanel.getCurrentTree(), foundTag); } } diff --git a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties index 5194777d2..e3bb0ffb0 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties @@ -555,3 +555,12 @@ config.description.showImportSymbolClassInfo = Displays some info about how Symb config.name.showImportXmlInfo = Show information before importing XML config.description.showImportXmlInfo = Displays some info about how XML importing works after clicking Import XML in the menu. + +config.name.lastSessionTagListSelection = Last session tag list selection +config.description.lastSessionTagListSelection = Contains the selection from the last session on the list selection view + +config.name.lastView = Last view +config.description.lastView = Last displayed view mode + +config.name.swfSpecificCustomConfigs = SWF specific custom configurations +config.description.swfSpecificCustomConfigs = Contains the SWF specific configurations in custom format diff --git a/src/com/jpexs/decompiler/flash/gui/taglistview/TagListTreeRoot.java b/src/com/jpexs/decompiler/flash/gui/taglistview/TagListTreeRoot.java index 8d3eeb843..dfca2d6ae 100644 --- a/src/com/jpexs/decompiler/flash/gui/taglistview/TagListTreeRoot.java +++ b/src/com/jpexs/decompiler/flash/gui/taglistview/TagListTreeRoot.java @@ -35,4 +35,9 @@ public class TagListTreeRoot implements TreeItem { public boolean isModified() { return false; } + + @Override + public String toString() { + return "root"; + } } diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/AbstractTagTree.java b/src/com/jpexs/decompiler/flash/gui/tagtree/AbstractTagTree.java index 6f271f4be..be85daa54 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/AbstractTagTree.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/AbstractTagTree.java @@ -354,7 +354,7 @@ public abstract class AbstractTagTree extends JTree { TreePath tp = View.getTreePathByPathStrings(this, Arrays.asList(path)); if (tp != null) { // the current view is the Resources view, otherwise tp is null - mainPanel.setTagTreeSelectedNode((TreeItem) tp.getLastPathComponent()); + mainPanel.setTagTreeSelectedNode(this, (TreeItem) tp.getLastPathComponent()); } } } @@ -502,4 +502,22 @@ public abstract class AbstractTagTree extends JTree { TreeItem item = (TreeItem) getLastSelectedPathComponent(); return item; } + + public String getSelectionPathString() { + StringBuilder sb = new StringBuilder(); + TreePath path = getSelectionPath(); + if (path != null) { + boolean first = true; + for (Object p : path.getPath()) { + if (!first) { + sb.append("|"); + } + + first = false; + sb.append(p.toString()); + } + } + + return sb.toString(); + } } diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java index f938c1e49..073a64a24 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java @@ -555,23 +555,7 @@ public class TagTree extends AbstractTagTree { return (TagTreeModel) super.getModel(); } - public String getSelectionPathString() { - StringBuilder sb = new StringBuilder(); - TreePath path = getSelectionPath(); - if (path != null) { - boolean first = true; - for (Object p : path.getPath()) { - if (!first) { - sb.append("|"); - } - - first = false; - sb.append(p.toString()); - } - } - - return sb.toString(); - } + } diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java index d347a100a..336fa8619 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java @@ -947,7 +947,7 @@ public class TagTreeContextMenu extends JPopupMenu { } CharacterIdTag characterIdTag = (CharacterIdTag) itemj; - mainPanel.setTagTreeSelectedNode(itemj.getSwf().getCharacter(characterIdTag.getCharacterId())); + mainPanel.setTagTreeSelectedNode(mainPanel.getCurrentTree(), itemj.getSwf().getCharacter(characterIdTag.getCharacterId())); } private void expandRecursiveActionPerformed(ActionEvent evt) {