]> Creatis software - crea.git/commitdiff
Feature #1711
authorDaniel Gonzalez <daniel@daniel.creatis>
Tue, 27 Nov 2012 15:22:32 +0000 (16:22 +0100)
committerDaniel Gonzalez <daniel@daniel.creatis>
Tue, 27 Nov 2012 15:22:32 +0000 (16:22 +0100)
CreaDevManager application implementation

Project description panel enabled when creating project or opening project

16 files changed:
lib/creaDevManagerLib/creaDevManagerIds.h
lib/creaDevManagerLib/modelCDMAppli.cpp
lib/creaDevManagerLib/modelCDMAppli.h
lib/creaDevManagerLib/modelCDMIProjectTreeNode.cpp
lib/creaDevManagerLib/modelCDMIProjectTreeNode.h
lib/creaDevManagerLib/modelCDMLib.cpp
lib/creaDevManagerLib/modelCDMLib.h
lib/creaDevManagerLib/modelCDMPackage.cpp
lib/creaDevManagerLib/modelCDMPackage.h
lib/creaDevManagerLib/modelCDMProject.cpp
lib/creaDevManagerLib/wxCDMMainDescriptionPanel.cpp
lib/creaDevManagerLib/wxCDMMainDescriptionPanel.h
lib/creaDevManagerLib/wxCDMMainFrame.cpp
lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.cpp
lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.h
lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.cxx

index d6310802f0da379d94e8aa9c54a7fba546f1971d..916f5da6fa832caf3463b75bf6d20c913fa470fd 100644 (file)
 #define ID_BUTTON_NEWPROJECT            10303
 #define ID_BUTTON_OPENPROJECT           10304
 
+#define ID_BUTTON_CREATE_PACKAGE        10305
+#define ID_BUTTON_CREATE_BLACKBOX       10306
+#define ID_BUTTON_CREATE_LIBRARY        10307
+#define ID_BUTTON_CREATE_APPLICATION    10308
+#define ID_BUTTON_EDIT_CMAKELISTSFILE   10309
+
 #endif /* CREADEVMANAGERIDS_H_ */
index 002a38e5c9b0646b155cbec02688e59075743103..c0f37744cc76213b068fe8e8b11886afbaf1d1d4 100644 (file)
 
 #include "modelCDMAppli.h"
 
+#include "creaWx.h"
+#include "wx/dir.h"
+
 modelCDMAppli::modelCDMAppli()
 {
 }
 
+modelCDMAppli::modelCDMAppli(const std::string& path, const int& level)
+{
+  this->type = wxDIR_DIRS;
+  this->name = "appli";
+  this->level = level;
+  this->path = path;
+}
+
 modelCDMAppli::~modelCDMAppli()
 {
 }
