Optimize various stuff

This commit is contained in:
Nico Mexis 2021-12-20 00:24:17 +01:00
parent dac8dcc6c7
commit 86fb69f694
No known key found for this signature in database
GPG Key ID: 27D6E17CE092AB78
53 changed files with 253 additions and 454 deletions

View File

@ -14,35 +14,35 @@
<lib>w32api/libshell32.a</lib> <lib>w32api/libshell32.a</lib>
<jar>H:\Repo\BCV\bytecode-viewer\BytecodeViewer 2.9.8.jar</jar> <jar>H:\Repo\BCV\bytecode-viewer\BytecodeViewer 2.9.8.jar</jar>
<outfile>H:\Repo\BCV\bytecode-viewer\BytecodeViewer.exe</outfile> <outfile>H:\Repo\BCV\bytecode-viewer\BytecodeViewer.exe</outfile>
<errTitle></errTitle> <errTitle/>
<cmdLine></cmdLine> <cmdLine/>
<chdir>.</chdir> <chdir>.</chdir>
<priority>normal</priority> <priority>normal</priority>
<downloadUrl>http://java.com/download</downloadUrl> <downloadUrl>https://java.com/de/download/</downloadUrl>
<supportUrl></supportUrl> <supportUrl/>
<stayAlive>false</stayAlive> <stayAlive>false</stayAlive>
<restartOnCrash>false</restartOnCrash> <restartOnCrash>false</restartOnCrash>
<manifest></manifest> <manifest/>
<icon>H:\Repo\BCV\bytecode-viewer\BCV Icon.ico</icon> <icon>H:\Repo\BCV\bytecode-viewer\BCV Icon.ico</icon>
<jre> <jre>
<path></path> <path/>
<bundledJre64Bit>false</bundledJre64Bit> <bundledJre64Bit>false</bundledJre64Bit>
<bundledJreAsFallback>false</bundledJreAsFallback> <bundledJreAsFallback>false</bundledJreAsFallback>
<minVersion>1.7.0_00</minVersion> <minVersion>1.7.0_00</minVersion>
<maxVersion></maxVersion> <maxVersion/>
<jdkPreference>preferJre</jdkPreference> <jdkPreference>preferJre</jdkPreference>
<runtimeBits>64/32</runtimeBits> <runtimeBits>64/32</runtimeBits>
</jre> </jre>
<versionInfo> <versionInfo>
<fileVersion>0.2.9.7</fileVersion> <fileVersion>0.2.9.7</fileVersion>
<txtFileVersion>http://the.bytecode.club</txtFileVersion> <txtFileVersion>https://the.bytecode.club/</txtFileVersion>
<fileDescription>Bytecode Viewer</fileDescription> <fileDescription>Bytecode Viewer</fileDescription>
<copyright>http://bytecodeviewer.com</copyright> <copyright>https://bytecodeviewer.com/</copyright>
<productVersion>0.2.9.6</productVersion> <productVersion>0.2.9.6</productVersion>
<txtProductVersion>http://the.bytecode.club</txtProductVersion> <txtProductVersion>https://the.bytecode.club/</txtProductVersion>
<productName>Bytecode Viewer</productName> <productName>Bytecode Viewer</productName>
<companyName></companyName> <companyName/>
<internalName>BCV</internalName> <internalName>BCV</internalName>
<originalFilename>Bytecode_Viewer.exe</originalFilename> <originalFilename>Bytecode_Viewer.exe</originalFilename>
</versionInfo> </versionInfo>
</launch4jConfig> </launch4jConfig>

View File

@ -1,14 +1,14 @@
import the.bytecode.club.bytecodeviewer.api.*; import org.objectweb.asm.tree.ClassNode
import java.util.ArrayList; import the.bytecode.club.bytecodeviewer.api.Plugin
import org.objectweb.asm.tree.ClassNode; import the.bytecode.club.bytecodeviewer.api.PluginConsole
import the.bytecode.club.bytecodeviewer.decompilers.*;
public class Skeleton extends Plugin { class Skeleton extends Plugin {
@Override @Override
public void execute(ArrayList<ClassNode> classNodesList) { void execute(List<ClassNode> classNodesList) {
PluginConsole gui = new PluginConsole("Skeleton"); PluginConsole gui = new PluginConsole("Skeleton")
gui.setVisible(true); gui.setVisible(true)
gui.appendText("executed skeleton"); gui.appendText("executed skeleton")
} }
}
}

View File

@ -1,52 +1,54 @@
import the.bytecode.club.bytecodeviewer.api.* import org.objectweb.asm.tree.ClassNode
import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialog;
import java.util.ArrayList;
import java.lang.reflect.Field;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldNode import org.objectweb.asm.tree.FieldNode
import the.bytecode.club.bytecodeviewer.api.BCV
import the.bytecode.club.bytecodeviewer.api.Plugin
import the.bytecode.club.bytecodeviewer.api.PluginConsole
import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialog
import static the.bytecode.club.bytecodeviewer.Constants.nl; import java.lang.reflect.Field
import static the.bytecode.club.bytecodeviewer.Constants.nl
/** /**
* This is an example of a string decrypter plugin * This is an example of a string decrypter plugin
*/ */
public class ExampleStringDecrypter extends Plugin { class ExampleStringDecrypter extends Plugin {
@Override @Override
public void execute(ArrayList<ClassNode> classNodesList) { void execute(List<ClassNode> classNodesList) {
PluginConsole gui = new PluginConsole("Example String Decrypter"); PluginConsole gui = new PluginConsole("Example String Decrypter")
MultipleChoiceDialog dialog = new MultipleChoiceDialog("Bytecode Viewer - WARNING", MultipleChoiceDialog dialog = new MultipleChoiceDialog("Bytecode Viewer - WARNING",
"WARNING: This will load the classes into the JVM and execute the initialize function" "WARNING: This will load the classes into the JVM and execute the initialize function"
+ nl + "for each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE.", + nl + "for each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE.",
new String[]{"Continue", "Cancel"}); new String[]{"Continue", "Cancel"})
if(dialog.promptChoice() == 0) if(dialog.promptChoice() == 0)
{ {
for(ClassNode cn : classNodesList) for(ClassNode cn : classNodesList)
{ {
BCV.getClassNodeLoader().addClass(cn); BCV.getClassNodeLoader().addClass(cn)
for(Object o : cn.fields.toArray()) for(Object o : cn.fields.toArray())
{ {
FieldNode f = (FieldNode) o; FieldNode f = (FieldNode) o
if(f.name.equals("z")) {// && f.desc.equals("([Ljava/lang/String;)V")) { if(f.name == "z") {// && f.desc.equals("([Ljava/lang/String;)V")) {
try try
{ {
for(Field f2 : BCV.getClassNodeLoader().nodeToClass(cn).getFields()) for(Field f2 : BCV.getClassNodeLoader().nodeToClass(cn).getFields())
{ {
String s = f2.get(null); String s = f2.get(null)
if(s != null && !s.empty()) if(s != null && !s.empty)
gui.appendText(cn+":"+s); gui.appendText(cn + ":" + s)
} }
} catch(Exception | StackOverflowError e) {} } catch(Exception | StackOverflowError ignored) {}
} }
} }
} }
gui.setVisible(true); gui.setVisible(true)
} }
} }
}
}

View File

@ -247,7 +247,7 @@ public class BCV
{ {
try { try {
Thread.sleep(100); Thread.sleep(100);
} catch (InterruptedException e) { } } catch (InterruptedException ignored) { }
} }
frame.setVisible(false); frame.setVisible(false);

View File

