package com.ecep.contract.controller.project.usage;

import java.time.LocalDate;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.ecep.contract.controller.AbstManagerWindowController;
import com.ecep.contract.model.ProductUsage;
import com.ecep.contract.service.ProductUsageService;
import com.ecep.contract.service.ProjectService;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.vm.ProductUsageViewModel;

import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.stage.Stage;

@Lazy
@Scope("prototype")
@Component
@FxmlPath("/ui/project/product-usage-manager.fxml")
public class ProductUsageManagerWindowController
        extends AbstManagerWindowController<ProductUsage, ProductUsageViewModel, ProductUsageManagerSkin> {

    @Autowired
    private ProjectService projectService;

    public TableView<ProductUsageViewModel> table;
    public TableColumn<ProductUsageViewModel, Number> idColumn;
    public TableColumn<ProductUsageViewModel, String> nameColumn;
    public TableColumn<ProductUsageViewModel, String> codeColumn;
    public TableColumn<ProductUsageViewModel, String> descriptionColumn;
    public TableColumn<ProductUsageViewModel, LocalDate> createdColumn;


    @Override
    public void show(Stage stage) {
        super.show(stage);
        getTitle().set("产品用途管理");
    }

    @Override
    protected ProductUsageManagerSkin createDefaultSkin() {
        ProductUsageManagerSkin skin = new ProductUsageManagerSkin(this);
        skin.setProjectService(projectService);
        return skin;
    }

    @Override
    public ProductUsageService getViewModelService() {
        return getSkin().getProductUsageService();
    }
}
