<commit_before>package org.yamcs.studio.ui.eventlog;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;

import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.yamcs.protobuf.Yamcs.Event;
import org.yamcs.utils.TimeEncoding;

public class EventLogContentProvider implements IStructuredContentProvider {

    private static final Logger log = Logger.getLogger(EventLogContentProvider.class.getName());
    private EventLogViewerComparator eventLogViewerComparator = new EventLogViewerComparator();
    private ArrayList<Event> sortedEvents = new ArrayList<>();
    private Map<Long, Event> eventsBySequenceNumber = new LinkedHashMap<>();
    private Table table;
    private boolean scrollLock;
    private int nbMessageLineToDisplay;
    private int warningCount = 0;
    private int errorCount = 0;
    private int infoCount = 0;

    private Image errorIcon;
    private Image warnIcon;
    private Image infoIcon;

    private Color errorColor;
    private Color warningColor;

    public EventLogContentProvider(Table table) {
        this.table = table;
        if (PlatformUI.isWorkbenchRunning()) {
            errorIcon = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
            warnIcon = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK);
            infoIcon = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_INFO_TSK);
        }
        errorColor = new Color(table.getDisplay(), new RGB(255, 102, 102));
        warningColor = new Color(table.getDisplay(), new RGB(255, 255, 102));
    }

    @Override
    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        // TODO could happen when switching channels
    }

    @Override
    public void dispose() {
        if (errorColor != null)
            errorColor.dispose();
        if (warningColor != null)
            warningColor.dispose();
    }

    @Override
    public Object[] getElements(Object inputElement) {
        return eventsBySequenceNumber.values().toArray();
    }

    public List<Event> getSortedEvents() {
        return sortedEvents;
    }

    public void addEvent(Event event) {
        if (eventsBySequenceNumber.containsKey(primaryKeyHash(event))) {
            // event is already loaded, ignoring it
        } else {
            sortedEvents.add(event); // add to local event list<commit_msg>Soften event bg colors<commit_after>package org.yamcs.studio.ui.eventlog;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;

import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.yamcs.protobuf.Yamcs.Event;
import org.yamcs.utils.TimeEncoding;

public class EventLogContentProvider implements IStructuredContentProvider {

    private static final Logger log = Logger.getLogger(EventLogContentProvider.class.getName());
    private EventLogViewerComparator eventLogViewerComparator = new EventLogViewerComparator();
    private ArrayList<Event> sortedEvents = new ArrayList<>();
    private Map<Long, Event> eventsBySequenceNumber = new LinkedHashMap<>();
    private Table table;
    private boolean scrollLock;
    private int nbMessageLineToDisplay;
    private int warningCount = 0;
    private int errorCount = 0;
    private int infoCount = 0;

    private Image errorIcon;
    private Image warnIcon;
    private Image infoIcon;

    private Color errorColor;
    private Color warningColor;

    public EventLogContentProvider(Table table) {
        this.table = table;
        if (PlatformUI.isWorkbenchRunning()) {
            errorIcon = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
            warnIcon = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK);
            infoIcon = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_INFO_TSK);
        }
        errorColor = new Color(table.getDisplay(), new RGB(255, 221, 221));
        warningColor = new Color(table.getDisplay(), new RGB(248, 238, 199));
    }

    @Override
    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        // TODO could happen when switching processors
    }

    @Override
    public void dispose() {
        if (errorColor != null)
            errorColor.dispose();
        if (warningColor != null)
            warningColor.dispose();
    }

    @Override
    public Object[] getElements(Object inputElement) {
        return eventsBySequenceNumber.values().toArray();
    }

    public List<Event> getSortedEvents() {
        return sortedEvents;
    }

    public void addEvent(Event event) {
        if (eventsBySequenceNumber.containsKey(primaryKeyHash(event))) {
            // event is already loaded, ignoring it
        } else {
            sortedEvents.add(event); // add to local event list
{'fraction_non_alphanumeric': 0.09558701082431308, 'fraction_numerical': 0.0069941715237302245, 'mean_word_length': 3.7216981132075473, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '6966500', 'n_tokens_mistral': 1756, 'n_tokens_neox': 1694, 'n_words': 382}