]> Creatis software - crea.git/commitdiff
Feature #1711
authorDaniel Felipe Gonzalez <daniel.gonzalez@creatis.insa-lyon.fr>
Mon, 21 Jan 2013 18:33:23 +0000 (19:33 +0100)
committerDaniel Felipe Gonzalez <daniel.gonzalez@creatis.insa-lyon.fr>
Tue, 22 Jan 2013 15:54:35 +0000 (16:54 +0100)
CreaDevManager application implementation

- Changes for windows compatibility Application opens and creates projects. hangs when showing project properties.

appli/creaDevManager/creaDevManager.cpp
appli/creaDevManager/creaDevManager.h
lib/creaDevManagerLib/CDMUtilities.cpp
lib/creaDevManagerLib/CDMUtilities.h
lib/creaDevManagerLib/modelCDMMain.cpp
lib/creaDevManagerLib/modelCDMProjectsTree.cpp
lib/creaDevManagerLib/wxCDMMainFrame.cpp
lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.cxx

index 10eef03b1246185a7b67c780504771a9d0c34ed2..be7b25b9d0930a7dd21bc0e445a6b7ed5e457eb6 100644 (file)
@@ -28,7 +28,6 @@
 #include <stdlib.h>
 #include <iostream> // for std::cout
 #include "creaDevManager.h"
-#include "wxCDMMainFrame.h"
 
 IMPLEMENT_APP(wxCreaDevManagerApp)
 
