]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/wxCDMProjectActionsPanel.cpp
Feature #1711
[crea.git] / lib / creaDevManagerLib / wxCDMProjectActionsPanel.cpp
index 2d89a2df0f05e76a7fa4dbccbcbc89033138cf1e..676e1b2b96b38ceef2acb89db307f0e9c39ce776 100755 (executable)
 
 #include "creaDevManagerIds.h"
 
+#include <map>
+#include "wxCDMProjectStructureReportDialog.h"
+
 BEGIN_EVENT_TABLE(wxCDMProjectActionsPanel, wxPanel)
+EVT_BUTTON(ID_BUTTON_CHECK_PROJECT, wxCDMProjectActionsPanel::OnBtnCheckProjectStructure)
 EVT_BUTTON(ID_BUTTON_BUILD_PROJECT, wxCDMProjectActionsPanel::OnBtnBuildProject)
 EVT_BUTTON(ID_BUTTON_CONFIGURE_BUILD, wxCDMProjectActionsPanel::OnBtnConfigureBuild)
 EVT_BUTTON(ID_BUTTON_CONNECT_PROJECT, wxCDMProjectActionsPanel::OnBtnConnectProject)
@@ -81,17 +85,30 @@ bool wxCDMProjectActionsPanel::Create(
 
 void wxCDMProjectActionsPanel::CreateControls()
 {
-  wxButton* configurebt = new wxButton(this, ID_BUTTON_CONFIGURE_BUILD, _T("1. Configure Project (CMake)"));
-  configurebt->SetToolTip(wxT("This is the first step in order to execute the project. Make sure you have selected the desired Build location."));
-  wxButton* compilebt = new wxButton(this, ID_BUTTON_BUILD_PROJECT, _T("2. Compile Project"));
+  wxButton* checkStructbt = new wxButton(this, ID_BUTTON_CHECK_PROJECT, _T("1. Check Project Structure"));
+  checkStructbt->SetToolTip(wxT("This step checks the project structure and tells what is going to be compiled."));
+  wxButton* configurebt = new wxButton(this, ID_BUTTON_CONFIGURE_BUILD, _T("2. Configure Project (CMake)"));
+  configurebt->SetToolTip(wxT("This is the second step in order to execute the project. Make sure you have selected the desired Build location."));
+  wxButton* compilebt = new wxButton(this, ID_BUTTON_BUILD_PROJECT, _T("3. Compile Project"));
   compilebt->SetToolTip(wxT("This step should be done after configuring the project. This will create the executables."));
-  wxButton* plugbt = new wxButton(this, ID_BUTTON_CONNECT_PROJECT, _T("3. Plug Packages (BBTK)"));
+  wxButton* plugbt = new wxButton(this, ID_BUTTON_CONNECT_PROJECT, _T("4. Plug Packages (BBTK)"));
   plugbt->SetToolTip(wxT("This step should be done after compiling the project. This will allow to use the boxes in this project to be available in the bbEditor."));
+  this->GetSizer()->Add(checkStructbt, 0, wxALL, 5);
   this->GetSizer()->Add(configurebt, 0, wxALL, 5);
   this->GetSizer()->Add(compilebt, 0, wxALL, 5);
   this->GetSizer()->Add(plugbt, 0, wxALL, 5);
 }
 
+//check project structure
+void wxCDMProjectActionsPanel::OnBtnCheckProjectStructure(wxCommandEvent& event)
+{
+  std::map<std::string, bool> prjStruct;
+  this->project->CheckStructure(prjStruct);
+  std::cout << prjStruct.size() << std::endl;
+  wxCDMProjectStructureReportDialog* structure = new wxCDMProjectStructureReportDialog(this->GetParent(), prjStruct, wxID_ANY);
+  structure->Show(true);
+}
+
 //configure project
 void wxCDMProjectActionsPanel::OnBtnConfigureBuild(wxCommandEvent& event)
 {
@@ -107,6 +124,14 @@ void wxCDMProjectActionsPanel::OnBtnConfigureBuild(wxCommandEvent& event)
 //compile project
 void wxCDMProjectActionsPanel::OnBtnBuildProject(wxCommandEvent& event)
 {
+#ifdef _WIN32
+       std::string* result;
+       if(!this->project->Build(result, ""))
+       {
+         wxMessageBox(crea::std2wx(result->c_str()), wxT("Project Compilation - Error!"));
+         return;
+       }
+#else
   //get author from user
   wxTextEntryDialog* buildDlg = new wxTextEntryDialog(
       this,
@@ -135,15 +160,30 @@ void wxCDMProjectActionsPanel::OnBtnBuildProject(wxCommandEvent& event)
           //wxMessageBox(crea::std2wx("The compilation was executed successfully. Please check the \"building.log\" file located in the build folder to check the compilation result."), wxT("Project Compilation"));
         }
     }
+#endif
 }
 //plug packages
 void wxCDMProjectActionsPanel::OnBtnConnectProject(wxCommandEvent& event)
 {
   std::string* result;
-  if(!this->project->Connect(result))
+  wxString file = wxDirSelector(
+    wxT("Please select the folder containing the bbtkPackage file you want to use. Usually it is where you built your project."),
+    crea::std2wx(this->project->GetBuildPath())
+  );
+  std::cout << crea::wx2std(file) << std::endl;
+  std::cout.flush();
+
+  if(crea::wx2std(file) == "" || !this->project->Connect(result, crea::wx2std(file)))
     {
-      wxMessageBox(crea::std2wx(result->c_str()), wxT("Plug Packages - Error!"));
+      if (crea::wx2std(file) == "")
+        result = new std::string("Folder not specified.");
+      wxMessageBox(crea::std2wx(result->c_str()), wxT("Plug BBTK Packages - Error!"), wxICON_ERROR);
       return;
     }
-  wxMessageBox(crea::std2wx("The connection was executed successfully. Please check the \"plugging.log\" file located in the build folder to check the compilation result."), wxT("Plug Package"));
+#ifdef _WIN32
+  wxMessageBox(crea::std2wx("The connection was executed successfully. Please check the console to see the compilation result."), wxT("Plug Package"));
+#else
+  wxMessageBox(crea::std2wx("The connection was executed successfully. Please check the \"plugging.log\" file located in the build folder to see the compilation result."), wxT("Plug Package"));
+#endif
+  
 }