]> 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 79c17ea..ce3388e 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 f239426..c37924d 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 73312b6..8122ebb 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 8676627..fb02b71 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 2403351..11b5f37 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 8f4fc74..47de063 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 390af69..e7bde23 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 dd44456..6e350a0 100644 (file)
@@ -82,6 +82,8 @@ protected:
 
   void OnMouseEnter(wxMouseEvent& event);
   void OnMouseExit(wxMouseEvent& event);
+  void OnCMakeMouseEnter(wxMouseEvent& event);
+  void OnCMakeMouseExit(wxMouseEvent& event);
 
 };
 
index 524e64f..d31f2b2 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 17922de..bcf23ff 100644 (file)
@@ -82,6 +82,8 @@ protected:
 
   void OnMouseEnter(wxMouseEvent& event);
   void OnMouseExit(wxMouseEvent& event);
+  void OnCMakeMouseEnter(wxMouseEvent& event);
+  void OnCMakeMouseExit(wxMouseEvent& event);
 
 };