]> Creatis software - crea.git/commitdiff
Feature #1711
authorDaniel Gonzalez <daniel.gonzalez@creatis.insa-lyon.fr>
Fri, 14 Dec 2012 15:19:57 +0000 (16:19 +0100)
committerDaniel Gonzalez <daniel.gonzalez@creatis.insa-lyon.fr>
Fri, 14 Dec 2012 15:19:57 +0000 (16:19 +0100)
CreaDevManager application implementation

- Setting up links highlighting in appli, lib, package Descriptions, and package Manager.
- Open Folder in Package implemented
- Open CMakeLists file in Project implemented
- Open Folder in Project implemented
- Set Project Version implemented
- Set Project Date implemented
- Set Project Build path implemented

15 files changed:
lib/creaDevManagerLib/CDMUtilities.cpp
lib/creaDevManagerLib/CDMUtilities.h
lib/creaDevManagerLib/modelCDMAppli.cpp
lib/creaDevManagerLib/modelCDMFolder.cpp
lib/creaDevManagerLib/modelCDMFolder.h
lib/creaDevManagerLib/modelCDMIProjectTreeNode.cpp
lib/creaDevManagerLib/modelCDMProject.cpp
lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.cpp
lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.h
lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp
lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp
lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.h
lib/creaDevManagerLib/wxCDMPackageManagerPanel.cpp
lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.cpp
lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.h

index 0149e8dbd5488000f8481549c1570bf5fe3b2070..d9ef9b7fff10d5504245a47aa2c825575e2fb3ad 100644 (file)
@@ -36,6 +36,7 @@
 
 #include<vector>
 #include<string>
+#include <cstdlib>
 
 namespace CDMUtilities
 {
@@ -92,4 +93,25 @@ namespace CDMUtilities
     return pathFixed;
 
   }
+
+  int openTextEditor(const std::string& file)
+  {
+    std::string command = TEXT_EDITOR;
+
+    if(file != "")
+      command += " \"" + file + "\" &";
+
+    return system(command.c_str());
+  }
+
+  int openFileExplorer(const std::string& file)
+    {
+      std::string command = FILE_EXPLORER;
+
+      if(file != "")
+        command += " \"" + file + "\" &";
+
+      return system(command.c_str());
+    }
+
 }
index 2b4f05bfcea9a505864c7969d26ea3964a9cf5df..16630d29e3e64793d2e5ac3897531ef68f8773d0 100644 (file)
 
 namespace CDMUtilities
 {
+  //text editor program
+#ifdef _WIN32
+  // ------ Windows
+  //TODO: implementation for windows
+#elif __APPLE__
+  // ------ Apple
+  //TODO: implementation for apple
+#else
+  static std::string TEXT_EDITOR = "gedit";
+#endif
+
+  //file explorer program
+#ifdef _WIN32
+  // ------ Windows
+  //TODO: implementation for windows
+#elif __APPLE__
+  // ------ Apple
+  //TODO: implementation for apple
+#else
+  static std::string FILE_EXPLORER = "nautilus";
+#endif
+
+
   struct splitter
   {
     enum empties_t { empties_ok, no_empties };
     template <typename Container>
-      static Container& split
-      (
-          Container& result,
-          const typename Container::value_type& s,
-          const typename Container::value_type& delimiters,
-          empties_t empties = empties_ok
-      );
+    static Container& split
+    (
+        Container& result,
+        const typename Container::value_type& s,
+        const typename Container::value_type& delimiters,
+        empties_t empties = empties_ok
+    );
   };
 
   const std::string fixPath(const std::string& path);
+
+  int openTextEditor(const std::string& file = "");
+  int openFileExplorer(const std::string& file = "");
 };
 
 #endif /* CDMUTILITIES_H_ */
