<commit_before>package it.backbox.gui;

import it.backbox.gui.bean.TableTask;
import it.backbox.gui.utility.GuiUtility;
import it.backbox.transaction.task.Transaction;

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

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextPane;
import javax.swing.border.EmptyBorder;

import net.miginfocom.swing.MigLayout;

public class DetailsDialog extends JDialog {

	private static final long serialVersionUID = 1L;

	private static DetailsDialog dialog;
	private final JPanel contentPanel = new JPanel();
	private JLabel lblTransactionIdValue;
	private JLabel lblTaskIdValue;
	private JLabel lblFilenameValue;
	private JLabel lblOperationValue;
	private JLabel lblSizeValue;
	private JLabel lblStatusValue;
	private JLabel lblTotalTimeValue;
	private JTextPane txtResult;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		try {
			dialog = new DetailsDialog();
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void updateDetails(TableTask tbt) {
		lblTransactionIdValue.setText(tbt.getTransaction().getId());
		lblTaskIdValue.setText(tbt.getTask().getId());
		lblFilenameValue.setText(tbt.getTask().getDescription());
		lblOperationValue.setText(GuiUtility.getTaskType(tbt.getTask()));
		lblSizeValue.setText(GuiUtility.getTaskSize(tbt.getTask()));
		if (tbt.getTransaction().getResultCode() == Transaction.NO_ESITO)
			lblStatusValue.setText("Not executed");
		else if (tbt.getTransaction().getResultCode() == Transaction.ESITO_KO) {
			lblStatusValue.setText("Error");
			txtResult.setText(tbt.getTransaction().getResultDescription());
		} else if (tbt.getTransaction().getResultCode() == Transaction.ESITO_OK)
			lblStatusValue.setText("Success");
		lblTotalTimeValue.setText(GuiUtility.getTimeString(tbt.getTask().getTotalTime()));
	}
	
	/**
	 * Create the dialog.
	 */
	public DetailsDialog() {
		setModalityType(ModalityType.APPLICATION_MODAL);
		setTitle("Details");
		setBounds(100, 100, 450, 302);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(new MigLayout("", "[125.00,grow][322.00]", "[][][][][][][][][grow]"));
		
		JLabel lblTransactionId = new JLabel("Transaction ID: ");
		contentPanel.add(lblTransactionId, "cell 0 0,alignx right,growy");
		
		lblTransactionIdValue = new JLabel("");
		contentPanel.add(lblTransactionIdValue, "cell 1 0,alignx left,growy");
		
		JLabel lblTaskId = new JLabel("Task ID: ");
		contentPanel.add(lblTaskId, "cell 0 1,alignx right,growy");
		
		lblTaskIdValue = new JLabel("");
		contentPanel.add(lblTaskIdValue, "cell 1 1,alignx left,growy");
		
		JLabel lblFilename = new JLabel("Filename: ");
		contentPanel.add(lblFilename, "cell 0 2,alignx right,growy");
		
		lblFilenameValue = new JLabel("");<commit_msg>details dialog: fix elapsed time<commit_after>package it.backbox.gui;

import it.backbox.gui.bean.TableTask;
import it.backbox.gui.utility.GuiUtility;
import it.backbox.transaction.task.Transaction;

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

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextPane;
import javax.swing.border.EmptyBorder;

import net.miginfocom.swing.MigLayout;

public class DetailsDialog extends JDialog {

	private static final long serialVersionUID = 1L;

	private static DetailsDialog dialog;
	private final JPanel contentPanel = new JPanel();
	private JLabel lblTransactionIdValue;
	private JLabel lblTaskIdValue;
	private JLabel lblFilenameValue;
	private JLabel lblOperationValue;
	private JLabel lblSizeValue;
	private JLabel lblStatusValue;
	private JLabel lblTotalTimeValue;
	private JTextPane txtResult;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		try {
			dialog = new DetailsDialog();
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void updateDetails(TableTask tbt) {
		lblTransactionIdValue.setText(tbt.getTransaction().getId());
		lblTaskIdValue.setText(tbt.getTask().getId());
		lblFilenameValue.setText(tbt.getTask().getDescription());
		lblOperationValue.setText(GuiUtility.getTaskType(tbt.getTask()));
		lblSizeValue.setText(GuiUtility.getTaskSize(tbt.getTask()));
		if (tbt.getTransaction().getResultCode() == Transaction.NO_ESITO)
			lblStatusValue.setText("Not executed");
		else if (tbt.getTransaction().getResultCode() == Transaction.ESITO_KO) {
			lblStatusValue.setText("Error");
			txtResult.setText(tbt.getTransaction().getResultDescription());
		} else if (tbt.getTransaction().getResultCode() == Transaction.ESITO_OK)
			lblStatusValue.setText("Success");
		lblTotalTimeValue.setText(GuiUtility.getTimeString(tbt.getTask().getTotalTime() / 1000));
	}
	
	/**
	 * Create the dialog.
	 */
	public DetailsDialog() {
		setModalityType(ModalityType.APPLICATION_MODAL);
		setTitle("Details");
		setBounds(100, 100, 450, 302);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(new MigLayout("", "[125.00,grow][322.00]", "[][][][][][][][][grow]"));
		
		JLabel lblTransactionId = new JLabel("Transaction ID: ");
		contentPanel.add(lblTransactionId, "cell 0 0,alignx right,growy");
		
		lblTransactionIdValue = new JLabel("");
		contentPanel.add(lblTransactionIdValue, "cell 1 0,alignx left,growy");
		
		JLabel lblTaskId = new JLabel("Task ID: ");
		contentPanel.add(lblTaskId, "cell 0 1,alignx right,growy");
		
		lblTaskIdValue = new JLabel("");
		contentPanel.add(lblTaskIdValue, "cell 1 1,alignx left,growy");
		
		JLabel lblFilename = new JLabel("Filename: ");
		contentPanel.add(lblFilename, "cell 0 2,alignx right,growy");
		
		lblFilenameValue = new JLabel("");
{'fraction_non_alphanumeric': 0.13126188966391883, 'fraction_numerical': 0.012365250475586557, 'mean_word_length': 5.813174946004319, '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': '2266764', 'n_tokens_mistral': 2196, 'n_tokens_neox': 2020, 'n_words': 386}