mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-27 06:20:55 +00:00
separating gui, classeslisttree removed (it was a duplicated code, which currently is in tagtree)
This commit is contained in:
@@ -55,7 +55,6 @@ import com.jpexs.decompiler.flash.flv.AUDIODATA;
|
||||
import com.jpexs.decompiler.flash.flv.FLVOutputStream;
|
||||
import com.jpexs.decompiler.flash.flv.FLVTAG;
|
||||
import com.jpexs.decompiler.flash.flv.VIDEODATA;
|
||||
import com.jpexs.decompiler.flash.gui.abc.ClassesListTreeModel;
|
||||
import com.jpexs.decompiler.flash.helpers.collections.MyEntry;
|
||||
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag;
|
||||
@@ -213,7 +212,6 @@ public final class SWF {
|
||||
public HashMap<Integer, CharacterTag> characters;
|
||||
public List<ABCContainerTag> abcList;
|
||||
public JPEGTablesTag jtt;
|
||||
public ClassesListTreeModel classTreeModel;
|
||||
|
||||
/**
|
||||
* Gets all tags with specified id
|
||||
|
||||
@@ -771,7 +771,6 @@ public final class MainFramePanel extends JPanel implements ActionListener, Tree
|
||||
pan1.add(new JScrollPane(tagTree), BorderLayout.CENTER);
|
||||
pan1.add(searchPanel, BorderLayout.SOUTH);
|
||||
|
||||
filterField.setActionCommand(ABCPanel.ACTION_FILTER_SCRIPT);
|
||||
filterField.addActionListener(this);
|
||||
|
||||
searchPanel.setVisible(false);
|
||||
@@ -857,6 +856,7 @@ public final class MainFramePanel extends JPanel implements ActionListener, Tree
|
||||
|
||||
swfs.add(swf);
|
||||
swf.abcList = abcList;
|
||||
tagTree.setModel(new TagTreeModel(mainFrame, swfs));
|
||||
|
||||
boolean hasAbc = !abcList.isEmpty();
|
||||
|
||||
@@ -874,7 +874,6 @@ public final class MainFramePanel extends JPanel implements ActionListener, Tree
|
||||
}
|
||||
}
|
||||
|
||||
tagTree.setModel(new TagTreeModel(mainFrame, swfs));
|
||||
expandSwfRoots();
|
||||
|
||||
for (Tag t : swf.tags) {
|
||||
@@ -1329,7 +1328,7 @@ public final class MainFramePanel extends JPanel implements ActionListener, Tree
|
||||
}
|
||||
updateClassesList();
|
||||
reload(true);
|
||||
abcPanel.hilightScript(abcPanel.decompiledTextArea.getScriptLeaf().getPath().toString());
|
||||
abcPanel.hilightScript(abcPanel.swf, abcPanel.decompiledTextArea.getScriptLeaf().getPath().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1535,7 +1534,7 @@ public final class MainFramePanel extends JPanel implements ActionListener, Tree
|
||||
showDetail(DETAILCARDAS3NAVIGATOR);
|
||||
showCard(CARDACTIONSCRIPT3PANEL);
|
||||
abcPanel.setSwf(swf);
|
||||
abcPanel.hilightScript(documentClass);
|
||||
abcPanel.hilightScript(swf, documentClass);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2220,6 +2219,7 @@ public final class MainFramePanel extends JPanel implements ActionListener, Tree
|
||||
setSourceWorker.cancel(true);
|
||||
}
|
||||
if (!Main.isWorking()) {
|
||||
Main.startWork(AppStrings.translate("work.decompiling") + "...");
|
||||
CancellableWorker worker = new CancellableWorker() {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.gui;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.TagNode;
|
||||
import com.jpexs.decompiler.flash.TreeNode;
|
||||
import com.jpexs.decompiler.flash.gui.abc.ClassesListTreeModel;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -30,6 +31,7 @@ public class SWFRoot implements TreeNode {
|
||||
private SWF swf;
|
||||
private String name;
|
||||
public List<TagNode> list;
|
||||
public ClassesListTreeModel classTreeModel;
|
||||
|
||||
public SWFRoot(SWF swf, String name, List<TagNode> list) {
|
||||
this.swf = swf;
|
||||
|
||||
@@ -33,7 +33,9 @@ import com.jpexs.decompiler.flash.tags.base.ContainerItem;
|
||||
import com.jpexs.decompiler.flash.tags.base.SoundStreamHeadTypeTag;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.swing.event.TreeModelListener;
|
||||
import javax.swing.tree.TreeModel;
|
||||
import javax.swing.tree.TreePath;
|
||||
@@ -42,18 +44,23 @@ public class TagTreeModel implements TreeModel {
|
||||
|
||||
private TagTreeRoot root = new TagTreeRoot();
|
||||
private List<SWFRoot> swfs;
|
||||
private Map<SWF, SWFRoot> swfToSwfRoot;
|
||||
private MainFrame mainFrame;
|
||||
|
||||
public TagTreeModel(MainFrame mainFrame, List<SWF> swfs) {
|
||||
this.mainFrame = mainFrame;
|
||||
this.swfs = new ArrayList<>();
|
||||
swfToSwfRoot = new HashMap<>();
|
||||
for (SWF swf : swfs) {
|
||||
List<ContainerItem> objs = new ArrayList<>();
|
||||
objs.addAll(swf.tags);
|
||||
List<TagNode> list = createTagList(objs, null, swf);
|
||||
ClassesListTreeModel classTreeModel = new ClassesListTreeModel(swf);
|
||||
List<TagNode> list = createTagList(objs, null, swf, classTreeModel);
|
||||
|
||||
SWFRoot swfRoot = new SWFRoot(swf, new File(swf.getFileTitle()).getName(), list);
|
||||
swfRoot.classTreeModel = classTreeModel;
|
||||
this.swfs.add(swfRoot);
|
||||
swfToSwfRoot.put(swf, swfRoot);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +83,7 @@ public class TagTreeModel implements TreeModel {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private List<TagNode> createTagList(List<ContainerItem> list, Object parent, SWF swf) {
|
||||
private List<TagNode> createTagList(List<ContainerItem> list, Object parent, SWF swf, ClassesListTreeModel classTreeModel) {
|
||||
List<TagNode> ret = new ArrayList<>();
|
||||
List<TagNode> frames = getTagNodesWithType(list, TagType.FRAME, parent, true);
|
||||
List<TagNode> shapes = getTagNodesWithType(list, TagType.SHAPE, parent, true);
|
||||
@@ -118,7 +125,7 @@ public class TagTreeModel implements TreeModel {
|
||||
TagNode tti = new TagNode(t, t.getSwf());
|
||||
if (((Container) t).getItemCount() > 0) {
|
||||
List<ContainerItem> subItems = ((Container) t).getSubItems();
|
||||
tti.subItems = createTagList(subItems, t, swf);
|
||||
tti.subItems = createTagList(subItems, t, swf, classTreeModel);
|
||||
}
|
||||
//ret.add(tti);
|
||||
}
|
||||
@@ -202,7 +209,7 @@ public class TagTreeModel implements TreeModel {
|
||||
|
||||
if (hasAbc) {
|
||||
actionScriptNode.subItems.clear();
|
||||
actionScriptNode.tag = swf.classTreeModel;
|
||||
actionScriptNode.tag = classTreeModel;
|
||||
}
|
||||
if ((!actionScriptNode.subItems.isEmpty()) || hasAbc) {
|
||||
ret.add(actionScriptNode);
|
||||
@@ -241,6 +248,10 @@ public class TagTreeModel implements TreeModel {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public SWFRoot getSwfRoot(SWF swf) {
|
||||
return swfToSwfRoot.get(swf);
|
||||
}
|
||||
|
||||
public TreePath getTagPath(TreeElementItem obj) {
|
||||
List<TreeNode> path = new ArrayList<>();
|
||||
path.add(getRoot());
|
||||
|
||||
@@ -82,7 +82,6 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Fr
|
||||
|
||||
private MainFramePanel mainFramePanel;
|
||||
public TraitsList navigator;
|
||||
public ClassesListTree classTree;
|
||||
public ABC abc;
|
||||
public SWF swf;
|
||||
public JComboBox abcComboBox;
|
||||
@@ -97,7 +96,6 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Fr
|
||||
public JLabel asmLabel = new HeaderLabel(AppStrings.translate("panel.disassembled"));
|
||||
public JLabel decLabel = new HeaderLabel(AppStrings.translate("panel.decompiled"));
|
||||
public DetailPanel detailPanel;
|
||||
public JTextField filterField = new MyTextField();
|
||||
public JPanel navPanel;
|
||||
public JTabbedPane tabbedPane;
|
||||
public JPanel searchPanel;
|
||||
@@ -113,7 +111,6 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Fr
|
||||
public JLabel scriptNameLabel;
|
||||
|
||||
static final String ACTION_ADD_TRAIT = "ADDTRAIT";
|
||||
public static final String ACTION_FILTER_SCRIPT = "FILTERSCRIPT";
|
||||
static final String ACTION_SEARCH_CANCEL = "SEARCHCANCEL";
|
||||
static final String ACTION_SEARCH_PREV = "SEARCHPREV";
|
||||
static final String ACTION_SEARCH_NEXT = "SEARCHNEXT";
|
||||
@@ -122,7 +119,8 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Fr
|
||||
if ((txt != null) && (!txt.isEmpty())) {
|
||||
searchIgnoreCase = ignoreCase;
|
||||
searchRegexp = regexp;
|
||||
ClassesListTreeModel clModel = (ClassesListTreeModel) classTree.getModel();
|
||||
TagTreeModel ttm = (TagTreeModel) mainFramePanel.tagTree.getModel();
|
||||
ClassesListTreeModel clModel = ttm.getSwfRoot(mainFramePanel.getCurrentSwf()).classTreeModel;
|
||||
List<MyEntry<ClassPath, ScriptPack>> allpacks = clModel.getList();
|
||||
found = new ArrayList<>();
|
||||
final Pattern pat = regexp ?
|
||||
@@ -272,7 +270,6 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Fr
|
||||
this.swf = null;
|
||||
this.abc = null;
|
||||
constantTable.setModel(new DefaultTableModel());
|
||||
classTree.clearDoABCTags();
|
||||
abcComboBox.setModel(new ABCComboBoxModel(new ArrayList<ABCContainerTag>()));
|
||||
navigator.clearABC();
|
||||
}
|
||||
@@ -294,7 +291,6 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Fr
|
||||
|
||||
public void switchAbc(int index) {
|
||||
listIndex = index;
|
||||
classTree.setSwf(swf);
|
||||
|
||||
if (index != -1) {
|
||||
this.abc = swf.abcList.get(index).getABC();
|
||||
@@ -418,37 +414,6 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Fr
|
||||
|
||||
Main.startWork(AppStrings.translate("work.buildingscripttree") + "...");
|
||||
|
||||
filterField.setActionCommand(ACTION_FILTER_SCRIPT);
|
||||
filterField.addActionListener(this);
|
||||
|
||||
|
||||
filterField.getDocument().addDocumentListener(new DocumentListener() {
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
warn();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
warn();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
warn();
|
||||
}
|
||||
|
||||
public void warn() {
|
||||
doFilter();
|
||||
}
|
||||
});
|
||||
|
||||
JPanel treePanel = new JPanel();
|
||||
treePanel.setLayout(new BorderLayout());
|
||||
treePanel.add(new JScrollPane(classTree = new ClassesListTree(this)), BorderLayout.CENTER);
|
||||
JPanel filterPanel = new JPanel();
|
||||
filterPanel.setLayout(new BorderLayout());
|
||||
filterPanel.add(filterField, BorderLayout.CENTER);
|
||||
JButton prevSearchButton = new JButton(View.getIcon("prev16"));
|
||||
prevSearchButton.setMargin(new Insets(3, 3, 3, 3));
|
||||
prevSearchButton.addActionListener(this);
|
||||
@@ -471,9 +436,6 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Fr
|
||||
searchPanel.add(nextSearchButton);
|
||||
searchPanel.add(cancelSearchButton);
|
||||
searchPanel.setVisible(false);
|
||||
JLabel picLabel = new JLabel(View.getIcon("search16"));
|
||||
filterPanel.add(picLabel, BorderLayout.EAST);
|
||||
treePanel.add(filterPanel, BorderLayout.NORTH);
|
||||
|
||||
/* splitPaneTreeVSNavigator = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
|
||||
treePanel,
|
||||
@@ -537,10 +499,6 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Fr
|
||||
tabbedPane.addTab(AppStrings.translate("constants"), panConstants);
|
||||
}
|
||||
|
||||
public void doFilter() {
|
||||
classTree.applyFilter(filterField.getText());
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
switchAbc(listIndex);
|
||||
decompiledTextArea.clearScriptCache();
|
||||
@@ -570,8 +528,9 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Fr
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
public void hilightScript(String name) {
|
||||
ClassesListTreeModel clModel = (ClassesListTreeModel) classTree.getModel();
|
||||
public void hilightScript(SWF swf, String name) {
|
||||
TagTreeModel ttm = (TagTreeModel) mainFramePanel.tagTree.getModel();
|
||||
ClassesListTreeModel clModel = ttm.getSwfRoot(swf).classTreeModel;
|
||||
ScriptPack pack = null;
|
||||
for (MyEntry<ClassPath, ScriptPack> item : clModel.getList()) {
|
||||
if (item.key.toString().equals(name)) {
|
||||
@@ -719,9 +678,6 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Fr
|
||||
decompiledTextArea.gotoTrait(traitId);
|
||||
}
|
||||
|
||||
break;
|
||||
case ACTION_FILTER_SCRIPT:
|
||||
doFilter();
|
||||
break;
|
||||
case ACTION_SEARCH_CANCEL:
|
||||
foundPos = 0;
|
||||
|
||||
@@ -1,160 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2013 JPEXS, Paolo Cancedda
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui.abc;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.abc.ScriptPack;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitClass;
|
||||
import com.jpexs.decompiler.flash.gui.AppStrings;
|
||||
import com.jpexs.decompiler.flash.gui.Main;
|
||||
import com.jpexs.decompiler.flash.gui.View;
|
||||
import com.jpexs.helpers.CancellableWorker;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.event.TreeSelectionEvent;
|
||||
import javax.swing.event.TreeSelectionListener;
|
||||
import javax.swing.tree.DefaultTreeCellRenderer;
|
||||
import javax.swing.tree.TreePath;
|
||||
import javax.swing.tree.TreeSelectionModel;
|
||||
|
||||
public final class ClassesListTree extends JTree implements TreeSelectionListener {
|
||||
|
||||
private ABCPanel abcPanel;
|
||||
private SWF swf;
|
||||
|
||||
public void selectClass(int classIndex) {
|
||||
ClassesListTreeModel model = (ClassesListTreeModel) getModel();
|
||||
TreeElement selectedElement = model.getElementByClassIndex(classIndex);
|
||||
TreePath treePath = selectedElement.getTreePath();
|
||||
setSelectionPath(treePath);
|
||||
scrollPathToVisible(treePath);
|
||||
}
|
||||
|
||||
public ClassesListTree(ABCPanel abcPanel) {
|
||||
this.abcPanel = abcPanel;
|
||||
addTreeSelectionListener(this);
|
||||
DefaultTreeCellRenderer treeRenderer = new DefaultTreeCellRenderer();
|
||||
treeRenderer.setLeafIcon(View.getIcon("as16"));
|
||||
setCellRenderer(treeRenderer);
|
||||
}
|
||||
|
||||
public List<ScriptPack> getSelectedScripts() {
|
||||
TreeSelectionModel tsm = getSelectionModel();
|
||||
final List<ScriptPack> selectedScripts = new ArrayList<>();
|
||||
TreePath[] tps = tsm.getSelectionPaths();
|
||||
if (tps == null) {
|
||||
return selectedScripts;
|
||||
}
|
||||
for (TreePath tp : tps) {
|
||||
TreeElement te = (TreeElement) tp.getLastPathComponent();
|
||||
if (te.isLeaf()) {
|
||||
Object item = te.getItem();
|
||||
if (item instanceof ScriptPack) {
|
||||
selectedScripts.add((ScriptPack) item);
|
||||
}
|
||||
} else {
|
||||
TreeVisitor tvi = new TreeVisitor() {
|
||||
@Override
|
||||
public void onBranch(TreeElement branch) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLeaf(TreeElement leaf) {
|
||||
Object item = leaf.getItem();
|
||||
if (item instanceof ScriptPack) {
|
||||
selectedScripts.add((ScriptPack) item);
|
||||
}
|
||||
}
|
||||
};
|
||||
te.visitBranches(tvi);
|
||||
te.visitLeafs(tvi);
|
||||
}
|
||||
}
|
||||
return selectedScripts;
|
||||
}
|
||||
|
||||
public void clearDoABCTags() {
|
||||
this.swf = null;
|
||||
setModel(null);
|
||||
}
|
||||
|
||||
public void setSwf(SWF swf) {
|
||||
if (swf != this.swf) {
|
||||
this.swf = swf;
|
||||
if (swf.classTreeModel == null) {
|
||||
swf.classTreeModel = new ClassesListTreeModel(swf);
|
||||
}
|
||||
setModel(swf.classTreeModel);
|
||||
}
|
||||
}
|
||||
|
||||
public void applyFilter(String filter) {
|
||||
getModel().setFilter(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassesListTreeModel getModel() {
|
||||
return (ClassesListTreeModel) super.getModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void valueChanged(TreeSelectionEvent e) {
|
||||
if (Main.isWorking()) {
|
||||
return;
|
||||
}
|
||||
final TreeElement tp = (TreeElement) getLastSelectedPathComponent();
|
||||
if (tp == null) {
|
||||
return;
|
||||
}
|
||||
Object item = tp.getItem();
|
||||
if (item instanceof ScriptPack) {
|
||||
final ScriptPack scriptLeaf = (ScriptPack) item;
|
||||
if (!Main.isWorking()) {
|
||||
Main.startWork(AppStrings.translate("work.decompiling") + "...");
|
||||
new CancellableWorker() {
|
||||
@Override
|
||||
public Void doInBackground() throws Exception {
|
||||
int classIndex = -1;
|
||||
for (Trait t : scriptLeaf.abc.script_info[scriptLeaf.scriptIndex].traits.traits) {
|
||||
if (t instanceof TraitClass) {
|
||||
classIndex = ((TraitClass) t).class_info;
|
||||
break;
|
||||
}
|
||||
}
|
||||
abcPanel.navigator.setABC(swf.abcList, scriptLeaf.abc);
|
||||
abcPanel.navigator.setClassIndex(classIndex, scriptLeaf.scriptIndex);
|
||||
abcPanel.setAbc(scriptLeaf.abc);
|
||||
abcPanel.decompiledTextArea.setScript(scriptLeaf, swf.abcList);
|
||||
abcPanel.decompiledTextArea.setClassIndex(classIndex);
|
||||
abcPanel.decompiledTextArea.setNoTrait();
|
||||
abcPanel.detailPanel.methodTraitPanel.methodCodePanel.clear();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
Main.stopWork();
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -87,7 +87,6 @@ public class UsageFrame extends AppFrame implements ActionListener, MouseListene
|
||||
MultinameUsage usage = usageListModel.getUsage(usageList.getSelectedIndex());
|
||||
if (usage instanceof InsideClassMultinameUsage) {
|
||||
InsideClassMultinameUsage icu = (InsideClassMultinameUsage) usage;
|
||||
abcPanel.classTree.selectClass(icu.classIndex);
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException ex) {
|
||||
|
||||
Reference in New Issue
Block a user