package _VisualDVM.ProjectData.SapforData.Variants.UI;
import Common.Database.Tables.DataSet;
import Common.Visual.DataSetControlForm;
import Common.Visual.Menus.DataMenuBar;
import Common.Visual.Tables.ColumnInfo;
import Common.Visual.Tables.RendererDate;
import Common.Visual.Tables.RendererMaskedNanInteger;
import Common.Visual.Tables.RendererMultiline;
import _VisualDVM.Passes.PassCode;
import _VisualDVM.ProjectData.SapforData.Variants.ParallelVariant;

import javax.swing.*;
public class ParallelVariantsForm extends DataSetControlForm<ParallelVariant> {
    public ParallelVariantsForm(DataSet<?, ParallelVariant> dataSource_in, JPanel mountPanel_in) {
        super(dataSource_in, mountPanel_in);
    }
    @Override
    protected boolean isPKVisible() {
        return false;
    }
    @Override
    protected void createColumns() {
        AddColumns(
                new ColumnInfo<ParallelVariant>("Распределение") {
                    @Override
                    public Object getFieldAt(ParallelVariant object) {
                        return object.templates_description;
                    }
                    @Override
                    public Class getRendererClass() {
                        return RendererMultiline.class;
                    }
                },
                new ColumnInfo<ParallelVariant>("PARALLEL") {
                    @Override
                    public Object getFieldAt(ParallelVariant object) {
                        return object.stats.ParallelCount;
                    }
                    @Override
                    public Class getRendererClass() {
                        return RendererMaskedNanInteger.class;
                    }
                },
                new ColumnInfo<ParallelVariant>("REMOTE") {
                    @Override
                    public Object getFieldAt(ParallelVariant object) {
                        return object.stats.RemoteCount;
                    }
                    @Override
                    public Class getRendererClass() {
                        return RendererMaskedNanInteger.class;
                    }
                },
                new ColumnInfo<ParallelVariant>("REDISTRIBUTE") {
                    @Override
                    public Object getFieldAt(ParallelVariant object) {
                        return object.stats.RedistributeCount;
                    }
                    @Override
                    public Class getRendererClass() {
                        return RendererMaskedNanInteger.class;
                    }
                },
                new ColumnInfo<ParallelVariant>("INTERVALS") {
                    @Override
                    public Object getFieldAt(ParallelVariant object) {
                        return object.stats.IntervalCount;
                    }
                    @Override
                    public Class getRendererClass() {
                        return RendererMaskedNanInteger.class;
                    }
                },
                new ColumnInfo<ParallelVariant>("PS.REMOTE") {
                    @Override
                    public Object getFieldAt(ParallelVariant object) {
                        return object.stats.PS_RemoteCount;
                    }
                    @Override
                    public Class getRendererClass() {
                        return RendererMaskedNanInteger.class;
                    }
                },
                new ColumnInfo<ParallelVariant>("PS.SHADOW") {
                    @Override
                    public Object getFieldAt(ParallelVariant object) {
                        return object.stats.PS_ShadowCount;
                    }
                    @Override
                    public Class getRendererClass() {
                        return RendererMaskedNanInteger.class;
                    }
                },
                new ColumnInfo<ParallelVariant>("PS.REDUCTION") {
                    @Override
                    public Object getFieldAt(ParallelVariant object) {
                        return object.stats.PS_ReductionCount;
                    }
                    @Override
                    public Class getRendererClass() {
                        return RendererMaskedNanInteger.class;
                    }
                },
                new ColumnInfo<ParallelVariant>("PS.ACROSS") {
                    @Override
                    public Object getFieldAt(ParallelVariant object) {
                        return object.stats.PS_AcrossCount;
                    }
                    @Override
                    public Class getRendererClass() {
                        return RendererMaskedNanInteger.class;
                    }
                },
                new ColumnInfo<ParallelVariant>("Оценка") {
                    @Override
                    public Object getFieldAt(ParallelVariant object) {
                        return object.stats.TotalScore;
                    }
                    @Override
                    public Class getRendererClass() {
                        return RendererVariantRank.class;
                    }
                },
                new ColumnInfo<ParallelVariant>("Дата оценки") {
                    @Override
                    public Object getFieldAt(ParallelVariant object) {
                        return object.stats.PredictionTime;
                    }
                    @Override
                    public Class getRendererClass() {
                        return RendererDate.class;
                    }
                },
                new ColumnInfo<ParallelVariant>("Версия") {
                    @Override
                    public Object getFieldAt(ParallelVariant object) {
                        return object.stats.last_version;
                    }
                }
        );
    }
    @Override
    public DataMenuBar createMenuBar() {
        return new DataMenuBar(dataSource.getPluralDescription(),
                PassCode.ShowAllParallelVariants,
                PassCode.ShowParallelVariantsCoverage,
                PassCode.PredictParallelVariants,
                PassCode.CreateParallelVariants);
    }
}
