]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.cpp
Feature #1711
[crea.git] / lib / creaDevManagerLib / wxCDMProjectDescriptionPanel.cpp
index 5093d7173a7855b6141c09b26d8147488f418bb3..ecd4e894b9ed75029418effb088dc6d31e176515 100644 (file)
 #include "wxCDMProjectDescriptionPanel.h"
 
 #include "wxCDMMainFrame.h"
+#include "wxCDMNewPackageDialog.h"
 
 #include "creaDevManagerIds.h"
 #include "images/PrIcon64.xpm"
 
 BEGIN_EVENT_TABLE(wxCDMProjectDescriptionPanel, wxPanel)
-EVT_BUTTON(ID_BUTTON_CREATE_PACKAGE, wxCDMProjectDescriptionPanel::OnBtnCreatePackage)
-EVT_BUTTON(ID_BUTTON_CREATE_BLACKBOX, wxCDMProjectDescriptionPanel::OnBtnCreateBlackBox)
-EVT_BUTTON(ID_BUTTON_CREATE_LIBRARY, wxCDMProjectDescriptionPanel::OnBtnCreateLibrary)
-EVT_BUTTON(ID_BUTTON_CREATE_APPLICATION, wxCDMProjectDescriptionPanel::OnBtnCreateApplication)
+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_EDIT_CMAKELISTSFILE, wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists)
-EVT_COMMAND(wxID_ANY, wxEVT_DISPLAY_CHANGED, wxCDMProjectDescriptionPanel::OnCreationComplete)
+EVT_BUTTON(ID_BUTTON_SET_BUILD_PATH, wxCDMProjectDescriptionPanel::OnBtnSetBuildPath)
+EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMProjectDescriptionPanel::OnBtnOpenFolder)
+EVT_BUTTON(ID_BUTTON_SET_VERSION, wxCDMProjectDescriptionPanel::OnBtnSetVersion)
 END_EVENT_TABLE()
 
 wxCDMProjectDescriptionPanel::wxCDMProjectDescriptionPanel(
@@ -94,119 +96,171 @@ void wxCDMProjectDescriptionPanel::CreateControls()
   //Project Name
   sizer->Add(new wxStaticText(this, -1, crea::std2wx(this->project->GetName())),0, wxALIGN_CENTER, 0);
 
-  //Project Properties
-  wxStaticBox* propertiesBox = new wxStaticBox(this, -1, _T("&Properties"));
-  wxStaticBoxSizer* propertiesBoxInnerSizer = new wxStaticBoxSizer(propertiesBox, wxVERTICAL);
-
-  wxFlexGridSizer* flexGridSizer = new wxFlexGridSizer(4, 2, 9, 15);
-
-  wxStaticText *pVersion = new wxStaticText(this, -1, wxT("Version"));
-  wxStaticText *pVersionDate = new wxStaticText(this, -1, wxT("Version Date"));
-  wxStaticText *pSourceLocation = new wxStaticText(this, -1, wxT("Source Location"));
-  wxStaticText *pBuildLocation = new wxStaticText(this, -1, wxT("Build Location"));
-
-  wxTextCtrl *pVersiontc = new wxTextCtrl(this, -1, crea::std2wx(this->project->GetVersion()));
-  wxTextCtrl *pVersionDatetc = new wxTextCtrl(this, -1, crea::std2wx(this->project->GetVersionDate()));
-  wxTextCtrl *pSourceLocationtc = new wxTextCtrl(this, -1, crea::std2wx(this->project->GetPath()));
-  wxTextCtrl *pBuildLocationtc = new wxTextCtrl(this, -1, crea::std2wx(this->project->GetBuildPath()));
-
-  flexGridSizer->Add(pVersion, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
-  flexGridSizer->Add(pVersiontc, 1, wxEXPAND);
-  flexGridSizer->Add(pVersionDate, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
-  flexGridSizer->Add(pVersionDatetc, 1, wxEXPAND);
-  flexGridSizer->Add(pSourceLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
-  flexGridSizer->Add(pSourceLocationtc, 1, wxEXPAND);
-  flexGridSizer->Add(pBuildLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
-  flexGridSizer->Add(pBuildLocationtc, 1, wxEXPAND);
-
-  propertiesBoxInnerSizer -> Add(flexGridSizer, 0, wxEXPAND);
-  sizer -> Add(propertiesBoxInnerSizer, 1, wxEXPAND | wxALL, 20);
-
-  //Actions
-  wxStaticBox* actionsBox = new wxStaticBox(this, -1, _T("&Actions"));
-  wxStaticBoxSizer* actionsBoxInnerSizer = new wxStaticBoxSizer(actionsBox, wxVERTICAL);
-  sizer -> Add(actionsBoxInnerSizer, 1, wxEXPAND | wxALL, 20);
+  //----------------------------------Project Properties-----------------------------------
+  //properties StaticBoxSizer
+  wxStaticBoxSizer* propertiesBox = new wxStaticBoxSizer(wxVERTICAL, this, _T("&Properties"));
+  //properties Panel
+  wxPanel* propertiesPanel = new wxPanel(this);
+  //properties Sizer
+  wxBoxSizer* propertiesPanelSizer = new wxBoxSizer(wxVERTICAL);
+  //propertiesGrid Sizer
+  wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(4, 2, 9, 15);
+  //properties elements
+  //labels
+  wxStaticText* pVersion = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Version"));
+  wxStaticText* pVersionDate = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Version Date"));
+  wxStaticText* pSourceLocation = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Source Location"));
+  wxStaticText* pBuildLocation = new wxStaticText(propertiesPanel, wxID_ANY, wxT("Build Location"));
+  //values
+  // version
+  wxBoxSizer* pVersionsz = new wxBoxSizer(wxHORIZONTAL);
+  wxStaticText* pVersiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->project->GetVersion()));
+  wxButton* pVersionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Set"));
+  pVersionbt->SetToolTip(wxT("Update the version of the project."));
+  pVersionsz->Add(pVersiontc, 0, wxALIGN_CENTER_VERTICAL, 0);
+  pVersionsz->Add(pVersionbt, 0, wxALIGN_CENTER | wxLEFT, 10);
+  // versionDate
+  wxStaticText* pVersionDatetc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetVersionDate()));
+  // sourceLocation
+  wxBoxSizer* pSourceLocationsz = new wxBoxSizer(wxHORIZONTAL);
+  wxStaticText* pSourceLocationtc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetPath()));
+  pSourceLocationtc->SetMaxSize(wxSize(350,-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, 0, wxALIGN_CENTER, 0);
+  pSourceLocationsz->Add(pSourceLocationbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
+  // buildLocation
+  wxBoxSizer* pBuildLocationsz = new wxBoxSizer(wxHORIZONTAL);
+  wxStaticText* pBuildLocationtc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetBuildPath()));
+  pBuildLocationtc->SetMaxSize(wxSize(350,-1));
+  wxButton* pBuildLocationbt = new wxButton(propertiesPanel, ID_BUTTON_SET_BUILD_PATH, wxT("Choose"));
+  pBuildLocationbt->SetToolTip(wxT("Select a new location for compiling the project."));
+  pBuildLocationsz->Add(pBuildLocationtc, 0, wxALIGN_CENTER, 0);
+  pBuildLocationsz->Add(pBuildLocationbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
+
+  propertiesGridSizer->Add(pVersion, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
+  propertiesGridSizer->Add(pVersionsz, 1, wxEXPAND);
+  propertiesGridSizer->Add(pVersionDate, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
+  propertiesGridSizer->Add(pVersionDatetc, 1, wxEXPAND);
+  propertiesGridSizer->Add(pSourceLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
+  propertiesGridSizer->Add(pSourceLocationsz, 1, wxEXPAND);
+  propertiesGridSizer->Add(pBuildLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
+  propertiesGridSizer->Add(pBuildLocationsz, 1, wxEXPAND);
+
+  propertiesGridSizer->AddGrowableCol(1,1);
+
+  propertiesPanelSizer-> Add(propertiesGridSizer, 0, wxALL | wxEXPAND, 5);
+
+  //SetPanel sizer and box
+  propertiesPanel->SetSizer(propertiesPanelSizer);
+  propertiesPanelSizer->Fit(propertiesPanel);
+  propertiesBox->Add(propertiesPanel, 0, wxEXPAND);
+  sizer->Add(propertiesBox, 0, wxEXPAND | wxALL, 10);
+
+  //----------------------------------Project Actions--------------------------------------
+  //actions StaticBoxSizer
+  wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxHORIZONTAL,this, _T("&Actions"));
+  actionsBox->GetStaticBox()->SetToolTip(wxT("Go to any of the content managers of the project or edit the project's CMakeLists.txt file by selecting any of the available actions."));
+  //actions Panel
+  wxPanel* actionsPanel = new wxPanel(this);
+  //actions Sizer
+  wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL);
+  //buttons
+  // package manager
+  wxButton* packageMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_PACKAGE_MANAGER, _T("Package Manager"));
+  packageMgrbt->SetToolTip(wxT("Find the current available packages into this project. You can also create new Packages in this section."));
+  actionsPanelSizer->Add(packageMgrbt, 0, wxALL, 5);
+  // lib manager
+  // show only if there is a lib folder
+  if(this->project->GetLib() != NULL)
+    {
+      wxButton* libMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_LIB_MANAGER, _T("Library Manager"));
+      libMgrbt->SetToolTip(wxT("Find the current available libraries into this project. You can also create new Libraries in this section as well as edit the lib folder's CMakeLists.txt file."));
+      actionsPanelSizer->Add(libMgrbt, 0, wxALL, 5);
+    }
+  // appli manager
+  // show only if there is a appli folder
+  if(this->project->GetAppli() != NULL)
+    {
+      wxButton* appliMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_APPLI_MANAGER, _T("Application Manager"));
+      appliMgrbt->SetToolTip(wxT("Find the current available applications into this project. You can also create new Applications in this section as well as edit the appli folder's CMakeLists.txt file."));
+      actionsPanelSizer->Add(appliMgrbt, 0, wxALL, 5);
+    }
+  // 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."));
+  actionsPanelSizer->Add(editCMakebt, 0, wxALL, 5);
 
