package TestingSystem.Common;
import Common.Current;
import Common.UI.StatusEnum;
import Common.UI.Themes.VisualiserFonts;

import java.awt.*;
import java.util.Arrays;
import java.util.Vector;
import java.util.stream.Collectors;
public enum TasksPackageState implements StatusEnum {
    Draft,
    //--
    Queued,
    //--
    TestsSynchronize, //оставить.
    PackageWorkspaceCreation,
    PackageStart,
    //
    CompilationWorkspacesCreation,
    CompilationPreparation,
    CompilationExecution,
    //-
    RunningWorkspacesCreation,
    RunningPreparation,
    RunningExecution,
    //--
    RunningEnd, //скачка архива
    //---------------------------------------
    Analysis,
    Done,
    Aborted;
    public boolean isActive() {
        switch (this) {
            case Done:
            case Aborted:
            case Draft:
                return false;
            default:
                return true;
        }
    }
    @Override
    public Font getFont() {
        switch (this) {
            case TestsSynchronize:
            case Analysis:
            case Draft:
                return Current.getTheme().Fonts.get(VisualiserFonts.BlueState);
            case CompilationExecution:
            case RunningExecution:
                return Current.getTheme().Fonts.get(VisualiserFonts.ProgressState);
            case Done:
                return Current.getTheme().Fonts.get(VisualiserFonts.GoodState);
            default:
                return StatusEnum.super.getFont();
        }
    }
    //-
    public String getDescription() {
        switch (this) {
            case Draft:
                return "Подготовка к публикации";
            case Aborted:
                return "Прерван";
            case Queued:
                return "в очереди";
            case TestsSynchronize:
                return "синхронизация тестов";
            case PackageWorkspaceCreation:
                return "создание рабочей папки пакета";
            case PackageStart:
                return "старт пакета";
            case CompilationWorkspacesCreation:
                return "создание рабочих папок компиляции";
            case CompilationPreparation:
                return "подготовка к компиляции";
            case CompilationExecution:
                return "компиляция";
            case RunningWorkspacesCreation:
                return "создание рабочих папок для запуска";
            case RunningPreparation:
                return "подготовка к запуску";
            case RunningExecution:
                return "запуск";
            case RunningEnd:
                return "загрузка результатов";
            case Analysis:
                return "анализ результатов";
            case Done:
                return "завершен";
            default:
                return StatusEnum.super.getDescription();
        }
    }

    public Vector<TasksPackageState> getHigherStates(){
        return Arrays.stream(values()).filter(state -> state.ordinal() > this.ordinal()).collect(Collectors.toCollection(Vector::new));
    }

}
