Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Commit

Permalink
Merge pull request #9 from Enaium/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Enaium authored Aug 15, 2022
2 parents 459ba64 + 68baf4a commit 63a2ad5
Show file tree
Hide file tree
Showing 46 changed files with 709 additions and 170 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group 'cn.enaium'
version '0.8.0'
version '0.9.0'

sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8

Expand Down
18 changes: 11 additions & 7 deletions src/main/java/cn/enaium/joe/JavaOctetEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,25 @@ public class JavaOctetEditor {

public Jar jar;

public FileTabbedPanel fileTabbedPanel = new FileTabbedPanel();
public FileTabbedPanel fileTabbedPanel;

public FileTreePanel fileTreePanel = new FileTreePanel();
public FileTreePanel fileTreePanel;

public BottomPanel bottomPanel = new BottomPanel();
public BottomPanel bottomPanel;

public ConfigManager configManager = new ConfigManager();
public ConfigManager configManager;

public JavaOctetEditor() {
instance = this;
configManager = new ConfigManager();
configManager.load();
Runtime.getRuntime().addShutdownHook(new Thread(configManager::save));
fileTabbedPanel = new FileTabbedPanel();
fileTreePanel = new FileTreePanel();
bottomPanel = new BottomPanel();
}

public void run() {
configManager.load();
Runtime.getRuntime().addShutdownHook(new Thread(configManager::save));

ToolTipManager.sharedInstance().setInitialDelay(0);

Expand Down Expand Up @@ -91,7 +95,7 @@ public void run() {
window.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
MessageUtil.confirm(LangUtil.i18n("dialog.wantCloseWindow"), "WARNING", () -> {
MessageUtil.confirm(LangUtil.i18n("dialog.wantCloseWindow"), LangUtil.i18n("warning"), () -> {
window.dispose();
System.exit(0);
}, () -> {
Expand Down
31 changes: 31 additions & 0 deletions src/main/java/cn/enaium/joe/annotation/NoUI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2022 Enaium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package cn.enaium.joe.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* @author Enaium
* @since 0.9.0
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface NoUI {
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@

package cn.enaium.joe.config.extend;

import cn.enaium.joe.annotation.NoUI;
import cn.enaium.joe.config.Config;
import cn.enaium.joe.config.value.ModeValue;
import cn.enaium.joe.config.value.StringSetValue;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;

/**
* @author Enaium
Expand All @@ -28,6 +32,8 @@
public class ApplicationConfig extends Config {
public final ModeValue decompilerMode = new ModeValue("Decompiler", "CFR", "Java Decompiler", Arrays.asList("CFR", "Procyon", "JD-Core"));
public final ModeValue language = new ModeValue("Language", "System", "UI language", Arrays.asList("System", "zh_CN", "en_US"));
@NoUI
public final StringSetValue loadRecent = new StringSetValue("Load Recent", new HashSet<>(), "");

public ApplicationConfig() {
super("Application");
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/cn/enaium/joe/config/value/StringSetValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2022 Enaium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package cn.enaium.joe.config.value;

import java.util.List;
import java.util.Set;

/**
* @author Enaium
* @since 0.9.0
*/
public class StringSetValue extends Value<Set<String>>{
public StringSetValue(String name, Set<String> value, String description) {
super(name, value, description);
}
}
7 changes: 7 additions & 0 deletions src/main/java/cn/enaium/joe/dialog/ConfigDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package cn.enaium.joe.dialog;

import cn.enaium.joe.JavaOctetEditor;
import cn.enaium.joe.annotation.NoUI;
import cn.enaium.joe.config.Config;
import cn.enaium.joe.config.value.*;
import cn.enaium.joe.util.LangUtil;
Expand Down Expand Up @@ -44,6 +45,12 @@ public ConfigDialog(Config config) {
try {
for (Field declaredField : config.getClass().getDeclaredFields()) {
declaredField.setAccessible(true);


if (declaredField.isAnnotationPresent(NoUI.class)) {
continue;
}

Object o = declaredField.get(config);

if (o instanceof Value) {
Expand Down
31 changes: 31 additions & 0 deletions src/main/java/cn/enaium/joe/gui/component/InstructionComboBox.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2022 Enaium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package cn.enaium.joe.gui.component;

import javax.swing.*;

/**
* @author Enaium
* @since 0.9.0
*/
public class InstructionComboBox extends JComboBox<String> {
public InstructionComboBox() {
super(new String[]{"Opcode", "Int", "Var", "Type", "Field", "Method", "InvokeDynamic", "Jump", "Label", "LDC", "Incr", "TableSwitch", "LookupSwitch", "MultiANewArray", "Frame", "Line"});
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class LabelNodeComboBox extends JComboBox<LabelNodeWrapper> {
public LabelNodeComboBox(AbstractInsnNode instruction, LabelNode select) {
super(new DefaultComboBoxModel<>());
LabelNodeWrapper selected = null;
for (AbstractInsnNode abstractInsnNode : OpcodeUtil.getInstructionList(instruction)) {
for (AbstractInsnNode abstractInsnNode : OpcodeUtil.getInstructionList(select)) {
if (abstractInsnNode instanceof LabelNode) {
LabelNodeWrapper anObject = new LabelNodeWrapper(((LabelNode) abstractInsnNode));
if (abstractInsnNode.equals(select)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package cn.enaium.joe.gui.panel.confirm;

import cn.enaium.joe.util.LangUtil;
import cn.enaium.joe.util.MessageUtil;
import cn.enaium.joe.wrapper.Wrapper;
import org.objectweb.asm.Handle;
Expand All @@ -40,7 +41,7 @@ public BootstrapMethodArgumentEditPanel(Wrapper<Object[]> wrapper) {
}
add(new JScrollPane(objectJList), BorderLayout.CENTER);
add(new JPanel() {{
add(new JButton("Add") {{
add(new JButton(LangUtil.i18n("button.add")) {{
addActionListener(e -> {
MessageUtil.confirm(new ConfirmPanel() {{
setLayout(new BorderLayout());
Expand All @@ -49,9 +50,9 @@ public BootstrapMethodArgumentEditPanel(Wrapper<Object[]> wrapper) {
add(left, BorderLayout.WEST);
add(right, BorderLayout.CENTER);
JComboBox<String> jComboBox = new JComboBox<>(new String[]{"String", "float", "double", "int", "long", "Class"});
left.add(new JLabel("Type:"));
left.add(new JLabel(LangUtil.i18n("instruction.type")));
right.add(jComboBox);
left.add(new JLabel("Var:"));
left.add(new JLabel(LangUtil.i18n("instruction.var")));
JTextField ldc = new JTextField();
right.add(ldc);
setConfirm(() -> {
Expand Down Expand Up @@ -79,7 +80,7 @@ public BootstrapMethodArgumentEditPanel(Wrapper<Object[]> wrapper) {
objectDefaultListModel.addElement(value);
}
});
}}, "Add");
}}, LangUtil.i18n("button.add"));
});
}});
add(new JButton("Add Handle") {{
Expand All @@ -93,7 +94,7 @@ public BootstrapMethodArgumentEditPanel(Wrapper<Object[]> wrapper) {
});
});
}});
add(new JButton("Remove") {{
add(new JButton(LangUtil.i18n("button.remove")) {{
addActionListener(e -> {
if (objectJList.getSelectedIndex() != -1) {
objectDefaultListModel.remove(objectJList.getSelectedIndex());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package cn.enaium.joe.gui.panel.confirm;

import cn.enaium.joe.util.LangUtil;
import cn.enaium.joe.util.MessageUtil;
import cn.enaium.joe.util.OpcodeUtil;
import cn.enaium.joe.util.StringUtil;
Expand Down Expand Up @@ -106,7 +107,7 @@ public ObjectList(List<Object> list) {
});
});
}});
add(new JButton("Remove") {{
add(new JButton(LangUtil.i18n("button.remove")) {{
addActionListener(e -> {
if (jList.getSelectedIndex() != -1) {
stringDefaultListModel.remove(jList.getSelectedIndex());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
package cn.enaium.joe.gui.panel.confirm;

import cn.enaium.joe.gui.panel.instruction.*;
import cn.enaium.joe.util.LangUtil;
import cn.enaium.joe.util.MessageUtil;
import cn.enaium.joe.util.OpcodeUtil;
import org.objectweb.asm.tree.*;

import java.awt.*;
Expand Down Expand Up @@ -86,7 +88,7 @@ public InstructionEditPanel(AbstractInsnNode instruction) {
setConfirm(() -> {
try {
if (!finalAbstractInstructionPanel.getConfirm().call()) {
MessageUtil.info("Failed");
MessageUtil.info(LangUtil.i18n("fail"));
}
} catch (Exception ex) {
MessageUtil.error(ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package cn.enaium.joe.gui.panel.confirm;

import cn.enaium.joe.util.LangUtil;
import cn.enaium.joe.util.MessageUtil;
import cn.enaium.joe.wrapper.LabelNodeWrapper;
import cn.enaium.joe.wrapper.Wrapper;
Expand All @@ -41,7 +42,7 @@ public LabelListEditPanel(List<LabelNode> labelNodes, InsnList instructions) {
}
add(new JScrollPane(labelNodeWrapperJList), BorderLayout.CENTER);
add(new JPanel() {{
add(new JButton("Add") {{
add(new JButton(LangUtil.i18n("button.add")) {{
addActionListener(e -> {
DefaultComboBoxModel<LabelNodeWrapper> labelNodeWrapperDefaultComboBoxModel = new DefaultComboBoxModel<>();
JComboBox<LabelNodeWrapper> labelNodeWrapperJComboBox = new JComboBox<>(labelNodeWrapperDefaultComboBoxModel);
Expand All @@ -58,7 +59,7 @@ public LabelListEditPanel(List<LabelNode> labelNodes, InsnList instructions) {
});
});
}});
add(new JButton("Remove") {{
add(new JButton(LangUtil.i18n("button.remove")) {{
addActionListener(e -> {
if (labelNodeWrapperJList.getSelectedIndex() != -1) {
labelNodeWrapperDefaultListModel.remove(labelNodeWrapperJList.getSelectedIndex());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package cn.enaium.joe.gui.panel.confirm;

import cn.enaium.joe.gui.component.LabelNodeComboBox;
import cn.enaium.joe.util.LangUtil;
import cn.enaium.joe.util.MessageUtil;
import cn.enaium.joe.wrapper.LabelNodeWrapper;
import org.objectweb.asm.tree.LabelNode;
Expand Down Expand Up @@ -46,7 +47,7 @@ public boolean isCellEditable(int row, int column) {
}
add(new JScrollPane(jTable), BorderLayout.CENTER);
add(new JPanel() {{
add(new JButton("Add") {{
add(new JButton(LangUtil.i18n("button.add")) {{
addActionListener(e -> {
MessageUtil.confirm(new ConfirmPanel() {{
JSpinner key = new JSpinner();
Expand All @@ -62,7 +63,7 @@ public boolean isCellEditable(int row, int column) {
}}, "Add");
});
}});
add(new JButton("Remove") {{
add(new JButton(LangUtil.i18n("button.remove")) {{
addActionListener(e -> {
if (jTable.getSelectedRow() != -1) {
dm.removeRow(jTable.getSelectedRow());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import cn.enaium.joe.JavaOctetEditor;
import cn.enaium.joe.gui.panel.CodeAreaPanel;
import cn.enaium.joe.util.ASyncUtil;
import cn.enaium.joe.util.LangUtil;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtMethod;
Expand Down Expand Up @@ -80,7 +81,7 @@ public void keyPressed(KeyEvent e) {
ClassNode newClassNode = new ClassNode();
new ClassReader(dumps).accept(newClassNode, ClassReader.EXPAND_FRAMES);
JavaOctetEditor.getInstance().jar.classes.put(newClassNode.name + ".class", newClassNode);
JOptionPane.showMessageDialog(null, "Save Success");
JOptionPane.showMessageDialog(null, LangUtil.i18n("success"));
} catch (Throwable ex) {
throw new RuntimeException(ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public ClassInfoTabPanel(ClassNode classNode) {
classNode.outerClass = null;
}

JOptionPane.showMessageDialog(ClassInfoTabPanel.this, "Save success");
JOptionPane.showMessageDialog(ClassInfoTabPanel.this, LangUtil.i18n("success"));
});
}}, BorderLayout.SOUTH);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public FieldInfoPanel(FieldNode fieldNode) {
fieldNode.signature = null;
}

JOptionPane.showMessageDialog(FieldInfoPanel.this, "Save success");
JOptionPane.showMessageDialog(FieldInfoPanel.this, LangUtil.i18n("success"));
});
}}, BorderLayout.SOUTH);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public MethodInfoTabPanel(MethodNode methodNode) {
methodNode.exceptions = new ArrayList<>();
}

JOptionPane.showMessageDialog(MethodInfoTabPanel.this, "Save success");
JOptionPane.showMessageDialog(MethodInfoTabPanel.this, LangUtil.i18n("success"));
});
}}, BorderLayout.SOUTH);
}
Expand Down
Loading

0 comments on commit 63a2ad5

Please sign in to comment.