Ejemplo n.º 1
0
//------------------------------------------------------------------------------
// void OnReadButtonClick(wxCommandEvent& event)
//------------------------------------------------------------------------------
void SetPathDialog::OnReadButtonClick(wxCommandEvent& event)
{
   #ifdef DEBUG_SETPATH
   MessageInterface::ShowMessage(wxT("SetPathDialog::OnReadButtonClick() entered\n"));
   #endif
   
   FileManager *fm = FileManager::Instance();
   // Do we want default directory to be where executable is?
   // Set it blank, so that system can show current working directory for now.
   //wxString defDir = fm->GetStartupFileDir();
   wxString defDir;
   
   #ifdef DEBUG_SETPATH
   MessageInterface::ShowMessage(wxT(" defDir='%s'\n"), defDir.c_str());
   #endif
   
   wxFileDialog dialog(this, wxT("Choose a file"), defDir, wxT(""), wxT("*.*"));
   
   if (dialog.ShowModal() == wxID_OK)
   {
      wxString filename;      
      filename = dialog.GetPath().c_str();
      
      if (!filename.IsSameAs(mStartupFilePath))
      {
         mReadFileTextCtrl->SetValue(filename);
         try
         {
            fm->ReadStartupFile(filename.c_str());            
            StringArray paths = fm->GetAllGmatFunctionPaths();
            mGmatFunPathPanel->UpdatePathNames(paths);
            paths = fm->GetAllMatlabFunctionPaths();
            mMatlabPathPanel->UpdatePathNames(paths);
            mStartupFilePath = filename;
         }
         catch(BaseException &e)
         {
            MessageInterface::PopupMessage(Gmat::ERROR_, e.GetFullMessage());
         }
      }
   }
}
Ejemplo n.º 2
0
//------------------------------------------------------------------------------
// virtual void Create()
//------------------------------------------------------------------------------
void SetPathDialog::Create()
{
   #ifdef DEBUG_SETPATH_DIALOG_CREATE
   MessageInterface::ShowMessage(wxT("SetPathDialog::Create() entered.\n"));
   #endif
   
   FileManager *fm = FileManager::Instance();
   mStartupFilePath = (fm->GetFullStartupFilePath()).c_str();
   
   //----- read startup file
   wxButton *readButton =
      new wxButton(this, ID_BUTTON_READ, wxT("Read Other Startup File"),
                   wxDefaultPosition, wxDefaultSize, 0);
   wxStaticText *currFileText =
      new wxStaticText(this, -1, wxT("Current Startup File:"), 
                       wxDefaultPosition, wxDefaultSize, 0 );
   mReadFileTextCtrl =
      new wxTextCtrl(this, -1, wxT(""),
                     wxDefaultPosition, wxSize(350, 20), 0);
   mReadFileTextCtrl->Disable();
   
   //----- write startup file
   wxButton *saveButton =
      new wxButton(this, ID_BUTTON_SAVE, wxT("Save Current Startup File"),
                   wxDefaultPosition, wxDefaultSize, 0);
   mSaveFileTextCtrl =
      new wxTextCtrl(this, -1, wxT(""),
                     wxDefaultPosition, wxSize(350, 20), 0);
   mSaveFileTextCtrl->Disable();
   
   //----- add to sizer
   GmatStaticBoxSizer *startupSizer =
      new GmatStaticBoxSizer(wxVERTICAL, this, wxT("Startup File"));
   startupSizer->Add(readButton, 0, wxALIGN_LEFT|wxALL, 2);
   startupSizer->Add(currFileText, 0, wxALIGN_LEFT|wxALL, 2);
   startupSizer->Add(mReadFileTextCtrl, 0, wxALIGN_CENTER|wxGROW|wxALL, 2);
   startupSizer->Add(saveButton, 0, wxALIGN_LEFT|wxALL, 2);
   startupSizer->Add(mSaveFileTextCtrl, 0, wxALIGN_CENTER|wxGROW|wxALL, 2);
   
   //----- create Notebook
   mPathNotebook =
      new wxNotebook(this, ID_NOTEBOOK, wxDefaultPosition, wxDefaultSize, wxGROW);
   
   StringArray gmatPaths = fm->GetAllGmatFunctionPaths();
   
   //----- add panels to notebook   
   mGmatFunPathPanel = new MultiPathSetupPanel(mPathNotebook, gmatPaths);
   mPathNotebook->AddPage(mGmatFunPathPanel, wxT("GMAT Function"));
   
   StringArray matlabPaths = fm->GetAllMatlabFunctionPaths();
   mMatlabPathPanel = new MultiPathSetupPanel(mPathNotebook, matlabPaths);
   mPathNotebook->AddPage(mMatlabPathPanel, wxT("MATLAB Function"));
   
   wxString outputPath = fm->GetFullPathname(wxT("OUTPUT_PATH"));
   
   #ifdef DEBUG_SETPATH_DIALOG_CREATE
   MessageInterface::ShowMessage(wxT("   outputPath='%s'\n"), outputPath.c_str());
   #endif
   
   mOutputPathPanel = new SinglePathSetupPanel(mPathNotebook, outputPath.c_str());
   mPathNotebook->AddPage(mOutputPathPanel, wxT("Output"));
   
   theMiddleSizer->Add(startupSizer, 0, wxALIGN_CENTER|wxGROW|wxALL, 5);
   theMiddleSizer->Add(mPathNotebook, 1, wxALIGN_CENTER|wxGROW|wxALL, 5);
}