]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.cpp
Feature #1711 CreaDevManager application implementation
[crea.git] / lib / creaDevManagerLib / wxCDMProjectDescriptionPanel.cpp
index b40e84f236bda0bc1261ab227f3552a092013338..ac170e0a7f41b9defd3bbe360445678115f6a7ed 100644 (file)
@@ -36,6 +36,7 @@
 
 #include "wxCDMMainFrame.h"
 #include "wxCDMNewPackageDialog.h"
+#include "wxCDMProjectConfigurationDialog.h"
 
 #include "wxCDMProjectHelpDialog.h"
 
@@ -47,8 +48,10 @@ BEGIN_EVENT_TABLE(wxCDMProjectDescriptionPanel, wxPanel)
 EVT_BUTTON(ID_BUTTON_GOTO_PACKAGE_MANAGER, wxCDMProjectDescriptionPanel::OnBtnManagePackages)
 EVT_BUTTON(ID_BUTTON_GOTO_LIB_MANAGER, wxCDMProjectDescriptionPanel::OnBtnManageLibraries)
 EVT_BUTTON(ID_BUTTON_GOTO_APPLI_MANAGER, wxCDMProjectDescriptionPanel::OnBtnManageApplications)
+EVT_BUTTON(ID_BUTTON_CHOOSE, wxCDMProjectDescriptionPanel::OnBtnConfigProject)
 EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists)
 EVT_BUTTON(ID_BUTTON_SET_BUILD_PATH, wxCDMProjectDescriptionPanel::OnBtnSetBuildPath)
+EVT_BUTTON(ID_BUTTON_OPEN_BUILD_PATH, wxCDMProjectDescriptionPanel::OnBtnOpenBuild)
 EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMProjectDescriptionPanel::OnBtnOpenFolder)
 EVT_BUTTON(ID_BUTTON_SET_VERSION, wxCDMProjectDescriptionPanel::OnBtnSetVersion)
 END_EVENT_TABLE()
@@ -83,6 +86,9 @@ bool wxCDMProjectDescriptionPanel::Create(
   wxPanel::Create(parent, id, pos, size, style);
   this->project = project;
   CreateControls();
+  // this part makes the scrollbars show up
+  this->FitInside(); // ask the sizer about the needed size
+  this->SetScrollRate(5, 5);
   return TRUE;
 }
 
@@ -135,7 +141,7 @@ void wxCDMProjectDescriptionPanel::CreateControls()
   // sourceLocation
   wxBoxSizer* pSourceLocationsz = new wxBoxSizer(wxHORIZONTAL);
   wxStaticText* pSourceLocationtc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetPath()));
-  //pSourceLocationtc->SetMaxSize(wxSize(350,-1));
+  pSourceLocationtc->SetMaxSize(wxSize(200,-1));
   wxButton* pSourceLocationbt = new wxButton(propertiesPanel, ID_BUTTON_OPEN_FOLDER, wxT("Open"));
   pSourceLocationbt->SetToolTip(wxT("Open the source folder in the file explorer."));
   pSourceLocationsz->Add(pSourceLocationtc, 1, wxALIGN_CENTER, 1);
@@ -143,11 +149,17 @@ void wxCDMProjectDescriptionPanel::CreateControls()
   // buildLocation
   wxBoxSizer* pBuildLocationsz = new wxBoxSizer(wxHORIZONTAL);
   this->buildPathtc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetBuildPath()));
-  //this->buildPathtc->SetMaxSize(wxSize(350,-1));
-  wxButton* pBuildLocationbt = new wxButton(propertiesPanel, ID_BUTTON_SET_BUILD_PATH, wxT("Choose"));
+  this->buildPathtc->SetMaxSize(wxSize(200,-1));
+
+  wxButton* pBuildLocationbt = new wxButton(propertiesPanel, ID_BUTTON_SET_BUILD_PATH, wxT("Choose..."));
   pBuildLocationbt->SetToolTip(wxT("Select a new location for compiling the project."));
