<commit_before>package org.yamcs.ui.archivebrowser;

import org.yamcs.TimeInterval;
import org.yamcs.protobuf.Yamcs.ArchiveRecord;
import org.yamcs.protobuf.Yamcs.ArchiveTag;
import org.yamcs.protobuf.Yamcs.IndexResult;
import org.yamcs.ui.UiColors;

import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
import java.awt.event.AWTEventListener;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryPoolMXBean;
import java.lang.management.MemoryType;
import java.util.*;
import java.util.List;

/**
 * Main panel of the ArchiveBrowser
 * @author nm
 *
 */
public class ArchivePanel extends JPanel implements PropertyChangeListener {
    private static final long serialVersionUID = 1L;

    ProgressMonitor progressMonitor;
    
    ArchiveBrowser archiveBrowser;
    JLabel totalRangeLabel;
    JLabel statusInfoLabel;
    JLabel instanceLabel;

    private LinkedHashMap<String,NavigatorItem> itemsByName=new LinkedHashMap<String, NavigatorItem>();

    SideNavigator sideNavigator;
    JToolBar archiveToolbar;
    protected PrefsToolbar prefs;
    
    private JPanel insetPanel; // Contains switchable navigator insets (depends on open item)
    private JPanel navigatorItemPanel; // Contains switchable items
    private NavigatorItem activeItem; // Currently opened item from SideNav
    public ReplayPanel replayPanel;
    
    int loadCount, recCount;
    boolean passiveUpdate = false;
   
    private TimeInterval receivedDataInterval = new TimeInterval();
    
    volatile boolean lowOnMemoryReported=false;
    
    //used to check for out of memory errors that may happen when receiving too many archive records 
    MemoryPoolMXBean heapMemoryPoolBean = null;
        