@@ -39,12 +38,10 @@ wxCreaDevManagerApp::wxCreaDevManagerApp():wxApp()
 bool wxCreaDevManagerApp::OnInit()
 {
   wxApp::OnInit();
-  
-  wxCDMMainFrame* mainWindow = new wxCDMMainFrame(NULL);
+  mainWindow = new wxCDMMainFrame(NULL);
   SetTopWindow(mainWindow);
   mainWindow->SetSize(750, 700);
   mainWindow->Show(true);
-
   std::cout << "Crea DevManager opened." << std::endl;
   
   return true;
@@ -52,6 +49,7 @@ bool wxCreaDevManagerApp::OnInit()
 
 int wxCreaDevManagerApp::OnExit()
 {
+  mainWindow->Destroy();
   wxApp::OnExit();
   std::cout << "Crea DevManager closed." << std::endl;
   return 0;
index ca8e970508ab13e5b9ee0ad51527d4f94687049c..eaafbee36e9e57bbc8f3054cf04cc5b32620cbcc 100644 (file)
@@ -36,6 +36,8 @@
 #ifndef CREADEVMANAGER_H_
 #define CREADEVMANAGER_H_
 
+#include "wxCDMMainFrame.h"
+
 /**
  * Crea Development Manager
  * Developed by Daniel Felipe González Obando for CREATIS.
@@ -62,6 +64,9 @@ public:
    */
   virtual int OnExit();
 
+private:
+  wxCDMMainFrame* mainWindow;
+
 };
 DECLARE_APP(wxCreaDevManagerApp)
 
index defe3f82d8a4229b73f97faf434f6c64ad8ce74f..4d409542b221dfb2ae83a975d1d1ece393d412d2 100644 (file)
@@ -80,17 +80,27 @@ namespace CDMUtilities
 
 #if(_WIN32)
     // ------ Windows
-    //TODO: implementation for windows
+    std::vector<std::string> pathSplit;
+
+    splitter::split(pathSplit, path, CDMUtilities::SLASH, splitter::no_empties);
+
+       if(0 < pathSplit.size())
+               pathFixed = pathSplit[0];
+
+    for (int i = 1; i < pathSplit.size(); i++)
+      {
+        pathFixed += CDMUtilities::SLASH + pathSplit[i];
+      }
 #else
     // ------ LINUX / MacOS
     //break path into folders
-    std::vector<std::string> pathSlpit;
+    std::vector<std::string> pathSplit;
 
-    splitter::split(pathSlpit, path, CDMUtilities::SLASH, splitter::no_empties);
+    splitter::split(pathSplit, path, CDMUtilities::SLASH, splitter::no_empties);
 
-    for (int i = 0; i < pathSlpit.size(); i++)
+    for (int i = 0; i < pathSplit.size(); i++)
       {
-        pathFixed += CDMUtilities::SLASH + pathSlpit[i];
+        pathFixed += CDMUtilities::SLASH + pathSplit[i];
       }
 #endif
     return pathFixed;
index 4b18fcb2ec6e26e30e510bdc528fc3e5f3051aee..4236eb5faab832b8d8d97f6cebec59dbe7de344a 100644 (file)
@@ -58,7 +58,7 @@ namespace CDMUtilities
    */
 #ifdef _WIN32
   // ------ Windows
-  //TODO: implementation for windows
+  static std::string TEXT_EDITOR = "notepad";
 #elif __APPLE__
   // ------ Apple
   //TODO: implementation for apple
@@ -71,7 +71,7 @@ namespace CDMUtilities
    */
 #ifdef _WIN32
   // ------ Windows
-  //TODO: implementation for windows
+  static std::string FILE_EXPLORER = "explorer";
 #elif __APPLE__
   // ------ Apple
   //TODO: implementation for apple
@@ -84,7 +84,7 @@ namespace CDMUtilities
    */
   #ifdef _WIN32
     // ------ Windows
-    //TODO: implementation for windows
+    static std::string TERMINAL = "start cmd.exe";
   #elif __APPLE__
     // ------ Apple
     //TODO: implementation for apple
index e856fd2bae2f847f2d318a55bee08a3679283cfc..7b47e90035841b8cafb42d19a26113b6246ba121 100644 (file)
@@ -83,9 +83,8 @@ bool modelCDMMain::CreateProject(
   std::string command2("del ");
 
   command  += "\"" + locationFixed + "\" \"" + name + "\"";
-  command1 += "\"" + locationFixed +CDMUtilities::SLASH+name+CDMUtilities::SLASH+"CMakeLists.txt.in\" " + "NameOfTheProject " + name + "> \"" + locationFixed + CDMUtilities::SLASH + name + CDMUtilities::SLASH + "CMakeLists.txt\"";
-  command2 += "\"" + locationFixed +CDMUtilities::SLASH+name+CDMUtilities::SLASH+"CMakeLists.txt.in\"";
-
+  command1 += "\"" + locationFixed + CDMUtilities::SLASH + name + CDMUtilities::SLASH + "CMakeLists.txt.in\" " + "PROJECT_NAME " + name + "> \"" + locationFixed + CDMUtilities::SLASH + name + CDMUtilities::SLASH + "CMakeLists.txt\"";
+  command2 += "\"" + locationFixed + CDMUtilities::SLASH + name + CDMUtilities::SLASH + "CMakeLists.txt.in\"";
 
   if (system (command.c_str()))
     {
@@ -93,20 +92,35 @@ bool modelCDMMain::CreateProject(
       return false;
     }
 
-  system ( command1.c_str() );
-  system ( command2.c_str() );
+  if (system (command1.c_str()))
+    {
+      result = new std::string("An error occurred while running '" + command1 + "'.");
+      return false;
+    }
+  if (system (command2.c_str()))
+    {
+      result = new std::string("An error occurred while running '" + command2 + "'.");
+      return false;
+    }
 
-  char *author = author.c_str();
   std::string nomDirectory = locationFixed + CDMUtilities::SLASH + name;
   std::string nomPackageDirectory = nomDirectory + CDMUtilities::SLASH + "bbtk_" + name + "_PKG";
   std::string bbCreatePackage("bbCreatePackage ");
   bbCreatePackage += "\"" + nomDirectory + "\" \"" + name + "\" \"" + author + "\" \"" + description + "\"";
-  system (bbCreatePackage.c_str());
+  if (!system (bbCreatePackage.c_str()))
+    {
+      result = new std::string("An error occurred while running '" + bbCreatePackage + "'.");
+         return false;
+    }
   std::string add;
   add = "echo ADD_SUBDIRECTORY(bbtk_" + name  + "_PKG) >> \"" + nomDirectory + CDMUtilities::SLASH + "CMakeLists.txt\"";
-  system(add.c_str());
+  if (system (add.c_str()))
+    {
+      result = new std::string("An error occurred while running '" + add + "'.");
+         return false;
+    }
 
-  this->project = new modelCDMProject(nomDirectory, name);
+  this->project = new modelCDMProject(NULL, nomDirectory, name);
 
 #else
   // ------ LINUX / MacOS
index 4e1722631bdbe0f956a7f170c6411838b6b2e604..06b9fb9e7fe0eee5af3b78ef42758f913401fbf6 100755 (executable)
@@ -86,7 +86,7 @@ bool modelCDMProjectsTree::CompareNodeItem(modelCDMProjectsTreeNode x, modelCDMP
 
   if(xType != yType)
   {
-    if(xType == DT_DIR)
+    if(xType == wxDIR_DIRS)
       returnValue = true;
     else
       returnValue = false;
@@ -121,7 +121,7 @@ void modelCDMProjectsTree::SetRoot(std::string path)
 
   if(!projectFound)
   {
-    this->projectRoot = modelCDMProjectsTreeNode(path,name,DT_DIR,0);
+    this->projectRoot = modelCDMProjectsTreeNode(path,name,wxDIR_DIRS ,0);
   }else{
     std::cout << "already existing ";
   }
index ec9543bc16057308a599853452ceb08591332017..a5b1315fd05814df8c2c0494190141a88e33cedb 100755 (executable)
@@ -97,6 +97,13 @@ wxCDMMainFrame::wxCDMMainFrame(
     long style
 )
 {
+  this->menu_File = NULL;
+  this->menu_Edit = NULL;
+  this->menu_Tools = NULL;
+  this->menu_Help = NULL;
+  this->panel_Properties = NULL;
+  this->panel_ProjectActions = NULL;
+  this->tree_Projects = NULL;
   Create(parent, id, caption, pos, size, style);
 }
 
@@ -209,7 +216,7 @@ void wxCDMMainFrame::CreateControls()
       ID_TREE_PROJECTS,
       wxDefaultPosition,
       wxSize(200,400),
-      wxTR_HAS_BUTTONS | wxTR_AQUA_BUTTONS
+         wxTR_HAS_BUTTONS | wxTR_AQUA_BUTTONS
   );
 
   panel_Properties = new wxCDMMainDescriptionPanel(
@@ -221,19 +228,10 @@ void wxCDMMainFrame::CreateControls()
       0
   );
 
-
-
-
-
-
-
   auiManager.AddPane(panel_Properties, wxAuiPaneInfo().BestSize(600,400).CenterPane().Name(wxT("panel_Properties")).Caption(wxT("")).CloseButton(false));
   auiManager.AddPane(tree_Projects, wxAuiPaneInfo().Right().MinSize(300,300).BestSize(300,400).CloseButton(false).Name(wxT("tree_Projects")).Caption(wxT("Project Tree")).CloseButton(false));
-
-  wxString pers = auiManager.SavePerspective();
-
   auiManager.Update();
-  auiManager.LoadPerspective(pers,true);
+  //auiManager.LoadPerspective(pers,true);
   wxToolTip::Enable(true);
   wxToolTip::SetDelay(0);
 }
@@ -262,6 +260,7 @@ void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event)
             }
         }
 
