mirror of
https://github.com/SuspiciousActivity/ByteEdit.git
synced 2026-08-13 17:56:17 +00:00
New stuff
This commit is contained in:
1 parent
6b66ff27e2
commit
c91d8ccada
23 files changed
+10071
-9217
No files matched your search
@@ -1,174 +1,174 @@
|
|||||||
package me.ByteEdit.boxes;
|
package me.ByteEdit.boxes;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
import javax.tools.JavaCompiler;
|
import javax.tools.JavaCompiler;
|
||||||
import javax.tools.SimpleJavaFileObject;
|
import javax.tools.SimpleJavaFileObject;
|
||||||
import javax.tools.ToolProvider;
|
import javax.tools.ToolProvider;
|
||||||
|
|
||||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||||
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
|
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
|
||||||
import org.fife.ui.rtextarea.RTextScrollPane;
|
import org.fife.ui.rtextarea.RTextScrollPane;
|
||||||
import org.objectweb.asm.ClassReader;
|
import org.objectweb.asm.ClassReader;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
|
||||||
import me.ByteEdit.edit.Disassembler;
|
import me.ByteEdit.edit.Disassembler;
|
||||||
import me.ByteEdit.main.Main;
|
import me.ByteEdit.main.Main;
|
||||||
|
|
||||||
public class CompilationBox extends JFrame {
|
public class CompilationBox extends JFrame {
|
||||||
|
|
||||||
private JPanel contentPane;
|
private JPanel contentPane;
|
||||||
private JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
private JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||||
RSyntaxTextArea textArea = new RSyntaxTextArea();
|
RSyntaxTextArea textArea = new RSyntaxTextArea();
|
||||||
CompilationSuccess compSuccess;
|
CompilationSuccess compSuccess;
|
||||||
|
|
||||||
public CompilationBox() {
|
public CompilationBox() {
|
||||||
compSuccess = new CompilationSuccess();
|
compSuccess = new CompilationSuccess();
|
||||||
try {
|
try {
|
||||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
setTitle("Java Compiler");
|
setTitle("Java Compiler");
|
||||||
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
||||||
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 400),
|
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 400),
|
||||||
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 200), 800, 400);
|
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 200), 800, 400);
|
||||||
contentPane = new JPanel();
|
contentPane = new JPanel();
|
||||||
contentPane.setBackground(Main.dark ? new Color(0x2F2F2F) : Color.GRAY);
|
contentPane.setBackground(Main.dark ? new Color(0x2F2F2F) : Color.GRAY);
|
||||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
setContentPane(contentPane);
|
setContentPane(contentPane);
|
||||||
contentPane.setLayout(new BorderLayout(0, 0));
|
contentPane.setLayout(new BorderLayout(0, 0));
|
||||||
|
|
||||||
Main.theme.apply(textArea);
|
Main.theme.apply(textArea);
|
||||||
textArea.setEditable(true);
|
textArea.setEditable(true);
|
||||||
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
|
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
|
||||||
textArea.setCodeFoldingEnabled(true);
|
textArea.setCodeFoldingEnabled(true);
|
||||||
textArea.setBackground(Main.dark ? new Color(0x2F2F2F) : Color.LIGHT_GRAY);
|
textArea.setBackground(Main.dark ? new Color(0x2F2F2F) : Color.LIGHT_GRAY);
|
||||||
|
|
||||||
RTextScrollPane scrollPane = new RTextScrollPane();
|
RTextScrollPane scrollPane = new RTextScrollPane();
|
||||||
scrollPane.setViewportView(textArea);
|
scrollPane.setViewportView(textArea);
|
||||||
scrollPane.setLineNumbersEnabled(true);
|
scrollPane.setLineNumbersEnabled(true);
|
||||||
scrollPane.setFoldIndicatorEnabled(true);
|
scrollPane.setFoldIndicatorEnabled(true);
|
||||||
scrollPane.getGutter().setBackground(Main.dark ? new Color(0x2F2F2F) : Color.LIGHT_GRAY);
|
scrollPane.getGutter().setBackground(Main.dark ? new Color(0x2F2F2F) : Color.LIGHT_GRAY);
|
||||||
contentPane.add(scrollPane);
|
contentPane.add(scrollPane);
|
||||||
|
|
||||||
KeyStroke ctrlS = KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_DOWN_MASK);
|
KeyStroke ctrlS = KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_DOWN_MASK);
|
||||||
textArea.registerKeyboardAction(new ActionListener() {
|
textArea.registerKeyboardAction(new ActionListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if (compiler == null) {
|
if (compiler == null) {
|
||||||
Main.showError("No Java Compiler found!\nYou need JDK installed!");
|
Main.showError("No Java Compiler found!\nYou need JDK installed!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try (StringWriter out = new StringWriter(); PrintWriter outWriter = new PrintWriter(out)) {
|
try (StringWriter out = new StringWriter(); PrintWriter outWriter = new PrintWriter(out)) {
|
||||||
File tmpFolder = Files.createTempDirectory("compiled").toFile();
|
File tmpFolder = Files.createTempDirectory("compiled").toFile();
|
||||||
|
|
||||||
String source = textArea.getText();
|
String source = textArea.getText();
|
||||||
if (!source.contains("\npublic class Compiled {\n")) {
|
if (!source.contains("\npublic class Compiled {\n")) {
|
||||||
int importIndex = source.lastIndexOf("\nimport");
|
int importIndex = source.lastIndexOf("\nimport");
|
||||||
if (importIndex == -1) {
|
if (importIndex == -1) {
|
||||||
if (source.startsWith("import")) {
|
if (source.startsWith("import")) {
|
||||||
importIndex = 0;
|
importIndex = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
importIndex++;
|
importIndex++;
|
||||||
}
|
}
|
||||||
if (importIndex != -1) {
|
if (importIndex != -1) {
|
||||||
int newLineIndex = source.indexOf('\n', importIndex);
|
int newLineIndex = source.indexOf('\n', importIndex);
|
||||||
source = source.substring(0, newLineIndex) + "\npublic class Compiled {\n"
|
source = source.substring(0, newLineIndex) + "\npublic class Compiled {\n"
|
||||||
+ source.substring(newLineIndex) + "\n}";
|
+ source.substring(newLineIndex) + "\n}";
|
||||||
} else {
|
} else {
|
||||||
source = "public class Compiled {\n" + source + "\n}";
|
source = "public class Compiled {\n" + source + "\n}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
compiler.getTask(outWriter, null, null,
|
compiler.getTask(outWriter, null, null,
|
||||||
Main.jarFile != null
|
Main.jarFile != null
|
||||||
? Arrays.asList("-d", tmpFolder.getAbsolutePath(), "-classpath",
|
? Arrays.asList("-d", tmpFolder.getAbsolutePath(), "-classpath",
|
||||||
Main.jarFile.getAbsolutePath())
|
Main.jarFile.getAbsolutePath())
|
||||||
: Arrays.asList("-d", tmpFolder.getAbsolutePath()),
|
: Arrays.asList("-d", tmpFolder.getAbsolutePath()),
|
||||||
null, Arrays.asList(new JavaSourceFromString("Compiled", source))).call();
|
null, Arrays.asList(new JavaSourceFromString("Compiled", source))).call();
|
||||||
String res = out.toString();
|
String res = out.toString();
|
||||||
if (res.isEmpty()) {
|
if (res.isEmpty()) {
|
||||||
File clazz = new File(tmpFolder, "Compiled.class");
|
File clazz = new File(tmpFolder, "Compiled.class");
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
InputStream is = new FileInputStream(clazz);
|
InputStream is = new FileInputStream(clazz);
|
||||||
byte[] tmp = new byte[1024];
|
byte[] tmp = new byte[1024];
|
||||||
int r;
|
int r;
|
||||||
while ((r = is.read(tmp)) > 0) {
|
while ((r = is.read(tmp)) > 0) {
|
||||||
baos.write(tmp, 0, r);
|
baos.write(tmp, 0, r);
|
||||||
}
|
}
|
||||||
is.close();
|
is.close();
|
||||||
ClassReader read = new ClassReader(baos.toByteArray());
|
ClassReader read = new ClassReader(baos.toByteArray());
|
||||||
ClassNode node = new ClassNode();
|
ClassNode node = new ClassNode();
|
||||||
read.accept(node, 0);
|
read.accept(node, 0);
|
||||||
String dis = Disassembler.disassemble(node);
|
String dis = Disassembler.disassemble(node);
|
||||||
File[] files = tmpFolder.listFiles();
|
File[] files = tmpFolder.listFiles();
|
||||||
if (files != null)
|
if (files != null)
|
||||||
for (File f : files) {
|
for (File f : files) {
|
||||||
if (f.getName().equals("Compiled.class"))
|
if (f.getName().equals("Compiled.class"))
|
||||||
continue;
|
continue;
|
||||||
baos = new ByteArrayOutputStream();
|
baos = new ByteArrayOutputStream();
|
||||||
is = new FileInputStream(f);
|
is = new FileInputStream(f);
|
||||||
while ((r = is.read(tmp)) > 0) {
|
while ((r = is.read(tmp)) > 0) {
|
||||||
baos.write(tmp, 0, r);
|
baos.write(tmp, 0, r);
|
||||||
}
|
}
|
||||||
is.close();
|
is.close();
|
||||||
read = new ClassReader(baos.toByteArray());
|
read = new ClassReader(baos.toByteArray());
|
||||||
node = new ClassNode();
|
node = new ClassNode();
|
||||||
read.accept(node, 0);
|
read.accept(node, 0);
|
||||||
dis += "\n" + Disassembler.disassemble(node);
|
dis += "\n" + Disassembler.disassemble(node);
|
||||||
}
|
}
|
||||||
compSuccess.textArea.setText(dis);
|
compSuccess.textArea.setText(dis);
|
||||||
compSuccess.setVisible(true);
|
compSuccess.setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
JOptionPane.showMessageDialog(CompilationBox.this, res, "Error!", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(CompilationBox.this, res, "Error!", JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
for (File f : tmpFolder.listFiles()) {
|
for (File f : tmpFolder.listFiles()) {
|
||||||
Files.delete(f.toPath());
|
Files.delete(f.toPath());
|
||||||
}
|
}
|
||||||
Files.delete(tmpFolder.toPath());
|
Files.delete(tmpFolder.toPath());
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, ctrlS, JComponent.WHEN_FOCUSED);
|
}, ctrlS, JComponent.WHEN_FOCUSED);
|
||||||
}
|
}
|
||||||
|
|
||||||
class JavaSourceFromString extends SimpleJavaFileObject {
|
class JavaSourceFromString extends SimpleJavaFileObject {
|
||||||
final String code;
|
final String code;
|
||||||
|
|
||||||
public JavaSourceFromString(String name, String code) {
|
public JavaSourceFromString(String name, String code) {
|
||||||
super(URI.create("string:///" + name.replace('.', '/') + Kind.SOURCE.extension), Kind.SOURCE);
|
super(URI.create("string:///" + name.replace('.', '/') + Kind.SOURCE.extension), Kind.SOURCE);
|
||||||
this.code = code;
|
this.code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getCharContent(boolean ignoreEncodingErrors) {
|
public CharSequence getCharContent(boolean ignoreEncodingErrors) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,82 +1,52 @@
|
|||||||
package me.ByteEdit.boxes;
|
package me.ByteEdit.boxes;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
import javax.swing.JFrame;
|
||||||
import java.awt.event.KeyEvent;
|
import javax.swing.JPanel;
|
||||||
import java.io.ByteArrayOutputStream;
|
import javax.swing.UIManager;
|
||||||
import java.io.File;
|
import javax.swing.border.EmptyBorder;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||||
import java.io.InputStream;
|
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
|
||||||
import java.io.PrintWriter;
|
import org.fife.ui.rtextarea.RTextScrollPane;
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.net.URI;
|
import me.ByteEdit.main.Main;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
public class CompilationSuccess extends JFrame {
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Iterator;
|
private JPanel contentPane;
|
||||||
import java.util.Set;
|
RSyntaxTextArea textArea = new RSyntaxTextArea();
|
||||||
|
|
||||||
import javax.swing.JComponent;
|
public CompilationSuccess() {
|
||||||
import javax.swing.JFrame;
|
try {
|
||||||
import javax.swing.JPanel;
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||||
import javax.swing.KeyStroke;
|
} catch (Exception e) {
|
||||||
import javax.swing.UIManager;
|
e.printStackTrace();
|
||||||
import javax.swing.border.EmptyBorder;
|
}
|
||||||
import javax.tools.FileObject;
|
setTitle("Java Compiler - Result");
|
||||||
import javax.tools.JavaCompiler;
|
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
||||||
import javax.tools.JavaCompiler.CompilationTask;
|
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 400),
|
||||||
import javax.tools.JavaFileManager;
|
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 200), 800, 400);
|
||||||
import javax.tools.JavaFileObject;
|
contentPane = new JPanel();
|
||||||
import javax.tools.JavaFileObject.Kind;
|
contentPane.setBackground(Main.dark ? new Color(0x2F2F2F) : Color.GRAY);
|
||||||
import javax.tools.SimpleJavaFileObject;
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
import javax.tools.StandardJavaFileManager;
|
setContentPane(contentPane);
|
||||||
import javax.tools.ToolProvider;
|
contentPane.setLayout(new BorderLayout(0, 0));
|
||||||
|
|
||||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
Main.theme.apply(textArea);
|
||||||
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
|
textArea.setEditable(true);
|
||||||
import org.fife.ui.rtextarea.RTextScrollPane;
|
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA_DISASSEMBLE);
|
||||||
import org.objectweb.asm.ClassReader;
|
textArea.setCodeFoldingEnabled(true);
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
textArea.setBackground(Main.dark ? new Color(0x2F2F2F) : Color.LIGHT_GRAY);
|
||||||
|
|
||||||
import me.ByteEdit.edit.Disassembler;
|
RTextScrollPane scrollPane = new RTextScrollPane();
|
||||||
import me.ByteEdit.main.Main;
|
scrollPane.setViewportView(textArea);
|
||||||
|
scrollPane.setLineNumbersEnabled(true);
|
||||||
public class CompilationSuccess extends JFrame {
|
scrollPane.setFoldIndicatorEnabled(true);
|
||||||
|
scrollPane.getGutter().setBackground(Main.dark ? new Color(0x2F2F2F) : Color.LIGHT_GRAY);
|
||||||
private JPanel contentPane;
|
contentPane.add(scrollPane);
|
||||||
RSyntaxTextArea textArea = new RSyntaxTextArea();
|
}
|
||||||
|
}
|
||||||
public CompilationSuccess() {
|
|
||||||
try {
|
|
||||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
setTitle("Java Compiler - Result");
|
|
||||||
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
|
||||||
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 400),
|
|
||||||
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 200), 800, 400);
|
|
||||||
contentPane = new JPanel();
|
|
||||||
contentPane.setBackground(Main.dark ? new Color(0x2F2F2F) : Color.GRAY);
|
|
||||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
|
||||||
setContentPane(contentPane);
|
|
||||||
contentPane.setLayout(new BorderLayout(0, 0));
|
|
||||||
|
|
||||||
Main.theme.apply(textArea);
|
|
||||||
textArea.setEditable(true);
|
|
||||||
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA_DISASSEMBLE);
|
|
||||||
textArea.setCodeFoldingEnabled(true);
|
|
||||||
textArea.setBackground(Main.dark ? new Color(0x2F2F2F) : Color.LIGHT_GRAY);
|
|
||||||
|
|
||||||
RTextScrollPane scrollPane = new RTextScrollPane();
|
|
||||||
scrollPane.setViewportView(textArea);
|
|
||||||
scrollPane.setLineNumbersEnabled(true);
|
|
||||||
scrollPane.setFoldIndicatorEnabled(true);
|
|
||||||
scrollPane.getGutter().setBackground(Main.dark ? new Color(0x2F2F2F) : Color.LIGHT_GRAY);
|
|
||||||
contentPane.add(scrollPane);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,190 +1,195 @@
|
|||||||
package me.ByteEdit.boxes;
|
package me.ByteEdit.boxes;
|
||||||
|
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
|
|
||||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
import org.objectweb.asm.tree.FieldInsnNode;
|
import org.objectweb.asm.tree.FieldInsnNode;
|
||||||
import org.objectweb.asm.tree.LdcInsnNode;
|
import org.objectweb.asm.tree.LdcInsnNode;
|
||||||
import org.objectweb.asm.tree.MethodInsnNode;
|
import org.objectweb.asm.tree.MethodInsnNode;
|
||||||
import org.objectweb.asm.tree.MethodNode;
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
|
||||||
import me.ByteEdit.boxes.GlobalSearchOpenBox.Info;
|
import me.ByteEdit.boxes.GlobalSearchOpenBox.Info;
|
||||||
import me.ByteEdit.main.Main;
|
import me.ByteEdit.main.Main;
|
||||||
import me.ByteEdit.utils.UnicodeUtils;
|
import me.ByteEdit.utils.UnicodeUtils;
|
||||||
|
|
||||||
public class GlobalSearchBox extends JFrame {
|
public class GlobalSearchBox extends JFrame {
|
||||||
|
|
||||||
public JPanel contentPane;
|
public JPanel contentPane;
|
||||||
public JTextField txtString;
|
public JTextField txtString;
|
||||||
public JCheckBox chckbxCaseSensitive;
|
public JCheckBox chckbxCaseSensitive;
|
||||||
private JLabel lblOwner;
|
private JLabel lblOwner;
|
||||||
private JTextField txtOwner;
|
private JTextField txtOwner;
|
||||||
private JLabel lblName;
|
private JLabel lblName;
|
||||||
private JTextField txtName;
|
private JTextField txtName;
|
||||||
private JLabel lblDesc;
|
private JLabel lblDesc;
|
||||||
private JTextField txtDesc;
|
private JTextField txtDesc;
|
||||||
private GlobalSearchOpenBox openBox;
|
private GlobalSearchOpenBox openBox;
|
||||||
|
|
||||||
public GlobalSearchBox() {
|
public GlobalSearchBox() {
|
||||||
try {
|
try {
|
||||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
openBox = new GlobalSearchOpenBox();
|
openBox = new GlobalSearchOpenBox();
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
setTitle("Global Search");
|
setTitle("Global Search");
|
||||||
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
||||||
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 128),
|
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 128),
|
||||||
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 181), 256, 262);
|
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 181), 256, 262);
|
||||||
contentPane = new JPanel();
|
contentPane = new JPanel();
|
||||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
setContentPane(contentPane);
|
setContentPane(contentPane);
|
||||||
contentPane.setLayout(null);
|
contentPane.setLayout(null);
|
||||||
JLabel lblFind = new JLabel("String Search");
|
JLabel lblFind = new JLabel("String Search");
|
||||||
lblFind.setBounds(10, 25, 71, 14);
|
lblFind.setBounds(10, 25, 71, 14);
|
||||||
contentPane.add(lblFind);
|
contentPane.add(lblFind);
|
||||||
txtString = new JTextField();
|
txtString = new JTextField();
|
||||||
KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
|
KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
|
||||||
txtString.registerKeyboardAction(new ActionListener() {
|
txtString.registerKeyboardAction(new ActionListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
find();
|
find();
|
||||||
}
|
}
|
||||||
}, enter, JComponent.WHEN_IN_FOCUSED_WINDOW);
|
}, enter, JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||||
txtString.setBounds(91, 22, 149, 20);
|
txtString.setBounds(91, 22, 149, 20);
|
||||||
contentPane.add(txtString);
|
contentPane.add(txtString);
|
||||||
txtString.setColumns(10);
|
txtString.setColumns(10);
|
||||||
chckbxCaseSensitive = new JCheckBox("Case sensitive");
|
chckbxCaseSensitive = new JCheckBox("Case sensitive");
|
||||||
chckbxCaseSensitive.setBounds(10, 199, 114, 23);
|
chckbxCaseSensitive.setBounds(10, 199, 114, 23);
|
||||||
contentPane.add(chckbxCaseSensitive);
|
contentPane.add(chckbxCaseSensitive);
|
||||||
JButton btnFind = new JButton("Find");
|
JButton btnFind = new JButton("Find");
|
||||||
btnFind.addActionListener(new ActionListener() {
|
btnFind.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
find();
|
find();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
btnFind.setBounds(130, 199, 110, 23);
|
btnFind.setBounds(130, 199, 110, 23);
|
||||||
contentPane.add(btnFind);
|
contentPane.add(btnFind);
|
||||||
|
|
||||||
JLabel lblFieldmethodSearch = new JLabel("Field/Method Search");
|
JLabel lblFieldmethodSearch = new JLabel("Field/Method Search");
|
||||||
lblFieldmethodSearch.setBounds(10, 53, 230, 14);
|
lblFieldmethodSearch.setBounds(10, 53, 230, 14);
|
||||||
contentPane.add(lblFieldmethodSearch);
|
contentPane.add(lblFieldmethodSearch);
|
||||||
|
|
||||||
lblOwner = new JLabel("Owner");
|
lblOwner = new JLabel("Owner");
|
||||||
lblOwner.setBounds(10, 81, 71, 14);
|
lblOwner.setBounds(10, 81, 71, 14);
|
||||||
contentPane.add(lblOwner);
|
contentPane.add(lblOwner);
|
||||||
|
|
||||||
txtOwner = new JTextField();
|
txtOwner = new JTextField();
|
||||||
txtOwner.addActionListener(new ActionListener() {
|
txtOwner.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
find();
|
find();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
txtOwner.setColumns(10);
|
txtOwner.setColumns(10);
|
||||||
txtOwner.setBounds(91, 78, 149, 20);
|
txtOwner.setBounds(91, 78, 149, 20);
|
||||||
contentPane.add(txtOwner);
|
contentPane.add(txtOwner);
|
||||||
|
|
||||||
lblName = new JLabel("Name");
|
lblName = new JLabel("Name");
|
||||||
lblName.setBounds(10, 109, 71, 14);
|
lblName.setBounds(10, 109, 71, 14);
|
||||||
contentPane.add(lblName);
|
contentPane.add(lblName);
|
||||||
|
|
||||||
txtName = new JTextField();
|
txtName = new JTextField();
|
||||||
txtName.addActionListener(new ActionListener() {
|
txtName.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
find();
|
find();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
txtName.setColumns(10);
|
txtName.setColumns(10);
|
||||||
txtName.setBounds(91, 106, 149, 20);
|
txtName.setBounds(91, 106, 149, 20);
|
||||||
contentPane.add(txtName);
|
contentPane.add(txtName);
|
||||||
|
|
||||||
lblDesc = new JLabel("Desc");
|
lblDesc = new JLabel("Desc");
|
||||||
lblDesc.setBounds(10, 137, 71, 14);
|
lblDesc.setBounds(10, 137, 71, 14);
|
||||||
contentPane.add(lblDesc);
|
contentPane.add(lblDesc);
|
||||||
|
|
||||||
txtDesc = new JTextField();
|
txtDesc = new JTextField();
|
||||||
txtDesc.addActionListener(new ActionListener() {
|
txtDesc.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
find();
|
find();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
txtDesc.setColumns(10);
|
txtDesc.setColumns(10);
|
||||||
txtDesc.setBounds(91, 134, 149, 20);
|
txtDesc.setBounds(91, 134, 149, 20);
|
||||||
contentPane.add(txtDesc);
|
contentPane.add(txtDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void find() {
|
public void find() {
|
||||||
boolean ignoreCase = !chckbxCaseSensitive.isSelected();
|
boolean ignoreCase = !chckbxCaseSensitive.isSelected();
|
||||||
openBox.model.clear();
|
openBox.model.clear();
|
||||||
Set<Info> set = new HashSet<>();
|
Set<Info> set = new HashSet<>();
|
||||||
if (!txtString.getText().isEmpty()) {
|
if (!txtString.getText().isEmpty()) {
|
||||||
String str = txtString.getText();
|
String str = UnicodeUtils.unescape(txtString.getText());
|
||||||
if (ignoreCase) {
|
if (ignoreCase) {
|
||||||
str = str.toLowerCase();
|
str = str.toLowerCase();
|
||||||
}
|
}
|
||||||
for (ClassNode cn : Main.classNodes.values()) {
|
for (ClassNode cn : Main.classNodes.values()) {
|
||||||
for (MethodNode mn : cn.methods) {
|
for (MethodNode mn : cn.methods) {
|
||||||
for (AbstractInsnNode insn : mn.instructions.toArray()) {
|
for (AbstractInsnNode insn : mn.instructions.toArray()) {
|
||||||
if (insn instanceof LdcInsnNode && ((LdcInsnNode) insn).cst instanceof String) {
|
if (insn instanceof LdcInsnNode && ((LdcInsnNode) insn).cst instanceof String) {
|
||||||
String s = (String) ((LdcInsnNode) insn).cst;
|
String s = (String) ((LdcInsnNode) insn).cst;
|
||||||
if (ignoreCase) {
|
if (ignoreCase) {
|
||||||
s = s.toLowerCase();
|
s = s.toLowerCase();
|
||||||
}
|
}
|
||||||
if (s.contains(str)) {
|
if (s.contains(str)) {
|
||||||
set.add(new Info(cn.name, mn.name, mn.desc, mn));
|
set.add(new Info(cn.name, mn.name, mn.desc, mn));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String owner = UnicodeUtils.unescape(txtOwner.getText());
|
String owner = UnicodeUtils.unescape(txtOwner.getText());
|
||||||
String name = UnicodeUtils.unescape(txtName.getText());
|
boolean wildCardOwner = owner.isEmpty();
|
||||||
String desc = UnicodeUtils.unescape(txtDesc.getText());
|
String name = UnicodeUtils.unescape(txtName.getText());
|
||||||
for (ClassNode cn : Main.classNodes.values()) {
|
boolean wildCardName = name.isEmpty();
|
||||||
for (MethodNode mn : cn.methods) {
|
String desc = UnicodeUtils.unescape(txtDesc.getText());
|
||||||
for (AbstractInsnNode insn : mn.instructions.toArray()) {
|
boolean wildCardDesc = desc.isEmpty();
|
||||||
if (insn instanceof FieldInsnNode) {
|
for (ClassNode cn : Main.classNodes.values()) {
|
||||||
if (((FieldInsnNode) insn).owner.equals(owner) && ((FieldInsnNode) insn).name.equals(name)
|
for (MethodNode mn : cn.methods) {
|
||||||
&& ((FieldInsnNode) insn).desc.equals(desc)) {
|
for (AbstractInsnNode insn : mn.instructions.toArray()) {
|
||||||
set.add(new Info(cn.name, mn.name, mn.desc, mn));
|
if (insn instanceof FieldInsnNode) {
|
||||||
}
|
if ((wildCardOwner || ((FieldInsnNode) insn).owner.equals(owner))
|
||||||
} else if (insn instanceof MethodInsnNode) {
|
&& (wildCardName || ((FieldInsnNode) insn).name.equals(name))
|
||||||
if (((MethodInsnNode) insn).owner.equals(owner) && ((MethodInsnNode) insn).name.equals(name)
|
&& (wildCardDesc || ((FieldInsnNode) insn).desc.equals(desc))) {
|
||||||
&& ((MethodInsnNode) insn).desc.equals(desc)) {
|
set.add(new Info(cn.name, mn.name, mn.desc, mn));
|
||||||
set.add(new Info(cn.name, mn.name, mn.desc, mn));
|
}
|
||||||
}
|
} else if (insn instanceof MethodInsnNode) {
|
||||||
}
|
if ((wildCardOwner || ((MethodInsnNode) insn).owner.equals(owner))
|
||||||
}
|
&& (wildCardName || ((MethodInsnNode) insn).name.equals(name))
|
||||||
}
|
&& (wildCardDesc || ((MethodInsnNode) insn).desc.equals(desc))) {
|
||||||
}
|
set.add(new Info(cn.name, mn.name, mn.desc, mn));
|
||||||
}
|
}
|
||||||
for (Info s : set) {
|
}
|
||||||
openBox.model.addElement(s);
|
}
|
||||||
}
|
}
|
||||||
openBox.setVisible(true);
|
}
|
||||||
}
|
}
|
||||||
}
|
for (Info s : set) {
|
||||||
|
openBox.model.addElement(s);
|
||||||
|
}
|
||||||
|
openBox.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,135 +1,134 @@
|
|||||||
package me.ByteEdit.boxes;
|
package me.ByteEdit.boxes;
|
||||||
|
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
|
|
||||||
import javax.swing.DefaultListModel;
|
import javax.swing.DefaultListModel;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JList;
|
import javax.swing.JList;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.ListSelectionModel;
|
import javax.swing.ListSelectionModel;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
import javax.swing.event.ListSelectionEvent;
|
import javax.swing.event.ListSelectionEvent;
|
||||||
import javax.swing.event.ListSelectionListener;
|
import javax.swing.event.ListSelectionListener;
|
||||||
import javax.swing.text.BadLocationException;
|
import javax.swing.text.BadLocationException;
|
||||||
|
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
import org.objectweb.asm.tree.MethodNode;
|
|
||||||
|
import me.ByteEdit.main.Main;
|
||||||
import me.ByteEdit.main.Main;
|
|
||||||
|
public class GlobalSearchOpenBox extends JFrame {
|
||||||
public class GlobalSearchOpenBox extends JFrame {
|
|
||||||
|
public JPanel contentPane;
|
||||||
public JPanel contentPane;
|
DefaultListModel<Info> model;
|
||||||
DefaultListModel<Info> model;
|
|
||||||
|
public GlobalSearchOpenBox() {
|
||||||
public GlobalSearchOpenBox() {
|
try {
|
||||||
try {
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
} catch (Exception e) {
|
||||||
} catch (Exception e) {
|
e.printStackTrace();
|
||||||
e.printStackTrace();
|
}
|
||||||
}
|
setResizable(false);
|
||||||
setResizable(false);
|
setTitle("Global Search - Result");
|
||||||
setTitle("Global Search - Result");
|
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
||||||
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 200),
|
||||||
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 200),
|
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 140), 400, 280);
|
||||||
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 140), 400, 280);
|
contentPane = new JPanel();
|
||||||
contentPane = new JPanel();
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
setContentPane(contentPane);
|
||||||
setContentPane(contentPane);
|
contentPane.setLayout(null);
|
||||||
contentPane.setLayout(null);
|
|
||||||
|
model = new DefaultListModel<>();
|
||||||
model = new DefaultListModel<>();
|
JList<Info> list = new JList(model);
|
||||||
JList<Info> list = new JList(model);
|
list.addListSelectionListener(new ListSelectionListener() {
|
||||||
list.addListSelectionListener(new ListSelectionListener() {
|
|
||||||
|
public void valueChanged(ListSelectionEvent e) {
|
||||||
public void valueChanged(ListSelectionEvent e) {
|
Info val = list.getSelectedValue();
|
||||||
Info val = list.getSelectedValue();
|
if (val != null && !val.owner.equals(Main.currentNodeName)) {
|
||||||
if (val != null && !val.owner.equals(Main.currentNodeName)) {
|
int lineFound = Main.selectFileWithSearch(val.nodePath, val.mn);
|
||||||
int lineFound = Main.selectFileWithSearch(val.nodePath, val.mn);
|
if (lineFound != -1) {
|
||||||
if (lineFound != -1) {
|
try {
|
||||||
try {
|
Main.txtByteEditView.setCaretPosition(Main.txtByteEditView.getLineStartOffset(lineFound));
|
||||||
Main.txtByteEditView.setCaretPosition(Main.txtByteEditView.getLineStartOffset(lineFound));
|
} catch (BadLocationException e1) {
|
||||||
} catch (BadLocationException e1) {
|
e1.printStackTrace();
|
||||||
e1.printStackTrace();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
JScrollPane scrollPane = new JScrollPane();
|
||||||
JScrollPane scrollPane = new JScrollPane();
|
scrollPane.setBounds(10, 11, 374, 229);
|
||||||
scrollPane.setBounds(10, 11, 374, 229);
|
contentPane.add(scrollPane);
|
||||||
contentPane.add(scrollPane);
|
|
||||||
|
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
scrollPane.setViewportView(list);
|
||||||
scrollPane.setViewportView(list);
|
}
|
||||||
}
|
|
||||||
|
static class Info {
|
||||||
static class Info {
|
String owner;
|
||||||
String owner;
|
String name;
|
||||||
String name;
|
String desc;
|
||||||
String desc;
|
MethodNode mn;
|
||||||
MethodNode mn;
|
String nodePath;
|
||||||
String nodePath;
|
|
||||||
|
public Info(String owner, String name, String desc, MethodNode mn) {
|
||||||
public Info(String owner, String name, String desc, MethodNode mn) {
|
this.owner = owner;
|
||||||
this.owner = owner;
|
this.name = name;
|
||||||
this.name = name;
|
this.desc = desc;
|
||||||
this.desc = desc;
|
this.mn = mn;
|
||||||
this.mn = mn;
|
nodePath = Main.getFullName(owner);
|
||||||
nodePath = owner + ".class";
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public String toString() {
|
||||||
public String toString() {
|
return owner + "/" + name + " " + desc;
|
||||||
return owner + "/" + name + " " + desc;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public int hashCode() {
|
||||||
public int hashCode() {
|
final int prime = 31;
|
||||||
final int prime = 31;
|
int result = 1;
|
||||||
int result = 1;
|
result = prime * result + ((desc == null) ? 0 : desc.hashCode());
|
||||||
result = prime * result + ((desc == null) ? 0 : desc.hashCode());
|
result = prime * result + ((mn == null) ? 0 : mn.hashCode());
|
||||||
result = prime * result + ((mn == null) ? 0 : mn.hashCode());
|
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
result = prime * result + ((owner == null) ? 0 : owner.hashCode());
|
||||||
result = prime * result + ((owner == null) ? 0 : owner.hashCode());
|
return result;
|
||||||
return result;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public boolean equals(Object obj) {
|
||||||
public boolean equals(Object obj) {
|
if (this == obj)
|
||||||
if (this == obj)
|
return true;
|
||||||
return true;
|
if (obj == null)
|
||||||
if (obj == null)
|
return false;
|
||||||
return false;
|
if (getClass() != obj.getClass())
|
||||||
if (getClass() != obj.getClass())
|
return false;
|
||||||
return false;
|
Info other = (Info) obj;
|
||||||
Info other = (Info) obj;
|
if (desc == null) {
|
||||||
if (desc == null) {
|
if (other.desc != null)
|
||||||
if (other.desc != null)
|
return false;
|
||||||
return false;
|
} else if (!desc.equals(other.desc))
|
||||||
} else if (!desc.equals(other.desc))
|
return false;
|
||||||
return false;
|
if (mn == null) {
|
||||||
if (mn == null) {
|
if (other.mn != null)
|
||||||
if (other.mn != null)
|
return false;
|
||||||
return false;
|
} else if (!mn.equals(other.mn))
|
||||||
} else if (!mn.equals(other.mn))
|
return false;
|
||||||
return false;
|
if (name == null) {
|
||||||
if (name == null) {
|
if (other.name != null)
|
||||||
if (other.name != null)
|
return false;
|
||||||
return false;
|
} else if (!name.equals(other.name))
|
||||||
} else if (!name.equals(other.name))
|
return false;
|
||||||
return false;
|
if (owner == null) {
|
||||||
if (owner == null) {
|
if (other.owner != null)
|
||||||
if (other.owner != null)
|
return false;
|
||||||
return false;
|
} else if (!owner.equals(other.owner))
|
||||||
} else if (!owner.equals(other.owner))
|
return false;
|
||||||
return false;
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
}
|
|
||||||
@@ -1,39 +1,39 @@
|
|||||||
package me.ByteEdit.boxes;
|
package me.ByteEdit.boxes;
|
||||||
|
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
|
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
|
|
||||||
public class OptionBox extends JFrame {
|
public class OptionBox extends JFrame {
|
||||||
|
|
||||||
private JPanel contentPane;
|
private JPanel contentPane;
|
||||||
public JCheckBox chckbxComputeFrames;
|
public JCheckBox chckbxComputeFrames;
|
||||||
public JCheckBox chckbxComputeMax;
|
public JCheckBox chckbxComputeMax;
|
||||||
|
|
||||||
public OptionBox() {
|
public OptionBox() {
|
||||||
try {
|
try {
|
||||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
setTitle("Options");
|
setTitle("Options");
|
||||||
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
||||||
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 150),
|
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 150),
|
||||||
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 100), 300, 200);
|
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 100), 300, 200);
|
||||||
contentPane = new JPanel();
|
contentPane = new JPanel();
|
||||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
setContentPane(contentPane);
|
setContentPane(contentPane);
|
||||||
contentPane.setLayout(null);
|
contentPane.setLayout(null);
|
||||||
chckbxComputeFrames = new JCheckBox("Compute Frames");
|
chckbxComputeFrames = new JCheckBox("Compute Frames");
|
||||||
chckbxComputeFrames.setBounds(6, 7, 138, 23);
|
chckbxComputeFrames.setBounds(6, 7, 138, 23);
|
||||||
contentPane.add(chckbxComputeFrames);
|
contentPane.add(chckbxComputeFrames);
|
||||||
chckbxComputeMax = new JCheckBox("Compute Max");
|
chckbxComputeMax = new JCheckBox("Compute Max");
|
||||||
chckbxComputeMax.setBounds(6, 33, 138, 23);
|
chckbxComputeMax.setBounds(6, 33, 138, 23);
|
||||||
contentPane.add(chckbxComputeMax);
|
contentPane.add(chckbxComputeMax);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,238 +1,239 @@
|
|||||||
package me.ByteEdit.boxes;
|
package me.ByteEdit.boxes;
|
||||||
|
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
|
|
||||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
import org.objectweb.asm.tree.FieldInsnNode;
|
import org.objectweb.asm.tree.FieldInsnNode;
|
||||||
import org.objectweb.asm.tree.FieldNode;
|
import org.objectweb.asm.tree.FieldNode;
|
||||||
import org.objectweb.asm.tree.MethodInsnNode;
|
import org.objectweb.asm.tree.MethodInsnNode;
|
||||||
import org.objectweb.asm.tree.MethodNode;
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
|
||||||
import me.ByteEdit.edit.Disassembler;
|
import me.ByteEdit.edit.Disassembler;
|
||||||
import me.ByteEdit.main.Main;
|
import me.ByteEdit.main.Main;
|
||||||
import me.ByteEdit.utils.ClassUtil;
|
import me.ByteEdit.utils.ClassUtil;
|
||||||
import me.ByteEdit.utils.UnicodeUtils;
|
import me.ByteEdit.utils.UnicodeUtils;
|
||||||
|
|
||||||
public class RenameBox extends JFrame {
|
public class RenameBox extends JFrame {
|
||||||
|
|
||||||
private JPanel contentPane;
|
private JPanel contentPane;
|
||||||
public JTextField txtName;
|
public JTextField txtName;
|
||||||
public JTextField txtDesc;
|
public JTextField txtDesc;
|
||||||
|
|
||||||
public String className;
|
public String className;
|
||||||
public String name;
|
public String name;
|
||||||
public String desc;
|
public String desc;
|
||||||
|
|
||||||
public RenameBox() {
|
public RenameBox() {
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
setTitle("Rename");
|
setTitle("Rename");
|
||||||
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
||||||
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 225),
|
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 225),
|
||||||
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 150), 450, 300);
|
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 150), 450, 300);
|
||||||
contentPane = new JPanel();
|
contentPane = new JPanel();
|
||||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
setContentPane(contentPane);
|
setContentPane(contentPane);
|
||||||
contentPane.setLayout(null);
|
contentPane.setLayout(null);
|
||||||
|
|
||||||
JLabel lblName = new JLabel("Name");
|
JLabel lblName = new JLabel("Name");
|
||||||
lblName.setBounds(10, 11, 33, 14);
|
lblName.setBounds(10, 11, 33, 14);
|
||||||
contentPane.add(lblName);
|
contentPane.add(lblName);
|
||||||
|
|
||||||
JLabel lblDesc = new JLabel("Desc");
|
JLabel lblDesc = new JLabel("Desc");
|
||||||
lblDesc.setBounds(10, 36, 33, 14);
|
lblDesc.setBounds(10, 36, 33, 14);
|
||||||
contentPane.add(lblDesc);
|
contentPane.add(lblDesc);
|
||||||
|
|
||||||
txtName = new JTextField();
|
txtName = new JTextField();
|
||||||
txtName.setBounds(53, 8, 381, 20);
|
txtName.setBounds(53, 8, 381, 20);
|
||||||
contentPane.add(txtName);
|
contentPane.add(txtName);
|
||||||
txtName.setColumns(10);
|
txtName.setColumns(10);
|
||||||
|
|
||||||
txtDesc = new JTextField();
|
txtDesc = new JTextField();
|
||||||
txtDesc.setColumns(10);
|
txtDesc.setColumns(10);
|
||||||
txtDesc.setBounds(53, 36, 381, 20);
|
txtDesc.setBounds(53, 36, 381, 20);
|
||||||
contentPane.add(txtDesc);
|
contentPane.add(txtDesc);
|
||||||
|
|
||||||
JButton btnRename = new JButton("Rename");
|
JButton btnRename = new JButton("Rename");
|
||||||
btnRename.addActionListener(new ActionListener() {
|
btnRename.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if (className == null) {
|
if (className == null) {
|
||||||
JOptionPane.showMessageDialog(null, "ClassName not set!", "Error!", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(null, "ClassName not set!", "Error!", JOptionPane.ERROR_MESSAGE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
JOptionPane.showMessageDialog(null, "Name not set!", "Error!", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(null, "Name not set!", "Error!", JOptionPane.ERROR_MESSAGE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (desc == null) {
|
if (desc == null) {
|
||||||
JOptionPane.showMessageDialog(null, "Desc not set!", "Error!", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(null, "Desc not set!", "Error!", JOptionPane.ERROR_MESSAGE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ClassNode clazz = Main.classNodes.get(className + ".class");
|
ClassNode clazz = Main.classNodes.get(Main.getFullName(className));
|
||||||
if (clazz == null) {
|
if (clazz == null) {
|
||||||
JOptionPane.showMessageDialog(null, "ClassNode not found!", "Error!", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(null, "ClassNode not found!", "Error!", JOptionPane.ERROR_MESSAGE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String newName = UnicodeUtils.unescape(txtName.getText());
|
String newName = UnicodeUtils.unescape(txtName.getText());
|
||||||
String newDesc = UnicodeUtils.unescape(txtDesc.getText());
|
String newDesc = UnicodeUtils.unescape(txtDesc.getText());
|
||||||
if (ClassUtil.isObjectClassMethod(newName, newDesc, true)) {
|
if (ClassUtil.isObjectClassMethod(newName, newDesc, true)) {
|
||||||
JOptionPane.showMessageDialog(null, "Invalid name!", "Error!", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(null, "Invalid name!", "Error!", JOptionPane.ERROR_MESSAGE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (desc.startsWith("(")) {
|
if (desc.startsWith("(")) {
|
||||||
if (newDesc.startsWith("(")) { // method
|
if (newDesc.startsWith("(")) { // method
|
||||||
ClassNode lastHit = clazz;
|
ClassNode lastHit = clazz;
|
||||||
while (clazz != null && clazz.superName != null) {
|
while (clazz != null && clazz.superName != null) {
|
||||||
ClassNode tmp = Main.classNodes.get(clazz.superName + ".class");
|
ClassNode tmp = Main.classNodes.get(Main.getFullName(clazz.superName));
|
||||||
if (tmp != null) {
|
if (tmp != null) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (MethodNode mn : clazz.methods) {
|
for (MethodNode mn : clazz.methods) {
|
||||||
if (mn.name.equals(name) && mn.desc.equals(desc)) {
|
if (mn.name.equals(name) && mn.desc.equals(desc)) {
|
||||||
lastHit = clazz;
|
lastHit = clazz;
|
||||||
clazz = tmp;
|
clazz = tmp;
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
clazz = tmp;
|
clazz = tmp;
|
||||||
lastHit = null;
|
lastHit = null;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lastHit != null) {
|
if (lastHit != null) {
|
||||||
clazz = lastHit;
|
clazz = lastHit;
|
||||||
}
|
}
|
||||||
LinkedList<MethodNode> methodsToRename = new LinkedList<>();
|
LinkedList<MethodNode> methodsToRename = new LinkedList<>();
|
||||||
LinkedList<MethodInsnNode> minsToRename = new LinkedList<>();
|
LinkedList<MethodInsnNode> minsToRename = new LinkedList<>();
|
||||||
for (ClassNode cn : Main.classNodes.values()) {
|
for (ClassNode cn : Main.classNodes.values()) {
|
||||||
boolean extendsMyClass = cn == clazz;
|
boolean extendsMyClass = cn == clazz;
|
||||||
if (!extendsMyClass) {
|
if (!extendsMyClass) {
|
||||||
ClassNode checkCN = cn;
|
ClassNode checkCN = cn;
|
||||||
while (checkCN != null && checkCN.superName != null) {
|
while (checkCN != null && checkCN.superName != null) {
|
||||||
if (clazz.name.equals(checkCN.superName)) {
|
if (clazz.name.equals(checkCN.superName)) {
|
||||||
extendsMyClass = true;
|
extendsMyClass = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ClassNode tmp = Main.classNodes.get(checkCN.superName + ".class");
|
ClassNode tmp = Main.classNodes.get(Main.getFullName(checkCN.superName));
|
||||||
if (tmp != null) {
|
if (tmp != null) {
|
||||||
checkCN = tmp;
|
checkCN = tmp;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (MethodNode mn : cn.methods) {
|
for (MethodNode mn : cn.methods) {
|
||||||
if (extendsMyClass) {
|
if (extendsMyClass) {
|
||||||
if (mn.name.equals(newName) && mn.desc.equals(newDesc)) {
|
if (mn.name.equals(newName) && mn.desc.equals(newDesc)) {
|
||||||
JOptionPane.showMessageDialog(null, "Method already exists in " + cn.name + "!",
|
JOptionPane.showMessageDialog(null, "Method already exists in " + cn.name + "!",
|
||||||
"Error!", JOptionPane.ERROR_MESSAGE);
|
"Error!", JOptionPane.ERROR_MESSAGE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mn.name.equals(name) && mn.desc.equals(desc)) {
|
if (mn.name.equals(name) && mn.desc.equals(desc)) {
|
||||||
methodsToRename.add(mn);
|
methodsToRename.add(mn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (AbstractInsnNode ain : mn.instructions.toArray()) {
|
for (AbstractInsnNode ain : mn.instructions.toArray()) {
|
||||||
if (ain instanceof MethodInsnNode) {
|
if (ain instanceof MethodInsnNode) {
|
||||||
MethodInsnNode min = (MethodInsnNode) ain;
|
MethodInsnNode min = (MethodInsnNode) ain;
|
||||||
if (min.name.equals(name) && min.desc.equals(desc)
|
if (min.name.equals(name) && min.desc.equals(desc)
|
||||||
&& min.owner.equals(clazz.name)) {
|
&& min.owner.equals(clazz.name)) {
|
||||||
minsToRename.add(min);
|
minsToRename.add(min);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (MethodNode mn : methodsToRename) {
|
for (MethodNode mn : methodsToRename) {
|
||||||
mn.name = newName;
|
mn.name = newName;
|
||||||
mn.desc = newDesc;
|
mn.desc = newDesc;
|
||||||
}
|
}
|
||||||
for (MethodInsnNode min : minsToRename) {
|
for (MethodInsnNode min : minsToRename) {
|
||||||
min.name = newName;
|
min.name = newName;
|
||||||
min.desc = newDesc;
|
min.desc = newDesc;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
JOptionPane.showMessageDialog(null, "New Desc is not a method desc!", "Error!",
|
JOptionPane.showMessageDialog(null, "New Desc is not a method desc!", "Error!",
|
||||||
JOptionPane.ERROR_MESSAGE);
|
JOptionPane.ERROR_MESSAGE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!newDesc.startsWith("(")) { // field
|
if (!newDesc.startsWith("(")) { // field
|
||||||
FieldNode currentFN = null;
|
FieldNode currentFN = null;
|
||||||
for (FieldNode fn : clazz.fields) {
|
for (FieldNode fn : clazz.fields) {
|
||||||
if (fn.name.equals(newName) && fn.desc.equals(newDesc)) {
|
if (fn.name.equals(newName) && fn.desc.equals(newDesc)) {
|
||||||
JOptionPane.showMessageDialog(null, "Field already exists!", "Error!",
|
JOptionPane.showMessageDialog(null, "Field already exists!", "Error!",
|
||||||
JOptionPane.ERROR_MESSAGE);
|
JOptionPane.ERROR_MESSAGE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (fn.name.equals(name) && fn.desc.equals(desc)) {
|
if (fn.name.equals(name) && fn.desc.equals(desc)) {
|
||||||
currentFN = fn;
|
currentFN = fn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (currentFN == null) {
|
if (currentFN == null) {
|
||||||
JOptionPane.showMessageDialog(null, "Field not found?!", "Error!",
|
JOptionPane.showMessageDialog(null, "Field not found?!", "Error!",
|
||||||
JOptionPane.ERROR_MESSAGE);
|
JOptionPane.ERROR_MESSAGE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
currentFN.name = newName;
|
currentFN.name = newName;
|
||||||
currentFN.desc = newDesc;
|
currentFN.desc = newDesc;
|
||||||
for (ClassNode cn : Main.classNodes.values()) {
|
for (ClassNode cn : Main.classNodes.values()) {
|
||||||
for (MethodNode mn : cn.methods) {
|
for (MethodNode mn : cn.methods) {
|
||||||
for (AbstractInsnNode ain : mn.instructions.toArray()) {
|
for (AbstractInsnNode ain : mn.instructions.toArray()) {
|
||||||
if (ain instanceof FieldInsnNode) {
|
if (ain instanceof FieldInsnNode) {
|
||||||
FieldInsnNode fin = (FieldInsnNode) ain;
|
FieldInsnNode fin = (FieldInsnNode) ain;
|
||||||
if (fin.name.equals(name) && fin.desc.equals(desc)
|
if (fin.name.equals(name) && fin.desc.equals(desc)
|
||||||
&& fin.owner.equals(className)) {
|
&& fin.owner.equals(className)) {
|
||||||
fin.name = newName;
|
fin.name = newName;
|
||||||
fin.desc = newDesc;
|
fin.desc = newDesc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
JOptionPane.showMessageDialog(null, "New Desc is not a field desc!", "Error!",
|
JOptionPane.showMessageDialog(null, "New Desc is not a field desc!", "Error!",
|
||||||
JOptionPane.ERROR_MESSAGE);
|
JOptionPane.ERROR_MESSAGE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try { // refresh
|
try { // refresh
|
||||||
ClassNode classNode = Main.classNodes.get(Main.currentNodeName);
|
ClassNode classNode = Main.classNodes.get(Main.currentNodeName);
|
||||||
int prev = Main.txtByteEditView.getCaretPosition();
|
int prev = Main.txtByteEditView.getCaretPosition();
|
||||||
String dis = Disassembler.disassemble(classNode);
|
String dis = Disassembler.disassemble(classNode);
|
||||||
String substr = Main.currentNodeName.substring(0, Main.currentNodeName.length() - 6);
|
String substr = Main.currentNodeName.substring(0, Main.currentNodeName.length() - 6);
|
||||||
for (String key : Main.classNodes.keySet()) {
|
for (String key : Main.classNodes.keySet()) {
|
||||||
if (key.contains("$")) {
|
if (key.contains("$")) {
|
||||||
String[] split = key.split("\\$");
|
String[] split = key.split("\\$");
|
||||||
if (split[0].equals(substr)) {
|
if (split[0].equals(substr)) {
|
||||||
dis += "\n" + Disassembler.disassemble(Main.classNodes.get(key));
|
dis += "\n" + Disassembler.disassemble(Main.classNodes.get(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Main.txtByteEditView.setText(dis);
|
Main.txtByteEditView.setText(dis);
|
||||||
Main.txtByteEditView.setCaretPosition(prev);
|
Main.txtByteEditView.setCaretPosition(prev);
|
||||||
} catch (Exception e2) {
|
} catch (Exception e2) {
|
||||||
e2.printStackTrace();
|
e2.printStackTrace();
|
||||||
}
|
}
|
||||||
name = newName;
|
name = newName;
|
||||||
desc = newDesc;
|
desc = newDesc;
|
||||||
}
|
RenameBox.this.setVisible(false);
|
||||||
});
|
}
|
||||||
btnRename.setBounds(345, 237, 89, 23);
|
});
|
||||||
contentPane.add(btnRename);
|
btnRename.setBounds(345, 237, 89, 23);
|
||||||
}
|
contentPane.add(btnRename);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@@ -1,152 +1,152 @@
|
|||||||
package me.ByteEdit.boxes;
|
package me.ByteEdit.boxes;
|
||||||
|
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
|
|
||||||
import me.ByteEdit.main.Main;
|
import me.ByteEdit.main.Main;
|
||||||
|
|
||||||
public class SearchBox extends JFrame {
|
public class SearchBox extends JFrame {
|
||||||
|
|
||||||
public JPanel contentPane;
|
public JPanel contentPane;
|
||||||
public JTextField txtFind;
|
public JTextField txtFind;
|
||||||
public JTextField txtReplace;
|
public JTextField txtReplace;
|
||||||
public JCheckBox chckbxCaseSensitive;
|
public JCheckBox chckbxCaseSensitive;
|
||||||
|
|
||||||
public SearchBox() {
|
public SearchBox() {
|
||||||
try {
|
try {
|
||||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
setTitle("Find/Replace");
|
setTitle("Find/Replace");
|
||||||
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
||||||
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 128),
|
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 128),
|
||||||
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 181), 256, 262);
|
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 181), 256, 262);
|
||||||
contentPane = new JPanel();
|
contentPane = new JPanel();
|
||||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
setContentPane(contentPane);
|
setContentPane(contentPane);
|
||||||
contentPane.setLayout(null);
|
contentPane.setLayout(null);
|
||||||
JLabel lblFind = new JLabel("Find:");
|
JLabel lblFind = new JLabel("Find:");
|
||||||
lblFind.setBounds(10, 25, 71, 14);
|
lblFind.setBounds(10, 25, 71, 14);
|
||||||
contentPane.add(lblFind);
|
contentPane.add(lblFind);
|
||||||
txtFind = new JTextField();
|
txtFind = new JTextField();
|
||||||
KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
|
KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
|
||||||
txtFind.registerKeyboardAction(new ActionListener() {
|
txtFind.registerKeyboardAction(new ActionListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
find();
|
find();
|
||||||
}
|
}
|
||||||
}, enter, JComponent.WHEN_IN_FOCUSED_WINDOW);
|
}, enter, JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||||
txtFind.setBounds(91, 22, 149, 20);
|
txtFind.setBounds(91, 22, 149, 20);
|
||||||
contentPane.add(txtFind);
|
contentPane.add(txtFind);
|
||||||
txtFind.setColumns(10);
|
txtFind.setColumns(10);
|
||||||
JLabel lblReplaceWith = new JLabel("Replace with:");
|
JLabel lblReplaceWith = new JLabel("Replace with:");
|
||||||
lblReplaceWith.setBounds(10, 53, 71, 14);
|
lblReplaceWith.setBounds(10, 53, 71, 14);
|
||||||
contentPane.add(lblReplaceWith);
|
contentPane.add(lblReplaceWith);
|
||||||
txtReplace = new JTextField();
|
txtReplace = new JTextField();
|
||||||
txtReplace.setColumns(10);
|
txtReplace.setColumns(10);
|
||||||
txtReplace.setBounds(91, 50, 149, 20);
|
txtReplace.setBounds(91, 50, 149, 20);
|
||||||
contentPane.add(txtReplace);
|
contentPane.add(txtReplace);
|
||||||
chckbxCaseSensitive = new JCheckBox("Case sensitive");
|
chckbxCaseSensitive = new JCheckBox("Case sensitive");
|
||||||
chckbxCaseSensitive.setBounds(10, 103, 230, 23);
|
chckbxCaseSensitive.setBounds(10, 103, 230, 23);
|
||||||
contentPane.add(chckbxCaseSensitive);
|
contentPane.add(chckbxCaseSensitive);
|
||||||
JButton btnFind = new JButton("Find");
|
JButton btnFind = new JButton("Find");
|
||||||
btnFind.addActionListener(new ActionListener() {
|
btnFind.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
find();
|
find();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
btnFind.setBounds(10, 150, 110, 23);
|
btnFind.setBounds(10, 150, 110, 23);
|
||||||
contentPane.add(btnFind);
|
contentPane.add(btnFind);
|
||||||
JButton btnReplacefind = new JButton("Replace/Find");
|
JButton btnReplacefind = new JButton("Replace/Find");
|
||||||
btnReplacefind.addActionListener(new ActionListener() {
|
btnReplacefind.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
replaceFind();
|
replaceFind();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
btnReplacefind.setBounds(130, 150, 110, 23);
|
btnReplacefind.setBounds(130, 150, 110, 23);
|
||||||
contentPane.add(btnReplacefind);
|
contentPane.add(btnReplacefind);
|
||||||
JButton btnReplace = new JButton("Replace");
|
JButton btnReplace = new JButton("Replace");
|
||||||
btnReplace.addActionListener(new ActionListener() {
|
btnReplace.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
replace();
|
replace();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
btnReplace.setBounds(10, 184, 110, 23);
|
btnReplace.setBounds(10, 184, 110, 23);
|
||||||
contentPane.add(btnReplace);
|
contentPane.add(btnReplace);
|
||||||
JButton btnReplaceAll = new JButton("Replace All");
|
JButton btnReplaceAll = new JButton("Replace All");
|
||||||
btnReplaceAll.addActionListener(new ActionListener() {
|
btnReplaceAll.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
replaceAll();
|
replaceAll();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
btnReplaceAll.setBounds(130, 184, 110, 23);
|
btnReplaceAll.setBounds(130, 184, 110, 23);
|
||||||
contentPane.add(btnReplaceAll);
|
contentPane.add(btnReplaceAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void find() {
|
public void find() {
|
||||||
int startPos = Main.txtByteEditView.getCaretPosition();
|
int startPos = Main.txtByteEditView.getCaretPosition();
|
||||||
String toFind = txtFind.getText();
|
String toFind = txtFind.getText();
|
||||||
String txt = chckbxCaseSensitive.isSelected() ? Main.txtByteEditView.getText().substring(startPos)
|
String txt = chckbxCaseSensitive.isSelected() ? Main.txtByteEditView.getText().substring(startPos)
|
||||||
: Main.txtByteEditView.getText().substring(startPos).toLowerCase();
|
: Main.txtByteEditView.getText().substring(startPos).toLowerCase();
|
||||||
int index = txt.indexOf(chckbxCaseSensitive.isSelected() ? toFind : toFind.toLowerCase());
|
int index = txt.indexOf(chckbxCaseSensitive.isSelected() ? toFind : toFind.toLowerCase());
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
txt = chckbxCaseSensitive.isSelected() ? Main.txtByteEditView.getText()
|
txt = chckbxCaseSensitive.isSelected() ? Main.txtByteEditView.getText()
|
||||||
: Main.txtByteEditView.getText().toLowerCase();
|
: Main.txtByteEditView.getText().toLowerCase();
|
||||||
index = txt.indexOf(chckbxCaseSensitive.isSelected() ? toFind : toFind.toLowerCase());
|
index = txt.indexOf(chckbxCaseSensitive.isSelected() ? toFind : toFind.toLowerCase());
|
||||||
startPos = 0;
|
startPos = 0;
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Main.txtByteEditView.select(startPos + index, startPos + index + toFind.length());
|
Main.txtByteEditView.select(startPos + index, startPos + index + toFind.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void replaceFind() {
|
public void replaceFind() {
|
||||||
replace();
|
replace();
|
||||||
find();
|
find();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void replace() {
|
public void replace() {
|
||||||
String txt = Main.txtByteEditView.getText();
|
String txt = Main.txtByteEditView.getText();
|
||||||
int startPos = Main.txtByteEditView.getSelectionStart();
|
int startPos = Main.txtByteEditView.getSelectionStart();
|
||||||
Main.txtByteEditView.replaceSelection(txtReplace.getText());
|
Main.txtByteEditView.replaceSelection(txtReplace.getText());
|
||||||
Main.txtByteEditView.select(startPos, startPos + txtReplace.getText().length());
|
Main.txtByteEditView.select(startPos, startPos + txtReplace.getText().length());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void replaceAll() {
|
public void replaceAll() {
|
||||||
String toFind = txtFind.getText();
|
String toFind = txtFind.getText();
|
||||||
String toReplace = txtReplace.getText();
|
String toReplace = txtReplace.getText();
|
||||||
String txt = Main.txtByteEditView.getText();
|
String txt = Main.txtByteEditView.getText();
|
||||||
int prev = Main.txtByteEditView.getCaretPosition();
|
int prev = Main.txtByteEditView.getCaretPosition();
|
||||||
if (chckbxCaseSensitive.isSelected()) {
|
if (chckbxCaseSensitive.isSelected()) {
|
||||||
Main.txtByteEditView.replaceRange(txt.replace(toFind, toReplace), 0, txt.length());
|
Main.txtByteEditView.replaceRange(txt.replace(toFind, toReplace), 0, txt.length());
|
||||||
} else {
|
} else {
|
||||||
Main.txtByteEditView.replaceRange(
|
Main.txtByteEditView.replaceRange(
|
||||||
txt.replaceAll("(?i)" + Pattern.quote(toFind), Matcher.quoteReplacement(toReplace)), 0,
|
txt.replaceAll("(?i)" + Pattern.quote(toFind), Matcher.quoteReplacement(toReplace)), 0,
|
||||||
txt.length());
|
txt.length());
|
||||||
}
|
}
|
||||||
Main.txtByteEditView.setCaretPosition(prev);
|
Main.txtByteEditView.setCaretPosition(prev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,116 +1,117 @@
|
|||||||
package me.ByteEdit.boxes;
|
package me.ByteEdit.boxes;
|
||||||
|
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
import javax.swing.DefaultListModel;
|
import javax.swing.DefaultListModel;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JList;
|
import javax.swing.JList;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.ListSelectionModel;
|
import javax.swing.ListSelectionModel;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
import javax.swing.event.DocumentEvent;
|
import javax.swing.event.DocumentEvent;
|
||||||
import javax.swing.event.DocumentListener;
|
import javax.swing.event.DocumentListener;
|
||||||
import javax.swing.event.ListSelectionEvent;
|
import javax.swing.event.ListSelectionEvent;
|
||||||
import javax.swing.event.ListSelectionListener;
|
import javax.swing.event.ListSelectionListener;
|
||||||
|
|
||||||
import me.ByteEdit.main.Main;
|
import me.ByteEdit.main.Main;
|
||||||
|
import me.ByteEdit.utils.UnicodeUtils;
|
||||||
public class TypeOpenBox extends JFrame {
|
|
||||||
|
public class TypeOpenBox extends JFrame {
|
||||||
public JPanel contentPane;
|
|
||||||
public JTextField txtSearch;
|
public JPanel contentPane;
|
||||||
|
public JTextField txtSearch;
|
||||||
public TypeOpenBox() {
|
|
||||||
try {
|
public TypeOpenBox() {
|
||||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
try {
|
||||||
} catch (Exception e) {
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||||
e.printStackTrace();
|
} catch (Exception e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
setResizable(false);
|
}
|
||||||
setTitle("Open Type");
|
setResizable(false);
|
||||||
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
setTitle("Open Type");
|
||||||
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 200),
|
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
||||||
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 140), 400, 280);
|
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 200),
|
||||||
contentPane = new JPanel();
|
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 140), 400, 280);
|
||||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
contentPane = new JPanel();
|
||||||
setContentPane(contentPane);
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
contentPane.setLayout(null);
|
setContentPane(contentPane);
|
||||||
|
contentPane.setLayout(null);
|
||||||
DefaultListModel<String> model = new DefaultListModel<>();
|
|
||||||
JList<String> list = new JList(model);
|
DefaultListModel<String> model = new DefaultListModel<>();
|
||||||
list.addListSelectionListener(new ListSelectionListener() {
|
JList<String> list = new JList(model);
|
||||||
|
list.addListSelectionListener(new ListSelectionListener() {
|
||||||
public void valueChanged(ListSelectionEvent e) {
|
|
||||||
String val = list.getSelectedValue();
|
public void valueChanged(ListSelectionEvent e) {
|
||||||
if (val != null && !val.equals(Main.currentNodeName)) {
|
String val = list.getSelectedValue();
|
||||||
Main.selectFile(val);
|
if (val != null && !val.equals(Main.currentNodeName)) {
|
||||||
}
|
Main.selectFile(val);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
txtSearch = new JTextField();
|
|
||||||
txtSearch.addActionListener(new ActionListener() {
|
txtSearch = new JTextField();
|
||||||
|
txtSearch.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
if (model.size() == 1) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
list.setSelectedIndex(0);
|
if (model.size() == 1) {
|
||||||
}
|
list.setSelectedIndex(0);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
txtSearch.getDocument().addDocumentListener(new DocumentListener() {
|
});
|
||||||
|
txtSearch.getDocument().addDocumentListener(new DocumentListener() {
|
||||||
public void changedUpdate(DocumentEvent e) {
|
|
||||||
updateList();
|
public void changedUpdate(DocumentEvent e) {
|
||||||
}
|
updateList();
|
||||||
|
}
|
||||||
public void removeUpdate(DocumentEvent e) {
|
|
||||||
updateList();
|
public void removeUpdate(DocumentEvent e) {
|
||||||
}
|
updateList();
|
||||||
|
}
|
||||||
public void insertUpdate(DocumentEvent e) {
|
|
||||||
updateList();
|
public void insertUpdate(DocumentEvent e) {
|
||||||
}
|
updateList();
|
||||||
|
}
|
||||||
public void updateList() {
|
|
||||||
model.clear();
|
public void updateList() {
|
||||||
if (txtSearch.getText().isEmpty()) {
|
model.clear();
|
||||||
return;
|
if (txtSearch.getText().isEmpty()) {
|
||||||
}
|
return;
|
||||||
String search = txtSearch.getText().toLowerCase();
|
}
|
||||||
if (search.contains("/")) {
|
String search = UnicodeUtils.unescape(txtSearch.getText()).toLowerCase();
|
||||||
for (String s : Main.classNodes.keySet()) {
|
if (search.contains("/")) {
|
||||||
String className = s.substring(0, s.length() - 6);
|
for (String s : Main.classNodes.keySet()) {
|
||||||
if (!className.contains("$") && className.toLowerCase().startsWith(search)) {
|
String className = s.substring(0, s.length() - 6);
|
||||||
model.addElement(s);
|
if (!className.contains("$") && className.toLowerCase().startsWith(search)) {
|
||||||
}
|
model.addElement(s);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
for (String s : Main.classNodes.keySet()) {
|
} else {
|
||||||
String[] split = s.split("/");
|
for (String s : Main.classNodes.keySet()) {
|
||||||
String className = split[split.length - 1];
|
String[] split = s.split("/");
|
||||||
className = className.substring(0, className.length() - 6);
|
String className = split[split.length - 1];
|
||||||
if (!className.contains("$") && className.toLowerCase().startsWith(search)) {
|
className = className.substring(0, className.length() - 6);
|
||||||
model.addElement(s);
|
if (!className.contains("$") && className.toLowerCase().startsWith(search)) {
|
||||||
}
|
model.addElement(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
txtSearch.setBounds(10, 11, 374, 20);
|
});
|
||||||
contentPane.add(txtSearch);
|
txtSearch.setBounds(10, 11, 374, 20);
|
||||||
txtSearch.setColumns(10);
|
contentPane.add(txtSearch);
|
||||||
|
txtSearch.setColumns(10);
|
||||||
JScrollPane scrollPane = new JScrollPane();
|
|
||||||
scrollPane.setBounds(10, 46, 374, 194);
|
JScrollPane scrollPane = new JScrollPane();
|
||||||
contentPane.add(scrollPane);
|
scrollPane.setBounds(10, 46, 374, 194);
|
||||||
|
contentPane.add(scrollPane);
|
||||||
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
|
||||||
scrollPane.setViewportView(list);
|
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
}
|
scrollPane.setViewportView(list);
|
||||||
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
@@ -1,74 +1,74 @@
|
|||||||
package me.ByteEdit.boxes;
|
package me.ByteEdit.boxes;
|
||||||
|
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTextArea;
|
import javax.swing.JTextArea;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
|
|
||||||
import me.ByteEdit.main.Main;
|
import me.ByteEdit.main.Main;
|
||||||
import me.ByteEdit.utils.UnicodeUtils;
|
import me.ByteEdit.utils.UnicodeUtils;
|
||||||
|
|
||||||
public class UnicodeBox extends JFrame {
|
public class UnicodeBox extends JFrame {
|
||||||
|
|
||||||
private JPanel contentPane;
|
private JPanel contentPane;
|
||||||
|
|
||||||
public UnicodeBox() {
|
public UnicodeBox() {
|
||||||
try {
|
try {
|
||||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
setTitle("Unicode Converter");
|
setTitle("Unicode Converter");
|
||||||
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
||||||
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 150),
|
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 150),
|
||||||
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 100), 300, 200);
|
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 100), 300, 200);
|
||||||
contentPane = new JPanel();
|
contentPane = new JPanel();
|
||||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
setContentPane(contentPane);
|
setContentPane(contentPane);
|
||||||
contentPane.setLayout(null);
|
contentPane.setLayout(null);
|
||||||
|
|
||||||
JTextArea textArea = new JTextArea();
|
JTextArea textArea = new JTextArea();
|
||||||
|
|
||||||
JButton btnEscape = new JButton("Escape");
|
JButton btnEscape = new JButton("Escape");
|
||||||
btnEscape.addActionListener(new ActionListener() {
|
btnEscape.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
try {
|
try {
|
||||||
textArea.setText(UnicodeUtils.escape(textArea.getText()));
|
textArea.setText(UnicodeUtils.escape(textArea.getText()));
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ex) {
|
||||||
Main.showError(ex.getMessage());
|
Main.showError(ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
btnEscape.setBounds(10, 137, 89, 23);
|
btnEscape.setBounds(10, 137, 89, 23);
|
||||||
contentPane.add(btnEscape);
|
contentPane.add(btnEscape);
|
||||||
|
|
||||||
JButton btnUnescape = new JButton("Unescape");
|
JButton btnUnescape = new JButton("Unescape");
|
||||||
btnUnescape.addActionListener(new ActionListener() {
|
btnUnescape.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
try {
|
try {
|
||||||
textArea.setText(UnicodeUtils.unescape(textArea.getText()));
|
textArea.setText(UnicodeUtils.unescape(textArea.getText()));
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ex) {
|
||||||
Main.showError(ex.getMessage());
|
Main.showError(ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
btnUnescape.setBounds(195, 137, 89, 23);
|
btnUnescape.setBounds(195, 137, 89, 23);
|
||||||
contentPane.add(btnUnescape);
|
contentPane.add(btnUnescape);
|
||||||
|
|
||||||
JScrollPane scrollPane = new JScrollPane();
|
JScrollPane scrollPane = new JScrollPane();
|
||||||
scrollPane.setBounds(10, 11, 274, 115);
|
scrollPane.setBounds(10, 11, 274, 115);
|
||||||
contentPane.add(scrollPane);
|
contentPane.add(scrollPane);
|
||||||
|
|
||||||
scrollPane.setViewportView(textArea);
|
scrollPane.setViewportView(textArea);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1610
-1577
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,60 +1,60 @@
|
|||||||
package me.ByteEdit.edit;
|
package me.ByteEdit.edit;
|
||||||
|
|
||||||
import java.awt.EventQueue;
|
import java.awt.EventQueue;
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
|
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
|
|
||||||
public class OptionBox extends JFrame {
|
public class OptionBox extends JFrame {
|
||||||
|
|
||||||
private JPanel contentPane;
|
private JPanel contentPane;
|
||||||
public JCheckBox chckbxComputeFrames;
|
public JCheckBox chckbxComputeFrames;
|
||||||
public JCheckBox chckbxComputeMax;
|
public JCheckBox chckbxComputeMax;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launch the application.
|
* Launch the application.
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
EventQueue.invokeLater(new Runnable() {
|
EventQueue.invokeLater(new Runnable() {
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
OptionBox frame = new OptionBox();
|
OptionBox frame = new OptionBox();
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the frame.
|
* Create the frame.
|
||||||
*/
|
*/
|
||||||
public OptionBox() {
|
public OptionBox() {
|
||||||
try {
|
try {
|
||||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
setTitle("Options");
|
setTitle("Options");
|
||||||
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
||||||
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 150),
|
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 150),
|
||||||
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 100), 300, 200);
|
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 100), 300, 200);
|
||||||
contentPane = new JPanel();
|
contentPane = new JPanel();
|
||||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
setContentPane(contentPane);
|
setContentPane(contentPane);
|
||||||
contentPane.setLayout(null);
|
contentPane.setLayout(null);
|
||||||
chckbxComputeFrames = new JCheckBox("Compute Frames");
|
chckbxComputeFrames = new JCheckBox("Compute Frames");
|
||||||
chckbxComputeFrames.setBounds(6, 7, 138, 23);
|
chckbxComputeFrames.setBounds(6, 7, 138, 23);
|
||||||
contentPane.add(chckbxComputeFrames);
|
contentPane.add(chckbxComputeFrames);
|
||||||
chckbxComputeMax = new JCheckBox("Compute Max");
|
chckbxComputeMax = new JCheckBox("Compute Max");
|
||||||
chckbxComputeMax.setBounds(6, 33, 138, 23);
|
chckbxComputeMax.setBounds(6, 33, 138, 23);
|
||||||
contentPane.add(chckbxComputeMax);
|
contentPane.add(chckbxComputeMax);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+151
-151
@@ -1,151 +1,151 @@
|
|||||||
package me.ByteEdit.edit;
|
package me.ByteEdit.edit;
|
||||||
|
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
|
|
||||||
import me.ByteEdit.main.Main;
|
import me.ByteEdit.main.Main;
|
||||||
|
|
||||||
public class SearchBox extends JFrame {
|
public class SearchBox extends JFrame {
|
||||||
|
|
||||||
public JPanel contentPane;
|
public JPanel contentPane;
|
||||||
public JTextField txtFind;
|
public JTextField txtFind;
|
||||||
public JTextField txtReplace;
|
public JTextField txtReplace;
|
||||||
public JCheckBox chckbxCaseSensitive;
|
public JCheckBox chckbxCaseSensitive;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the frame.
|
* Create the frame.
|
||||||
*/
|
*/
|
||||||
public SearchBox() {
|
public SearchBox() {
|
||||||
try {
|
try {
|
||||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
setTitle("Find/Replace");
|
setTitle("Find/Replace");
|
||||||
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
||||||
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 128),
|
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 128),
|
||||||
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 181), 256, 262);
|
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 181), 256, 262);
|
||||||
contentPane = new JPanel();
|
contentPane = new JPanel();
|
||||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
setContentPane(contentPane);
|
setContentPane(contentPane);
|
||||||
contentPane.setLayout(null);
|
contentPane.setLayout(null);
|
||||||
JLabel lblFind = new JLabel("Find:");
|
JLabel lblFind = new JLabel("Find:");
|
||||||
lblFind.setBounds(10, 25, 71, 14);
|
lblFind.setBounds(10, 25, 71, 14);
|
||||||
contentPane.add(lblFind);
|
contentPane.add(lblFind);
|
||||||
txtFind = new JTextField();
|
txtFind = new JTextField();
|
||||||
KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
|
KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
|
||||||
txtFind.registerKeyboardAction(new ActionListener() {
|
txtFind.registerKeyboardAction(new ActionListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
find();
|
find();
|
||||||
}
|
}
|
||||||
}, enter, JComponent.WHEN_IN_FOCUSED_WINDOW);
|
}, enter, JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||||
txtFind.setBounds(91, 22, 149, 20);
|
txtFind.setBounds(91, 22, 149, 20);
|
||||||
contentPane.add(txtFind);
|
contentPane.add(txtFind);
|
||||||
txtFind.setColumns(10);
|
txtFind.setColumns(10);
|
||||||
JLabel lblReplaceWith = new JLabel("Replace with:");
|
JLabel lblReplaceWith = new JLabel("Replace with:");
|
||||||
lblReplaceWith.setBounds(10, 53, 71, 14);
|
lblReplaceWith.setBounds(10, 53, 71, 14);
|
||||||
contentPane.add(lblReplaceWith);
|
contentPane.add(lblReplaceWith);
|
||||||
txtReplace = new JTextField();
|
txtReplace = new JTextField();
|
||||||
txtReplace.setColumns(10);
|
txtReplace.setColumns(10);
|
||||||
txtReplace.setBounds(91, 50, 149, 20);
|
txtReplace.setBounds(91, 50, 149, 20);
|
||||||
contentPane.add(txtReplace);
|
contentPane.add(txtReplace);
|
||||||
chckbxCaseSensitive = new JCheckBox("Case sensitive");
|
chckbxCaseSensitive = new JCheckBox("Case sensitive");
|
||||||
chckbxCaseSensitive.setBounds(10, 103, 230, 23);
|
chckbxCaseSensitive.setBounds(10, 103, 230, 23);
|
||||||
contentPane.add(chckbxCaseSensitive);
|
contentPane.add(chckbxCaseSensitive);
|
||||||
JButton btnFind = new JButton("Find");
|
JButton btnFind = new JButton("Find");
|
||||||
btnFind.addActionListener(new ActionListener() {
|
btnFind.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
find();
|
find();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
btnFind.setBounds(10, 150, 110, 23);
|
btnFind.setBounds(10, 150, 110, 23);
|
||||||
contentPane.add(btnFind);
|
contentPane.add(btnFind);
|
||||||
JButton btnReplacefind = new JButton("Replace/Find");
|
JButton btnReplacefind = new JButton("Replace/Find");
|
||||||
btnReplacefind.addActionListener(new ActionListener() {
|
btnReplacefind.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
replaceFind();
|
replaceFind();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
btnReplacefind.setBounds(130, 150, 110, 23);
|
btnReplacefind.setBounds(130, 150, 110, 23);
|
||||||
contentPane.add(btnReplacefind);
|
contentPane.add(btnReplacefind);
|
||||||
JButton btnReplace = new JButton("Replace");
|
JButton btnReplace = new JButton("Replace");
|
||||||
btnReplace.addActionListener(new ActionListener() {
|
btnReplace.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
replace();
|
replace();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
btnReplace.setBounds(10, 184, 110, 23);
|
btnReplace.setBounds(10, 184, 110, 23);
|
||||||
contentPane.add(btnReplace);
|
contentPane.add(btnReplace);
|
||||||
JButton btnReplaceAll = new JButton("Replace All");
|
JButton btnReplaceAll = new JButton("Replace All");
|
||||||
btnReplaceAll.addActionListener(new ActionListener() {
|
btnReplaceAll.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
replaceAll();
|
replaceAll();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
btnReplaceAll.setBounds(130, 184, 110, 23);
|
btnReplaceAll.setBounds(130, 184, 110, 23);
|
||||||
contentPane.add(btnReplaceAll);
|
contentPane.add(btnReplaceAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void find() {
|
public void find() {
|
||||||
int startPos = Main.txtByteEditView.getCaretPosition();
|
int startPos = Main.txtByteEditView.getCaretPosition();
|
||||||
String toFind = txtFind.getText();
|
String toFind = txtFind.getText();
|
||||||
String txt = chckbxCaseSensitive.isSelected() ? Main.txtByteEditView.getText().substring(startPos)
|
String txt = chckbxCaseSensitive.isSelected() ? Main.txtByteEditView.getText().substring(startPos)
|
||||||
: Main.txtByteEditView.getText().substring(startPos).toLowerCase();
|
: Main.txtByteEditView.getText().substring(startPos).toLowerCase();
|
||||||
int index = txt.indexOf(chckbxCaseSensitive.isSelected() ? toFind : toFind.toLowerCase());
|
int index = txt.indexOf(chckbxCaseSensitive.isSelected() ? toFind : toFind.toLowerCase());
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
txt = chckbxCaseSensitive.isSelected() ? Main.txtByteEditView.getText() : Main.txtByteEditView.getText().toLowerCase();
|
txt = chckbxCaseSensitive.isSelected() ? Main.txtByteEditView.getText() : Main.txtByteEditView.getText().toLowerCase();
|
||||||
index = txt.indexOf(chckbxCaseSensitive.isSelected() ? toFind : toFind.toLowerCase());
|
index = txt.indexOf(chckbxCaseSensitive.isSelected() ? toFind : toFind.toLowerCase());
|
||||||
startPos = 0;
|
startPos = 0;
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Main.txtByteEditView.select(startPos + index, startPos + index + toFind.length());
|
Main.txtByteEditView.select(startPos + index, startPos + index + toFind.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void replaceFind() {
|
public void replaceFind() {
|
||||||
replace();
|
replace();
|
||||||
find();
|
find();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void replace() {
|
public void replace() {
|
||||||
String txt = Main.txtByteEditView.getText();
|
String txt = Main.txtByteEditView.getText();
|
||||||
int startPos = Main.txtByteEditView.getSelectionStart();
|
int startPos = Main.txtByteEditView.getSelectionStart();
|
||||||
Main.txtByteEditView.replaceSelection(txtReplace.getText());
|
Main.txtByteEditView.replaceSelection(txtReplace.getText());
|
||||||
Main.txtByteEditView.select(startPos, startPos + txtReplace.getText().length());
|
Main.txtByteEditView.select(startPos, startPos + txtReplace.getText().length());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void replaceAll() {
|
public void replaceAll() {
|
||||||
String toFind = txtFind.getText();
|
String toFind = txtFind.getText();
|
||||||
String toReplace = txtReplace.getText();
|
String toReplace = txtReplace.getText();
|
||||||
String txt = Main.txtByteEditView.getText();
|
String txt = Main.txtByteEditView.getText();
|
||||||
int prev = Main.txtByteEditView.getCaretPosition();
|
int prev = Main.txtByteEditView.getCaretPosition();
|
||||||
if (chckbxCaseSensitive.isSelected()) {
|
if (chckbxCaseSensitive.isSelected()) {
|
||||||
Main.txtByteEditView.replaceRange(txt.replace(toFind, toReplace), 0, txt.length());
|
Main.txtByteEditView.replaceRange(txt.replace(toFind, toReplace), 0, txt.length());
|
||||||
} else {
|
} else {
|
||||||
Main.txtByteEditView.replaceRange(txt.replaceAll("(?i)" + Pattern.quote(toFind), toReplace), 0, txt.length());
|
Main.txtByteEditView.replaceRange(txt.replaceAll("(?i)" + Pattern.quote(toFind), toReplace), 0, txt.length());
|
||||||
}
|
}
|
||||||
Main.txtByteEditView.setCaretPosition(prev);
|
Main.txtByteEditView.setCaretPosition(prev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,119 +1,119 @@
|
|||||||
package me.ByteEdit.edit;
|
package me.ByteEdit.edit;
|
||||||
|
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
import javax.swing.DefaultListModel;
|
import javax.swing.DefaultListModel;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JList;
|
import javax.swing.JList;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.ListSelectionModel;
|
import javax.swing.ListSelectionModel;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
import javax.swing.event.DocumentEvent;
|
import javax.swing.event.DocumentEvent;
|
||||||
import javax.swing.event.DocumentListener;
|
import javax.swing.event.DocumentListener;
|
||||||
import javax.swing.event.ListSelectionEvent;
|
import javax.swing.event.ListSelectionEvent;
|
||||||
import javax.swing.event.ListSelectionListener;
|
import javax.swing.event.ListSelectionListener;
|
||||||
|
|
||||||
import me.ByteEdit.main.Main;
|
import me.ByteEdit.main.Main;
|
||||||
|
|
||||||
public class TypeOpenBox extends JFrame {
|
public class TypeOpenBox extends JFrame {
|
||||||
|
|
||||||
public JPanel contentPane;
|
public JPanel contentPane;
|
||||||
public JTextField txtSearch;
|
public JTextField txtSearch;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the frame.
|
* Create the frame.
|
||||||
*/
|
*/
|
||||||
public TypeOpenBox() {
|
public TypeOpenBox() {
|
||||||
try {
|
try {
|
||||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
setTitle("Open Type");
|
setTitle("Open Type");
|
||||||
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
||||||
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 200),
|
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 200),
|
||||||
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 140), 400, 280);
|
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 140), 400, 280);
|
||||||
contentPane = new JPanel();
|
contentPane = new JPanel();
|
||||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
setContentPane(contentPane);
|
setContentPane(contentPane);
|
||||||
contentPane.setLayout(null);
|
contentPane.setLayout(null);
|
||||||
|
|
||||||
DefaultListModel<String> model = new DefaultListModel<>();
|
DefaultListModel<String> model = new DefaultListModel<>();
|
||||||
JList<String> list = new JList(model);
|
JList<String> list = new JList(model);
|
||||||
list.addListSelectionListener(new ListSelectionListener() {
|
list.addListSelectionListener(new ListSelectionListener() {
|
||||||
|
|
||||||
public void valueChanged(ListSelectionEvent e) {
|
public void valueChanged(ListSelectionEvent e) {
|
||||||
String val = list.getSelectedValue();
|
String val = list.getSelectedValue();
|
||||||
if (val != null && !val.equals(Main.currentNodeName)) {
|
if (val != null && !val.equals(Main.currentNodeName)) {
|
||||||
Main.selectFile(val);
|
Main.selectFile(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
txtSearch = new JTextField();
|
txtSearch = new JTextField();
|
||||||
txtSearch.addActionListener(new ActionListener() {
|
txtSearch.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if (model.size() == 1) {
|
if (model.size() == 1) {
|
||||||
list.setSelectedIndex(0);
|
list.setSelectedIndex(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
txtSearch.getDocument().addDocumentListener(new DocumentListener() {
|
txtSearch.getDocument().addDocumentListener(new DocumentListener() {
|
||||||
|
|
||||||
public void changedUpdate(DocumentEvent e) {
|
public void changedUpdate(DocumentEvent e) {
|
||||||
updateList();
|
updateList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeUpdate(DocumentEvent e) {
|
public void removeUpdate(DocumentEvent e) {
|
||||||
updateList();
|
updateList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertUpdate(DocumentEvent e) {
|
public void insertUpdate(DocumentEvent e) {
|
||||||
updateList();
|
updateList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateList() {
|
public void updateList() {
|
||||||
model.clear();
|
model.clear();
|
||||||
if (txtSearch.getText().isEmpty()) {
|
if (txtSearch.getText().isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String search = txtSearch.getText().toLowerCase();
|
String search = txtSearch.getText().toLowerCase();
|
||||||
if (search.contains("/")) {
|
if (search.contains("/")) {
|
||||||
for (String s : Main.classNodes.keySet()) {
|
for (String s : Main.classNodes.keySet()) {
|
||||||
String className = s.substring(0, s.length() - 6);
|
String className = s.substring(0, s.length() - 6);
|
||||||
if (!className.contains("$") && className.toLowerCase().startsWith(search)) {
|
if (!className.contains("$") && className.toLowerCase().startsWith(search)) {
|
||||||
model.addElement(s);
|
model.addElement(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (String s : Main.classNodes.keySet()) {
|
for (String s : Main.classNodes.keySet()) {
|
||||||
String[] split = s.split("/");
|
String[] split = s.split("/");
|
||||||
String className = split[split.length - 1];
|
String className = split[split.length - 1];
|
||||||
className = className.substring(0, className.length() - 6);
|
className = className.substring(0, className.length() - 6);
|
||||||
if (!className.contains("$") && className.toLowerCase().startsWith(search)) {
|
if (!className.contains("$") && className.toLowerCase().startsWith(search)) {
|
||||||
model.addElement(s);
|
model.addElement(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
txtSearch.setBounds(10, 11, 374, 20);
|
txtSearch.setBounds(10, 11, 374, 20);
|
||||||
contentPane.add(txtSearch);
|
contentPane.add(txtSearch);
|
||||||
txtSearch.setColumns(10);
|
txtSearch.setColumns(10);
|
||||||
|
|
||||||
JScrollPane scrollPane = new JScrollPane();
|
JScrollPane scrollPane = new JScrollPane();
|
||||||
scrollPane.setBounds(10, 46, 374, 194);
|
scrollPane.setBounds(10, 46, 374, 194);
|
||||||
contentPane.add(scrollPane);
|
contentPane.add(scrollPane);
|
||||||
|
|
||||||
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
scrollPane.setViewportView(list);
|
scrollPane.setViewportView(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,19 +1,19 @@
|
|||||||
package me.ByteEdit.main;
|
package me.ByteEdit.main;
|
||||||
|
|
||||||
import javax.swing.tree.DefaultMutableTreeNode;
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
|
|
||||||
public class ByteEditTreeNode extends DefaultMutableTreeNode {
|
public class ByteEditTreeNode extends DefaultMutableTreeNode {
|
||||||
|
|
||||||
public String path;
|
public String path;
|
||||||
|
|
||||||
public ByteEditTreeNode(String name) {
|
public ByteEditTreeNode(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ByteEditTreeNode(String name, String path) {
|
public ByteEditTreeNode(String name, String path) {
|
||||||
this(name);
|
this(name);
|
||||||
if (name.endsWith(".class"))
|
if (name.endsWith(".class"))
|
||||||
this.path = path;
|
this.path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+1002
-897
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,20 +1,20 @@
|
|||||||
package me.ByteEdit.utils;
|
package me.ByteEdit.utils;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
|
|
||||||
public class CustomBufferedReader extends BufferedReader {
|
public class CustomBufferedReader extends BufferedReader {
|
||||||
|
|
||||||
public int currentLine = 0;
|
public int currentLine = 0;
|
||||||
|
|
||||||
public CustomBufferedReader(Reader in) {
|
public CustomBufferedReader(Reader in) {
|
||||||
super(in);
|
super(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String readLine() throws IOException {
|
public String readLine() throws IOException {
|
||||||
currentLine++;
|
currentLine++;
|
||||||
return super.readLine();
|
return super.readLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,45 +1,47 @@
|
|||||||
package me.ByteEdit.utils;
|
package me.ByteEdit.utils;
|
||||||
|
|
||||||
public class ExternalTypeEnumeration {
|
public class ExternalTypeEnumeration {
|
||||||
|
|
||||||
private String descriptor;
|
private String descriptor;
|
||||||
private int index;
|
private int index;
|
||||||
|
|
||||||
public ExternalTypeEnumeration(String paramString) {
|
public ExternalTypeEnumeration(String paramString) {
|
||||||
setDescriptor(paramString);
|
setDescriptor(paramString);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExternalTypeEnumeration() {}
|
ExternalTypeEnumeration() {
|
||||||
|
}
|
||||||
void setDescriptor(String paramString) {
|
|
||||||
this.descriptor = paramString;
|
void setDescriptor(String paramString) {
|
||||||
reset();
|
this.descriptor = paramString;
|
||||||
}
|
reset();
|
||||||
|
}
|
||||||
public void reset() {
|
|
||||||
this.index = (this.descriptor.indexOf('(') + 1);
|
public void reset() {
|
||||||
if (this.index < 1) {
|
this.index = (this.descriptor.indexOf('(') + 1);
|
||||||
throw new IllegalArgumentException("Missing opening parenthesis in descriptor [" + this.descriptor + "]");
|
if (this.index < 1) {
|
||||||
}
|
throw new IllegalArgumentException("Missing opening parenthesis in descriptor [" + this.descriptor + "]");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public boolean hasMoreTypes() {
|
|
||||||
return this.index < this.descriptor.length() - 1;
|
public boolean hasMoreTypes() {
|
||||||
}
|
return this.index < this.descriptor.length() - 1;
|
||||||
|
}
|
||||||
public String nextType() {
|
|
||||||
int i = this.index;
|
public String nextType() {
|
||||||
this.index = this.descriptor.indexOf(',', i);
|
int i = this.index;
|
||||||
if (this.index < 0) {
|
this.index = this.descriptor.indexOf(',', i);
|
||||||
this.index = this.descriptor.indexOf(')', i);
|
if (this.index < 0) {
|
||||||
if (this.index < 0) {
|
this.index = this.descriptor.indexOf(')', i);
|
||||||
throw new IllegalArgumentException("Missing closing parenthesis in descriptor [" + this.descriptor + "]");
|
if (this.index < 0) {
|
||||||
}
|
throw new IllegalArgumentException(
|
||||||
}
|
"Missing closing parenthesis in descriptor [" + this.descriptor + "]");
|
||||||
return this.descriptor.substring(i, this.index++).trim();
|
}
|
||||||
}
|
}
|
||||||
|
return this.descriptor.substring(i, this.index++).trim();
|
||||||
public String methodName() {
|
}
|
||||||
return this.descriptor.substring(0, this.descriptor.indexOf('(')).trim();
|
|
||||||
}
|
public String methodName() {
|
||||||
}
|
return this.descriptor.substring(0, this.descriptor.indexOf('(')).trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -1,15 +1,15 @@
|
|||||||
package me.ByteEdit.utils;
|
package me.ByteEdit.utils;
|
||||||
|
|
||||||
public class SwitchIntContainer {
|
public class SwitchIntContainer {
|
||||||
|
|
||||||
private final int id;
|
private final int id;
|
||||||
|
|
||||||
public SwitchIntContainer(final int id) {
|
public SwitchIntContainer(final int id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,159 +1,160 @@
|
|||||||
package me.ByteEdit.utils;
|
package me.ByteEdit.utils;
|
||||||
|
|
||||||
public class UnicodeUtils {
|
public class UnicodeUtils {
|
||||||
|
|
||||||
public static String unescape(String s) {
|
public static String unescape(String s) {
|
||||||
if (s == null) {
|
if (s == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
char unicodeBuffer = 0;
|
char unicodeBuffer = 0;
|
||||||
int stage = 0;
|
int stage = 0;
|
||||||
for (char c : s.toCharArray()) {
|
for (char c : s.toCharArray()) {
|
||||||
if (c == '\\' && stage == 0) {
|
if (c == '\\' && stage == 0) {
|
||||||
stage = 1;
|
stage = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (stage == 1) {
|
if (stage == 1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'b':
|
case 'b':
|
||||||
sb.append('\b');
|
sb.append('\b');
|
||||||
stage = 0;
|
stage = 0;
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
sb.append('\t');
|
sb.append('\t');
|
||||||
stage = 0;
|
stage = 0;
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
sb.append('\n');
|
sb.append('\n');
|
||||||
stage = 0;
|
stage = 0;
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
sb.append('\r');
|
sb.append('\r');
|
||||||
stage = 0;
|
stage = 0;
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
sb.append('\f');
|
sb.append('\f');
|
||||||
stage = 0;
|
stage = 0;
|
||||||
break;
|
break;
|
||||||
case '"':
|
case '"':
|
||||||
sb.append('"');
|
sb.append('"');
|
||||||
stage = 0;
|
stage = 0;
|
||||||
break;
|
break;
|
||||||
case '\\':
|
case '\\':
|
||||||
sb.append('\\');
|
sb.append('\\');
|
||||||
stage = 0;
|
stage = 0;
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
stage++;
|
stage++;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("'\\" + c + "' is invalid.");
|
throw new IllegalArgumentException("'\\" + c + "' is invalid.");
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
} else if (stage > 1 && stage < 6) { // \u1234 => up to 6
|
} else if (stage > 1 && stage < 6) { // \u1234 => up to 6
|
||||||
try {
|
try {
|
||||||
int i = Integer.parseInt(Character.toString(c), 16);
|
int i = Integer.parseInt(Character.toString(c), 16);
|
||||||
unicodeBuffer += i << (4 * (5 - stage++)); // 4 bytes each, shift left byte * 4..3..2..1 and add to unicodeBuffer
|
unicodeBuffer += i << (4 * (5 - stage++)); // 4 bytes each, shift left byte * 4..3..2..1 and add to
|
||||||
if (stage == 6) {
|
// unicodeBuffer
|
||||||
sb.append(unicodeBuffer);
|
if (stage == 6) {
|
||||||
stage = 0;
|
sb.append(unicodeBuffer);
|
||||||
unicodeBuffer = 0;
|
stage = 0;
|
||||||
}
|
unicodeBuffer = 0;
|
||||||
} catch (NumberFormatException e) {
|
}
|
||||||
throw new IllegalArgumentException("'" + c + "' is not a valid hex value.");
|
} catch (NumberFormatException e) {
|
||||||
}
|
throw new IllegalArgumentException("'" + c + "' is not a valid hex value.");
|
||||||
continue;
|
}
|
||||||
}
|
continue;
|
||||||
sb.append(c);
|
}
|
||||||
}
|
sb.append(c);
|
||||||
if (stage != 0) {
|
}
|
||||||
if (unicodeBuffer != 0) {
|
if (stage != 0) {
|
||||||
throw new IllegalArgumentException("The unicode at the end is incomplete.");
|
if (unicodeBuffer != 0) {
|
||||||
} else {
|
throw new IllegalArgumentException("The unicode at the end is incomplete.");
|
||||||
throw new IllegalArgumentException("'\\' at the end is invalid.");
|
} else {
|
||||||
}
|
throw new IllegalArgumentException("'\\' at the end is invalid.");
|
||||||
}
|
}
|
||||||
return sb.toString();
|
}
|
||||||
}
|
return sb.toString();
|
||||||
|
}
|
||||||
public static String escapeWithSpaces(String s) {
|
|
||||||
if (s == null) {
|
public static String escapeWithSpaces(String s) {
|
||||||
return null;
|
if (s == null) {
|
||||||
}
|
return null;
|
||||||
s = escape(s).replace(" ", "\\u0020");
|
}
|
||||||
if (s.startsWith("/")) {
|
s = escape(s).replace(" ", "\\u0020");
|
||||||
s = "\\u002F" + s.substring(1);
|
if (s.startsWith("/")) {
|
||||||
}
|
s = "\\u002F" + s.substring(1);
|
||||||
if (s.endsWith("/")) {
|
}
|
||||||
s = s.substring(0, s.length() - 1) + "\\u002F";
|
if (s.endsWith("/")) {
|
||||||
}
|
s = s.substring(0, s.length() - 1) + "\\u002F";
|
||||||
return s;
|
}
|
||||||
}
|
return s;
|
||||||
|
}
|
||||||
public static String escape(String s) {
|
|
||||||
if (s == null) {
|
public static String escape(String s) {
|
||||||
return null;
|
if (s == null) {
|
||||||
}
|
return null;
|
||||||
StringBuilder sb = new StringBuilder();
|
}
|
||||||
for (char c : s.toCharArray()) {
|
StringBuilder sb = new StringBuilder();
|
||||||
if (isPrintable(c)) {
|
for (char c : s.toCharArray()) {
|
||||||
sb.append(c);
|
if (isPrintable(c)) {
|
||||||
} else {
|
sb.append(c);
|
||||||
switch (c) {
|
} else {
|
||||||
case '\b':
|
switch (c) {
|
||||||
sb.append("\\b");
|
case '\b':
|
||||||
break;
|
sb.append("\\b");
|
||||||
case '\t':
|
break;
|
||||||
sb.append("\\t");
|
case '\t':
|
||||||
break;
|
sb.append("\\t");
|
||||||
case '\n':
|
break;
|
||||||
sb.append("\\n");
|
case '\n':
|
||||||
break;
|
sb.append("\\n");
|
||||||
case '\r':
|
break;
|
||||||
sb.append("\\r");
|
case '\r':
|
||||||
break;
|
sb.append("\\r");
|
||||||
case '\f':
|
break;
|
||||||
sb.append("\\f");
|
case '\f':
|
||||||
break;
|
sb.append("\\f");
|
||||||
case '"':
|
break;
|
||||||
sb.append("\\\"");
|
case '"':
|
||||||
break;
|
sb.append("\\\"");
|
||||||
case '\\':
|
break;
|
||||||
sb.append("\\\\");
|
case '\\':
|
||||||
break;
|
sb.append("\\\\");
|
||||||
default:
|
break;
|
||||||
sb.append(String.format("\\u%04X", (int) c));
|
default:
|
||||||
}
|
sb.append(String.format("\\u%04X", (int) c));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sb.toString();
|
}
|
||||||
}
|
return sb.toString();
|
||||||
|
}
|
||||||
private static boolean isPrintable(char c) {
|
|
||||||
switch (c) {
|
private static boolean isPrintable(char c) {
|
||||||
case 'Ä':
|
switch (c) {
|
||||||
case 'ä':
|
case 'Ä':
|
||||||
case 'Ö':
|
case 'ä':
|
||||||
case 'ö':
|
case 'Ö':
|
||||||
case 'Ü':
|
case 'ö':
|
||||||
case 'ü':
|
case 'Ü':
|
||||||
case 'ß':
|
case 'ü':
|
||||||
case '€':
|
case 'ß':
|
||||||
case '©':
|
case '€':
|
||||||
case '®':
|
case '©':
|
||||||
case '«':
|
case '®':
|
||||||
case '»':
|
case '«':
|
||||||
case '§':
|
case '»':
|
||||||
case '£':
|
case '§':
|
||||||
case '¥':
|
case '£':
|
||||||
return true;
|
case '¥':
|
||||||
case '"':
|
return true;
|
||||||
case '\\':
|
case '"':
|
||||||
return false;
|
case '\\':
|
||||||
default:
|
return false;
|
||||||
return c >= ' ' && c <= '~';
|
default:
|
||||||
}
|
return c >= ' ' && c <= '~';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
Reference in new issue
Block a user