-  actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_CREATE_PACKAGE, _T("Create Package")), 0, wxEXPAND | wxRIGHT | wxLEFT, 20);
-  actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_CREATE_BLACKBOX, _T("Create Black Box")), 0, wxEXPAND | wxRIGHT | wxLEFT, 20);
-  actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_CREATE_LIBRARY, _T("Create Library")), 0, wxEXPAND | wxRIGHT | wxLEFT, 20);
-  actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_CREATE_APPLICATION, _T("Create Application")), 0, wxEXPAND | wxRIGHT | wxLEFT, 20);
+  //SetPanel sizer and box
+  actionsPanel->SetSizer(actionsPanelSizer);
+  actionsPanelSizer->Fit(actionsPanel);
+  actionsBox->Add(actionsPanel, 0, wxALL, 5);
+  sizer->Add(actionsBox, 0, wxEXPAND | wxALL, 10);
 
-  actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File")), 0, wxEXPAND | wxRIGHT | wxLEFT, 20);
 
   //Assign sizer
-  actionsBoxInnerSizer->SetSizeHints(this);
-
-  SetSizer(sizer);
+  this->SetSizer(sizer);
   sizer->SetSizeHints(this);
 }
 
-void wxCDMProjectDescriptionPanel::OnBtnCreatePackage(wxCommandEvent& event)
+void
+wxCDMProjectDescriptionPanel::OnBtnManagePackages(wxCommandEvent& event)
 {
-  //TODO: implement method
-  //TODO: call project to create package : use bbCreatePackage <path> <name> [author] [description]
-  std::cerr << "Event OnBtnCreatePackage not implemented" << std::endl;
+  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
+  newEvent->SetId(1);
+  newEvent->SetString(wxT("manage_packages"));
+  newEvent->SetInt(this->project->GetId());
+  wxPostEvent(this->GetParent(), *newEvent);
   event.Skip();
 }
 
