<commit_before>/*  Copyright (C) 2003-2015 JabRef contributors.
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program 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 General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package net.sf.jabref.gui;

import java.awt.Component;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Frame;
import java.awt.GraphicsEnvironment;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.SortedSet;
import java.util.Vector;
import java.util.stream.Collectors;

import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.table.TableColumn;

import net.sf.jabref.*;
import net.sf.jabref.gui.actions.*;
import net.sf.jabref.gui.desktop.JabRefDesktop;
import net.sf.jabref.gui.keyboard.KeyBinds;
import net.sf.jabref.gui.menus.help.DonateAction;
import net.sf.jabref.gui.worker.AbstractWorker;
import net.sf.jabref.gui.worker.MarkEntriesAction;
import net.sf.jabref.gui.preftabs.PreferencesDialog;
import net.sf.jabref.importer.*;
import net.sf.jabref.importer.fetcher.GeneralFetcher;
import net.sf.jabref.importer.fileformat.ImportFormat;
import net.sf.jabref.logic.id.IdGenerator;
import net.sf.jabref.logic.integrity.IntegrityCheck;
import net.sf.jabref.logic.integrity.IntegrityMessage;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.util.OS;
import net.sf.jabref.model.database.BibtexDatabase;
import net.sf.jabref.model.entry.BibtexEntry;
import net.sf.jabref.model.entry.BibtexEntryType;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import net.sf.jabref.exporter.AutoSaveManager;
import net.sf.jabref.exporter.ExportCustomizationDialog;
import net.sf.jabref.exporter.ExportFormats;
import net.sf.jabref.exporter.SaveAllAction;
import net.sf.jabref.exporter.SaveDatabaseAction;
import net.sf.jabref.external.ExternalFileTypeEditor;
import net.sf.jabref.external.push.PushToApplicationButton;
import net.sf.jabref.external.push.PushToApplications;
import net.sf.jabref.groups.EntryTableTransferHandler;
import net.sf.jabref.groups.GroupSelector;
import net.sf.jabref.gui.menus.help.ForkMeOnGitHubAction;
import net.sf.jabref.gui.help.HelpAction;
import net.sf.jabref.gui.help.HelpDialog;
import net.sf.jabref.gui.journals.ManageJournalsAction;
import net.sf.jabref.openoffice.OpenOfficePanel;
import net.sf.jabref.specialfields.Printed;
import net.sf.jabref.specialfields.Priority;
import net.sf.jabref.specialfields.Quality;
import net.sf.jabref.specialfields.Rank;
import net.sf.jabref.specialfields.ReadStatus;
import net.sf.jabref.specialfields.Relevance;
import net.sf.jabref.specialfields.SpecialFieldsUtils;
import net.sf.jabref.sql.importer.DbImportAction;
import net.sf.jabref.util.ManageKeywordsAction;
import net.sf.jabref.util.MassSetFieldAction;
import net.sf.jabref.logic.util.strings.StringUtil;
import net.sf.jabref.util.Util;

import com.jgoodies.looks.HeaderStyle;
import com.jgoodies.looks.Options;
import osx.macadapter.MacAdapter;

/**
 * The main window of the application.
 */
public class JabRefFrame extends JFrame implements OutputPrinter {
    private static final long serialVersionUID = 1L;
    private static final Log LOGGER = LogFactory.getLog(JabRefFrame.class);

    final JSplitPane contentPane = new JSplitPane();

    final JabRefPreferences prefs = Globals.prefs;
    private PreferencesDialog prefsDialog;

    private int lastTabbedPanelSelectionIndex = -1;

    // The sidepane manager takes care of populating the sidepane. 
    public SidePaneManager sidePaneManager;

    public JTabbedPane tabbedPane; // initialized at constructor