index d370a17d0caa4491c55fb0657517604ee480978f..79c17eafec0302892d9884928b5babfc94b3299c 100644 (file)
@@ -93,7 +93,7 @@ modelCDMApplication* modelCDMAppli::CreateApplication(
     const std::string& path
 )
 {
-  //copy template library folder with new name
+  //copy template application folder with new name
   //TODO: fix for windows
   std::string copyCommand = "cp -r " + this->path + "/template_appli " + this->path + "/" + name;
   if(system(copyCommand.c_str()))
index ed718747d8dc971a807e518b6a8703daf3ce4648..73312b64fbae52a4c1c1fac588a8fcce733cb6c9 100644 (file)
@@ -136,6 +136,16 @@ const bool modelCDMFolder::Refresh(std::string*& result)
   return true;
 }
 
+modelCDMCMakeListsFile* modelCDMFolder::GetCMakeLists() const
+{
+  return this->CMakeLists;
+}
+
+std::vector<modelCDMFolder*> modelCDMFolder::GetFolders() const
+{
+  return this->folders;
+}
+
 bool
 modelCDMFolder::HasCMakeLists()
 {
index f8cd26c34c3acf5b1f83cb089d3067eace0230c2..383f89d5deb5be8e421b86f568fe241e1ca9449c 100644 (file)
@@ -48,6 +48,9 @@ public:
   modelCDMFolder(const std::string& path, const int& level = 3);
   ~modelCDMFolder();
 
+  modelCDMCMakeListsFile* GetCMakeLists() const;
+  std::vector<modelCDMFolder*> GetFolders() const;
+
   bool CreateFolder(
       const std::string& name,
       std::string*& result,
index 1c9db624a2e58e1d387ccaf804e9933effca0517..8676627df6bf2717ab480dcf90e5244461a10772 100644 (file)
@@ -34,6 +34,8 @@
 #include "modelCDMIProjectTreeNode.h"
 #include <algorithm>
 
+#include "CDMUtilities.h"
+
 #include "wx/dir.h"
 
 bool modelCDMIProjectTreeNode::CompareNodeItem(const modelCDMIProjectTreeNode* x, const modelCDMIProjectTreeNode* y)
@@ -142,6 +144,11 @@ const int& modelCDMIProjectTreeNode::GetLength()
 
 const bool modelCDMIProjectTreeNode::OpenInFileExplorer(std::string*& result) const
 {
-  //TODO: implement method
-  return false;
+  if (!CDMUtilities::openFileExplorer(this->GetPath()))
+      return true;
+    else
+      {
+        result = new std::string("Couldn't open file.");
+        return false;
+      }
 }
index a961f62268b00433e6eaa0f5eadec1f6ee61bf75..7ebe67d8d5685e11b7407fb342d2621a44bdd4ee 100644 (file)
 #include "modelCDMProject.h"
 
 #include <iostream>
+#include <sstream>
 #include <vector>
 #include <algorithm>
 #include <fstream>
+#include <ctime>
 
 #include "CDMUtilities.h"
 #include "creaWx.h"
@@ -244,13 +246,70 @@ modelCDMLib* modelCDMProject::GetLib() const
 
 bool modelCDMProject::SetVersion(const std::string& version, std::string*& result)
 {
-  //TODO: implement method
+
+  std::vector<std::string> vers;
+  CDMUtilities::splitter::split(vers, version, " .", CDMUtilities::splitter::no_empties);
+
+  time_t now = time(0);
+  tm* ltm = localtime(&now);
+
+  std::stringstream date;
+  date << ltm->tm_mday << "/" << ltm->tm_mon << "/" << 1900 + ltm->tm_year;
+
+  //set name of library in CMakeLists inside copied folder
+  std::string line;
+  std::ifstream in((this->path + "/CMakeLists.txt").c_str());
+  if( !in.is_open())
+    {
+      result = new std::string("CMakeLists.txt file failed to open.");
+      return false;
+    }
+  std::ofstream out((this->path + "/CMakeLists.txt.tmp").c_str());
+  if( !out.is_open())
+    {
+      result = new std::string("CMakeLists.txt.tmp file failed to open.");
+      return false;
+    }
+  while (getline(in, line))
+    {
+      if(line.find("SET(PROJECT_MAJOR_VERSION") != std::string::npos)
+        line = "SET(PROJECT_MAJOR_VERSION " + vers[0] + ")";
+      else if(line.find("SET(PROJECT_MINOR_VERSION") != std::string::npos)
+        line = "SET(PROJECT_MINOR_VERSION " + vers[1] + ")";
+      else if(line.find("SET(PROJECT_BUILD_VERSION") != std::string::npos)
+        line = "SET(PROJECT_BUILD_VERSION " + vers[2] + ")";
+      else if(line.find("SET(PROJECT_VERSION_DATE") != std::string::npos)
+              line = "SET(PROJECT_VERSION_DATE \"" + date.str() + "\")";
+      out << line << std::endl;
+    }
+  in.close();
+  out.close();
+  //delete old file and rename new file
+  std::string renameCommand = "mv " + this->path + "/CMakeLists.txt.tmp " + this->path + "/CMakeLists.txt";
+  if(system(renameCommand.c_str()))
+    {
+      result = new std::string("An error occurred while running '" + renameCommand + "'.");
+      return false;
+    }
+
+  this->version = vers[0] + "." + vers[1] + "." + vers[2];
+  this->versionDate = date.str();
   return true;
 }
 
 bool modelCDMProject::SetBuildPath(const std::string& path, std::string*& result)
 {
-  //TODO: implement method
+  if(path == "")
+    {
+      result = new std::string("The path cannot be empty");
+      return false;
+    }
+  if(path == this->path)
+    {
+      result = new std::string("The path cannot be same as the project sources");
+      return false;
+    }
+  this->buildPath = path;
   return true;
 }
 
@@ -339,11 +398,11 @@ modelCDMIProjectTreeNode* modelCDMProject::CreateApplication(
 )
 {
   if(this->appli != NULL)
-      {
-        return this->appli->CreateApplication(name, result);
-      }
-    result = new std::string("there is no appli folder in this project.");
-    return NULL;
+    {
+      return this->appli->CreateApplication(name, result);
+    }
+  result = new std::string("there is no appli folder in this project.");
+  return NULL;
 }
 
 modelCDMIProjectTreeNode* modelCDMProject::CreateBlackBox(
@@ -361,8 +420,13 @@ modelCDMIProjectTreeNode* modelCDMProject::CreateBlackBox(
 
 bool modelCDMProject::OpenCMakeListsFile(std::string*& result)
 {
-  //TODO: implement method
-  return true;
+  if (!CDMUtilities::openTextEditor(this->CMakeLists->GetPath()))
+    return true;
+  else
+    {
+      result = new std::string("Couldn't open CMakeLists file.");
+      return false;
+    }
 }
 
 const bool modelCDMProject::Refresh(std::string*& result)
index 778525fe842d8b309ea8a5017bb5a4daedc904de..390af69172107bdd39b26262717276195ab93739 100644 (file)
@@ -104,11 +104,13 @@ void wxCDMAppliDescriptionPanel::CreateControls()
   std::vector<modelCDMApplication*> applications = this->appli->GetApplications();
   for (int i = 0; i < applications.size(); i++)
     {
-      wxHyperlinkCtrl* pLibrarylk = new wxHyperlinkCtrl(propertiesPanel,ID_LINK_SELECT_APPLICATION, crea::std2wx(applications[i]->GetName().c_str()), crea::std2wx(applications[i]->GetName().c_str()));
+      wxHyperlinkCtrl* pApplicationlk = new wxHyperlinkCtrl(propertiesPanel,ID_LINK_SELECT_APPLICATION, crea::std2wx(applications[i]->GetName().c_str()), crea::std2wx(applications[i]->GetName().c_str()));
       std::string tt = "Name: " + applications[i]->GetName() + "\n";
       tt += "Location: " + applications[i]->GetPath();
-      pLibrarylk->SetToolTip(crea::std2wx(tt.c_str()));
-      propertiesPanelSizer -> Add(pLibrarylk, 0, wxALIGN_LEFT | wxALL, 5);
+      pApplicationlk->SetToolTip(crea::std2wx(tt.c_str()));
+      pApplicationlk->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMAppliDescriptionPanel::OnMouseEnter,NULL,this);
+      pApplicationlk->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMAppliDescriptionPanel::OnMouseExit,NULL,this);
+      propertiesPanelSizer -> Add(pApplicationlk, 0, wxALIGN_LEFT | wxALL, 5);
     }
 
   propertiesPanel->SetSizer(propertiesPanelSizer);
@@ -196,6 +198,10 @@ void wxCDMAppliDescriptionPanel::OnLnkApplicationSelect(wxHyperlinkEvent& event)
           break;
         }
     }
