mirror of
https://github.com/SuspiciousActivity/ByteEdit.git
synced 2026-08-13 17:56:17 +00:00
Cleanup
This commit is contained in:
1 parent
71c224f83f
commit
8832d67d8b
5 files changed
+6
-367
No files matched your search
@@ -145,7 +145,6 @@ public class CompilationBox extends JFrame {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(CompilationBox.this, res, "Error!", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
@@ -60,13 +60,7 @@ public class GlobalSearchBox extends JFrame {
|
||||
contentPane.add(lblFind);
|
||||
txtString = new JTextField();
|
||||
KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
|
||||
txtString.registerKeyboardAction(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
find();
|
||||
}
|
||||
}, enter, JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
txtString.registerKeyboardAction(e -> find(), enter, JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
txtString.setBounds(91, 22, 149, 20);
|
||||
contentPane.add(txtString);
|
||||
txtString.setColumns(10);
|
||||
@@ -74,12 +68,7 @@ public class GlobalSearchBox extends JFrame {
|
||||
chckbxCaseSensitive.setBounds(10, 199, 114, 23);
|
||||
contentPane.add(chckbxCaseSensitive);
|
||||
JButton btnFind = new JButton("Find");
|
||||
btnFind.addActionListener(new ActionListener() {
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
find();
|
||||
}
|
||||
});
|
||||
btnFind.addActionListener(e -> find());
|
||||
btnFind.setBounds(130, 199, 110, 23);
|
||||
contentPane.add(btnFind);
|
||||
|
||||
@@ -92,12 +81,7 @@ public class GlobalSearchBox extends JFrame {
|
||||
contentPane.add(lblOwner);
|
||||
|
||||
txtOwner = new JTextField();
|
||||
txtOwner.addActionListener(new ActionListener() {
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
find();
|
||||
}
|
||||
});
|
||||
txtOwner.addActionListener(e -> find());
|
||||
txtOwner.setColumns(10);
|
||||
txtOwner.setBounds(91, 78, 149, 20);
|
||||
contentPane.add(txtOwner);
|
||||
@@ -107,12 +91,7 @@ public class GlobalSearchBox extends JFrame {
|
||||
contentPane.add(lblName);
|
||||
|
||||
txtName = new JTextField();
|
||||
txtName.addActionListener(new ActionListener() {
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
find();
|
||||
}
|
||||
});
|
||||
txtName.addActionListener(e -> find());
|
||||
txtName.setColumns(10);
|
||||
txtName.setBounds(91, 106, 149, 20);
|
||||
contentPane.add(txtName);
|
||||
@@ -122,12 +101,7 @@ public class GlobalSearchBox extends JFrame {
|
||||
contentPane.add(lblDesc);
|
||||
|
||||
txtDesc = new JTextField();
|
||||
txtDesc.addActionListener(new ActionListener() {
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
find();
|
||||
}
|
||||
});
|
||||
txtDesc.addActionListener(e -> find());
|
||||
txtDesc.setColumns(10);
|
||||
txtDesc.setBounds(91, 134, 149, 20);
|
||||
contentPane.add(txtDesc);
|
||||
@@ -194,9 +168,7 @@ public class GlobalSearchBox extends JFrame {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Info s : set) {
|
||||
openBox.model.addElement(s);
|
||||
}
|
||||
set.forEach(openBox.model::addElement);
|
||||
openBox.setVisible(true);
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
package me.ByteEdit.edit;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Toolkit;
|
||||
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
public class OptionBox extends JFrame {
|
||||
|
||||
private JPanel contentPane;
|
||||
public JCheckBox chckbxComputeFrames;
|
||||
public JCheckBox chckbxComputeMax;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
OptionBox frame = new OptionBox();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public OptionBox() {
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
setResizable(false);
|
||||
setTitle("Options");
|
||||
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
||||
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 150),
|
||||
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 100), 300, 200);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
chckbxComputeFrames = new JCheckBox("Compute Frames");
|
||||
chckbxComputeFrames.setBounds(6, 7, 138, 23);
|
||||
contentPane.add(chckbxComputeFrames);
|
||||
chckbxComputeMax = new JCheckBox("Compute Max");
|
||||
chckbxComputeMax.setBounds(6, 33, 138, 23);
|
||||
contentPane.add(chckbxComputeMax);
|
||||
}
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
package me.ByteEdit.edit;
|
||||
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
import me.ByteEdit.main.Main;
|
||||
|
||||
public class SearchBox extends JFrame {
|
||||
|
||||
public JPanel contentPane;
|
||||
public JTextField txtFind;
|
||||
public JTextField txtReplace;
|
||||
public JCheckBox chckbxCaseSensitive;
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public SearchBox() {
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
setResizable(false);
|
||||
setTitle("Find/Replace");
|
||||
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
||||
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 128),
|
||||
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 181), 256, 262);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
JLabel lblFind = new JLabel("Find:");
|
||||
lblFind.setBounds(10, 25, 71, 14);
|
||||
contentPane.add(lblFind);
|
||||
txtFind = new JTextField();
|
||||
KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
|
||||
txtFind.registerKeyboardAction(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
find();
|
||||
}
|
||||
}, enter, JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
txtFind.setBounds(91, 22, 149, 20);
|
||||
contentPane.add(txtFind);
|
||||
txtFind.setColumns(10);
|
||||
JLabel lblReplaceWith = new JLabel("Replace with:");
|
||||
lblReplaceWith.setBounds(10, 53, 71, 14);
|
||||
contentPane.add(lblReplaceWith);
|
||||
txtReplace = new JTextField();
|
||||
txtReplace.setColumns(10);
|
||||
txtReplace.setBounds(91, 50, 149, 20);
|
||||
contentPane.add(txtReplace);
|
||||
chckbxCaseSensitive = new JCheckBox("Case sensitive");
|
||||
chckbxCaseSensitive.setBounds(10, 103, 230, 23);
|
||||
contentPane.add(chckbxCaseSensitive);
|
||||
JButton btnFind = new JButton("Find");
|
||||
btnFind.addActionListener(new ActionListener() {
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
find();
|
||||
}
|
||||
});
|
||||
btnFind.setBounds(10, 150, 110, 23);
|
||||
contentPane.add(btnFind);
|
||||
JButton btnReplacefind = new JButton("Replace/Find");
|
||||
btnReplacefind.addActionListener(new ActionListener() {
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
replaceFind();
|
||||
}
|
||||
});
|
||||
btnReplacefind.setBounds(130, 150, 110, 23);
|
||||
contentPane.add(btnReplacefind);
|
||||
JButton btnReplace = new JButton("Replace");
|
||||
btnReplace.addActionListener(new ActionListener() {
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
replace();
|
||||
}
|
||||
});
|
||||
btnReplace.setBounds(10, 184, 110, 23);
|
||||
contentPane.add(btnReplace);
|
||||
JButton btnReplaceAll = new JButton("Replace All");
|
||||
btnReplaceAll.addActionListener(new ActionListener() {
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
replaceAll();
|
||||
}
|
||||
});
|
||||
btnReplaceAll.setBounds(130, 184, 110, 23);
|
||||
contentPane.add(btnReplaceAll);
|
||||
}
|
||||
|
||||
public void find() {
|
||||
int startPos = Main.txtByteEditView.getCaretPosition();
|
||||
String toFind = txtFind.getText();
|
||||
String txt = chckbxCaseSensitive.isSelected() ? Main.txtByteEditView.getText().substring(startPos)
|
||||
: Main.txtByteEditView.getText().substring(startPos).toLowerCase();
|
||||
int index = txt.indexOf(chckbxCaseSensitive.isSelected() ? toFind : toFind.toLowerCase());
|
||||
if (index == -1) {
|
||||
txt = chckbxCaseSensitive.isSelected() ? Main.txtByteEditView.getText()
|
||||
: Main.txtByteEditView.getText().toLowerCase();
|
||||
index = txt.indexOf(chckbxCaseSensitive.isSelected() ? toFind : toFind.toLowerCase());
|
||||
startPos = 0;
|
||||
if (index == -1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
Main.txtByteEditView.select(startPos + index, startPos + index + toFind.length());
|
||||
}
|
||||
|
||||
public void replaceFind() {
|
||||
replace();
|
||||
find();
|
||||
}
|
||||
|
||||
public void replace() {
|
||||
int startPos = Main.txtByteEditView.getSelectionStart();
|
||||
Main.txtByteEditView.replaceSelection(txtReplace.getText());
|
||||
Main.txtByteEditView.select(startPos, startPos + txtReplace.getText().length());
|
||||
}
|
||||
|
||||
public void replaceAll() {
|
||||
String toFind = txtFind.getText();
|
||||
String toReplace = txtReplace.getText();
|
||||
String txt = Main.txtByteEditView.getText();
|
||||
int prev = Main.txtByteEditView.getCaretPosition();
|
||||
if (chckbxCaseSensitive.isSelected()) {
|
||||
Main.txtByteEditView.replaceRange(txt.replace(toFind, toReplace), 0, txt.length());
|
||||
} else {
|
||||
Main.txtByteEditView.replaceRange(txt.replaceAll("(?i)" + Pattern.quote(toFind), toReplace), 0,
|
||||
txt.length());
|
||||
}
|
||||
Main.txtByteEditView.setCaretPosition(prev);
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
package me.ByteEdit.edit;
|
||||
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.DefaultListModel;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import me.ByteEdit.decompiler.SingleThreadedExecutor;
|
||||
import me.ByteEdit.main.Main;
|
||||
|
||||
public class TypeOpenBox extends JFrame {
|
||||
|
||||
public JPanel contentPane;
|
||||
public JTextField txtSearch;
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public TypeOpenBox() {
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
setResizable(false);
|
||||
setTitle("Open Type");
|
||||
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
||||
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 200),
|
||||
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 140), 400, 280);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
DefaultListModel<String> model = new DefaultListModel<>();
|
||||
JList<String> list = new JList(model);
|
||||
list.addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
String val = list.getSelectedValue();
|
||||
if (val != null && !val.equals(Main.currentNodeName)) {
|
||||
SingleThreadedExecutor.execute(() -> Main.selectFile(val));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
txtSearch = new JTextField();
|
||||
txtSearch.addActionListener(new ActionListener() {
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (model.size() == 1) {
|
||||
list.setSelectedIndex(0);
|
||||
}
|
||||
}
|
||||
});
|
||||
txtSearch.getDocument().addDocumentListener(new DocumentListener() {
|
||||
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
updateList();
|
||||
}
|
||||
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
updateList();
|
||||
}
|
||||
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
updateList();
|
||||
}
|
||||
|
||||
public void updateList() {
|
||||
model.clear();
|
||||
if (txtSearch.getText().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
String search = txtSearch.getText().toLowerCase();
|
||||
if (search.contains("/")) {
|
||||
for (String s : Main.classNodes.keySet()) {
|
||||
String className = s.substring(0, s.length() - 6);
|
||||
if (!className.contains("$") && className.toLowerCase().startsWith(search)) {
|
||||
model.addElement(s);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (String s : Main.classNodes.keySet()) {
|
||||
String[] split = s.split("/");
|
||||
String className = split[split.length - 1];
|
||||
className = className.substring(0, className.length() - 6);
|
||||
if (!className.contains("$") && className.toLowerCase().startsWith(search)) {
|
||||
model.addElement(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
txtSearch.setBounds(10, 11, 374, 20);
|
||||
contentPane.add(txtSearch);
|
||||
txtSearch.setColumns(10);
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane();
|
||||
scrollPane.setBounds(10, 46, 374, 194);
|
||||
contentPane.add(scrollPane);
|
||||
|
||||
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
scrollPane.setViewportView(list);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user