Resource View Cleanup

This commit is contained in:
Konloch 2021-07-03 22:20:25 -07:00
parent ea6cacf0c1
commit 22c3f36372
2 changed files with 24 additions and 21 deletions

View file

@ -41,7 +41,6 @@ import java.awt.*;
public class ResourceViewProcessing extends PaneUpdaterThread public class ResourceViewProcessing extends PaneUpdaterThread
{ {
private final ResourceViewPanel resourceViewPanel; private final ResourceViewPanel resourceViewPanel;
private final ClassViewer cv;
private final byte[] b; private final byte[] b;
private final boolean isPanelEditable; private final boolean isPanelEditable;
private final JButton button; private final JButton button;
@ -49,9 +48,8 @@ public class ResourceViewProcessing extends PaneUpdaterThread
public ResourceViewProcessing(ResourceViewPanel resourceViewPanel, ClassViewer cv, byte[] b, boolean isPanelEditable, JButton button) public ResourceViewProcessing(ResourceViewPanel resourceViewPanel, ClassViewer cv, byte[] b, boolean isPanelEditable, JButton button)
{ {
super(resourceViewPanel.panelIndex, resourceViewPanel.decompilerViewIndex); super(cv, resourceViewPanel.panelIndex, resourceViewPanel.decompilerViewIndex);
this.resourceViewPanel = resourceViewPanel; this.resourceViewPanel = resourceViewPanel;
this.cv = cv;
this.b = b; this.b = b;
this.isPanelEditable = isPanelEditable; this.isPanelEditable = isPanelEditable;
this.button = button; this.button = button;
@ -71,28 +69,29 @@ public class ResourceViewProcessing extends PaneUpdaterThread
if (resourceViewPanel.decompilerViewIndex == 5) if (resourceViewPanel.decompilerViewIndex == 5)
{ {
final ClassWriter cw = new ClassWriter(0); final ClassWriter cw = new ClassWriter(0);
cv.cn.accept(cw); viewer.cn.accept(cw);
final JHexEditor hex = new JHexEditor(cw.toByteArray()); SwingUtilities.invokeLater(() ->
hex.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int) BytecodeViewer.viewer.fontSpinner.getValue())); {
final JHexEditor hex = new JHexEditor(cw.toByteArray());
SwingUtilities.invokeLater(() -> resourceViewPanel.panel.add(hex)); hex.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int) BytecodeViewer.viewer.fontSpinner.getValue()));
resourceViewPanel.panel.add(hex);
});
} }
else else
{ {
viewer = cv;
updateUpdaterTextArea = (SearchableRSyntaxTextArea) Configuration.rstaTheme.apply(new SearchableRSyntaxTextArea());
final Decompiler decompiler = Decompiler.decompilersByIndex.get(resourceViewPanel.decompilerViewIndex); final Decompiler decompiler = Decompiler.decompilersByIndex.get(resourceViewPanel.decompilerViewIndex);
//perform decompiling inside of this thread //perform decompiling inside of this thread
final String decompiledSource = decompiler.getDecompiler().decompileClassNode(cv.cn, b); final String decompiledSource = decompiler.getDecompiler().decompileClassNode(viewer.cn, b);
resourceViewPanel.textArea = updateUpdaterTextArea;
//set the swing components on the swing thread //set the swing components on the swing thread
SwingUtilities.invokeLater(() -> SwingUtilities.invokeLater(() ->
{ {
updateUpdaterTextArea = (SearchableRSyntaxTextArea) Configuration.rstaTheme.apply(new SearchableRSyntaxTextArea());
resourceViewPanel.textArea = updateUpdaterTextArea;
resourceViewPanel.panel.add(updateUpdaterTextArea.getScrollPane()); resourceViewPanel.panel.add(updateUpdaterTextArea.getScrollPane());
resourceViewPanel.panel.add(updateUpdaterTextArea.getTitleHeader(), BorderLayout.NORTH); resourceViewPanel.panel.add(updateUpdaterTextArea.getTitleHeader(), BorderLayout.NORTH);
@ -131,10 +130,13 @@ public class ResourceViewProcessing extends PaneUpdaterThread
} }
finally finally
{ {
cv.resetDivider(); viewer.resetDivider();
BytecodeViewer.viewer.updateBusyStatus(false); BytecodeViewer.viewer.updateBusyStatus(false);
if (button != null) SwingUtilities.invokeLater(() ->
button.setEnabled(true); {
if (button != null)
button.setEnabled(true);
});
} }
} }
} }

View file

@ -47,15 +47,16 @@ import static the.bytecode.club.bytecodeviewer.gui.resourceviewer.TabbedPane.BLA
*/ */
public abstract class PaneUpdaterThread implements Runnable public abstract class PaneUpdaterThread implements Runnable
{ {
public ClassViewer viewer; public final ClassViewer viewer;
public final int paneIndex;
public final int decompilerViewIndex;
public SearchableRSyntaxTextArea updateUpdaterTextArea; public SearchableRSyntaxTextArea updateUpdaterTextArea;
public JComboBox<Integer> methodsList; public JComboBox<Integer> methodsList;
private Thread thread; private Thread thread;
public int paneIndex;
public int decompilerViewIndex;
public PaneUpdaterThread(int paneIndex, int decompilerViewIndex) public PaneUpdaterThread(ClassViewer viewer, int paneIndex, int decompilerViewIndex)
{ {
this.viewer = viewer;
this.paneIndex = paneIndex; this.paneIndex = paneIndex;
this.decompilerViewIndex = decompilerViewIndex; this.decompilerViewIndex = decompilerViewIndex;
} }