Merge origin/master

This commit is contained in:
Jindra Petřík
2014-11-11 06:32:35 +01:00
9 changed files with 59 additions and 147 deletions
@@ -2216,6 +2216,10 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
} }
public void loadFromBinaryTag(final DefineBinaryDataTag binaryDataTag) { public void loadFromBinaryTag(final DefineBinaryDataTag binaryDataTag) {
loadFromBinaryTag(Arrays.asList(binaryDataTag));
}
public void loadFromBinaryTag(final List<DefineBinaryDataTag> binaryDataTags) {
if (Main.loadingDialog == null || Main.loadingDialog.getOwner() == null) { if (Main.loadingDialog == null || Main.loadingDialog.getOwner() == null) {
Main.loadingDialog = new LoadingDialog(mainFrame == null ? null : mainFrame.getWindow()); Main.loadingDialog = new LoadingDialog(mainFrame == null ? null : mainFrame.getWindow());
@@ -2227,19 +2231,26 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
@Override @Override
public void run() { public void run() {
try { try {
SWF bswf = new SWF(new ByteArrayInputStream(binaryDataTag.binaryData.getRangeData()), new ProgressListener() { for (DefineBinaryDataTag binaryDataTag : binaryDataTags) {
try {
SWF bswf = new SWF(new ByteArrayInputStream(binaryDataTag.binaryData.getRangeData()), new ProgressListener() {
@Override @Override
public void progress(int p) { public void progress(int p) {
Main.loadingDialog.setPercent(p); Main.loadingDialog.setPercent(p);
}
}, Configuration.parallelSpeedUp.get());
bswf.fileTitle = "(SWF Data)";
binaryDataTag.innerSwf = bswf;
bswf.binaryData = binaryDataTag;
} catch (IOException ex) {
//ignore
} }
}, Configuration.parallelSpeedUp.get()); }
bswf.fileTitle = "(SWF Data)"; } catch (InterruptedException ex) {
binaryDataTag.innerSwf = bswf;
bswf.binaryData = binaryDataTag;
} catch (IOException | InterruptedException ex) {
//ignore //ignore
} }
Main.loadingDialog.setVisible(false); Main.loadingDialog.setVisible(false);
Main.stopWork(); Main.stopWork();
} }
@@ -1,63 +0,0 @@
/*
* 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 javax.swing.JTree;
import javax.swing.tree.TreeModel;
/**
*
* @author JPEXS
*/
public class MyTree extends JTree {
public MyTree() {
setUI(new MyTreeUI());
setBackground(Color.white);
}
public MyTree(TreeModel newModel) {
super(newModel);
setUI(new MyTreeUI());
setBackground(Color.white);
}
private boolean overrideIsEnabled = false;
public void setOverrideIsEnable(boolean b) {
overrideIsEnabled = true;
}
public boolean isOverrideIsEnable(boolean b) {
return overrideIsEnabled;
}
@Override
public boolean isEnabled() {
if (overrideIsEnabled) {
return false;
}
return super.isEnabled();
}
/*
@Override
public void paint(Graphics g) {
g.setColor(Color.white);
g.fillRect(0, 0, getWidth(), getHeight());
super.paint(g);
}*/
}
@@ -1,60 +0,0 @@
/*
* 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.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
import java.lang.reflect.Field;
import javax.swing.tree.TreePath;
import org.pushingpixels.substance.internal.ui.SubstanceTreeUI;
/**
*
* @author JPEXS
*/
class MyTreeUI extends SubstanceTreeUI {
@Override
protected void paintHorizontalPartOfLeg(Graphics g, Rectangle clipBounds,
Insets insets, Rectangle bounds, TreePath path, int row,
boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) {
System.out.println("");
if (this.tree instanceof MyTree) {
Field f = null;
Boolean v = false;
try {
f = SubstanceTreeUI.class.getDeclaredField("inside");
f.setAccessible(true);
v = (Boolean) f.get(this);
f.set(this, Boolean.TRUE);
((MyTree) this.tree).setOverrideIsEnable(true);
} catch (Throwable t) {
//want to default back to substanceUI if this fails.
}
super.paintHorizontalPartOfLeg(g, bounds, insets, bounds, path, row, isLeaf, isLeaf, isLeaf);
try {
f.set(this, v);
((MyTree) this.tree).setOverrideIsEnable(true);
} catch (Throwable t) {
//see above
}
}
}
//repeat for Vertical
}
+9 -1
View File
@@ -69,6 +69,7 @@ import javax.swing.UIDefaults;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException; import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.plaf.FontUIResource; import javax.swing.plaf.FontUIResource;
import javax.swing.plaf.TreeUI;
import javax.swing.plaf.basic.BasicColorChooserUI; import javax.swing.plaf.basic.BasicColorChooserUI;
import javax.swing.text.JTextComponent; import javax.swing.text.JTextComponent;
import javax.swing.tree.TreeModel; import javax.swing.tree.TreeModel;
@@ -514,7 +515,14 @@ public class View {
tree.expandPath(tp); tree.expandPath(tp);
} }
public static void expandTreeNodesRecursive(JTree tree, TreePath parent, boolean expand) { public static void expandTreeNodes(JTree tree, TreePath parent, boolean expand) {
TreeUI ui = tree.getUI();
tree.setUI(null);
expandTreeNodesRecursive(tree, parent, expand);
tree.setUI(ui);
}
private static void expandTreeNodesRecursive(JTree tree, TreePath parent, boolean expand) {
TreeModel model = tree.getModel(); TreeModel model = tree.getModel();
Object node = parent.getLastPathComponent(); Object node = parent.getLastPathComponent();
@@ -211,7 +211,7 @@ public class DumpTree extends JTree implements ActionListener {
if (path == null) { if (path == null) {
return; return;
} }
View.expandTreeNodesRecursive(this, path, true); View.expandTreeNodes(this, path, true);
} }
break; break;
case ACTION_SAVE_TO_FILE: { case ACTION_SAVE_TO_FILE: {
@@ -228,6 +228,9 @@ public class HexView extends JTable {
private int getIdxByColAndRow(int row, int col) { private int getIdxByColAndRow(int row, int col) {
int idx = -1; int idx = -1;
if (row < 0 || col < 0) {
return -1;
}
if (col > 0 && col != bytesInRow + 1) { if (col > 0 && col != bytesInRow + 1) {
idx = row * bytesInRow + ((col > bytesInRow + 1) ? (col - bytesInRow - 2) : (col - 1)); idx = row * bytesInRow + ((col > bytesInRow + 1) ? (col - bytesInRow - 2) : (col - 1));
} }
@@ -113,15 +113,14 @@ import com.jpexs.decompiler.flash.treeitems.TreeItem;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Font; import java.awt.Font;
import java.awt.Graphics;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JTree; import javax.swing.JTree;
import javax.swing.plaf.TreeUI;
import javax.swing.plaf.basic.BasicLabelUI; import javax.swing.plaf.basic.BasicLabelUI;
import javax.swing.plaf.basic.BasicTreeUI; import javax.swing.plaf.basic.BasicTreeUI;
import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.DefaultTreeCellRenderer;
@@ -216,13 +215,15 @@ public class TagTree extends JTree {
setCellRenderer(new TagTreeCellRenderer()); setCellRenderer(new TagTreeCellRenderer());
setRootVisible(false); setRootVisible(false);
setBackground(Color.white); setBackground(Color.white);
setUI(new BasicTreeUI() { setRowHeight(16);
@Override setLargeModel(true);
public void paint(Graphics g, JComponent c) {
TreeUI treeUI = new BasicTreeUI() {
{
setHashColor(Color.gray); setHashColor(Color.gray);
super.paint(g, c);
} }
}); };
setUI(treeUI);
} }
public void createContextMenu() { public void createContextMenu() {
@@ -194,8 +194,9 @@ public class TagTreeContextMenu extends JPopupMenu implements ActionListener {
allSelectedIsSwf = false; allSelectedIsSwf = false;
break; break;
} else if (item instanceof SWF) { } else if (item instanceof SWF) {
SWF swf = (SWF) item;
// Do not allow to close SWF in bundle // Do not allow to close SWF in bundle
if (((SWF) item).swfList.isBundle) { if (swf.swfList != null &&swf.swfList.isBundle) {
allSelectedIsSwf = false; allSelectedIsSwf = false;
} }
} }
@@ -328,11 +329,15 @@ public class TagTreeContextMenu extends JPopupMenu implements ActionListener {
switch (e.getActionCommand()) { switch (e.getActionCommand()) {
case ACTION_OPEN_SWFINSIDE: { case ACTION_OPEN_SWFINSIDE: {
List<TreeItem> sel = tagTree.getSelected(tagTree); List<TreeItem> sel = tagTree.getSelected(tagTree);
List<DefineBinaryDataTag> binaryDatas = new ArrayList<>();
for (TreeItem item : sel) { for (TreeItem item : sel) {
if (item instanceof DefineBinaryDataTag) { DefineBinaryDataTag binaryData = (DefineBinaryDataTag) item;
mainPanel.loadFromBinaryTag((DefineBinaryDataTag) item); if (binaryData.isSwfData()) {
binaryDatas.add((DefineBinaryDataTag) item);
} }
} }
mainPanel.loadFromBinaryTag(binaryDatas);
} }
break; break;
case ACTION_RAW_EDIT: { case ACTION_RAW_EDIT: {
@@ -359,7 +364,7 @@ public class TagTreeContextMenu extends JPopupMenu implements ActionListener {
if (path == null) { if (path == null) {
return; return;
} }
View.expandTreeNodesRecursive(tagTree, path, true); View.expandTreeNodes(tagTree, path, true);
} }
break; break;
case ACTION_REMOVE_ITEM: case ACTION_REMOVE_ITEM:
@@ -403,7 +408,14 @@ public class TagTreeContextMenu extends JPopupMenu implements ActionListener {
List<TreeItem> sel = tagTree.getSelected(tagTree); List<TreeItem> sel = tagTree.getSelected(tagTree);
for (TreeItem item : sel) { for (TreeItem item : sel) {
if (item instanceof SWF) { if (item instanceof SWF) {
Main.closeFile(((SWF) item).swfList); SWF swf = (SWF) item;
if (swf.binaryData != null) {
// embedded swf
swf.binaryData.innerSwf = null;
mainPanel.refreshTree();
} else {
Main.closeFile(swf.swfList);
}
} else if (item instanceof SWFList) { } else if (item instanceof SWFList) {
Main.closeFile((SWFList) item); Main.closeFile((SWFList) item);
} }
@@ -461,7 +461,7 @@ public class TagTreeModel implements TreeModel {
} else if (parentNode instanceof Frame) { } else if (parentNode instanceof Frame) {
return ((Frame) parentNode).innerTags.indexOf(childNode); return ((Frame) parentNode).innerTags.indexOf(childNode);
} else if (parentNode instanceof DefineSpriteTag) { } else if (parentNode instanceof DefineSpriteTag) {
return ((Frame) parentNode).frame; return ((Frame) childNode).frame;
} else if (parentNode instanceof DefineBinaryDataTag) { } else if (parentNode instanceof DefineBinaryDataTag) {
return 0; // binary data tag can have only 1 child return 0; // binary data tag can have only 1 child
} else if (parentNode instanceof AS2Package) { } else if (parentNode instanceof AS2Package) {