From e62dd3092b4156e8f3f3f804de2cf88467a93dc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sat, 5 Jul 2014 10:01:00 +0200 Subject: [PATCH] hex dump moved to separate ribbon task - view + icons space between hex and ASCII dump white foreground for hilighted bytes --- .../jpexs/decompiler/flash/gui/HexView.java | 28 ++++++---- .../flash/gui/MainFrameRibbonMenu.java | 51 ++++++++++++++++-- .../flash/gui/graphics/viewhex16.png | Bin 0 -> 554 bytes .../flash/gui/graphics/viewresources16.png | Bin 0 -> 755 bytes .../flash/gui/locales/MainFrame.properties | 4 ++ .../flash/gui/locales/MainFrame_cs.properties | 6 ++- 6 files changed, 74 insertions(+), 15 deletions(-) create mode 100644 src/com/jpexs/decompiler/flash/gui/graphics/viewhex16.png create mode 100644 src/com/jpexs/decompiler/flash/gui/graphics/viewresources16.png diff --git a/src/com/jpexs/decompiler/flash/gui/HexView.java b/src/com/jpexs/decompiler/flash/gui/HexView.java index adc6ac243..633f670e5 100644 --- a/src/com/jpexs/decompiler/flash/gui/HexView.java +++ b/src/com/jpexs/decompiler/flash/gui/HexView.java @@ -51,19 +51,23 @@ public class HexView extends JTable { JLabel l = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col); int level = -1; if (col > 0 && highlightStarts != null) { - int idx = row * bytesInRow + ((col > bytesInRow) ? (col - bytesInRow - 1) : (col - 1)); - for (int i = 0; i < highlightStarts.length; i++) { - if (highlightStarts[i] <= idx && highlightEnds[i] >= idx) { - level++; - } else { - break; + if(col!=bytesInRow+1){ + int idx = row * bytesInRow + ((col > bytesInRow + 1) ? (col - bytesInRow - 2) : (col - 1)); + for (int i = 0; i < highlightStarts.length; i++) { + if (highlightStarts[i] <= idx && highlightEnds[i] >= idx) { + level++; + } else { + break; + } } } } if (level > -1) { + l.setForeground(Color.white); l.setBackground(highlightColors[level % highlightColors.length]); } else { + l.setForeground(Color.black); l.setBackground(row % 2 == 0 ? bgColor : bgColorAlternate); } @@ -94,7 +98,7 @@ public class HexView extends JTable { @Override public int getColumnCount() { - return 2 * bytesInRow + 1; + return 2 * bytesInRow + 1 + 1; } @Override @@ -117,8 +121,10 @@ public class HexView extends JTable { return String.format("%02X", data[pos]); } return null; + } else if (column == 1 + bytesInRow) { + return null; } else { - int pos = row * bytesInRow + column - bytesInRow - 1; + int pos = row * bytesInRow + column - bytesInRow - 1 - 1; if (pos < data.length) { return (char) data[pos]; } @@ -146,8 +152,12 @@ public class HexView extends JTable { column.setMaxWidth(25); column.setCellRenderer(cellRenderer); } + + column = columnModel.getColumn(bytesInRow + 1); + column.setMaxWidth(10); + for (int i = 0; i < bytesInRow; i++) { - column = columnModel.getColumn(i + bytesInRow + 1); + column = columnModel.getColumn(i + bytesInRow + 1 + 1); column.setMaxWidth(10); column.setCellRenderer(cellRenderer); } diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java index 7ad39a49e..ab2d111ad 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java @@ -50,9 +50,12 @@ import javax.swing.JEditorPane; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.SwingUtilities; +import org.pushingpixels.flamingo.api.common.AbstractCommandButton; import org.pushingpixels.flamingo.api.common.CommandButtonDisplayState; +import org.pushingpixels.flamingo.api.common.CommandToggleButtonGroup; import org.pushingpixels.flamingo.api.common.JCommandButton; import org.pushingpixels.flamingo.api.common.JCommandButtonPanel; +import org.pushingpixels.flamingo.api.common.JCommandToggleButton; import org.pushingpixels.flamingo.api.ribbon.JRibbon; import org.pushingpixels.flamingo.api.ribbon.JRibbonBand; import org.pushingpixels.flamingo.api.ribbon.JRibbonComponent; @@ -118,6 +121,8 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener { static final String ACTION_REFRESH_DECOMPILED = "REFRESHDECOMPILED"; static final String ACTION_CLEAR_RECENT_FILES = "CLEARRECENTFILES"; static final String ACTION_CHECK_RESOURCES = "CHECKRESOURCES"; + static final String ACTION_VIEWMODE_RESOURCES = "VIEWMODERESOURCES"; + static final String ACTION_VIEWMODE_HEX = "VIEWMODEHEX"; private final MainFrameRibbon mainFrame; @@ -137,6 +142,8 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener { private JCommandButton exportFlaCommandButton; private JCommandButton exportSelectionCommandButton; private JCommandButton importTextCommandButton; + private JCommandToggleButton viewModeResourcesToggleButton; + private JCommandToggleButton viewModeHexToggleButton; private JCommandButton reloadCommandButton; private JCommandButton renameinvalidCommandButton; @@ -177,7 +184,7 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener { return mainFrame.translate(key); } - private void assignListener(JCommandButton b, final String command) { + private void assignListener(AbstractCommandButton b, final String command) { final MainFrameRibbonMenu t = this; b.addActionListener(new ActionListener() { @Override @@ -322,8 +329,33 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener { assignListener(importTextCommandButton, ACTION_IMPORT_TEXT); importBand.addCommandButton(importTextCommandButton, RibbonElementPriority.TOP); + + + JRibbonBand viewBand = new JRibbonBand(translate("menu.view"), null); + viewBand.setResizePolicies(getResizePolicies(viewBand)); + + CommandToggleButtonGroup grp=new CommandToggleButtonGroup(); + + viewModeResourcesToggleButton = new JCommandToggleButton(fixCommandTitle(translate("menu.file.view.resources")), View.getResizableIcon("viewresources16")); + assignListener(viewModeResourcesToggleButton, ACTION_VIEWMODE_RESOURCES); + + viewModeHexToggleButton = new JCommandToggleButton(fixCommandTitle(translate("menu.file.view.hex")), View.getResizableIcon("viewhex16")); + assignListener(viewModeHexToggleButton, ACTION_VIEWMODE_HEX); + + grp.add(viewModeResourcesToggleButton); + grp.add(viewModeHexToggleButton); + + if(Configuration.dumpView.get()){ + grp.setSelected(viewModeHexToggleButton, true); + }else{ + grp.setSelected(viewModeResourcesToggleButton, true); + } + + + viewBand.addCommandButton(viewModeResourcesToggleButton, RibbonElementPriority.MEDIUM); + viewBand.addCommandButton(viewModeHexToggleButton, RibbonElementPriority.MEDIUM); - return new RibbonTask(translate("menu.file"), editBand, exportBand, importBand); + return new RibbonTask(translate("menu.file"), editBand, exportBand, importBand, viewBand); } private RibbonTask createToolsRibbonTask() { @@ -427,10 +459,10 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener { miAutoRenameIdentifiers.setActionCommand(ACTION_AUTO_RENAME_IDENTIFIERS); miAutoRenameIdentifiers.addActionListener(this); - miDumpView = new JCheckBox(translate("menu.settings.dumpView")); + /*miDumpView = new JCheckBox(translate("menu.settings.dumpView")); miDumpView.setSelected(Configuration.dumpView.get()); miDumpView.setActionCommand(ACTION_DUMP_VIEW_SWITCH); - miDumpView.addActionListener(this); + miDumpView.addActionListener(this);*/ settingsBand.addRibbonComponent(new JRibbonComponent(miAutoDeobfuscation)); settingsBand.addRibbonComponent(new JRibbonComponent(miInternalViewer)); @@ -442,7 +474,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)); + //settingsBand.addRibbonComponent(new JRibbonComponent(miDumpView)); JRibbonBand languageBand = new JRibbonBand(translate("menu.language"), null); List languageBandResizePolicies = getIconBandResizePolicies(languageBand); @@ -620,6 +652,15 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener { Configuration.internalFlashViewer.set(miInternalViewer.isSelected()); mainFrame.panel.reload(true); break; + + case ACTION_VIEWMODE_RESOURCES: + Configuration.dumpView.set(false); + mainFrame.panel.showDumpView(false); + break; + case ACTION_VIEWMODE_HEX: + Configuration.dumpView.set(true); + mainFrame.panel.showDumpView(true); + break; case ACTION_DUMP_VIEW_SWITCH: Configuration.dumpView.set(miDumpView.isSelected()); mainFrame.panel.showDumpView(miDumpView.isSelected()); diff --git a/src/com/jpexs/decompiler/flash/gui/graphics/viewhex16.png b/src/com/jpexs/decompiler/flash/gui/graphics/viewhex16.png new file mode 100644 index 0000000000000000000000000000000000000000..f6b74cc40f82fc83e4dfa6e9647ccc1b34e6ed7e GIT binary patch literal 554 zcmV+_0@eMAP)Vb2f>2}Fa82O3m(Ob=t*sniin`NpInLyMJgI`saru@YOPfh zy4g0#G*cV!#N%;Gq9_VH9?v%kjS3Rb1j8^;C={$Gp=lbj z*(?%?geA!5^Pok%UauwjA)v4g2`HedDw4_Mk4hhBQt?e7YJ5(hcj|3dNu^TOPGnjB zTTsqd3GIZ=Bb`n=7no)dflv&K(lsWw?lH6T1Yht0F9qgIuzh}ym0%n<3d3EBWB*pg z+G!I0lbAEXyd>k|QNuwr4=KX1D+tLPv)j@C1=N4sA4NF9A>HcO3G47*Y6!+SrUH-7 z1hb;^#S=r|`aMh>J#dWruAEf}gcR(DRUC`ZUev&$Sbh0SgLiTXeeHEU<$_YV;9281 zym`igIE%Sm8DpDw7@71Tv^EB5xSdUR*0$Mqp+Wq8OoaZtOg52&)zZ;;M=7#C1Yd6x svjx>8ad4e2x|*xHHwRjcjs6zA0XLDUqKT6dS^xk507*qoM6N<$fAEsD~v-EDXG-F<&OGY*S3BA8_IBr};$<~uWwQC0qBZ|>xVQt7^l z(!}S1^(Ske7UmrO!!*&y9esxot1o`frT$hpelOdF<(SuhxF@%42a8v}$Ue=tpKj|i zSJoV=l>yA3B)qwui;bhMadW1l=OAAHHe4+eM-Jr=5AX{Qu#Kwt)1rTrQ2Lmhjp8jP zH+Y8bp#!+g5|>7BwMg&ky>t#7#gEoH#aTIL#%^zT*4jBdY|KKIQu+M2lxi918`^q` zxNsL~Oo7HY-TQfUKTl!e*^xaL!s{uc&YFR(SJTEA&}K2lkObfQ#%^wx%H%_*y=xG+ zeHiP%r84!L>X(m_XDg42mH9<57uvZ#BxD_sWQ^cxj1EfBR+Bwu#k>EY3;HCvld{k