package _VisualDVM.GlobalData.SapforProfile.UI;
import Common.Database.Tables.DataSet;
import Common.Passes.PassCode_;
import Common.Visual.DataSetControlForm;
import Common.Visual.Menus.DataMenuBar;
import Common.Visual.Tables.ColumnInfo;
import Common.Visual.Windows.Dialog.DBObjectDialog;
import Common.Visual.Windows.Dialog.DialogFields;
import _VisualDVM.GlobalData.SapforProfile.SapforProfile;
import _VisualDVM.Passes.PassCode;
import _VisualDVM.Visual.Tables.RendererProfileAuto;
import _VisualDVM.Visual.Tables.SwitcherProfileAuto;

import javax.swing.*;
import java.util.Date;
public class SapforProfilesForm extends DataSetControlForm<SapforProfile> {
    public SapforProfilesForm(DataSet<?, SapforProfile> dataSource_in, JPanel mountPanel_in) {
        super(dataSource_in, mountPanel_in);
    }
    @Override
    protected void createColumns() {
        AddColumns(
                new ColumnInfo<SapforProfile>("Описание") {
                    @Override
                    public Object getFieldAt(SapforProfile object) {
                        return object.description;
                    }
                },
                new ColumnInfo<SapforProfile>("Дата создания") {
                    @Override
                    public Object getFieldAt(SapforProfile object) {
                        return new Date(object.creationDate);
                    }
                },
                new ColumnInfo<SapforProfile>("") {
                    @Override
                    public Object getFieldAt(SapforProfile object) {
                        return object.printAuto();
                    }
                    @Override
                    public Class getRendererClass() {
                        return RendererProfileAuto.class;
                    }
                    @Override
                    public Class getEditorClass() {
                        return SwitcherProfileAuto.class;
                    }
                    @Override
                    public int getMinWidth() {
                        return 25;
                    }
                    @Override
                    public int getMaxWidth() {
                        return 25;
                    }
                }
        );
    }
    @Override
    public PassCode_ getDeletePassCode() {
        return PassCode.DeleteProfile;
    }
    @Override
    public DataMenuBar createMenuBar() {
        return new DataMenuBar(dataSource.getPluralDescription(),
                PassCode.SaveProfile,
                PassCode.EditProfile,
                PassCode.ApplyProfile,
                PassCode.DeleteProfile);
    }
    @Override
    protected DBObjectDialog<SapforProfile, ? extends DialogFields> getDialog() {
        return new SapforProfileDialog();
    }
}
