From 921c85646eb457d9e8cfc1a9031481df176970ce Mon Sep 17 00:00:00 2001 From: Daniel Felipe Gonzalez Date: Mon, 21 Jan 2013 19:33:23 +0100 Subject: [PATCH] Feature #1711 CreaDevManager application implementation - Changes for windows compatibility Application opens and creates projects. hangs when showing project properties. --- appli/creaDevManager/creaDevManager.cpp | 6 ++-- appli/creaDevManager/creaDevManager.h | 5 +++ lib/creaDevManagerLib/CDMUtilities.cpp | 20 +++++++++--- lib/creaDevManagerLib/CDMUtilities.h | 6 ++-- lib/creaDevManagerLib/modelCDMMain.cpp | 32 +++++++++++++------ .../modelCDMProjectsTree.cpp | 4 +-- lib/creaDevManagerLib/wxCDMMainFrame.cpp | 32 +++++++++---------- .../wxCDMProjectsTreeCtrl.cxx | 6 +++- 8 files changed, 70 insertions(+), 41 deletions(-) diff --git a/appli/creaDevManager/creaDevManager.cpp b/appli/creaDevManager/creaDevManager.cpp index 10eef03..be7b25b 100644 --- a/appli/creaDevManager/creaDevManager.cpp +++ b/appli/creaDevManager/creaDevManager.cpp @@ -28,7 +28,6 @@ #include #include // 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; diff --git a/appli/creaDevManager/creaDevManager.h b/appli/creaDevManager/creaDevManager.h index ca8e970..eaafbee 100644 --- a/appli/creaDevManager/creaDevManager.h +++ b/appli/creaDevManager/creaDevManager.h @@ -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) diff --git a/lib/creaDevManagerLib/CDMUtilities.cpp b/lib/creaDevManagerLib/CDMUtilities.cpp index defe3f8..4d40954 100644 --- a/lib/creaDevManagerLib/CDMUtilities.cpp +++ b/lib/creaDevManagerLib/CDMUtilities.cpp @@ -80,17 +80,27 @@ namespace CDMUtilities #if(_WIN32) // ------ Windows - //TODO: implementation for windows + std::vector 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 pathSlpit; + std::vector 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; diff --git a/lib/creaDevManagerLib/CDMUtilities.h b/lib/creaDevManagerLib/CDMUtilities.h index 4b18fcb..4236eb5 100644 --- a/lib/creaDevManagerLib/CDMUtilities.h +++ b/lib/creaDevManagerLib/CDMUtilities.h @@ -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 diff --git a/lib/creaDevManagerLib/modelCDMMain.cpp b/lib/creaDevManagerLib/modelCDMMain.cpp index e856fd2..7b47e90 100644 --- a/lib/creaDevManagerLib/modelCDMMain.cpp +++ b/lib/creaDevManagerLib/modelCDMMain.cpp @@ -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 diff --git a/lib/creaDevManagerLib/modelCDMProjectsTree.cpp b/lib/creaDevManagerLib/modelCDMProjectsTree.cpp index 4e17226..06b9fb9 100755 --- a/lib/creaDevManagerLib/modelCDMProjectsTree.cpp +++ b/lib/creaDevManagerLib/modelCDMProjectsTree.cpp @@ -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 "; } diff --git a/lib/creaDevManagerLib/wxCDMMainFrame.cpp b/lib/creaDevManagerLib/wxCDMMainFrame.cpp index ec9543b..a5b1315 100755 --- a/lib/creaDevManagerLib/wxCDMMainFrame.cpp +++ b/lib/creaDevManagerLib/wxCDMMainFrame.cpp @@ -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(element); diff --git a/lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.cxx b/lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.cxx index eba2c0d..e05fa97 100755 --- a/lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.cxx +++ b/lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.cxx @@ -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; } -- 2.47.1