index 00f4d663e985ca9bede8055a68165622a80f1a95..b97c0126381a0d525abca349409903ee965fbe6d 100644 (file)
@@ -45,6 +45,7 @@ class modelCDMAppli : public modelCDMIProjectTreeNode
 {
 public:
   modelCDMAppli();
+  modelCDMAppli(const std::string& path, const int& level = 1);
   ~modelCDMAppli();
 
   bool CreateApplication(
index 8026b415476857f0e2ca9472ea6580aa7e628c46..b444af28d2f8bf922a0e9aa510f158c7a1a9abdd 100644 (file)
  *      Author: Daniel Felipe Gonzalez Obando
  */
 #include "modelCDMIProjectTreeNode.h"
+#include <algorithm>
 
-bool modelCDMIProjectTreeNode::CompareNodeItem(const modelCDMIProjectTreeNode& x, const modelCDMIProjectTreeNode& y)
+bool modelCDMIProjectTreeNode::CompareNodeItem(const modelCDMIProjectTreeNode* x, const modelCDMIProjectTreeNode* y)
 {
   bool returnValue;
   bool noWinner = true;
   unsigned int i = 0;
-  std::string xName = x.GetName();
-  std::string yName = y.GetName();
-  unsigned char xType = x.GetType();
-  unsigned char yType = y.GetType();
+  std::string xName = x->GetName();
+  std::string yName = y->GetName();
+  unsigned char xType = x->GetType();
+  unsigned char yType = y->GetType();
 
   while ((i < xName.length()) && (i < yName.length()))
   {
@@ -114,6 +115,11 @@ void modelCDMIProjectTreeNode::SetId(const wxTreeItemId& id)
   this->id = id;
 }
 
+void modelCDMIProjectTreeNode::SortChildren()
+{
+  std::sort(this->children.begin(), this->children.end(), CompareNodeItem);
+}
+
 void modelCDMIProjectTreeNode::SetChildren(
     const std::vector<modelCDMIProjectTreeNode*>& children)
 {
index b74c6f11ccdbac6baaf6c19683f3ec73ff418df5..c07986df1efe5e156447aae8a3c173423dc643d4 100644 (file)
@@ -45,7 +45,7 @@ class modelCDMIProjectTreeNode
 public:
   virtual ~modelCDMIProjectTreeNode() {}
 
-  static bool CompareNodeItem(const modelCDMIProjectTreeNode& x, const modelCDMIProjectTreeNode& y);
+  static bool CompareNodeItem(const modelCDMIProjectTreeNode* x, const modelCDMIProjectTreeNode* y);
 
   const wxTreeItemId& GetId() const;
   const std::string& GetPath() const;
@@ -54,6 +54,7 @@ public:
   const int& GetLevel() const;
   const std::vector<modelCDMIProjectTreeNode*>& GetChildren() const;
   void SetId(const wxTreeItemId& id);
+  void SortChildren();
   void SetChildren(const std::vector<modelCDMIProjectTreeNode*>& children);
 
   virtual const bool Refresh(std::string*& result);
index e8a4ac9b45270d602f0043e919aff5fded02c1ef..2324eb9148f0a706992f23a825daaaf70567a7cf 100644 (file)
 
 #include "modelCDMLib.h"
 
+#include "creaWx.h"
+#include "wx/dir.h"
+
 modelCDMLib::modelCDMLib()
 {
 }
 
+modelCDMLib::modelCDMLib(const std::string& path, const int& level)
+{
+  this->type = wxDIR_DIRS;
+  this->name = "lib";
+  this->level = level;
+  this->path = path;
+}
+
 modelCDMLib::~modelCDMLib()
 {
 }
index 2a7e16459b265953eef96c0c8c7b3cff77e76285..f93752e130eca87fe952ecf808e8891e04cb4199 100644 (file)
@@ -45,6 +45,7 @@ class modelCDMLib : public modelCDMIProjectTreeNode
 {
 public:
   modelCDMLib();
+  modelCDMLib(const std::string& path, const int& level = 1);
   ~modelCDMLib();
 
   bool CreateLibrary(
index 8d33e17c72b2c742c53838dee3ea39bf6073ac45..490236779924622750ab1c760d6351977c70b233 100644 (file)
 
 #include "modelCDMPackage.h"
 
+#include "creaWx.h"
+#include "wx/dir.h"
+
 modelCDMPackage::modelCDMPackage()
 {
 }
 
+modelCDMPackage::modelCDMPackage(const std::string& path, const int& level)
+{
+  this->type = wxDIR_DIRS;
+  //TODO: Get Package Name
+  this->name = "Package";
+  this->namePackage = this->name;
+  this->level = level;
+  this->path = path;
+}
+
 modelCDMPackage::~modelCDMPackage()
 {
 }
 
-const std::string& modelCDMPackage::GetName() const
+const std::string& modelCDMPackage::GetNamePackage() const
 {
-  return this->name;
+  return this->namePackage;
 }
 
 const std::string& modelCDMPackage::GetAuthors() const
index 5af92109b50611d289ab2c1f78c324c75633565a..a644aae99b3c35ce788fadd1efbbe71a3035517c 100644 (file)
@@ -45,9 +45,10 @@ class modelCDMPackage : public modelCDMIProjectTreeNode
 {
 public:
   modelCDMPackage();
+  modelCDMPackage(const std::string& path, const int& level = 1);
   ~modelCDMPackage();
 
-  const std::string& GetName() const;
+  const std::string& GetNamePackage() const;
   const std::string& GetAuthors() const;
   const std::string& GetAuthorsEmail() const;
   const std::string& GetVersion() const;
@@ -70,7 +71,7 @@ public:
   virtual const bool Refresh(std::string*& result);
 
 private:
-  std::string name;
+  std::string namePackage;
   std::string authors;
   std::string authorsEmail;
   std::string version;
index 25bba8d0b34c3838c5cea47dcc8b342cb93a8807..3966c7ccaac195eb1eec7f51519cb26eee57329d 100644 (file)
@@ -140,10 +140,45 @@ modelCDMProject::modelCDMProject(
   //TODO: implement method
   //if appli exist create Appli
   this->appli = NULL;
+  wxDir dir(crea::std2wx((pathFixed + "/appli").c_str()));
+  if (dir.IsOpened())
+    {
+      this->appli = new modelCDMAppli(pathFixed + "/appli", this->level + 1);
+      this->children.push_back(this->appli);
+    }
+
   //if lib exist create Lib
   this->lib = NULL;
+  dir.Open(crea::std2wx((pathFixed + "/lib").c_str()));
+  if (dir.IsOpened())
+    {
+      this->lib = new modelCDMLib(pathFixed + "/lib", this->level + 1);
+      this->children.push_back(this->lib);
+    }
+
   //if bbtk_* exist create Packages
+  this->packages.clear();
+  dir.Open(crea::std2wx((pathFixed).c_str()));
+  if (dir.IsOpened())
+    {
+      wxString fileName;
+      bool cont = dir.GetFirst(&fileName, wxEmptyString, wxDIR_DIRS);
+      while (cont)
+        {
+          std::string stdfileName = crea::wx2std(fileName);
+
+          if(stdfileName.size() > 9 && stdfileName.substr(0,5) == "bbtk_" && stdfileName.substr(stdfileName.size()-4,4) == "_PKG")
+            {
+              modelCDMPackage* package = new modelCDMPackage(pathFixed + "/" + stdfileName, this->level + 1);
+              this->packages.push_back(package);
+              this->children.push_back(package);
+            }
 
+          cont = dir.GetNext(&fileName);
+        }
+
+    }
+  this->SortChildren();
 
 }
 
index e50abba8d423605035c6d4040259cd4eac2654cc..aecfaaa883db87dd7ea7e0628dce4f33c7661df1 100644 (file)
  */
 
 #include "wxCDMMainDescriptionPanel.h"
+
 #include "creaDevManagerIds.h"
 #include "images/Cicon64.xpm"
 
+BEGIN_EVENT_TABLE(wxCDMMainDescriptionPanel, wxPanel)
+EVT_MENU(ID_MENU_NEW_PROJECT, wxCDMMainDescriptionPanel::OnBtnNewProject)
+EVT_MENU(ID_MENU_OPEN_PROJECT, wxCDMMainDescriptionPanel::OnBtnOpenProject)
+END_EVENT_TABLE()
 
 wxCDMMainDescriptionPanel::wxCDMMainDescriptionPanel(
     wxWindow* parent,
index e2efa88ee26f6334f6f75ea99c3d26151052fdd0..0e384fd0b627f6e62f483dff22763902ee91f1fe 100644 (file)
@@ -41,6 +41,8 @@
 
 class wxCDMMainDescriptionPanel : public wxPanel
 {
+  DECLARE_EVENT_TABLE()
+
 public:
     wxCDMMainDescriptionPanel(
         wxWindow* parent,
index 775cfc75938dad5e5ee90cd1a3b63eed99d0cac0..8050bf924cf503f16d221e46d58830d9bf224fc5 100755 (executable)
@@ -36,6 +36,7 @@
 
 #include "creaDevManagerIds.h"
 #include "wxCDMMainDescriptionPanel.h"
+#include "wxCDMProjectDescriptionPanel.h"
 #include "wxCDMProjectActionsPanel.h"
 #include "wxCDMNewProjectDialog.h"
 
@@ -205,7 +206,6 @@ void wxCDMMainFrame::CreateControls()
 
   auiManager.Update();
   auiManager.GetPane(tree_Projects).CloseButton(false).MaximizeButton(true);
-  auiManager.GetPane(panel_Properties).CloseButton(false);
 }
 
 //Event Handlers
@@ -236,7 +236,20 @@ void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event)
       //populate tree control
       tree_Projects->BuildTree(this->model->GetProject());
       tree_Projects->SelectItem(this->model->GetProject()->GetId());
-      //TODO: change description panel
+
+      //change description panel
+      auiManager.DetachPane(this->panel_Properties);
+      this->panel_Properties->Destroy();
+      this->panel_Properties = new wxCDMProjectDescriptionPanel(
+          this,
+          this->model->GetProject(),
+          ID_WINDOW_PROPERTIES,
+          wxT("Description Panel"),
+          wxDefaultPosition,
+          wxSize(300, 400),
+          0);
+      auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
+
       //TODO: change project's actions panel
       auiManager.Update();
 
@@ -269,6 +282,22 @@ void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event)
       //populate tree control
       tree_Projects->BuildTree(this->model->GetProject());
       tree_Projects->SelectItem(this->model->GetProject()->GetId());
+
+      //change description panel
+      auiManager.DetachPane(this->panel_Properties);
+      this->panel_Properties->Destroy();
+      this->panel_Properties = new wxCDMProjectDescriptionPanel(
+          this,
+          this->model->GetProject(),
+          ID_WINDOW_PROPERTIES,
+          wxT("Description Panel"),
+          wxDefaultPosition,
+          wxSize(300, 400),
+          0);
+
+      auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
+
+      //TODO: change project's actions panel
       auiManager.Update();
     }
 
@@ -286,6 +315,8 @@ void wxCDMMainFrame::OnMenuCloseProject(wxCommandEvent& event)
     {
       wxMessageBox( crea::std2wx(result->c_str()), wxT("Close Project - Error"), wxICON_ERROR);
     }
+  tree_Projects->BuildTree(this->model->GetProject());
+  auiManager.Update();
   event.Skip();
 }
 void wxCDMMainFrame::OnMenuCloseAllProjects(wxCommandEvent& event)
index 0fadfeb7911e0c0e547af9692ad50136ee0fdfcd..ff5d01bbdb5827238ca940e4a890e47cb07ea00c 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.
 # ------------------------------------------------------------------------
-*/
+ */
 
 /*
  * wxCDMProjectDescriptionPanel.cpp
 
 #include "wxCDMProjectDescriptionPanel.h"
 
+#include "creaDevManagerIds.h"
+#include "images/Cicon64.xpm"
+
+BEGIN_EVENT_TABLE(wxCDMProjectDescriptionPanel, wxPanel)
+EVT_MENU(ID_BUTTON_CREATE_PACKAGE, wxCDMProjectDescriptionPanel::OnBtnCreatePackage)
+EVT_MENU(ID_BUTTON_CREATE_BLACKBOX, wxCDMProjectDescriptionPanel::OnBtnCreateBlackBox)
+EVT_MENU(ID_BUTTON_CREATE_LIBRARY, wxCDMProjectDescriptionPanel::OnBtnCreateLibrary)
+EVT_MENU(ID_BUTTON_CREATE_APPLICATION, wxCDMProjectDescriptionPanel::OnBtnCreateApplication)
+EVT_MENU(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists)
+END_EVENT_TABLE()
+
 wxCDMProjectDescriptionPanel::wxCDMProjectDescriptionPanel(
     wxWindow* parent,
+    modelCDMProject* project,
     wxWindowID id,
-    const wxString&
-    caption,
+    const wxString& caption,
     const wxPoint& pos,
     const wxSize& size,
     long style
 )
 {
+  wxCDMProjectDescriptionPanel::Create(parent, project, id, caption, pos, size, style);
 }
 
 wxCDMProjectDescriptionPanel::~wxCDMProjectDescriptionPanel()
@@ -52,6 +64,7 @@ wxCDMProjectDescriptionPanel::~wxCDMProjectDescriptionPanel()
 
 bool wxCDMProjectDescriptionPanel::Create(
     wxWindow* parent,
+    modelCDMProject* project,
     wxWindowID id,
     const wxString& caption,
     const wxPoint& pos,
@@ -59,8 +72,103 @@ bool wxCDMProjectDescriptionPanel::Create(
     long style
 )
 {
+  wxPanel::Create(parent, id, pos, size, style);
+  this->project = project;
+  CreateControls();
+  return TRUE;
 }
 
 void wxCDMProjectDescriptionPanel::CreateControls()
 {
+  wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
+
+  //Welcome
+  sizer->Add(new wxStaticText(this, -1, _("Project")),0, wxALIGN_CENTER, 0);
+
+  //Image
+  sizer->Add(new wxStaticBitmap(this, -1, wxBitmap(Cicon)),0, wxALIGN_CENTER, 0);
+
+  //Project Name
+  sizer->Add(new wxStaticText(this, -1, crea::std2wx(this->project->GetName())),0, wxALIGN_CENTER, 0);
+
+  //Project Properties
+  wxStaticBox* propertiesBox = new wxStaticBox(this, -1, _T("&Properties"));
+  wxStaticBoxSizer* propertiesBoxInnerSizer = new wxStaticBoxSizer(propertiesBox, wxHORIZONTAL);
+  sizer -> Add(propertiesBoxInnerSizer, 1, wxEXPAND | wxALL, 20);
+
+  wxFlexGridSizer* flexGridSizer = new wxFlexGridSizer(4, 2, 9, 15);
+  propertiesBoxInnerSizer -> Add(flexGridSizer, 1, wxEXPAND | wxALL);
+
+  wxStaticText *pVersion = new wxStaticText(this, -1, wxT("Version"));
+  wxStaticText *pVersionDate = new wxStaticText(this, -1, wxT("Version Date"));
+  wxStaticText *pSourceLocation = new wxStaticText(this, -1, wxT("Source Location"));
+  wxStaticText *pBuildLocation = new wxStaticText(this, -1, wxT("Build Location"));
+
+  wxTextCtrl *pVersiontc = new wxTextCtrl(this, -1, crea::std2wx(this->project->GetVersion()));
+  wxTextCtrl *pVersionDatetc = new wxTextCtrl(this, -1, crea::std2wx(this->project->GetVersionDate()));
+  wxTextCtrl *pSourceLocationtc = new wxTextCtrl(this, -1, crea::std2wx(this->project->GetPath()));
+  wxTextCtrl *pBuildLocationtc = new wxTextCtrl(this, -1, crea::std2wx(this->project->GetBuildPath()));
+
+  flexGridSizer->Add(pVersion, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
+  flexGridSizer->Add(pVersiontc, 1, wxEXPAND);
+  flexGridSizer->Add(pVersionDate, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
+  flexGridSizer->Add(pVersionDatetc, 1, wxEXPAND);
+  flexGridSizer->Add(pSourceLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
+  flexGridSizer->Add(pSourceLocationtc, 1, wxEXPAND);
+  flexGridSizer->Add(pBuildLocation, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
+  flexGridSizer->Add(pBuildLocationtc, 1, wxEXPAND);
+
+  flexGridSizer->SetSizeHints(this);
+
+  //Actions
+  wxStaticBox* actionsBox = new wxStaticBox(this, -1, _T("&Actions"));
+  wxStaticBoxSizer* actionsBoxInnerSizer = new wxStaticBoxSizer(actionsBox, wxVERTICAL);
+  sizer -> Add(actionsBoxInnerSizer, 1, wxEXPAND | wxALL, 20);
+
+  actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_CREATE_PACKAGE, _T("Create Package")), 0, wxRIGHT | wxLEFT, 20);
+  actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_CREATE_BLACKBOX, _T("Create Black Box")), 0, wxRIGHT | wxLEFT, 20);
+  actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_CREATE_LIBRARY, _T("Create Library")), 0, wxRIGHT | wxLEFT, 20);
+  actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_CREATE_APPLICATION, _T("Create Application")), 0, wxRIGHT | wxLEFT, 20);
+
+  actionsBoxInnerSizer->Add(new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File")), 0, wxRIGHT | wxLEFT, 20);
+
+  //Asign sizer
+  actionsBoxInnerSizer->SetSizeHints(this);
+  sizer->SetSizeHints(this);
+  SetSizer(sizer);
+}
+
+void wxCDMProjectDescriptionPanel::OnBtnCreatePackage(wxCommandEvent& event)
+{
+  //TODO: implement method
+  std::cerr << "Event OnBtnCreatePackage not implemented" << std::endl;
+  event.Skip();
+}
+
+void wxCDMProjectDescriptionPanel::OnBtnCreateBlackBox(wxCommandEvent& event)
+{
+  //TODO: implement method
+  std::cerr << "Event OnBtnCreatePackage not implemented" << std::endl;
+  event.Skip();
+}
+
+void wxCDMProjectDescriptionPanel::OnBtnCreateLibrary(wxCommandEvent& event)
+{
+  //TODO: implement method
+  std::cerr << "Event OnBtnCreatePackage not implemented" << std::endl;
+  event.Skip();
+}
+
+void wxCDMProjectDescriptionPanel::OnBtnCreateApplication(wxCommandEvent& event)
+{
+  //TODO: implement method
+  std::cerr << "Event OnBtnCreatePackage not implemented" << std::endl;
+  event.Skip();
+}
+
+void wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
+{
+  //TODO: implement method
+  std::cerr << "Event OnBtnCreatePackage not implemented" << std::endl;
+  event.Skip();
 }
index e91dca0099475c97a27c1c6c9a596c4c1f1eea49..85aed83653887819bd0b39b391e8a1ced24a266c 100644 (file)
 #include <creaWx.h>
 #include <wx/panel.h>
 
+#include "modelCDMProject.h"
+
 class wxCDMProjectDescriptionPanel : public wxPanel
 {
+  DECLARE_EVENT_TABLE()
 public:
   wxCDMProjectDescriptionPanel(
       wxWindow* parent,
+      modelCDMProject* project,
       wxWindowID id = -1,
       const wxString& caption = _("Description Frame"),
       const wxPoint& pos = wxDefaultPosition,
@@ -54,6 +58,7 @@ public:
 
   bool Create(
       wxWindow* parent,
+      modelCDMProject* project,
       wxWindowID id = -1,
       const wxString& caption = _("Description Frame"),
       const wxPoint& pos = wxDefaultPosition,
@@ -63,8 +68,17 @@ public:
 
   void CreateControls();
 
+private:
+  modelCDMProject* project;
+
   //handlers
 protected:
+  void OnBtnCreatePackage(wxCommandEvent& event);
+  void OnBtnCreateBlackBox(wxCommandEvent& event);
+  void OnBtnCreateLibrary(wxCommandEvent& event);
+  void OnBtnCreateApplication(wxCommandEvent& event);
+  void OnBtnEditCMakeLists(wxCommandEvent& event);
+
 };
 
 #endif /* WXCDMPROJECTDESCRIPTIONPANEL_H_ */
index 8337e48c35da386e7f1e4989a2936d166fbcf3b4..61bd7e7752de661ebbd72431474d1fe361b90946 100755 (executable)
@@ -65,16 +65,16 @@ bool wxCDMProjectsTreeCtrl::Create(
 )
 {
   wxTreeCtrl::Create (parent, id, pos, size, style, validator, name);
-  wxTreeItemId rootIndex = this-> AddRoot(_("Open Projects"));
+  wxTreeItemId rootIndex = this-> AddRoot(_("No Open Project"));
   this->Update();
   return TRUE;
 }
 
 void wxCDMProjectsTreeCtrl::BuildTree(modelCDMProject* projectTree)
 {
+  this->DeleteAllItems();
   if(projectTree != NULL)
     {
-      this->DeleteAllItems();
       wxTreeItemId rootIndex;
       rootIndex= this-> AddRoot(crea::std2wx(projectTree->GetName()));
       projectTree->SetId(rootIndex);
@@ -86,6 +86,10 @@ void wxCDMProjectsTreeCtrl::BuildTree(modelCDMProject* projectTree)
 
       this->Update();
     }
+  else
+    {
+      wxTreeItemId rootIndex = this-> AddRoot(_("No Open Project"));
+    }
 }
 
 void wxCDMProjectsTreeCtrl::BuildTree(const std::vector<modelCDMIProjectTreeNode*>& treeNodes, wxTreeItemId parent)