+
+  wxButton* pBuildOpenbt = new wxButton(propertiesPanel, ID_BUTTON_OPEN_BUILD_PATH, wxT("Open"));
+  pBuildOpenbt->SetToolTip(wxT("Open the binaries folder in the file explorer."));
+
   pBuildLocationsz->Add(this->buildPathtc, 1, wxALIGN_CENTER, 1);
   pBuildLocationsz->Add(pBuildLocationbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
+  pBuildLocationsz->Add(pBuildOpenbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
 
   propertiesGridSizer->Add(pVersion, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
   propertiesGridSizer->Add(pVersionsz, 1, wxEXPAND);
@@ -178,7 +190,7 @@ void wxCDMProjectDescriptionPanel::CreateControls()
   wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL);
 
   //actionsGrid Sizer
-  wxFlexGridSizer* actionsGridSizer = new wxFlexGridSizer(2, 2, 9, 15);
+  wxFlexGridSizer* actionsGridSizer = new wxFlexGridSizer(3, 2, 9, 15);
   //buttons
   // lib manager
   //   show only if there is a lib folder
@@ -205,8 +217,13 @@ void wxCDMProjectDescriptionPanel::CreateControls()
       appliMgrbt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnAppliMouseExit,NULL,this);
       actionsGridSizer->Add(appliMgrbt, 1, wxALL | wxEXPAND, 5);
     }
+  // edit 3rd Party libraries
+  wxButton* configPrjbt = new wxButton(actionsPanel, ID_BUTTON_CHOOSE, _T("D. 3rd Party Libraries Manager"));
+  configPrjbt->SetToolTip(wxT("Select which third party libraries will be used in this project."));
+  actionsGridSizer->Add(configPrjbt, 1, wxALL | wxEXPAND, 5);
+
   // edit CMakeLists file
-  wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("D. Edit CMakeLists File"));
+  wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File"));
   editCMakebt->SetToolTip(wxT("Edit the CMakeLists.txt file of this project."));
   editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnCMakeMouseEnter,NULL,this);
   editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnCMakeMouseExit,NULL,this);
@@ -244,7 +261,7 @@ void wxCDMProjectDescriptionPanel::OnBtnManagePackages(wxCommandEvent& event)
   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
   newEvent->SetId(1);
   newEvent->SetString(wxT("manage_packages"));
-  newEvent->SetInt(this->project->GetId());
+  newEvent->SetClientData(this->project);
   wxPostEvent(this->GetParent(), *newEvent);
   event.Skip();
 }
@@ -256,12 +273,11 @@ void wxCDMProjectDescriptionPanel::OnBtnManageLibraries(wxCommandEvent& event)
   newEvent->SetString(wxT("manage_libraries"));
   wxPostEvent(this->GetParent(), *newEvent);
 
-  wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
+  wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
 
   if(this->project->GetLib() != NULL)
     {
-      int CMId = this->project->GetLib()->GetId();
-      newEvent1->SetInt(CMId);
+      newEvent1->SetClientData(this->project->GetLib());
       newEvent1->SetId(0);
       wxPostEvent(this->GetParent(), *newEvent1);
     }
