<commit_before>package net.sourceforge.javydreamercsw.client.ui.nodes.actions;

import com.validation.manager.core.DataBaseManager;
import com.validation.manager.core.VMException;
import com.validation.manager.core.db.RequirementSpecNode;
import com.validation.manager.core.db.controller.RequirementSpecNodeJpaController;
import com.validation.manager.core.tool.requirement.importer.RequirementImportException;
import com.validation.manager.core.tool.requirement.importer.RequirementImporter;
import java.awt.event.ActionEvent;
import java.io.File;
import javax.swing.AbstractAction;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileFilter;
import org.openide.util.Exceptions;
import org.openide.util.Utilities;

/**
 *
 * @author <NAME> <<EMAIL>>
 */
public class ImportRequirementAction extends AbstractAction {

    public ImportRequirementAction() {
        super("Import Requirements",
                new ImageIcon("com/validation/manager/resources/icons/Signage/Add Square.png"));
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                final JFileChooser fc = new JFileChooser();
                fc.addChoosableFileFilter(new FileFilter() {
                    @Override
                    public boolean accept(File file) {
                        return file.isDirectory() || file.getName().endsWith(".xls")
                                || file.getName().endsWith(".xlsx");
                    }

                    @Override
                    public String getDescription() {
                        return "Excel Files";
                    }
                });
                fc.addChoosableFileFilter(new FileFilter() {
                    @Override
                    public boolean accept(File file) {
                        return file.getName().endsWith(".csv");
                    }

                    @Override
                    public String getDescription() {
                        return "Comma delimited Files";
                    }
                });
                int returnVal = fc.showOpenDialog(null);
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                    try {
                        File file = fc.getSelectedFile();
                        RequirementSpecNode rsns
                                = Utilities.actionsGlobalContext().lookup(RequirementSpecNode.class);
                        RequirementImporter instance = new RequirementImporter(file,
                                new RequirementSpecNodeJpaController(
                                        DataBaseManager.getEntityManagerFactory())
                                .findRequirementSpecNode(rsns.getRequirementSpecNodePK()));
                        instance.importFile(true);
                        instance.processImport();
                    } catch (UnsupportedOperationException ex) {
                        Exceptions.printStackTrace(ex);
                    } catch (RequirementImportException ex) {
                        Exceptions.printStackTrace(ex);
                    } catch (VMException ex) {
                        Exceptions.printStackTrace(ex);
                    }
                }
            }
        });
    }
}
<commit_msg>Java 8 enhancements<commit_after>package net.sourceforge.javydreamercsw.client.ui.nodes.actions;

import com.validation.manager.core.DataBaseManager;
import com.validation.manager.core.VMException;
import com.validation.manager.core.db.RequirementSpecNode;
import com.validation.manager.core.db.controller.RequirementSpecNodeJpaController;
import com.validation.manager.core.tool.requirement.importer.RequirementImportException;
import com.validation.manager.core.tool.requirement.importer.RequirementImporter;
import java.awt.event.ActionEvent;
import java.io.File;
import java.util.logging.Logger;
import javax.swing.AbstractAction;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileFilter;
import org.netbeans.api.progress.ProgressHandle;
import org.openide.util.Exceptions;
import org.openide.util.RequestProcessor;
import org.openide.util.Utilities;

/**
 *
 * @author <NAME> <<EMAIL>>
 */
public class ImportRequirementAction extends AbstractAction {

    private static final long serialVersionUID = 5175273885154629542L;
    private static final RequestProcessor RP
            = new RequestProcessor("Requirement Importer", 1, true);
    private static RequestProcessor.Task theTask = null;
    private static ProgressHandle ph;
    private static final Logger LOG
            = Logger.getLogger(ImportRequirementAction.class.getSimpleName());

    public ImportRequirementAction() {
        super("Import Requirements",
                new ImageIcon("com/validation/manager/resources/icons/Signage/Add Square.png"));
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(() -> {
            final JFileChooser fc = new JFileChooser();
            fc.addChoosableFileFilter(new FileFilter() {
                @Override
                public boolean accept(File file) {
                    return file.isDirectory() || file.getName().endsWith(".xls")
                            || file.getName().endsWith(".xlsx");
                }
                
                @Override
                public String getDescription() {
                    return "Excel Files";
                }
            });
            fc.addChoosableFileFilter(new FileFilter() {
                @Override
                public boolean accept(File file) {
                    return file.getName().endsWith(".csv");
                }
                
                @Override
                public String getDescription() {
                    return "Comma delimited Files";
                }
            });
            int returnVal = fc.showOpenDialog(null);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                try {
                    File file = fc.getSelectedFile();
                    RequirementSpecNode rsns
                            = Utilities.actionsGlobalContext().lookup(RequirementSpecNode.class);
                    RequirementImporter instance = new RequirementImporter(file,
                            new RequirementSpecNodeJpaController(
                                    DataBaseManager.getEntityManagerFactory())
                                    .findRequirementSpecNode(rsns.getRequirementSpecNodePK()));
                    instance.importFile(true);
                    instance.processImport();
                } catch (UnsupportedOperationException ex) {
                    Exceptions.printStackTrace(ex);
                } catch (RequirementImportException ex) {
                    Exceptions.printStackTrace(ex);
                } catch (VMException ex) {
                    Exceptions.printStackTrace(ex);
                }
            }
        });
    }
}

{'fraction_non_alphanumeric': 0.08667313826099016, 'fraction_numerical': 0.0029122174455692693, 'mean_word_length': 1.8062256809338522, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5331439', 'n_tokens_mistral': 1771, 'n_tokens_neox': 1653, 'n_words': 306}