Issue #134 Goto document class

This commit is contained in:
Jindra Petk
2013-06-23 19:06:56 +02:00
parent 140370dc1c
commit 24bfd5f5ee
5 changed files with 46 additions and 8 deletions

View File

@@ -77,7 +77,7 @@ public class ScriptPack {
scriptName = name.getName(abc.constants, new ArrayList<String>());
}
}
return packageName + "." + scriptName;
return packageName.equals("") ? scriptName : packageName + "." + scriptName;
}
private static String makeDirPath(String packageName) {

View File

@@ -446,13 +446,25 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener {
setVisible(true);
}
public void hilightScript(String name) {
ClassesListTreeModel clModel = (ClassesListTreeModel) classTree.getModel();
ScriptPack pack = clModel.getList().get(name);
if (pack != null) {
hilightScript(pack);
}
}
public void hilightScript(ScriptPack pack) {
TagTreeModel ttm = (TagTreeModel) Main.mainFrame.tagTree.getModel();
TreePath tp = ttm.getTagPath(pack);
Main.mainFrame.tagTree.setSelectionPath(tp);
Main.mainFrame.tagTree.scrollPathToVisible(tp);
}
public void updateSearchPos() {
searchPos.setText((foundPos + 1) + "/" + found.size());
decompiledTextArea.setScript(found.get(foundPos), list);
TagTreeModel ttm = (TagTreeModel) Main.mainFrame.tagTree.getModel();
TreePath tp = ttm.getTagPath(found.get(foundPos));
Main.mainFrame.tagTree.setSelectionPath(tp);
Main.mainFrame.tagTree.scrollPathToVisible(tp);
hilightScript(found.get(foundPos));
decompiledTextArea.setCaretPosition(0);
java.util.Timer t = new java.util.Timer();
t.schedule(new TimerTask() {

View File

@@ -94,8 +94,8 @@ public class ClassesListTreeModel implements TreeModel {
}
}
}
String nsName = path.substring(path.lastIndexOf(".") + 1);
String packageName = path.substring(0, path.lastIndexOf("."));
String nsName = path.contains(".") ? path.substring(path.lastIndexOf(".") + 1) : path;
String packageName = path.contains(".") ? path.substring(0, path.lastIndexOf(".")) : "";
classTree.add(nsName, packageName, list.get(path));
}
this.list = list;

View File

@@ -52,7 +52,7 @@ public class ScriptInfo {
|| (ns.kind == Namespace.KIND_PACKAGE)) {
String packageName = ns.getName(abc.constants);
String objectName = name.getName(abc.constants, new ArrayList<String>());
String path = packageName + "." + objectName;
String path = packageName.equals("") ? objectName : packageName + "." + objectName;
List<Integer> traitIndices = new ArrayList<>();
traitIndices.add(j);

View File

@@ -72,6 +72,7 @@ import com.jpexs.decompiler.flash.tags.SoundStreamBlockTag;
import com.jpexs.decompiler.flash.tags.SoundStreamHead2Tag;
import com.jpexs.decompiler.flash.tags.SoundStreamHeadTag;
import com.jpexs.decompiler.flash.tags.SoundStreamHeadTypeTag;
import com.jpexs.decompiler.flash.tags.SymbolClassTag;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.tags.base.ASMSource;
import com.jpexs.decompiler.flash.tags.base.AloneTag;
@@ -403,6 +404,13 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
//menuTools.add(menuDeobfuscation);
menuTools.add(menuDeobfuscation);
JMenuItem miGotoDocumentClass = new JMenuItem("Go to document class");
miGotoDocumentClass.setActionCommand("GOTODOCUMENTCLASS");
miGotoDocumentClass.addActionListener(this);
if (swf.fileAttributes.actionScript3) {
menuTools.add(miGotoDocumentClass);
}
menuBar.add(menuTools);
JMenu menuHelp = new JMenu("Help");
@@ -1239,6 +1247,24 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
@Override
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case "GOTODOCUMENTCLASS":
String documentClass = null;
loopdc:
for (Tag t : swf.tags) {
if (t instanceof SymbolClassTag) {
SymbolClassTag sc = (SymbolClassTag) t;
for (int i = 0; i < sc.tagIDs.length; i++) {
if (sc.tagIDs[i] == 0) {
documentClass = sc.classNames[i];
break loopdc;
}
}
}
}
if (documentClass != null) {
abcPanel.hilightScript(documentClass);
}
break;
case "PARALLELSPEEDUP":
String confStr = "Parallelism can speed up loading and decompilation but uses more memory.\r\n";
if (miParallelSpeedUp.isSelected()) {