-void wxCDMProjectDescriptionPanel::OnBtnCreateBlackBox(wxCommandEvent& event)
+void
+wxCDMProjectDescriptionPanel::OnBtnManageLibraries(wxCommandEvent& event)
 {
-  //TODO: implement method
-  std::cerr << "Event OnBtnCreatePackage not implemented" << std::endl;
+  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
+  newEvent->SetId(1);
+  newEvent->SetString(wxT("manage_libraries"));
+  wxPostEvent(this->GetParent(), *newEvent);
   event.Skip();
 }
 
-void wxCDMProjectDescriptionPanel::OnBtnCreateLibrary(wxCommandEvent& event)
+void
+wxCDMProjectDescriptionPanel::OnBtnManageApplications(wxCommandEvent& event)
 {
-  //get name
-  wxString libraryName = wxGetTextFromUser(
-      _T("Enter the new library name"),
-      _T("New Library - creaDevManager"),
-      _T("")
-  );
-  //check name
-  if(libraryName.Len() > 0)
-    {
-      std::string* result;
-      //create library
-      modelCDMIProjectTreeNode* library = this->project->CreateLibrary(crea::wx2std(libraryName),result);
-      //check library created
-      if(library == NULL)
-        {
-          wxMessageBox(crea::std2wx(*result),_T("New Library - Error!"),wxOK | wxICON_ERROR);
-          event.Skip();
-          return;
-        }
-      wxMessageBox(crea::std2wx("Library successfully created."),_T("New Library - Success!"),wxOK | wxICON_INFORMATION);
-
-      //refreshing tree and description
-      //send event instead of calling parent to avoid crashing
-
-      ((wxCDMMainFrame*)this->GetParent())->RefreshProject();
-
-      wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
-      newEvent->SetInt(library->GetId());
-      wxPostEvent(this->GetParent(), *newEvent);
-      event.Skip();
-    }
+  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
+  newEvent->SetId(1);
+  newEvent->SetString(wxT("manage_applications"));
+  wxPostEvent(this->GetParent(), *newEvent);
+  event.Skip();
 }
 
