Skip to content

Commit

Permalink
select correct tab opcodechooser
Browse files Browse the repository at this point in the history
  • Loading branch information
GraxCode committed Aug 11, 2019
1 parent 061a743 commit 8b027b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/me/nov/cafebabe/gui/opchooser/OpcodeChooserPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public OpcodeChooserPane(OpcodeChooserDialog chooser, AbstractInsnNode ain) {
CALOAD, SALOAD, IASTORE, LASTORE, FASTORE, DASTORE, AASTORE, BASTORE, CASTORE, SASTORE))));
this.addTab(Translations.get("Other"), new JScrollPane(
addList(new OpList(chooser, TABLESWITCH, LOOKUPSWITCH, MONITORENTER, MONITOREXIT, IINC, NOP, JSR, RET))));
this.refresh();
}

private OpList addList(OpList opList) {
Expand All @@ -54,8 +55,11 @@ private OpList addList(OpList opList) {
}

public void refresh() {
for (OpList ol : lists) {
ol.refresh();
for (int i = 0; i < lists.size(); i++) {
OpList ol = lists.get(i);
if(ol.refresh()) {
setSelectedIndex(i);
}
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/me/nov/cafebabe/gui/smalleditor/list/OpList.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public OpList(OpcodeChooserDialog chooser, int... opcodes) {
llm.addElement(new OpcodeNode(opcode));
}
this.setModel(llm);
this.refresh();
this.repaint();
for (MouseListener ml : this.getMouseListeners())
this.removeMouseListener(ml);
this.addMouseListener(new MouseAdapter() {
Expand All @@ -43,16 +41,19 @@ public void mouseClicked(MouseEvent evt) {

}

public void refresh() {
public boolean refresh() {
clearSelection();
int i = 0;
if (opcodes != null)
for (int opcode : opcodes) {
if (chooser.getOpcode() == opcode) {
setSelectedIndex(i);
super.repaint();
return true;
}
i++;
}
super.repaint();
return false;
}
}

0 comments on commit 8b027b4

Please sign in to comment.