Quintiq file version 2.0
#parent: #root
Method UpdateImportStatus (Boolean checkIfDisplayMessageBox) id:Method_LibSOPImpExp_BaseButtonImport_UpdateImportStatus
{
  #keys: '[144528.1.557630242]'
  Body:
  [*
    // Update button enabled state, image and tooltip
    importObj := this.O_GetImportBase();
    
    // No import object means no import executing (get last imported time & button should be enabled)
    if( isnull( importObj ) )
    {
      this.Enabled( true, '' );
      this.Image( 'IMPORT1' );
      this.Tooltip( Translations::LibSOPImpExp_Import_LastImportTime( this.O_GetLastImportTime() ) );
    }
    else if( importObj.Status() = LibSOPImpExp_ImportExportBase::Status_InProgress() )
    {
      // Even if another user performed a successful import, as long as this current user's
      // import still executing, we display 'in progress'
      this.Enabled( false, '' );
      this.Image( 'PROGRESS_BAR' );
      this.Tooltip( Translations::LibSOPImpExp_Import_InProgress() );
    }
    else if(  importObj.Status() = LibSOPImpExp_ImportExportBase::Status_Done() )
    {
      this.Enabled( true, '' );
      this.Image( 'IMPORT1' );
      this.Tooltip( Translations::LibSOPImpExp_Import_LastImportTime( this.O_GetLastImportTime() ) );
    
      // On sucess, display notification
      if( checkIfDisplayMessageBox )
      {
        WebMessageBox::Success( Application, importObj.GetSuccessMessage() );
      }
    }
    else if(  importObj.Status() = LibSOPImpExp_ImportExportBase::Status_Error() )
    {
      this.Enabled( true, '' );
      this.Image( 'IMPORT1' );
      this.Tooltip( Translations::LibSOPImpExp_Import_LastImportTime( this.O_GetLastImportTime() ) );
    
      // If this method triggered by changes to last imported time (either by current user or other users), we skip display error message
      if( checkIfDisplayMessageBox )
      {
        WebMessageBox::Error( Application, importObj.GetErrorMessage() );
      }
    }
  *]
}
