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

- Setting up links highlighting in Lib and Appli Descriptions.
- Open Folder in Appli implemented
- Open CMakeLists file in Appli implemented
- Fixed responsibility of open folder to folder class

lib/creaDevManagerLib/modelCDMAppli.cpp
lib/creaDevManagerLib/modelCDMAppli.h
lib/creaDevManagerLib/modelCDMFolder.cpp
lib/creaDevManagerLib/modelCDMIProjectTreeNode.cpp
lib/creaDevManagerLib/modelCDMLib.cpp
lib/creaDevManagerLib/modelCDMLib.h
lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.cpp
lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.h
lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp
lib/creaDevManagerLib/wxCDMLibDescriptionPanel.h

index 79c17eafec0302892d9884928b5babfc94b3299c..ce3388e03d13722a4fc13102569990c566367635 100644 (file)
@@ -138,12 +138,6 @@ modelCDMApplication* modelCDMAppli::CreateApplication(
   return application;
 }
 
-bool modelCDMAppli::OpenCMakeListsFile(std::string*& result)
-{
-  //TODO: implement method
-  return true;
-}
-
 const bool modelCDMAppli::Refresh(std::string*& result)
 {
   //TODO: implement method
index f23942642b61f9a31cc49e77e4cb7eeb9f67a58d..c37924d246719c37b399cc344fed5b3d99fc5572 100644 (file)
@@ -55,7 +55,6 @@ public:
       std::string*& result,
       const std::string& path = "/"
   );
-  bool OpenCMakeListsFile(std::string*& result);
   virtual const bool Refresh(std::string*& result);
 
 private:
