<commit_before>package comeon.ui.actions;

import in.yuvi.http.fluent.ProgressListener;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;

import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JProgressBar;
import javax.swing.SwingUtilities;

import comeon.Core;
import comeon.UploadMonitor;
import comeon.ui.UI;

public final class UploadPicturesAction extends BaseAction {
  private static final long serialVersionUID = 1L;

  public UploadPicturesAction(final UI ui) {
    super("upload", ui);
  }

  @Override
  public void actionPerformed(final ActionEvent e) {
    Core.getInstance().uploadPictures(new Monitor());
  }

  private final class Monitor extends JOptionPane implements UploadMonitor {
    private static final long serialVersionUID = 1L;

    private final JDialog dialog;

    private final JProgressBar batchBar;

    private final JProgressBar pictureBar;

    public Monitor() {
      super(null, JOptionPane.INFORMATION_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new Object[0]);
      this.batchBar = new JProgressBar(JProgressBar.HORIZONTAL);
      this.pictureBar = new JProgressBar(JProgressBar.HORIZONTAL);
      this.pictureBar.setStringPainted(true);
      // TODO i18n
      this.dialog = new JDialog(UploadPicturesAction.this.ui, "Progress", true);
      this.dialog.getContentPane().setLayout(new BorderLayout());
      this.dialog.getContentPane().add(this, BorderLayout.CENTER);
      this.dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
      this.dialog.pack();
      this.setMessage(new Object[] { batchBar, pictureBar });
    }

    @Override
    public void setBatchSize(final int size) {
      SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
          Monitor.this.batchBar.setMaximum(size);
        }
      });
    }

    @Override
    public void uploadStarting() {
      SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
          Monitor.this.batchBar.setValue(0);
          Monitor.this.dialog.setVisible(true);
        }
      });
    }

    @Override
    public ProgressListener itemStarting(final int index, final long length, final String name) {
      SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
          Monitor.this.pictureBar.setMaximum((int) length);<commit_msg>Meilleure utilisation de JOptionPane<commit_after>package comeon.ui.actions;

import in.yuvi.http.fluent.ProgressListener;

import java.awt.event.ActionEvent;

import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JProgressBar;
import javax.swing.SwingUtilities;

import comeon.Core;
import comeon.UploadMonitor;
import comeon.ui.UI;

public final class UploadPicturesAction extends BaseAction {
  private static final long serialVersionUID = 1L;

  public UploadPicturesAction(final UI ui) {
    super("upload", ui);
  }

  @Override
  public void actionPerformed(final ActionEvent e) {
    Core.getInstance().uploadPictures(new Monitor());
  }

  private final class Monitor extends JOptionPane implements UploadMonitor {
    private static final long serialVersionUID = 1L;

    private final JDialog dialog;

    private final JProgressBar batchBar;

    private final JProgressBar pictureBar;

    public Monitor() {
      super(null, JOptionPane.INFORMATION_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new Object[0]);
      this.batchBar = new JProgressBar(JProgressBar.HORIZONTAL);
      this.pictureBar = new JProgressBar(JProgressBar.HORIZONTAL);
      this.pictureBar.setStringPainted(true);
      this.setMessage(new Object[] { batchBar, pictureBar });
      // TODO i18n
      this.dialog = this.createDialog(UploadPicturesAction.this.ui, "Progress");
    }

    @Override
    public void setBatchSize(final int size) {
      SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
          Monitor.this.batchBar.setMaximum(size);
        }
      });
    }

    @Override
    public void uploadStarting() {
      SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
          Monitor.this.batchBar.setValue(0);
          Monitor.this.dialog.setVisible(true);
        }
      });
    }

    @Override
    public ProgressListener itemStarting(final int index, final long length, final String name) {
      SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
          Monitor.this.pictureBar.setMaximum((int) length);
{'fraction_non_alphanumeric': 0.09427757070817804, 'fraction_numerical': 0.00263100197325148, 'mean_word_length': 3.399228543876567, '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': '3432771', 'n_tokens_mistral': 1345, 'n_tokens_neox': 1296, 'n_words': 294}