Search in sources :

Example 1 with BackgroundExecutor

use of jadx.gui.jobs.BackgroundExecutor in project jadx by skylot.

the class QuarkManager method start.

public void start() {
    if (!checkFileSize(LARGE_APK_SIZE)) {
        int result = JOptionPane.showConfirmDialog(mainWindow, "The selected file size is too large (over 30M) that may take a long time to analyze, do you want to continue", "Quark: Warning", JOptionPane.YES_NO_OPTION);
        if (result == JOptionPane.NO_OPTION) {
            return;
        }
    }
    BackgroundExecutor executor = mainWindow.getBackgroundExecutor();
    executor.execute("Quark install", this::checkInstall, installStatus -> executor.execute("Quark analysis", this::startAnalysis, analysisStatus -> loadReport()));
}
Also used : SystemInfo(jadx.gui.utils.SystemInfo) Logger(org.slf4j.Logger) Files(java.nio.file.Files) LoggerFactory(org.slf4j.LoggerFactory) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException) JOptionPane(javax.swing.JOptionPane) InputStreamReader(java.io.InputStreamReader) File(java.io.File) ArrayList(java.util.ArrayList) BackgroundExecutor(jadx.gui.jobs.BackgroundExecutor) List(java.util.List) Paths(java.nio.file.Paths) UiUtils(jadx.gui.utils.UiUtils) JRoot(jadx.gui.treemodel.JRoot) BufferedReader(java.io.BufferedReader) MainWindow(jadx.gui.ui.MainWindow) Path(java.nio.file.Path) BackgroundExecutor(jadx.gui.jobs.BackgroundExecutor)

Example 2 with BackgroundExecutor

use of jadx.gui.jobs.BackgroundExecutor in project jadx by skylot.

the class QuarkReportPanel method buildTree.

private JTree buildTree() {
    JTree tree = new JTree(treeRoot);
    tree.setLayout(new BorderLayout());
    tree.setBorder(BorderFactory.createEmptyBorder());
    tree.setShowsRootHandles(false);
    tree.setScrollsOnExpand(false);
    tree.setSelectionModel(null);
    tree.setCellRenderer(cellRenderer);
    tree.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent event) {
            if (SwingUtilities.isLeftMouseButton(event)) {
                Object node = getNodeUnderMouse(tree, event);
                if (node instanceof MethodTreeNode) {
                    JMethod method = ((MethodTreeNode) node).getJMethod();
                    BackgroundExecutor executor = tabbedPane.getMainWindow().getBackgroundExecutor();
                    executor.execute("Decompiling class", () -> tabbedPane.codeJump(method), // TODO: fix bug with incorrect jump on just decompiled code
                    status -> tabbedPane.codeJump(method));
                }
            }
        }
    });
    tree.addTreeExpansionListener(new TreeExpansionListener() {

        @Override
        public void treeExpanded(TreeExpansionEvent event) {
            TreePath path = event.getPath();
            Object leaf = path.getLastPathComponent();
            if (leaf instanceof CrimeTreeNode) {
                CrimeTreeNode node = (CrimeTreeNode) leaf;
                Enumeration<TreeNode> children = node.children();
                while (children.hasMoreElements()) {
                    TreeNode child = children.nextElement();
                    tree.expandPath(path.pathByAddingChild(child));
                }
            }
        }

        @Override
        public void treeCollapsed(TreeExpansionEvent event) {
        }
    });
    return tree;
}
Also used : TreeExpansionEvent(javax.swing.event.TreeExpansionEvent) Enumeration(java.util.Enumeration) TreeNode(javax.swing.tree.TreeNode) LoggerFactory(org.slf4j.LoggerFactory) TabbedPane(jadx.gui.ui.TabbedPane) JsonElement(com.google.gson.JsonElement) SwingUtilities(javax.swing.SwingUtilities) Map(java.util.Map) MouseAdapter(java.awt.event.MouseAdapter) JEditorPane(javax.swing.JEditorPane) BorderLayout(java.awt.BorderLayout) ScrollPaneConstants(javax.swing.ScrollPaneConstants) JMethod(jadx.gui.treemodel.JMethod) IdentityHashMap(java.util.IdentityHashMap) Logger(org.slf4j.Logger) TreePath(javax.swing.tree.TreePath) Font(java.awt.Font) BorderFactory(javax.swing.BorderFactory) StringEscapeUtils(org.apache.commons.text.StringEscapeUtils) ContentPanel(jadx.gui.ui.panel.ContentPanel) JTree(javax.swing.JTree) JavaClass(jadx.api.JavaClass) Component(java.awt.Component) MouseEvent(java.awt.event.MouseEvent) MutableTreeNode(javax.swing.tree.MutableTreeNode) JadxWrapper(jadx.gui.JadxWrapper) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) JScrollPane(javax.swing.JScrollPane) BackgroundExecutor(jadx.gui.jobs.BackgroundExecutor) List(java.util.List) JsonArray(com.google.gson.JsonArray) TreeCellRenderer(javax.swing.tree.TreeCellRenderer) Strings(com.beust.jcommander.Strings) JLabel(javax.swing.JLabel) JNodeCache(jadx.gui.utils.JNodeCache) Comparator(java.util.Comparator) JavaMethod(jadx.api.JavaMethod) MainWindow(jadx.gui.ui.MainWindow) TreeExpansionListener(javax.swing.event.TreeExpansionListener) JPanel(javax.swing.JPanel) Utils(jadx.core.utils.Utils) BackgroundExecutor(jadx.gui.jobs.BackgroundExecutor) TreeExpansionListener(javax.swing.event.TreeExpansionListener) MouseEvent(java.awt.event.MouseEvent) Enumeration(java.util.Enumeration) MouseAdapter(java.awt.event.MouseAdapter) JTree(javax.swing.JTree) BorderLayout(java.awt.BorderLayout) TreePath(javax.swing.tree.TreePath) TreeNode(javax.swing.tree.TreeNode) MutableTreeNode(javax.swing.tree.MutableTreeNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) JMethod(jadx.gui.treemodel.JMethod) TreeExpansionEvent(javax.swing.event.TreeExpansionEvent)

Aggregations

BackgroundExecutor (jadx.gui.jobs.BackgroundExecutor)2 MainWindow (jadx.gui.ui.MainWindow)2 List (java.util.List)2 Logger (org.slf4j.Logger)2 Strings (com.beust.jcommander.Strings)1 JsonArray (com.google.gson.JsonArray)1 JsonElement (com.google.gson.JsonElement)1 JavaClass (jadx.api.JavaClass)1 JavaMethod (jadx.api.JavaMethod)1 Utils (jadx.core.utils.Utils)1 JadxRuntimeException (jadx.core.utils.exceptions.JadxRuntimeException)1 JadxWrapper (jadx.gui.JadxWrapper)1 JMethod (jadx.gui.treemodel.JMethod)1 JRoot (jadx.gui.treemodel.JRoot)1 TabbedPane (jadx.gui.ui.TabbedPane)1 ContentPanel (jadx.gui.ui.panel.ContentPanel)1 JNodeCache (jadx.gui.utils.JNodeCache)1 SystemInfo (jadx.gui.utils.SystemInfo)1 UiUtils (jadx.gui.utils.UiUtils)1 BorderLayout (java.awt.BorderLayout)1