+  wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
+  newEvent1->SetInt(applicationId);
+  newEvent1->SetId(0);
+  wxPostEvent(this->GetParent(), *newEvent1);
 
   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
   newEvent->SetInt(applicationId);
@@ -211,10 +217,50 @@ void wxCDMAppliDescriptionPanel::OnBtnReturn(wxCommandEvent& event)
   wxPostEvent(this->GetParent(), *newEvent);
 }
 
-void
-wxCDMAppliDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
+void wxCDMAppliDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
 {
   //TODO: implement method
   std::cerr << "Event OnBtnOpenFolder not implemented" << std::endl;
   event.Skip();
 }
+
+void wxCDMAppliDescriptionPanel::OnMouseEnter(wxMouseEvent& event)
+{
+  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
+  std::string AppName = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL());
+  int appId = 0;
+  std::vector<modelCDMApplication*> applications = this->appli->GetApplications();
+  for (int i = 0; i < applications.size(); i++)
+    {
+      if(applications[i]->GetName() == AppName)
+        {
+          appId = applications[i]->GetId();
+          break;
+        }
+    }
+  newEvent->SetInt(appId);
+  newEvent->SetId(0);
+  wxPostEvent(this->GetParent(), *newEvent);
+  event.Skip();
+}
+
+void wxCDMAppliDescriptionPanel::OnMouseExit(wxMouseEvent& event)
+{
+  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
+  std::string AppName = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL());
+  int appId = 0;
+  std::vector<modelCDMApplication*> applications = this->appli->GetApplications();
+  for (int i = 0; i < applications.size(); i++)
+    {
+      if(applications[i]->GetName() == AppName)
+        {
+          appId = applications[i]->GetId();
+          break;
+        }
+    }
+  newEvent->SetInt(appId);
+  newEvent->SetId(0);
+  wxPostEvent(this->GetParent(), *newEvent);
+  event.Skip();
+}
+
index 01d4c78033d193a7ff5642a6f2108ab7d41bde35..dd44456982363cba4781792063b91f0186077a18 100644 (file)
@@ -80,6 +80,9 @@ protected:
   void OnBtnReturn(wxCommandEvent& event);
   void OnBtnOpenFolder(wxCommandEvent& event);
 
