use of jadx.gui.ui.panel.ContentPanel in project jadx by skylot.
the class TabbedPane method smaliJump.
public void smaliJump(JClass cls, int pos, boolean debugMode) {
ContentPanel panel = getOpenTabs().get(cls);
if (panel == null) {
showCode(new JumpPosition(cls, 0, 1));
panel = getOpenTabs().get(cls);
if (panel == null) {
throw new JadxRuntimeException("Failed to open panel for JClass: " + cls);
}
} else {
selectTab(panel);
}
ClassCodeContentPanel codePane = ((ClassCodeContentPanel) panel);
codePane.showSmaliPane();
SmaliArea smaliArea = (SmaliArea) codePane.getSmaliCodeArea();
if (debugMode) {
smaliArea.scrollToDebugPos(pos);
}
smaliArea.scrollToPos(pos);
smaliArea.requestFocus();
}
use of jadx.gui.ui.panel.ContentPanel in project jadx by skylot.
the class MainWindow method syncWithEditor.
public void syncWithEditor() {
ContentPanel selectedContentPanel = tabbedPane.getSelectedCodePanel();
if (selectedContentPanel == null) {
return;
}
JNode node = selectedContentPanel.getNode();
if (node.getParent() == null && treeRoot != null) {
// node not register in tree
node = treeRoot.searchNode(node);
if (node == null) {
LOG.error("Class not found in tree");
return;
}
}
TreeNode[] pathNodes = treeModel.getPathToRoot(node);
if (pathNodes == null) {
return;
}
TreePath path = new TreePath(pathNodes);
tree.setSelectionPath(path);
tree.makeVisible(path);
tree.scrollPathToVisible(path);
tree.requestFocus();
}
use of jadx.gui.ui.panel.ContentPanel in project jadx by skylot.
the class TabbedPane method enableSwitchingTabs.
private void enableSwitchingTabs() {
addChangeListener(e -> {
ContentPanel tab = getSelectedCodePanel();
if (tab == null) {
// all closed
curTab = null;
lastTab = null;
return;
}
FocusManager.focusOnCodePanel(tab);
if (tab == curTab) {
// a tab was closed by not the current one.
if (lastTab != null && indexOfComponent(lastTab) == -1) {
// lastTab was closed
setLastTabAdjacentToCurTab();
}
return;
}
if (tab == lastTab) {
if (indexOfComponent(curTab) == -1) {
// curTab was closed and lastTab is the current one.
curTab = lastTab;
setLastTabAdjacentToCurTab();
return;
}
// it's switching between lastTab and curTab.
}
lastTab = curTab;
curTab = tab;
});
}
use of jadx.gui.ui.panel.ContentPanel in project jadx by skylot.
the class TabComponent method createTabPopupMenu.
private JPopupMenu createTabPopupMenu(final ContentPanel contentPanel) {
JPopupMenu menu = new JPopupMenu();
String nodeFullName = getNodeFullName(contentPanel);
if (nodeFullName != null) {
JMenuItem copyRootClassName = new JMenuItem(NLS.str("tabs.copy_class_name"));
copyRootClassName.addActionListener(actionEvent -> UiUtils.setClipboardString(nodeFullName));
menu.add(copyRootClassName);
menu.addSeparator();
}
JMenuItem closeTab = new JMenuItem(NLS.str("tabs.close"));
closeTab.addActionListener(e -> tabbedPane.closeCodePanel(contentPanel));
menu.add(closeTab);
Map<JNode, ContentPanel> openTabs = tabbedPane.getOpenTabs();
if (openTabs.size() > 1) {
JMenuItem closeOther = new JMenuItem(NLS.str("tabs.closeOthers"));
closeOther.addActionListener(e -> {
List<ContentPanel> contentPanels = new ArrayList<>(openTabs.values());
for (ContentPanel panel : contentPanels) {
if (panel != contentPanel) {
tabbedPane.closeCodePanel(panel);
}
}
});
menu.add(closeOther);
JMenuItem closeAll = new JMenuItem(NLS.str("tabs.closeAll"));
closeAll.addActionListener(e -> tabbedPane.closeAllTabs());
menu.add(closeAll);
menu.addSeparator();
ContentPanel selectedContentPanel = tabbedPane.getSelectedCodePanel();
for (final Map.Entry<JNode, ContentPanel> entry : openTabs.entrySet()) {
final ContentPanel cp = entry.getValue();
if (cp == selectedContentPanel) {
continue;
}
JNode node = entry.getKey();
final String clsName = node.makeLongString();
JMenuItem item = new JMenuItem(clsName);
item.addActionListener(e -> tabbedPane.setSelectedComponent(cp));
item.setIcon(node.getIcon());
menu.add(item);
}
}
return menu;
}
Aggregations