package com.ecep.contract.controller;

import org.apache.poi.ss.formula.functions.T;

import com.ecep.contract.model.IdentityEntity;
import com.ecep.contract.service.ViewModelService;
import com.ecep.contract.vm.IdentityViewModel;

import javafx.scene.control.TableView;
import javafx.stage.WindowEvent;
import lombok.Getter;

public abstract class AbstEntityBasedController<T extends IdentityEntity, TV extends IdentityViewModel<T>, Skin extends ManagerSkin>
        extends BaseController {

    public TableView<TV> table;

    @Getter
    private Skin skin;

    protected abstract Skin createDefaultSkin();

    @Override
    public void onShown(WindowEvent windowEvent) {
        super.onShown(windowEvent);
        if (skin == null) {
            skin = createDefaultSkin();
        }
        skin.install();
    }

    @Override
    public void onHiding(WindowEvent windowEvent) {
        if (skin != null) {
            skin.dispose();
        }
        super.onHiding(windowEvent);
    }

    public abstract ViewModelService<T, TV> getViewModelService();
}
