<commit_before>/*
 * LongThreadDialog.java
 *
 * Created on 30. März 2006, 10:04
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.pironet.tda;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Map;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;

/**
 *
 * @author irockel
 */
public class LongThreadDialog extends JDialog {
    private JTabbedPane prefsPane;
    private SettingsPanel settingsPanel;
    private JPanel buttonPanel;
    private JButton okButton;
    private JButton cancelButton;
    private TDA backRef;
    private TreePath[] dumps;
    private DefaultMutableTreeNode top;
    private Map threadDumps;
    
    /** 
     * Creates a new instance of PreferencesDialog 
     */
    public LongThreadDialog(TDA owner, TreePath[] dumps, DefaultMutableTreeNode top, Map threadDumps) {        
        super(owner.frame, "Detect long running Threads");
        backRef = owner;
        this.dumps = dumps;
        this.threadDumps = threadDumps;
        this.top = top;
        getContentPane().setLayout(new BorderLayout());
        initPanel();
        setLocationRelativeTo(owner);
    }
    
    private void initPanel() {
        prefsPane = new JTabbedPane();
        settingsPanel = new SettingsPanel();
        prefsPane.addTab("Settings", settingsPanel);        
        getContentPane().add(prefsPane,BorderLayout.CENTER);
        okButton = new JButton("Start Detection");
        cancelButton = new JButton("Cancel");
        buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
        buttonPanel.add(okButton);
        buttonPanel.add(cancelButton);
        getContentPane().add(buttonPanel, BorderLayout.SOUTH);
        
        okButton.addActionListener( new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                int divider = backRef.topSplitPane.getDividerLocation();

                if(backRef.frame != null) {
                    backRef.frame.setEnabled(true);
                }
                DumpParserFactory.get().getCurrentDumpParser().findLongRunningThreads(top, threadDumps, dumps, Integer.parseInt(settingsPanel.minOccurenceField.getText()), settingsPanel.threadRegExField.getText());
                backRef.createTree();
                backRef.tree.expandRow(1);

                backRef.getRootPane().revalidate();
                backRef.topSplitPane.setDividerLocation(divider);
                dispose();
            }
        });
        
        cancelButton.addActionListener( new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if(backRef.frame != null) {
                    backRef.frame.setEnabled(true);
                }
                dispose();
            }
        });
        reset();        
    }
    
    public void reset() {
        getRootPane().setDefaultButton(okButton);
    }
    
    class SettingsPanel extends JPanel {
        JTextField minOccurenceField;
        JTextField threadRegExField;
        
        public SettingsPanel() {
            //super(new GridLayout(3,2, 10, 10));
            setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
            setPreferredSize(new Dimension(420, 100));
            
            JPanel layoutPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));            
            layoutPanel.add(new JLabel("Minimum occurence of a thread"));
            minOccurenceField = new JTextField(3);
            minOccurenceField.setText(String.valueOf(dumps.length));
            layoutPanel.add(minOccurenceField);
            
            layoutPanel.add(new JLabel("Regular Expression thread identifier matches"));
            threadRegExField = new JTextField(30);
            layoutPanel.add(threadRegExField);
            JLabel example = new JLabel("<html><body>Example is <b>\"AJPRequestHandler(.*)</b>");
            example.setFont(new Font("SansSerif", Font.PLAIN, 10));
            layoutPanel.add(example);
            add(layoutPanel);            
        }
    }
    
    /**
     * Must be called from the event-dispatching thread.
     */
    public void resetFocus() {
        //searchField.requestFocusInWindow();
    }
    
}<commit_msg>reworked layout of dialog<commit_after>/*
 * LongThreadDialog.java
 *
 * This file is part of TDA - Thread Dump Analysis Tool.
 *
 * TDA is free software; you can redistribute it and/or modify
 * it under the terms of the Lesser GNU General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * TDA 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
 * Lesser GNU General Public License for more details.
 *
 * TDA should have received a copy of the Lesser GNU General Public License
 * along with Foobar; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * $Id: LongThreadDialog.java,v 1.6 2008-01-08 19:47:27 irockel Exp $
 */

