<commit_before>/*
 * AnalysisRun.java
 *
 * Created on April 1, 2003, 2:24 PM
 */

package edu.umd.cs.findbugs.gui;

import java.util.*;
import javax.swing.tree.DefaultTreeModel;
import edu.umd.cs.findbugs.*;

/**
 * Representation of a run of the FindBugs analysis on a Project.
 * This class has convenient methods which can be used to extract
 * bug reports in various interesting ways.
 *
 * @author <NAME>
 */
public class AnalysisRun {
    /**
     * Our BugReporter just puts the reported BugInstances into a HashSet.
     */
    private static class Reporter implements BugReporter {
        HashSet bugSet = new HashSet();
        
        public void finish() { }
        
        public void reportBug(edu.umd.cs.findbugs.BugInstance bugInstance) {
            bugSet.add(bugInstance);
        }
    }

    private Project project;
    private FindBugs findBugs;
    private Reporter reporter;
    private int runNumber;
    private DefaultTreeModel treeModel;
    
    /** Creates a new instance of AnalysisRun. */
    public AnalysisRun(Project project) {
        this.project = project;
        reporter = new Reporter();
        findBugs = new FindBugs(reporter);
	runNumber = project.getNextAnalysisRun();
    }
    
    /**
     * Run the analysis.
     * This should be done in a separate thread (not the GUI event thread).
     * The progress callback can be used to update the user interface to
     * reflect the progress of the analysis.  The GUI may cancel the analysis
     * by interrupting the analysis thread, in which case InterruptedException
     * will be thrown by this method.
     *
     * @param progressCallback the progress callback
     * @throws java.io.IOException if an I/O error occurs during the analysis
     * @throws InterruptedException if the analysis thread is interrupted
     */
    public void execute(FindBugsProgress progressCallback) throws java.io.IOException, InterruptedException {
        findBugs.setProgressCallback(progressCallback);
        
        // Run the analysis!
        findBugs.execute(project.getJarFileArray());
    }
    
    /**
     * Return the collection of BugInstances.
     */
    public java.util.Collection getBugInstances() {
        return reporter.bugSet;
    }
    
    /**
     * Set the tree model to be used in the BugTree.
     */
    public void setTreeModel(DefaultTreeModel treeModel) {
        this.treeModel = treeModel;
    }
    
    /**
     * Get the tree model to be used in the BugTree.
     */
    public DefaultTreeModel getTreeModel() {
        return treeModel;
    }
    
    public String toString() {
	return "Run " + runNumber;
    }
    
}<commit_msg>Added support for keeping track of the current sort order of the run's tree model.<commit_after>/*
 * AnalysisRun.java
 *
 * Created on April 1, 2003, 2:24 PM
 */

package edu.umd.cs.findbugs.gui;

import java.util.*;
import javax.swing.tree.DefaultTreeModel;
import edu.umd.cs.findbugs.*;

/**
 * Representation of a run of the FindBugs analysis on a Project.
 * This class has convenient methods which can be used to extract
 * bug reports in various interesting ways.
 *
 * @author <NAME>
 */
public class AnalysisRun {
    /**
     * Our BugReporter just puts the reported BugInstances into a HashSet.
     */
    private static class Reporter implements BugReporter {
        HashSet bugSet = new HashSet();
        
        public void finish() { }
        
        public void reportBug(edu.umd.cs.findbugs.BugInstance bugInstance) {
            bugSet.add(bugInstance);
        }
    }

    private Project project;
    private FindBugs findBugs;
    private Reporter reporter;
    private int runNumber;
    private DefaultTreeModel treeModel;
    private String sortOrder;
    
    /** Creates a new instance of AnalysisRun. */
    public AnalysisRun(Project project) {
        this.project = project;
        reporter = new Reporter();
        findBugs = new FindBugs(reporter);
	runNumber = project.getNextAnalysisRun();
        sortOrder = "invalid";
    }
    
    /**
     * Run the analysis.
     * This should be done in a separate thread (not the GUI event thread).
     * The progress callback can be used to update the user interface to
     * reflect the progress of the analysis.  The GUI may cancel the analysis
     * by interrupting the analysis thread, in which case InterruptedException
     * will be thrown by this method.
     *
     * @param progressCallback the progress callback
     * @throws java.io.IOException if an I/O error occurs during the analysis
     * @throws InterruptedException if the analysis thread is interrupted
     */
    public void execute(FindBugsProgress progressCallback) throws java.io.IOException, InterruptedException {
        findBugs.setProgressCallback(progressCallback);
        
        // Run the analysis!
        findBugs.execute(project.getJarFileArray());
    }
    
    /**
     * Return the collection of BugInstances.
     */
    public java.util.Collection getBugInstances() {
        return reporter.bugSet;
    }
    
    /**
     * Set the tree model to be used in the BugTree.
     */
    public void setTreeModel(DefaultTreeModel treeModel) {
        this.treeModel = treeModel;
    }
    
    /**
     * Get the tree model to be used in the BugTree.
     */
    public DefaultTreeModel getTreeModel() {
        return treeModel;
    }
    
    /**
     * Set current sort order of the run's tree model.
     */
    public void setSortOrder(String sortOrder) {
        this.sortOrder = sortOrder;
    }
    
    /**
     * Get current sort order of the run's tree model.
     */
    public String getSortOrder() {
        return sortOrder;
    }
    
    public String toString() {
	return "Run " + runNumber;
    }
    
}
{'fraction_non_alphanumeric': 0.07819001386962553, 'fraction_numerical': 0.0027739251040221915, 'mean_word_length': 2.427807486631016, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4890065', 'n_tokens_mistral': 1580, 'n_tokens_neox': 1541, 'n_words': 546}