Quintiq file version 2.0
#parent: #root
Method EditLane (
  internal[GUIComponent] parent,
  structured[Lane] selection,
  Boolean isfilteredbyunit
) id:Method_DialogCreateEditLane_EditLane
{
  #keys: '[109478.0.549376948]'
  Body:
  [*
    // Edit lanes
    
    isbatchedit := selection.Size() > 1;
    Dialog.ShowHideComponentForBatchEdit( isbatchedit );
    Dialog.SetFilters( isfilteredbyunit );
    
    data := shadow( selection.Element( 0 ) );
    Dialog.Data( data );
    
    result := this.DoModal( parent );
    
    if( result > 0 )
    {
      /* TWO Transaction is expected in editing single lane
         1. Update cost, we need to call Commit to commit the shadow costs
         2. Update lane, we need to call Update to updated the TypeIndex
      */
      if( not isbatchedit )
      {
        selection.Element( 0 ).UpdateTypeIndex( EditorID.Text() );      // Read-only, apply changes to shadow is not taking place for read-only attribute when editing.
        data.Commit();
      }
      // To keep only one transaction if the user did not change the ID
      else
      {
        Lane::Update( selection,
                      data.Unit(),
                      EditorID.Text(),      // Read-only, apply changes to shadow is not taking place for read-only attribute when editing.
                      data.Name(),
                      false /* isBatchEditIsEnabled */,
                      data.IsEnabled(),
                      CheckBoxBatchEditStart.Checked(),
                      data.Start(),
                      CheckBoxBatchEditEnd.Checked(),
                      data.End(),
                      CheckBoxBatchEditDuration.Checked(),
                      data.UserLeadTime(),
                      CheckBoxBatchEditStandardDeviationLeadTime.Checked(),
                      data.StandardDeviationLeadTimeLane() );
      }
    }
  *]
}
