Quintiq file version 2.0
#parent: #root
Method InitializeComponents () id:Method_DialogEditLaneLegs_InitializeComponents
{
  #keys: '[139394.0.1547078056]'
  Body:
  [*
    // During creation of the dialog, we will update the ui
    data := DataHolderDialogData.Data();
    
    // Hide / unhide batch
    isbatchedit := DataHolderDialogDatas.Data().Size() > 1;
    CheckboxBatchEditLeadTime.Visible( isbatchedit );
    CheckboxBatchEditStart.Visible( isbatchedit );
    CheckboxBatchEditEnd.Visible( isbatchedit );
    CheckboxBatchEditCO2Emission.Visible(isbatchedit );
    
    // Enable the checkboxes if not batchedit
    CheckBoxHasUserLeadTime.Enabled( not isbatchedit, '' );
    CheckboxHasStart.Enabled( not isbatchedit, '' );
    CheckboxHasEnd.Enabled( not isbatchedit, '' );
    
    
    // Enable/disable datetime selector
    // lane leg start
    isstartfinite := data.Start().IsFinite();
    CheckboxHasStart.Checked( isstartfinite )
    DateSelectorStart.Enabled( not isbatchedit and isstartfinite, '' );
    
    // lane leg end
    isendfinite := data.End().IsFinite();
    CheckboxHasEnd.Checked( isendfinite );
    DateSelectorEnd.Enabled( not isbatchedit and isendfinite, '' );
    
    DurationSelectorLeadTime.Enabled(  not isbatchedit and DataHolderDialogData.Data().HasUserLeadTime(), '' );
    DurationSelectorLeadTime.Duration( data.LeadTime() );
    
    // Set CO2 emission tooltip and label
    mp := MacroPlan;
    gpProcessUoM := ifexpr( isnull(  mp ), '', mp.GlobalParameters_MP().CO2ProcessUoM() );
    EditFieldCO2Emission.Tooltip( Translations::MP_GlobalParameters_CO2LaneLegTooltip( gpProcessUoM ) );
    LabelCO2Emission.Label( mp.GlobalParameters_MP().DefaultCO2EmissionUoM() );
    
    // Workaround: edit field not disabled when first opened
    this.OnUserUpdateUI();
  *]
}
