<commit_before>package fr.tikione.jacocoverage.plugin.config;

import fr.tikione.jacocoverage.plugin.util.NBUtils;
import fr.tikione.jacocoverage.plugin.util.Utils;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.regex.Matcher;
import javax.swing.ButtonGroup;
import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.LayoutStyle;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableModel;
import org.netbeans.api.project.Project;
import org.openide.awt.Mnemonics;
import org.openide.filesystems.FileObject;
import org.openide.util.Exceptions;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;

/**
 * Configuration panel at project level.
 *
 * @author <NAME>
 */
public class PrjcfgAntJavasePanel extends javax.swing.JPanel implements IStorable {

    private static final long serialVersionUID = 1L;

    /** The file to save project side configuration. */
    private File prjCfgFile;

    /** The folder that contains project's Java sources. */
    private File prjSrcDir;

    /** The list of packages and Java classes found on the project associated to the current configuration panel. */
    private Map<File, List<File>> pkgAndClasses;

    /** The model used to handle packages filter table. */
    private DefaultTableModel pkgfltModel;

    /**
     * Creates new form PrjcfgAntJavasePanel.
     *
     * @param context
     * @throws FileNotFoundException
     * @throws IOException
     */
    public PrjcfgAntJavasePanel(Lookup context)
            throws FileNotFoundException,
                   IOException {
        super();
        initComponents();
        // <editor-fold defaultstate="collapsed" desc="Tooltips">
        // Warning: background of tooltips is black on Ubuntu. Avoid coloring links with blue.
        jButtonSocialTwitter.setToolTipText("<html><body><NAME> on <b>Twitter</b> (author of JaCoCoverage)<br>"
                + "https://twitter.com/JLermitage" + "</body></html>");
        jButtonSocialFacebook.setToolTipText("<html><body><NAME> on <b>Facebook</b> (author of JaCoCoverage)<br>"
                + "https://www.facebook.com/jonathan.lermitage" + "</body></html>");
        jButtonSocialGithub.setToolTipText("<html><body><NAME>  on <b>GitHub</b> (author of JaCoCoverage)<br>"
                + "https://github.com/jonathanlermitage" + "</body></html>");
        jButtonSocialJojohome.setToolTipText("<html><body><NAME> devblog (author of JaCoCoverage)<br>"
                + "http://netbeanscolors.org" + "</body></html>");
        jButtonOnlineHelp.setToolTipText("<html><body>Online help page of JaCoCoverage<br>"
                + "http://jacocoverage.tikione.fr/redirect/help/" + "</body></html>");
        // </editor-fold>
        Project prj = context.lookup(Project.class);
        prjCfgFile = new File(NBUtils.getProjectDir(prj), Globals.PRJ_CFG);

        // Get project sources folder.
        String prjDir = NBUtils.getProjectDir(prj) + File.separator;
        FileObject prjPropsFo = prj.getProjectDirectory().getFileObject("nbproject/project.properties");
        Properties prjProps = new Properties();
        prjProps.load(prjPropsFo.getInputStream());
        prjSrcDir = new File(prjDir + Utils.getProperty(prjProps, "src.dir") + File.separator);
        
        load();
    }

