]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/wxCDMMainFrame.cpp
Feature #1711
[crea.git] / lib / creaDevManagerLib / wxCDMMainFrame.cpp
index 355b284191e268e7ea45438b5e878e6d9f016c58..acda55d9ffcfef2276ad4e62f1bc0dae8ffcad73 100755 (executable)
@@ -516,6 +516,8 @@ void wxCDMMainFrame::OnMenuRefreshProject(wxCommandEvent& event)
     {
       wxMessageBox( crea::std2wx(result->c_str()), wxT("Refresh Project - Error"), wxICON_ERROR);
     }
+  this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
+  this->auiManager.Update();
   //TODO: Show possible problems in CMakeLists files
   event.Skip();
 }
@@ -612,11 +614,11 @@ void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
   //TODO get element type
   //project
   modelCDMProject* elementProject = dynamic_cast<modelCDMProject*>(element);
+  wxPanel* description;
   if(elementProject != NULL)
     {
-
       //create element description
-      wxCDMProjectDescriptionPanel* description = new wxCDMProjectDescriptionPanel(
+      description = new wxCDMProjectDescriptionPanel(
           this,
           elementProject,
           ID_WINDOW_PROPERTIES,
@@ -625,291 +627,185 @@ void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
           wxSize(300, 400),
           0
       );
-      //delete old view
-      if(this->panel_Properties!= NULL)
-        {
-          this->panel_Properties->Hide();
-          this->panel_Properties->Destroy();
-          auiManager.DetachPane(this->panel_Properties);
-        }
-      //set new view
-      this->panel_Properties = description;
-      auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
-      auiManager.Update();
-      event.Skip();
-      return;
-    }
-  //appli
-  modelCDMAppli* elementAppli = dynamic_cast<modelCDMAppli*>(element);
-  if(elementAppli != NULL)
-    {
-      //create element description
-      wxCDMAppliDescriptionPanel* description = new wxCDMAppliDescriptionPanel(
-          this,
-          elementAppli,
-          ID_WINDOW_PROPERTIES,
-          wxT("Description Panel"),
-          wxDefaultPosition,
-          wxSize(300, 400),
-          0
-      );
-      //delete old view
-      if(this->panel_Properties!= NULL)
-        {
-          this->panel_Properties->Hide();
-          this->panel_Properties->Destroy();
-          auiManager.DetachPane(this->panel_Properties);
-        }
-      //set new view
-      this->panel_Properties = description;
-      auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
-      auiManager.Update();
-      event.Skip();
-      return;
-    }
-  //application
-  modelCDMApplication* elementApplication = dynamic_cast<modelCDMApplication*>(element);
-  if(elementApplication != NULL)
-    {
-      //create element description
-      wxCDMApplicationDescriptionPanel* description = new wxCDMApplicationDescriptionPanel(
-          this,
-          elementApplication,
-          ID_WINDOW_PROPERTIES,
-          wxT("Description Panel"),
-          wxDefaultPosition,
-          wxSize(300, 400),
-          0
-      );
-      //delete old view
-      if(this->panel_Properties!= NULL)
-        {
-          this->panel_Properties->Hide();
-          this->panel_Properties->Destroy();
-          auiManager.DetachPane(this->panel_Properties);
-
-        }
-      //set new view
-      this->panel_Properties = description;
-      auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
-      auiManager.Update();
-      event.Skip();
-      return;
-    }
-  //lib
-  modelCDMLib* elementLib = dynamic_cast<modelCDMLib*>(element);
-  if(elementLib != NULL)
-    {
-      //create element description
-      wxCDMLibDescriptionPanel* description = new wxCDMLibDescriptionPanel(
-          this,
-          elementLib,
-          ID_WINDOW_PROPERTIES,
-          wxT("Description Panel"),
-          wxDefaultPosition,
-          wxSize(300, 400),
-          0
-      );
-      //delete old view
-      if(this->panel_Properties!= NULL)
-        {
-          this->panel_Properties->Hide();
-          this->panel_Properties->Destroy();
-          auiManager.DetachPane(this->panel_Properties);
-
-        }
-      //set new view
-      this->panel_Properties = description;
-      auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
-      auiManager.Update();
-      event.Skip();
-      return;
-    }
-  //library
-  modelCDMLibrary* elementLibrary = dynamic_cast<modelCDMLibrary*>(element);
-  if(elementLibrary != NULL)
-    {
-      //create element description
-      wxCDMLibraryDescriptionPanel* description = new wxCDMLibraryDescriptionPanel(
-          this,
-          elementLibrary,
-          ID_WINDOW_PROPERTIES,
-          wxT("Description Panel"),
-          wxDefaultPosition,
-          wxSize(300, 400),
-          0
-      );
-      //delete old view
-      if(this->panel_Properties!= NULL)
-        {
-          auiManager.DetachPane(this->panel_Properties);
-          this->panel_Properties->Hide();
-          this->panel_Properties->Destroy();
-        }
-
-      //set new view
-      this->panel_Properties = description;
-      auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
-      auiManager.Update();
-      event.Skip();
-      return;
-    }
-  //package
-  modelCDMPackage* elementPackage = dynamic_cast<modelCDMPackage*>(element);
-  if(elementPackage != NULL)
-    {
-      //create element description
-      wxCDMPackageDescriptionPanel* description = new wxCDMPackageDescriptionPanel(
-          this,
-          elementPackage,
-          ID_WINDOW_PROPERTIES,
-          wxT("Description Panel"),
-          wxDefaultPosition,
-          wxSize(300, 400),
-          0
-      );
-      //delete old view
-      if(this->panel_Properties!= NULL)
-        {
-          this->panel_Properties->Hide();
-          this->panel_Properties->Destroy();
-          auiManager.DetachPane(this->panel_Properties);
 
-        }
-      //set new view
-      this->panel_Properties = description;
-      auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
-      auiManager.Update();
-      event.Skip();
-      return;
     }
-  //black box
-  modelCDMBlackBox* elementBlackBox = dynamic_cast<modelCDMBlackBox*>(element);
-  if(elementBlackBox != NULL)
+  else
     {
-      //create element description
-      wxCDMBlackBoxDescriptionPanel* description = new wxCDMBlackBoxDescriptionPanel(
-          this,
-          elementBlackBox,
-          ID_WINDOW_PROPERTIES,
-          wxT("Description Panel"),
-          wxDefaultPosition,
-          wxSize(300, 400),
-          0
-      );
-      //delete old view
-      if(this->panel_Properties!= NULL)
+      //appli
+      modelCDMAppli* elementAppli = dynamic_cast<modelCDMAppli*>(element);
+      if(elementAppli != NULL)
         {
-          this->panel_Properties->Hide();
-          this->panel_Properties->Destroy();
-          auiManager.DetachPane(this->panel_Properties);
-
+          //create element description
+          description = new wxCDMAppliDescriptionPanel(
+              this,
+              elementAppli,
+              ID_WINDOW_PROPERTIES,
+              wxT("Description Panel"),
+              wxDefaultPosition,
+              wxSize(300, 400),
+              0
+          );
         }
-      //set new view
-      this->panel_Properties = description;
-      auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
-      auiManager.Update();
-      event.Skip();
-      return;
-    }
-  //CMakeLists
-  modelCDMCMakeListsFile* elementCMakeLists = dynamic_cast<modelCDMCMakeListsFile*>(element);
-  if(elementCMakeLists != NULL)
-    {
-      //create element description
-      wxCDMCMakeListsDescriptionPanel* description = new wxCDMCMakeListsDescriptionPanel(
-          this,
-          elementCMakeLists,
-          ID_WINDOW_PROPERTIES,
-          wxT("Description Panel"),
-          wxDefaultPosition,
-          wxSize(300, 400),
-          0
-      );
-      //delete old view
-      if(this->panel_Properties!= NULL)
+      else
         {
-          this->panel_Properties->Hide();
-          this->panel_Properties->Destroy();
-          auiManager.DetachPane(this->panel_Properties);
-
-        }
-      //set new view
-      this->panel_Properties = description;
-      auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
-      auiManager.Update();
-      event.Skip();
-      return;
-    }
-  //folder
-  modelCDMFolder* elementFolder = dynamic_cast<modelCDMFolder*>(element);
-  if(elementFolder != NULL)
-    {
-      //create element description
-      wxCDMFolderDescriptionPanel* description = new wxCDMFolderDescriptionPanel(
-          this,
-          elementFolder,
-          ID_WINDOW_PROPERTIES,
-          wxT("Description Panel"),
-          wxDefaultPosition,
-          wxSize(300, 400),
-          0
-      );
-      //delete old view
-      if(this->panel_Properties!= NULL)
-        {
-          this->panel_Properties->Hide();
-          this->panel_Properties->Destroy();
-          auiManager.DetachPane(this->panel_Properties);
-
-        }
-      //set new view
-      this->panel_Properties = description;
-      auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
-      auiManager.Update();
-      event.Skip();
-      return;
-    }
-  //TODO: file
-  modelCDMFile* elementFile = dynamic_cast<modelCDMFile*>(element);
-  if(elementFile != NULL)
-    {
-      //create element description
-      wxCDMFileDescriptionPanel* description = new wxCDMFileDescriptionPanel(
-          this,
-          elementFile,
-          ID_WINDOW_PROPERTIES,
-          wxT("Description Panel"),
-          wxDefaultPosition,
-          wxSize(300, 400),
-          0
-      );
-      //delete old view
-      if(this->panel_Properties!= NULL)
-        {
-          this->panel_Properties->Hide();
-          this->panel_Properties->Destroy();
-          auiManager.DetachPane(this->panel_Properties);
-
+          //application
+          modelCDMApplication* elementApplication = dynamic_cast<modelCDMApplication*>(element);
+          if(elementApplication != NULL)
+            {
+              //create element description
+              description = new wxCDMApplicationDescriptionPanel(
+                  this,
+                  elementApplication,
+                  ID_WINDOW_PROPERTIES,
+                  wxT("Description Panel"),
+                  wxDefaultPosition,
+                  wxSize(300, 400),
+                  0
+              );
+            }
+          else
+            {
+              //lib
+              modelCDMLib* elementLib = dynamic_cast<modelCDMLib*>(element);
+              if(elementLib != NULL)
+                {
+                  //create element description
+                  description = new wxCDMLibDescriptionPanel(
+                      this,
+                      elementLib,
+                      ID_WINDOW_PROPERTIES,
+                      wxT("Description Panel"),
+                      wxDefaultPosition,
+                      wxSize(300, 400),
+                      0
+                  );
+                }
+              else
+                {
+                  //library
+                  modelCDMLibrary* elementLibrary = dynamic_cast<modelCDMLibrary*>(element);
+                  if(elementLibrary != NULL)
+                    {
+                      //create element description
+                      description = new wxCDMLibraryDescriptionPanel(
+                          this,
+                          elementLibrary,
+                          ID_WINDOW_PROPERTIES,
+                          wxT("Description Panel"),
+                          wxDefaultPosition,
+                          wxSize(300, 400),
+                          0
+                      );
+                    }
+                  else
+                    {
+                      //package
+                      modelCDMPackage* elementPackage = dynamic_cast<modelCDMPackage*>(element);
+                      if(elementPackage != NULL)
+                        {
+                          //create element description
+                          description = new wxCDMPackageDescriptionPanel(
+                              this,
+                              elementPackage,
+                              ID_WINDOW_PROPERTIES,
+                              wxT("Description Panel"),
+                              wxDefaultPosition,
+                              wxSize(300, 400),
+                              0
+                          );
+                        }
+                      else
+                        {
+                          //black box
+                          modelCDMBlackBox* elementBlackBox = dynamic_cast<modelCDMBlackBox*>(element);
+                          if(elementBlackBox != NULL)
+                            {
+                              //create element description
+                              description = new wxCDMBlackBoxDescriptionPanel(
+                                  this,
+                                  elementBlackBox,
+                                  ID_WINDOW_PROPERTIES,
+                                  wxT("Description Panel"),
+                                  wxDefaultPosition,
+                                  wxSize(300, 400),
+                                  0
+                              );
+                            }
+                          else
+                            {
+                              //CMakeLists
+                              modelCDMCMakeListsFile* elementCMakeLists = dynamic_cast<modelCDMCMakeListsFile*>(element);
+                              if(elementCMakeLists != NULL)
+                                {
+                                  //create element description
+                                  description = new wxCDMCMakeListsDescriptionPanel(
+                                      this,
+                                      elementCMakeLists,
+                                      ID_WINDOW_PROPERTIES,
+                                      wxT("Description Panel"),
+                                      wxDefaultPosition,
+                                      wxSize(300, 400),
+                                      0
+                                  );
+                                }
+                              else
+                                {
+                                  //folder
+                                  modelCDMFolder* elementFolder = dynamic_cast<modelCDMFolder*>(element);
+                                  if(elementFolder != NULL)
+                                    {
+                                      //create element description
+                                      description = new wxCDMFolderDescriptionPanel(
+                                          this,
+                                          elementFolder,
+                                          ID_WINDOW_PROPERTIES,
+                                          wxT("Description Panel"),
+                                          wxDefaultPosition,
+                                          wxSize(300, 400),
+                                          0
+                                      );
+                                    }
+                                  else
+                                    {
+                                      //file
+                                      modelCDMFile* elementFile = dynamic_cast<modelCDMFile*>(element);
+                                      if(elementFile != NULL)
+                                        {
+                                          //create element description
+                                          description = new wxCDMFileDescriptionPanel(
+                                              this,
+                                              elementFile,
+                                              ID_WINDOW_PROPERTIES,
+                                              wxT("Description Panel"),
+                                              wxDefaultPosition,
+                                              wxSize(300, 400),
+                                              0
+                                          );
+                                        }
+                                      else
+                                        {
+
+                                          //main if not any
+                                          //create element description
+                                          description = new wxCDMMainDescriptionPanel(
+                                              this,
+                                              ID_WINDOW_PROPERTIES,
+                                              wxT("Description Panel"),
+                                              wxDefaultPosition,
+                                              wxSize(300, 400),
+                                              0
+                                          );
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
         }
-      //set new view
-      this->panel_Properties = description;
-      auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
-      auiManager.Update();
-      event.Skip();
-      return;
     }
-
-  //main if not any
-  //create element description
-  wxCDMMainDescriptionPanel* description = new wxCDMMainDescriptionPanel(
-      this,
-      ID_WINDOW_PROPERTIES,
-      wxT("Description Panel"),
-      wxDefaultPosition,
-      wxSize(300, 400),
-      0
-  );
+  description->Hide();
   //delete old view
   if(this->panel_Properties!= NULL)
     {
@@ -919,9 +815,11 @@ void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
 
     }
   //set new view
+
   this->panel_Properties = description;
   auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
   auiManager.Update();
+  this->panel_Properties->Show(true);
   event.Skip();
   return;