package _VisualDVM.Visual.Tables;
import Common.MainModule_;
import Common.Utils.Utils_;
import Common.Visual.Tables.RendererCell;
import _VisualDVM.TestingSystem.Common.TasksPackageState;
import _VisualDVM.TestingSystem.Common.TestingPackage.TestingPackage;

import javax.swing.*;
public class RendererTestingPackageStatus extends RendererCell<TestingPackage> {
    @Override
    public TestingPackage Init(JTable table, Object value, int row, int column) {
        return (TestingPackage) value;
    }
    @Override
    public void Display() {
        if (value != null) {
            TasksPackageState state = value.state;
            setFont(MainModule_.instance.getUI().getTheme().Fonts.get(state.getFont()));
            String text_ = state.getDescription();
            switch (state) {
                case DoneWithErrors:
                    if (value.tasksCount>value.doneTasksCount) {
                        text_ += " " + Utils_.Brackets((value.tasksCount - value.doneTasksCount) + "/" + value.tasksCount);
                    }
                    break;
                default:
                    break;
            }
            setText(text_);
        }
    }
}