package _VisualDVM.GlobalData.CompilerOption;
import Common.Database.Tables.DataSet;
import Common.Visual.DataSetControlForm;
import _VisualDVM.GlobalData.CompilerOption.Json.OptionsJson;
import _VisualDVM.GlobalData.CompilerOption.Json.OptionsSetJson;
import _VisualDVM.GlobalData.CompilerOption.UI.OptionsLinesForm;

import javax.swing.*;
public class OptionsLinesSet extends DataSet<Integer, OptionsLine> {
    public int maxId = 1;
    public OptionsLinesSet() {
        super(Integer.class, OptionsLine.class);
    }
    public OptionsLinesSet(OptionsSetJson json) {
        super(Integer.class, OptionsLine.class);
        for (OptionsJson optionsJson : json.values) {
            OptionsLine optionsLine = new OptionsLine(optionsJson);
            optionsLine.id = maxId++;
            put(optionsLine.id, optionsLine);
        }
    }
    @Override
    public String getSingleDescription() {
        return "набор опций компиляции";
    }
    @Override
    public String getPluralDescription() {
        return "наборы опций компиляции";
    }
    @Override
    protected DataSetControlForm createUI(JPanel mountPanel) {
        return new OptionsLinesForm(this, mountPanel);
    }
    public OptionsSetJson toJson() {
        OptionsSetJson res = new OptionsSetJson();
        for (OptionsLine optionsLine : Data.values()) {
            res.values.add(optionsLine.json);
        }
        return res;
    }
}
