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

Commit 63a2ad5

Browse files
authored
Merge pull request #9 from Enaium/develop
Develop
2 parents 459ba64 + 68baf4a commit 63a2ad5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+709
-170
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ plugins {
77
}
88

99
group 'cn.enaium'
10-
version '0.8.0'
10+
version '0.9.0'
1111

1212
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
1313

src/main/java/cn/enaium/joe/JavaOctetEditor.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,25 @@ public class JavaOctetEditor {
4949

5050
public Jar jar;
5151

52-
public FileTabbedPanel fileTabbedPanel = new FileTabbedPanel();
52+
public FileTabbedPanel fileTabbedPanel;
5353

54-
public FileTreePanel fileTreePanel = new FileTreePanel();
54+
public FileTreePanel fileTreePanel;
5555

56-
public BottomPanel bottomPanel = new BottomPanel();
56+
public BottomPanel bottomPanel;
5757

58-
public ConfigManager configManager = new ConfigManager();
58+
public ConfigManager configManager;
5959

6060
public JavaOctetEditor() {
6161
instance = this;
62+
configManager = new ConfigManager();
63+
configManager.load();
64+
Runtime.getRuntime().addShutdownHook(new Thread(configManager::save));
65+
fileTabbedPanel = new FileTabbedPanel();
66+
fileTreePanel = new FileTreePanel();
67+
bottomPanel = new BottomPanel();
6268
}
6369

6470
public void run() {
65-
configManager.load();
66-
Runtime.getRuntime().addShutdownHook(new Thread(configManager::save));
6771

6872
ToolTipManager.sharedInstance().setInitialDelay(0);
6973

@@ -91,7 +95,7 @@ public void run() {
9195
window.addWindowListener(new WindowAdapter() {
9296
@Override
9397
public void windowClosing(WindowEvent e) {
94-
MessageUtil.confirm(LangUtil.i18n("dialog.wantCloseWindow"), "WARNING", () -> {
98+
MessageUtil.confirm(LangUtil.i18n("dialog.wantCloseWindow"), LangUtil.i18n("warning"), () -> {
9599
window.dispose();
96100
System.exit(0);
97101
}, () -> {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2022 Enaium
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package cn.enaium.joe.annotation;
18+
19+
import java.lang.annotation.ElementType;
20+
import java.lang.annotation.Retention;
21+
import java.lang.annotation.RetentionPolicy;
22+
import java.lang.annotation.Target;
23+
24+
/**
25+
* @author Enaium
26+
* @since 0.9.0
27+
*/
28+
@Retention(RetentionPolicy.RUNTIME)
29+
@Target(ElementType.FIELD)
30+
public @interface NoUI {
31+
}

src/main/java/cn/enaium/joe/config/extend/ApplicationConfig.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@
1616

1717
package cn.enaium.joe.config.extend;
1818

19+
import cn.enaium.joe.annotation.NoUI;
1920
import cn.enaium.joe.config.Config;
2021
import cn.enaium.joe.config.value.ModeValue;
22+
import cn.enaium.joe.config.value.StringSetValue;
2123

24+
import java.util.ArrayList;
2225
import java.util.Arrays;
26+
import java.util.HashSet;
2327

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

3238
public ApplicationConfig() {
3339
super("Application");
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2022 Enaium
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package cn.enaium.joe.config.value;
18+
19+
import java.util.List;
20+
import java.util.Set;
21+
22+
/**
23+
* @author Enaium
24+
* @since 0.9.0
25+
*/
26+
public class StringSetValue extends Value<Set<String>>{
27+
public StringSetValue(String name, Set<String> value, String description) {
28+
super(name, value, description);
29+
}
30+
}

src/main/java/cn/enaium/joe/dialog/ConfigDialog.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package cn.enaium.joe.dialog;
1818

1919
import cn.enaium.joe.JavaOctetEditor;
20+
import cn.enaium.joe.annotation.NoUI;
2021
import cn.enaium.joe.config.Config;
2122
import cn.enaium.joe.config.value.*;
2223
import cn.enaium.joe.util.LangUtil;
@@ -44,6 +45,12 @@ public ConfigDialog(Config config) {
4445
try {
4546
for (Field declaredField : config.getClass().getDeclaredFields()) {
4647
declaredField.setAccessible(true);
48+
49+
50+
if (declaredField.isAnnotationPresent(NoUI.class)) {
51+
continue;
52+
}
53+
4754
Object o = declaredField.get(config);
4855

4956
if (o instanceof Value) {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2022 Enaium
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package cn.enaium.joe.gui.component;
18+
19+
import javax.swing.*;
20+
21+
/**
22+
* @author Enaium
23+
* @since 0.9.0
24+
*/
25+
public class InstructionComboBox extends JComboBox<String> {
26+
public InstructionComboBox() {
27+
super(new String[]{"Opcode", "Int", "Var", "Type", "Field", "Method", "InvokeDynamic", "Jump", "Label", "LDC", "Incr", "TableSwitch", "LookupSwitch", "MultiANewArray", "Frame", "Line"});
28+
}
29+
}
30+
31+

src/main/java/cn/enaium/joe/gui/component/LabelNodeComboBox.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class LabelNodeComboBox extends JComboBox<LabelNodeWrapper> {
3131
public LabelNodeComboBox(AbstractInsnNode instruction, LabelNode select) {
3232
super(new DefaultComboBoxModel<>());
3333
LabelNodeWrapper selected = null;
34-
for (AbstractInsnNode abstractInsnNode : OpcodeUtil.getInstructionList(instruction)) {
34+
for (AbstractInsnNode abstractInsnNode : OpcodeUtil.getInstructionList(select)) {
3535
if (abstractInsnNode instanceof LabelNode) {
3636
LabelNodeWrapper anObject = new LabelNodeWrapper(((LabelNode) abstractInsnNode));
3737
if (abstractInsnNode.equals(select)) {

src/main/java/cn/enaium/joe/gui/panel/confirm/BootstrapMethodArgumentEditPanel.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

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

19+
import cn.enaium.joe.util.LangUtil;
1920
import cn.enaium.joe.util.MessageUtil;
2021
import cn.enaium.joe.wrapper.Wrapper;
2122
import org.objectweb.asm.Handle;
@@ -40,7 +41,7 @@ public BootstrapMethodArgumentEditPanel(Wrapper<Object[]> wrapper) {
4041
}
4142
add(new JScrollPane(objectJList), BorderLayout.CENTER);
4243
add(new JPanel() {{
43-
add(new JButton("Add") {{
44+
add(new JButton(LangUtil.i18n("button.add")) {{
4445
addActionListener(e -> {
4546
MessageUtil.confirm(new ConfirmPanel() {{
4647
setLayout(new BorderLayout());
@@ -49,9 +50,9 @@ public BootstrapMethodArgumentEditPanel(Wrapper<Object[]> wrapper) {
4950
add(left, BorderLayout.WEST);
5051
add(right, BorderLayout.CENTER);
5152
JComboBox<String> jComboBox = new JComboBox<>(new String[]{"String", "float", "double", "int", "long", "Class"});
52-
left.add(new JLabel("Type:"));
53+
left.add(new JLabel(LangUtil.i18n("instruction.type")));
5354
right.add(jComboBox);
54-
left.add(new JLabel("Var:"));
55+
left.add(new JLabel(LangUtil.i18n("instruction.var")));
5556
JTextField ldc = new JTextField();
5657
right.add(ldc);
5758
setConfirm(() -> {
@@ -79,7 +80,7 @@ public BootstrapMethodArgumentEditPanel(Wrapper<Object[]> wrapper) {
7980
objectDefaultListModel.addElement(value);
8081
}
8182
});
82-
}}, "Add");
83+
}}, LangUtil.i18n("button.add"));
8384
});
8485
}});
8586
add(new JButton("Add Handle") {{
@@ -93,7 +94,7 @@ public BootstrapMethodArgumentEditPanel(Wrapper<Object[]> wrapper) {
9394
});
9495
});
9596
}});
96-
add(new JButton("Remove") {{
97+
add(new JButton(LangUtil.i18n("button.remove")) {{
9798
addActionListener(e -> {
9899
if (objectJList.getSelectedIndex() != -1) {
99100
objectDefaultListModel.remove(objectJList.getSelectedIndex());

src/main/java/cn/enaium/joe/gui/panel/confirm/FrameListEditPanel.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

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

19+
import cn.enaium.joe.util.LangUtil;
1920
import cn.enaium.joe.util.MessageUtil;
2021
import cn.enaium.joe.util.OpcodeUtil;
2122
import cn.enaium.joe.util.StringUtil;
@@ -106,7 +107,7 @@ public ObjectList(List<Object> list) {
106107
});
107108
});
108109
}});
109-
add(new JButton("Remove") {{
110+
add(new JButton(LangUtil.i18n("button.remove")) {{
110111
addActionListener(e -> {
111112
if (jList.getSelectedIndex() != -1) {
112113
stringDefaultListModel.remove(jList.getSelectedIndex());

0 commit comments

Comments
 (0)