mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-07 20:30:01 +00:00
save last selected path for each swf
This commit is contained in:
@@ -26,7 +26,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class SwfSpecificConfiguration implements Serializable {
|
||||
|
||||
public final Map<String, String> fontPairingMap = new HashMap<>();
|
||||
public Map<String, String> fontPairingMap = new HashMap<>();
|
||||
|
||||
public final ConfigurationItem<String> lastSessionData = null;
|
||||
public String lastSelectedPath = null;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.jpexs.decompiler.flash.SwfOpenException;
|
||||
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.console.CommandLineArgumentParser;
|
||||
import com.jpexs.decompiler.flash.console.ContextMenuTools;
|
||||
import com.jpexs.decompiler.flash.gui.pipes.FirstInstance;
|
||||
@@ -33,7 +34,6 @@ import com.jpexs.decompiler.flash.gui.proxy.ProxyFrame;
|
||||
import com.jpexs.decompiler.flash.helpers.SWFDecompilerPlugin;
|
||||
import com.jpexs.decompiler.flash.tags.base.FontTag;
|
||||
import com.jpexs.decompiler.flash.treeitems.SWFList;
|
||||
import com.jpexs.decompiler.flash.treeitems.TreeItem;
|
||||
import com.jpexs.helpers.Cache;
|
||||
import com.jpexs.helpers.CancellableWorker;
|
||||
import com.jpexs.helpers.Helper;
|
||||
@@ -98,7 +98,6 @@ import javax.swing.SwingWorker;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
import javax.swing.tree.TreePath;
|
||||
|
||||
/**
|
||||
* Main executable class
|
||||
@@ -515,6 +514,14 @@ public class Main {
|
||||
mainFrame.getPanel().gotoDocumentClass(fswf);
|
||||
}
|
||||
|
||||
if (mainFrame != null && fswf != null) {
|
||||
SwfSpecificConfiguration swfConf = Configuration.getSwfSpecificConfiguration(fswf.getShortFileName());
|
||||
if (swfConf != null) {
|
||||
String pathStr = swfConf.lastSelectedPath;
|
||||
mainFrame.getPanel().tagTree.setSelectionPathString(pathStr);
|
||||
}
|
||||
}
|
||||
|
||||
if (executeAfterOpen != null) {
|
||||
executeAfterOpen.run();
|
||||
}
|
||||
@@ -1126,16 +1133,7 @@ public class Main {
|
||||
openFile(sourceInfos, () -> {
|
||||
// last part contains the selected node in the tagtree
|
||||
String pathStr = filesToOpen[filesToOpen.length - 1];
|
||||
if (pathStr.length() > 0) {
|
||||
String[] path = pathStr.split("\\|");
|
||||
|
||||
MainPanel mainPanel = mainFrame.getPanel();
|
||||
TreePath tp = View.getTreePathByPathStrings(mainPanel.tagTree, Arrays.asList(path));
|
||||
if (tp != null) {
|
||||
// the current view is the Resources view, otherwise tp is null
|
||||
mainPanel.setTagTreeSelectedNode((TreeItem) tp.getLastPathComponent());
|
||||
}
|
||||
}
|
||||
mainFrame.getPanel().tagTree.setSelectionPathString(pathStr);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ import java.awt.event.WindowStateListener;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.tree.TreePath;
|
||||
import org.pushingpixels.flamingo.api.ribbon.JRibbon;
|
||||
import org.pushingpixels.flamingo.internal.ui.ribbon.appmenu.JRibbonApplicationMenuButton;
|
||||
|
||||
@@ -127,17 +126,9 @@ public final class MainFrameRibbon extends AppRibbonFrame {
|
||||
}
|
||||
}
|
||||
|
||||
TreePath path = panel.tagTree.getLeadSelectionPath();
|
||||
String path = panel.tagTree.getSelectionPathString();
|
||||
if (path != null) {
|
||||
boolean first = true;
|
||||
for (Object p : path.getPath()) {
|
||||
if (!first) {
|
||||
sb.append("|");
|
||||
}
|
||||
|
||||
first = false;
|
||||
sb.append(p.toString());
|
||||
}
|
||||
sb.append(path);
|
||||
}
|
||||
|
||||
Configuration.lastSessionData.set(sb.toString());
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
|
||||
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.dumpview.DumpInfo;
|
||||
import com.jpexs.decompiler.flash.dumpview.DumpInfoSwfNode;
|
||||
import com.jpexs.decompiler.flash.exporters.BinaryDataExporter;
|
||||
@@ -2808,6 +2809,19 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
treeItem = (TreeItem) treePath.getLastPathComponent();
|
||||
}
|
||||
|
||||
// save last selected node to config
|
||||
if (treeItem != null) {
|
||||
SWF swf = treeItem.getSwf();
|
||||
if (swf != null) {
|
||||
swf = swf.getRootSwf();
|
||||
}
|
||||
|
||||
if (swf != null) {
|
||||
SwfSpecificConfiguration swfConf = Configuration.getOrCreateSwfSpecificConfiguration(swf.getShortFileName());
|
||||
swfConf.lastSelectedPath = tagTree.getSelectionPathString();
|
||||
}
|
||||
}
|
||||
|
||||
if (!forceReload && (treeItem == oldItem)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -621,4 +621,34 @@ public class TagTree extends JTree {
|
||||
expandPath(new TreePath(new Object[]{root, ttm.getChild(root, i)}));
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
public void setSelectionPathString(String pathStr) {
|
||||
if (pathStr != null && pathStr.length() > 0) {
|
||||
String[] path = pathStr.split("\\|");
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user