<commit_before>/*
 * Autopsy Forensic Browser
 *
 * Copyright 2011-2018 Basis Technology Corp.
 * Contact: carrier <at> sleuthkit <dot> org
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.sleuthkit.autopsy.keywordsearch;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import javax.swing.JCheckBox;
import javax.swing.JList;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import org.openide.util.NbBundle;
import org.openide.util.actions.SystemAction;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.ingest.IngestManager;

/**
 * Viewer panel widget for keyword lists that is used in the ingest config and
 * options area.
 */
@SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
class DropdownListSearchPanel extends AdHocSearchPanel {

    private static final Logger logger = Logger.getLogger(DropdownListSearchPanel.class.getName());
    private static DropdownListSearchPanel instance;
    private XmlKeywordSearchList loader;
    private final KeywordListsTableModel listsTableModel;
    private final KeywordsTableModel keywordsTableModel;
    private ActionListener searchAddListener;
    private boolean ingestRunning;

    /**
     * Creates new form DropdownListSearchPanel
     */
    private DropdownListSearchPanel() {
        listsTableModel = new KeywordListsTableModel();
        keywordsTableModel = new KeywordsTableModel();
        initComponents();
        customizeComponents();
        dataSourceList.setModel(getDataSourceListModel());

        dataSourceList.addListSelectionListener((ListSelectionEvent evt) -> {
            firePropertyChange(Bundle.DropdownSingleTermSearchPanel_selected(), null, null);
        });
        dataSourceList.addMouseMotionListener(new MouseMotionListener() {

            @Override
            public void mouseDragged(MouseEvent evt) {
                //Unused by now
            }

            @Override
            public void mouseMoved(MouseEvent evt) {
                JList<String> DsList = (JList<String>) evt.getSource();
                int index = DsList.locationToIndex(evt.getPoint());
                if (index > -1) {
                    DsList.setToolTipText(getDataSourceToolTipList().get(index));
                }
            }
        });
    }

    static synchronized DropdownListSearchPanel getDefault() {
        if (instance == null) {
            instance = new DropdownListSearchPanel();
        }
        return instance;
    }

    private void customizeComponents() {
        listsTable.setTableHeader(null);
        listsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        //customize column witdhs
        final int leftWidth = leftPane.getPreferredSize().width;
        TableColumn column;
        for (int i = 0; i < listsTable.getColumnCount(); i++) {
            column = listsTable.getColumnModel().getColumn(i);
            if (i == 0) {
                column.setPreferredWidth(((int) (leftWidth * 0.10)));
                column.setCellRenderer(new LeftCheckBoxRenderer());
            } else {
                column.setPreferredWidth(((int) (leftWidth * 0.89)));
            }
        }
        final int rightWidth = rightPane.getPreferredSize().width;
        for (int i = 0; i < keywordsTable.getColumnCount(); i++) {
            column = keywordsTable.getColumnModel().getColumn(i);
            if (i == 0) {<commit_msg>3780: Update variable name.<commit_after>/*
 * Autopsy Forensic Browser
 *
 * Copyright 2011-2018 Basis Technology Corp.
 * Contact: carrier <at> sleuthkit <dot> org
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.sleuthkit.autopsy.keywordsearch;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import javax.swing.JCheckBox;
import javax.swing.JList;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import org.openide.util.NbBundle;
import org.openide.util.actions.SystemAction;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.ingest.IngestManager;

/**
 * Viewer panel widget for keyword lists that is used in the ingest config and
 * options area.
 */
@SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
class DropdownListSearchPanel extends AdHocSearchPanel {

    private static final Logger logger = Logger.getLogger(DropdownListSearchPanel.class.getName());
    private static DropdownListSearchPanel instance;
    private XmlKeywordSearchList loader;
    private final KeywordListsTableModel listsTableModel;
    private final KeywordsTableModel keywordsTableModel;
    private ActionListener searchAddListener;
    private boolean ingestRunning;

    /**
     * Creates new form DropdownListSearchPanel
     */
    private DropdownListSearchPanel() {
        listsTableModel = new KeywordListsTableModel();
        keywordsTableModel = new KeywordsTableModel();
        initComponents();
        customizeComponents();
        dataSourceList.setModel(getDataSourceListModel());

        dataSourceList.addListSelectionListener((ListSelectionEvent evt) -> {
            firePropertyChange(Bundle.DropdownSingleTermSearchPanel_selected(), null, null);
        });
        dataSourceList.addMouseMotionListener(new MouseMotionListener() {

            @Override
            public void mouseDragged(MouseEvent evt) {
                //Unused by now
            }

            @Override
            public void mouseMoved(MouseEvent evt) {
                JList<String> dsList = (JList<String>) evt.getSource();
                int index = dsList.locationToIndex(evt.getPoint());
                if (index > -1) {
                    dsList.setToolTipText(getDataSourceToolTipList().get(index));
                }
            }
        });
    }

    static synchronized DropdownListSearchPanel getDefault() {
        if (instance == null) {
            instance = new DropdownListSearchPanel();
        }
        return instance;
    }

    private void customizeComponents() {
        listsTable.setTableHeader(null);
        listsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        //customize column witdhs
        final int leftWidth = leftPane.getPreferredSize().width;
        TableColumn column;
        for (int i = 0; i < listsTable.getColumnCount(); i++) {
            column = listsTable.getColumnModel().getColumn(i);
            if (i == 0) {
                column.setPreferredWidth(((int) (leftWidth * 0.10)));
                column.setCellRenderer(new LeftCheckBoxRenderer());
            } else {
                column.setPreferredWidth(((int) (leftWidth * 0.89)));
            }
        }
        final int rightWidth = rightPane.getPreferredSize().width;
        for (int i = 0; i < keywordsTable.getColumnCount(); i++) {
            column = keywordsTable.getColumnModel().getColumn(i);
            if (i == 0) {
{'fraction_non_alphanumeric': 0.0915508493271564, 'fraction_numerical': 0.005515111405250386, 'mean_word_length': 3.1382930168872663, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7324471', 'n_tokens_mistral': 2445, 'n_tokens_neox': 2363, 'n_words': 625}