index 73312b64fbae52a4c1c1fac588a8fcce733cb6c9..8122ebb063103d94cc23c4bf16b8008ab9e828db 100644 (file)
@@ -126,8 +126,18 @@ bool modelCDMFolder::CreateFolder(const std::string& name, std::string*& result,
 
 bool modelCDMFolder::OpenCMakeListsFile(std::string*& result)
 {
-  //TODO: implement method
-  return true;
+  if (this->CMakeLists == NULL)
+    {
+      result = new std::string("There's no CMakeLists file to open.");
+      return false;
+    }
+  if (!CDMUtilities::openTextEditor(this->CMakeLists->GetPath()))
+    return true;
+  else
+    {
+      result = new std::string("Couldn't open CMakeLists file.");
+      return false;
+    }
 }
 
 const bool modelCDMFolder::Refresh(std::string*& result)
index 8676627df6bf2717ab480dcf90e5244461a10772..fb02b7134175771239231defaec764f14c20461f 100644 (file)
@@ -23,7 +23,7 @@
 #  The fact that you are presently reading this means that you have had
 #  knowledge of the CeCILL-B license and that you accept its terms.
 # ------------------------------------------------------------------------
-*/
+ */
 
 /*
  * modelCDMIProjectTreeNode.cpp
@@ -49,37 +49,37 @@ bool modelCDMIProjectTreeNode::CompareNodeItem(const modelCDMIProjectTreeNode* x
   unsigned char yType = y->GetType();
 
   while ((i < xName.length()) && (i < yName.length()))
-  {
-    if (tolower (xName[i]) < tolower (yName[i]))
-    {
-      noWinner = false;
-      returnValue = true;
-      break;
-    }
-    else if (tolower (xName[i]) > tolower (yName[i]))
     {
-      noWinner = false;
-      returnValue = false;
-      break;
+      if (tolower (xName[i]) < tolower (yName[i]))
+        {
+          noWinner = false;
+          returnValue = true;
+          break;
+        }
+      else if (tolower (xName[i]) > tolower (yName[i]))
+        {
+          noWinner = false;
+          returnValue = false;
+          break;
+        }
+      i++;
     }
-    i++;
-  }
 
   if(noWinner)
-  {
-    if (xName.length() < yName.length())
-      returnValue = true;
-    else
-      returnValue = false;
-  }
+    {
+      if (xName.length() < yName.length())
+        returnValue = true;
+      else
+        returnValue = false;
+    }
 
   if(xType != yType)
-  {
-    if(xType == wxDIR_DIRS)
-      returnValue = true;
-    else
-      returnValue = false;
-  }
+    {
+      if(xType == wxDIR_DIRS)
+        returnValue = true;
+      else
+        returnValue = false;
+    }
 
   return returnValue;
 }
@@ -145,10 +145,10 @@ const int& modelCDMIProjectTreeNode::GetLength()
 const bool modelCDMIProjectTreeNode::OpenInFileExplorer(std::string*& result) const
 {
   if (!CDMUtilities::openFileExplorer(this->GetPath()))
-      return true;
-    else
-      {
-        result = new std::string("Couldn't open file.");
-        return false;
-      }
+    return true;
+  else
+    {
+      result = new std::string("Couldn't open file.");
+      return false;
+    }
 }
index 24033518f493f43e633d253a7edf06e02eeb5ea7..11b5f370252efdb83e624303fc86286af871afb9 100644 (file)
@@ -159,17 +159,6 @@ modelCDMLibrary* modelCDMLib::CreateLibrary(
   return library;
 }
 
-bool modelCDMLib::OpenCMakeListsFile(std::string*& result)
-{
-  if (!CDMUtilities::openTextEditor(this->CMakeLists->GetPath()))
-    return true;
-  else
-    {
-      result = new std::string("Couldn't open CMakeLists file.");
-      return false;
-    }
-}
-
 const bool modelCDMLib::Refresh(std::string*& result)
 {
   this->type = wxDIR_DIRS;
index 8f4fc74c3a8371ad0952f14b3f5c5190acfd1b2b..47de063adfb86cef46810d0db15c2aa1c242aceb 100644 (file)
@@ -56,7 +56,6 @@ public:
       const std::string& path = "/"
   );
 
-  bool OpenCMakeListsFile(std::string*& result);
   virtual const bool Refresh(std::string*& result);
 
 private:
index 390af69172107bdd39b26262717276195ab93739..e7bde237655fd912d6c41851b4c880fc5f388612 100644 (file)
@@ -129,6 +129,8 @@ void wxCDMAppliDescriptionPanel::CreateControls()
   actionsPanelSizer->Add(createApplicationbt, 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 CMakeLists.txt file."));
+  editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMAppliDescriptionPanel::OnCMakeMouseEnter,NULL,this);
+  editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMAppliDescriptionPanel::OnCMakeMouseExit,NULL,this);
   actionsPanelSizer->Add(editCMakebt, 0, wxALL, 5);
   wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Applications Folder"));
   openFolderbt->SetToolTip(wxT("Open the appli folder in the file explorer."));
@@ -181,9 +183,19 @@ void wxCDMAppliDescriptionPanel::OnBtnCreateApplication(wxCommandEvent& event)
 
 void wxCDMAppliDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
 {
-  //TODO: implement method
-  std::cerr << "Event OnBtnEditCMakeLists not implemented" << std::endl;
-  event.Skip();
+  std::string* result;
+  if(!this->appli->OpenCMakeListsFile(result))
+    wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
+
+  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
+
+  if(this->appli->GetCMakeLists() != NULL)
+    {
+      int CMId = this->appli->GetCMakeLists()->GetId();
+      newEvent->SetInt(CMId);
+      newEvent->SetId(0);
+      wxPostEvent(this->GetParent(), *newEvent);
+    }
 }
 
 void wxCDMAppliDescriptionPanel::OnLnkApplicationSelect(wxHyperlinkEvent& event)
@@ -219,9 +231,9 @@ void wxCDMAppliDescriptionPanel::OnBtnReturn(wxCommandEvent& event)
 
 void wxCDMAppliDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
 {
-  //TODO: implement method
-  std::cerr << "Event OnBtnOpenFolder not implemented" << std::endl;
-  event.Skip();
+  std::string* result;
+  if(!this->appli->OpenInFileExplorer(result))
+    wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR);
 }
 
 void wxCDMAppliDescriptionPanel::OnMouseEnter(wxMouseEvent& event)
@@ -264,3 +276,30 @@ void wxCDMAppliDescriptionPanel::OnMouseExit(wxMouseEvent& event)
   event.Skip();
 }
 
+void wxCDMAppliDescriptionPanel::OnCMakeMouseEnter(wxMouseEvent& event)
+{
+  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
+
+  if(this->appli->GetCMakeLists() != NULL)
+    {
+      int CMId = this->appli->GetCMakeLists()->GetId();
+      newEvent->SetInt(CMId);
+      newEvent->SetId(0);
+      wxPostEvent(this->GetParent(), *newEvent);
+    }
+  event.Skip();
+}
+
+void wxCDMAppliDescriptionPanel::OnCMakeMouseExit(wxMouseEvent& event)
+{
+  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
+
+  if(this->appli->GetCMakeLists() != NULL)
+    {
+      int CMId = this->appli->GetCMakeLists()->GetId();
+      newEvent->SetInt(CMId);
+      newEvent->SetId(0);
+      wxPostEvent(this->GetParent(), *newEvent);
+    }
+  event.Skip();
+}
index dd44456982363cba4781792063b91f0186077a18..6e350a02c9fde28b05d10c39257c826da444cfe8 100644 (file)
@@ -82,6 +82,8 @@ protected:
 
   void OnMouseEnter(wxMouseEvent& event);
   void OnMouseExit(wxMouseEvent& event);
+  void OnCMakeMouseEnter(wxMouseEvent& event);
+  void OnCMakeMouseExit(wxMouseEvent& event);
 
 };
 
index 524e64f5ecb4ed95a03e56c6c2e6aa52816550d2..d31f2b2ba51f399fdd306e3d6e8588085510ecfd 100644 (file)
@@ -129,6 +129,8 @@ void wxCDMLibDescriptionPanel::CreateControls()
   actionsPanelSizer->Add(createLibrarybt, 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 Lib's CMakeLists.txt file."));
+  editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibDescriptionPanel::OnCMakeMouseEnter,NULL,this);
+  editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibDescriptionPanel::OnCMakeMouseExit,NULL,this);
   actionsPanelSizer->Add(editCMakebt, 0, wxALL, 5);
   wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Libraries Folder"));
   openFolderbt->SetToolTip(wxT("Open the lib folder in the file explorer."));
@@ -182,6 +184,16 @@ void wxCDMLibDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
   std::string* result;
   if(!this->lib->OpenCMakeListsFile(result))
     wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
+
+  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
+
+  if(this->lib->GetCMakeLists() != NULL)
+    {
+      int CMId = this->lib->GetCMakeLists()->GetId();
+      newEvent->SetInt(CMId);
+      newEvent->SetId(0);
+      wxPostEvent(this->GetParent(), *newEvent);
+    }
 }
 
 void wxCDMLibDescriptionPanel::OnLnkLibrarySelect(wxHyperlinkEvent& event)
@@ -263,3 +275,31 @@ void wxCDMLibDescriptionPanel::OnMouseExit(wxMouseEvent& event)
   wxPostEvent(this->GetParent(), *newEvent);
   event.Skip();
 }
+
+void wxCDMLibDescriptionPanel::OnCMakeMouseEnter(wxMouseEvent& event)
+{
+  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
+
+  if(this->lib->GetCMakeLists() != NULL)
+    {
+      int CMId = this->lib->GetCMakeLists()->GetId();
+      newEvent->SetInt(CMId);
+      newEvent->SetId(0);
+      wxPostEvent(this->GetParent(), *newEvent);
+    }
+  event.Skip();
+}
+
+void wxCDMLibDescriptionPanel::OnCMakeMouseExit(wxMouseEvent& event)
+{
+  wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
+
+  if(this->lib->GetCMakeLists() != NULL)
+    {
+      int CMId = this->lib->GetCMakeLists()->GetId();
+      newEvent->SetInt(CMId);
+      newEvent->SetId(0);
+      wxPostEvent(this->GetParent(), *newEvent);
+    }
+  event.Skip();
+}
index 17922decc8600fc127178906fc3a9b9035cf411e..bcf23ff1bde79b452d0ec5c55ad68227040dac54 100644 (file)
@@ -82,6 +82,8 @@ protected:
 
   void OnMouseEnter(wxMouseEvent& event);
   void OnMouseExit(wxMouseEvent& event);
+  void OnCMakeMouseEnter(wxMouseEvent& event);
+  void OnCMakeMouseExit(wxMouseEvent& event);
 
 };