+  void OnMouseEnter(wxMouseEvent& event);
+  void OnMouseExit(wxMouseEvent& event);
+
 };
 
 #endif /* WXCDMAPPLIDESCRIPTIONPANEL_H_ */
index 88d598bc6141a0cc585a30a426c198735bee3c95..313a720dd569a8835729b240f2c430cde2ded02e 100644 (file)
@@ -202,6 +202,11 @@ void wxCDMLibDescriptionPanel::OnLnkLibrarySelect(wxHyperlinkEvent& event)
   newEvent->SetId(0);
   wxPostEvent(this->GetParent(), *newEvent);
 
+  wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
+  newEvent1->SetInt(libraryId);
+  newEvent1->SetId(0);
+  wxPostEvent(this->GetParent(), *newEvent1);
+
 }
 
 void wxCDMLibDescriptionPanel::OnBtnReturn(wxCommandEvent& event)
index 5a4f56ae64efd0ef0ff1340789b8ac4f67a1e876..d6271ba80feda36af37263956e4ea90d49ec4934 100644 (file)
@@ -158,6 +158,8 @@ void wxCDMPackageDescriptionPanel::CreateControls()
       wxHyperlinkCtrl* pBBlk = new wxHyperlinkCtrl(BBPanel,ID_LINK_SELECT_BLACKBOX, crea::std2wx(blackBoxes[i]->GetName().c_str()), crea::std2wx(blackBoxes[i]->GetName().c_str()));
       std::string tt = "Author: " + blackBoxes[i]->GetAuthors() + "\nDescription: " + blackBoxes[i]->GetDescription() + "\nCategories: " + blackBoxes[i]->GetCategories();
       pBBlk->SetToolTip(crea::std2wx(tt));