package com.pironet.tda;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Map;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;

/**
 * long running thread detection dialog.
 * 
 * @author irockel
 */
public class LongThreadDialog extends JDialog {
    private JTabbedPane prefsPane;
    private SettingsPanel settingsPanel;
    private JPanel buttonPanel;
    private JButton okButton;
    private JButton cancelButton;
    private TDA backRef;
    private TreePath[] dumps;
    private DefaultMutableTreeNode top;
    private Map threadDumps;
    
    /** 
     * Creates a new instance of PreferencesDialog 
     */
    public LongThreadDialog(TDA owner, TreePath[] dumps, DefaultMutableTreeNode top, Map threadDumps) {        
        super(owner.frame, "Detect long running Threads");
        backRef = owner;
        this.dumps = dumps;
        this.threadDumps = threadDumps;
        this.top = top;
        getContentPane().setLayout(new BorderLayout());
        initPanel();
        setLocationRelativeTo(owner);
    }
    
    private void initPanel() {
        prefsPane = new JTabbedPane();
        settingsPanel = new SettingsPanel();
        prefsPane.addTab("Settings", settingsPanel);        
        getContentPane().add(prefsPane,BorderLayout.CENTER);
        okButton = new JButton("Start Detection");
        cancelButton = new JButton("Cancel");
        buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
        buttonPanel.add(okButton);
        buttonPanel.add(cancelButton);
        getContentPane().add(buttonPanel, BorderLayout.SOUTH);
        
        okButton.addActionListener( new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                int divider = backRef.topSplitPane.getDividerLocation();

                if(backRef.frame != null) {
                    backRef.frame.setEnabled(true);
                }
                DumpParserFactory.get().getCurrentDumpParser().findLongRunningThreads(top, threadDumps, dumps, Integer.parseInt(settingsPanel.minOccurenceField.getText()), settingsPanel.threadRegExField.getText());
                backRef.createTree();
                backRef.tree.expandRow(1);

                backRef.getRootPane().revalidate();
                backRef.topSplitPane.setDividerLocation(divider);
                dispose();
            }
        });
        
        cancelButton.addActionListener( new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if(backRef.frame != null) {
                    backRef.frame.setEnabled(true);
                }
                dispose();
            }
        });
        reset();        
    }
    
    public void reset() {
        getRootPane().setDefaultButton(okButton);
    }
    
    class SettingsPanel extends JPanel {
        JTextField minOccurenceField;
        JTextField threadRegExField;
        
        public SettingsPanel() {
            setLayout(new BorderLayout());
            
            JPanel layoutPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));            
            layoutPanel.add(new JLabel("Minimum occurence of a thread"));
            minOccurenceField = new JTextField(3);
            minOccurenceField.setText(String.valueOf(dumps.length));
            layoutPanel.add(minOccurenceField);
            add(layoutPanel, BorderLayout.NORTH);
            
            layoutPanel = new JPanel(new BorderLayout());
            layoutPanel.add(new JLabel("Regular Expression thread identifier matches"), BorderLayout.NORTH);
            threadRegExField = new JTextField(30);
            layoutPanel.add(threadRegExField, BorderLayout.CENTER);
            add(layoutPanel, BorderLayout.CENTER);
            
            layoutPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
            JLabel example = new JLabel("<html><body>Example is <b>\"AJPRequestHandler(.*)</b>");
            example.setFont(new Font("SansSerif", Font.PLAIN, 10));
            layoutPanel.add(example);
            add(layoutPanel, BorderLayout.SOUTH);
        }
    }
    
    /**
     * Must be called from the event-dispatching thread.
     */
    public void resetFocus() {
    }
    
}
{'fraction_non_alphanumeric': 0.0953564681316496, 'fraction_numerical': 0.006264293526896689, 'mean_word_length': 2.4421629021218343, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '6031858', 'n_tokens_mistral': 2778, 'n_tokens_neox': 2669, 'n_words': 635}