Search in sources :

Example 6 with ContentPanel

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();
}
Also used : JumpPosition(jadx.gui.utils.JumpPosition) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException) ClassCodeContentPanel(jadx.gui.ui.codearea.ClassCodeContentPanel) AbstractCodeContentPanel(jadx.gui.ui.codearea.AbstractCodeContentPanel) ClassCodeContentPanel(jadx.gui.ui.codearea.ClassCodeContentPanel) ContentPanel(jadx.gui.ui.panel.ContentPanel) SmaliArea(jadx.gui.ui.codearea.SmaliArea)

Example 7 with ContentPanel

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();
}
Also used : TreePath(javax.swing.tree.TreePath) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreeNode(javax.swing.tree.TreeNode) JNode(jadx.gui.treemodel.JNode) ContentPanel(jadx.gui.ui.panel.ContentPanel) AbstractCodeContentPanel(jadx.gui.ui.codearea.AbstractCodeContentPanel)

Example 8 with ContentPanel

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;
    });
}
Also used : AbstractCodeContentPanel(jadx.gui.ui.codearea.AbstractCodeContentPanel) ClassCodeContentPanel(jadx.gui.ui.codearea.ClassCodeContentPanel) ContentPanel(jadx.gui.ui.panel.ContentPanel)

Example 9 with ContentPanel

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;
}
Also used : ArrayList(java.util.ArrayList) JNode(jadx.gui.treemodel.JNode) JMenuItem(javax.swing.JMenuItem) Map(java.util.Map) JPopupMenu(javax.swing.JPopupMenu) ContentPanel(jadx.gui.ui.panel.ContentPanel)

Aggregations

ContentPanel (jadx.gui.ui.panel.ContentPanel)9 AbstractCodeContentPanel (jadx.gui.ui.codearea.AbstractCodeContentPanel)7 ClassCodeContentPanel (jadx.gui.ui.codearea.ClassCodeContentPanel)6 JNode (jadx.gui.treemodel.JNode)4 JClass (jadx.gui.treemodel.JClass)2 JumpPosition (jadx.gui.utils.JumpPosition)2 Nullable (org.jetbrains.annotations.Nullable)2 Level (ch.qos.logback.classic.Level)1 EMPTY_RUNNABLE (io.reactivex.internal.functions.Functions.EMPTY_RUNNABLE)1 JadxArgs (jadx.api.JadxArgs)1 JavaNode (jadx.api.JavaNode)1 ResourceFile (jadx.api.ResourceFile)1 StringUtils (jadx.core.utils.StringUtils)1 Utils (jadx.core.utils.Utils)1 JadxRuntimeException (jadx.core.utils.exceptions.JadxRuntimeException)1 FileUtils (jadx.core.utils.files.FileUtils)1 JadxWrapper (jadx.gui.JadxWrapper)1 BreakpointManager (jadx.gui.device.debugger.BreakpointManager)1 BackgroundExecutor (jadx.gui.jobs.BackgroundExecutor)1 DecompileTask (jadx.gui.jobs.DecompileTask)1