package _VisualDVM.ProjectData.DBArray.UI;
import Common.Database.Tables.DataSet;
import Common.Visual.DataSetControlForm;
import Common.Visual.Menus.DataMenuBar;
import Common.Visual.Tables.ColumnInfo;
import Common.Visual.Tables.DBObjectSelectionRenderer;
import _VisualDVM.ProjectData.DBArray.DBArray;

import javax.swing.*;
public class DBArraysForm extends DataSetControlForm<DBArray> {
    public DBArraysForm(DataSet<?, DBArray> dataSource_in, JPanel mountPanel_in) {
        super(dataSource_in, mountPanel_in);
    }
    @Override
    protected void createColumns() {
        AddColumns(
                new ColumnInfo<DBArray>("Имя") {
                    @Override
                    public Object getFieldAt(DBArray object) {
                        return object.shortName;
                    }
                }
        );
    }
    @Override
    protected ColumnInfo<DBArray> createCheckBoxColummn() {
        return new ColumnInfo<DBArray>("") {
            @Override
            public Object getFieldAt(DBArray object) {
                return object.State;
            }
            @Override
            public int getMinWidth() {
                return 25;
            }
            @Override
            public int getMaxWidth() {
                return 25;
            }
            @Override
            public Class getRendererClass() {
                return DBObjectSelectionRenderer.class;
            }
            @Override
            public boolean isEditable() {
                return false;
            }
        };
    }
    @Override
    public DataMenuBar createMenuBar() {
        return new DataMenuBar(dataSource.getPluralDescription()) {
            @Override
            public void createSelectionButtons(DataSet dataSource_in) {
                //не нужны.
            }
        };
    }
}
