<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.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.EnumSet;
import java.util.logging.Level;
import javax.swing.SwingUtilities;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.core.RuntimeProperties;
import org.sleuthkit.autopsy.coreutils.Logger;

/**
 * A panel that provides a toolbar button for the dropdown keyword list search
 * panel and dropdown single keyword search panel. Displayed in the upper right
 * hand corner of the application by default.
 */
class DropdownToolbar extends javax.swing.JPanel {

    private static final long serialVersionUID = 1L;
    private static final Logger logger = Logger.getLogger(DropdownToolbar.class.getName());
    private static DropdownToolbar instance;
    private SearchSettingsChangeListener searchSettingsChangeListener;
    private boolean active = false;
    private DropdownSingleTermSearchPanel dropPanel = null;

    /**
     * Gets the singleton panel that provides a toolbar button for the dropdown
     * keyword list search panel and dropdown single keyword search panel.
     * Displayed in the upper right hand corner of the application by default.
     *
     * @return The panel.
     */
    public synchronized static DropdownToolbar getDefault() {
        if (instance == null) {
            instance = new DropdownToolbar();
        }
        return instance;
    }

    /**
     * Constructs a panel that provides a toolbar button for the dropdown
     * keyword list search panel and dropdown single keyword search panel.
     * Displayed in the upper right hand corner of the application by default.
     */
    private DropdownToolbar() {
        initComponents();
        customizeComponents();
    }

    /**
     * Does additional initialization of the GUI components created by the
     * initComponents method.
     */
    private void customizeComponents() {
        searchSettingsChangeListener = new SearchSettingsChangeListener();
        KeywordSearch.getServer().addServerActionListener(searchSettingsChangeListener);
        Case.addEventTypeSubscriber(EnumSet.of(Case.Events.CURRENT_CASE), searchSettingsChangeListener);

        DropdownListSearchPanel listsPanel = DropdownListSearchPanel.getDefault();
        listsPanel.addSearchButtonActionListener((ActionEvent e) -> {
            listsMenu.setVisible(false);
        });

        // Adding border of six to account for menu border
        listsMenu.setSize(listsPanel.getPreferredSize().width + 6, listsPanel.getPreferredSize().height + 6);
        listsMenu.add(listsPanel);
        listsMenu.addPopupMenuListener(new PopupMenuListener() {
            @Override
            public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
                listsButton.setSelected(true);
            }

            @Override
            public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
                listsButton.setSelected(false);
            }

            @Override
            public void popupMenuCanceled(PopupMenuEvent e) {
                listsButton.setSelected(false);
            }
        });

        dropPanel = DropdownSingleTermSearchPanel.getDefault();
        dropPanel.addSearchButtonActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                searchMenu.setVisible(false);
            }
        });
        
        searchMenu.setSize(dropPanel.getPreferredSize().width + 6, dropPanel.getPreferredSize().height + 6);<commit_msg>3780: revert the unnecessary changes<commit_after>/*
 * Autopsy Forensic Browser
 *
 * Copyright 2011-2017 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.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.EnumSet;
import java.util.logging.Level;
import javax.swing.SwingUtilities;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.core.RuntimeProperties;
import org.sleuthkit.autopsy.coreutils.Logger;

/**
 * A panel that provides a toolbar button for the dropdown keyword list search
 * panel and dropdown single keyword search panel. Displayed in the upper right
 * hand corner of the application by default.
 */
class DropdownToolbar extends javax.swing.JPanel {

    private static final long serialVersionUID = 1L;
    private static final Logger logger = Logger.getLogger(DropdownToolbar.class.getName());
    private static DropdownToolbar instance;
    private SearchSettingsChangeListener searchSettingsChangeListener;
    private boolean active = false;
    private DropdownSingleTermSearchPanel dropPanel = null;

    /**
     * Gets the singleton panel that provides a toolbar button for the dropdown
     * keyword list search panel and dropdown single keyword search panel.
     * Displayed in the upper right hand corner of the application by default.
     *
     * @return The panel.
     */
    public synchronized static DropdownToolbar getDefault() {
        if (instance == null) {
            instance = new DropdownToolbar();
        }
        return instance;
    }

    /**
     * Constructs a panel that provides a toolbar button for the dropdown
     * keyword list search panel and dropdown single keyword search panel.
     * Displayed in the upper right hand corner of the application by default.
     */
    private DropdownToolbar() {
        initComponents();
        customizeComponents();
    }

    /**
     * Does additional initialization of the GUI components created by the
     * initComponents method.
     */
    private void customizeComponents() {
        searchSettingsChangeListener = new SearchSettingsChangeListener();
        KeywordSearch.getServer().addServerActionListener(searchSettingsChangeListener);
        Case.addEventTypeSubscriber(EnumSet.of(Case.Events.CURRENT_CASE), searchSettingsChangeListener);

        DropdownListSearchPanel listsPanel = DropdownListSearchPanel.getDefault();
        listsPanel.addSearchButtonActionListener((ActionEvent e) -> {
            listsMenu.setVisible(false);
        });

        // Adding border of six to account for menu border
        listsMenu.setSize(listsPanel.getPreferredSize().width + 6, listsPanel.getPreferredSize().height + 6);
        listsMenu.add(listsPanel);
        listsMenu.addPopupMenuListener(new PopupMenuListener() {
            @Override
            public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
                listsButton.setSelected(true);
            }

            @Override
            public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
                listsButton.setSelected(false);
            }

            @Override
            public void popupMenuCanceled(PopupMenuEvent e) {
                listsButton.setSelected(false);
            }
        });

        dropPanel = DropdownSingleTermSearchPanel.getDefault();
        dropPanel.addSearchButtonActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                searchMenu.setVisible(false);
            }
        });        
        searchMenu.setSize(dropPanel.getPreferredSize().width + 6, dropPanel.getPreferredSize().height + 6);
{'fraction_non_alphanumeric': 0.07397107897664071, 'fraction_numerical': 0.004226918798665183, 'mean_word_length': 3.131893382352941, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '141291', 'n_tokens_mistral': 2273, 'n_tokens_neox': 2201, 'n_words': 695}