<commit_before>package net.sf.jabref.gui;

import net.sf.jabref.*;
import net.sf.jabref.search.SearchMatcher;
import net.sf.jabref.search.HitOrMissComparator;
import net.sf.jabref.groups.EntryTableTransferHandler;

import javax.swing.*;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableModel;
import javax.swing.table.TableColumnModel;

import ca.odell.glazedlists.SortedList;
import ca.odell.glazedlists.EventList;
import ca.odell.glazedlists.matchers.Matcher;
import ca.odell.glazedlists.event.ListEventListener;
import ca.odell.glazedlists.swing.EventSelectionModel;
import ca.odell.glazedlists.swing.TableComparatorChooser;
import ca.odell.glazedlists.swing.EventTableModel;

import java.awt.*;
import java.util.Comparator;

/**
 * Created by IntelliJ IDEA.
 * User: alver
 * Date: Oct 12, 2005
 * Time: 10:29:39 PM
 * To change this template use File | Settings | File Templates.
 */
public class MainTable extends JTable {
    private MainTableFormat tableFormat;
    private SortedList sortedForTable, sortedForSearch, sortedForGrouping;
    private boolean tableColorCodes, showingFloatSearch=false, showingFloatGrouping=false;
    private EventSelectionModel selectionModel;
    private TableComparatorChooser comparatorChooser;
    private JScrollPane pane;
    private Comparator searchComparator, groupComparator;
    private Matcher searchMatcher, groupMatcher;
    public static final int REQUIRED = 1
    ,
    OPTIONAL = 2
    ,
    OTHER = 3;

    static {
        updateRenderers();
    }

    public MainTable(MainTableFormat tableFormat, EventList list) {
        super();
        this.tableFormat = tableFormat;
        // This SortedList has a Comparator controlled by the TableComparatorChooser
        // we are going to install, which responds to user sorting selctions:
        sortedForTable = new SortedList(list, null);
        // This SortedList applies afterwards, and can float search hits:
        sortedForSearch = new SortedList(sortedForTable, null);
        // This SortedList applies afterwards, and can float grouping hits:
        sortedForGrouping = new SortedList(sortedForSearch, null);


        searchMatcher = null;
        groupMatcher = null;
        searchComparator = null;//new HitOrMissComparator(searchMatcher);
        groupComparator = null;//new HitOrMissComparator(groupMatcher);

        EventTableModel tableModel = new EventTableModel(sortedForGrouping, tableFormat);
        setModel(tableModel);

        tableColorCodes = Globals.prefs.getBoolean("tableColorCodesOn");
        selectionModel = new EventSelectionModel(list);
        setSelectionModel(selectionModel);
        pane = new JScrollPane(this);
        pane.getViewport().setBackground(Globals.prefs.getColor("tableBackground"));
        setGridColor(Globals.prefs.getColor("gridColor"));
        comparatorChooser = new MyTableComparatorChooser(this, sortedForTable, true);
        final EventList selected = getSelected();

        // enable DnD
        setDragEnabled(true);<commit_msg>Fixed selection bug.<commit_after>package net.sf.jabref.gui;

import net.sf.jabref.*;
import net.sf.jabref.search.SearchMatcher;
import net.sf.jabref.search.HitOrMissComparator;
import net.sf.jabref.groups.EntryTableTransferHandler;

import javax.swing.*;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableModel;
import javax.swing.table.TableColumnModel;

import ca.odell.glazedlists.SortedList;
import ca.odell.glazedlists.EventList;
import ca.odell.glazedlists.matchers.Matcher;
import ca.odell.glazedlists.event.ListEventListener;
import ca.odell.glazedlists.swing.EventSelectionModel;
import ca.odell.glazedlists.swing.TableComparatorChooser;
import ca.odell.glazedlists.swing.EventTableModel;

import java.awt.*;
import java.util.Comparator;

/**
 * Created by IntelliJ IDEA.
 * User: alver
 * Date: Oct 12, 2005
 * Time: 10:29:39 PM
 * To change this template use File | Settings | File Templates.
 */
public class MainTable extends JTable {
    private MainTableFormat tableFormat;
    private SortedList sortedForTable, sortedForSearch, sortedForGrouping;
    private boolean tableColorCodes, showingFloatSearch=false, showingFloatGrouping=false;
    private EventSelectionModel selectionModel;
    private TableComparatorChooser comparatorChooser;
    private JScrollPane pane;
    private Comparator searchComparator, groupComparator;
    private Matcher searchMatcher, groupMatcher;
    public static final int REQUIRED = 1
    ,
    OPTIONAL = 2
    ,
    OTHER = 3;

    static {
        updateRenderers();
    }

    public MainTable(MainTableFormat tableFormat, EventList list) {
        super();
        this.tableFormat = tableFormat;
        // This SortedList has a Comparator controlled by the TableComparatorChooser
        // we are going to install, which responds to user sorting selctions:
        sortedForTable = new SortedList(list, null);
        // This SortedList applies afterwards, and can float search hits:
        sortedForSearch = new SortedList(sortedForTable, null);
        // This SortedList applies afterwards, and can float grouping hits:
        sortedForGrouping = new SortedList(sortedForSearch, null);


        searchMatcher = null;
        groupMatcher = null;
        searchComparator = null;//new HitOrMissComparator(searchMatcher);
        groupComparator = null;//new HitOrMissComparator(groupMatcher);

        EventTableModel tableModel = new EventTableModel(sortedForGrouping, tableFormat);
        setModel(tableModel);

        tableColorCodes = Globals.prefs.getBoolean("tableColorCodesOn");
        selectionModel = new EventSelectionModel(sortedForGrouping);
        setSelectionModel(selectionModel);
        pane = new JScrollPane(this);
        pane.getViewport().setBackground(Globals.prefs.getColor("tableBackground"));
        setGridColor(Globals.prefs.getColor("gridColor"));
        comparatorChooser = new MyTableComparatorChooser(this, sortedForTable, true);
        final EventList selected = getSelected();

        // enable DnD
        setDragEnabled(true);
{'fraction_non_alphanumeric': 0.08284120734908136, 'fraction_numerical': 0.004921259842519685, 'mean_word_length': 3.9488636363636362, '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': '7577298', 'n_tokens_mistral': 1729, 'n_tokens_neox': 1692, 'n_words': 405}