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

Commit 8e908fe

Browse files
committed
tab index consistent
1 parent a008446 commit 8e908fe

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/main/java/cn/enaium/joe/gui/panel/file/tabbed/tab/classes/ClassTabPanel.java

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

1717
package cn.enaium.joe.gui.panel.file.tabbed.tab.classes;
1818

19+
import cn.enaium.joe.JavaOctetEditor;
20+
import cn.enaium.joe.event.Event;
1921
import cn.enaium.joe.util.LangUtil;
2022
import org.objectweb.asm.tree.ClassNode;
2123

2224
import javax.swing.*;
25+
import javax.swing.event.ChangeEvent;
26+
import javax.swing.event.ChangeListener;
2327
import java.awt.*;
28+
import java.util.function.Consumer;
2429

2530
/**
2631
* @author Enaium
@@ -35,9 +40,19 @@ public ClassTabPanel(ClassNode classNode) {
3540
JTabbedPane jTabbedPane = new JTabbedPane();
3641
jTabbedPane.setTabPlacement(JTabbedPane.BOTTOM);
3742
jTabbedPane.addTab(LangUtil.i18n("class.tab.bytecodeView"), new TraceBytecodeTabPanel(classNode));
38-
jTabbedPane.addTab(LangUtil.i18n("class.tab.decompileView"), new DecompileTabPanel(classNode));
43+
jTabbedPane.addTab(LangUtil.i18n("class.tab.decompileEdit"), new DecompileTabPanel(classNode));
3944
jTabbedPane.addTab(LangUtil.i18n("class.tab.visitorEdit"), new ASMifierTablePanel(classNode));
4045
jTabbedPane.addTab(LangUtil.i18n("class.tab.infoEdit"), new ClassInfoTabPanel(classNode));
46+
jTabbedPane.addChangeListener(e -> JavaOctetEditor.getInstance().event.call(new Change(jTabbedPane.getSelectedIndex())));
47+
JavaOctetEditor.getInstance().event.register(Change.class, (Consumer<Change>) event -> jTabbedPane.setSelectedIndex(event.index));
4148
add(jTabbedPane);
4249
}
50+
51+
private static class Change implements Event {
52+
private final int index;
53+
54+
public Change(int index) {
55+
this.index = index;
56+
}
57+
}
4358
}

0 commit comments

Comments
 (0)