Skip to content

Commit

Permalink
General Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Konloch committed Aug 21, 2024
1 parent 16c2eef commit b5c87e4
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
public final class ASMResourceUtil
{
/**
* Attempts to a method main inside of the loaded resources and returns the fully qualified name
* Attempts to a method main inside the loaded resources and returns the fully qualified name
*/
public static String findMainMethod(String defaultFQN)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class BCV
/**
* Grab the loader instance
*
* @return
* @return the static ClassNodeLoader instance
*/
public static ClassNodeLoader getClassNodeLoader() {
return loader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,38 +154,46 @@ public void refresh(JButton button)
}
}

public void setPanes() {
public void setPanes()
{
bytecodeViewPanel1.decompiler = BytecodeViewer.viewer.viewPane1.getSelectedDecompiler();
bytecodeViewPanel2.decompiler = BytecodeViewer.viewer.viewPane2.getSelectedDecompiler();
bytecodeViewPanel3.decompiler = BytecodeViewer.viewer.viewPane3.getSelectedDecompiler();
}

public boolean isPanel1Editable() {
public boolean isPanel1Editable()
{
setPanes();
return BytecodeViewer.viewer.viewPane1.isPaneEditable();
}

public boolean isPanel2Editable() {
public boolean isPanel2Editable()
{
setPanes();
return BytecodeViewer.viewer.viewPane2.isPaneEditable();
}

public boolean isPanel3Editable() {
public boolean isPanel3Editable()
{
setPanes();
return BytecodeViewer.viewer.viewPane3.isPaneEditable();
}


public static void selectMethod(RSyntaxTextArea area, int methodLine) {
if (methodLine != area.getCaretLineNumber()) {
public static void selectMethod(RSyntaxTextArea area, int methodLine)
{
if (methodLine != area.getCaretLineNumber())
{
setCaretLine(area, methodLine);
setViewLine(area, methodLine);
}
}

public static void selectMethod(ClassViewer classViewer, int paneId, Method method) {
public static void selectMethod(ClassViewer classViewer, int paneId, Method method)
{
RSyntaxTextArea area = null;
switch (paneId) {
switch (paneId)
{
case 0:
area = classViewer.bytecodeViewPanel1.updateThread.updateUpdaterTextArea;
break;
Expand All @@ -197,11 +205,14 @@ public static void selectMethod(ClassViewer classViewer, int paneId, Method meth
break;
}

if (area != null) {
if (area != null)
{
MethodParser methods = classViewer.methods.get(paneId);
if (methods != null) {
if (methods != null)
{
int methodLine = methods.findMethod(method);
if (methodLine != -1) {
if (methodLine != -1)
{
selectMethod(area, methodLine);
}
}
Expand Down Expand Up @@ -261,27 +272,31 @@ public void resetDivider()
{
sp.setResizeWeight(0.5);

if (bytecodeViewPanel2.decompiler != Decompiler.NONE && bytecodeViewPanel1.decompiler != Decompiler.NONE) {
if (bytecodeViewPanel2.decompiler != Decompiler.NONE && bytecodeViewPanel1.decompiler != Decompiler.NONE)
setDividerLocation(sp, 0.5);
} else if (bytecodeViewPanel1.decompiler != Decompiler.NONE) {
else if (bytecodeViewPanel1.decompiler != Decompiler.NONE)
setDividerLocation(sp, 1);
} else if (bytecodeViewPanel2.decompiler != Decompiler.NONE) {
else if (bytecodeViewPanel2.decompiler != Decompiler.NONE)
{
sp.setResizeWeight(1);
setDividerLocation(sp, 0);
} else {
setDividerLocation(sp, 0);
}
else
setDividerLocation(sp, 0);

if (bytecodeViewPanel3.decompiler != Decompiler.NONE) {
if (bytecodeViewPanel3.decompiler != Decompiler.NONE)
{
sp2.setResizeWeight(0.7);
setDividerLocation(sp2, 0.7);
if ((bytecodeViewPanel2.decompiler == Decompiler.NONE && bytecodeViewPanel1.decompiler != Decompiler.NONE)
|| (bytecodeViewPanel1.decompiler == Decompiler.NONE && bytecodeViewPanel2.decompiler != Decompiler.NONE)) {
setDividerLocation(sp2, 0.5);
} else if (bytecodeViewPanel1.decompiler == Decompiler.NONE) {
setDividerLocation(sp2, 0);
}
} else {
else if (bytecodeViewPanel1.decompiler == Decompiler.NONE)
setDividerLocation(sp2, 0);
}
else
{
sp.setResizeWeight(1);
sp2.setResizeWeight(0);
setDividerLocation(sp2, 1);
Expand All @@ -294,30 +309,39 @@ public void resetDivider()
*/
public static JSplitPane setDividerLocation(JSplitPane splitter, double proportion)
{
if (splitter.isShowing()) {
if (splitter.getWidth() > 0 && splitter.getHeight() > 0) {
if (splitter.isShowing())
{
if (splitter.getWidth() > 0 && splitter.getHeight() > 0)
splitter.setDividerLocation(proportion);
} else {
splitter.addComponentListener(new ComponentAdapter() {
else
{
splitter.addComponentListener(new ComponentAdapter()
{
@Override
public void componentResized(ComponentEvent ce) {
public void componentResized(ComponentEvent ce)
{
splitter.removeComponentListener(this);
setDividerLocation(splitter, proportion);
}
});
}
} else {
splitter.addHierarchyListener(new HierarchyListener() {
}
else
{
splitter.addHierarchyListener(new HierarchyListener()
{
@Override
public void hierarchyChanged(HierarchyEvent e) {
if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0
&& splitter.isShowing()) {
public void hierarchyChanged(HierarchyEvent e)
{
if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0 && splitter.isShowing())
{
splitter.removeHierarchyListener(this);
setDividerLocation(splitter, proportion);
}
}
});
}

return splitter;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ public static ComponentViewer addComponentAsTab(String title, Component c)
{
String workingName = containerName + title;
ComponentViewer componentViewer = new ComponentViewer(title, c);
BytecodeViewer.viewer.workPane.addResourceToTab(componentViewer,
workingName, containerName, title);
BytecodeViewer.viewer.workPane.addResourceToTab(componentViewer, workingName, containerName, title);

return componentViewer;
}
Expand Down

0 comments on commit b5c87e4

Please sign in to comment.