Quintiq file version 2.0
#parent: #root
Method SetOptimizerButtonDisplay () id:Method_ApplicationMacroPlanner_SetOptimizerButtonDisplay
{
  #keys: '[137862.0.662894600]'
  Body:
  [*
    //Update icon and tooltip of the run optimizer button based on the last run status
    run := guard( MacroPlan.Optimization().GetLastRegularAlgorithmRun(), null( AlgorithmRun ) );
    
    strategy := AlgorithmRun::GetLastStrategyUsed( MacroPlan.GlobalParameters_MP(), run, ScenarioManager, true, false );
    strategyname := guard( strategy.Name(), '' );
    
    imageopt := "GEAR_RUN";
    tooltipopt := Translations::MP_Designer_RunOptimizerWeb( strategyname );
    
    if( MacroPlan::GetIsStatusRunning( LabelOptimizerStatus.Text()) )
    {
      imageopt := 'GEAR_STOP';
      tooltipopt := Translations::MP_Designer_AbortOptimizer() ;
      
    }
    
    else if( LabelOptimizerStatus.Text() = Translations::MP_GlobalParameters_GetOptimizerTerminatedStatus() )
    {
      // Set run optimizer button image & tooltips after termination
      imageopt := 'GEAR_WARNING';
      tooltipopt := Translations::MP_Designer_RunOptimizerWithNoteWeb( strategyname, LabelOptimizerStatus.Text() );
      
    }
    else if( guard( run.LastLevel().End() >= run.FirstLevel().Start(), true ) )
    { 
      
      if( MacroPlan.SanityCheckHighestSeverity() = SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue() )
      {
        imageopt := 'GEAR_WARNING';
        tooltipopt := Translations::MP_Designer_RunOptimizerWithWarningWeb( strategyname );
        
      }
    }
    
    ButtonOptimizer.Image( imageopt );
    ButtonOptimizer.Tooltip( tooltipopt );
  *]
}