+      pBBlk->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageDescriptionPanel::OnMouseEnter,NULL,this);
+      pBBlk->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageDescriptionPanel::OnMouseExit,NULL,this);
       BBPanelSizer -> Add(pBBlk, 0, wxALIGN_LEFT | wxALL, 5);
     }
 
@@ -177,6 +179,8 @@ void wxCDMPackageDescriptionPanel::CreateControls()
   actionsPanelSizer->Add(createBBbt, 0, wxALL, 5);
   wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File"));
   editCMakebt->SetToolTip(wxT("Open the system default text editor to edit the package's CMakeLists.txt file."));
+  editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageDescriptionPanel::OnCMakeMouseEnter,NULL,this);
+  editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageDescriptionPanel::OnCMakeMouseExit,NULL,this);
   actionsPanelSizer->Add(editCMakebt, 0, wxALL, 5);
   wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Package Folder"));
   openFolderbt->SetToolTip(wxT("Open the package folder in the file explorer."));
@@ -218,6 +222,11 @@ void wxCDMPackageDescriptionPanel::OnLnkBlackBoxSelect(wxHyperlinkEvent& event)
   newEvent->SetId(0);
   wxPostEvent(this->GetParent(), *newEvent);
 
+  wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
+  newEvent1->SetInt(bbId);
+  newEvent1->SetId(0);
+  wxPostEvent(this->GetParent(), *newEvent1);
+
 }
 
 void wxCDMPackageDescriptionPanel::OnBtnCreateBlackBox(wxCommandEvent& event)
@@ -241,3 +250,72 @@ void wxCDMPackageDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
   event.Skip();
 }
 
+void wxCDMPackageDescriptionPanel::OnMouseEnter(wxMouseEvent& event)
+{
+  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
+  std::string BBName = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL());
+  int bbId = 0;
+  std::vector<modelCDMBlackBox*> boxes = this->package->GetBlackBoxes();
+  for (int i = 0; i < boxes.size(); i++)
+    {
+      if(boxes[i]->GetName() == BBName)
+        {
+          bbId = boxes[i]->GetId();
+          break;
+        }
+    }
+  newEvent->SetInt(bbId);
+  newEvent->SetId(0);
+  wxPostEvent(this->GetParent(), *newEvent);
+  event.Skip();
+}
+
+void wxCDMPackageDescriptionPanel::OnMouseExit(wxMouseEvent& event)
+{
+  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
+  std::string BBName = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL());
+  int bbId = 0;
+  std::vector<modelCDMBlackBox*> boxes = this->package->GetBlackBoxes();
+  for (int i = 0; i < boxes.size(); i++)
+    {
+      if(boxes[i]->GetName() == BBName)
+        {
+          bbId = boxes[i]->GetId();
+          break;
+        }
+    }
+  newEvent->SetInt(bbId);
+  newEvent->SetId(0);
+  wxPostEvent(this->GetParent(), *newEvent);
+  event.Skip();
+}
+
+void wxCDMPackageDescriptionPanel::OnCMakeMouseEnter(wxMouseEvent& event)
+{
+  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
+
+  if(this->package->GetCMakeLists() != NULL)
+    {
+      int CMId = this->package->GetCMakeLists()->GetId();
+      newEvent->SetInt(CMId);
+      newEvent->SetId(0);
+      wxPostEvent(this->GetParent(), *newEvent);
+    }
+  event.Skip();
+}
+
+void wxCDMPackageDescriptionPanel::OnCMakeMouseExit(wxMouseEvent& event)
+{
+  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
+
+  if(this->package->GetCMakeLists() != NULL)
+    {
+      int CMId = this->package->GetCMakeLists()->GetId();
+      newEvent->SetInt(CMId);
+      newEvent->SetId(0);
+      wxPostEvent(this->GetParent(), *newEvent);
+    }
+  event.Skip();
+}
+
+
index a6688a2b98e410efec4ac5bd425fa34864b461c7..41c2ba5d16db8f9775294d59c3a0502ecae2daad 100644 (file)
@@ -80,6 +80,12 @@ protected:
   void OnBtnEditCMakeLists(wxCommandEvent& event);
   void OnBtnOpenFolder(wxCommandEvent& event);
 