    public ArchivePanel(ArchiveBrowser archiveBrowser,  boolean replayEnabled)	{
        super(new BorderLayout());
        this.archiveBrowser=archiveBrowser;
        
        /*
         * Upper fixed content
         */
        Box fixedTop = Box.createVerticalBox();
        fixedTop.setBorder(BorderFactory.createMatteBorder(0, 0, 2, 0, UiColors.BORDER_COLOR));
        prefs = new PrefsToolbar();
        prefs.setAlignmentX(Component.LEFT_ALIGNMENT);
        fixedTop.add(prefs);
        
        archiveToolbar = new JToolBar();
        archiveToolbar.setFloatable(false);
        archiveToolbar.setAlignmentX(Component.LEFT_ALIGNMENT);
        fixedTop.add(archiveToolbar);
        
        //
        // transport control panel (only enabled when a HRDP data channel is selected)
        //
        if (replayEnabled) {
            replayPanel = new ReplayPanel();
            replayPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Replay Control"));
            replayPanel.setToolTipText("Doubleclick between the start/stop locators to reposition the replay.");
            replayPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
           fixedTop.add(replayPanel);
        }

        // This is a bit clumsy right now with the inner classes, but will make more
        // sense once we add custom components to different DataViewers.
        DataViewer allViewer = new DataViewer(archiveBrowser.yconnector, archiveBrowser.indexReceiver, this, replayEnabled) {
            @Override
            public String getLabelName() {
                return "Archive";
            }

            @Override
            public JComponent createContentPanel() {
                JComponent component = super.createContentPanel();
                addIndex("completeness", "completeness index");
                addIndex("tm", "tm histogram", 1000);
                addIndex("pp", "pp histogram", 1000);
                addIndex("cmdhist", "cmdhist histogram", 1000);
                addVerticalGlue();
                return component;
            }
        };
        itemsByName.put(allViewer.getLabelName(), allViewer);

        DataViewer completenessViewer = new DataViewer(archiveBrowser.yconnector, archiveBrowser.indexReceiver, this, false) {
            @Override
            public String getLabelName() {
                return "Completeness";
            }

            @Override
            public int getIndent() {
                return 1;
            }

            @Override
            public JComponent createContentPanel() {
                JComponent component = super.createContentPanel();
                addIndex("completeness", "completeness index");
                addVerticalGlue();
                return component;
            }<commit_msg>Archive browser: clarify Completeness<commit_after>package org.yamcs.ui.archivebrowser;

import org.yamcs.TimeInterval;
import org.yamcs.protobuf.Yamcs.ArchiveRecord;
import org.yamcs.protobuf.Yamcs.ArchiveTag;
import org.yamcs.protobuf.Yamcs.IndexResult;
import org.yamcs.ui.UiColors;

import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
import java.awt.event.AWTEventListener;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryPoolMXBean;
import java.lang.management.MemoryType;
import java.util.*;
import java.util.List;

/**
 * Main panel of the ArchiveBrowser
 * @author nm
 *
 */
public class ArchivePanel extends JPanel implements PropertyChangeListener {
    private static final long serialVersionUID = 1L;

    ProgressMonitor progressMonitor;
    
    ArchiveBrowser archiveBrowser;
    JLabel totalRangeLabel;
    JLabel statusInfoLabel;
    JLabel instanceLabel;

    private LinkedHashMap<String,NavigatorItem> itemsByName=new LinkedHashMap<String, NavigatorItem>();

    SideNavigator sideNavigator;
    JToolBar archiveToolbar;
    protected PrefsToolbar prefs;
    
    private JPanel insetPanel; // Contains switchable navigator insets (depends on open item)
    private JPanel navigatorItemPanel; // Contains switchable items
    private NavigatorItem activeItem; // Currently opened item from SideNav
    public ReplayPanel replayPanel;
    
    int loadCount, recCount;
    boolean passiveUpdate = false;
   
    private TimeInterval receivedDataInterval = new TimeInterval();
    
    volatile boolean lowOnMemoryReported=false;
    
    //used to check for out of memory errors that may happen when receiving too many archive records 
    MemoryPoolMXBean heapMemoryPoolBean = null;
        
    public ArchivePanel(ArchiveBrowser archiveBrowser,  boolean replayEnabled)	{
        super(new BorderLayout());
        this.archiveBrowser=archiveBrowser;
        
        /*
         * Upper fixed content
         */
        Box fixedTop = Box.createVerticalBox();
        fixedTop.setBorder(BorderFactory.createMatteBorder(0, 0, 2, 0, UiColors.BORDER_COLOR));
        prefs = new PrefsToolbar();
        prefs.setAlignmentX(Component.LEFT_ALIGNMENT);
        fixedTop.add(prefs);
        
        archiveToolbar = new JToolBar();
        archiveToolbar.setFloatable(false);
        archiveToolbar.setAlignmentX(Component.LEFT_ALIGNMENT);
        fixedTop.add(archiveToolbar);
        
        //
        // transport control panel (only enabled when a HRDP data channel is selected)
        //
        if (replayEnabled) {
            replayPanel = new ReplayPanel();
            replayPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Replay Control"));
            replayPanel.setToolTipText("Doubleclick between the start/stop locators to reposition the replay.");
            replayPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
           fixedTop.add(replayPanel);
        }

        // This is a bit clumsy right now with the inner classes, but will make more
        // sense once we add custom components to different DataViewers.
        DataViewer allViewer = new DataViewer(archiveBrowser.yconnector, archiveBrowser.indexReceiver, this, replayEnabled) {
            @Override
            public String getLabelName() {
                return "Archive";
            }

            @Override
            public JComponent createContentPanel() {
                JComponent component = super.createContentPanel();
                addIndex("completeness", "completeness index");
                addIndex("tm", "tm histogram", 1000);
                addIndex("pp", "pp histogram", 1000);
                addIndex("cmdhist", "cmdhist histogram", 1000);
                addVerticalGlue();
                return component;
            }
        };
        itemsByName.put(allViewer.getLabelName(), allViewer);

        DataViewer completenessViewer = new DataViewer(archiveBrowser.yconnector, archiveBrowser.indexReceiver, this, false) {
            @Override
            public String getLabelName() {
                return "Telemetry Completeness";
            }

            @Override
            public int getIndent() {
                return 1;
            }

            @Override
            public JComponent createContentPanel() {
                JComponent component = super.createContentPanel();
                addIndex("completeness", "completeness index");
                addVerticalGlue();
                return component;
            }
{'fraction_non_alphanumeric': 0.07871064467766117, 'fraction_numerical': 0.003855215249518098, 'mean_word_length': 2.6580493537015277, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '7151973', 'n_tokens_mistral': 2452, 'n_tokens_neox': 2350, 'n_words': 598}