Search in sources :

Example 1 with JadxProject

use of jadx.gui.settings.JadxProject in project jadx by skylot.

the class CommentDialog method updateCommentsData.

private static void updateCommentsData(CodeArea codeArea, Consumer<List<ICodeComment>> updater) {
    try {
        JadxProject project = codeArea.getProject();
        JadxCodeData codeData = project.getCodeData();
        if (codeData == null) {
            codeData = new JadxCodeData();
        }
        List<ICodeComment> list = new ArrayList<>(codeData.getComments());
        updater.accept(list);
        Collections.sort(list);
        codeData.setComments(list);
        project.setCodeData(codeData);
        codeArea.getMainWindow().getWrapper().getDecompiler().reloadCodeData();
    } catch (Exception e) {
        LOG.error("Comment action failed", e);
    }
    try {
        // refresh code
        codeArea.refreshClass();
    } catch (Exception e) {
        LOG.error("Failed to reload code", e);
    }
}
Also used : ICodeComment(jadx.api.data.ICodeComment) ArrayList(java.util.ArrayList) JadxProject(jadx.gui.settings.JadxProject) JadxCodeData(jadx.api.data.impl.JadxCodeData)

Example 2 with JadxProject

use of jadx.gui.settings.JadxProject in project jadx by skylot.

the class CommentDialog method searchForExistComment.

private static ICodeComment searchForExistComment(CodeArea codeArea, ICodeComment blankComment) {
    try {
        JadxProject project = codeArea.getProject();
        JadxCodeData codeData = project.getCodeData();
        if (codeData == null || codeData.getComments().isEmpty()) {
            return null;
        }
        for (ICodeComment comment : codeData.getComments()) {
            if (Objects.equals(comment.getNodeRef(), blankComment.getNodeRef()) && Objects.equals(comment.getCodeRef(), blankComment.getCodeRef())) {
                return comment;
            }
        }
    } catch (Exception e) {
        LOG.error("Error searching for exists comment", e);
    }
    return null;
}
Also used : ICodeComment(jadx.api.data.ICodeComment) JadxProject(jadx.gui.settings.JadxProject) JadxCodeData(jadx.api.data.impl.JadxCodeData)

Example 3 with JadxProject

use of jadx.gui.settings.JadxProject in project jadx by skylot.

the class RenameDialog method updateCodeRenames.

private void updateCodeRenames(Consumer<Set<ICodeRename>> updater) {
    JadxProject project = mainWindow.getProject();
    JadxCodeData codeData = project.getCodeData();
    if (codeData == null) {
        codeData = new JadxCodeData();
    }
    Set<ICodeRename> set = new HashSet<>(codeData.getRenames());
    updater.accept(set);
    List<ICodeRename> list = new ArrayList<>(set);
    Collections.sort(list);
    codeData.setRenames(list);
    project.setCodeData(codeData);
    mainWindow.getWrapper().getDecompiler().reloadCodeData();
}
Also used : ICodeRename(jadx.api.data.ICodeRename) ArrayList(java.util.ArrayList) JadxProject(jadx.gui.settings.JadxProject) JadxCodeData(jadx.api.data.impl.JadxCodeData) HashSet(java.util.HashSet)

Example 4 with JadxProject

use of jadx.gui.settings.JadxProject in project jadx by skylot.

the class MainWindow method openProject.

private void openProject(Path path) {
    if (!ensureProjectIsSaved()) {
        return;
    }
    JadxProject jadxProject = JadxProject.from(path);
    if (jadxProject == null) {
        JOptionPane.showMessageDialog(this, NLS.str("msg.project_error"), NLS.str("msg.project_error_title"), JOptionPane.INFORMATION_MESSAGE);
        jadxProject = new JadxProject();
    }
    updateProject(jadxProject);
    settings.addRecentProject(path);
    List<Path> filePaths = jadxProject.getFilePaths();
    if (filePaths == null) {
        clearTree();
    } else {
        open(filePaths);
    }
}
Also used : Path(java.nio.file.Path) TreePath(javax.swing.tree.TreePath) JadxProject(jadx.gui.settings.JadxProject)

Example 5 with JadxProject

use of jadx.gui.settings.JadxProject in project jadx by skylot.

the class MainWindow method newProject.

private void newProject() {
    if (!ensureProjectIsSaved()) {
        return;
    }
    cancelBackgroundJobs();
    clearTree();
    wrapper.close();
    updateProject(new JadxProject());
}
Also used : JadxProject(jadx.gui.settings.JadxProject)

Aggregations

JadxProject (jadx.gui.settings.JadxProject)5 JadxCodeData (jadx.api.data.impl.JadxCodeData)3 ICodeComment (jadx.api.data.ICodeComment)2 ArrayList (java.util.ArrayList)2 ICodeRename (jadx.api.data.ICodeRename)1 Path (java.nio.file.Path)1 HashSet (java.util.HashSet)1 TreePath (javax.swing.tree.TreePath)1