package TestingSystem.SAPFOR.SapforPackage;
import Common.Current;
import Common.Database.iDBTable;
import Common.UI.DataSetControlForm;

import java.util.Date;

import static Common.UI.Tables.TableRenderers.*;
public class SapforPackageDBTable extends iDBTable<SapforPackage> {
    @Override
    public Current CurrentName() {
        return Current.SapforPackage;
    }
    @Override
    public String getSingleDescription() {
        return "пакет задач SAPFOR";
    }
    @Override
    public String getPluralDescription() {
        return "пакеты задач SAPFOR";
    }
    public SapforPackageDBTable() {
        super(SapforPackage.class);
    }
    @Override
    protected DataSetControlForm createUI() {
        return new DataSetControlForm(this) {
            @Override
            public boolean hasCheckBox() {
                return true;
            }
            @Override
            protected void AdditionalInitColumns() {
                //   columns.get(0).setVisible(false);
                columns.get(4).setMaxWidth(200);
                columns.get(7).setRenderer(RendererProgress);
                columns.get(8).setRenderer(RendererDate);
                columns.get(9).setRenderer(RendererDate);
                columns.get(10).setRenderer(RendererStatusEnum);
            }
        };
    }
    @Override
    public String[] getUIColumnNames() {
        return new String[]{
                "Автор",
                "SAPFOR",
                "Тесты",
                "Задач",
                "Ядер",
                "Прогресс",
                "Начало",
                "Изменено",
                "Статус"
        };
    }
    @Override
    public Object getFieldAt(SapforPackage object, int columnIndex) {
        switch (columnIndex) {
            case 2:
                return object.sender_name;
            case 3:
                return object.version;
            case 4:
                return object.testsNames;
            case 5:
                return object.tasksCount;
            case 6:
                return object.kernels;
            case 7:
                return object.progress;
            case 8:
                return new Date(object.StartDate);
            case 9:
                return new Date(object.ChangeDate);
            case 10:
                return object.state;
            default:
                return null;
        }
    }
}
