From b0d23e9d3ea846a49ec9cfb97d0115911fb3b5b3 Mon Sep 17 00:00:00 2001 From: honfika <> Date: Tue, 24 Jun 2014 14:07:48 +0200 Subject: [PATCH] show abc and actionbytes in dump view, hexview style fixes --- src/com/jpexs/decompiler/flash/abc/ABC.java | 2 ++ .../jpexs/decompiler/flash/gui/HexView.java | 30 +++++++++++-------- .../decompiler/flash/tags/DoActionTag.java | 4 +-- .../flash/tags/DoInitActionTag.java | 4 +-- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/com/jpexs/decompiler/flash/abc/ABC.java b/src/com/jpexs/decompiler/flash/abc/ABC.java index eaf80995c..7bc1b2f7f 100644 --- a/src/com/jpexs/decompiler/flash/abc/ABC.java +++ b/src/com/jpexs/decompiler/flash/abc/ABC.java @@ -340,6 +340,8 @@ public class ABC { this.swf = swf; this.parentTag = tag; ABCInputStream ais = new ABCInputStream(is.getBaseStream()); + // put it to the dumpview: + is.readBytesEx(is.available(), "abcBytes"); minor_version = ais.readU16(); major_version = ais.readU16(); logger.log(Level.FINE, "ABC minor_version: {0}, major_version: {1}", new Object[]{minor_version, major_version}); diff --git a/src/com/jpexs/decompiler/flash/gui/HexView.java b/src/com/jpexs/decompiler/flash/gui/HexView.java index 8a6837ea7..b4ebe9a22 100644 --- a/src/com/jpexs/decompiler/flash/gui/HexView.java +++ b/src/com/jpexs/decompiler/flash/gui/HexView.java @@ -27,7 +27,6 @@ import javax.swing.table.AbstractTableModel; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.JTableHeader; import javax.swing.table.TableColumn; -import javax.swing.table.TableColumnModel; /** * @@ -41,6 +40,8 @@ public class HexView extends JTable { private byte[] data; private final String[] highlightColorsStr = new String[]{/*"EEEEEE", */"29AEC2", "9AC88C", "DF5F80", "EEA32E", "FFD200", "5E9B4C", "D3E976", "A3AEC2"}; private final Color[] highlightColors; + private Color bgColor = Color.decode("#F7F7F7"); + private Color bgColorAlternate = Color.decode("#EDEDED"); public class HighlightCellRenderer extends DefaultTableCellRenderer { @@ -48,9 +49,9 @@ public class HexView extends JTable { public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) { JLabel l = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col); - if (highlightStarts != null) { + int level = -1; + if (col > 0 && highlightStarts != null) { int idx = row * bytesInRow + ((col > bytesInRow) ? (col - bytesInRow - 1) : (col - 1)); - int level = -1; for (int i = 0; i < highlightStarts.length; i++) { if (highlightStarts[i] <= idx && highlightEnds[i] >= idx) { level++; @@ -58,12 +59,14 @@ public class HexView extends JTable { break; } } - if (level > -1) { - l.setBackground(highlightColors[level % highlightColors.length]); - } else { - l.setBackground(Color.white); - } } + + if (level > -1) { + l.setBackground(highlightColors[level % highlightColors.length]); + } else { + l.setBackground(row % 2 == 0 ? bgColor : bgColorAlternate); + } + return l; } } @@ -131,17 +134,20 @@ public class HexView extends JTable { setShowHorizontalLines(false); setShowVerticalLines(false); + setRowSelectionAllowed(false); + setColumnSelectionAllowed(false); HighlightCellRenderer cellRenderer = new HighlightCellRenderer(); - TableColumnModel columnModel = getColumnModel(); - columnModel.getColumn(0).setMaxWidth(80); + TableColumn column = columnModel.getColumn(0); + column.setMaxWidth(80); + //column.setCellRenderer(cellRenderer); for (int i = 0; i < bytesInRow; i++) { - TableColumn column = columnModel.getColumn(i + 1); + column = columnModel.getColumn(i + 1); column.setMaxWidth(25); column.setCellRenderer(cellRenderer); } for (int i = 0; i < bytesInRow; i++) { - TableColumn column = columnModel.getColumn(i + bytesInRow + 1); + column = columnModel.getColumn(i + bytesInRow + 1); column.setMaxWidth(10); column.setCellRenderer(cellRenderer); } diff --git a/src/com/jpexs/decompiler/flash/tags/DoActionTag.java b/src/com/jpexs/decompiler/flash/tags/DoActionTag.java index 20863a926..ca0f279e9 100644 --- a/src/com/jpexs/decompiler/flash/tags/DoActionTag.java +++ b/src/com/jpexs/decompiler/flash/tags/DoActionTag.java @@ -56,8 +56,8 @@ public class DoActionTag extends Tag implements ASMSource { */ public DoActionTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DoAction", pos, length); - //do not load actionBytes. Disassebler will use the original SWF stream in this case - //actionBytes = sis.readBytesEx(sis.available()); + //do not store actionBytes. Disassebler will use the original SWF stream in this case + sis.readBytesEx(sis.available(), "actionBytes"); } /** diff --git a/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java b/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java index 7963f06e7..c89d6875f 100644 --- a/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java +++ b/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java @@ -62,8 +62,8 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource { public DoInitActionTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DoInitAction", pos, length); spriteId = sis.readUI16("spriteId"); - //actions = sis.readActionList(); - actionBytes = sis.readBytesEx(sis.available(), "actionBytes"); + //do not store actionBytes. Disassebler will use the original SWF stream in this case + sis.readBytesEx(sis.available(), "actionBytes"); } /**