<commit_before>package de.andreasgiemza.mangamanager.mangadetails;

import de.andreasgiemza.mangamanager.data.ChapterForSubscription;
import de.andreasgiemza.mangamanager.data.Subscription;

/**
 *
 * @author <NAME> <<EMAIL>>
 */
public class MangaDetails extends javax.swing.JDialog {

    private final Subscription subscription;
    private final ChapterForSubscriptionTableModel chapterForSubscriptionTableModel;

    public MangaDetails(java.awt.Frame parent, boolean modal, Subscription subscription) {
        super(parent, modal);
        this.subscription = subscription;
        this.chapterForSubscriptionTableModel = new ChapterForSubscriptionTableModel(subscription.getChapters());
        initComponents();

        setLocation(parent.getX() + (parent.getWidth() / 2) - (getWidth() / 2),
                parent.getY() + (parent.getHeight() / 2) - (getHeight() / 2));

        setTitle(subscription.getSite().getName() + " - " + subscription.getManga().getTitle());
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        chaptersScrollPane = new javax.swing.JScrollPane();
        chaptersTable = new javax.swing.JTable();
        markReadButton = new javax.swing.JButton();
        markUnreadButton = new javax.swing.JButton();
        closeButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        chaptersTable.setModel(chapterForSubscriptionTableModel);
        chaptersScrollPane.setViewportView(chaptersTable);

        markReadButton.setText("Mark read");
        markReadButton.addActionListener(new java.awt.event.ActionListener() {<commit_msg>Double click on a chapter in MangaDetails open it in the browser<commit_after>package de.andreasgiemza.mangamanager.mangadetails;

import de.andreasgiemza.mangamanager.data.ChapterForSubscription;
import de.andreasgiemza.mangamanager.data.Subscription;
import java.awt.Desktop;
import java.awt.Point;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import javax.swing.JTable;

/**
 *
 * @author <NAME> <<EMAIL>>
 */
public class MangaDetails extends javax.swing.JDialog {

    private final ChapterForSubscriptionTableModel chapterForSubscriptionTableModel;

    public MangaDetails(java.awt.Frame parent, boolean modal, Subscription subscription) {
        super(parent, modal);
        this.chapterForSubscriptionTableModel = new ChapterForSubscriptionTableModel(subscription.getChapters());
        initComponents();

        setLocation(parent.getX() + (parent.getWidth() / 2) - (getWidth() / 2),
                parent.getY() + (parent.getHeight() / 2) - (getHeight() / 2));

        setTitle(subscription.getSite().getName() + " - " + subscription.getManga().getTitle());

        chaptersTable.addMouseListener(new MouseAdapter() {
            @Override
            public void mousePressed(MouseEvent me) {
                JTable table = (JTable) me.getSource();
                Point p = me.getPoint();
                int row = table.rowAtPoint(p);
                if (me.getClickCount() == 2) {
                    ChapterForSubscription selectedChapter = ((ChapterForSubscriptionTableModel) chaptersTable.getModel()).getChapter(chaptersTable.convertRowIndexToModel(row));

                    try {
                        Desktop.getDesktop().browse(new URI(selectedChapter.getLink()));
                    } catch (URISyntaxException | IOException ex) {
                    }
                }
            }
        });
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        chaptersScrollPane = new javax.swing.JScrollPane();
        chaptersTable = new javax.swing.JTable();
        markReadButton = new javax.swing.JButton();
        markUnreadButton = new javax.swing.JButton();
        closeButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        chaptersTable.setModel(chapterForSubscriptionTableModel);
        chaptersScrollPane.setViewportView(chaptersTable);

        markReadButton.setText("Mark read");
        markReadButton.addActionListener(new java.awt.event.ActionListener() {
{'fraction_non_alphanumeric': 0.1055532870559412, 'fraction_numerical': 0.0018374846876276032, 'mean_word_length': 3.2232758620689657, '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': '4557654', 'n_tokens_mistral': 1343, 'n_tokens_neox': 1319, 'n_words': 270}