+  void OnMouseEnter(wxMouseEvent& event);
+  void OnMouseExit(wxMouseEvent& event);
+
+  void OnCMakeMouseEnter(wxMouseEvent& event);
+  void OnCMakeMouseExit(wxMouseEvent& event);
+
 };
 
 #endif /* WXCDMPACKAGEDESCRIPTIONPANEL_H_ */
index 8ace0666d906a12b30979a340cc2efc46802aae9..28b2fe110db2fdc8b3aa5756f03a297b6b26e289 100644 (file)
@@ -166,6 +166,11 @@ void wxCDMPackageManagerPanel::OnLnkPackageSelect(wxHyperlinkEvent& event)
   newEvent->SetId(0);
   wxPostEvent(this->GetParent(), *newEvent);
 
+  wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
+  newEvent1->SetInt(packageId);
+  newEvent1->SetId(0);
+  wxPostEvent(this->GetParent(), *newEvent1);
+
 }
 
 void wxCDMPackageManagerPanel::OnBtnCreatePackage(wxCommandEvent& event)
@@ -242,7 +247,7 @@ void wxCDMPackageManagerPanel::OnMouseExit(wxMouseEvent& event)
   std::string PkgName = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL());
   int pkgId = 0;
   std::vector<modelCDMPackage*> packages = this->project->GetPackages();
-      project->GetPackages();
+  project->GetPackages();
   for (int i = 0; i < packages.size(); i++)
     {
       if(packages[i]->GetName() == PkgName)
index ecd4e894b9ed75029418effb088dc6d31e176515..e49e2899feaa4375c5264feec4bb603fd7ceeabd 100644 (file)
@@ -39,6 +39,7 @@
 
 #include "creaDevManagerIds.h"
 #include "images/PrIcon64.xpm"
+#include "CDMUtilities.h"
 
 BEGIN_EVENT_TABLE(wxCDMProjectDescriptionPanel, wxPanel)
 EVT_BUTTON(ID_BUTTON_GOTO_PACKAGE_MANAGER, wxCDMProjectDescriptionPanel::OnBtnManagePackages)
@@ -114,13 +115,13 @@ void wxCDMProjectDescriptionPanel::CreateControls()
   //values
   // version
   wxBoxSizer* pVersionsz = new wxBoxSizer(wxHORIZONTAL);
-  wxStaticText* pVersiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->project->GetVersion()));
+  this->versiontc = 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(this->versiontc, 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()));
+  this->versionDatetc = 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()));
@@ -131,17 +132,17 @@ void wxCDMProjectDescriptionPanel::CreateControls()
   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));
+  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"));
   pBuildLocationbt->SetToolTip(wxT("Select a new location for compiling the project."));
-  pBuildLocationsz->Add(pBuildLocationtc, 0, wxALIGN_CENTER, 0);
+  pBuildLocationsz->Add(this->buildPathtc, 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(this->versionDatetc, 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);
@@ -203,8 +204,7 @@ void wxCDMProjectDescriptionPanel::CreateControls()
   sizer->SetSizeHints(this);
 }
 
-void
-wxCDMProjectDescriptionPanel::OnBtnManagePackages(wxCommandEvent& event)
+void wxCDMProjectDescriptionPanel::OnBtnManagePackages(wxCommandEvent& event)
 {
   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
   newEvent->SetId(1);
@@ -214,8 +214,7 @@ wxCDMProjectDescriptionPanel::OnBtnManagePackages(wxCommandEvent& event)
   event.Skip();
 }
 
