Skip to content

Commit

Permalink
Indentation in decompilers to 4 spaces, fixed some threading issues
Browse files Browse the repository at this point in the history
  • Loading branch information
SuspiciousActivity committed Mar 11, 2021
1 parent 71437ea commit 71c224f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 26 deletions.
3 changes: 1 addition & 2 deletions src/me/ByteEdit/boxes/TypeOpenBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ public TypeOpenBox() {
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));
}
}
Expand Down
1 change: 1 addition & 0 deletions src/me/ByteEdit/decompiler/FernflowerDecompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public String doDecompilation(ClassNode cn, byte[] b) {
for (Entry<String, Boolean> entry : options.entrySet()) {
map.put(entry.getKey(), entry.getValue() ? "1" : "0");
}
map.put("ind", " ");
Fernflower f = new Fernflower(this, this, map, new IFernflowerLogger() {
@Override
public void writeMessage(String message, Throwable t) {
Expand Down
2 changes: 1 addition & 1 deletion src/me/ByteEdit/decompiler/JDDecompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public byte[] load(String internalName) throws LoaderException {
return cw.toByteArray();
}

protected static final String TAB = " ";
protected static final String TAB = " ";
protected static final String NEWLINE = "\n";

protected int indentationCount = 0;
Expand Down
3 changes: 1 addition & 2 deletions src/me/ByteEdit/edit/TypeOpenBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ public TypeOpenBox() {
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));
}
}
Expand Down
53 changes: 32 additions & 21 deletions src/me/ByteEdit/main/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public void run() {
try {
ArchiveTreeModel model = new ArchiveTreeModel(new ZipFile(jarFile), classNodes,
otherFiles);
EventQueue.invokeLater(new Runnable() {
EventQueue.invokeAndWait(new Runnable() {
public void run() {
synchronized (treeLock) {
tree.setModel(model);
Expand All @@ -320,7 +320,7 @@ public void run() {
}
}
});
} catch (IOException e) {
} catch (Exception e) {
e.printStackTrace();
}
}
Expand Down Expand Up @@ -458,7 +458,7 @@ public void run() {
try {
ArchiveTreeModel model = new ArchiveTreeModel(new ZipFile(jarFile), classNodes,
otherFiles);
EventQueue.invokeLater(new Runnable() {
EventQueue.invokeAndWait(new Runnable() {
public void run() {
synchronized (treeLock) {
tree.setModel(model);
Expand All @@ -467,7 +467,7 @@ public void run() {
}
}
});
} catch (IOException e) {
} catch (Exception e) {
e.printStackTrace();
}
}
Expand Down Expand Up @@ -545,7 +545,7 @@ public void run() {
try {
ArchiveTreeModel model = new ArchiveTreeModel(new ZipFile(jarFile),
classNodes, otherFiles);
EventQueue.invokeLater(new Runnable() {
EventQueue.invokeAndWait(new Runnable() {
public void run() {
synchronized (treeLock) {
tree.setModel(model);
Expand All @@ -562,7 +562,7 @@ public void run() {
}
}
});
} catch (IOException e) {
} catch (Exception e) {
e.printStackTrace();
}
}
Expand Down Expand Up @@ -667,12 +667,14 @@ public void itemStateChanged(ItemEvent e) {
decompileCurrentNode();
try {
EventQueue.invokeAndWait(() -> {
txtByteEditView.setCaretPosition(0);
try {
txtByteEditView.setSyntaxEditingStyle(decompiler.getSyntaxStyle());
} catch (Throwable t) {
synchronized (treeLock) {
txtByteEditView.setCaretPosition(0);
try {
txtByteEditView.setSyntaxEditingStyle(decompiler.getSyntaxStyle());
} catch (Throwable t) {
}
txtByteEditView.setEditable(decompiler.isEditable());
}
txtByteEditView.setEditable(decompiler.isEditable());
});
} catch (Exception e1) {
e1.printStackTrace();
Expand Down Expand Up @@ -796,9 +798,14 @@ public static void decompileCurrentNode() {
}
}
}
txtByteEditView.setText(dis);
if (dis.length() > prev)
txtByteEditView.setCaretPosition(prev);
String fdis = dis;
EventQueue.invokeAndWait(() -> {
synchronized (treeLock) {
txtByteEditView.setText(fdis);
if (fdis.length() > prev)
txtByteEditView.setCaretPosition(prev);
}
});
} catch (Exception e2) {
e2.printStackTrace();
}
Expand Down Expand Up @@ -857,14 +864,18 @@ protected JDialog createDialog(final Component parent) throws HeadlessException
public void run() {
synchronized (treeLock) {
save(file, classNodes.values());
EventQueue.invokeLater(new Runnable() {
public void run() {
synchronized (treeLock) {
isChangingFile = false;
Main.this.setTitle("ByteEdit");
try {
EventQueue.invokeAndWait(new Runnable() {
public void run() {
synchronized (treeLock) {
isChangingFile = false;
Main.this.setTitle("ByteEdit");
}
}
}
});
});
} catch (Exception e) {
e.printStackTrace();
}
}
}
}).start();
Expand Down

0 comments on commit 71c224f

Please sign in to comment.