General Refactoring
This commit is contained in:
parent
16c2eef1d9
commit
b5c87e4eef
|
@ -38,7 +38,7 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||||
public final class ASMResourceUtil
|
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)
|
public static String findMainMethod(String defaultFQN)
|
||||||
{
|
{
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class BCV
|
||||||
/**
|
/**
|
||||||
* Grab the loader instance
|
* Grab the loader instance
|
||||||
*
|
*
|
||||||
* @return
|
* @return the static ClassNodeLoader instance
|
||||||
*/
|
*/
|
||||||
public static ClassNodeLoader getClassNodeLoader() {
|
public static ClassNodeLoader getClassNodeLoader() {
|
||||||
return loader;
|
return loader;
|
||||||
|
|
|
@ -154,38 +154,46 @@ public class ClassViewer extends ResourceViewer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPanes() {
|
public void setPanes()
|
||||||
|
{
|
||||||
bytecodeViewPanel1.decompiler = BytecodeViewer.viewer.viewPane1.getSelectedDecompiler();
|
bytecodeViewPanel1.decompiler = BytecodeViewer.viewer.viewPane1.getSelectedDecompiler();
|
||||||
bytecodeViewPanel2.decompiler = BytecodeViewer.viewer.viewPane2.getSelectedDecompiler();
|
bytecodeViewPanel2.decompiler = BytecodeViewer.viewer.viewPane2.getSelectedDecompiler();
|
||||||
bytecodeViewPanel3.decompiler = BytecodeViewer.viewer.viewPane3.getSelectedDecompiler();
|
bytecodeViewPanel3.decompiler = BytecodeViewer.viewer.viewPane3.getSelectedDecompiler();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPanel1Editable() {
|
public boolean isPanel1Editable()
|
||||||
|
{
|
||||||
setPanes();
|
setPanes();
|
||||||
return BytecodeViewer.viewer.viewPane1.isPaneEditable();
|
return BytecodeViewer.viewer.viewPane1.isPaneEditable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPanel2Editable() {
|
public boolean isPanel2Editable()
|
||||||
|
{
|
||||||
setPanes();
|
setPanes();
|
||||||
return BytecodeViewer.viewer.viewPane2.isPaneEditable();
|
return BytecodeViewer.viewer.viewPane2.isPaneEditable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPanel3Editable() {
|
public boolean isPanel3Editable()
|
||||||
|
{
|
||||||
setPanes();
|
setPanes();
|
||||||
return BytecodeViewer.viewer.viewPane3.isPaneEditable();
|
return BytecodeViewer.viewer.viewPane3.isPaneEditable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void selectMethod(RSyntaxTextArea area, int methodLine) {
|
public static void selectMethod(RSyntaxTextArea area, int methodLine)
|
||||||
if (methodLine != area.getCaretLineNumber()) {
|
{
|
||||||
|
if (methodLine != area.getCaretLineNumber())
|
||||||
|
{
|
||||||
setCaretLine(area, methodLine);
|
setCaretLine(area, methodLine);
|
||||||
setViewLine(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;
|
RSyntaxTextArea area = null;
|
||||||
switch (paneId) {
|
switch (paneId)
|
||||||
|
{
|
||||||
case 0:
|
case 0:
|
||||||
area = classViewer.bytecodeViewPanel1.updateThread.updateUpdaterTextArea;
|
area = classViewer.bytecodeViewPanel1.updateThread.updateUpdaterTextArea;
|
||||||
break;
|
break;
|
||||||
|
@ -197,11 +205,14 @@ public class ClassViewer extends ResourceViewer
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (area != null) {
|
if (area != null)
|
||||||
|
{
|
||||||
MethodParser methods = classViewer.methods.get(paneId);
|
MethodParser methods = classViewer.methods.get(paneId);
|
||||||
if (methods != null) {
|
if (methods != null)
|
||||||
|
{
|
||||||
int methodLine = methods.findMethod(method);
|
int methodLine = methods.findMethod(method);
|
||||||
if (methodLine != -1) {
|
if (methodLine != -1)
|
||||||
|
{
|
||||||
selectMethod(area, methodLine);
|
selectMethod(area, methodLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -261,27 +272,31 @@ public class ClassViewer extends ResourceViewer
|
||||||
{
|
{
|
||||||
sp.setResizeWeight(0.5);
|
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);
|
setDividerLocation(sp, 0.5);
|
||||||
} else if (bytecodeViewPanel1.decompiler != Decompiler.NONE) {
|
else if (bytecodeViewPanel1.decompiler != Decompiler.NONE)
|
||||||
setDividerLocation(sp, 1);
|
setDividerLocation(sp, 1);
|
||||||
} else if (bytecodeViewPanel2.decompiler != Decompiler.NONE) {
|
else if (bytecodeViewPanel2.decompiler != Decompiler.NONE)
|
||||||
|
{
|
||||||
sp.setResizeWeight(1);
|
sp.setResizeWeight(1);
|
||||||
setDividerLocation(sp, 0);
|
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);
|
sp2.setResizeWeight(0.7);
|
||||||
setDividerLocation(sp2, 0.7);
|
setDividerLocation(sp2, 0.7);
|
||||||
if ((bytecodeViewPanel2.decompiler == Decompiler.NONE && bytecodeViewPanel1.decompiler != Decompiler.NONE)
|
if ((bytecodeViewPanel2.decompiler == Decompiler.NONE && bytecodeViewPanel1.decompiler != Decompiler.NONE)
|
||||||
|| (bytecodeViewPanel1.decompiler == Decompiler.NONE && bytecodeViewPanel2.decompiler != Decompiler.NONE)) {
|
|| (bytecodeViewPanel1.decompiler == Decompiler.NONE && bytecodeViewPanel2.decompiler != Decompiler.NONE)) {
|
||||||
setDividerLocation(sp2, 0.5);
|
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);
|
sp.setResizeWeight(1);
|
||||||
sp2.setResizeWeight(0);
|
sp2.setResizeWeight(0);
|
||||||
setDividerLocation(sp2, 1);
|
setDividerLocation(sp2, 1);
|
||||||
|
@ -294,30 +309,39 @@ public class ClassViewer extends ResourceViewer
|
||||||
*/
|
*/
|
||||||
public static JSplitPane setDividerLocation(JSplitPane splitter, double proportion)
|
public static JSplitPane setDividerLocation(JSplitPane splitter, double proportion)
|
||||||
{
|
{
|
||||||
if (splitter.isShowing()) {
|
if (splitter.isShowing())
|
||||||
if (splitter.getWidth() > 0 && splitter.getHeight() > 0) {
|
{
|
||||||
|
if (splitter.getWidth() > 0 && splitter.getHeight() > 0)
|
||||||
splitter.setDividerLocation(proportion);
|
splitter.setDividerLocation(proportion);
|
||||||
} else {
|
else
|
||||||
splitter.addComponentListener(new ComponentAdapter() {
|
{
|
||||||
|
splitter.addComponentListener(new ComponentAdapter()
|
||||||
|
{
|
||||||
@Override
|
@Override
|
||||||
public void componentResized(ComponentEvent ce) {
|
public void componentResized(ComponentEvent ce)
|
||||||
|
{
|
||||||
splitter.removeComponentListener(this);
|
splitter.removeComponentListener(this);
|
||||||
setDividerLocation(splitter, proportion);
|
setDividerLocation(splitter, proportion);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
splitter.addHierarchyListener(new HierarchyListener() {
|
else
|
||||||
|
{
|
||||||
|
splitter.addHierarchyListener(new HierarchyListener()
|
||||||
|
{
|
||||||
@Override
|
@Override
|
||||||
public void hierarchyChanged(HierarchyEvent e) {
|
public void hierarchyChanged(HierarchyEvent e)
|
||||||
if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0
|
{
|
||||||
&& splitter.isShowing()) {
|
if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0 && splitter.isShowing())
|
||||||
|
{
|
||||||
splitter.removeHierarchyListener(this);
|
splitter.removeHierarchyListener(this);
|
||||||
setDividerLocation(splitter, proportion);
|
setDividerLocation(splitter, proportion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return splitter;
|
return splitter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,8 +51,7 @@ public class ComponentViewer extends ResourceViewer
|
||||||
{
|
{
|
||||||
String workingName = containerName + title;
|
String workingName = containerName + title;
|
||||||
ComponentViewer componentViewer = new ComponentViewer(title, c);
|
ComponentViewer componentViewer = new ComponentViewer(title, c);
|
||||||
BytecodeViewer.viewer.workPane.addResourceToTab(componentViewer,
|
BytecodeViewer.viewer.workPane.addResourceToTab(componentViewer, workingName, containerName, title);
|
||||||
workingName, containerName, title);
|
|
||||||
|
|
||||||
return componentViewer;
|
return componentViewer;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user