<commit_before>/*
  Copyright (C) 2003 EBI, GRL
 
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.
 
  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.
 
  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package org.ensembl.healthcheck;

import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;

/**
 * Settings Dialog for the GuiTestRunner.
 */
public class GuiTestRunnerSettings extends javax.swing.JDialog {
  
  GuiTestRunnerFrame gtrf;
  GuiTestRunner guiTestRunner;
  
  private final static Dimension PANEL_SIZE = new Dimension(300, 500);
  
  /** Creates new form GuiTestRunnerSettings
   * @param parent The parent frame.
   * @param gtr The GuiTestRunner to use.
   * @param modal Whether this dialog is modal or not.
   */
  public GuiTestRunnerSettings(GuiTestRunnerFrame parent, GuiTestRunner gtr, boolean modal) {
    super(parent, modal);
    this.gtrf = parent;
    this.guiTestRunner = gtr;
    initComponents();
    init();
    
  }
  
  /** This method is called from within the constructor to
   * initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is
   * always regenerated by the Form Editor.
   */
  private void initComponents() {//GEN-BEGIN:initComponents
    topPanel = new javax.swing.JPanel();
    centrePanel = new javax.swing.JPanel();
    dbListPanel = new javax.swing.JPanel();
    listScrollPane = new javax.swing.JScrollPane();
    dbList = new javax.swing.JList();
    threadsPanel = new javax.swing.JPanel();
    maxThreadsLabel = new javax.swing.JLabel();
    threadsSpinner = new javax.swing.JSpinner();
    outputLabel = new javax.swing.JLabel();
    outputComboBox = new javax.swing.JComboBox();
    bottomPanel = new javax.swing.JPanel();
    applyButton = new javax.swing.JButton();
    cancelButton = new javax.swing.JButton();
    
    setTitle("EnsEMBL HealthCheck Settings");
    addWindowListener(new java.awt.event.WindowAdapter() {
      public void windowClosing(java.awt.event.WindowEvent evt) {
        closeDialog(evt);
      }
    });
    
    getContentPane().add(topPanel, java.awt.BorderLayout.NORTH);
    
    centrePanel.setLayout(new javax.swing.BoxLayout(centrePanel, javax.swing.BoxLayout.Y_AXIS));
    
    dbListPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
    
    dbListPanel.setBackground(new java.awt.Color(255, 255, 255));
    dbListPanel.setBorder(new javax.swing.border.TitledBorder("Select schemas"));
    dbList.setFont(new java.awt.Font("Dialog", 0, 12));
    dbList.setToolTipText("Select schema(s). Use Ctrl or Shift to make multiple selctions.");
    listScrollPane.setViewportView(dbList);
    
    dbListPanel.add(listScrollPane);
    
    centrePanel.add(dbListPanel);
    
    threadsPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
    
    threadsPanel.setBorder(new javax.swing.border.EtchedBorder());
    maxThreadsLabel.setFont(new java.awt.Font("Dialog", 0, 12));
    maxThreadsLabel.setText("Max. threads: ");
    maxThreadsLabel.setToolTipText("The maximum number of tests to run at one time.");
    threadsPanel.add(maxThreadsLabel);
    
    threadsSpinner.setFont(new java.awt.Font("Dialog", 0, 12));
    threadsSpinner.setToolTipText("Select the maximum number of threads to run");
    threadsPanel.add(threadsSpinner);
    
    outputLabel.setFont(new java.awt.Font("Dialog", 0, 12));
    outputLabel.setText("  Output level: ");
    threadsPanel.add(outputLabel);
    
    outputComboBox.setFont(new java.awt.Font("Dialog", 0, 12));
    outputComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "All", "Problems only", "Correct results", "Summary", "Info", "None" }));
    threadsPanel.add(outputComboBox);
    
    centrePanel.add(threadsPanel);
    
    getContentPane().add(centrePanel, java.awt.BorderLayout.CENTER);
    
    bottomPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
    
    applyButton.setText("Apply");
    applyButton.setToolTipText("Apply the current settings and return");
    bottomPanel.add(applyButton);
    
    cancelButton.setText("Cancel");
    cancelButton.setToolTipText("Return without applying settings");
    bottomPanel.add(cancelButton);
    
    getContentPane().add(bottomPanel, java.awt.BorderLayout.SOUTH);
    
    pack();
  }//GEN-END:initComponents
  
  /** Closes the dialog */
  private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
    setVisible(false);
    dispose();
  }//GEN-LAST:event_closeDialog
  
  /**
   * Command-line entry point.
   * @param args the command line arguments
   */
  public static void main(String args[]) {
    new GuiTestRunnerSettings(null, null, true).show();
  }
  
  
  // Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.JButton applyButton;
  private javax.swing.JPanel bottomPanel;
  private javax.swing.JButton cancelButton;
  private javax.swing.JPanel centrePanel;
  private javax.swing.JList dbList;
  private javax.swing.JPanel dbListPanel;
  private javax.swing.JScrollPane listScrollPane;
  private javax.swing.JLabel maxThreadsLabel;
  private javax.swing.JComboBox outputComboBox;
  private javax.swing.JLabel outputLabel;
  private javax.swing.JPanel threadsPanel;
  private javax.swing.JSpinner threadsSpinner;
  private javax.swing.JPanel topPanel;
  // End of variables declaration//GEN-END:variables
  
  // -------------------------------------------------------------------------
  
  private void init() {
    
    final GuiTestRunner localGTR = guiTestRunner;
    
    threadsSpinner.setModel(new SpinnerNumberModel(guiTestRunner.getMaxThreads(), 0, 10, 1));
    
    cancelButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        closeDialog(null);
      }
    });
    
    applyButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        int spinnerValue = ((SpinnerNumberModel)threadsSpinner.getModel()).getNumber().intValue();
        HashMap levels = new HashMap();
        levels.put("All"            , new Integer(ReportLine.ALL));
        levels.put("Problems only"  , new Integer(ReportLine.PROBLEM));
        levels.put("Correct results", new Integer(ReportLine.CORRECT));
        levels.put("Warnings"        , new Integer(ReportLine.WARNING));
        levels.put("Info"           , new Integer(ReportLine.INFO));
        levels.put("None"           , new Integer(ReportLine.NONE));
        
        String selection = outputComboBox.getSelectedItem().toString();
        int level = ((Integer)levels.get(selection)).intValue();
        
        localGTR.setOutputLevel(level);
        localGTR.setSelectedSchemas(dbList.getSelectedValues());
        localGTR.setMaxThreads(spinnerValue);
        
        closeDialog(null);
      }
    });
    
    listScrollPane.setPreferredSize(PANEL_SIZE);
    //dbListPanel.setPreferredSize(PANEL_SIZE);
    
    dbList.setListData(localGTR.getSchemaList());
  
    pack();
    
  } // init
  
  // -------------------------------------------------------------------------
  
}
<commit_msg>Modified "Output level" dropdown to match modified levels in ReportLine.<commit_after>/*
  Copyright (C) 2003 EBI, GRL
 
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.
 
  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.
 
  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package org.ensembl.healthcheck;

import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;

/**
 * Settings Dialog for the GuiTestRunner.
 */
