From 5af1633cdea030f5189c57c51bd843685eecd8b6 Mon Sep 17 00:00:00 2001 From: Daniel Gonzalez Date: Mon, 14 Jan 2013 15:34:33 +0100 Subject: [PATCH] Feature #1711 CreaDevManager application implementation -Tree Highlight is now darker -Template libraries and applications are not shown as such (because they are templates) -Buttons are ordered in they way they are supposed to be used -Create class implemented in folder and library -Properties distribution fixed in black box view --- appli/creaDevManager/creaDevManager.cpp | 2 +- lib/creaDevManagerLib/CDMUtilities.cpp | 153 +++++++++++++++++- lib/creaDevManagerLib/CDMUtilities.h | 1 + lib/creaDevManagerLib/modelCDMAppli.cpp | 69 +++++--- lib/creaDevManagerLib/modelCDMFolder.cpp | 15 ++ lib/creaDevManagerLib/modelCDMFolder.h | 2 + lib/creaDevManagerLib/modelCDMLib.cpp | 68 +++++--- .../wxCDMAppliDescriptionPanel.cpp | 5 +- .../wxCDMApplicationDescriptionPanel.cpp | 8 +- .../wxCDMBlackBoxDescriptionPanel.cpp | 16 +- .../wxCDMFileDescriptionPanel.cpp | 2 +- .../wxCDMFolderDescriptionPanel.cpp | 37 +++++ .../wxCDMFolderDescriptionPanel.h | 1 + .../wxCDMLibDescriptionPanel.cpp | 5 +- .../wxCDMLibraryDescriptionPanel.cpp | 35 +++- lib/creaDevManagerLib/wxCDMMainFrame.cpp | 3 + .../wxCDMPackageDescriptionPanel.cpp | 6 +- .../wxCDMPackageManagerPanel.cpp | 5 +- 18 files changed, 370 insertions(+), 63 deletions(-) diff --git a/appli/creaDevManager/creaDevManager.cpp b/appli/creaDevManager/creaDevManager.cpp index a4903d2..10eef03 100644 --- a/appli/creaDevManager/creaDevManager.cpp +++ b/appli/creaDevManager/creaDevManager.cpp @@ -42,7 +42,7 @@ bool wxCreaDevManagerApp::OnInit() wxCDMMainFrame* mainWindow = new wxCDMMainFrame(NULL); SetTopWindow(mainWindow); - mainWindow->SetSize(900, 700); + mainWindow->SetSize(750, 700); mainWindow->Show(true); std::cout << "Crea DevManager opened." << std::endl; diff --git a/lib/creaDevManagerLib/CDMUtilities.cpp b/lib/creaDevManagerLib/CDMUtilities.cpp index 431ebef..defe3f8 100644 --- a/lib/creaDevManagerLib/CDMUtilities.cpp +++ b/lib/creaDevManagerLib/CDMUtilities.cpp @@ -36,7 +36,10 @@ #include #include -#include +#include +#include +#include +#include namespace CDMUtilities { @@ -144,4 +147,152 @@ namespace CDMUtilities return system(comm.c_str()); } + bool createEmptyClass(const std::string& name, const std::string& path) + { + std::vector words; + splitter::split(words,name," \\/\",.'`",splitter::no_empties); + std::string fixedName = ""; + for (int i = 0; i < words.size(); i++) + { + fixedName += words[i]; + } + + if(fixedName == "" || path == "") + { + return false; + } + + std::string nameupper = fixedName; + std::transform(nameupper.begin(), nameupper.end(),nameupper.begin(),::toupper); + + std::ofstream out((path + SLASH + fixedName + ".h").c_str()); + if( !out.is_open()) + { + return false; + } + + out << "/*" << std::endl; + out << "# ---------------------------------------------------------------------" << std::endl; + out << "#" << std::endl; + out << "# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image" << std::endl; + out << "# pour la Sante)" << std::endl; + out << "# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton" << std::endl; + out << "# Previous Authors : Laurent Guigues, Jean-Pierre Roux" << std::endl; + out << "# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil" << std::endl; + out << "#" << std::endl; + out << "# This software is governed by the CeCILL-B license under French law and" << std::endl; + out << "# abiding by the rules of distribution of free software. You can use," << std::endl; + out << "# modify and/ or redistribute the software under the terms of the CeCILL-B" << std::endl; + out << "# license as circulated by CEA, CNRS and INRIA at the following URL" << std::endl; + out << "# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html" << std::endl; + out << "# or in the file LICENSE.txt." << std::endl; + out << "#" << std::endl; + out << "# As a counterpart to the access to the source code and rights to copy," << std::endl; + out << "# modify and redistribute granted by the license, users are provided only" << std::endl; + out << "# with a limited warranty and the software's author, the holder of the" << std::endl; + out << "# economic rights, and the successive licensors have only limited" << std::endl; + out << "# liability." << std::endl; + out << "#" << std::endl; + out << "# The fact that you are presently reading this means that you have had" << std::endl; + out << "# knowledge of the CeCILL-B license and that you accept its terms." << std::endl; + out << "# ------------------------------------------------------------------------" << std::endl; + out << "*/" << std::endl; + out << "" << std::endl; + out << "#ifndef _" << nameupper << "_H_" << std::endl; + out << "#define _" << nameupper << "_H_" << std::endl; + out << "" << std::endl; + out << "//---------------------------------------------" << std::endl; + out << "// Class Name: " << fixedName << "" << std::endl; + out << "// [classdescription]" << std::endl; + out << "//---------------------------------------------" << std::endl; + out << "" << std::endl; + out << "class " << fixedName << "" << std::endl; + out << "{" << std::endl; + out << "" << std::endl; + out << "//---------------------------------------------" << std::endl; + out << "//Methods and attributes exposed to other classes" << std::endl; + out << "//---------------------------------------------" << std::endl; + out << "public :" << std::endl; + out << " " << fixedName << "();" << std::endl; + out << " ~" << fixedName << "();" << std::endl; + out << "" << std::endl; + out << "//--Method template----------------------------" << std::endl; + out << "// void FunctionName(int& parameterA);" << std::endl; + out << "" << std::endl; + out << "" << std::endl; + out << "//---------------------------------------------" << std::endl; + out << "//Methods and attributes exposed only to classes" << std::endl; + out << "//that are derived from this class" << std::endl; + out << "//---------------------------------------------" << std::endl; + out << "protected:" << std::endl; + out << "" << std::endl; + out << "//---------------------------------------------" << std::endl; + out << "//Methods and attributes only visible by this class" << std::endl; + out << "//---------------------------------------------" << std::endl; + out << "private:" << std::endl; + out << "" << std::endl; + out << "};" << std::endl; + out << "" << std::endl; + out << "//-end of _" << nameupper << "_H_------------------------------------------------------" << std::endl; + out << "#endif" << std::endl; + + out.close(); + + out.open((path + CDMUtilities::SLASH + fixedName + ".cpp").c_str()); + if( !out.is_open()) + { + return false; + } + + out << "/*" << std::endl; + out << "# ---------------------------------------------------------------------" << std::endl; + out << "#" << std::endl; + out << "# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image" << std::endl; + out << "# pour la Sante)" << std::endl; + out << "# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton" << std::endl; + out << "# Previous Authors : Laurent Guigues, Jean-Pierre Roux" << std::endl; + out << "# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil" << std::endl; + out << "#" << std::endl; + out << "# This software is governed by the CeCILL-B license under French law and" << std::endl; + out << "# abiding by the rules of distribution of free software. You can use," << std::endl; + out << "# modify and/ or redistribute the software under the terms of the CeCILL-B" << std::endl; + out << "# license as circulated by CEA, CNRS and INRIA at the following URL" << std::endl; + out << "# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html" << std::endl; + out << "# or in the file LICENSE.txt." << std::endl; + out << "#" << std::endl; + out << "# As a counterpart to the access to the source code and rights to copy," << std::endl; + out << "# modify and redistribute granted by the license, users are provided only" << std::endl; + out << "# with a limited warranty and the software's author, the holder of the" << std::endl; + out << "# economic rights, and the successive licensors have only limited" << std::endl; + out << "# liability." << std::endl; + out << "#" << std::endl; + out << "# The fact that you are presently reading this means that you have had" << std::endl; + out << "# knowledge of the CeCILL-B license and that you accept its terms." << std::endl; + out << "# ------------------------------------------------------------------------" << std::endl; + out << "*/" << std::endl; + out << "" << std::endl; + out << "#include \"" << fixedName << ".h\"" << std::endl; + out << "" << std::endl; + out << "" << fixedName << "::" << fixedName << "()" << std::endl; + out << "{" << std::endl; + out << "}" << std::endl; + out << "" << std::endl; + out << "" << fixedName << "::~" << fixedName << "()" << std::endl; + out << "{" << std::endl; + out << "}" << std::endl; + out << "" << std::endl; + out << "//---------------------------------------------" << std::endl; + out << "//Method template" << std::endl; + out << "//---------------------------------------------" << std::endl; + out << "/*" << std::endl; + out << "void " << fixedName << "::FunctionName(int& parameterA)" << std::endl; + out << "{" << std::endl; + out << " parameterA = 2 * parameterA;" << std::endl; + out << " return;" << std::endl; + out << "}" << std::endl; + out << "*/" << std::endl; + + return true; + } + } diff --git a/lib/creaDevManagerLib/CDMUtilities.h b/lib/creaDevManagerLib/CDMUtilities.h index 1050989..21f66d8 100644 --- a/lib/creaDevManagerLib/CDMUtilities.h +++ b/lib/creaDevManagerLib/CDMUtilities.h @@ -106,6 +106,7 @@ namespace CDMUtilities int openBBEditor(); int openCreaToolsTools(); int openTerminal(const std::string& command = ""); + bool createEmptyClass(const std::string& name, const std::string& path); }; #endif /* CDMUTILITIES_H_ */ diff --git a/lib/creaDevManagerLib/modelCDMAppli.cpp b/lib/creaDevManagerLib/modelCDMAppli.cpp index c92932a..4173927 100644 --- a/lib/creaDevManagerLib/modelCDMAppli.cpp +++ b/lib/creaDevManagerLib/modelCDMAppli.cpp @@ -69,9 +69,17 @@ modelCDMAppli::modelCDMAppli(const std::string& path, const std::string& name, c { std::string stdfileName = crea::wx2std(fileName); - modelCDMApplication* application = new modelCDMApplication(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1); - this->applications.push_back(application); - this->children.push_back(application); + if(stdfileName != "template_appli" && stdfileName != "template_wx_appli") + { + modelCDMApplication* application = new modelCDMApplication(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1); + this->applications.push_back(application); + this->children.push_back(application); + } + else + { + modelCDMFolder* folder = new modelCDMFolder(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1); + this->children.push_back(folder); + } cont = dir.GetNext(&fileName); } @@ -175,26 +183,51 @@ const bool modelCDMAppli::Refresh(std::string*& result) while (cont) { std::string stdfileName = crea::wx2std(fileName); - std::string applicationName = stdfileName; - //check if they already exist - bool found = false; - for (int i = 0; !found && i < this->applications.size(); i++) + + if(stdfileName != "template_appli" && stdfileName != "template_wx_appli") { - if (this->applications[i]->GetName() == applicationName) + std::string applicationName = stdfileName; + //check if application already exist + bool found = false; + for (int i = 0; !found && i < this->applications.size(); i++) { - found = true; - int pos = std::find(this->children.begin(), this->children.end(), this->applications[i]) - this->children.begin(); - checked[pos] = true; - checkedApplications[i] = true; - if(!this->applications[i]->Refresh(result)) - return false; + if (this->applications[i]->GetName() == applicationName) + { + found = true; + int pos = std::find(this->children.begin(), this->children.end(), this->applications[i]) - this->children.begin(); + checked[pos] = true; + checkedApplications[i] = true; + if(!this->applications[i]->Refresh(result)) + return false; + } + } + if(!found) + { + modelCDMApplication* application= new modelCDMApplication(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1); + this->applications.push_back(application); + this->children.push_back(application); } } - if(!found) + else { - modelCDMApplication* application= new modelCDMApplication(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1); - this->applications.push_back(application); - this->children.push_back(application); + //check if folder already exist + bool found = false; + for (int i = 0; !found && i < this->children.size(); i++) + { + if (this->children[i]->GetName() == stdfileName) + { + found = true; + checked[i] = true; + + if(!this->children[i]->Refresh(result)) + return false; + } + } + if(!found) + { + modelCDMFolder* folder= new modelCDMFolder(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1); + this->children.push_back(folder); + } } cont = dir.GetNext(&fileName); } diff --git a/lib/creaDevManagerLib/modelCDMFolder.cpp b/lib/creaDevManagerLib/modelCDMFolder.cpp index 3365c09..c97b129 100644 --- a/lib/creaDevManagerLib/modelCDMFolder.cpp +++ b/lib/creaDevManagerLib/modelCDMFolder.cpp @@ -117,6 +117,21 @@ modelCDMFolder::~modelCDMFolder() this->children.clear(); } +bool modelCDMFolder::CreateClass(const std::string& name) +{ + if (!CDMUtilities::createEmptyClass(name, this->path)) + { + return false; + } + else + { + this->children.push_back(new modelCDMFile(this->path + CDMUtilities::SLASH + name + ".h", name + ".h", this->level + 1)); + this->children.push_back(new modelCDMFile(this->path + CDMUtilities::SLASH + name + ".cpp", name + ".cpp", this->level + 1)); + this->SortChildren(); + return true; + } +} + modelCDMFolder* modelCDMFolder::CreateFolder(const std::string& name, std::string*& result) { //TODO:: mkdir depending on OS diff --git a/lib/creaDevManagerLib/modelCDMFolder.h b/lib/creaDevManagerLib/modelCDMFolder.h index a4ea6e7..0756500 100644 --- a/lib/creaDevManagerLib/modelCDMFolder.h +++ b/lib/creaDevManagerLib/modelCDMFolder.h @@ -51,6 +51,8 @@ public: modelCDMCMakeListsFile* GetCMakeLists() const; std::vector GetFolders() const; + bool CreateClass(const std::string& name); + modelCDMFolder* CreateFolder( const std::string& name, std::string*& result diff --git a/lib/creaDevManagerLib/modelCDMLib.cpp b/lib/creaDevManagerLib/modelCDMLib.cpp index 8ebd9ae..16211ee 100644 --- a/lib/creaDevManagerLib/modelCDMLib.cpp +++ b/lib/creaDevManagerLib/modelCDMLib.cpp @@ -70,9 +70,17 @@ modelCDMLib::modelCDMLib(const std::string& path, const std::string& name, const { std::string stdfileName = crea::wx2std(fileName); - modelCDMLibrary* library = new modelCDMLibrary(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1); - this->libraries.push_back(library); - this->children.push_back(library); + if(stdfileName != "template_lib") + { + modelCDMLibrary* library = new modelCDMLibrary(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1); + this->libraries.push_back(library); + this->children.push_back(library); + } + else + { + modelCDMFolder* folder = new modelCDMFolder(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1); + this->children.push_back(folder); + } cont = dir.GetNext(&fileName); } @@ -177,26 +185,50 @@ const bool modelCDMLib::Refresh(std::string*& result) while (cont) { std::string stdfileName = crea::wx2std(fileName); - std::string libraryName = stdfileName; - //check if they already exist - bool found = false; - for (int i = 0; !found && i < this->libraries.size(); i++) + + if(stdfileName != "template_lib") { - if (this->libraries[i]->GetName() == libraryName) + std::string libraryName = stdfileName; + //check if library already exist + bool found = false; + for (int i = 0; !found && i < this->libraries.size(); i++) { - found = true; - int pos = std::find(this->children.begin(), this->children.end(), this->libraries[i]) - this->children.begin(); - checked[pos] = true; - checkedLibraries[i] = true; - if(!this->libraries[i]->Refresh(result)) - return false; + if (this->libraries[i]->GetName() == libraryName) + { + found = true; + int pos = std::find(this->children.begin(), this->children.end(), this->libraries[i]) - this->children.begin(); + checked[pos] = true; + checkedLibraries[i] = true; + if(!this->libraries[i]->Refresh(result)) + return false; + } + } + if(!found) + { + modelCDMLibrary* library = new modelCDMLibrary(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1); + this->libraries.push_back(library); + this->children.push_back(library); } } - if(!found) + else { - modelCDMLibrary* library = new modelCDMLibrary(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1); - this->libraries.push_back(library); - this->children.push_back(library); + //check if folder already exist + bool found = false; + for (int i = 0; !found && i < this->children.size(); i++) + { + if (this->children[i]->GetName() == stdfileName) + { + found = true; + checked[i] = true; + if(!this->children[i]->Refresh(result)) + return false; + } + } + if(!found) + { + modelCDMFolder* folder= new modelCDMFolder(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1); + this->children.push_back(folder); + } } cont = dir.GetNext(&fileName); } diff --git a/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.cpp index e99bc13..ec0dc04 100644 --- a/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMAppliDescriptionPanel.cpp @@ -115,17 +115,18 @@ void wxCDMAppliDescriptionPanel::CreateControls() for (int i = 0; i < applications.size(); i++) { wxHyperlinkCtrl* pApplicationlk = new wxHyperlinkCtrl(propertiesPanel,ID_LINK_SELECT_APPLICATION, crea::std2wx(applications[i]->GetName().c_str()), crea::std2wx(applications[i]->GetName().c_str())); + pApplicationlk->SetWindowStyle(wxALIGN_LEFT); std::string tt = "Name: " + applications[i]->GetName() + "\n"; tt += "Location: " + applications[i]->GetPath(); pApplicationlk->SetToolTip(crea::std2wx(tt.c_str())); pApplicationlk->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMAppliDescriptionPanel::OnMouseEnter,NULL,this); pApplicationlk->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMAppliDescriptionPanel::OnMouseExit,NULL,this); - propertiesPanelSizer -> Add(pApplicationlk, 0, wxALIGN_LEFT | wxALL, 5); + propertiesPanelSizer -> Add(pApplicationlk, 1, wxEXPAND | wxALL, 5); } propertiesPanel->SetSizer(propertiesPanelSizer); propertiesPanelSizer->Fit(propertiesPanel); - propertiesBox->Add(propertiesPanel, 0, wxALL, 5); + propertiesBox->Add(propertiesPanel, 1, wxEXPAND | wxALL, 5); sizer -> Add(propertiesBox, 0, wxEXPAND | wxALL, 10); //Actions diff --git a/lib/creaDevManagerLib/wxCDMApplicationDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMApplicationDescriptionPanel.cpp index d791376..079a093 100644 --- a/lib/creaDevManagerLib/wxCDMApplicationDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMApplicationDescriptionPanel.cpp @@ -144,7 +144,7 @@ void wxCDMApplicationDescriptionPanel::CreateControls() //actionsGrid Sizer wxFlexGridSizer* actionsGridSizer = new wxFlexGridSizer(2, 2, 9, 15); - wxButton* createClassbt = new wxButton(actionsPanel, ID_BUTTON_CREATE_CLASS, _T("A. Create Class")); + wxButton* createClassbt = new wxButton(actionsPanel, ID_BUTTON_CREATE_CLASS, _T("Create Class (Optional)")); createClassbt->SetToolTip(wxT("Create a new Class (.h and .cxx files).")); wxButton* createFolderbt = new wxButton(actionsPanel, ID_BUTTON_CREATE_FOLDER, _T("Create Folder (Optional)")); createFolderbt->SetToolTip(wxT("Create a new Folder inside the application folder.")); @@ -152,13 +152,13 @@ void wxCDMApplicationDescriptionPanel::CreateControls() editCMakebt->SetToolTip(wxT("Edit the CMakeLists.txt file inside this application.")); editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationDescriptionPanel::OnCMakeMouseEnter,NULL,this); editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationDescriptionPanel::OnCMakeMouseExit,NULL,this); - wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("C. Open Application Folder")); + wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("A. Open Application Folder")); openFolderbt->SetToolTip(wxT("Open the application folder in the file explorer.")); - actionsGridSizer->Add(createClassbt, 1, wxALL | wxEXPAND, 5); - actionsGridSizer->Add(editCMakebt, 1, wxALL | wxEXPAND, 5); actionsGridSizer->Add(openFolderbt, 1, wxALL | wxEXPAND, 5); + actionsGridSizer->Add(editCMakebt, 1, wxALL | wxEXPAND, 5); + actionsGridSizer->Add(createClassbt, 1, wxALL | wxEXPAND, 5); actionsGridSizer->Add(createFolderbt, 1, wxALL | wxEXPAND, 5); //SetPanel sizer and box diff --git a/lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.cpp index 065eb8f..006ca3d 100644 --- a/lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMBlackBoxDescriptionPanel.cpp @@ -122,24 +122,24 @@ void wxCDMBlackBoxDescriptionPanel::CreateControls() this->authortc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetAuthors())); wxButton* pAuthorbt = new wxButton(propertiesPanel, ID_BUTTON_SET_AUTHOR, wxT("Change")); pAuthorbt->SetToolTip(wxT("Update the author/s of the package.")); - pAuthorsz->Add(this->authortc, 1, wxALIGN_CENTER_VERTICAL, 0); - pAuthorsz->Add(pAuthorbt, 0, wxALIGN_CENTER | wxLEFT, 10); + pAuthorsz->Add(this->authortc, 1, wxALIGN_CENTER, 0); + pAuthorsz->Add(pAuthorbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10); // description wxBoxSizer* pDescriptionsz = new wxBoxSizer(wxHORIZONTAL); this->descriptiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetDescription())); wxButton* pDescriptionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_DESCRIPTION, wxT("Change")); pDescriptionbt->SetToolTip(wxT("Update the description of the project.")); - pDescriptionsz->Add(this->descriptiontc, 1, wxALIGN_CENTER_VERTICAL, 0); - pDescriptionsz->Add(pDescriptionbt, 0, wxALIGN_CENTER | wxLEFT, 10); + pDescriptionsz->Add(this->descriptiontc, 1, wxALIGN_CENTER, 1); + pDescriptionsz->Add(pDescriptionbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10); // categories wxBoxSizer* pCategoriessz = new wxBoxSizer(wxHORIZONTAL); this->categoriestc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->blackBox->GetCategories())); wxButton* pCategoriesbt = new wxButton(propertiesPanel, ID_BUTTON_SET_CATEGORY, wxT("Change")); pCategoriesbt->SetToolTip(wxT("Update the categories of the project.")); - pCategoriessz->Add(this->categoriestc, 1, wxALIGN_CENTER_VERTICAL, 0); - pCategoriessz->Add(pCategoriesbt, 0, wxALIGN_CENTER | wxLEFT, 10); + pCategoriessz->Add(this->categoriestc, 1, wxALIGN_CENTER, 0); + pCategoriessz->Add(pCategoriesbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10); propertiesGridSizer->Add(pAuthor, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); propertiesGridSizer->Add(pAuthorsz, 1, wxEXPAND); @@ -150,10 +150,10 @@ void wxCDMBlackBoxDescriptionPanel::CreateControls() propertiesGridSizer->AddGrowableCol(1,1); - propertiesPanelSizer -> Add(propertiesGridSizer, 1, wxEXPAND); + propertiesPanelSizer -> Add(propertiesGridSizer, 1, wxEXPAND | wxALL, 5); propertiesPanel->SetSizer(propertiesPanelSizer); propertiesPanelSizer->Fit(propertiesPanel); - propertiesBox->Add(propertiesPanel, 0, wxALL, 5); + propertiesBox->Add(propertiesPanel, 1, wxEXPAND, 5); sizer->Add(propertiesBox, 0, wxEXPAND | wxALL, 10); diff --git a/lib/creaDevManagerLib/wxCDMFileDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMFileDescriptionPanel.cpp index efbc396..9e01585 100644 --- a/lib/creaDevManagerLib/wxCDMFileDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMFileDescriptionPanel.cpp @@ -130,7 +130,7 @@ void wxCDMFileDescriptionPanel::CreateControls() propertiesPanelSizer -> Add(propertiesGridSizer, 1, wxEXPAND); propertiesPanel->SetSizer(propertiesPanelSizer); propertiesPanelSizer->Fit(propertiesPanel); - propertiesBox->Add(propertiesPanel, 0, wxALL, 5); + propertiesBox->Add(propertiesPanel, 1, wxALL|wxEXPAND, 5); sizer->Add(propertiesBox, 0, wxEXPAND | wxALL, 10); diff --git a/lib/creaDevManagerLib/wxCDMFolderDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMFolderDescriptionPanel.cpp index d3ca77b..e0669cf 100644 --- a/lib/creaDevManagerLib/wxCDMFolderDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMFolderDescriptionPanel.cpp @@ -44,6 +44,7 @@ BEGIN_EVENT_TABLE(wxCDMFolderDescriptionPanel, wxPanel) EVT_BUTTON(ID_BUTTON_PREV, wxCDMFolderDescriptionPanel::OnBtnReturn) EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMFolderDescriptionPanel::OnBtnOpenInExplorer) EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMFolderDescriptionPanel::OnBtnEditCMakeLists) +EVT_BUTTON(ID_BUTTON_CREATE_CLASS, wxCDMFolderDescriptionPanel::OnBtnCreateClass) EVT_BUTTON(ID_BUTTON_CREATE_FOLDER, wxCDMFolderDescriptionPanel::OnBtnCreateFolder) END_EVENT_TABLE() @@ -177,6 +178,42 @@ void wxCDMFolderDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event) } } +void wxCDMFolderDescriptionPanel::OnBtnCreateClass(wxCommandEvent& event) +{ + //get class name from user + wxTextEntryDialog* newClassDlg = new wxTextEntryDialog( + this, + wxT("Please enter the new class name."), + wxT("New Class - creaDevManager"), + wxT(""), + wxOK | wxCANCEL + ); + + if (newClassDlg->ShowModal() == wxID_OK) + { + std::string className = crea::wx2std(newClassDlg->GetValue()); + //check class name + if(className.size() > 0) + { + if(!this->folder->CreateClass(className)) + wxMessageBox(crea::std2wx("Something has gone wrong with the creation of the class."),_T("New Class - Error!"),wxOK | wxICON_ERROR); + + ((wxCDMMainFrame*)this->GetParent())->RefreshProject(); + + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED); + newEvent->SetId(0); + newEvent->SetInt(folder->GetId()); + wxPostEvent(this->GetParent(), *newEvent); + + wxMessageBox(crea::std2wx("The class has been created successfully."),_T("New Class - Success"),wxOK | wxICON_INFORMATION); + } + else + { + wxMessageBox(crea::std2wx("The new class name cannot be empty."),_T("New Class - Error!"),wxOK | wxICON_ERROR); + } + } +} + void wxCDMFolderDescriptionPanel::OnBtnCreateFolder(wxCommandEvent& event) { //get name diff --git a/lib/creaDevManagerLib/wxCDMFolderDescriptionPanel.h b/lib/creaDevManagerLib/wxCDMFolderDescriptionPanel.h index ecf47ff..e273114 100644 --- a/lib/creaDevManagerLib/wxCDMFolderDescriptionPanel.h +++ b/lib/creaDevManagerLib/wxCDMFolderDescriptionPanel.h @@ -75,6 +75,7 @@ private: protected: void OnBtnReturn(wxCommandEvent& event); void OnBtnEditCMakeLists(wxCommandEvent& event); + void OnBtnCreateClass(wxCommandEvent& event); void OnBtnCreateFolder(wxCommandEvent& event); void OnBtnOpenInExplorer(wxCommandEvent& event); diff --git a/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp index 7928739..6167c17 100644 --- a/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMLibDescriptionPanel.cpp @@ -112,17 +112,18 @@ void wxCDMLibDescriptionPanel::CreateControls() for (int i = 0; i < libraries.size(); i++) { wxHyperlinkCtrl* pLibrarylk = new wxHyperlinkCtrl(propertiesPanel, ID_LINK_SELECT_LIBRARY, crea::std2wx(libraries[i]->GetName().c_str()), crea::std2wx(libraries[i]->GetName().c_str())); + pLibrarylk->SetWindowStyle(wxALIGN_LEFT); std::string tt = "Name: " + libraries[i]->GetName() + "\n"; tt += "Location: " + libraries[i]->GetPath(); pLibrarylk->SetToolTip(crea::std2wx(tt.c_str())); pLibrarylk->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibDescriptionPanel::OnMouseEnter,NULL,this); pLibrarylk->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibDescriptionPanel::OnMouseExit,NULL,this); - propertiesPanelSizer -> Add(pLibrarylk, 0, wxALIGN_LEFT | wxALL, 5); + propertiesPanelSizer -> Add(pLibrarylk, 0, wxEXPAND | wxALL, 5); } propertiesPanel->SetSizer(propertiesPanelSizer); propertiesPanelSizer->Fit(propertiesPanel); - propertiesBox->Add(propertiesPanel, 0, wxALL, 5); + propertiesBox->Add(propertiesPanel, 1, wxALL | wxEXPAND, 5); sizer -> Add(propertiesBox, 0, wxEXPAND | wxALL, 10); //Actions diff --git a/lib/creaDevManagerLib/wxCDMLibraryDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMLibraryDescriptionPanel.cpp index 62b5b93..4bee166 100644 --- a/lib/creaDevManagerLib/wxCDMLibraryDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMLibraryDescriptionPanel.cpp @@ -209,9 +209,38 @@ void wxCDMLibraryDescriptionPanel::OnBtnSetExeName(wxCommandEvent& event) void wxCDMLibraryDescriptionPanel::OnBtnCreateClass(wxCommandEvent& event) { - //TODO: implement method - std::cerr << "Event OnBtnCreateClass not implemented" << std::endl; - event.Skip(); + //get class name from user + wxTextEntryDialog* newClassDlg = new wxTextEntryDialog( + this, + wxT("Please enter the new class name."), + wxT("New Class - creaDevManager"), + wxT(""), + wxOK | wxCANCEL + ); + + if (newClassDlg->ShowModal() == wxID_OK) + { + std::string className = crea::wx2std(newClassDlg->GetValue()); + //check class name + if(className.size() > 0) + { + if(!this->library->CreateClass(className)) + wxMessageBox(crea::std2wx("Something has gone wrong with the creation of the class."),_T("New Class - Error!"),wxOK | wxICON_ERROR); + + ((wxCDMMainFrame*)this->GetParent())->RefreshProject(); + + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED); + newEvent->SetId(0); + newEvent->SetInt(library->GetId()); + wxPostEvent(this->GetParent(), *newEvent); + + wxMessageBox(crea::std2wx("The class has been created successfully."),_T("New Class - Success"),wxOK | wxICON_INFORMATION); + } + else + { + wxMessageBox(crea::std2wx("The new class name cannot be empty."),_T("New Class - Error!"),wxOK | wxICON_ERROR); + } + } } void wxCDMLibraryDescriptionPanel::OnBtnCreateFolder(wxCommandEvent& event) diff --git a/lib/creaDevManagerLib/wxCDMMainFrame.cpp b/lib/creaDevManagerLib/wxCDMMainFrame.cpp index 6f0af46..143d239 100755 --- a/lib/creaDevManagerLib/wxCDMMainFrame.cpp +++ b/lib/creaDevManagerLib/wxCDMMainFrame.cpp @@ -867,6 +867,7 @@ void wxCDMMainFrame::OnCreationComplete(wxCommandEvent& event) { case 0: //select out old one to generate selection event + this->tree_Projects->SelectItem(event.GetInt(), false); this->tree_Projects->SelectItem(event.GetInt(), true); this->tree_Projects->Expand(event.GetInt()); break; @@ -941,6 +942,7 @@ void wxCDMMainFrame::OnElementSelected(wxCommandEvent& event) this->tree_Projects->EnsureVisible(event.GetInt()); this->tree_Projects->SetItemBold(event.GetInt(), true); this->tree_Projects->SetItemTextColour(event.GetInt(), wxColour(0,0,255)); + this->tree_Projects->SetItemBackgroundColour(event.GetInt(), wxColour(230,230,255)); this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE); auiManager.Update(); } @@ -949,6 +951,7 @@ void wxCDMMainFrame::OnElementDeselected(wxCommandEvent& event) { this->tree_Projects->SetItemBold(event.GetInt(), false); this->tree_Projects->SetItemTextColour(event.GetInt(), wxColour(0,0,0)); + this->tree_Projects->SetItemBackgroundColour(event.GetInt(), wxColour(255,255,255)); this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE); auiManager.Update(); } diff --git a/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp index e332a56..d4348fa 100644 --- a/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp @@ -180,18 +180,18 @@ void wxCDMPackageDescriptionPanel::CreateControls() { wxHyperlinkCtrl* pBBlk = new wxHyperlinkCtrl(BBPanel,ID_LINK_SELECT_BLACKBOX, crea::std2wx(blackBoxes[i]->GetName().c_str()), crea::std2wx(blackBoxes[i]->GetName().c_str())); + pBBlk->SetWindowStyle(wxALIGN_LEFT); 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); + BBPanelSizer -> Add(pBBlk, 0, wxEXPAND | wxALL, 5); } } BBPanel->SetSizer(BBPanelSizer); BBPanelSizer->Fit(BBPanel); - BBBox->Add(BBPanel, 0, wxALL, 5); - + BBBox->Add(BBPanel, 1, wxEXPAND | wxALL, 5); sizer -> Add(BBBox, 0, wxEXPAND | wxALL, 10); //Actions diff --git a/lib/creaDevManagerLib/wxCDMPackageManagerPanel.cpp b/lib/creaDevManagerLib/wxCDMPackageManagerPanel.cpp index 3cd317b..a888f8b 100644 --- a/lib/creaDevManagerLib/wxCDMPackageManagerPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMPackageManagerPanel.cpp @@ -116,16 +116,17 @@ void wxCDMPackageManagerPanel::CreateControls() for (int i = 0; i < packages.size(); i++) { wxHyperlinkCtrl* pPackagelk = new wxHyperlinkCtrl(propertiesPanel,ID_LINK_SELECT_PACKAGE, crea::std2wx(packages[i]->GetName().c_str()), crea::std2wx(packages[i]->GetName().c_str())); + pPackagelk->SetWindowStyle(wxALIGN_LEFT); std::string tt = "Author: " + packages[i]->GetAuthors() + "\nDescription: " + packages[i]->GetDescription(); pPackagelk->SetToolTip(crea::std2wx(tt)); - propertiesPanelSizer -> Add(pPackagelk, 0, wxALIGN_LEFT | wxALL, 5); + propertiesPanelSizer -> Add(pPackagelk, 0, wxEXPAND | wxALL, 5); pPackagelk->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageManagerPanel::OnMouseEnter,NULL,this); pPackagelk->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageManagerPanel::OnMouseExit,NULL,this); } propertiesPanel->SetSizer(propertiesPanelSizer); propertiesPanelSizer->Fit(propertiesPanel); - propertiesBox->Add(propertiesPanel, 0, wxALL, 5); + propertiesBox->Add(propertiesPanel, 1, wxALL | wxEXPAND, 5); sizer -> Add(propertiesBox, 0, wxEXPAND | wxALL, 10); -- 2.46.2