fix(gui): send select tab event before code jump (#2292)
This commit is contained in:
@@ -877,12 +877,7 @@ public class MainWindow extends JFrame {
|
||||
return true;
|
||||
}
|
||||
} else if (obj instanceof JNode) {
|
||||
JNode node = (JNode) obj;
|
||||
if (node.getRootClass() != null) {
|
||||
tabsController.codeJump(node);
|
||||
return true;
|
||||
}
|
||||
tabsController.selectTab(node);
|
||||
tabsController.codeJump((JNode) obj);
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -1022,7 +1017,7 @@ public class MainWindow extends JFrame {
|
||||
}
|
||||
|
||||
JResource res = new JResource(androidManifest, androidManifest.getDeobfName(), JResource.JResType.FILE);
|
||||
tabsController.selectTab(res);
|
||||
tabsController.codeJump(res);
|
||||
}
|
||||
|
||||
private void initMenuAndToolbar() {
|
||||
|
||||
@@ -284,7 +284,7 @@ public class TabComponent extends JPanel {
|
||||
JNode node = tab.getNode();
|
||||
final String clsName = node.makeLongString();
|
||||
JMenuItem item = new JMenuItem(clsName);
|
||||
item.addActionListener(e -> tabsController.selectTab(node));
|
||||
item.addActionListener(e -> tabsController.codeJump(node));
|
||||
item.setIcon(node.getIcon());
|
||||
menu.add(item);
|
||||
}
|
||||
|
||||
@@ -98,10 +98,15 @@ public class TabsController {
|
||||
}
|
||||
|
||||
// Not an inline node, jump normally
|
||||
if (node.getPos() != 0 || node.getRootClass() == null) {
|
||||
if (node.getPos() > 0) {
|
||||
codeJump(new JumpPosition(node));
|
||||
return;
|
||||
}
|
||||
if (node.getRootClass() == null) {
|
||||
// not a class, select tab without position scroll
|
||||
selectTab(node);
|
||||
return;
|
||||
}
|
||||
// node need loading
|
||||
loadCodeWithUIAction(node.getRootClass(), () -> codeJump(new JumpPosition(node)));
|
||||
}
|
||||
@@ -140,15 +145,15 @@ public class TabsController {
|
||||
* Prefer {@link TabsController#codeJump(JNode)} method
|
||||
*/
|
||||
public void codeJump(JumpPosition pos) {
|
||||
if (selectedTab == null) {
|
||||
LOG.warn("Cannot codeJump because selectedTab is null");
|
||||
return;
|
||||
if (selectedTab == null || selectedTab.getNode() != pos.getNode()) {
|
||||
selectTab(pos.getNode());
|
||||
}
|
||||
listeners.forEach(l -> l.onTabCodeJump(selectedTab, pos));
|
||||
}
|
||||
|
||||
public void smaliJump(JClass cls, int pos, boolean debugMode) {
|
||||
TabBlueprint blueprint = openTab(cls);
|
||||
selectTab(cls);
|
||||
TabBlueprint blueprint = getTabByNode(cls);
|
||||
listeners.forEach(l -> l.onTabSmaliJump(blueprint, pos, debugMode));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user