Пример #1
0
//------------------------------------------------------------------------------
// void SaveAndBuildScript(wxCommandEvent &event)
//------------------------------------------------------------------------------
void GmatSavePanel::SaveAndBuildScript(wxCommandEvent &event)
{
   #ifdef DEBUG_SAVE
   MessageInterface::ShowMessage
      ("GmatSavePanel::SaveAndBuildScript() entered\n   mFilename = '%s'\n",
       mFilename.c_str());
   #endif
   
   SaveData();
   mScriptDirtyLabel->SetLabel("");
   
   GmatAppData *gmatAppData = GmatAppData::Instance();
   SetEditorModified(false);
   gmatAppData->GetMainFrame()->SetActiveChildDirty(false);
   
   // If script is active, build the script 
   if (mIsScriptActive & !mDelayBuild)
   {
      if (gmatAppData->GetMainFrame()->SetScriptFileName(mFilename.c_str()))
         gmatAppData->GetMainFrame()->OnScriptBuildObject(event);
   }
   
   #ifdef DEBUG_SAVE
   MessageInterface::ShowMessage
      ("GmatSavePanel::SaveAndBuildScript() leaving\n   mFilename = '%s'\n",
       mFilename.c_str());
   #endif
}
Пример #2
0
//------------------------------------------------------------------------------
// void SaveData()
//------------------------------------------------------------------------------
void ScriptPanel::SaveData()
{
   #ifdef DEBUG_SCRIPTPANEL_SAVE
   MessageInterface::ShowMessage
      ("ScriptPanel::SaveData() entered\n   mScriptFilename = '%s'\n   "
       "      mFilename = '%s'\n", mScriptFilename.c_str(), mFilename.c_str());
   #endif
   
   GmatAppData *gmatAppData = GmatAppData::Instance();
   
   if (mScriptFilename != mFilename)
   {
      // add new script to tree
      gmatAppData->GetResourceTree()->AddScriptItem(mFilename);
      
      // rename this child window
      gmatAppData->GetMainFrame()->RenameActiveChild(mFilename);
      mScriptFilename = mFilename;
   }
   
   mFileContentsTextCtrl->SaveFile(mScriptFilename);
   gmatAppData->GetMainFrame()->SetActiveChildDirty(false);
   mUserModified = false;
   
   #ifdef DEBUG_SCRIPTPANEL_SAVE
   MessageInterface::ShowMessage
      ("ScriptPanel::SaveData() leaving\n   mScriptFilename = '%s'\n   "
       "      mFilename = '%s'\n", mScriptFilename.c_str(), mFilename.c_str());
   #endif
}
Пример #3
0
//------------------------------------------------------------------------------
void OutputTree::OnClose(wxCommandEvent &event)
{
   // Get info from selected item
   GmatTreeItemData *item = (GmatTreeItemData *) GetItemData(GetSelection());
   
   // if its open, its activated
   GmatAppData *gmatAppData = GmatAppData::Instance();
   if (gmatAppData->GetMainFrame()->IsChildOpen(item))
      gmatAppData->GetMainFrame()->CloseActiveChild();
   else
      return;
}
Пример #4
0
//------------------------------------------------------------------------------
// void UpdateResourceTree()
//------------------------------------------------------------------------------
void GuiInterpreter::UpdateResourceTree()
{
#if !defined __CONSOLE_APP__
   //close the open windows first
   GmatAppData *gmatAppData = GmatAppData::Instance();
   gmatAppData->GetMainFrame()->CloseAllChildren();
   gmatAppData->GetResourceTree()->UpdateResource(true);
#endif
}
Пример #5
0
//------------------------------------------------------------------------------
// void MakeScriptActive(wxCommandEvent &event, bool isScriptModified)
//------------------------------------------------------------------------------
void GmatSavePanel::MakeScriptActive(wxCommandEvent &event, bool isScriptModified)
{
   #ifdef DEBUG_ACTIVE_SCRIPT
   MessageInterface::ShowMessage
      ("GmatSavePanel::MakeScriptActive() entered, isScriptModified=%d\n",
       isScriptModified);
   #endif
   
   bool saveScript = true;
   mSyncGui = false;
   mDelayBuild = false;
   GmatAppData *gmatAppData = GmatAppData::Instance();
   
   if (event.GetEventObject() == mSaveSyncButton ||
       event.GetEventObject() == mSaveSyncRunButton)
   {
      #ifdef DEBUG_ACTIVE_SCRIPT
      MessageInterface::ShowMessage("   Event is SaveSyncButton or SaveSyncRunButton\n");
      #endif
      if (gmatAppData->GetMainFrame()->IsAnimationRunning())
      {
         #ifdef DEBUG_ACTIVE_SCRIPT
         MessageInterface::ShowMessage("   Animation is running\n");
         #endif
         // @todo - Figure out why following happens. (LOJ: 2012.07.18)
         // It always runs mission before updating the resource tree.
         // It sometimes crashes when I tried SaveSyncRun again.
         // @note - Prompt user to stop animation first until issue is resolved.
         // Is there a timing issue? wxYield() didn't seem to solve the problem.
         // Use wxTimer?
         //===========================================================
         #if 0
         //===========================================================
         wxString action = "reload the GUI with the saved script?";
         if (event.GetEventObject() == mSaveSyncRunButton)
            action = "reload the GUI with the saved script and run?";
         
         int answer =
            wxMessageBox(wxT("GMAT is running the animation.\n"
                             "Are you sure you want to stop the animation and " + action),
                         wxT("Please confirm"), wxYES_NO);
         
         if (answer == wxYES)
         {
            // Stop animation
            gmatAppData->GetMainFrame()->StopAnimation();
         }
         else
            return;
         
         //===========================================================
         #else
         //===========================================================
        
         wxMessageBox(wxT("GMAT is running the animation.\n"
                          "Please stop the animation first."),
                      wxT("Warning"), wxOK);
         return;
         
         //===========================================================
         #endif
         //===========================================================
      }
      else
      {
         #ifdef DEBUG_ACTIVE_SCRIPT
         MessageInterface::ShowMessage("   Animation is not running\n");
         #endif
      }
      mSyncGui = true;
      mDelayBuild = true;
   }
   
   wxYield();
   
   #ifdef DEBUG_ACTIVE_SCRIPT
   MessageInterface::ShowMessage("   mIsScriptActive=%d\n", mIsScriptActive);
   #endif
   
   // If this is not an active script, prompt the user for setting active
   if (!mIsScriptActive)
   {
      #ifdef DEBUG_ACTIVE_SCRIPT
      MessageInterface::ShowMessage("   ==> Showing active script confirm message\n");
      #endif
      wxString makeActiveMsg = "The script file \"" + mFilename + "\" is not the active script.  "
         "Would you like to save, make it the active script, and load it into the GUI";
      if (event.GetEventObject() == mSaveSyncButton)
         makeActiveMsg = makeActiveMsg + "?";
      else if (event.GetEventObject() == mSaveSyncRunButton)
         makeActiveMsg = makeActiveMsg + " and run?";
      
      wxMessageDialog *msgDlg = new wxMessageDialog
         (this, makeActiveMsg, "Save active...", wxYES_NO | wxICON_QUESTION, wxDefaultPosition);
      int result = msgDlg->ShowModal();
      
      if (result == wxID_YES)
      {
         mSyncGui = true;
         saveScript = true;
         // If inactive script is modified, set it dirty so that change can be saved
         // before build (Fix for GMT-2843, LOJ: 2012.08.22)
         if (isScriptModified)
            theGuiManager->SetActiveScriptStatus(2);
      }
      else
      {
         mSyncGui = false;
         saveScript = false;
      }
   }
   
   #ifdef DEBUG_ACTIVE_SCRIPT
   MessageInterface::ShowMessage
      ("   mSyncGui=%d, saveScript=%d, mScriptFilename='%s'\n", mSyncGui, saveScript,
       mScriptFilename.c_str());
   #endif
   
   // No action is performed if user said no to sync GUI
   // See GMAT Software Specification, Script Editor section (LOJ: 2012.02.22)
   if (saveScript)
   {
      OnSave(event);
      if (mSaveCanceled)
      {
         #ifdef DEBUG_SAVE
         MessageInterface::ShowMessage
            ("GmatSavePanel::OnSave() leaving, user canceled SaveAs, mFilename='%s'\n", mFilename.c_str());
         #endif
         return;
      }
   }
   
   wxYield();
   
   // If continue building, set script file name and build script
   if (mSyncGui)
   {
      if (event.GetEventObject() == mSaveSyncButton)
      {
         if (gmatAppData->GetMainFrame()->SetScriptFileName(mScriptFilename.c_str()))
         {
            #ifdef DEBUG_ACTIVE_SCRIPT
            MessageInterface::ShowMessage
               ("   ==> Calling GmatMainFrame::OnScriptBuildObject()\n");
            #endif
            gmatAppData->GetMainFrame()->OnScriptBuildObject(event);
         }
      }
      else if (event.GetEventObject() == mSaveSyncRunButton)
      {
         if (gmatAppData->GetMainFrame()->SetScriptFileName(mScriptFilename.c_str()))
         {
            #ifdef DEBUG_ACTIVE_SCRIPT
            MessageInterface::ShowMessage
               ("   ==> Calling GmatMainFrame::OnScriptBuildAndRun()\n");
            #endif
            gmatAppData->GetMainFrame()->OnScriptBuildAndRun(event);
         }
      }
      // Make current script active script (Fix for GMT-206, LOJ: 2012.02.09)
      UpdateScriptActiveStatus(true);
      mSyncGui = false;
   }
   
   #ifdef DEBUG_ACTIVE_SCRIPT
   MessageInterface::ShowMessage("GmatSavePanel::MakeScriptActive() leaving\n");
   #endif
}