    private void loadPkgFilter() {
        pkgAndClasses = Utils.listPkgAndClasses(prjSrcDir);
        pkgfltModel = new PackageFilterModel();
        jTablePackageFilter.setModel(pkgfltModel);
        jTablePackageFilter.getColumnModel().getColumn(0).setPreferredWidth(50);
        jTablePackageFilter.getColumnModel().getColumn(0).setMinWidth(0);
        jTablePackageFilter.getColumnModel().getColumn(0).setMaxWidth(200);<commit_msg>fixed: unclosed input stream on project's properties Signed-off-by:jonathanlermitage <<EMAIL>><commit_after>package fr.tikione.jacocoverage.plugin.config;

import fr.tikione.jacocoverage.plugin.util.NBUtils;
import fr.tikione.jacocoverage.plugin.util.Utils;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.regex.Matcher;
import javax.swing.ButtonGroup;
import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.LayoutStyle;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableModel;
import org.netbeans.api.project.Project;
import org.openide.awt.Mnemonics;
import org.openide.filesystems.FileObject;
import org.openide.util.Exceptions;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;

/**
 * Configuration panel at project level.
 *
 * @author <NAME>
 */
public class PrjcfgAntJavasePanel extends javax.swing.JPanel implements IStorable {

    private static final long serialVersionUID = 1L;

    /** The file to save project side configuration. */
    private File prjCfgFile;

    /** The folder that contains project's Java sources. */
    private File prjSrcDir;

    /** The list of packages and Java classes found on the project associated to the current configuration panel. */
    private Map<File, List<File>> pkgAndClasses;

    /** The model used to handle packages filter table. */
    private DefaultTableModel pkgfltModel;

    /**
     * Creates new form PrjcfgAntJavasePanel.
     *
     * @param context
     * @throws FileNotFoundException
     * @throws IOException
     */
    public PrjcfgAntJavasePanel(Lookup context)
            throws FileNotFoundException,
                   IOException {
        super();
        initComponents();
        // <editor-fold defaultstate="collapsed" desc="Tooltips">
        // Warning: background of tooltips is black on Ubuntu. Avoid coloring links with blue.
        jButtonSocialTwitter.setToolTipText("<html><body><NAME> on <b>Twitter</b> (author of JaCoCoverage)<br>"
                + "https://twitter.com/JLermitage" + "</body></html>");
        jButtonSocialFacebook.setToolTipText("<html><body><NAME> on <b>Facebook</b> (author of JaCoCoverage)<br>"
                + "https://www.facebook.com/jonathan.lermitage" + "</body></html>");
        jButtonSocialGithub.setToolTipText("<html><body><NAME>  on <b>GitHub</b> (author of JaCoCoverage)<br>"
                + "https://github.com/jonathanlermitage" + "</body></html>");
        jButtonSocialJojohome.setToolTipText("<html><body><NAME> devblog (author of JaCoCoverage)<br>"
                + "http://netbeanscolors.org" + "</body></html>");
        jButtonOnlineHelp.setToolTipText("<html><body>Online help page of JaCoCoverage<br>"
                + "http://jacocoverage.tikione.fr/redirect/help/" + "</body></html>");
        // </editor-fold>
        Project prj = context.lookup(Project.class);
        prjCfgFile = new File(NBUtils.getProjectDir(prj), Globals.PRJ_CFG);

        // Get project sources folder.
        String prjDir = NBUtils.getProjectDir(prj) + File.separator;
        FileObject prjPropsFo = prj.getProjectDirectory().getFileObject("nbproject/project.properties");
        Properties prjProps = new Properties();
        try (InputStream inputStream = prjPropsFo.getInputStream()) {
            prjProps.load(inputStream);
        }
        prjSrcDir = new File(prjDir + Utils.getProperty(prjProps, "src.dir") + File.separator);
        
        load();
    }

    private void loadPkgFilter() {
        pkgAndClasses = Utils.listPkgAndClasses(prjSrcDir);
        pkgfltModel = new PackageFilterModel();
        jTablePackageFilter.setModel(pkgfltModel);
        jTablePackageFilter.getColumnModel().getColumn(0).setPreferredWidth(50);
        jTablePackageFilter.getColumnModel().getColumn(0).setMinWidth(0);
        jTablePackageFilter.getColumnModel().getColumn(0).setMaxWidth(200);
{'fraction_non_alphanumeric': 0.1201177402920865, 'fraction_numerical': 0.0022642363862787275, 'mean_word_length': 3.6839872746553555, 'pattern_counts': {'":': 0, '<': 85, '<?xml version=': 0, '>': 85, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1798696', 'n_tokens_mistral': 2710, 'n_tokens_neox': 2598, 'n_words': 535}