]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp
Black Box view and folder structure implemented
[crea.git] / lib / creaDevManagerLib / wxCDMPackageDescriptionPanel.cpp
index 99367d7eeb3487a1392295d71317439538e2d2d0..4411c9eeb5cc9963864c7c8e4090aa35b64cd413 100644 (file)
@@ -160,15 +160,21 @@ void wxCDMPackageDescriptionPanel::CreateControls()
   wxPanel* BBPanel = new wxPanel(this);
   wxBoxSizer* BBPanelSizer = new wxBoxSizer(wxVERTICAL);
 
-  std::vector<modelCDMBlackBox*> blackBoxes = this->package->GetBlackBoxes();
+
+  std::vector<modelCDMBlackBox*> blackBoxes = this->package->GetSrc()->GetBlackBoxes();
   for (int i = 0; i < blackBoxes.size(); i++)
     {
-      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);
+
+      if(blackBoxes[i] != NULL)
+        {
+
+          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);
+        }
     }
 
   BBPanel->SetSizer(BBPanelSizer);
@@ -265,7 +271,7 @@ void wxCDMPackageDescriptionPanel::OnBtnSetVersion(wxCommandEvent& event)
 
 void wxCDMPackageDescriptionPanel::OnBtnSetDescription(wxCommandEvent& event)
 {
-  //get author from user
+  //get description from user
   wxTextEntryDialog* descDlg = new wxTextEntryDialog(
       this,
       wxT("Edit the package description."),
@@ -277,7 +283,7 @@ void wxCDMPackageDescriptionPanel::OnBtnSetDescription(wxCommandEvent& event)
   if (descDlg->ShowModal() == wxID_OK)
     {
       std::string descriptionStr = crea::wx2std(descDlg->GetValue());
-      //check name
+      //check desc
       if(descriptionStr.size() > 0)
         {
           std::string* result;
@@ -292,19 +298,22 @@ void wxCDMPackageDescriptionPanel::OnBtnSetDescription(wxCommandEvent& event)
 void wxCDMPackageDescriptionPanel::OnLnkBlackBoxSelect(wxHyperlinkEvent& event)
 {
   int bbId = 0;
-  std::vector<modelCDMBlackBox*> bbs = this->package->GetBlackBoxes();
+  modelCDMBlackBox* bb;
+  std::vector<modelCDMBlackBox*> bbs = this->package->GetSrc()->GetBlackBoxes();
   for (int i = 0; i < bbs.size(); i++)
     {
       if(bbs[i]->GetName() == crea::wx2std(event.GetURL()))
         {
-          bbId = bbs[i]->GetId();
+          bbId = bbs[i]->GetHeaderFile()->GetId();
+          bb = bbs[i];
           break;
         }
     }
 
   wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
-  newEvent->SetInt(bbId);
-  newEvent->SetId(0);
+  newEvent->SetClientData(bb);
+  newEvent->SetId(1);
+  newEvent->SetString(wxT("blackbox"));
   wxPostEvent(this->GetParent(), *newEvent);
 
   wxCommandEvent* newEvent1 = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
@@ -351,13 +360,14 @@ 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();
+  std::vector<modelCDMBlackBox*> boxes = this->package->GetSrc()->GetBlackBoxes();
   for (int i = 0; i < boxes.size(); i++)
     {
       if(boxes[i]->GetName() == BBName)
         {
-          bbId = boxes[i]->GetId();
+          bbId = boxes[i]->GetHeaderFile()->GetId();
           break;
         }
     }
@@ -372,12 +382,12 @@ 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();
+  std::vector<modelCDMBlackBox*> boxes = this->package->GetSrc()->GetBlackBoxes();
   for (int i = 0; i < boxes.size(); i++)
     {
       if(boxes[i]->GetName() == BBName)
         {
-          bbId = boxes[i]->GetId();
+          bbId = boxes[i]->GetHeaderFile()->GetId();
           break;
         }
     }