@ -296,7 +296,7 @@ public class Boot {
public static void dropKrakatau() { public static void dropKrakatau() {
File temp = new File(getBCVDirectory() + fs + "krakatau_" + krakatauVersion + ".zip"); File temp = new File(getBCVDirectory() + fs + "krakatau_" + krakatauVersion + ".zip");
File krakatauDirectory = new File(krakatauWorkingDirectory); File krakatauDirectory = new File(krakatauWorkingDirectory);
Constants.krakatauWorkingDirectory = krakatauWorkingDirectory + fs + "Krakatau-master"; krakatauWorkingDirectory += fs + "Krakatau-master";
if (!krakatauDirectory.exists() || temp.exists()) { if (!krakatauDirectory.exists() || temp.exists()) {
if (temp.exists()) if (temp.exists())
temp.delete(); temp.delete();
@ -308,7 +308,7 @@ public class Boot {
temp.delete(); temp.delete();
try (InputStream is = BytecodeViewer.class.getClassLoader().getResourceAsStream("Krakatau-" try (InputStream is = BytecodeViewer.class.getClassLoader().getResourceAsStream("Krakatau-"
+ Constants.krakatauVersion + ".zip"); + krakatauVersion + ".zip");
FileOutputStream baos = new FileOutputStream(temp)) { FileOutputStream baos = new FileOutputStream(temp)) {
int r; int r;
byte[] buffer = new byte[8192]; byte[] buffer = new byte[8192];
@ -329,7 +329,7 @@ public class Boot {
public static void dropEnjarify() { public static void dropEnjarify() {
File temp = new File(getBCVDirectory() + fs + "enjarify" + Constants.enjarifyVersion + ".zip"); File temp = new File(getBCVDirectory() + fs + "enjarify" + Constants.enjarifyVersion + ".zip");
File enjarifyDirectory = new File(Constants.enjarifyWorkingDirectory); File enjarifyDirectory = new File(Constants.enjarifyWorkingDirectory);
Constants.enjarifyWorkingDirectory = Constants.enjarifyWorkingDirectory + fs + "enjarify-master"; Constants.enjarifyWorkingDirectory += fs + "enjarify-master";
if (!enjarifyDirectory.exists() || temp.exists()) { if (!enjarifyDirectory.exists() || temp.exists()) {
if (temp.exists()) if (temp.exists())
temp.delete(); temp.delete();
@ -359,7 +359,7 @@ public class Boot {
} }
} }
public static void downloadZipsOnly() throws Exception { public static void downloadZipsOnly() {
for (String s : urlList) { for (String s : urlList) {
String fileName = s.substring("https://github.com/Konloch/bytecode-viewer/blob/master/libs/".length() String fileName = s.substring("https://github.com/Konloch/bytecode-viewer/blob/master/libs/".length()
); );

View File

@ -3,7 +3,6 @@ package the.bytecode.club.bytecodeviewer.bootloader.classtree;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
/*************************************************************************** /***************************************************************************
@ -45,8 +44,6 @@ public class ClassHelper {
} }
public static <T, K> void copy(Map<T, K> src, Map<T, K> dst) { public static <T, K> void copy(Map<T, K> src, Map<T, K> dst) {
for (Entry<T, K> e : src.entrySet()) { dst.putAll(src);
dst.put(e.getKey(), e.getValue());
}
} }
} }

View File

@ -1,6 +1,5 @@
package the.bytecode.club.bytecodeviewer.bootloader.resource.external; package the.bytecode.club.bytecodeviewer.bootloader.resource.external;
import java.io.IOException;
import java.net.URL; import java.net.URL;
/*************************************************************************** /***************************************************************************
@ -38,7 +37,7 @@ public class EmptyExternalResource<T> extends ExternalResource<T> {
* @see the.bytecode.club.bootloader.resource.ExternalResource#load() * @see the.bytecode.club.bootloader.resource.ExternalResource#load()
*/ */
@Override @Override
public T load() throws IOException { public T load() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
} }

View File

@ -162,8 +162,6 @@ public class ClassNodeDecompiler
if (!tokens.contains("interface") && !tokens.contains("enum") if (!tokens.contains("interface") && !tokens.contains("enum")
&& !tokens.contains("annotation")) && !tokens.contains("annotation"))
tokens.add("class"); tokens.add("class");
if (tokens.size() == 0)
return "[Error parsing]";
// hackery delimeters // hackery delimeters
StringBuilder sb = new StringBuilder(tokens.get(0)); StringBuilder sb = new StringBuilder(tokens.get(0));

View File

@ -316,7 +316,6 @@ public class CFRDecompiler extends InternalDecompiler
fuck.delete(); fuck.delete();
} }
@SuppressWarnings("resource")
public void zip(File directory, File zipFile) throws IOException { public void zip(File directory, File zipFile) throws IOException {
java.net.URI base = directory.toURI(); java.net.URI base = directory.toURI();
Deque<File> queue = new LinkedList<>(); Deque<File> queue = new LinkedList<>();

View File

@ -226,7 +226,7 @@ public class KrakatauDecompiler extends InternalDecompiler
} }
int exitValue = process.waitFor(); int exitValue = process.waitFor();
log.append(nl).append(nl).append(TranslatedStrings.EXIT_VALUE_IS + " ").append(exitValue); log.append(nl).append(nl).append(TranslatedStrings.EXIT_VALUE_IS).append(" ").append(exitValue);
s = log.toString(); s = log.toString();
//if the motherfucker failed this'll fail, aka wont set. //if the motherfucker failed this'll fail, aka wont set.

View File

@ -1,7 +1,6 @@
package the.bytecode.club.bytecodeviewer.decompilers.jdgui; package the.bytecode.club.bytecodeviewer.decompilers.jdgui;
import java.io.Closeable; import java.io.Closeable;
import java.io.IOException;
import java.io.PrintStream; import java.io.PrintStream;
import org.jd.core.v1.api.printer.Printer; import org.jd.core.v1.api.printer.Printer;
@ -230,7 +229,7 @@ public class PlainTextPrinter implements Printer, Closeable {
} }
@Override @Override
public void close() throws IOException { public void close() {
if (this.printStream != null) if (this.printStream != null)
this.printStream.close(); this.printStream.close();
} }

View File

@ -119,9 +119,7 @@ public class ExtendedJOptionPane
int style = styleFromMessageType(messageType); int style = styleFromMessageType(messageType);
JDialog dialog = createNewJDialog(parentComponent, pane, title, style, (d)-> JDialog dialog = createNewJDialog(parentComponent, pane, title, style, (d)->
{ pane.selectInitialValue());
pane.selectInitialValue();
});
pane.selectInitialValue(); pane.selectInitialValue();
@ -163,9 +161,7 @@ public class ExtendedJOptionPane
int style = styleFromMessageType(messageType); int style = styleFromMessageType(messageType);
JDialog dialog = createNewJDialog(parentComponent, pane, title, style, (d)-> JDialog dialog = createNewJDialog(parentComponent, pane, title, style, (d)->
{ pane.selectInitialValue());
pane.selectInitialValue();
});
pane.selectInitialValue(); pane.selectInitialValue();

View File

@ -1,7 +1,6 @@
package the.bytecode.club.bytecodeviewer.gui.components; package the.bytecode.club.bytecodeviewer.gui.components;
import java.io.Closeable; import java.io.Closeable;
import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.PrintStream; import java.io.PrintStream;
import javax.swing.JTextArea; import javax.swing.JTextArea;
@ -65,7 +64,7 @@ public class JTextAreaOutputStream extends OutputStream implements Closeable
} }
@Override @Override
public void close() throws IOException { public void close() {
if (og != null) if (og != null)
og.close(); og.close();
} }

View File

@ -39,7 +39,7 @@ import the.bytecode.club.bytecodeviewer.searching.LDCSearchTreeNodeResult;
*/ */
public class ContextMenu public class ContextMenu
{ {
private static ContextMenu SINGLETON = new ContextMenu(); private static final ContextMenu SINGLETON = new ContextMenu();
private final List<ContextMenuItem> contextMenuItems = new ArrayList<>(); private final List<ContextMenuItem> contextMenuItems = new ArrayList<>();
static static
@ -85,11 +85,11 @@ public class ContextMenu
switch(item.getMenuType()) switch(item.getMenuType())
{ {
case CONTAINER: case CONTAINER:
if(!isContainerSelected || searchBoxPane) if(!isContainerSelected)
continue; continue;
break; break;
case RESOURCE: case RESOURCE:
if(!isResourceSelected || isContainerSelected || searchBoxPane) if(!isResourceSelected || isContainerSelected)
continue; continue;
break; break;
case DIRECTORY: case DIRECTORY:

View File

@ -34,15 +34,13 @@ public class Collapse extends ContextMenuItem
public Collapse() public Collapse()
{ {
super(ContextMenuType.DIRECTORY, ((tree, selPath, result, menu) -> super(ContextMenuType.DIRECTORY, ((tree, selPath, result, menu) ->
{ menu.add(new AbstractAction(TranslatedStrings.COLLAPSE.toString())
menu.add(new AbstractAction(TranslatedStrings.COLLAPSE.toString()) {
{ @Override
@Override public void actionPerformed(ActionEvent e)
public void actionPerformed(ActionEvent e) {
{ BytecodeViewer.viewer.resourcePane.expandAll(tree, selPath, false);
BytecodeViewer.viewer.resourcePane.expandAll(tree, selPath, false); }
} })));
});
}));
} }
} }

View File

@ -34,15 +34,13 @@ public class Delete extends ContextMenuItem
public Delete() public Delete()
{ {
super(ContextMenuType.CONTAINER, ((tree, selPath, result, menu) -> super(ContextMenuType.CONTAINER, ((tree, selPath, result, menu) ->
{ menu.add(new AbstractAction(TranslatedStrings.DELETE.toString())
menu.add(new AbstractAction(TranslatedStrings.DELETE.toString()) {
{ @Override
@Override public void actionPerformed(ActionEvent e)
public void actionPerformed(ActionEvent e) {
{ BytecodeViewer.viewer.resourcePane.removeNode(tree, selPath);
BytecodeViewer.viewer.resourcePane.removeNode(tree, selPath); }
} })));
});
}));
} }
} }

View File

@ -34,15 +34,13 @@ public class Expand extends ContextMenuItem
public Expand() public Expand()
{ {
super(ContextMenuType.DIRECTORY, ((tree, selPath, result, menu) -> super(ContextMenuType.DIRECTORY, ((tree, selPath, result, menu) ->
{ menu.add(new AbstractAction(TranslatedStrings.EXPAND.toString())
menu.add(new AbstractAction(TranslatedStrings.EXPAND.toString()) {
{ @Override
@Override public void actionPerformed(ActionEvent e)
public void actionPerformed(ActionEvent e) {
{ BytecodeViewer.viewer.resourcePane.expandAll(tree, selPath, true);
BytecodeViewer.viewer.resourcePane.expandAll(tree, selPath, true); }
} })));
});
}));
} }
} }

View File

@ -77,8 +77,7 @@ public class New extends ContextMenuItem
return; return;
byte[] contents = new byte[0]; byte[] contents = new byte[0];
String resourcePath = newPath;
switch(fileType) switch(fileType)
{ {
case CLASS: case CLASS:
@ -89,7 +88,7 @@ public class New extends ContextMenuItem
//TODO santize newPath and remove extension if added //TODO santize newPath and remove extension if added
cn.name = newPath; cn.name = newPath;
String oldResourcePath = resourcePath.replace(".", "/"); String oldResourcePath = newPath.replace(".", "/");
String newResourcePath = oldResourcePath + ".class"; String newResourcePath = oldResourcePath + ".class";
contents = ASMUtil.nodeToBytes(cn); contents = ASMUtil.nodeToBytes(cn);
@ -100,7 +99,7 @@ public class New extends ContextMenuItem
break; break;
case FILE: case FILE:
BytecodeViewer.resourceContainers.get(containerName).resourceFiles.put(resourcePath, contents); BytecodeViewer.resourceContainers.get(containerName).resourceFiles.put(newPath, contents);
searchAndInsert(firstPath + separator +newPath, BytecodeViewer.resourceContainers.get(containerName).treeNode, separator); searchAndInsert(firstPath + separator +newPath, BytecodeViewer.resourceContainers.get(containerName).treeNode, separator);
break; break;
} }
@ -115,7 +114,7 @@ public class New extends ContextMenuItem
{ {
StringBuilder tempSpot = new StringBuilder(); StringBuilder tempSpot = new StringBuilder();
for(int counter = startsAt, maxCounter = max;counter < maxCounter; counter++) for(int counter = startsAt; counter < max; counter++)
{ {
if(counter > startsAt) if(counter > startsAt)
tempSpot.append(separator); tempSpot.append(separator);
@ -129,7 +128,7 @@ public class New extends ContextMenuItem
{ {
StringBuilder tempSpot = new StringBuilder(); StringBuilder tempSpot = new StringBuilder();
for(int counter = startsAt, maxCounter = max;counter < maxCounter; counter++) for(int counter = startsAt; counter < max; counter++)
{ {
if(counter > startsAt) if(counter > startsAt)
tempSpot.append(separator); tempSpot.append(separator);
@ -140,6 +139,7 @@ public class New extends ContextMenuItem
} }
//TODO this needs to be rewritten to support creating parent nodes that don't exist //TODO this needs to be rewritten to support creating parent nodes that don't exist
@SuppressWarnings("unchecked")
public static boolean searchAndInsert(String path, DefaultMutableTreeNode treeNode, String separator) public static boolean searchAndInsert(String path, DefaultMutableTreeNode treeNode, String separator)
{ {
Enumeration<TreeNode> children = treeNode.children(); Enumeration<TreeNode> children = treeNode.children();

View File

@ -34,15 +34,13 @@ public class Open extends ContextMenuItem
public Open() public Open()
{ {
super(ContextMenuType.RESOURCE, ((tree, selPath, result, menu) -> super(ContextMenuType.RESOURCE, ((tree, selPath, result, menu) ->
{ menu.add(new AbstractAction(TranslatedStrings.OPEN_UNSTYLED.toString())
menu.add(new AbstractAction(TranslatedStrings.OPEN_UNSTYLED.toString()) {
{ @Override
@Override public void actionPerformed(ActionEvent e)
public void actionPerformed(ActionEvent e) {
{ BytecodeViewer.viewer.resourcePane.openPath(selPath);
BytecodeViewer.viewer.resourcePane.openPath(selPath); }
} })));
});
}));
} }
} }

View File

@ -34,15 +34,13 @@ public class Open extends ContextMenuItem
public Open() public Open()
{ {
super(ContextMenuType.SEARCH_BOX_RESULT, ((tree, selPath, result, menu) -> super(ContextMenuType.SEARCH_BOX_RESULT, ((tree, selPath, result, menu) ->
{ menu.add(new AbstractAction(TranslatedStrings.OPEN_UNSTYLED.toString())
menu.add(new AbstractAction(TranslatedStrings.OPEN_UNSTYLED.toString()) {
{ @Override
@Override public void actionPerformed(ActionEvent e)
public void actionPerformed(ActionEvent e) {
{ BytecodeViewer.viewer.workPane.addClassResource(result.container, result.resourceWorkingName);
BytecodeViewer.viewer.workPane.addClassResource(result.container, result.resourceWorkingName); }
} })));
});
}));
} }
} }

View File

@ -66,7 +66,6 @@ public class BaseSwitchableSpinnerPanel extends javax.swing.JPanel {
* WARNING: Do NOT modify this code. The content of this method is always * WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor. * regenerated by the Form Editor.
*/ */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() { private void initComponents() {
@ -79,29 +78,17 @@ public class BaseSwitchableSpinnerPanel extends javax.swing.JPanel {
octalMenuItem.setText("OCT"); octalMenuItem.setText("OCT");
octalMenuItem.setToolTipText("Octal"); octalMenuItem.setToolTipText("Octal");
octalMenuItem.addActionListener(new java.awt.event.ActionListener() { octalMenuItem.addActionListener(this::octalMenuItemActionPerformed);
public void actionPerformed(java.awt.event.ActionEvent evt) {
octalMenuItemActionPerformed(evt);
}
});
baseSwitchPopupMenu.add(octalMenuItem); baseSwitchPopupMenu.add(octalMenuItem);
decimalMenuItem.setText("DEC"); decimalMenuItem.setText("DEC");
decimalMenuItem.setToolTipText("Decimal"); decimalMenuItem.setToolTipText("Decimal");
decimalMenuItem.addActionListener(new java.awt.event.ActionListener() { decimalMenuItem.addActionListener(this::decimalMenuItemActionPerformed);
public void actionPerformed(java.awt.event.ActionEvent evt) {
decimalMenuItemActionPerformed(evt);
}
});
baseSwitchPopupMenu.add(decimalMenuItem); baseSwitchPopupMenu.add(decimalMenuItem);
hexadecimalMenuItem.setText("HEX"); hexadecimalMenuItem.setText("HEX");
hexadecimalMenuItem.setToolTipText("Hexadecimal"); hexadecimalMenuItem.setToolTipText("Hexadecimal");
hexadecimalMenuItem.addActionListener(new java.awt.event.ActionListener() { hexadecimalMenuItem.addActionListener(this::hexadecimalMenuItemActionPerformed);
public void actionPerformed(java.awt.event.ActionEvent evt) {
hexadecimalMenuItemActionPerformed(evt);
}
});
baseSwitchPopupMenu.add(hexadecimalMenuItem); baseSwitchPopupMenu.add(hexadecimalMenuItem);
setPreferredSize(new java.awt.Dimension(400, 300)); setPreferredSize(new java.awt.Dimension(400, 300));
@ -109,11 +96,7 @@ public class BaseSwitchableSpinnerPanel extends javax.swing.JPanel {
baseSwitchButton.setText("DEC"); baseSwitchButton.setText("DEC");
baseSwitchButton.setToolTipText("Decimal"); baseSwitchButton.setToolTipText("Decimal");
baseSwitchButton.setComponentPopupMenu(baseSwitchPopupMenu); baseSwitchButton.setComponentPopupMenu(baseSwitchPopupMenu);
baseSwitchButton.addActionListener(new java.awt.event.ActionListener() { baseSwitchButton.addActionListener(this::baseSwitchButtonActionPerformed);
public void actionPerformed(java.awt.event.ActionEvent evt) {
baseSwitchButtonActionPerformed(evt);
}
});
spinner.setModel(new javax.swing.SpinnerNumberModel(0L, null, null, 1L)); spinner.setModel(new javax.swing.SpinnerNumberModel(0L, null, null, 1L));
@ -302,9 +285,7 @@ public class BaseSwitchableSpinnerPanel extends javax.swing.JPanel {
} }
JSpinner sourceSpinner = (JSpinner) (e.getSource()); JSpinner sourceSpinner = (JSpinner) (e.getSource());
SwingUtilities.invokeLater(() -> { SwingUtilities.invokeLater(() -> textField.setText(getPositionAsString((Long) sourceSpinner.getValue())));
textField.setText(getPositionAsString((Long) sourceSpinner.getValue()));
});
} }
@Override @Override

View File

@ -35,11 +35,11 @@ public class BinaryStatusPanel extends javax.swing.JPanel implements BinaryStatu
public static final String DECIMAL_CODE_TYPE_LABEL = "DEC"; public static final String DECIMAL_CODE_TYPE_LABEL = "DEC";
public static final String HEXADECIMAL_CODE_TYPE_LABEL = "HEX"; public static final String HEXADECIMAL_CODE_TYPE_LABEL = "HEX";
private StatusCursorPositionFormat cursorPositionFormat = new StatusCursorPositionFormat(); private final StatusCursorPositionFormat cursorPositionFormat = new StatusCursorPositionFormat();
private StatusDocumentSizeFormat documentSizeFormat = new StatusDocumentSizeFormat(); private final StatusDocumentSizeFormat documentSizeFormat = new StatusDocumentSizeFormat();
private int octalSpaceGroupSize = DEFAULT_OCTAL_SPACE_GROUP_SIZE; private final int octalSpaceGroupSize = DEFAULT_OCTAL_SPACE_GROUP_SIZE;
private int decimalSpaceGroupSize = DEFAULT_DECIMAL_SPACE_GROUP_SIZE; private final int decimalSpaceGroupSize = DEFAULT_DECIMAL_SPACE_GROUP_SIZE;
private int hexadecimalSpaceGroupSize = DEFAULT_HEXADECIMAL_SPACE_GROUP_SIZE; private final int hexadecimalSpaceGroupSize = DEFAULT_HEXADECIMAL_SPACE_GROUP_SIZE;
private EditOperation editOperation; private EditOperation editOperation;
private CodeAreaCaretPosition caretPosition; private CodeAreaCaretPosition caretPosition;
@ -164,32 +164,20 @@ public class BinaryStatusPanel extends javax.swing.JPanel implements BinaryStatu
cursorPositionModeButtonGroup.add(octalCursorPositionModeRadioButtonMenuItem); cursorPositionModeButtonGroup.add(octalCursorPositionModeRadioButtonMenuItem);
octalCursorPositionModeRadioButtonMenuItem.setText("Show as octal"); octalCursorPositionModeRadioButtonMenuItem.setText("Show as octal");
octalCursorPositionModeRadioButtonMenuItem.setName("octalCursorPositionModeRadioButtonMenuItem"); octalCursorPositionModeRadioButtonMenuItem.setName("octalCursorPositionModeRadioButtonMenuItem");
octalCursorPositionModeRadioButtonMenuItem.addActionListener(new java.awt.event.ActionListener() { octalCursorPositionModeRadioButtonMenuItem.addActionListener(this::octalCursorPositionModeRadioButtonMenuItemActionPerformed);
public void actionPerformed(java.awt.event.ActionEvent evt) {
octalCursorPositionModeRadioButtonMenuItemActionPerformed(evt);
}
});
cursorPositionCodeTypeMenu.add(octalCursorPositionModeRadioButtonMenuItem); cursorPositionCodeTypeMenu.add(octalCursorPositionModeRadioButtonMenuItem);
cursorPositionModeButtonGroup.add(decimalCursorPositionModeRadioButtonMenuItem); cursorPositionModeButtonGroup.add(decimalCursorPositionModeRadioButtonMenuItem);
decimalCursorPositionModeRadioButtonMenuItem.setSelected(true); decimalCursorPositionModeRadioButtonMenuItem.setSelected(true);
decimalCursorPositionModeRadioButtonMenuItem.setText("Show as decimal"); decimalCursorPositionModeRadioButtonMenuItem.setText("Show as decimal");
decimalCursorPositionModeRadioButtonMenuItem.setName("decimalCursorPositionModeRadioButtonMenuItem"); decimalCursorPositionModeRadioButtonMenuItem.setName("decimalCursorPositionModeRadioButtonMenuItem");
decimalCursorPositionModeRadioButtonMenuItem.addActionListener(new java.awt.event.ActionListener() { decimalCursorPositionModeRadioButtonMenuItem.addActionListener(this::decimalCursorPositionModeRadioButtonMenuItemActionPerformed);
public void actionPerformed(java.awt.event.ActionEvent evt) {
decimalCursorPositionModeRadioButtonMenuItemActionPerformed(evt);
}
});
cursorPositionCodeTypeMenu.add(decimalCursorPositionModeRadioButtonMenuItem); cursorPositionCodeTypeMenu.add(decimalCursorPositionModeRadioButtonMenuItem);
cursorPositionModeButtonGroup.add(hexadecimalCursorPositionModeRadioButtonMenuItem); cursorPositionModeButtonGroup.add(hexadecimalCursorPositionModeRadioButtonMenuItem);
hexadecimalCursorPositionModeRadioButtonMenuItem.setText("Show as hexadecimal"); hexadecimalCursorPositionModeRadioButtonMenuItem.setText("Show as hexadecimal");
hexadecimalCursorPositionModeRadioButtonMenuItem.setName("hexadecimalCursorPositionModeRadioButtonMenuItem"); hexadecimalCursorPositionModeRadioButtonMenuItem.setName("hexadecimalCursorPositionModeRadioButtonMenuItem");
hexadecimalCursorPositionModeRadioButtonMenuItem.addActionListener(new java.awt.event.ActionListener() { hexadecimalCursorPositionModeRadioButtonMenuItem.addActionListener(this::hexadecimalCursorPositionModeRadioButtonMenuItemActionPerformed);
public void actionPerformed(java.awt.event.ActionEvent evt) {
hexadecimalCursorPositionModeRadioButtonMenuItemActionPerformed(evt);
}
});
cursorPositionCodeTypeMenu.add(hexadecimalCursorPositionModeRadioButtonMenuItem); cursorPositionCodeTypeMenu.add(hexadecimalCursorPositionModeRadioButtonMenuItem);
positionPopupMenu.add(cursorPositionCodeTypeMenu); positionPopupMenu.add(cursorPositionCodeTypeMenu);
@ -197,11 +185,7 @@ public class BinaryStatusPanel extends javax.swing.JPanel implements BinaryStatu
cursorPositionShowOffsetCheckBoxMenuItem.setSelected(true); cursorPositionShowOffsetCheckBoxMenuItem.setSelected(true);
cursorPositionShowOffsetCheckBoxMenuItem.setText("Show offset"); cursorPositionShowOffsetCheckBoxMenuItem.setText("Show offset");
cursorPositionShowOffsetCheckBoxMenuItem.setName("cursorPositionShowOffsetCheckBoxMenuItem"); cursorPositionShowOffsetCheckBoxMenuItem.setName("cursorPositionShowOffsetCheckBoxMenuItem");
cursorPositionShowOffsetCheckBoxMenuItem.addActionListener(new java.awt.event.ActionListener() { cursorPositionShowOffsetCheckBoxMenuItem.addActionListener(this::cursorPositionShowOffsetCheckBoxMenuItemActionPerformed);
public void actionPerformed(java.awt.event.ActionEvent evt) {
cursorPositionShowOffsetCheckBoxMenuItemActionPerformed(evt);
}
});
positionPopupMenu.add(cursorPositionShowOffsetCheckBoxMenuItem); positionPopupMenu.add(cursorPositionShowOffsetCheckBoxMenuItem);
jSeparator2.setName("jSeparator2"); jSeparator2.setName("jSeparator2");
@ -209,21 +193,13 @@ public class BinaryStatusPanel extends javax.swing.JPanel implements BinaryStatu
positionCopyMenuItem.setText("Copy"); positionCopyMenuItem.setText("Copy");
positionCopyMenuItem.setName("positionCopyMenuItem"); positionCopyMenuItem.setName("positionCopyMenuItem");
positionCopyMenuItem.addActionListener(new java.awt.event.ActionListener() { positionCopyMenuItem.addActionListener(this::positionCopyMenuItemActionPerformed);
public void actionPerformed(java.awt.event.ActionEvent evt) {
positionCopyMenuItemActionPerformed(evt);
}
});
positionPopupMenu.add(positionCopyMenuItem); positionPopupMenu.add(positionCopyMenuItem);
positionGoToMenuItem.setText("Go To..."); positionGoToMenuItem.setText("Go To...");
positionGoToMenuItem.setEnabled(false); positionGoToMenuItem.setEnabled(false);
positionGoToMenuItem.setName("positionGoToMenuItem"); positionGoToMenuItem.setName("positionGoToMenuItem");
positionGoToMenuItem.addActionListener(new java.awt.event.ActionListener() { positionGoToMenuItem.addActionListener(this::positionGoToMenuItemActionPerformed);
public void actionPerformed(java.awt.event.ActionEvent evt) {
positionGoToMenuItemActionPerformed(evt);
}
});
positionPopupMenu.add(positionGoToMenuItem); positionPopupMenu.add(positionGoToMenuItem);
documentSizePopupMenu.setName("documentSizePopupMenu"); documentSizePopupMenu.setName("documentSizePopupMenu");
@ -234,31 +210,19 @@ public class BinaryStatusPanel extends javax.swing.JPanel implements BinaryStatu
documentSizeModeButtonGroup.add(octalDocumentSizeModeRadioButtonMenuItem); documentSizeModeButtonGroup.add(octalDocumentSizeModeRadioButtonMenuItem);
octalDocumentSizeModeRadioButtonMenuItem.setText("Show as octal"); octalDocumentSizeModeRadioButtonMenuItem.setText("Show as octal");
octalDocumentSizeModeRadioButtonMenuItem.setName("octalDocumentSizeModeRadioButtonMenuItem"); octalDocumentSizeModeRadioButtonMenuItem.setName("octalDocumentSizeModeRadioButtonMenuItem");
octalDocumentSizeModeRadioButtonMenuItem.addActionListener(new java.awt.event.ActionListener() { octalDocumentSizeModeRadioButtonMenuItem.addActionListener(this::octalDocumentSizeModeRadioButtonMenuItemActionPerformed);
public void actionPerformed(java.awt.event.ActionEvent evt) {
octalDocumentSizeModeRadioButtonMenuItemActionPerformed(evt);
}
});
documentSizeCodeTypeMenu.add(octalDocumentSizeModeRadioButtonMenuItem); documentSizeCodeTypeMenu.add(octalDocumentSizeModeRadioButtonMenuItem);
documentSizeModeButtonGroup.add(decimalDocumentSizeModeRadioButtonMenuItem); documentSizeModeButtonGroup.add(decimalDocumentSizeModeRadioButtonMenuItem);
decimalDocumentSizeModeRadioButtonMenuItem.setText("Show as decimal"); decimalDocumentSizeModeRadioButtonMenuItem.setText("Show as decimal");
decimalDocumentSizeModeRadioButtonMenuItem.setName("decimalDocumentSizeModeRadioButtonMenuItem"); decimalDocumentSizeModeRadioButtonMenuItem.setName("decimalDocumentSizeModeRadioButtonMenuItem");
decimalDocumentSizeModeRadioButtonMenuItem.addActionListener(new java.awt.event.ActionListener() { decimalDocumentSizeModeRadioButtonMenuItem.addActionListener(this::decimalDocumentSizeModeRadioButtonMenuItemActionPerformed);
public void actionPerformed(java.awt.event.ActionEvent evt) {
decimalDocumentSizeModeRadioButtonMenuItemActionPerformed(evt);
}
});
documentSizeCodeTypeMenu.add(decimalDocumentSizeModeRadioButtonMenuItem); documentSizeCodeTypeMenu.add(decimalDocumentSizeModeRadioButtonMenuItem);
documentSizeModeButtonGroup.add(hexadecimalDocumentSizeModeRadioButtonMenuItem); documentSizeModeButtonGroup.add(hexadecimalDocumentSizeModeRadioButtonMenuItem);
hexadecimalDocumentSizeModeRadioButtonMenuItem.setText("Show as hexadecimal"); hexadecimalDocumentSizeModeRadioButtonMenuItem.setText("Show as hexadecimal");
hexadecimalDocumentSizeModeRadioButtonMenuItem.setName("hexadecimalDocumentSizeModeRadioButtonMenuItem"); hexadecimalDocumentSizeModeRadioButtonMenuItem.setName("hexadecimalDocumentSizeModeRadioButtonMenuItem");
hexadecimalDocumentSizeModeRadioButtonMenuItem.addActionListener(new java.awt.event.ActionListener() { hexadecimalDocumentSizeModeRadioButtonMenuItem.addActionListener(this::hexadecimalDocumentSizeModeRadioButtonMenuItemActionPerformed);
public void actionPerformed(java.awt.event.ActionEvent evt) {
hexadecimalDocumentSizeModeRadioButtonMenuItemActionPerformed(evt);
}
});
documentSizeCodeTypeMenu.add(hexadecimalDocumentSizeModeRadioButtonMenuItem); documentSizeCodeTypeMenu.add(hexadecimalDocumentSizeModeRadioButtonMenuItem);
documentSizePopupMenu.add(documentSizeCodeTypeMenu); documentSizePopupMenu.add(documentSizeCodeTypeMenu);
@ -266,11 +230,7 @@ public class BinaryStatusPanel extends javax.swing.JPanel implements BinaryStatu
documentSizeShowRelativeCheckBoxMenuItem.setSelected(true); documentSizeShowRelativeCheckBoxMenuItem.setSelected(true);
documentSizeShowRelativeCheckBoxMenuItem.setText("Show relative size"); documentSizeShowRelativeCheckBoxMenuItem.setText("Show relative size");
documentSizeShowRelativeCheckBoxMenuItem.setName("documentSizeShowRelativeCheckBoxMenuItem"); documentSizeShowRelativeCheckBoxMenuItem.setName("documentSizeShowRelativeCheckBoxMenuItem");
documentSizeShowRelativeCheckBoxMenuItem.addActionListener(new java.awt.event.ActionListener() { documentSizeShowRelativeCheckBoxMenuItem.addActionListener(this::documentSizeShowRelativeCheckBoxMenuItemActionPerformed);
public void actionPerformed(java.awt.event.ActionEvent evt) {
documentSizeShowRelativeCheckBoxMenuItemActionPerformed(evt);
}
});
documentSizePopupMenu.add(documentSizeShowRelativeCheckBoxMenuItem); documentSizePopupMenu.add(documentSizeShowRelativeCheckBoxMenuItem);
jSeparator1.setName("jSeparator1"); jSeparator1.setName("jSeparator1");
@ -278,11 +238,7 @@ public class BinaryStatusPanel extends javax.swing.JPanel implements BinaryStatu
documentSizeCopyMenuItem.setText("Copy"); documentSizeCopyMenuItem.setText("Copy");
documentSizeCopyMenuItem.setName("documentSizeCopyMenuItem"); documentSizeCopyMenuItem.setName("documentSizeCopyMenuItem");
documentSizeCopyMenuItem.addActionListener(new java.awt.event.ActionListener() { documentSizeCopyMenuItem.addActionListener(this::documentSizeCopyMenuItemActionPerformed);
public void actionPerformed(java.awt.event.ActionEvent evt) {
documentSizeCopyMenuItemActionPerformed(evt);
}
});
documentSizePopupMenu.add(documentSizeCopyMenuItem); documentSizePopupMenu.add(documentSizeCopyMenuItem);
setName("Form"); setName("Form");
@ -627,7 +583,7 @@ public class BinaryStatusPanel extends javax.swing.JPanel implements BinaryStatu
return "0"; return "0";
} }
int spaceGroupSize = 0; int spaceGroupSize;
switch (codeType) { switch (codeType) {
case OCTAL: { case OCTAL: {
spaceGroupSize = octalSpaceGroupSize; spaceGroupSize = octalSpaceGroupSize;
@ -660,7 +616,7 @@ public class BinaryStatusPanel extends javax.swing.JPanel implements BinaryStatu
} }
int digit = (int) (remainder % base); int digit = (int) (remainder % base);
remainder = remainder / base; remainder /= base;
builder.insert(0, CodeAreaUtils.UPPER_HEX_CODES[digit]); builder.insert(0, CodeAreaUtils.UPPER_HEX_CODES[digit]);
} }

View File

@ -1,7 +1,5 @@
package the.bytecode.club.bytecodeviewer.gui.hexviewer; package the.bytecode.club.bytecodeviewer.gui.hexviewer;
import java.util.ResourceBundle;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;
import org.exbin.bined.CodeAreaUtils; import org.exbin.bined.CodeAreaUtils;
@ -18,10 +16,8 @@ public class GoToBinaryPanel extends javax.swing.JPanel {
public GoToBinaryPanel() { public GoToBinaryPanel() {
initComponents(); initComponents();
baseSwitchableSpinnerPanel.setMinimum(0l); baseSwitchableSpinnerPanel.setMinimum(0L);
baseSwitchableSpinnerPanel.addChangeListener((javax.swing.event.ChangeEvent evt) -> { baseSwitchableSpinnerPanel.addChangeListener((javax.swing.event.ChangeEvent evt) -> updateTargetPosition());
updateTargetPosition();
});
} }
/** /**
@ -29,7 +25,6 @@ public class GoToBinaryPanel extends javax.swing.JPanel {
* WARNING: Do NOT modify this code. The content of this method is always * WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor. * regenerated by the Form Editor.
*/ */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() { private void initComponents() {
@ -55,27 +50,15 @@ public class GoToBinaryPanel extends javax.swing.JPanel {
positionTypeButtonGroup.add(fromStartRadioButton); positionTypeButtonGroup.add(fromStartRadioButton);
fromStartRadioButton.setSelected(true); fromStartRadioButton.setSelected(true);
fromStartRadioButton.setText("Position from start"); fromStartRadioButton.setText("Position from start");
fromStartRadioButton.addItemListener(new java.awt.event.ItemListener() { fromStartRadioButton.addItemListener(this::fromStartRadioButtonItemStateChanged);
public void itemStateChanged(java.awt.event.ItemEvent evt) {
fromStartRadioButtonItemStateChanged(evt);
}
});
positionTypeButtonGroup.add(fromEndRadioButton); positionTypeButtonGroup.add(fromEndRadioButton);
fromEndRadioButton.setText("Position from end"); fromEndRadioButton.setText("Position from end");
fromEndRadioButton.addItemListener(new java.awt.event.ItemListener() { fromEndRadioButton.addItemListener(this::fromEndRadioButtonItemStateChanged);
public void itemStateChanged(java.awt.event.ItemEvent evt) {
fromEndRadioButtonItemStateChanged(evt);
}
});
positionTypeButtonGroup.add(fromCursorRadioButton); positionTypeButtonGroup.add(fromCursorRadioButton);
fromCursorRadioButton.setText("Position relative to cursor"); fromCursorRadioButton.setText("Position relative to cursor");
fromCursorRadioButton.addItemListener(new java.awt.event.ItemListener() { fromCursorRadioButton.addItemListener(this::fromCursorRadioButtonItemStateChanged);
public void itemStateChanged(java.awt.event.ItemEvent evt) {
fromCursorRadioButtonItemStateChanged(evt);
}
});
positionLabel.setText("Position"); positionLabel.setText("Position");
@ -250,22 +233,16 @@ public class GoToBinaryPanel extends javax.swing.JPanel {
long absolutePosition = getTargetPosition(); long absolutePosition = getTargetPosition();
this.goToMode = goToMode; this.goToMode = goToMode;
switch (goToMode) { switch (goToMode) {
case FROM_START: { case FROM_START:
setPositionValue(0l); case FROM_END: {
baseSwitchableSpinnerPanel.setMinimum(0l); setPositionValue(0L);
baseSwitchableSpinnerPanel.setMinimum(0L);
baseSwitchableSpinnerPanel.setMaximum(maxPosition); baseSwitchableSpinnerPanel.setMaximum(maxPosition);
baseSwitchableSpinnerPanel.revalidateSpinner(); baseSwitchableSpinnerPanel.revalidateSpinner();
break; break;
} }
case FROM_END: { case FROM_CURSOR: {
setPositionValue(0l); setPositionValue(0L);
baseSwitchableSpinnerPanel.setMinimum(0l);
baseSwitchableSpinnerPanel.setMaximum(maxPosition);
baseSwitchableSpinnerPanel.revalidateSpinner();
break;
}
case FROM_CURSOR: {
setPositionValue(0l);
baseSwitchableSpinnerPanel.setMinimum(-cursorPosition); baseSwitchableSpinnerPanel.setMinimum(-cursorPosition);
baseSwitchableSpinnerPanel.setMaximum(maxPosition - cursorPosition); baseSwitchableSpinnerPanel.setMaximum(maxPosition - cursorPosition);
baseSwitchableSpinnerPanel.revalidateSpinner(); baseSwitchableSpinnerPanel.revalidateSpinner();
@ -278,7 +255,7 @@ public class GoToBinaryPanel extends javax.swing.JPanel {
} }
private long getPositionValue() { private long getPositionValue() {
return (Long) baseSwitchableSpinnerPanel.getValue(); return baseSwitchableSpinnerPanel.getValue();
} }
private void setPositionValue(long value) { private void setPositionValue(long value) {

View File

@ -30,7 +30,6 @@ public class HexViewer extends JPanel {
private boolean valuesPanelVisible = false; private boolean valuesPanelVisible = false;
private final AbstractAction cycleCodeTypesAction; private final AbstractAction cycleCodeTypesAction;
private javax.swing.JToggleButton lineWrappingToggleButton;
private JButton cycleCodeTypeButton; private JButton cycleCodeTypeButton;
private BinaryStatusApi binaryStatus; private BinaryStatusApi binaryStatus;
private final AbstractAction goToAction; private final AbstractAction goToAction;
@ -114,18 +113,16 @@ public class HexViewer extends JPanel {
cycleCodeTypeButton.setAction(cycleCodeTypesAction); cycleCodeTypeButton.setAction(cycleCodeTypesAction);
updateCycleButtonState(); updateCycleButtonState();
toolBar.add(cycleCodeTypeButton); toolBar.add(cycleCodeTypeButton);
lineWrappingToggleButton = new javax.swing.JToggleButton(); JToggleButton lineWrappingToggleButton = new JToggleButton();
lineWrappingToggleButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/the/bytecode/club/bytecodeviewer/gui/hexviewer/resources/bined-linewrap.png"))); lineWrappingToggleButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/the/bytecode/club/bytecodeviewer/gui/hexviewer/resources/bined-linewrap.png")));
lineWrappingToggleButton.setToolTipText("Toggle line wrapping"); lineWrappingToggleButton.setToolTipText("Toggle line wrapping");
lineWrappingToggleButton.addActionListener(new java.awt.event.ActionListener() { lineWrappingToggleButton.addActionListener(evt -> {
public void actionPerformed(java.awt.event.ActionEvent evt) { if (codeArea.getRowWrapping() == RowWrappingMode.WRAPPING) {
if (codeArea.getRowWrapping() == RowWrappingMode.WRAPPING) { codeArea.setMaxBytesPerRow(16);
codeArea.setMaxBytesPerRow(16); codeArea.setRowWrapping(RowWrappingMode.NO_WRAPPING);
codeArea.setRowWrapping(RowWrappingMode.NO_WRAPPING); } else {
} else { codeArea.setMaxBytesPerRow(0);
codeArea.setMaxBytesPerRow(0); codeArea.setRowWrapping(RowWrappingMode.WRAPPING);
codeArea.setRowWrapping(RowWrappingMode.WRAPPING);
}
} }
}); });
toolBar.add(lineWrappingToggleButton); toolBar.add(lineWrappingToggleButton);
@ -137,15 +134,8 @@ public class HexViewer extends JPanel {
codeArea.setComponentPopupMenu(new JPopupMenu() { codeArea.setComponentPopupMenu(new JPopupMenu() {
@Override @Override
public void show(Component invoker, int x, int y) { public void show(Component invoker, int x, int y) {
int clickedX = x;
int clickedY = y;
if (invoker instanceof JViewport) {
clickedX += ((JViewport) invoker).getParent().getX();
clickedY += ((JViewport) invoker).getParent().getY();
}
removeAll(); removeAll();
final JPopupMenu menu = createPopupMenu(clickedX, clickedY); final JPopupMenu menu = createPopupMenu();
menu.show(invoker, x, y); menu.show(invoker, x, y);
} }
}); });
@ -187,15 +177,9 @@ public class HexViewer extends JPanel {
public void registerBinaryStatus(BinaryStatusApi binaryStatusApi) { public void registerBinaryStatus(BinaryStatusApi binaryStatusApi) {
this.binaryStatus = binaryStatusApi; this.binaryStatus = binaryStatusApi;
codeArea.addCaretMovedListener((CodeAreaCaretPosition caretPosition) -> { codeArea.addCaretMovedListener((CodeAreaCaretPosition caretPosition) -> binaryStatus.setCursorPosition(caretPosition));
binaryStatus.setCursorPosition(caretPosition); codeArea.addSelectionChangedListener(() -> binaryStatus.setSelectionRange(codeArea.getSelection()));
}); codeArea.addDataChangedListener(() -> binaryStatus.setCurrentDocumentSize(codeArea.getDataSize(), codeArea.getDataSize()));
codeArea.addSelectionChangedListener(() -> {
binaryStatus.setSelectionRange(codeArea.getSelection());
});
codeArea.addDataChangedListener(() -> {
binaryStatus.setCurrentDocumentSize(codeArea.getDataSize(), codeArea.getDataSize());
});
binaryStatus.setCurrentDocumentSize(codeArea.getDataSize(), codeArea.getDataSize()); binaryStatus.setCurrentDocumentSize(codeArea.getDataSize(), codeArea.getDataSize());
codeArea.addEditModeChangedListener(binaryStatus::setEditMode); codeArea.addEditModeChangedListener(binaryStatus::setEditMode);
@ -207,7 +191,6 @@ public class HexViewer extends JPanel {
* *
* @return down mask for meta keys * @return down mask for meta keys
*/ */
@SuppressWarnings("deprecation")
public static int getMetaMask() { public static int getMetaMask() {
try { try {
switch (java.awt.Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) { switch (java.awt.Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) {
@ -226,7 +209,7 @@ public class HexViewer extends JPanel {
} }
@Nonnull @Nonnull
private JPopupMenu createPopupMenu(int x, int y) { private JPopupMenu createPopupMenu() {
JPopupMenu menu = new JPopupMenu(); JPopupMenu menu = new JPopupMenu();
JMenu viewMenu = new JMenu("View"); JMenu viewMenu = new JMenu("View");
@ -311,22 +294,18 @@ public class HexViewer extends JPanel {
final JMenuItem copyMenuItem = new JMenuItem("Copy"); final JMenuItem copyMenuItem = new JMenuItem("Copy");
copyMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, HexViewer.getMetaMask())); copyMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, HexViewer.getMetaMask()));
copyMenuItem.setEnabled(codeArea.hasSelection()); copyMenuItem.setEnabled(codeArea.hasSelection());
copyMenuItem.addActionListener((ActionEvent e) -> { copyMenuItem.addActionListener((ActionEvent e) -> codeArea.copy());
codeArea.copy();
});
menu.add(copyMenuItem); menu.add(copyMenuItem);
final JMenuItem selectAllMenuItem = new JMenuItem("Select All"); final JMenuItem selectAllMenuItem = new JMenuItem("Select All");
selectAllMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, HexViewer.getMetaMask())); selectAllMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, HexViewer.getMetaMask()));
selectAllMenuItem.addActionListener((ActionEvent e) -> { selectAllMenuItem.addActionListener((ActionEvent e) -> codeArea.selectAll());
codeArea.selectAll();
});
menu.add(selectAllMenuItem); menu.add(selectAllMenuItem);
menu.addSeparator(); menu.addSeparator();
final JMenuItem goToMenuItem = new JMenuItem("Go To..."); final JMenuItem goToMenuItem = new JMenuItem("Go To...");
goToMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, HexViewer.getMetaMask())); goToMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, HexViewer.getMetaMask()));
goToMenuItem.addActionListener(goToAction::actionPerformed); goToMenuItem.addActionListener(goToAction);
menu.add(goToMenuItem); menu.add(goToMenuItem);
return menu; return menu;

View File

@ -14,7 +14,6 @@ public class OkCancelPanel extends javax.swing.JPanel {
* WARNING: Do NOT modify this code. The content of this method is always * WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor. * regenerated by the Form Editor.
*/ */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() { private void initComponents() {
@ -22,18 +21,10 @@ public class OkCancelPanel extends javax.swing.JPanel {
okButton = new javax.swing.JButton(); okButton = new javax.swing.JButton();
cancelButton.setText("Cancel"); cancelButton.setText("Cancel");
cancelButton.addActionListener(new java.awt.event.ActionListener() { cancelButton.addActionListener(this::cancelButtonActionPerformed);
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelButtonActionPerformed(evt);
}
});
okButton.setText("Ok"); okButton.setText("Ok");
okButton.addActionListener(new java.awt.event.ActionListener() { okButton.addActionListener(this::okButtonActionPerformed);
public void actionPerformed(java.awt.event.ActionEvent evt) {
okButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout); this.setLayout(layout);

View File

@ -29,7 +29,7 @@ public class ValuesPanel extends javax.swing.JPanel {
public static final int SWORD_MIN_VALUE = -32768; public static final int SWORD_MIN_VALUE = -32768;
public static final int SWORD_MAX_VALUE = 32767; public static final int SWORD_MAX_VALUE = 32767;
public static final int UWORD_MAX_VALUE = 65535; public static final int UWORD_MAX_VALUE = 65535;
public static final long UINT_MAX_VALUE = 4294967295l; public static final long UINT_MAX_VALUE = 4294967295L;
public static final BigInteger ULONG_MAX_VALUE = new BigInteger("4294967295"); public static final BigInteger ULONG_MAX_VALUE = new BigInteger("4294967295");
public static final BigInteger BIG_INTEGER_BYTE_MASK = BigInteger.valueOf(255); public static final BigInteger BIG_INTEGER_BYTE_MASK = BigInteger.valueOf(255);
public static final String VALUE_OUT_OF_RANGE = "Value is out of range"; public static final String VALUE_OUT_OF_RANGE = "Value is out of range";
@ -86,7 +86,6 @@ public class ValuesPanel extends javax.swing.JPanel {
* WARNING: Do NOT modify this code. The content of this method is always * WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor. * regenerated by the Form Editor.
*/ */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() { private void initComponents() {
@ -128,53 +127,21 @@ public class ValuesPanel extends javax.swing.JPanel {
binaryLabel.setText("Binary"); binaryLabel.setText("Binary");
binaryCheckBox0.addActionListener(new java.awt.event.ActionListener() { binaryCheckBox0.addActionListener(this::binaryCheckBox0ActionPerformed);
public void actionPerformed(java.awt.event.ActionEvent evt) {
binaryCheckBox0ActionPerformed(evt);
}
});
binaryCheckBox1.addActionListener(new java.awt.event.ActionListener() { binaryCheckBox1.addActionListener(this::binaryCheckBox1ActionPerformed);
public void actionPerformed(java.awt.event.ActionEvent evt) {
binaryCheckBox1ActionPerformed(evt);
}
});
binaryCheckBox2.addActionListener(new java.awt.event.ActionListener() { binaryCheckBox2.addActionListener(this::binaryCheckBox2ActionPerformed);
public void actionPerformed(java.awt.event.ActionEvent evt) {
binaryCheckBox2ActionPerformed(evt);
}
});
binaryCheckBox3.addActionListener(new java.awt.event.ActionListener() { binaryCheckBox3.addActionListener(this::binaryCheckBox3ActionPerformed);
public void actionPerformed(java.awt.event.ActionEvent evt) {
binaryCheckBox3ActionPerformed(evt);
}
});
binaryCheckBox4.addActionListener(new java.awt.event.ActionListener() { binaryCheckBox4.addActionListener(this::binaryCheckBox4ActionPerformed);
public void actionPerformed(java.awt.event.ActionEvent evt) {
binaryCheckBox4ActionPerformed(evt);
}
});
binaryCheckBox5.addActionListener(new java.awt.event.ActionListener() { binaryCheckBox5.addActionListener(this::binaryCheckBox5ActionPerformed);
public void actionPerformed(java.awt.event.ActionEvent evt) {
binaryCheckBox5ActionPerformed(evt);
}
});
binaryCheckBox6.addActionListener(new java.awt.event.ActionListener() { binaryCheckBox6.addActionListener(this::binaryCheckBox6ActionPerformed);
public void actionPerformed(java.awt.event.ActionEvent evt) {
binaryCheckBox6ActionPerformed(evt);
}
});
binaryCheckBox7.addActionListener(new java.awt.event.ActionListener() { binaryCheckBox7.addActionListener(this::binaryCheckBox7ActionPerformed);
public void actionPerformed(java.awt.event.ActionEvent evt) {
binaryCheckBox7ActionPerformed(evt);
}
});
byteLabel.setText("Byte"); byteLabel.setText("Byte");
@ -254,39 +221,23 @@ public class ValuesPanel extends javax.swing.JPanel {
bigEndianRadioButton.setSelected(true); bigEndianRadioButton.setSelected(true);
bigEndianRadioButton.setText("BE"); bigEndianRadioButton.setText("BE");
bigEndianRadioButton.setToolTipText("Big Endian"); bigEndianRadioButton.setToolTipText("Big Endian");
bigEndianRadioButton.addChangeListener(new javax.swing.event.ChangeListener() { bigEndianRadioButton.addChangeListener(this::bigEndianRadioButtonStateChanged);
public void stateChanged(javax.swing.event.ChangeEvent evt) {
bigEndianRadioButtonStateChanged(evt);
}
});
endianButtonGroup.add(littleEndianRadioButton); endianButtonGroup.add(littleEndianRadioButton);
littleEndianRadioButton.setText("LE"); littleEndianRadioButton.setText("LE");
littleEndianRadioButton.setToolTipText("Little Endian"); littleEndianRadioButton.setToolTipText("Little Endian");
littleEndianRadioButton.addChangeListener(new javax.swing.event.ChangeListener() { littleEndianRadioButton.addChangeListener(this::littleEndianRadioButtonStateChanged);
public void stateChanged(javax.swing.event.ChangeEvent evt) {
littleEndianRadioButtonStateChanged(evt);
}
});
integerSignButtonGroup.add(signedRadioButton); integerSignButtonGroup.add(signedRadioButton);
signedRadioButton.setSelected(true); signedRadioButton.setSelected(true);
signedRadioButton.setText("Sig"); signedRadioButton.setText("Sig");
signedRadioButton.setToolTipText("Signed Integers"); signedRadioButton.setToolTipText("Signed Integers");
signedRadioButton.addChangeListener(new javax.swing.event.ChangeListener() { signedRadioButton.addChangeListener(this::signedRadioButtonStateChanged);
public void stateChanged(javax.swing.event.ChangeEvent evt) {
signedRadioButtonStateChanged(evt);
}
});
integerSignButtonGroup.add(unsignedRadioButton); integerSignButtonGroup.add(unsignedRadioButton);
unsignedRadioButton.setText("Uns"); unsignedRadioButton.setText("Uns");
unsignedRadioButton.setToolTipText("Unsigned Integers"); unsignedRadioButton.setToolTipText("Unsigned Integers");
unsignedRadioButton.addChangeListener(new javax.swing.event.ChangeListener() { unsignedRadioButton.addChangeListener(this::unsignedRadioButtonStateChanged);
public void stateChanged(javax.swing.event.ChangeEvent evt) {
unsignedRadioButtonStateChanged(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout); this.setLayout(layout);
@ -482,7 +433,7 @@ public class ValuesPanel extends javax.swing.JPanel {
private void byteTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_byteTextFieldKeyReleased private void byteTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_byteTextFieldKeyReleased
if (evt.getKeyCode() == KeyEvent.VK_ENTER && isEditable()) { if (evt.getKeyCode() == KeyEvent.VK_ENTER && isEditable()) {
try { try {
Integer intValue = Integer.valueOf(byteTextField.getText()); int intValue = Integer.parseInt(byteTextField.getText());
if (isSigned()) { if (isSigned()) {
if (intValue < Byte.MIN_VALUE || intValue > Byte.MAX_VALUE) { if (intValue < Byte.MIN_VALUE || intValue > Byte.MAX_VALUE) {
throw new NumberFormatException(VALUE_OUT_OF_RANGE); throw new NumberFormatException(VALUE_OUT_OF_RANGE);
@ -493,7 +444,7 @@ public class ValuesPanel extends javax.swing.JPanel {
} }
} }
valuesCache[0] = intValue.byteValue(); valuesCache[0] = (byte) intValue;
modifyValues(1); modifyValues(1);
updateValues(); updateValues();
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
@ -505,7 +456,7 @@ public class ValuesPanel extends javax.swing.JPanel {
private void wordTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_wordTextFieldKeyReleased private void wordTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_wordTextFieldKeyReleased
if (evt.getKeyCode() == KeyEvent.VK_ENTER && isEditable()) { if (evt.getKeyCode() == KeyEvent.VK_ENTER && isEditable()) {
try { try {
Integer intValue = Integer.valueOf(wordTextField.getText()); int intValue = Integer.parseInt(wordTextField.getText());
if (isSigned()) { if (isSigned()) {
if (intValue < SWORD_MIN_VALUE || intValue > SWORD_MAX_VALUE) { if (intValue < SWORD_MIN_VALUE || intValue > SWORD_MAX_VALUE) {
throw new NumberFormatException(VALUE_OUT_OF_RANGE); throw new NumberFormatException(VALUE_OUT_OF_RANGE);
@ -534,7 +485,7 @@ public class ValuesPanel extends javax.swing.JPanel {
private void intTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_intTextFieldKeyReleased private void intTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_intTextFieldKeyReleased
if (evt.getKeyCode() == KeyEvent.VK_ENTER && isEditable()) { if (evt.getKeyCode() == KeyEvent.VK_ENTER && isEditable()) {
try { try {
Long longValue = Long.valueOf(intTextField.getText()); long longValue = Long.parseLong(intTextField.getText());
if (isSigned()) { if (isSigned()) {
if (longValue < Integer.MIN_VALUE || longValue > Integer.MAX_VALUE) { if (longValue < Integer.MIN_VALUE || longValue > Integer.MAX_VALUE) {
throw new NumberFormatException(VALUE_OUT_OF_RANGE); throw new NumberFormatException(VALUE_OUT_OF_RANGE);
@ -569,7 +520,7 @@ public class ValuesPanel extends javax.swing.JPanel {
try { try {
ByteOrder byteOrder = getByteOrder(); ByteOrder byteOrder = getByteOrder();
if (isSigned()) { if (isSigned()) {
Long longValue = Long.valueOf(longTextField.getText()); long longValue = Long.parseLong(longTextField.getText());
byteBuffer.rewind(); byteBuffer.rewind();
if (byteBuffer.order() != byteOrder) { if (byteBuffer.order() != byteOrder) {
@ -579,7 +530,7 @@ public class ValuesPanel extends javax.swing.JPanel {
byteBuffer.putLong(longValue); byteBuffer.putLong(longValue);
} else { } else {
BigInteger bigInteger = new BigInteger(longTextField.getText()); BigInteger bigInteger = new BigInteger(longTextField.getText());
if (bigInteger.compareTo(BigInteger.ZERO) == -1 || bigInteger.compareTo(ULONG_MAX_VALUE) == 1) { if (bigInteger.signum() == -1 || bigInteger.compareTo(ULONG_MAX_VALUE) > 0) {
throw new NumberFormatException(VALUE_OUT_OF_RANGE); throw new NumberFormatException(VALUE_OUT_OF_RANGE);
} }
@ -610,7 +561,7 @@ public class ValuesPanel extends javax.swing.JPanel {
if (evt.getKeyCode() == KeyEvent.VK_ENTER && isEditable()) { if (evt.getKeyCode() == KeyEvent.VK_ENTER && isEditable()) {
try { try {
ByteOrder byteOrder = getByteOrder(); ByteOrder byteOrder = getByteOrder();
Float floatValue = Float.valueOf(floatTextField.getText()); float floatValue = Float.parseFloat(floatTextField.getText());
byteBuffer.rewind(); byteBuffer.rewind();
if (byteBuffer.order() != byteOrder) { if (byteBuffer.order() != byteOrder) {
@ -631,7 +582,7 @@ public class ValuesPanel extends javax.swing.JPanel {
if (evt.getKeyCode() == KeyEvent.VK_ENTER && isEditable()) { if (evt.getKeyCode() == KeyEvent.VK_ENTER && isEditable()) {
try { try {
ByteOrder byteOrder = getByteOrder(); ByteOrder byteOrder = getByteOrder();
Double doubleValue = Double.valueOf(doubleTextField.getText()); double doubleValue = Double.parseDouble(doubleTextField.getText());
byteBuffer.rewind(); byteBuffer.rewind();
if (byteBuffer.order() != byteOrder) { if (byteBuffer.order() != byteOrder) {
@ -703,9 +654,7 @@ public class ValuesPanel extends javax.swing.JPanel {
updateValues(); updateValues();
}; };
codeArea.addDataChangedListener(dataChangedListener); codeArea.addDataChangedListener(dataChangedListener);
caretMovedListener = (CodeAreaCaretPosition caretPosition) -> { caretMovedListener = (CodeAreaCaretPosition caretPosition) -> updateValues();
updateValues();
};
codeArea.addCaretMovedListener(caretMovedListener); codeArea.addCaretMovedListener(caretMovedListener);
updateEditMode(); updateEditMode();
updateValues(); updateValues();
@ -815,9 +764,7 @@ public class ValuesPanel extends javax.swing.JPanel {
} }
private void scheduleNextStep(final ValuesPanelField valuesPanelField) { private void scheduleNextStep(final ValuesPanelField valuesPanelField) {
SwingUtilities.invokeLater(() -> { SwingUtilities.invokeLater(() -> updateValue(valuesPanelField));
updateValue(valuesPanelField);
});
} }
public boolean isUpdateInProgress() { public boolean isUpdateInProgress() {
@ -913,11 +860,11 @@ public class ValuesPanel extends javax.swing.JPanel {
case INTEGER: { case INTEGER: {
long intValue = signed long intValue = signed
? (byteOrder == ByteOrder.LITTLE_ENDIAN ? (byteOrder == ByteOrder.LITTLE_ENDIAN
? (values[0] & 0xffl) | ((values[1] & 0xffl) << 8) | ((values[2] & 0xffl) << 16) | (values[3] << 24) ? (values[0] & 0xffL) | ((values[1] & 0xffL) << 8) | ((values[2] & 0xffL) << 16) | (values[3] << 24)
: (values[3] & 0xffl) | ((values[2] & 0xffl) << 8) | ((values[1] & 0xffl) << 16) | (values[0] << 24)) : (values[3] & 0xffL) | ((values[2] & 0xffL) << 8) | ((values[1] & 0xffL) << 16) | (values[0] << 24))
: (byteOrder == ByteOrder.LITTLE_ENDIAN : (byteOrder == ByteOrder.LITTLE_ENDIAN
? (values[0] & 0xffl) | ((values[1] & 0xffl) << 8) | ((values[2] & 0xffl) << 16) | ((values[3] & 0xffl) << 24) ? (values[0] & 0xffL) | ((values[1] & 0xffL) << 8) | ((values[2] & 0xffL) << 16) | ((values[3] & 0xffL) << 24)
: (values[3] & 0xffl) | ((values[2] & 0xffl) << 8) | ((values[1] & 0xffl) << 16) | ((values[0] & 0xffl) << 24)); : (values[3] & 0xffL) | ((values[2] & 0xffL) << 8) | ((values[1] & 0xffL) << 16) | ((values[0] & 0xffL) << 24));
intTextField.setText(String.valueOf(intValue)); intTextField.setText(String.valueOf(intValue));
break; break;
} }
@ -931,11 +878,11 @@ public class ValuesPanel extends javax.swing.JPanel {
longTextField.setText(String.valueOf(byteBuffer.getLong())); longTextField.setText(String.valueOf(byteBuffer.getLong()));
} else { } else {
long longValue = byteOrder == ByteOrder.LITTLE_ENDIAN long longValue = byteOrder == ByteOrder.LITTLE_ENDIAN
? (values[0] & 0xffl) | ((values[1] & 0xffl) << 8) | ((values[2] & 0xffl) << 16) | ((values[3] & 0xffl) << 24) ? (values[0] & 0xffL) | ((values[1] & 0xffL) << 8) | ((values[2] & 0xffL) << 16) | ((values[3] & 0xffL) << 24)
| ((values[4] & 0xffl) << 32) | ((values[5] & 0xffl) << 40) | ((values[6] & 0xffl) << 48) | ((values[4] & 0xffL) << 32) | ((values[5] & 0xffL) << 40) | ((values[6] & 0xffL) << 48)
: (values[7] & 0xffl) | ((values[6] & 0xffl) << 8) | ((values[5] & 0xffl) << 16) | ((values[4] & 0xffl) << 24) : (values[7] & 0xffL) | ((values[6] & 0xffL) << 8) | ((values[5] & 0xffL) << 16) | ((values[4] & 0xffL) << 24)
| ((values[3] & 0xffl) << 32) | ((values[2] & 0xffl) << 40) | ((values[1] & 0xffl) << 48); | ((values[3] & 0xffL) << 32) | ((values[2] & 0xffL) << 40) | ((values[1] & 0xffL) << 48);
BigInteger bigInt1 = BigInteger.valueOf(values[byteOrder == ByteOrder.LITTLE_ENDIAN ? 7 : 0] & 0xffl); BigInteger bigInt1 = BigInteger.valueOf(values[byteOrder == ByteOrder.LITTLE_ENDIAN ? 7 : 0] & 0xffL);
BigInteger bigInt2 = bigInt1.shiftLeft(56); BigInteger bigInt2 = bigInt1.shiftLeft(56);
BigInteger bigInt3 = bigInt2.add(BigInteger.valueOf(longValue)); BigInteger bigInt3 = bigInt2.add(BigInteger.valueOf(longValue));
longTextField.setText(bigInt3.toString()); longTextField.setText(bigInt3.toString());

View File

@ -94,7 +94,7 @@ public class ResourceListPane extends TranslatedVisibleComponent implements File
//used to remove resources from the resource list //used to remove resources from the resource list
public void removeFile(ResourceContainer resourceContainer) public void removeFile(ResourceContainer resourceContainer)
{ {
BytecodeViewer.resourceContainers.remove(resourceContainer); while (BytecodeViewer.resourceContainers.values().remove(resourceContainer));
LazyNameUtil.removeName(resourceContainer.name); LazyNameUtil.removeName(resourceContainer.name);
} }
@ -263,7 +263,6 @@ public class ResourceListPane extends TranslatedVisibleComponent implements File
} }
} }
@SuppressWarnings("rawtypes")
public void removeNode(final JTree tree, final TreePath nodePath) { public void removeNode(final JTree tree, final TreePath nodePath) {
MutableTreeNode node = findNodeByPath(nodePath); MutableTreeNode node = findNodeByPath(nodePath);
if (node == null) if (node == null)
@ -274,7 +273,6 @@ public class ResourceListPane extends TranslatedVisibleComponent implements File
tree.updateUI(); tree.updateUI();
} }
@SuppressWarnings("rawtypes")
private MutableTreeNode findNodeByPath(TreePath path) { private MutableTreeNode findNodeByPath(TreePath path) {
MutableTreeNode node = treeRoot; MutableTreeNode node = treeRoot;
for (int pathStep = 1; pathStep < path.getPathCount(); pathStep++) { for (int pathStep = 1; pathStep < path.getPathCount(); pathStep++) {

View File

@ -55,9 +55,7 @@ class PerformSearch extends BackgroundSearchThread
} }
for (ResourceContainer container : BytecodeViewer.resourceContainers.values()) for (ResourceContainer container : BytecodeViewer.resourceContainers.values())
container.resourceClasses.forEach((key,cn)->{ container.resourceClasses.forEach((key,cn)-> searchBoxPane.searchType.panel.search(container, key, cn, searchBoxPane.exact.isSelected()));
searchBoxPane.searchType.panel.search(container, key, cn, searchBoxPane.exact.isSelected());
});
BytecodeViewer.viewer.searchBoxPane.search.setEnabled(true); BytecodeViewer.viewer.searchBoxPane.search.setEnabled(true);
BytecodeViewer.viewer.searchBoxPane.search.setText(TranslatedStrings.SEARCH.toString()); BytecodeViewer.viewer.searchBoxPane.search.setText(TranslatedStrings.SEARCH.toString());

View File

@ -65,13 +65,12 @@ public class SearchBoxPane extends TranslatedVisibleComponent
public final JComboBox<SearchType> typeBox; public final JComboBox<SearchType> typeBox;
public SearchType searchType = null; public SearchType searchType = null;
public final JComboBox searchRadiusBox; public final JComboBox<SearchRadius> searchRadiusBox;
public final JPopupMenu rightClickMenu = new JPopupMenu(); public final JPopupMenu rightClickMenu = new JPopupMenu();
public JButton search = new TranslatedJButton("Search", TranslatedComponents.SEARCH); public JButton search = new TranslatedJButton("Search", TranslatedComponents.SEARCH);
public BackgroundSearchThread performSearchThread; public BackgroundSearchThread performSearchThread;
@SuppressWarnings("unchecked")
public SearchBoxPane() public SearchBoxPane()
{ {
super("Search", TranslatedComponents.SEARCH); super("Search", TranslatedComponents.SEARCH);
@ -82,20 +81,20 @@ public class SearchBoxPane extends TranslatedVisibleComponent
searchRadiusOpt.add(new TranslatedJLabel("Search from ", TranslatedComponents.SEARCH_FROM), BorderLayout.WEST); searchRadiusOpt.add(new TranslatedJLabel("Search from ", TranslatedComponents.SEARCH_FROM), BorderLayout.WEST);
DefaultComboBoxModel model = new DefaultComboBoxModel(); DefaultComboBoxModel<SearchRadius> radiusModel = new DefaultComboBoxModel<>();
for (final SearchRadius st : SEARCH_RADII) for (final SearchRadius st : SEARCH_RADII)
model.addElement(st); radiusModel.addElement(st);
searchRadiusBox = new JComboBox(model); searchRadiusBox = new JComboBox<>(radiusModel);
searchRadiusOpt.add(searchRadiusBox, BorderLayout.CENTER); searchRadiusOpt.add(searchRadiusBox, BorderLayout.CENTER);
searchOpts.add(searchRadiusOpt); searchOpts.add(searchRadiusOpt);
model = new DefaultComboBoxModel(); DefaultComboBoxModel<SearchType> typeModel = new DefaultComboBoxModel<>();
for (final SearchType st : SEARCH_TYPES) for (final SearchType st : SEARCH_TYPES)
model.addElement(st); typeModel.addElement(st);
typeBox = new JComboBox<SearchType>(model); typeBox = new JComboBox<>(typeModel);
final JPanel searchOptPanel = new JPanel(); final JPanel searchOptPanel = new JPanel();
final ItemListener il = arg0 -> { final ItemListener il = arg0 -> {

View File

@ -80,8 +80,8 @@ public class BytecodeViewPanel extends JPanel
return true; return true;
SystemConsole errConsole = new SystemConsole(TranslatedStrings.JAVA_COMPILE_FAILED.toString()); SystemConsole errConsole = new SystemConsole(TranslatedStrings.JAVA_COMPILE_FAILED.toString());
errConsole.setText(TranslatedStrings.ERROR_COMPILING_CLASS.toString() + " " + viewer.resource.getResourceClassNode().name + errConsole.setText(TranslatedStrings.ERROR_COMPILING_CLASS + " " + viewer.resource.getResourceClassNode().name +
nl + TranslatedStrings.COMPILER_TIP.toString() + nl + TranslatedStrings.COMPILER_TIP +
nl + nl + TranslatedStrings.SUGGESTED_FIX_COMPILER_ERROR + nl + nl + TranslatedStrings.SUGGESTED_FIX_COMPILER_ERROR +
nl + nl); nl + nl);

View File

@ -72,9 +72,9 @@ public class DecompilerSelectionPane
{ {
this.paneID = paneID; this.paneID = paneID;
if(paneID == 1) if(paneID == 1)
this.menu = new TranslatedJMenu("Pane " + paneID, TranslatedComponents.PANE_1); this.menu = new TranslatedJMenu("Pane " + 1, TranslatedComponents.PANE_1);
else if(paneID == 2) else if(paneID == 2)
this.menu = new TranslatedJMenu("Pane " + paneID, TranslatedComponents.PANE_2); this.menu = new TranslatedJMenu("Pane " + 2, TranslatedComponents.PANE_2);
else else
this.menu = new TranslatedJMenu("Pane " + paneID, TranslatedComponents.PANE_3); this.menu = new TranslatedJMenu("Pane " + paneID, TranslatedComponents.PANE_3);

View File

@ -91,8 +91,8 @@ public class TabbedPane extends JPanel
//define the right click pop-up menu //define the right click pop-up menu
JPopupMenu rightClickMenu = new JPopupMenu(); JPopupMenu rightClickMenu = new JPopupMenu();
JMenuItem closeAllTabs = new JMenuItem(TranslatedStrings.CLOSE_ALL_BUT_THIS.toString() + ": " + name); JMenuItem closeAllTabs = new JMenuItem(TranslatedStrings.CLOSE_ALL_BUT_THIS + ": " + name);
JMenuItem closeTab = new JMenuItem(TranslatedStrings.CLOSE_TAB.toString() + ": " + name); JMenuItem closeTab = new JMenuItem(TranslatedStrings.CLOSE_TAB + ": " + name);
rightClickMenu.add(closeAllTabs); rightClickMenu.add(closeAllTabs);
rightClickMenu.add(closeTab); rightClickMenu.add(closeTab);

View File

@ -119,8 +119,8 @@ public class Workspace extends TranslatedVisibleComponent
if (c != null && bounds.intersects(c.getBounds())) if (c != null && bounds.intersects(c.getBounds()))
{ {
popUp.setVisible(true); popUp.setVisible(true);
closeAllTabs.setText(TranslatedStrings.CLOSE_TAB.toString() + ": " + ((TabbedPane) c).tabName); closeAllTabs.setText(TranslatedStrings.CLOSE_TAB + ": " + ((TabbedPane) c).tabName);
closeTab.setText(TranslatedStrings.CLOSE_TAB.toString() + ": " + ((TabbedPane) c).tabName); closeTab.setText(TranslatedStrings.CLOSE_TAB + ": " + ((TabbedPane) c).tabName);
} }
else else
{ {

View File

@ -33,7 +33,7 @@ import the.bytecode.club.bytecodeviewer.resources.Resource;
public class ComponentViewer extends ResourceViewer public class ComponentViewer extends ResourceViewer
{ {
private Component component; private final Component component;
private static final String containerName = "internalComponent."; private static final String containerName = "internalComponent.";
public ComponentViewer(String title, Component component) public ComponentViewer(String title, Component component)

View File

@ -1,6 +1,7 @@
package the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.synchronizedscroll; package the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.synchronizedscroll;
import java.util.Arrays; import java.util.Arrays;
import java.util.Objects;
import org.objectweb.asm.Type; import org.objectweb.asm.Type;
/*************************************************************************** /***************************************************************************
@ -28,18 +29,20 @@ import org.objectweb.asm.Type;
public class MethodData public class MethodData
{ {
public String name, desc; public String name, desc;
@Override @Override
public boolean equals(final Object o) public boolean equals(Object o) {
{ if (this == o) return true;
return equals((MethodData) o); if (!(o instanceof MethodData)) return false;
MethodData that = (MethodData) o;
return Objects.equals(name, that.name) && Objects.equals(desc, that.desc);
} }
public boolean equals(final MethodData md) @Override
{ public int hashCode() {
return this.name.equals(md.name) && this.desc.equals(md.desc); return Objects.hash(name, desc);
} }
public String constructPattern() public String constructPattern()
{ {
final StringBuilder pattern = new StringBuilder(); final StringBuilder pattern = new StringBuilder();

View File

@ -119,7 +119,7 @@ public class BytecodeViewPanelUpdater implements Runnable
{ {
try { try {
Thread.sleep(1); Thread.sleep(1);
} catch (Exception e) {} } catch (Exception ignored) {}
} }
} }
} }

View File

@ -68,7 +68,7 @@ public class RemappingSignatureAdapter extends SignatureVisitor {
@Override @Override
public void visitInnerClassType(String name) { public void visitInnerClassType(String name) {
String remappedOuter = remapper.mapType(className) + '$'; String remappedOuter = remapper.mapType(className) + '$';
className = className + '$' + name; className += '$' + name;
String remappedName = remapper.mapType(className); String remappedName = remapper.mapType(className);
int index = remappedName.startsWith(remappedOuter) ? remappedOuter int index = remappedName.startsWith(remappedOuter) ? remappedOuter
.length() : remappedName.lastIndexOf('$') + 1; .length() : remappedName.lastIndexOf('$') + 1;

View File

@ -55,7 +55,7 @@ public final class PluginManager
{ {
private static final Map<String, PluginLaunchStrategy> launchStrategies = new HashMap<>(); private static final Map<String, PluginLaunchStrategy> launchStrategies = new HashMap<>();
private static final PluginFileFilter filter = new PluginFileFilter(); private static final PluginFileFilter filter = new PluginFileFilter();
private static List<Plugin> pluginInstances = new ArrayList<>(); private static final List<Plugin> pluginInstances = new ArrayList<>();
//TODO this system needs to be redone, currently it will conflict if more than one plugin is ran at the same time //TODO this system needs to be redone, currently it will conflict if more than one plugin is ran at the same time
// the solution is to tie the plugin object into the plugin console, // the solution is to tie the plugin object into the plugin console,
@ -155,8 +155,8 @@ public final class PluginManager
return; return;
} }
final String name = (activePlugin == null || activePlugin.activeContainer == null) final String name = activePlugin.activeContainer == null
? ("#" + (activeTabbedException.getTabbedPane().getTabCount() + 1)) : activePlugin.activeContainer.name; ? "#" + (activeTabbedException.getTabbedPane().getTabCount() + 1) : activePlugin.activeContainer.name;
ExceptionUI existingUI = exceptionTabs.get(name); ExceptionUI existingUI = exceptionTabs.get(name);

View File

@ -231,7 +231,7 @@ public class PluginWriter extends JFrame
//auto append extension //auto append extension
if (!path.endsWith("." + ext)) if (!path.endsWith("." + ext))
path = path + "." + ext; path += "." + ext;
if (!DialogUtils.canOverwriteFile(path)) if (!DialogUtils.canOverwriteFile(path))
return; return;

View File

@ -226,7 +226,7 @@ public class AllatoriStringDecrypter extends Plugin
{ {
InsnList iList = decryptermethodnode.instructions; InsnList iList = decryptermethodnode.instructions;
AbstractInsnNode insn = null, removeInsn = null; AbstractInsnNode insn = null, removeInsn;
for (AbstractInsnNode i : iList.toArray()) for (AbstractInsnNode i : iList.toArray())
{ {
if (i instanceof MethodInsnNode) if (i instanceof MethodInsnNode)
@ -292,7 +292,7 @@ public class AllatoriStringDecrypter extends Plugin
public static class AllatoriStringDecrypterOptionsFrame extends JFrame public static class AllatoriStringDecrypterOptionsFrame extends JFrame
{ {
private JTextField textField; private final JTextField textField;
public AllatoriStringDecrypterOptionsFrame() public AllatoriStringDecrypterOptionsFrame()
{ {

View File

@ -62,9 +62,7 @@ public class ExternalResources
return Configuration.java; return Configuration.java;
//check CLI for java //check CLI for java
testCommand(new String[]{"java", "-version"}, "java version", ()->{ testCommand(new String[]{"java", "-version"}, "java version", ()-> Configuration.java = "java");
Configuration.java = "java";
});
if(!Configuration.java.isEmpty()) if(!Configuration.java.isEmpty())
return Configuration.java; return Configuration.java;
@ -137,9 +135,7 @@ public class ExternalResources
return Configuration.python2; return Configuration.python2;
//check if 'python' command is bound as python 2.X //check if 'python' command is bound as python 2.X
testCommand(new String[]{"python", "--version"}, "python 2", ()->{ testCommand(new String[]{"python", "--version"}, "python 2", ()-> Configuration.python2 = "python");
Configuration.python2 = "python";
});
if(!Configuration.python2.isEmpty()) if(!Configuration.python2.isEmpty())
return Configuration.python2; return Configuration.python2;
@ -178,17 +174,13 @@ public class ExternalResources
//check if 'python3' command is bound as python 3.X //check if 'python3' command is bound as python 3.X
testCommand(new String[]{"python3", "--version"}, "python 3", ()->{ testCommand(new String[]{"python3", "--version"}, "python 3", ()-> Configuration.python3 = "python3");
Configuration.python3 = "python3";
});
if(!Configuration.python3.isEmpty()) if(!Configuration.python3.isEmpty())
return Configuration.python3; return Configuration.python3;
//check if 'python' command is bound as python 3.X //check if 'python' command is bound as python 3.X
testCommand(new String[]{"python", "--version"}, "python 3", ()->{ testCommand(new String[]{"python", "--version"}, "python 3", ()-> Configuration.python3 = "python");
Configuration.python3 = "python";
});
if(!Configuration.python3.isEmpty()) if(!Configuration.python3.isEmpty())
return Configuration.python3; return Configuration.python3;

View File

@ -104,9 +104,9 @@ public class APKExport implements Exporter
final File file = fc.getSelectedFile(); final File file = fc.getSelectedFile();
String output = file.getAbsolutePath(); String output = file.getAbsolutePath();
//auto appened .apk //auto append .apk
if (!output.endsWith(".apk")) if (!output.endsWith(".apk"))
output = output + ".apk"; output += ".apk";
final File file2 = new File(output); final File file2 = new File(output);
if (!DialogUtils.canOverwriteFile(file2)) if (!DialogUtils.canOverwriteFile(file2))

View File

@ -65,7 +65,7 @@ public class DexExport implements Exporter
//auto append .dex //auto append .dex
if (!output.endsWith(".dex")) if (!output.endsWith(".dex"))
output = output + ".dex"; output += ".dex";
File outputPath = new File(output); File outputPath = new File(output);
if (!DialogUtils.canOverwriteFile(outputPath)) if (!DialogUtils.canOverwriteFile(outputPath))

View File

@ -59,7 +59,7 @@ public class RunnableJarExporter implements Exporter
//auto append .jar //auto append .jar
if (!path.endsWith(".jar")) if (!path.endsWith(".jar"))
path = path + ".jar"; path += ".jar";
if (!DialogUtils.canOverwriteFile(path)) if (!DialogUtils.canOverwriteFile(path))
return; return;

View File

@ -54,7 +54,6 @@ public class ImportResource implements Runnable
if (file.isDirectory()) if (file.isDirectory())
{ {
Import.DIRECTORY.getImporter().open(file); Import.DIRECTORY.getImporter().open(file);
continue;
} }
//everything else import as a resource //everything else import as a resource
else if(!importKnownFile(file)) else if(!importKnownFile(file))

View File

@ -132,7 +132,7 @@ public enum Language
try { try {
TranslatedStrings str = TranslatedStrings.valueOf(text.key); TranslatedStrings str = TranslatedStrings.valueOf(text.key);
str.setText(text.value); str.setText(text.value);
} catch (IllegalArgumentException e) { } } catch (IllegalArgumentException ignored) { }
//check if translation key has been assigned to a component, //check if translation key has been assigned to a component,
//on fail print an error alerting the devs //on fail print an error alerting the devs

View File

@ -82,7 +82,7 @@ public class Enjarify {
try { try {
Thread.sleep(500); Thread.sleep(500);
} catch (InterruptedException e) { } } catch (InterruptedException ignored) { }
} }
}, "Enjarify Fail Safe Thread").start(); }, "Enjarify Fail Safe Thread").start();

View File

@ -54,7 +54,7 @@ import static the.bytecode.club.bytecodeviewer.BytecodeViewer.gson;
public class MiscUtils public class MiscUtils
{ {
private static CharsetEncoder asciiEncoder = StandardCharsets.US_ASCII.newEncoder(); // or "ISO-8859-1" for ISO Latin 1 private static final CharsetEncoder asciiEncoder = StandardCharsets.US_ASCII.newEncoder(); // or "ISO-8859-1" for ISO Latin 1
private static final String AB = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; private static final String AB = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
private static final String AN = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; private static final String AN = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
private static final Random rnd = new Random(); private static final Random rnd = new Random();
@ -186,7 +186,7 @@ public class MiscUtils
public static String append(File file, String extension) { public static String append(File file, String extension) {
String path = file.getAbsolutePath(); String path = file.getAbsolutePath();
if (!path.endsWith(extension)) if (!path.endsWith(extension))
path = path + extension; path += extension;
return path; return path;
} }

View File

@ -37,26 +37,26 @@ class SeqAndCount
public SeqAndCount incrSeq() public SeqAndCount incrSeq()
{ {
seq = seq + 1; seq++;
return this; return this;
} }
public SeqAndCount incrCount() public SeqAndCount incrCount()
{ {
count = count + 1; count++;
return this; return this;
} }
public SeqAndCount decrCount() public SeqAndCount decrCount()
{ {
count = count - 1; count--;
return this; return this;
} }
public SeqAndCount incrSeqAndCount() public SeqAndCount incrSeqAndCount()
{ {
seq = seq + 1; seq++;
count = count + 1; count++;
return this; return this;
} }

View File

@ -1,4 +1,4 @@
<html> <html lang="en">
<h2>About</h2> <h2>About</h2>
Bytecode Viewer (BCV) is an easy to use Java & Android Reverse Engineering Suite!<br> Bytecode Viewer (BCV) is an easy to use Java & Android Reverse Engineering Suite!<br>

View File

@ -1,4 +1,4 @@
<html> <html lang="en">
<h2>About</h2> <h2>About</h2>
Bytecode Viewer (BCV) was designed to be extremely user and beginner friendly, because of this almost everything Bytecode Viewer (BCV) was designed to be extremely user and beginner friendly, because of this almost everything

View File

@ -1,4 +1,4 @@
<html> <html lang="de">
<h2>Über uns</h2> <h2>Über uns</h2>
Der Bytecode Viewer (BCV) wurde extrem benutzer- und einsteigerfreundlich gestaltet, deshalb ist fast alles Der Bytecode Viewer (BCV) wurde extrem benutzer- und einsteigerfreundlich gestaltet, deshalb ist fast alles

View File

@ -1,9 +1,9 @@
<html> <html lang="zh">
<h2>关于</h2> <h2>关于</h2>
Bytecode Viewer (BCV)被设计成对用户和初学者非常友好,因此,几乎所有的东西都可以通过界面、设置、工具等方式进行访问。 Bytecode Viewer (BCV)被设计成对用户和初学者非常友好,因此,几乎所有的东西都可以通过界面、设置、工具等方式进行访问。
<br>将Jar/APK/Class文件拖到资源列表中。</br> <br><br>将Jar/APK/Class文件拖到资源列表中。
<h2>设置</h2> <h2>设置</h2>
<ul> <ul>
@ -118,4 +118,4 @@ Bytecode Viewer (BCV)被设计成对用户和初学者非常友好,因此,
<li>Bytecode Viewer的主页是 <a href="https://bytecodeviewer.com">https://bytecodeviewer.com</a></li> <li>Bytecode Viewer的主页是 <a href="https://bytecodeviewer.com">https://bytecodeviewer.com</a></li>
</ul> </ul>
</html> </html>