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

import com.ecep.contract.controller.tab.TabSkin;

import javafx.scene.control.Tab;
import javafx.util.converter.DoubleStringConverter;

public class ProjectSaleTypeBaseTabSkin extends AbstProjectSaleTypeBasedTabSkin implements TabSkin {

    public ProjectSaleTypeBaseTabSkin(ProjectSaleTypeWindowController controller) {
        super(controller);
    }

    @Override
    public Tab getTab() {
        return controller.baseInfoTab;
    }

    @Override
    public void initializeTab() {
        controller.nameField.textProperty().bindBidirectional(viewModel.getName());
        controller.codeField.textProperty().bindBidirectional(viewModel.getCode());
        controller.pathField.textProperty().bindBidirectional(viewModel.getPath());
        controller.storeByYearField.selectedProperty().bindBidirectional(viewModel.getStoreByYear());

        controller.criticalProjectDecisionField.selectedProperty().bindBidirectional(viewModel.getCriticalProjectDecision());
        controller.criticalProjectLimitField.textProperty().bindBidirectional(viewModel.getCriticalProjectLimit().asObject(), new DoubleStringConverter());
        controller.criticalProjectLimitField.disableProperty().bind(viewModel.getCriticalProjectDecision().not());

        controller.createdField.valueProperty().bindBidirectional(viewModel.getCreated());
        controller.activeField.selectedProperty().bindBidirectional(viewModel.getActive());
        controller.descriptionField.textProperty().bindBidirectional(viewModel.getDescription());
    }
}