@@ -276,12 +292,11 @@ void wxCDMProjectDescriptionPanel::OnBtnManageApplications(wxCommandEvent& event
   newEvent->SetString(wxT("manage_applications"));
   wxPostEvent(this->GetParent(), *newEvent);
 
-  wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
+  wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
 
   if(this->project->GetAppli() != NULL)
     {
-      int CMId = this->project->GetAppli()->GetId();
-      newEvent1->SetInt(CMId);
+      newEvent1->SetClientData(this->project->GetAppli());
       newEvent1->SetId(0);
       wxPostEvent(this->GetParent(), *newEvent1);
     }
@@ -289,25 +304,30 @@ void wxCDMProjectDescriptionPanel::OnBtnManageApplications(wxCommandEvent& event
   event.Skip();
 }
 
+void wxCDMProjectDescriptionPanel::OnBtnConfigProject(wxCommandEvent& event)
+{
+  wxCDMProjectConfigurationDialog* dialog = new wxCDMProjectConfigurationDialog(this,this->project);
+  long userResponse;
+  userResponse = dialog->ShowModal();
+}
+
 void wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
 {
   std::string* result;
   if(!this->project->OpenCMakeListsFile(result))
     wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
 
-  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
+  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
 
   if(this->project->GetCMakeLists() != NULL)
     {
-      int CMId = this->project->GetCMakeLists()->GetId();
-      newEvent->SetInt(CMId);
+      newEvent->SetClientData(this->project->GetCMakeLists());
       newEvent->SetId(0);
       wxPostEvent(this->GetParent(), *newEvent);
     }
 }
 
-void
-wxCDMProjectDescriptionPanel::OnBtnSetBuildPath(wxCommandEvent& event)
+void wxCDMProjectDescriptionPanel::OnBtnSetBuildPath(wxCommandEvent& event)
 {
   wxDirDialog* dialog = new wxDirDialog(this, wxT("Choose the new build location for the project"));
   if(dialog->ShowModal())
@@ -319,8 +339,13 @@ wxCDMProjectDescriptionPanel::OnBtnSetBuildPath(wxCommandEvent& event)
   this->buildPathtc->SetLabel(crea::std2wx(this->project->GetBuildPath()));
 }
 
-void
-wxCDMProjectDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
+void wxCDMProjectDescriptionPanel::OnBtnOpenBuild(wxCommandEvent& event)
+{
+  if(CDMUtilities::openFileExplorer(this->project->GetBuildPath()))
+    wxMessageBox(crea::std2wx("The folder doesn't exist or hasn't yet been created."),_T("Open Folder - Error!"),wxOK | wxICON_ERROR);
+}
+
+void wxCDMProjectDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
 {
   std::string* result;
   if(!this->project->OpenInFileExplorer(result))
@@ -355,12 +380,11 @@ void wxCDMProjectDescriptionPanel::OnBtnSetVersion(wxCommandEvent& event)
 
 void wxCDMProjectDescriptionPanel::OnCMakeMouseEnter(wxMouseEvent& event)
 {
-  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
+  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
 
   if(this->project->GetCMakeLists() != NULL)
     {
-      int CMId = this->project->GetCMakeLists()->GetId();
-      newEvent->SetInt(CMId);
+      newEvent->SetClientData(this->project->GetCMakeLists());
       newEvent->SetId(0);
       wxPostEvent(this->GetParent(), *newEvent);
     }
@@ -369,12 +393,11 @@ void wxCDMProjectDescriptionPanel::OnCMakeMouseEnter(wxMouseEvent& event)
 
 void wxCDMProjectDescriptionPanel::OnCMakeMouseExit(wxMouseEvent& event)
 {
-  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
+  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
 
   if(this->project->GetCMakeLists() != NULL)
     {
-      int CMId = this->project->GetCMakeLists()->GetId();
-      newEvent->SetInt(CMId);
+      newEvent->SetClientData(this->project->GetCMakeLists());
       newEvent->SetId(0);
       wxPostEvent(this->GetParent(), *newEvent);
     }
@@ -383,12 +406,11 @@ void wxCDMProjectDescriptionPanel::OnCMakeMouseExit(wxMouseEvent& event)
 
 void wxCDMProjectDescriptionPanel::OnAppliMouseEnter(wxMouseEvent& event)
 {
-  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
+  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
   std::cout << "entra appli " << this->project->GetAppli()->GetCMakeLists();
   if(this->project->GetAppli() != NULL)
     {
-      int AppId = this->project->GetAppli()->GetId();
-      newEvent->SetInt(AppId);
+      newEvent->SetClientData(this->project->GetAppli());
       newEvent->SetId(0);
       wxPostEvent(this->GetParent(), *newEvent);
     }
@@ -397,12 +419,11 @@ void wxCDMProjectDescriptionPanel::OnAppliMouseEnter(wxMouseEvent& event)
 
 void wxCDMProjectDescriptionPanel::OnAppliMouseExit(wxMouseEvent& event)
 {
-  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
+  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
 
   if(this->project->GetAppli() != NULL)
     {
-      int AppId = this->project->GetAppli()->GetId();
-      newEvent->SetInt(AppId);
+      newEvent->SetClientData(this->project->GetAppli());
       newEvent->SetId(0);
       wxPostEvent(this->GetParent(), *newEvent);
     }
@@ -411,12 +432,11 @@ void wxCDMProjectDescriptionPanel::OnAppliMouseExit(wxMouseEvent& event)
 
 void wxCDMProjectDescriptionPanel::OnLibMouseEnter(wxMouseEvent& event)
 {
-  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
+  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
 
   if(this->project->GetLib() != NULL)
     {
-      int LbId = this->project->GetLib()->GetId();
-      newEvent->SetInt(LbId);
+      newEvent->SetClientData(this->project->GetLib());
       newEvent->SetId(0);
       wxPostEvent(this->GetParent(), *newEvent);
     }
@@ -425,12 +445,11 @@ void wxCDMProjectDescriptionPanel::OnLibMouseEnter(wxMouseEvent& event)
 
 void wxCDMProjectDescriptionPanel::OnLibMouseExit(wxMouseEvent& event)
 {
-  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
+  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
 
   if(this->project->GetLib() != NULL)
     {
-      int LbId = this->project->GetLib()->GetId();
-      newEvent->SetInt(LbId);
+      newEvent->SetClientData(this->project->GetLib());
       newEvent->SetId(0);
       wxPostEvent(this->GetParent(), *newEvent);
     }