basic dump view

This commit is contained in:
honfika
2014-06-21 20:36:55 +02:00
parent 6232a141b7
commit a0804e2cb9
112 changed files with 2082 additions and 1954 deletions
@@ -0,0 +1,75 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* 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;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import javax.swing.JComponent;
import javax.swing.JTree;
import javax.swing.plaf.basic.BasicLabelUI;
import javax.swing.plaf.basic.BasicTreeUI;
import javax.swing.tree.DefaultTreeCellRenderer;
/**
*
* @author JPEXS
*/
public class DumpTree extends JTree {
public class DumpTreeCellRenderer extends DefaultTreeCellRenderer {
@Override
public Component getTreeCellRendererComponent(
JTree tree,
Object value,
boolean sel,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus) {
super.getTreeCellRendererComponent(
tree, value, sel,
expanded, leaf, row,
hasFocus);
//DumpInfo dumpInfo = (DumpInfo) value;
setUI(new BasicLabelUI());
setOpaque(false);
setBackgroundNonSelectionColor(Color.white);
return this;
}
}
DumpTree(DumpTreeModel treeModel) {
super(treeModel);
setCellRenderer(new DumpTreeCellRenderer());
setRootVisible(false);
setBackground(Color.white);
setUI(new BasicTreeUI() {
@Override
public void paint(Graphics g, JComponent c) {
setHashColor(Color.gray);
super.paint(g, c);
}
});
}
}
@@ -0,0 +1,84 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* 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;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.dumpview.DumpInfo;
import com.jpexs.decompiler.flash.treeitems.SWFList;
import java.util.List;
import javax.swing.event.TreeModelListener;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
/**
*
* @author JPEXS
*/
public class DumpTreeModel implements TreeModel {
private final DumpInfo root;
public DumpTreeModel(List<SWFList> swfs) {
DumpInfo root = new DumpInfo("root", "", null, 0, 0);
for (SWFList swfList : swfs) {
for (SWF swf : swfList) {
swf.dumpInfo.name = swf.getFileTitle();
root.childInfos.add(swf.dumpInfo);
}
}
this.root = root;
}
@Override
public Object getRoot() {
return root;
}
@Override
public Object getChild(Object o, int i) {
return ((DumpInfo) o).childInfos.get(i);
}
@Override
public int getChildCount(Object o) {
return ((DumpInfo) o).childInfos.size();
}
@Override
public boolean isLeaf(Object o) {
return ((DumpInfo) o).childInfos.isEmpty();
}
@Override
public void valueForPathChanged(TreePath tp, Object o) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public int getIndexOfChild(Object o, Object o1) {
return ((DumpInfo) o).childInfos.indexOf(o1);
}
@Override
public void addTreeModelListener(TreeModelListener tl) {
}
@Override
public void removeTreeModelListener(TreeModelListener tl) {
}
}
File diff suppressed because it is too large Load Diff
@@ -86,6 +86,7 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener {
static final String ACTION_GOTO_DOCUMENT_CLASS = "GOTODOCUMENTCLASS";
static final String ACTION_PARALLEL_SPEED_UP = "PARALLELSPEEDUP";
static final String ACTION_INTERNAL_VIEWER_SWITCH = "INTERNALVIEWERSWITCH";
static final String ACTION_DUMP_VIEW_SWITCH = "DUMPVIEWSWITCH";
static final String ACTION_SEARCH = "SEARCH";
static final String ACTION_TIMELINE = "TIMELINE";
static final String ACTION_AUTO_DEOBFUSCATE = "AUTODEOBFUSCATE";
@@ -122,6 +123,7 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener {
private JCheckBox miAutoDeobfuscation;
private JCheckBox miInternalViewer;
private JCheckBox miDumpView;
private JCheckBox miParallelSpeedUp;
private JCheckBox miAssociate;
private JCheckBox miDecompile;
@@ -425,6 +427,11 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener {
miAutoRenameIdentifiers.setActionCommand(ACTION_AUTO_RENAME_IDENTIFIERS);
miAutoRenameIdentifiers.addActionListener(this);
miDumpView = new JCheckBox(translate("menu.settings.dumpView"));
miDumpView.setSelected(Configuration.dumpView.get());
miDumpView.setActionCommand(ACTION_DUMP_VIEW_SWITCH);
miDumpView.addActionListener(this);
settingsBand.addRibbonComponent(new JRibbonComponent(miAutoDeobfuscation));
settingsBand.addRibbonComponent(new JRibbonComponent(miInternalViewer));
settingsBand.addRibbonComponent(new JRibbonComponent(miParallelSpeedUp));
@@ -435,6 +442,7 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener {
settingsBand.addRibbonComponent(new JRibbonComponent(miCacheDisk));
settingsBand.addRibbonComponent(new JRibbonComponent(miGotoMainClassOnStartup));
settingsBand.addRibbonComponent(new JRibbonComponent(miAutoRenameIdentifiers));
settingsBand.addRibbonComponent(new JRibbonComponent(miDumpView));
JRibbonBand languageBand = new JRibbonBand(translate("menu.language"), null);
List<RibbonBandResizePolicy> languageBandResizePolicies = getIconBandResizePolicies(languageBand);
@@ -610,6 +618,10 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener {
Configuration.internalFlashViewer.set(miInternalViewer.isSelected());
mainFrame.panel.reload(true);
break;
case ACTION_DUMP_VIEW_SWITCH:
Configuration.internalFlashViewer.set(miDumpView.isSelected());
mainFrame.panel.showDumpView(miDumpView.isSelected());
break;
case ACTION_SEARCH:
mainFrame.panel.searchAs();
break;
@@ -26,6 +26,7 @@ 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.configuration.Configuration;
import com.jpexs.decompiler.flash.dumpview.DumpInfo;
import com.jpexs.decompiler.flash.exporters.BinaryDataExporter;
import com.jpexs.decompiler.flash.exporters.FontExporter;
import com.jpexs.decompiler.flash.exporters.ImageExporter;
@@ -221,14 +222,18 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
private final JProgressBar progressBar = new JProgressBar(0, 100);
private DeobfuscationDialog deobfuscationDialog;
public TagTree tagTree;
public DumpTree dumpTree;
private final FlashPlayerPanel flashPanel;
private final JPanel contentPanel;
private final JPanel displayPanel;
private JPanel folderPreviewPanel;
private JPanel dumpViewPanel;
private JLabel dumpViewLabel; // very very simple dump view, todo: hexview with virtual scrolling
private boolean isWelcomeScreen = true;
private static final String CARDPREVIEWPANEL = "Preview card";
private static final String CARDFOLDERPREVIEWPANEL = "Folder preview card";
private static final String CARDEMPTYPANEL = "Empty card";
private static final String CARDDUMPVIEW = "Dump view";
private static final String CARDACTIONSCRIPTPANEL = "ActionScript card";
private static final String CARDACTIONSCRIPT3PANEL = "ActionScript3 card";
private static final String DETAILCARDAS3NAVIGATOR = "Traits list";
@@ -242,6 +247,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
private JTextField filterField = new MyTextField("");
private JPanel searchPanel;
private PreviewPanel previewPanel;
private JPanel treePanel;
private AbortRetryIgnoreHandler errorHandler = new GuiAbortRetryIgnoreHandler();
private CancellableWorker setSourceWorker;
public TreeNode oldNode;
@@ -494,6 +500,16 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
return folderPreviewCard;
}
private JPanel createDumpPreviewCard() {
JPanel dumpViewCard = new JPanel(new BorderLayout());
dumpViewPanel = new JPanel(new WrapLayout(FlowLayout.LEFT));
dumpViewLabel = new JLabel();
dumpViewPanel.add(dumpViewLabel);
dumpViewCard.add(new JScrollPane(dumpViewPanel), BorderLayout.CENTER);
return dumpViewCard;
}
public String translate(String key) {
return mainFrame.translate(key);
}
@@ -603,6 +619,9 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
createContextMenu();
dumpTree = new DumpTree((DumpTreeModel) null);
dumpTree.addTreeSelectionListener(this);
statusPanel = new MainFrameStatusPanel(this);
add(statusPanel, BorderLayout.SOUTH);
@@ -611,6 +630,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
previewPanel = new PreviewPanel(this, flashPanel);
displayPanel.add(previewPanel, CARDPREVIEWPANEL);
displayPanel.add(createFolderPreviewCard(), CARDFOLDERPREVIEWPANEL);
displayPanel.add(createDumpPreviewCard(), CARDDUMPVIEW);
displayPanel.add(new JPanel(), CARDEMPTYPANEL);
showCard(CARDEMPTYPANEL);
@@ -629,9 +649,9 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
}
});
searchPanel.add(closeSearchButton, BorderLayout.EAST);
JPanel pan1 = new JPanel(new BorderLayout());
pan1.add(new JScrollPane(tagTree), BorderLayout.CENTER);
pan1.add(searchPanel, BorderLayout.SOUTH);
treePanel = new JPanel(new BorderLayout());
showDumpView(Configuration.dumpView.get());
treePanel.add(searchPanel, BorderLayout.SOUTH);
filterField.addActionListener(this);
@@ -659,7 +679,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
});
//displayPanel.setBorder(BorderFactory.createLineBorder(Color.black));
splitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, pan1, detailPanel);
splitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, treePanel, detailPanel);
splitPane1 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, splitPane2, displayPanel);
welcomePanel = createWelcomePanel();
@@ -719,6 +739,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
swf.isAS3 = hasAbc;
tagTree.setModel(new TagTreeModel(mainFrame, swfs));
dumpTree.setModel(new DumpTreeModel(swfs));
if (hasAbc) {
if (abcPanel == null) {
@@ -2363,8 +2384,25 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
cl.show(displayPanel, card);
}
private void dumpTreeValueChanged(TreeSelectionEvent e) {
showCard(CARDDUMPVIEW);
DumpInfo dumpInfo = (DumpInfo) e.getPath().getLastPathComponent();
if (dumpInfo.lengthBytes != 0 || dumpInfo.lengthBits != 0) {
// todo
dumpViewLabel.setText("startByte: " + dumpInfo.startByte +
" startBit: " + dumpInfo.startBit +
" lengthBytes: " + dumpInfo.lengthBytes +
" lengthBits: " + dumpInfo.lengthBits);
}
}
@Override
public void valueChanged(TreeSelectionEvent e) {
Object source = e.getSource();
if (source == dumpTree) {
dumpTreeValueChanged(e);
return;
}
TreeNode treeNode = (TreeNode) e.getPath().getLastPathComponent();
TreeItem treeItem = treeNode.getItem();
if (!(treeItem instanceof SWFList)) {
@@ -2404,6 +2442,16 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
return mainMenu.isInternalFlashViewerSelected();
}
public void showDumpView(boolean show) {
treePanel.removeAll();
if (show) {
treePanel.add(new JScrollPane(dumpTree), BorderLayout.CENTER);
} else {
treePanel.add(new JScrollPane(tagTree), BorderLayout.CENTER);
}
treePanel.revalidate();
}
public void reload(boolean forceReload) {
TreeNode treeNode = (TreeNode) tagTree.getLastSelectedPathComponent();
if (treeNode == null) {
@@ -16,7 +16,10 @@
*/
package com.jpexs.decompiler.flash.gui;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.gui.player.MediaDisplay;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.tags.base.SoundTag;
import com.jpexs.helpers.SoundPlayer;
import java.awt.Color;
@@ -67,7 +70,9 @@ public class SoundTagPlayer implements MediaDisplay {
this.tag = tag;
this.loops = loops;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
tag.getSoundFormat().createWav(tag.getRawSoundData(), baos);
byte[] soundData = tag.getRawSoundData();
SWF swf = ((Tag) tag).getSwf();
tag.getSoundFormat().createWav(new SWFInputStream(swf, soundData), baos);
player = new SoundPlayer(new ByteArrayInputStream(baos.toByteArray()));
}
@@ -486,3 +486,5 @@ abc.action.find-declaration = Find declaration
contextmenu.rawEdit = Raw edit
contextmenu.jumpToCharacter = Jump to character
menu.settings.dumpView = Dump view