-void
-wxCDMProjectDescriptionPanel::OnBtnManageLibraries(wxCommandEvent& event)
+void wxCDMProjectDescriptionPanel::OnBtnManageLibraries(wxCommandEvent& event)
 {
   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
   newEvent->SetId(1);
@@ -224,8 +223,7 @@ wxCDMProjectDescriptionPanel::OnBtnManageLibraries(wxCommandEvent& event)
   event.Skip();
 }
 
-void
-wxCDMProjectDescriptionPanel::OnBtnManageApplications(wxCommandEvent& event)
+void wxCDMProjectDescriptionPanel::OnBtnManageApplications(wxCommandEvent& event)
 {
   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
   newEvent->SetId(1);
@@ -236,25 +234,30 @@ wxCDMProjectDescriptionPanel::OnBtnManageApplications(wxCommandEvent& event)
 
 void wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
 {
-  //TODO: implement method
-  std::cerr << "Event OnBtnEditCMakeLists not implemented" << std::endl;
-  event.Skip();
+  std::string* result;
+  if(!this->project->OpenCMakeListsFile(result))
+    wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
 }
 
 void
 wxCDMProjectDescriptionPanel::OnBtnSetBuildPath(wxCommandEvent& event)
 {
-  //TODO: implement method
-  std::cerr << "Event OnBtnSetBuildPath not implemented" << std::endl;
-  event.Skip();
+  wxDirDialog* dialog = new wxDirDialog(this, wxT("Choose the new build location for the project"));
+  if(dialog->ShowModal())
+    {
+      std::string* result;
+      if(!this->project->SetBuildPath(crea::wx2std(dialog->GetPath()), result))
+        wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
+    }
+  this->buildPathtc->SetLabel(crea::std2wx(this->project->GetBuildPath()));
 }
 
 void
 wxCDMProjectDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
 {
-  //TODO: implement method
-  std::cerr << "Event OnBtnOpenFolder not implemented" << std::endl;
-  event.Skip();
+  std::string* result;
+  if(!this->project->OpenInFileExplorer(result))
+    wxMessageBox(crea::std2wx(*result),_T("Open File - Error!"),wxOK | wxICON_ERROR);
 }
 
 void
@@ -263,4 +266,27 @@ wxCDMProjectDescriptionPanel::OnBtnSetVersion(wxCommandEvent& event)
   //TODO: implement method
   std::cerr << "Event OnBtnSetVersion not implemented" << std::endl;
   event.Skip();
+
+  //get name
+  wxString libraryName = wxGetTextFromUser(
+      wxT("Enter the new version name"),
+      wxT("New Library - creaDevManager"),
+      crea::std2wx(this->project->GetVersion())
+  );
+  //check name
+  std::vector<std::string> parts;
+  CDMUtilities::splitter::split(parts, crea::wx2std(libraryName), " .", CDMUtilities::splitter::no_empties);
+  if(parts.size() == 3)
+    {
+      std::string* result;
+      if(!this->project->SetVersion(crea::wx2std(libraryName), result))
+        wxMessageBox(crea::std2wx(*result),_T("Open File - Error!"),wxOK | wxICON_ERROR);
+    }
+  else
+    {
+      wxMessageBox(crea::std2wx("The version format is incorrect, please follow the following format:\nX.Y.Z\nX: Major Version\nY: Minor Version\nZ: Build Version"),_T("Set Project Version - Error!"),wxOK | wxICON_ERROR);
+    }
+  this->versiontc->SetLabel(crea::std2wx(this->project->GetVersion()));
+  this->versionDatetc->SetLabel(crea::std2wx(this->project->GetVersionDate()));
+
 }
index 0c347d8ebd3c1fd00db1db04728427c158ee1dcf..0ac8771bf3e37150da75b0ba804303ef47f0306e 100644 (file)
@@ -71,6 +71,9 @@ public:
 
 private:
   modelCDMProject* project;
+  wxStaticText* versiontc;
+  wxStaticText* versionDatetc;
+  wxStaticText* buildPathtc;
 
   //handlers
 protected: