Quintiq file version 2.0
#parent: ToolbarMain/ButtonRunOptimizer
Response OnClick () id:Response_ToolbarMain_ButtonRunOptimizer_OnClick
{
  #keys: '[127472.0.155584305]'
  Body:
  [*
    // Run/stop optimizer
    if( not this.GetProperty( 'Image' ) = 'MEDIA_STOP_RED' )//Image media run means optimizer is not running
    {
      ApplicationLibMacroPlanner.RunOptimizerGlobal();
    }
    else 
    {
      ApplicationLibMacroPlanner.AbortOptimizer();
    }
  *]
  CanBindMultiple: false
  DefinitionID: 'Responsedef_GUIButtonBase_OnClick'
  Precondition:
  [*
    laststrategyname := guard( MacroPlan.GetLastAlgorithmRun().StrategyName(), '' );
    activescenario := DataHolderActiveScenario.Data();
    
    return ScenarioManager::HasScenarioManager( ScenarioManager, feedback )
           and ScenarioManager::HasStrategy( ScenarioManager, feedback )
           and Strategy::HasMatchingLastRunStrategy( ScenarioManager, laststrategyname, feedback )
           and OptimizerPuzzle::HasLastUsedOptimizerPuzzle( MacroPlan, feedback )
           and ScenarioManager::HasActiveStrategy( ScenarioManager, feedback )
           and ScenarioManager.ActiveStrategy().GetHasValidContinuousLevels( feedback, false )  //iswebapp = FALSE
           and MacroPlan::HasMacroPlan( MacroPlan, feedback )
           and Period_MP::HasPeriod( feedback, MacroPlan )       
           and ScenarioManager::HasCapacityForMaximumNumberofConcurrentRuns( ScenarioManager, activescenario, false, feedback ) 
           and MacroPlan.CanPlan( feedback );
  *]
}