-void wxCDMProjectDescriptionPanel::OnBtnCreateApplication(wxCommandEvent& event)
+void wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
 {
   //TODO: implement method
-  std::cerr << "Event OnBtnCreatePackage not implemented" << std::endl;
+  std::cerr << "Event OnBtnEditCMakeLists not implemented" << std::endl;
   event.Skip();
 }
 
-void wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
+void
+wxCDMProjectDescriptionPanel::OnBtnSetBuildPath(wxCommandEvent& event)
 {
   //TODO: implement method
-  std::cerr << "Event OnBtnCreatePackage not implemented" << std::endl;
+  std::cerr << "Event OnBtnSetBuildPath not implemented" << std::endl;
   event.Skip();
 }
 
-void wxCDMProjectDescriptionPanel::OnCreationComplete(wxCommandEvent& event)
+void
+wxCDMProjectDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
 {
-  std::cout << "catched" << std::endl;
+  //TODO: implement method
+  std::cerr << "Event OnBtnOpenFolder not implemented" << std::endl;
+  event.Skip();
+}
 
+void
+wxCDMProjectDescriptionPanel::OnBtnSetVersion(wxCommandEvent& event)
+{
+  //TODO: implement method
+  std::cerr << "Event OnBtnSetVersion not implemented" << std::endl;
+  event.Skip();
 }