+
       if(!this->model->CreateProject(
           crea::wx2std(dialog->GetProjectName()),
           crea::wx2std(dialog->GetProjectLocation()),
@@ -438,26 +437,23 @@ void wxCDMMainFrame::OnMenuExit(wxCommandEvent& event)
   if(this->model->GetProject() != NULL && !this->model->CloseProject(result))
     {
       std::cout << "error closing project: " << *result << std::endl;
-      wxMessageBox( crea::std2wx(result->c_str()), wxT("Close Project - Error"), wxICON_ERROR);
     }
   tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
-
   if(this->panel_Properties != NULL)
     {
       auiManager.DetachPane(this->panel_Properties);
       this->panel_Properties->Destroy();
       this->panel_Properties = NULL;
     }
-
+  
   if(this->panel_ProjectActions != NULL)
     {
       auiManager.DetachPane(this->panel_ProjectActions);
       this->panel_ProjectActions->Destroy();
       this->panel_ProjectActions = NULL;
     }
-
+  
   Close();
-  event.Skip();
 }
 
 //Edit Menu
@@ -564,8 +560,10 @@ void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
       std::cout << "Tree Selection id: " << elementId << std::endl;
       //get element from model
       modelCDMIProjectTreeNode* element = this->model->GetModelElements()[elementId];
+         if (element == NULL)
+                 return;
       std::cout << "Tree Selection: " << element->GetName() << std::endl;
-
+               
       //TODO get element type
       //project
       modelCDMProject* elementProject = dynamic_cast<modelCDMProject*>(element);
index eba2c0de19da2c74a60e1ce592a6cc7800fed633..e05fa97b0711b743550fcbcd1ed2491dd74e272a 100755 (executable)
@@ -81,6 +81,8 @@ bool wxCDMProjectsTreeCtrl::Create(
 {
   wxTreeCtrl::Create (parent, id, pos, size, style, validator, name);
 
+  this->DeleteAllItems();
+
   wxImageList* images = new wxImageList(20, 20, true);
   this->ID_AIcon = images->Add(wxIcon(AIcon20));
   this->ID_ApIcon = images->Add(wxIcon(ApIcon20));
@@ -95,7 +97,9 @@ bool wxCDMProjectsTreeCtrl::Create(
   this->ID_PkIcon = images->Add(wxIcon(PkIcon20));
   this->AssignImageList(images);
 
-  wxTreeItemId rootIndex = this-> AddRoot(_("No Open Project"), this->ID_Cicon, this->ID_Cicon);
+  wxTreeItemId rootId = AddRoot(wxT("Root"), 0, 0);
+/*
+  wxTreeItemId rootIndex = this->AddRoot(wxT("No Open Project"), this->ID_Cicon, this->ID_Cicon);*/
   this->Update();
   return TRUE;
 }