public class GuiTestRunnerSettings extends javax.swing.JDialog {
  
  GuiTestRunnerFrame gtrf;
  GuiTestRunner guiTestRunner;
  
  private final static Dimension PANEL_SIZE = new Dimension(300, 500);
  
  /** Creates new form GuiTestRunnerSettings
   * @param parent The parent frame.
   * @param gtr The GuiTestRunner to use.
   * @param modal Whether this dialog is modal or not.
   */
  public GuiTestRunnerSettings(GuiTestRunnerFrame parent, GuiTestRunner gtr, boolean modal) {
    super(parent, modal);
    this.gtrf = parent;
    this.guiTestRunner = gtr;
    initComponents();
    init();
    
  }
  
  /** This method is called from within the constructor to
   * initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is
   * always regenerated by the Form Editor.
   */
  private void initComponents() {//GEN-BEGIN:initComponents
    topPanel = new javax.swing.JPanel();
    centrePanel = new javax.swing.JPanel();
    dbListPanel = new javax.swing.JPanel();
    listScrollPane = new javax.swing.JScrollPane();
    dbList = new javax.swing.JList();
    threadsPanel = new javax.swing.JPanel();
    maxThreadsLabel = new javax.swing.JLabel();
    threadsSpinner = new javax.swing.JSpinner();
    outputLabel = new javax.swing.JLabel();
    outputComboBox = new javax.swing.JComboBox();
    bottomPanel = new javax.swing.JPanel();
    applyButton = new javax.swing.JButton();
    cancelButton = new javax.swing.JButton();
    
    setTitle("EnsEMBL HealthCheck Settings");
    addWindowListener(new java.awt.event.WindowAdapter() {
      public void windowClosing(java.awt.event.WindowEvent evt) {
        closeDialog(evt);
      }
    });
    
    getContentPane().add(topPanel, java.awt.BorderLayout.NORTH);
    
    centrePanel.setLayout(new javax.swing.BoxLayout(centrePanel, javax.swing.BoxLayout.Y_AXIS));
    
    dbListPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
    
    dbListPanel.setBackground(new java.awt.Color(255, 255, 255));
    dbListPanel.setBorder(new javax.swing.border.TitledBorder("Select schemas"));
    dbList.setFont(new java.awt.Font("Dialog", 0, 12));
    dbList.setToolTipText("Select schema(s). Use Ctrl or Shift to make multiple selctions.");
    listScrollPane.setViewportView(dbList);
    
    dbListPanel.add(listScrollPane);
    
    centrePanel.add(dbListPanel);
    
    threadsPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
    
    threadsPanel.setBorder(new javax.swing.border.EtchedBorder());
    maxThreadsLabel.setFont(new java.awt.Font("Dialog", 0, 12));
    maxThreadsLabel.setText("Max. threads: ");
    maxThreadsLabel.setToolTipText("The maximum number of tests to run at one time.");
    threadsPanel.add(maxThreadsLabel);
    
    threadsSpinner.setFont(new java.awt.Font("Dialog", 0, 12));
    threadsSpinner.setToolTipText("Select the maximum number of threads to run");
    threadsPanel.add(threadsSpinner);
    
    outputLabel.setFont(new java.awt.Font("Dialog", 0, 12));
    outputLabel.setText("  Output level: ");
    threadsPanel.add(outputLabel);
    
    outputComboBox.setFont(new java.awt.Font("Dialog", 0, 12));
    outputComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "All", "Problems only", "Correct results", "Summary", "Info", "None" }));
    threadsPanel.add(outputComboBox);
    
    centrePanel.add(threadsPanel);
    
    getContentPane().add(centrePanel, java.awt.BorderLayout.CENTER);
    
    bottomPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
    
    applyButton.setText("Apply");
    applyButton.setToolTipText("Apply the current settings and return");
    bottomPanel.add(applyButton);
    
    cancelButton.setText("Cancel");
    cancelButton.setToolTipText("Return without applying settings");
    bottomPanel.add(cancelButton);
    
    getContentPane().add(bottomPanel, java.awt.BorderLayout.SOUTH);
    
    pack();
  }//GEN-END:initComponents
  
  /** Closes the dialog */
  private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
    setVisible(false);
    dispose();
  }//GEN-LAST:event_closeDialog
  
  /**
   * Command-line entry point.
   * @param args the command line arguments
   */
  public static void main(String args[]) {
    new GuiTestRunnerSettings(null, null, true).show();
  }
  
  
  // Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.JButton applyButton;
  private javax.swing.JPanel bottomPanel;
  private javax.swing.JButton cancelButton;
  private javax.swing.JPanel centrePanel;
  private javax.swing.JList dbList;
  private javax.swing.JPanel dbListPanel;
  private javax.swing.JScrollPane listScrollPane;
  private javax.swing.JLabel maxThreadsLabel;
  private javax.swing.JComboBox outputComboBox;
  private javax.swing.JLabel outputLabel;
  private javax.swing.JPanel threadsPanel;
  private javax.swing.JSpinner threadsSpinner;
  private javax.swing.JPanel topPanel;
  // End of variables declaration//GEN-END:variables
  
  // -------------------------------------------------------------------------
  
  private void init() {
    
    final GuiTestRunner localGTR = guiTestRunner;
    
    threadsSpinner.setModel(new SpinnerNumberModel(guiTestRunner.getMaxThreads(), 0, 10, 1));
    
    cancelButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        closeDialog(null);
      }
    });
    
    applyButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        int spinnerValue = ((SpinnerNumberModel)threadsSpinner.getModel()).getNumber().intValue();
        HashMap levels = new HashMap();
        levels.put("All"            , new Integer(ReportLine.ALL));
        levels.put("Problems only"  , new Integer(ReportLine.PROBLEM));
        levels.put("Correct results", new Integer(ReportLine.CORRECT));
        levels.put("Warnings"       , new Integer(ReportLine.WARNING));
        levels.put("Info"           , new Integer(ReportLine.INFO));
        levels.put("None"           , new Integer(ReportLine.NONE));
        
        String selection = outputComboBox.getSelectedItem().toString();
        int level = ((Integer)levels.get(selection)).intValue();
        
        localGTR.setOutputLevel(level);
        localGTR.setSelectedSchemas(dbList.getSelectedValues());
        localGTR.setMaxThreads(spinnerValue);
        
        closeDialog(null);
      }
    });
    
    listScrollPane.setPreferredSize(PANEL_SIZE);
    //dbListPanel.setPreferredSize(PANEL_SIZE);
    
    dbList.setListData(localGTR.getSchemaList());
  
    pack();
    
  } // init
  
  // -------------------------------------------------------------------------
  
}

{'fraction_non_alphanumeric': 0.12517680339462517, 'fraction_numerical': 0.006943551498006944, 'mean_word_length': 3.213163596966414, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1885251', 'n_tokens_mistral': 4592, 'n_tokens_neox': 4472, 'n_words': 1077}