fix(gui): minor fixes for code jumps
This commit is contained in:
@@ -269,7 +269,7 @@ public class MethodGen {
|
||||
JadxArgs args = mth.root().getArgs();
|
||||
switch (args.getDecompilationMode()) {
|
||||
case AUTO:
|
||||
if (classGen.isFallbackMode()) {
|
||||
if (classGen.isFallbackMode() || mth.getRegion() == null) {
|
||||
// TODO: try simple mode first
|
||||
dumpInstructions(code);
|
||||
} else {
|
||||
|
||||
@@ -1165,8 +1165,9 @@ public class MainWindow extends JFrame {
|
||||
ExceptionDialog.throwTestException();
|
||||
}
|
||||
});
|
||||
help.add(new JCheckBoxMenuItem(new ActionHandler("UI WatchDog", UIWatchDog::toggle)));
|
||||
UIWatchDog.onStart();
|
||||
JCheckBoxMenuItem uiWatchDog = new JCheckBoxMenuItem(new ActionHandler("UI WatchDog", UIWatchDog::toggle));
|
||||
uiWatchDog.setState(UIWatchDog.onStart());
|
||||
help.add(uiWatchDog);
|
||||
}
|
||||
help.add(aboutAction);
|
||||
|
||||
@@ -1550,6 +1551,9 @@ public class MainWindow extends JFrame {
|
||||
private void preLoadOpenTabs(List<EditorViewState> openTabs) {
|
||||
UiUtils.notUiThreadGuard();
|
||||
for (EditorViewState tabState : openTabs) {
|
||||
if (tabState.isHidden()) {
|
||||
continue;
|
||||
}
|
||||
JNode node = tabState.getNode();
|
||||
try {
|
||||
node.getCodeInfo();
|
||||
|
||||
@@ -26,6 +26,7 @@ import jadx.gui.treemodel.JClass;
|
||||
import jadx.gui.treemodel.JNode;
|
||||
import jadx.gui.treemodel.JResource;
|
||||
import jadx.gui.ui.MainWindow;
|
||||
import jadx.gui.ui.codearea.mode.JCodeMode;
|
||||
import jadx.gui.ui.panel.ContentPanel;
|
||||
import jadx.gui.utils.CaretPositionFix;
|
||||
import jadx.gui.utils.DefaultPopupMenuListener;
|
||||
@@ -51,7 +52,7 @@ public final class CodeArea extends AbstractCodeArea {
|
||||
this.shortcutsController = getMainWindow().getShortcutsController();
|
||||
|
||||
setSyntaxEditingStyle(node.getSyntaxName());
|
||||
boolean isJavaCode = node instanceof JClass;
|
||||
boolean isJavaCode = isCodeNode();
|
||||
if (isJavaCode) {
|
||||
((RSyntaxDocument) getDocument()).setSyntaxStyle(new JadxTokenMaker(this));
|
||||
}
|
||||
@@ -79,6 +80,10 @@ public final class CodeArea extends AbstractCodeArea {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCodeNode() {
|
||||
return node instanceof JClass || node instanceof JCodeMode;
|
||||
}
|
||||
|
||||
private boolean jumpOnDoubleClick(MouseEvent e) {
|
||||
return e.getClickCount() == 2 && getMainWindow().getSettings().isJumpOnDoubleClick();
|
||||
}
|
||||
@@ -174,7 +179,7 @@ public final class CodeArea extends AbstractCodeArea {
|
||||
return -1;
|
||||
}
|
||||
int type = token.getType();
|
||||
if (node instanceof JClass) {
|
||||
if (isCodeNode()) {
|
||||
if (type == TokenTypes.IDENTIFIER || type == TokenTypes.FUNCTION) {
|
||||
return token.getOffset();
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import jadx.gui.treemodel.JNode;
|
||||
import jadx.gui.ui.MainWindow;
|
||||
import jadx.gui.ui.codearea.EditorViewState;
|
||||
import jadx.gui.utils.JumpPosition;
|
||||
import jadx.gui.utils.NLS;
|
||||
|
||||
public class TabsController {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(TabsController.class);
|
||||
@@ -104,11 +103,6 @@ public class TabsController {
|
||||
return;
|
||||
}
|
||||
// node need loading
|
||||
mainWindow.getBackgroundExecutor().execute(
|
||||
NLS.str("progress.load"),
|
||||
() -> node.getRootClass().getCodeInfo(), // run heavy loading in background
|
||||
status -> codeJump(new JumpPosition(node)));
|
||||
|
||||
loadCodeWithUIAction(node.getRootClass(), () -> codeJump(new JumpPosition(node)));
|
||||
}
|
||||
|
||||
|
||||
@@ -20,15 +20,17 @@ import jadx.gui.utils.UiUtils;
|
||||
public class UIWatchDog {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(UIWatchDog.class);
|
||||
|
||||
private static final boolean RUN_ON_START = false;
|
||||
private static final boolean RUN_ON_START = true;
|
||||
|
||||
private static final int UI_MAX_DELAY_MS = 1000;
|
||||
private static final int CHECK_INTERVAL_MS = 100;
|
||||
private static final int UI_MAX_DELAY_MS = 200;
|
||||
private static final int CHECK_INTERVAL_MS = 50;
|
||||
|
||||
public static void onStart() {
|
||||
public static boolean onStart() {
|
||||
if (RUN_ON_START) {
|
||||
UiUtils.uiRun(UIWatchDog::toggle);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static synchronized void toggle() {
|
||||
|
||||
Reference in New Issue
Block a user