<commit_before>package de.uni.freiburg.iig.telematik.swat.logs;

import de.invation.code.toval.file.FileUtils;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JEditorPane;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.SpringLayout;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import org.processmining.analysis.sciffchecker.logic.interfaces.ISciffLogReader;

import de.invation.code.toval.file.MonitoredInputStream;
import de.invation.code.toval.graphic.util.SpringUtilities;
import de.invation.code.toval.parser.ParserException;
import de.invation.code.toval.properties.PropertyException;
import de.invation.code.toval.validate.ParameterException;
import de.uni.freiburg.iig.telematik.sewol.parser.AbstractLogParser;
import de.uni.freiburg.iig.telematik.sewol.parser.ParsingMode;
import de.uni.freiburg.iig.telematik.sewol.parser.mxml.MXMLLogParser;
import de.uni.freiburg.iig.telematik.sewol.parser.xes.XESLogParser;
import de.uni.freiburg.iig.telematik.swat.aristaFlow.AristaFlowParser;
import de.uni.freiburg.iig.telematik.swat.aristaFlow.AristaFlowParser.whichTimestamp;
import de.uni.freiburg.iig.telematik.swat.icons.IconFactory;
import de.uni.freiburg.iig.telematik.swat.plugin.sciff.LogParserAdapter;
import de.uni.freiburg.iig.telematik.swat.workbench.Workbench;
import de.uni.freiburg.iig.telematik.swat.workbench.action.SciffAnalyzeAction;
import de.uni.freiburg.iig.telematik.wolfgang.editor.component.ViewComponent;
import java.nio.charset.Charset;
import java.util.Objects;

/**
 * presents view on mxml files. extends {@link JEditorPane}, implements
 * {@link ViewComponent}
 *
 */
public class LogFileViewer extends JScrollPane implements ViewComponent {

        private static final long serialVersionUID = 7051631037013916120L;
        
        private static final long FILE_TOO_BIG_SIZE = 2097152l;
        
        private JComponent properties = null;
        private JButton analyzeButton = null;
        private JComponent mainComponent;
        private final JProgressBar bar = new JProgressBar();

        private LogModel model;
        private ISciffLogReader logReader = null;
        private MXMLLogParser p;

        public LogFileViewer(LogModel model) throws Exception {
                this.model = model;
        }

        public LogModel getModel() {
                return model;
        }

        public void setModel(LogModel model) {
                this.model = model;
        }

        @Override
        public JComponent getMainComponent() {
                try {
                        mainComponent = getEditorField();
                        getViewport().add(mainComponent);
                        mainComponent.revalidate();
                        mainComponent.repaint();
                } catch (MalformedURLException e) {
                        Workbench.errorMessage("Could not generate Log viewer, URL malformed", e, true);
                } catch (IOException e) {
                        Workbench.errorMessage("Could not generate Log viewer, I/O Error", e, true);
                }
                return this;
        }

        private JComponent getEditorField() throws MalformedURLException, IOException {
                if (model.getFileReference().length() > FILE_TOO_BIG_SIZE) {
                        p = new MXMLLogParser();
                        return getParserPanel(p, getFileReference(), getFileReference().length());
                } else {
                        JEditorPane editor = new JEditorPane(model.getFileReference().toURI().toURL());
                        editor.setEditable(false);
                        return editor;
                }
        }
<commit_msg>resolved conflict from cherry picking<commit_after>package de.uni.freiburg.iig.telematik.swat.logs;

import de.invation.code.toval.file.FileUtils;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JEditorPane;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.SpringLayout;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import org.processmining.analysis.sciffchecker.logic.interfaces.ISciffLogReader;

import de.invation.code.toval.file.MonitoredInputStream;
import de.invation.code.toval.graphic.util.SpringUtilities;
import de.invation.code.toval.parser.ParserException;
import de.invation.code.toval.properties.PropertyException;
import de.invation.code.toval.validate.ParameterException;
import de.uni.freiburg.iig.telematik.sewol.parser.AbstractLogParser;
import de.uni.freiburg.iig.telematik.sewol.parser.ParsingMode;
import de.uni.freiburg.iig.telematik.sewol.parser.mxml.MXMLLogParser;
import de.uni.freiburg.iig.telematik.sewol.parser.xes.XESLogParser;
import de.uni.freiburg.iig.telematik.swat.aristaFlow.AristaFlowParser;
import de.uni.freiburg.iig.telematik.swat.aristaFlow.AristaFlowParser.whichTimestamp;
import de.uni.freiburg.iig.telematik.swat.icons.IconFactory;
import de.uni.freiburg.iig.telematik.swat.plugin.sciff.LogParserAdapter;
import de.uni.freiburg.iig.telematik.swat.workbench.Workbench;
import de.uni.freiburg.iig.telematik.swat.workbench.action.SciffAnalyzeAction;
import de.uni.freiburg.iig.telematik.wolfgang.editor.component.ViewComponent;
import java.nio.charset.Charset;
import java.util.Objects;

/**
 * presents view on mxml files. extends {@link JEditorPane}, implements
 * {@link ViewComponent}
 *
 */
public class LogFileViewer extends JScrollPane implements ViewComponent {

        private static final long serialVersionUID = 7051631037013916120L;
        
        private static final long FILE_TOO_BIG_SIZE = 2097152l;
        
        private JComponent properties = null;
        private JButton analyzeButton = null;
        private JComponent mainComponent;
        private final JProgressBar bar = new JProgressBar();

        private LogModel model;
        private ISciffLogReader logReader = null;
        private AbstractLogParser p;

        public LogFileViewer(LogModel model) throws Exception {
                this.model = model;
        }

        public LogModel getModel() {
                return model;
        }

        public void setModel(LogModel model) {
                this.model = model;
        }

        @Override
        public JComponent getMainComponent() {
                try {
                        mainComponent = getEditorField();
                        getViewport().add(mainComponent);
                        mainComponent.revalidate();
                        mainComponent.repaint();
                } catch (MalformedURLException e) {
                        Workbench.errorMessage("Could not generate Log viewer, URL malformed", e, true);
                } catch (IOException e) {
                        Workbench.errorMessage("Could not generate Log viewer, I/O Error", e, true);
                }
                return this;
        }

        private JComponent getEditorField() throws MalformedURLException, IOException {
                if (model.getFileReference().length() > FILE_TOO_BIG_SIZE) {
                        if (model.getFileReference().getName().toLowerCase().endsWith(".mxml")) {
                                p = new MXMLLogParser();
                        } else if (model.getFileReference().getName().toLowerCase().endsWith(".xes")) {
                                p = new XESLogParser();
                        } else {
                                // TODO
                        }
                        return getParserPanel(p, getFileReference(), getFileReference().length());
                } else {
                        JEditorPane editor = new JEditorPane(model.getFileReference().toURI().toURL());
                        editor.setEditable(false);
                        return editor;
                }
        }

{'fraction_non_alphanumeric': 0.09227637679520524, 'fraction_numerical': 0.0058803573447924916, 'mean_word_length': 2.705069124423963, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 5}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4822710', 'n_tokens_mistral': 2596, 'n_tokens_neox': 2475, 'n_words': 456}