//------------------------------------------------------------------------------
// virtual void LoadData()
//------------------------------------------------------------------------------
void RunScriptFolderDialog::LoadData()
{
   #ifdef DEBUG_RUN_SCRIPT_FOLDER_DIALOG
   MessageInterface::ShowMessage("RunScriptFolderDialog::LoadData() entered.\n");
   #endif
   
   wxString str;
   str.Printf("%d", mNumScriptsToRun);
   mNumScriptsToRunTextCtrl->SetValue(str);
   
   FileManager *fm = FileManager::Instance();
   wxString sep = fm->GetPathSeparator().c_str();
   
   try
   {
      mCurrOutDir = fm->GetFullPathname(FileManager::OUTPUT_PATH).c_str();
   }
   catch (BaseException &e)
   {
      MessageInterface::ShowMessage(e.GetFullMessage());
   }
   
   #ifdef DEBUG_RUN_SCRIPT_FOLDER_DIALOG
   MessageInterface::ShowMessage("   mCurrOutDir='%s'\n", mCurrOutDir.c_str());
   #endif
   
   mSaveScriptsDirTextCtrl->SetValue(mCurrOutDir + "AutoSave");
   mCurrOutDirTextCtrl->SetValue(mCurrOutDir);
   
   //=======================================================
   #ifdef __ENABLE_COMPARE__
   //=======================================================
   str.Printf("%g", mAbsTol);
   mAbsTolTextCtrl->SetValue(str);
   mCompareDirTextCtrl->SetValue(mCompareDir);
   mSaveFileTextCtrl->SetValue(mCompareDir + sep + "CompareNumericResults.txt");
   mSaveResultCheckBox->Disable();
   mSaveFileTextCtrl->Disable();
   mSaveBrowseButton->Disable();
   mSaveScriptsDirTextCtrl->Disable();
   mChangeSaveScriptsDirButton->Disable();
   //=======================================================
   #endif
   //=======================================================
   
   theOkButton->Enable();
   
   #ifdef DEBUG_RUN_SCRIPT_FOLDER_DIALOG
   MessageInterface::ShowMessage("RunScriptFolderDialog::LoadData() leaving.\n");
   #endif
}
//------------------------------------------------------------------------------
// void OnButtonClick(wxCommandEvent& event)
//------------------------------------------------------------------------------
void RunScriptFolderDialog::OnButtonClick(wxCommandEvent& event)
{
   if (event.GetEventObject() == mChangeSaveScriptsDirButton)
   {
      wxDirDialog dialog(this, "Select a directory to save scripts", mCompareDir);
      
      if (dialog.ShowModal() == wxID_OK)
      {
         mSaveScriptsDir = dialog.GetPath();
         mSaveScriptsDirTextCtrl->SetValue(mSaveScriptsDir);
         
         #ifdef DEBUG_RUN_SCRIPT_FOLDER_DIALOG
         MessageInterface::ShowMessage
            ("RunScriptFolderDialog::OnButtonClick() mSaveScriptsDir=%s\n",
             mSaveScriptsDir.c_str());
         #endif
      }
   }
   else if (event.GetEventObject() == mChangeCurrOutDirButton)
   {
      wxDirDialog dialog(this, "Select a new output directory", mCompareDir);
   
      if (dialog.ShowModal() == wxID_OK)
      {
         FileManager *fm = FileManager::Instance();
         wxString sep = fm->GetPathSeparator().c_str();
         
         mCurrOutDir = dialog.GetPath();
         mCurrOutDirTextCtrl->SetValue(mCurrOutDir);
         //=================================================================
         #ifdef __ENABLE_COMPARE__
         //------------------------------------------------------
         mSaveFileTextCtrl->SetValue(mCurrOutDir + sep + "CompareNumericResults.txt");
         //=================================================================
         #endif
         //------------------------------------------------------
         
         mOutDirChanged = true;
         
         #ifdef DEBUG_RUN_SCRIPT_FOLDER_DIALOG
         MessageInterface::ShowMessage
            ("RunScriptFolderDialog::OnButtonClick() mCurrOutDir=%s\n",
             mCurrOutDir.c_str());
         #endif
      }
   }
   //=================================================================
   #ifdef __ENABLE_COMPARE__
   //------------------------------------------------------
   else if (event.GetEventObject() == mDirBrowseButton)
   {
      wxDirDialog dialog(this, "Select a directory to compare", mCompareDir);
      
      if (dialog.ShowModal() == wxID_OK)
      {
         wxString dirname = dialog.GetPath();
         mCompareDirTextCtrl->SetValue(dirname);
         
         #ifdef DEBUG_RUN_SCRIPT_FOLDER_DIALOG
         MessageInterface::ShowMessage
            ("RunScriptFolderDialog::OnButtonClick() dirname=%s\n",
             dirname.c_str());
         #endif
      }
   }
   else if (event.GetEventObject() == mSaveBrowseButton)
   {
      wxString filename =
         wxFileSelector("Choose a file to save", "", "", "txt",
                        "Report files (*.report)|*.report|Text files (*.txt)|*.txt",
                        wxSAVE);
      
      if (!filename.empty())
      {
         mSaveFileTextCtrl->SetValue(filename);
         MessageInterface::ShowMessage
            ("RunScriptFolderDialog::OnButtonClick() savefile=%s\n",
             filename.c_str());
      }
   }
   //=================================================================
   #endif
   //=================================================================
   
}