    private final Insets marg = new Insets(1, 0, 2, 0);
    private final JabRef jabRef;
    private final GeneralAction checkIntegrity = new GeneralAction(Actions.CHECK_INTEGRITY, Localization.lang("Check integrity")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            IntegrityCheck check = new IntegrityCheck();
            List<IntegrityMessage> messages = check.checkBibtexDatabase(basePanel().database());

            if (messages.isEmpty()) {
                JOptionPane.showMessageDialog(basePanel(), Localization.lang("No problems found."));
            } else {
                // prepare data model
                Object[][] model = new Object[messages.size()][3];
                int i = 0;
                for (IntegrityMessage message : messages) {
                    model[i][0] = message.getEntry().getCiteKey();
                    model[i][1] = message.getFieldName();
                    model[i][2] = message.getMessage();
                    i++;
                }

                // construct view
                JTable table = new JTable(
                        model,
                        new Object[] {"key", "field", "message"}
                );
                JScrollPane scrollPane = new JScrollPane(table);
                String title = Localization.lang("%0 problem(s) found", String.valueOf(messages.size()));
                JDialog dialog = new JDialog(JabRefFrame.this, title, false);
                dialog.add(scrollPane);
                dialog.setSize(600, 800);

                // show view
                dialog.setVisible(true);
            }<commit_msg>improve default width for table columns<commit_after>/*  Copyright (C) 2003-2015 JabRef contributors.
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program 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 General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package net.sf.jabref.gui;

import java.awt.Component;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Frame;
import java.awt.GraphicsEnvironment;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.SortedSet;
import java.util.Vector;
import java.util.stream.Collectors;

import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.table.TableColumn;

import net.sf.jabref.*;
import net.sf.jabref.gui.actions.*;
import net.sf.jabref.gui.desktop.JabRefDesktop;
import net.sf.jabref.gui.keyboard.KeyBinds;
import net.sf.jabref.gui.menus.help.DonateAction;
import net.sf.jabref.gui.worker.AbstractWorker;
import net.sf.jabref.gui.worker.MarkEntriesAction;
import net.sf.jabref.gui.preftabs.PreferencesDialog;
import net.sf.jabref.importer.*;
import net.sf.jabref.importer.fetcher.GeneralFetcher;
import net.sf.jabref.importer.fileformat.ImportFormat;
import net.sf.jabref.logic.id.IdGenerator;
import net.sf.jabref.logic.integrity.IntegrityCheck;
import net.sf.jabref.logic.integrity.IntegrityMessage;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.util.OS;
import net.sf.jabref.model.database.BibtexDatabase;
import net.sf.jabref.model.entry.BibtexEntry;
import net.sf.jabref.model.entry.BibtexEntryType;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import net.sf.jabref.exporter.AutoSaveManager;
import net.sf.jabref.exporter.ExportCustomizationDialog;
import net.sf.jabref.exporter.ExportFormats;
import net.sf.jabref.exporter.SaveAllAction;
import net.sf.jabref.exporter.SaveDatabaseAction;
import net.sf.jabref.external.ExternalFileTypeEditor;
import net.sf.jabref.external.push.PushToApplicationButton;
import net.sf.jabref.external.push.PushToApplications;
import net.sf.jabref.groups.EntryTableTransferHandler;
import net.sf.jabref.groups.GroupSelector;
import net.sf.jabref.gui.menus.help.ForkMeOnGitHubAction;
import net.sf.jabref.gui.help.HelpAction;
import net.sf.jabref.gui.help.HelpDialog;
import net.sf.jabref.gui.journals.ManageJournalsAction;
import net.sf.jabref.openoffice.OpenOfficePanel;
import net.sf.jabref.specialfields.Printed;
import net.sf.jabref.specialfields.Priority;
import net.sf.jabref.specialfields.Quality;
import net.sf.jabref.specialfields.Rank;
import net.sf.jabref.specialfields.ReadStatus;
import net.sf.jabref.specialfields.Relevance;
import net.sf.jabref.specialfields.SpecialFieldsUtils;
import net.sf.jabref.sql.importer.DbImportAction;
import net.sf.jabref.util.ManageKeywordsAction;
import net.sf.jabref.util.MassSetFieldAction;
import net.sf.jabref.logic.util.strings.StringUtil;
import net.sf.jabref.util.Util;

import com.jgoodies.looks.HeaderStyle;
import com.jgoodies.looks.Options;
import osx.macadapter.MacAdapter;

/**
 * The main window of the application.
 */
public class JabRefFrame extends JFrame implements OutputPrinter {
    private static final long serialVersionUID = 1L;
    private static final Log LOGGER = LogFactory.getLog(JabRefFrame.class);

    final JSplitPane contentPane = new JSplitPane();

    final JabRefPreferences prefs = Globals.prefs;
    private PreferencesDialog prefsDialog;

    private int lastTabbedPanelSelectionIndex = -1;

    // The sidepane manager takes care of populating the sidepane. 
    public SidePaneManager sidePaneManager;

    public JTabbedPane tabbedPane; // initialized at constructor

    private final Insets marg = new Insets(1, 0, 2, 0);
    private final JabRef jabRef;
    private final GeneralAction checkIntegrity = new GeneralAction(Actions.CHECK_INTEGRITY, Localization.lang("Check integrity")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            IntegrityCheck check = new IntegrityCheck();
            List<IntegrityMessage> messages = check.checkBibtexDatabase(basePanel().database());

            if (messages.isEmpty()) {
                JOptionPane.showMessageDialog(basePanel(), Localization.lang("No problems found."));
            } else {
                // prepare data model
                Object[][] model = new Object[messages.size()][3];
                int i = 0;
                for (IntegrityMessage message : messages) {
                    model[i][0] = message.getEntry().getCiteKey();
                    model[i][1] = message.getFieldName();
                    model[i][2] = message.getMessage();
                    i++;
                }

                // construct view
                JTable table = new JTable(
                        model,
                        new Object[] {"key", "field", "message"}
                );
                table.getColumnModel().getColumn(0).setPreferredWidth(80);
                table.getColumnModel().getColumn(1).setPreferredWidth(30);
                table.getColumnModel().getColumn(2).setPreferredWidth(250);
                table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
                JScrollPane scrollPane = new JScrollPane(table);
                String title = Localization.lang("%0 problem(s) found", String.valueOf(messages.size()));
                JDialog dialog = new JDialog(JabRefFrame.this, title, false);
                dialog.add(scrollPane);
                dialog.setSize(600, 500);

                // show view
                dialog.setVisible(true);
            }
{'fraction_non_alphanumeric': 0.0994169758461422, 'fraction_numerical': 0.006814568032104187, 'mean_word_length': 3.546643717728055, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6980004', 'n_tokens_mistral': 4076, 'n_tokens_neox': 3827, 'n_words': 895}