From: Daniel Gonzalez Date: Mon, 17 Dec 2012 17:14:08 +0000 (+0100) Subject: Feature #1711 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=609d8d48cae96384e664ec6b000e8ecfcbad6459;p=crea.git Feature #1711 CreaDevManager application implementation - Package functions implemented. Creating Black Boxes still not working. - All CMake files open implemented. - All Open in File explorer implemented. - Implemented Open BBEditor, Text Editor, Minitools and command line. - Properties rezise bug fixed. --- diff --git a/lib/creaDevManagerLib/CDMUtilities.cpp b/lib/creaDevManagerLib/CDMUtilities.cpp index d9ef9b7..29a277f 100644 --- a/lib/creaDevManagerLib/CDMUtilities.cpp +++ b/lib/creaDevManagerLib/CDMUtilities.cpp @@ -105,13 +105,40 @@ namespace CDMUtilities } int openFileExplorer(const std::string& file) - { - std::string command = FILE_EXPLORER; + { + std::string command = FILE_EXPLORER; + + if(file != "") + command += " \"" + file + "\" &"; + + return system(command.c_str()); + } - if(file != "") - command += " \"" + file + "\" &"; + int openFileWithCommand(const std::string& file, const std::string& command) + { + std::string comm = command; + if(file != "") + comm += " \"" + file + "\" &"; - return system(command.c_str()); - } + return system(comm.c_str()); + } + + int openBBEditor() + { + std::string comm = "bbEditor &"; + return system(comm.c_str()); + } + + int openCreaToolsTools() + { + std::string comm = "creaTools.sh &"; + return system(comm.c_str()); + } + + int openTerminal() + { + std::string comm = TERMINAL + "&"; + return system(comm.c_str()); + } } diff --git a/lib/creaDevManagerLib/CDMUtilities.h b/lib/creaDevManagerLib/CDMUtilities.h index 16630d2..bed8ed9 100644 --- a/lib/creaDevManagerLib/CDMUtilities.h +++ b/lib/creaDevManagerLib/CDMUtilities.h @@ -62,6 +62,17 @@ namespace CDMUtilities static std::string FILE_EXPLORER = "nautilus"; #endif + //terminal program + #ifdef _WIN32 + // ------ Windows + //TODO: implementation for windows + #elif __APPLE__ + // ------ Apple + //TODO: implementation for apple + #else + static std::string TERMINAL = "gnome-terminal"; + #endif + struct splitter { @@ -80,6 +91,10 @@ namespace CDMUtilities int openTextEditor(const std::string& file = ""); int openFileExplorer(const std::string& file = ""); + int openFileWithCommand(const std::string& file, const std::string& command); + int openBBEditor(); + int openCreaToolsTools(); + int openTerminal(); }; #endif /* CDMUTILITIES_H_ */ diff --git a/lib/creaDevManagerLib/creaDevManagerIds.h b/lib/creaDevManagerLib/creaDevManagerIds.h index 0e4b788..49193d9 100644 --- a/lib/creaDevManagerLib/creaDevManagerIds.h +++ b/lib/creaDevManagerLib/creaDevManagerIds.h @@ -91,18 +91,21 @@ #define ID_BUTTON_OPEN_COMMAND 10317 #define ID_BUTTON_SET_VERSION 10318 #define ID_BUTTON_SET_BUILD_PATH 10319 +#define ID_BUTTON_SET_AUTHOR 10320 +#define ID_BUTTON_SET_DESCRIPTION 10321 -#define ID_BUTTON_BUILD_PROJECT 10320 -#define ID_BUTTON_CONFIGURE_BUILD 10321 -#define ID_BUTTON_CONNECT_PROJECT 10322 -#define ID_BUTTON_GOTO_PACKAGE_MANAGER 10323 -#define ID_BUTTON_GOTO_APPLI_MANAGER 10324 -#define ID_BUTTON_GOTO_LIB_MANAGER 10325 +#define ID_BUTTON_BUILD_PROJECT 10322 +#define ID_BUTTON_CONFIGURE_BUILD 10323 +#define ID_BUTTON_CONNECT_PROJECT 10324 -#define ID_LINK_SELECT_PACKAGE 10326 -#define ID_LINK_SELECT_LIBRARY 10327 -#define ID_LINK_SELECT_APPLICATION 10328 -#define ID_LINK_SELECT_BLACKBOX 10329 +#define ID_BUTTON_GOTO_PACKAGE_MANAGER 10325 +#define ID_BUTTON_GOTO_APPLI_MANAGER 10326 +#define ID_BUTTON_GOTO_LIB_MANAGER 10327 + +#define ID_LINK_SELECT_PACKAGE 10328 +#define ID_LINK_SELECT_LIBRARY 10329 +#define ID_LINK_SELECT_APPLICATION 10330 +#define ID_LINK_SELECT_BLACKBOX 10331 #endif /* CREADEVMANAGERIDS_H_ */ diff --git a/lib/creaDevManagerLib/modelCDMApplication.cpp b/lib/creaDevManagerLib/modelCDMApplication.cpp index 17a660a..35a731c 100644 --- a/lib/creaDevManagerLib/modelCDMApplication.cpp +++ b/lib/creaDevManagerLib/modelCDMApplication.cpp @@ -68,9 +68,9 @@ const std::string& modelCDMApplication::GetNameApplication() const return this->nameApplication; } -const std::string& modelCDMApplication::GetMainFile() const +const std::string& modelCDMApplication::GetExecutableName() const { - return this->mainFile; + return this->executableName; } void modelCDMApplication::SetMainFile(const std::string& fileName) @@ -87,12 +87,6 @@ bool modelCDMApplication::CreateFolder( return true; } -bool modelCDMApplication::OpenCMakeListsFile(std::string*& result) -{ - //TODO: implement method - return true; -} - const bool modelCDMApplication::Refresh(std::string*& result) { //TODO: implement method diff --git a/lib/creaDevManagerLib/modelCDMApplication.h b/lib/creaDevManagerLib/modelCDMApplication.h index 2f8834b..97d3a79 100644 --- a/lib/creaDevManagerLib/modelCDMApplication.h +++ b/lib/creaDevManagerLib/modelCDMApplication.h @@ -48,7 +48,7 @@ public: ~modelCDMApplication(); const std::string& GetNameApplication() const; - const std::string& GetMainFile() const; + const std::string& GetExecutableName() const; void SetMainFile(const std::string& fileName); @@ -57,12 +57,11 @@ public: std::string*& result, const std::string& path = "/" ); - bool OpenCMakeListsFile(std::string* & result); virtual const bool Refresh(std::string*& result); private: std::string nameApplication; - std::string mainFile; + std::string executableName; std::vector applications; }; diff --git a/lib/creaDevManagerLib/modelCDMCMakeListsFile.cpp b/lib/creaDevManagerLib/modelCDMCMakeListsFile.cpp index 768ce80..2b9cb2a 100644 --- a/lib/creaDevManagerLib/modelCDMCMakeListsFile.cpp +++ b/lib/creaDevManagerLib/modelCDMCMakeListsFile.cpp @@ -37,6 +37,8 @@ #include #include +#include "CDMUtilities.h" + modelCDMCMakeListsFile::modelCDMCMakeListsFile() { } @@ -57,8 +59,14 @@ modelCDMCMakeListsFile::~modelCDMCMakeListsFile() bool modelCDMCMakeListsFile::OpenFile(std::string*& result) { - //TODO: implement method - return true; + + if (!CDMUtilities::openTextEditor(this->path)) + return true; + else + { + result = new std::string("Couldn't open CMakeLists file."); + return false; + } } const bool modelCDMCMakeListsFile::Refresh(std::string*& result) diff --git a/lib/creaDevManagerLib/modelCDMFile.cpp b/lib/creaDevManagerLib/modelCDMFile.cpp index 8e8a40f..6767b98 100644 --- a/lib/creaDevManagerLib/modelCDMFile.cpp +++ b/lib/creaDevManagerLib/modelCDMFile.cpp @@ -69,14 +69,36 @@ modelCDMFile::~modelCDMFile() { } -bool modelCDMFile::OpenFile(std::string*& result) +bool modelCDMFile::OpenFile(std::string*& result, const std::string& command) { - //TODO: implement method + if (!CDMUtilities::openFileWithCommand(path, command)) return true; + else + { + result = new std::string("Couldn't open file with command " + command + "."); + return false; + } } const bool modelCDMFile::Refresh(std::string*& result) { - //TODO: implement method + std::ifstream in((this->path).c_str()); + if(!in.is_open()) + { + in.close(); + return false; + } + return true; +} + +const bool modelCDMFile::OpenInFileExplorer(std::string*& result) const +{ + std::string pth = this->path.substr(0, path.size() - name.size() - 1); + if (!CDMUtilities::openFileExplorer(pth)) return true; + else + { + result = new std::string("Couldn't open file."); + return false; + } } diff --git a/lib/creaDevManagerLib/modelCDMFile.h b/lib/creaDevManagerLib/modelCDMFile.h index a74990a..228447f 100644 --- a/lib/creaDevManagerLib/modelCDMFile.h +++ b/lib/creaDevManagerLib/modelCDMFile.h @@ -47,8 +47,9 @@ public: modelCDMFile(const std::string& path, const int& level = 3); ~modelCDMFile(); - bool OpenFile(std::string* & result); + bool OpenFile(std::string* & result, const std::string& command = ""); virtual const bool Refresh(std::string*& result); + const bool OpenInFileExplorer(std::string*& result) const; }; #endif /* MODELCDMFILE_H_ */ diff --git a/lib/creaDevManagerLib/modelCDMLibrary.cpp b/lib/creaDevManagerLib/modelCDMLibrary.cpp index 66f8ee4..d5b4efb 100644 --- a/lib/creaDevManagerLib/modelCDMLibrary.cpp +++ b/lib/creaDevManagerLib/modelCDMLibrary.cpp @@ -77,12 +77,6 @@ bool modelCDMLibrary::CreateFolder( return true; } -bool modelCDMLibrary::OpenCMakeListsFile(std::string*& result) -{ - //TODO: implement method - return true; -} - const bool modelCDMLibrary::Refresh(std::string*& result) { //TODO: implement method diff --git a/lib/creaDevManagerLib/modelCDMLibrary.h b/lib/creaDevManagerLib/modelCDMLibrary.h index 2e5adce..9f19def 100644 --- a/lib/creaDevManagerLib/modelCDMLibrary.h +++ b/lib/creaDevManagerLib/modelCDMLibrary.h @@ -54,7 +54,6 @@ public: std::string*& result, const std::string& path = "/" ); - bool OpenCMakeListsFile(std::string*& result); virtual const bool Refresh(std::string*& result); private: diff --git a/lib/creaDevManagerLib/modelCDMPackage.cpp b/lib/creaDevManagerLib/modelCDMPackage.cpp index d2d6e12..9ec218a 100644 --- a/lib/creaDevManagerLib/modelCDMPackage.cpp +++ b/lib/creaDevManagerLib/modelCDMPackage.cpp @@ -34,6 +34,8 @@ #include "modelCDMPackage.h" +#include + #include "creaWx.h" #include "wx/dir.h" #include "CDMUtilities.h" @@ -46,13 +48,83 @@ modelCDMPackage::modelCDMPackage(const std::string& path, const int& level) { this->type = wxDIR_DIRS; //Get Package Name + + //TODO: set pathMakeLists for windows + std::string pathMakeLists = path + "/CMakeLists.txt"; + + std::ifstream confFile; + confFile.open((pathMakeLists).c_str()); + + std::string word; + while(confFile.is_open() && !confFile.eof()) + { + //get sets + std::getline(confFile,word,'('); + std::vector wordBits; + CDMUtilities::splitter::split(wordBits,word," (\n",CDMUtilities::splitter::no_empties); + + if(wordBits[wordBits.size()-1] == "SET") + { + //get package name + std::getline(confFile,word,')'); + CDMUtilities::splitter::split(wordBits, word, " ", CDMUtilities::splitter::no_empties); + if(wordBits[0] == "BBTK_PACKAGE_NAME") + { + word = wordBits[1]; + for (int i = 2; i < wordBits.size(); i++) + { + word += " " + wordBits[i]; + } + wordBits.clear(); + CDMUtilities::splitter::split(wordBits, word, "\"", CDMUtilities::splitter::no_empties); + + this->namePackage = wordBits[0]; + } + else if(wordBits[0] == "${BBTK_PACKAGE_NAME}_AUTHOR") + { + word = wordBits[1]; + for (int i = 2; i < wordBits.size(); i++) + { + word += " " + wordBits[i]; + } + wordBits.clear(); + CDMUtilities::splitter::split(wordBits, word, "\"", CDMUtilities::splitter::no_empties); + + this->authors = wordBits[0]; + } + else if(wordBits[0] == "${BBTK_PACKAGE_NAME}_DESCRIPTION") + { + word = wordBits[1]; + for (int i = 2; i < wordBits.size(); i++) + { + word += " " + wordBits[i]; + } + wordBits.clear(); + CDMUtilities::splitter::split(wordBits, word, "\"", CDMUtilities::splitter::no_empties); + + this->description = wordBits[0]; + } + else if(wordBits[0] == "${BBTK_PACKAGE_NAME}_MAJOR_VERSION") + { + this->version = wordBits[1]; + } + else if(wordBits[0] == "${BBTK_PACKAGE_NAME}_MINOR_VERSION") + { + this->version += "." + wordBits[1]; + } + else if(wordBits[0] == "${BBTK_PACKAGE_NAME}_BUILD_VERSION") + { + this->version += "." + wordBits[1]; + } + } + } + std::vector words; std::string delimiters; //TODO::fix for windows delimiters = "/"; CDMUtilities::splitter::split(words, path, delimiters, CDMUtilities::splitter::no_empties); this->name = words[words.size()-1]; - this->namePackage = this->name; this->level = level; this->path = path; @@ -154,7 +226,47 @@ const std::vector& modelCDMPackage::GetBlackBoxes() const bool modelCDMPackage::SetAuthors(const std::string& authors, std::string*& result) { - //TODO: implement method + std::vector words; + CDMUtilities::splitter::split(words, authors, ",\n", CDMUtilities::splitter::no_empties); + std::string authorsReal = words[0]; + for (int i = 1; i < words.size(); i++) + { + authorsReal += "/" + words[i]; + } + + std::string line; + //opening original cmakelists + std::ifstream in((this->path + "/CMakeLists.txt").c_str()); + if( !in.is_open()) + { + result = new std::string("CMakeLists.txt file failed to open."); + return false; + } + //opening temporal cmakelists + std::ofstream out((this->path + "/CMakeLists.txt.tmp").c_str()); + if( !out.is_open()) + { + result = new std::string("CMakeLists.txt.tmp file failed to open."); + return false; + } + //copying contents from original to temporal and making changes + while (getline(in, line)) + { + if(line.find("SET(${BBTK_PACKAGE_NAME}_AUTHOR") != std::string::npos) + line = "SET(${BBTK_PACKAGE_NAME}_AUTHOR \"" + authorsReal + "\")"; + out << line << std::endl; + } + in.close(); + out.close(); + //delete old file and rename new file + std::string renameCommand = "mv " + this->path + "/CMakeLists.txt.tmp " + this->path + "/CMakeLists.txt"; + if(system(renameCommand.c_str())) + { + result = new std::string("An error occurred while running '" + renameCommand + "'."); + return false; + } + + this->authors = authorsReal; return true; } @@ -166,13 +278,93 @@ bool modelCDMPackage::SetAuthorsEmail(const std::string& email, std::string*& re bool modelCDMPackage::SetVersion(const std::string& version, std::string*& result) { - //TODO: implement method + std::vector vers; + CDMUtilities::splitter::split(vers, version, " .", CDMUtilities::splitter::no_empties); + + + std::string line; + //opening original cmakelists + std::ifstream in((this->path + "/CMakeLists.txt").c_str()); + if( !in.is_open()) + { + result = new std::string("CMakeLists.txt file failed to open."); + return false; + } + //opening temporal cmakelists + std::ofstream out((this->path + "/CMakeLists.txt.tmp").c_str()); + if( !out.is_open()) + { + result = new std::string("CMakeLists.txt.tmp file failed to open."); + return false; + } + //copying contents from original to temporal and making changes + while (getline(in, line)) + { + if(line.find("SET(${BBTK_PACKAGE_NAME}_MAJOR_VERSION") != std::string::npos) + line = "SET(${BBTK_PACKAGE_NAME}_MAJOR_VERSION " + vers[0] + ")"; + else if(line.find("SET(${BBTK_PACKAGE_NAME}_VERSION") != std::string::npos) + line = "SET(${BBTK_PACKAGE_NAME}_MINOR_VERSION " + vers[1] + ")"; + else if(line.find("SET(${BBTK_PACKAGE_NAME}_BUILD_VERSION") != std::string::npos) + line = "SET(${BBTK_PACKAGE_NAME}_BUILD_VERSION " + vers[2] + ")"; + out << line << std::endl; + } + in.close(); + out.close(); + //delete old file and rename new file + std::string renameCommand = "mv " + this->path + "/CMakeLists.txt.tmp " + this->path + "/CMakeLists.txt"; + if(system(renameCommand.c_str())) + { + result = new std::string("An error occurred while running '" + renameCommand + "'."); + return false; + } + + this->version = vers[0] + "." + vers[1] + "." + vers[2]; return true; } bool modelCDMPackage::SetDescription(const std::string& description, std::string*& result) { - //TODO: implement method + std::vector words; + CDMUtilities::splitter::split(words, description, " \n", CDMUtilities::splitter::no_empties); + std::string descriptionReal = words[0]; + for (int i = 1; i < words.size(); i++) + { + descriptionReal += " " + words[i]; + } + + std::string line; + //opening original cmakelists + std::ifstream in((this->path + "/CMakeLists.txt").c_str()); + if( !in.is_open()) + { + result = new std::string("CMakeLists.txt file failed to open."); + return false; + } + //opening temporal cmakelists + std::ofstream out((this->path + "/CMakeLists.txt.tmp").c_str()); + if( !out.is_open()) + { + result = new std::string("CMakeLists.txt.tmp file failed to open."); + return false; + } + //copying contents from original to temporal and making changes + while (getline(in, line)) + { + if(line.find("SET(${BBTK_PACKAGE_NAME}_DESCRIPTION") != std::string::npos) + line = "SET(${BBTK_PACKAGE_NAME}_DESCRIPTION \"" + descriptionReal + "\")"; + out << line << std::endl; + } + in.close(); + out.close(); + //delete old file and rename new file + std::string renameCommand = "mv " + this->path + "/CMakeLists.txt.tmp " + this->path + "/CMakeLists.txt"; + if(system(renameCommand.c_str())) + { + result = new std::string("An error occurred while running '" + renameCommand + "'."); + return false; + } + + this->description = descriptionReal; return true; } @@ -188,12 +380,6 @@ bool modelCDMPackage::CreateBlackBox( return true; } -bool modelCDMPackage::OpenCMakeListsFile(std::string*& result) -{ - //TODO: implement method - return true; -} - const bool modelCDMPackage::Refresh(std::string*& result) { //TODO: implement method diff --git a/lib/creaDevManagerLib/modelCDMPackage.h b/lib/creaDevManagerLib/modelCDMPackage.h index 66d86c7..632b2ef 100644 --- a/lib/creaDevManagerLib/modelCDMPackage.h +++ b/lib/creaDevManagerLib/modelCDMPackage.h @@ -68,7 +68,6 @@ public: const std::string& categories = "empty", const std::string& description = "no description" ); - bool OpenCMakeListsFile(std::string*& result); virtual const bool Refresh(std::string*& result); private: diff --git a/lib/creaDevManagerLib/wxCDMApplicationDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMApplicationDescriptionPanel.cpp index 03142d0..44ee9b1 100644 --- a/lib/creaDevManagerLib/wxCDMApplicationDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMApplicationDescriptionPanel.cpp @@ -105,11 +105,11 @@ void wxCDMApplicationDescriptionPanel::CreateControls() wxFlexGridSizer* propertiesGridSizer = new wxFlexGridSizer(4, 2, 9, 15); - wxStaticText *pMainFile = new wxStaticText(propertiesPanel, -1, wxT("Main File")); + wxStaticText *pMainFile = new wxStaticText(propertiesPanel, -1, wxT("Executable Name")); wxBoxSizer* pMainFilesz = new wxBoxSizer(wxHORIZONTAL); - wxStaticText* pMainFiletc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->application->GetMainFile())); - wxButton* pMainFilebt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Choose")); - pMainFilebt->SetToolTip(wxT("Choose the main file for the application.")); + wxStaticText* pMainFiletc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->application->GetExecutableName())); + wxButton* pMainFilebt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Set")); + pMainFilebt->SetToolTip(wxT("Set the name of the executable file for the application.")); pMainFilesz->Add(pMainFiletc, 0, wxALIGN_CENTER_VERTICAL, 0); pMainFilesz->Add(pMainFilebt, 0, wxALIGN_CENTER | wxLEFT, 10); @@ -139,6 +139,8 @@ void wxCDMApplicationDescriptionPanel::CreateControls() createFolderbt->SetToolTip(wxT("Create a new Folder inside the application folder.")); wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File")); 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("Open Application Folder")); openFolderbt->SetToolTip(wxT("Open the application folder in the file explorer.")); @@ -183,14 +185,54 @@ void wxCDMApplicationDescriptionPanel::OnBtnCreateFolder(wxCommandEvent& event) void wxCDMApplicationDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event) { - //TODO: implement method - std::cerr << "Event OnBtnEditCMakeLists not implemented" << std::endl; + std::string* result; + if(!this->application->OpenCMakeListsFile(result)) + wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR); + + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + + if(this->application->GetCMakeLists() != NULL) + { + int CMId = this->application->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + event.Skip(); } void wxCDMApplicationDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event) { - //TODO: implement method - std::cerr << "Event OnBtnOpenFolder not implemented" << std::endl; + std::string* result; + if(!this->application->OpenInFileExplorer(result)) + wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR); +} + +void wxCDMApplicationDescriptionPanel::OnCMakeMouseEnter(wxMouseEvent& event) +{ + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED); + + if(this->application->GetCMakeLists() != NULL) + { + int CMId = this->application->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + event.Skip(); +} + +void wxCDMApplicationDescriptionPanel::OnCMakeMouseExit(wxMouseEvent& event) +{ + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + + if(this->application->GetCMakeLists() != NULL) + { + int CMId = this->application->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } event.Skip(); } diff --git a/lib/creaDevManagerLib/wxCDMApplicationDescriptionPanel.h b/lib/creaDevManagerLib/wxCDMApplicationDescriptionPanel.h index 7611d5b..fbb0a24 100644 --- a/lib/creaDevManagerLib/wxCDMApplicationDescriptionPanel.h +++ b/lib/creaDevManagerLib/wxCDMApplicationDescriptionPanel.h @@ -78,6 +78,8 @@ protected: void OnBtnCreateFolder(wxCommandEvent& event); void OnBtnEditCMakeLists(wxCommandEvent& event); void OnBtnOpenFolder(wxCommandEvent& event); + void OnCMakeMouseEnter(wxMouseEvent& event); + void OnCMakeMouseExit(wxMouseEvent& event); }; diff --git a/lib/creaDevManagerLib/wxCDMCMakeListsDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMCMakeListsDescriptionPanel.cpp index 719426a..ac7172d 100644 --- a/lib/creaDevManagerLib/wxCDMCMakeListsDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMCMakeListsDescriptionPanel.cpp @@ -128,14 +128,14 @@ void wxCDMCMakeListsDescriptionPanel::OnBtnReturn(wxCommandEvent& event) void wxCDMCMakeListsDescriptionPanel::OnBtnOpenInEditor(wxCommandEvent& event) { - //TODO: implement method - std::cerr << "Event OnBtnOpenInEditor not implemented" << std::endl; - event.Skip(); + std::string* result; + if(!this->cMakeLists->OpenFile(result)) + wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR); } void wxCDMCMakeListsDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event) { - //TODO: implement method - std::cerr << "Event OnBtnOpenFolder not implemented" << std::endl; - event.Skip(); + std::string* result; + if(!this->cMakeLists->OpenInFileExplorer(result)) + wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR); } diff --git a/lib/creaDevManagerLib/wxCDMFileDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMFileDescriptionPanel.cpp index 4f48a4f..001bb2a 100644 --- a/lib/creaDevManagerLib/wxCDMFileDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMFileDescriptionPanel.cpp @@ -43,8 +43,8 @@ BEGIN_EVENT_TABLE(wxCDMFileDescriptionPanel, wxPanel) EVT_BUTTON(ID_BUTTON_PREV, wxCDMFileDescriptionPanel::OnBtnReturn) -EVT_MENU(ID_BUTTON_OPEN_FOLDER, wxCDMFileDescriptionPanel::OnBtnOpenFolder) -EVT_MENU(ID_BUTTON_OPEN_COMMAND, wxCDMFileDescriptionPanel::OnBtnOpenWithCommand) +EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMFileDescriptionPanel::OnBtnOpenFolder) +EVT_BUTTON(ID_BUTTON_OPEN_COMMAND, wxCDMFileDescriptionPanel::OnBtnOpenWithCommand) END_EVENT_TABLE() wxCDMFileDescriptionPanel::wxCDMFileDescriptionPanel( @@ -162,14 +162,24 @@ void wxCDMFileDescriptionPanel::OnBtnReturn(wxCommandEvent& event) void wxCDMFileDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event) { - //TODO: implement method - std::cerr << "Event OnBtnOpenContainingFolder not implemented" << std::endl; - event.Skip(); + std::string* result; + if(!this->file->OpenInFileExplorer(result)) + wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR); } void wxCDMFileDescriptionPanel::OnBtnOpenWithCommand(wxCommandEvent& event) { - //TODO: implement method - std::cerr << "Event OnBtnOpenWithCommand not implemented" << std::endl; - event.Skip(); + //get command + wxString commandEx = wxGetTextFromUser( + _T("Enter the command to execute file"), + _T("Execute File - creaDevManager"), + _T("") + ); + //check name + if(commandEx.Len() > 0) + { + std::string* result; + if(!this->file->OpenFile(result, crea::wx2std(commandEx))) + wxMessageBox(crea::std2wx(*result),_T("Execute File - Error!"),wxOK | wxICON_ERROR); + } } diff --git a/lib/creaDevManagerLib/wxCDMFileDescriptionPanel.h b/lib/creaDevManagerLib/wxCDMFileDescriptionPanel.h index 38f50da..dd4e366 100644 --- a/lib/creaDevManagerLib/wxCDMFileDescriptionPanel.h +++ b/lib/creaDevManagerLib/wxCDMFileDescriptionPanel.h @@ -68,6 +68,7 @@ public: void CreateControls(); + private: modelCDMFile* file; diff --git a/lib/creaDevManagerLib/wxCDMFolderDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMFolderDescriptionPanel.cpp index d27bca0..7ac3841 100644 --- a/lib/creaDevManagerLib/wxCDMFolderDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMFolderDescriptionPanel.cpp @@ -41,8 +41,8 @@ BEGIN_EVENT_TABLE(wxCDMFolderDescriptionPanel, wxPanel) EVT_BUTTON(ID_BUTTON_PREV, wxCDMFolderDescriptionPanel::OnBtnReturn) -EVT_MENU(ID_BUTTON_OPEN_FOLDER, wxCDMFolderDescriptionPanel::OnBtnOpenInExplorer) -EVT_MENU(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMFolderDescriptionPanel::OnBtnEditCMakeLists) +EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMFolderDescriptionPanel::OnBtnOpenInExplorer) +EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMFolderDescriptionPanel::OnBtnEditCMakeLists) END_EVENT_TABLE() wxCDMFolderDescriptionPanel::wxCDMFolderDescriptionPanel( @@ -109,6 +109,8 @@ void wxCDMFolderDescriptionPanel::CreateControls() { wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File")); editCMakebt->SetToolTip(wxT("Open the CMakeLists.txt file in this folder with the default text editor.")); + editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMFolderDescriptionPanel::OnCMakeMouseEnter,NULL,this); + editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMFolderDescriptionPanel::OnCMakeMouseExit,NULL,this); actionsPanelSizer->Add(editCMakebt, 0, wxALL, 5); } @@ -132,14 +134,52 @@ void wxCDMFolderDescriptionPanel::OnBtnReturn(wxCommandEvent& event) void wxCDMFolderDescriptionPanel::OnBtnOpenInExplorer(wxCommandEvent& event) { - //TODO: implement method - std::cerr << "Event OnBtnOpenInExplorer not implemented" << std::endl; - event.Skip(); + std::string* result; + if(!this->folder->OpenInFileExplorer(result)) + wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR); } void wxCDMFolderDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event) { - //TODO: implement method - std::cerr << "Event OnBtnEditCMakeLists not implemented" << std::endl; + std::string* result; + if(!this->folder->OpenCMakeListsFile(result)) + wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR); + + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + + if(this->folder->GetCMakeLists() != NULL) + { + int CMId = this->folder->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } +} + +void wxCDMFolderDescriptionPanel::OnCMakeMouseEnter(wxMouseEvent& event) +{ + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED); + + if(this->folder->GetCMakeLists() != NULL) + { + int CMId = this->folder->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + event.Skip(); +} + +void wxCDMFolderDescriptionPanel::OnCMakeMouseExit(wxMouseEvent& event) +{ + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + + if(this->folder->GetCMakeLists() != NULL) + { + int CMId = this->folder->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } event.Skip(); } diff --git a/lib/creaDevManagerLib/wxCDMFolderDescriptionPanel.h b/lib/creaDevManagerLib/wxCDMFolderDescriptionPanel.h index d5c5685..514984e 100644 --- a/lib/creaDevManagerLib/wxCDMFolderDescriptionPanel.h +++ b/lib/creaDevManagerLib/wxCDMFolderDescriptionPanel.h @@ -77,6 +77,9 @@ protected: void OnBtnEditCMakeLists(wxCommandEvent& event); void OnBtnOpenInExplorer(wxCommandEvent& event); + void OnCMakeMouseEnter(wxMouseEvent& event); + void OnCMakeMouseExit(wxMouseEvent& event); + }; #endif /* WXCDMLIBDESCRIPTIONPANEL_H_ */ diff --git a/lib/creaDevManagerLib/wxCDMLibraryDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMLibraryDescriptionPanel.cpp index 38c67cc..61cec4d 100644 --- a/lib/creaDevManagerLib/wxCDMLibraryDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMLibraryDescriptionPanel.cpp @@ -111,6 +111,8 @@ void wxCDMLibraryDescriptionPanel::CreateControls() actionsPanelSizer->Add(createFolderbt, 0, wxALL, 5); wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File")); editCMakebt->SetToolTip(wxT("Edit the CMakeLists.txt of this library in the default text editor.")); + editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibraryDescriptionPanel::OnCMakeMouseEnter,NULL,this); + editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibraryDescriptionPanel::OnCMakeMouseExit,NULL,this); actionsPanelSizer->Add(editCMakebt, 0, wxALL, 5); wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Library Folder")); openFolderbt->SetToolTip(wxT("Open the library folder in the file explorer.")); @@ -150,15 +152,54 @@ void wxCDMLibraryDescriptionPanel::OnBtnCreateFolder(wxCommandEvent& event) void wxCDMLibraryDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event) { - //TODO: implement method - std::cerr << "Event OnBtnEditCMakeLists not implemented" << std::endl; + std::string* result; + if(!this->library->OpenCMakeListsFile(result)) + wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR); + + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + + if(this->library->GetCMakeLists() != NULL) + { + int CMId = this->library->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + + event.Skip(); +} + +void wxCDMLibraryDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event) +{ + std::string* result; + if(!this->library->OpenInFileExplorer(result)) + wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR); +} + +void wxCDMLibraryDescriptionPanel::OnCMakeMouseEnter(wxMouseEvent& event) +{ + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED); + + if(this->library->GetCMakeLists() != NULL) + { + int CMId = this->library->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } event.Skip(); } -void -wxCDMLibraryDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event) +void wxCDMLibraryDescriptionPanel::OnCMakeMouseExit(wxMouseEvent& event) { - //TODO: implement method - std::cerr << "Event OnBtnOpenFolder not implemented" << std::endl; + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + + if(this->library->GetCMakeLists() != NULL) + { + int CMId = this->library->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } event.Skip(); } diff --git a/lib/creaDevManagerLib/wxCDMLibraryDescriptionPanel.h b/lib/creaDevManagerLib/wxCDMLibraryDescriptionPanel.h index 8ae6abd..37c0ff2 100644 --- a/lib/creaDevManagerLib/wxCDMLibraryDescriptionPanel.h +++ b/lib/creaDevManagerLib/wxCDMLibraryDescriptionPanel.h @@ -78,6 +78,8 @@ protected: void OnBtnCreateFolder(wxCommandEvent& event); void OnBtnEditCMakeLists(wxCommandEvent& event); void OnBtnOpenFolder(wxCommandEvent& event); + void OnCMakeMouseEnter(wxMouseEvent& event); + void OnCMakeMouseExit(wxMouseEvent& event); }; diff --git a/lib/creaDevManagerLib/wxCDMMainFrame.cpp b/lib/creaDevManagerLib/wxCDMMainFrame.cpp index 1484059..dc2843e 100755 --- a/lib/creaDevManagerLib/wxCDMMainFrame.cpp +++ b/lib/creaDevManagerLib/wxCDMMainFrame.cpp @@ -579,21 +579,31 @@ void wxCDMMainFrame::OnMenuBBTKGraphicalEditor(wxCommandEvent& event) { std::cerr << "Event OnMenuBBTKGraphicalEditor not implemented" << std::endl; event.Skip(); + if(CDMUtilities::openBBEditor()) + { + wxMessageBox( wxT("Can't open the BB Graphical Editor. Please check your Crea Tools installation."), wxT("Refresh Project - Error"), wxICON_ERROR); + } } void wxCDMMainFrame::OnMenuMiniTools(wxCommandEvent& event) { - std::cerr << "Event OnMenuMiniTools not implemented" << std::endl; - event.Skip(); + if(CDMUtilities::openCreaToolsTools()) + { + wxMessageBox( wxT("Can't open the Minitools. Please check your Crea Tools installation."), wxT("Refresh Project - Error"), wxICON_ERROR); + } } void wxCDMMainFrame::OnMenuCodeEditor(wxCommandEvent& event) { - std::cerr << "Event OnMenuCodeEditor not implemented" << std::endl; - event.Skip(); + if(CDMUtilities::openTextEditor()) + { + wxMessageBox( wxT("Can't open the Text Editor. Please check the default text editor command in the Crea Development Manager settings (Edit -> Settings)."), wxT("Refresh Project - Error"), wxICON_ERROR); + } } void wxCDMMainFrame::OnMenuCommandLine(wxCommandEvent& event) { - std::cerr << "Event OnMenuCommandLine not implemented" << std::endl; - event.Skip(); + if(CDMUtilities::openTerminal()) + { + wxMessageBox( wxT("Can't open Terminal. Please check the default terminal command in the Crea Development Manager settings (Edit -> Settings)."), wxT("Refresh Project - Error"), wxICON_ERROR); + } } //Help Menu diff --git a/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp index d32ed86..99367d7 100644 --- a/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.cpp @@ -39,8 +39,14 @@ #include "creaDevManagerIds.h" #include "images/PkIcon64.xpm" +#include +#include "CDMUtilities.h" + BEGIN_EVENT_TABLE(wxCDMPackageDescriptionPanel, wxPanel) EVT_BUTTON(ID_BUTTON_PREV, wxCDMPackageDescriptionPanel::OnBtnReturn) +EVT_BUTTON(ID_BUTTON_SET_AUTHOR, wxCDMPackageDescriptionPanel::OnBtnSetAuthor) +EVT_BUTTON(ID_BUTTON_SET_VERSION, wxCDMPackageDescriptionPanel::OnBtnSetVersion) +EVT_BUTTON(ID_BUTTON_SET_DESCRIPTION, wxCDMPackageDescriptionPanel::OnBtnSetDescription) EVT_HYPERLINK(ID_LINK_SELECT_BLACKBOX, wxCDMPackageDescriptionPanel::OnLnkBlackBoxSelect) EVT_BUTTON(ID_BUTTON_CREATE_BLACKBOX, wxCDMPackageDescriptionPanel::OnBtnCreateBlackBox) EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMPackageDescriptionPanel::OnBtnEditCMakeLists) @@ -110,26 +116,26 @@ void wxCDMPackageDescriptionPanel::CreateControls() // author wxBoxSizer* pAuthorsz = new wxBoxSizer(wxHORIZONTAL); - wxStaticText* pAuthortc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->package->GetAuthors())); - wxButton* pAuthorbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Change")); + this->authortc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->package->GetAuthors())); + wxButton* pAuthorbt = new wxButton(propertiesPanel, ID_BUTTON_SET_AUTHOR, wxT("Change")); pAuthorbt->SetToolTip(wxT("Update the author/s of the package.")); - pAuthorsz->Add(pAuthortc, 0, wxALIGN_CENTER_VERTICAL, 0); + pAuthorsz->Add(this->authortc, 1, wxALIGN_CENTER_VERTICAL); pAuthorsz->Add(pAuthorbt, 0, wxALIGN_CENTER | wxLEFT, 10); // version wxBoxSizer* pVersionsz = new wxBoxSizer(wxHORIZONTAL); - wxStaticText* pVersiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->package->GetVersion())); + this->versiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->package->GetVersion())); wxButton* pVersionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Set")); pVersionbt->SetToolTip(wxT("Update the version of the package.")); - pVersionsz->Add(pVersiontc, 0, wxALIGN_CENTER_VERTICAL, 0); + pVersionsz->Add(this->versiontc, 1, wxALIGN_CENTER_VERTICAL); pVersionsz->Add(pVersionbt, 0, wxALIGN_CENTER | wxLEFT, 10); // description wxBoxSizer* pDescriptionsz = new wxBoxSizer(wxHORIZONTAL); - wxStaticText* pDescriptiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->package->GetDescription())); - wxButton* pDescriptionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Change")); + this->descriptiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->package->GetDescription())); + wxButton* pDescriptionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_DESCRIPTION, wxT("Change")); pDescriptionbt->SetToolTip(wxT("Update the description of the project.")); - pDescriptionsz->Add(pDescriptiontc, 0, wxALIGN_CENTER_VERTICAL, 0); + pDescriptionsz->Add(this->descriptiontc, 1, wxALIGN_CENTER_VERTICAL); pDescriptionsz->Add(pDescriptionbt, 0, wxALIGN_CENTER | wxLEFT, 10); propertiesGridSizer->Add(pAuthor, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); @@ -139,10 +145,12 @@ void wxCDMPackageDescriptionPanel::CreateControls() propertiesGridSizer->Add(pDescription, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); propertiesGridSizer->Add(pDescriptionsz, 1, wxEXPAND); + propertiesGridSizer->AddGrowableCol(1,1); + propertiesPanelSizer -> Add(propertiesGridSizer, 1, wxEXPAND); propertiesPanel->SetSizer(propertiesPanelSizer); propertiesPanelSizer->Fit(propertiesPanel); - propertiesBox->Add(propertiesPanel, 0, wxALL, 5); + propertiesBox->Add(propertiesPanel, 0, wxEXPAND | wxALL, 5); sizer->Add(propertiesBox, 0, wxEXPAND | wxALL, 10); @@ -204,6 +212,83 @@ void wxCDMPackageDescriptionPanel::OnBtnReturn(wxCommandEvent& event) wxPostEvent(this->GetParent(), *newEvent); } +void wxCDMPackageDescriptionPanel::OnBtnSetAuthor(wxCommandEvent& event) +{ + //get author from user + wxTextEntryDialog* authDlg = new wxTextEntryDialog( + this, + wxT("Enter the new authors name. Separate each author with a '/'."), + wxT("Change Package Author - creaDevManager"), + crea::std2wx(this->package->GetAuthors()), + wxTE_MULTILINE | wxOK | wxCANCEL + ); + + if (authDlg->ShowModal() == wxID_OK) + { + std::string authorsStr = crea::wx2std(authDlg->GetValue()); + //check name + if(authorsStr.size() > 0) + { + std::string* result; + if(!this->package->SetAuthors(authorsStr, result)) + wxMessageBox(crea::std2wx(*result),_T("Change Package Author - Error!"),wxOK | wxICON_ERROR); + } + this->authortc->SetLabel(crea::std2wx(this->package->GetAuthors())); + this->authortc->GetParent()->GetSizer()->RecalcSizes(); + } + +} + +void wxCDMPackageDescriptionPanel::OnBtnSetVersion(wxCommandEvent& event) +{ + //get version + wxString versionWx = wxGetTextFromUser( + wxT("Enter the new version name"), + wxT("Change Package Version - creaDevManager"), + crea::std2wx(this->package->GetVersion()) + ); + //check name + std::vector parts; + CDMUtilities::splitter::split(parts, crea::wx2std(versionWx), " .", CDMUtilities::splitter::no_empties); + if(parts.size() == 3) + { + std::string* result; + if(!this->package->SetVersion(crea::wx2std(versionWx), result)) + wxMessageBox(crea::std2wx(*result),_T("Change Package Version - Error!"),wxOK | wxICON_ERROR); + } + else + { + wxMessageBox(crea::std2wx("The version format is incorrect, please follow the following format:\nX.Y.Z\nX: Major Version\nY: Minor Version\nZ: Build Version"),_T("Set Project Version - Error!"),wxOK | wxICON_ERROR); + } + this->versiontc->SetLabel(crea::std2wx(this->package->GetVersion())); +} + +void wxCDMPackageDescriptionPanel::OnBtnSetDescription(wxCommandEvent& event) +{ + //get author from user + wxTextEntryDialog* descDlg = new wxTextEntryDialog( + this, + wxT("Edit the package description."), + wxT("Change Package Description - creaDevManager"), + crea::std2wx(this->package->GetDescription()), + wxTE_MULTILINE | wxOK | wxCANCEL + ); + + if (descDlg->ShowModal() == wxID_OK) + { + std::string descriptionStr = crea::wx2std(descDlg->GetValue()); + //check name + if(descriptionStr.size() > 0) + { + std::string* result; + if(!this->package->SetDescription(descriptionStr, result)) + wxMessageBox(crea::std2wx(*result),_T("Change Package Description - Error!"),wxOK | wxICON_ERROR); + } + this->descriptiontc->SetLabel(crea::std2wx(this->package->GetDescription())); + this->descriptiontc->GetParent()->GetSizer()->RecalcSizes(); + } +} + void wxCDMPackageDescriptionPanel::OnLnkBlackBoxSelect(wxHyperlinkEvent& event) { int bbId = 0; @@ -238,8 +323,9 @@ void wxCDMPackageDescriptionPanel::OnBtnCreateBlackBox(wxCommandEvent& event) void wxCDMPackageDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event) { - //TODO: implement method - std::cerr << "Event OnBtnEditCMakeLists not implemented" << std::endl; + std::string* result; + if(!this->package->OpenCMakeListsFile(result)) + wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR); wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); @@ -256,9 +342,9 @@ void wxCDMPackageDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event) void wxCDMPackageDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event) { - //TODO: implement method - std::cerr << "Event OnBtnOpenFolder not implemented" << std::endl; - event.Skip(); + std::string* result; + if(!this->package->OpenInFileExplorer(result)) + wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR); } void wxCDMPackageDescriptionPanel::OnMouseEnter(wxMouseEvent& event) diff --git a/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.h b/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.h index 41c2ba5..2f9d937 100644 --- a/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.h +++ b/lib/creaDevManagerLib/wxCDMPackageDescriptionPanel.h @@ -71,18 +71,25 @@ public: private: modelCDMPackage* package; + wxStaticText* authortc; + wxStaticText* versiontc; + wxStaticText* descriptiontc; //handlers protected: void OnBtnReturn(wxCommandEvent& event); + + void OnBtnSetAuthor(wxCommandEvent& event); + void OnBtnSetVersion(wxCommandEvent& event); + void OnBtnSetDescription(wxCommandEvent& event); + void OnLnkBlackBoxSelect(wxHyperlinkEvent& event); + void OnBtnCreateBlackBox(wxCommandEvent& event); void OnBtnEditCMakeLists(wxCommandEvent& event); void OnBtnOpenFolder(wxCommandEvent& event); - void OnMouseEnter(wxMouseEvent& event); void OnMouseExit(wxMouseEvent& event); - void OnCMakeMouseEnter(wxMouseEvent& event); void OnCMakeMouseExit(wxMouseEvent& event); diff --git a/lib/creaDevManagerLib/wxCDMPackageManagerPanel.cpp b/lib/creaDevManagerLib/wxCDMPackageManagerPanel.cpp index 28b2fe1..683d4ec 100644 --- a/lib/creaDevManagerLib/wxCDMPackageManagerPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMPackageManagerPanel.cpp @@ -128,6 +128,8 @@ void wxCDMPackageManagerPanel::CreateControls() actionsPanelSizer->Add(createPkgbt, 0, wxALL, 5); wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File")); editCMakebt->SetToolTip(wxT("Edit the CMakeLists.txt file of this project.")); + editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageManagerPanel::OnCMakeMouseEnter,NULL,this); + editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMPackageManagerPanel::OnCMakeMouseExit,NULL,this); actionsPanelSizer->Add(editCMakebt, 0, wxALL, 5); actionsPanel->SetSizer(actionsPanelSizer); @@ -216,9 +218,19 @@ void wxCDMPackageManagerPanel::OnBtnCreatePackage(wxCommandEvent& event) void wxCDMPackageManagerPanel::OnBtnEditCMakeLists(wxCommandEvent& event) { - //TODO: implement method - std::cerr << "Event OnBtnCreatePackage not implemented" << std::endl; - event.Skip(); + std::string* result; + if(!this->project->OpenCMakeListsFile(result)) + wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR); + + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + + if(this->project->GetCMakeLists() != NULL) + { + int CMId = this->project->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } } void wxCDMPackageManagerPanel::OnMouseEnter(wxMouseEvent& event) @@ -262,4 +274,32 @@ void wxCDMPackageManagerPanel::OnMouseExit(wxMouseEvent& event) event.Skip(); } +void wxCDMPackageManagerPanel::OnCMakeMouseEnter(wxMouseEvent& event) +{ + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED); + + if(this->project->GetCMakeLists() != NULL) + { + int CMId = this->project->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + event.Skip(); +} + +void wxCDMPackageManagerPanel::OnCMakeMouseExit(wxMouseEvent& event) +{ + wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED); + + if(this->project->GetCMakeLists() != NULL) + { + int CMId = this->project->GetCMakeLists()->GetId(); + newEvent->SetInt(CMId); + newEvent->SetId(0); + wxPostEvent(this->GetParent(), *newEvent); + } + event.Skip(); +} + diff --git a/lib/creaDevManagerLib/wxCDMPackageManagerPanel.h b/lib/creaDevManagerLib/wxCDMPackageManagerPanel.h index 349e0d8..3ce319f 100644 --- a/lib/creaDevManagerLib/wxCDMPackageManagerPanel.h +++ b/lib/creaDevManagerLib/wxCDMPackageManagerPanel.h @@ -83,6 +83,8 @@ protected: void OnMouseEnter(wxMouseEvent& event); void OnMouseExit(wxMouseEvent& event); + void OnCMakeMouseEnter(wxMouseEvent& event); + void OnCMakeMouseExit(wxMouseEvent& event); }; #endif /* WXCDMPACKAGEMANAGERPANEL_H_ */ diff --git a/lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.cpp index 4f60890..1bc58e2 100644 --- a/lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMProjectDescriptionPanel.cpp @@ -118,25 +118,25 @@ void wxCDMProjectDescriptionPanel::CreateControls() this->versiontc = new wxStaticText(propertiesPanel, wxID_ANY, crea::std2wx(this->project->GetVersion())); wxButton* pVersionbt = new wxButton(propertiesPanel, ID_BUTTON_SET_VERSION, wxT("Set")); pVersionbt->SetToolTip(wxT("Update the version of the project.")); - pVersionsz->Add(this->versiontc, 0, wxALIGN_CENTER_VERTICAL, 0); - pVersionsz->Add(pVersionbt, 0, wxALIGN_CENTER | wxLEFT, 10); + pVersionsz->Add(this->versiontc, 1, wxALIGN_CENTER, 1); + pVersionsz->Add(pVersionbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10); // versionDate this->versionDatetc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetVersionDate())); // sourceLocation wxBoxSizer* pSourceLocationsz = new wxBoxSizer(wxHORIZONTAL); wxStaticText* pSourceLocationtc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetPath())); - pSourceLocationtc->SetMaxSize(wxSize(350,-1)); + //pSourceLocationtc->SetMaxSize(wxSize(350,-1)); wxButton* pSourceLocationbt = new wxButton(propertiesPanel, ID_BUTTON_OPEN_FOLDER, wxT("Open")); pSourceLocationbt->SetToolTip(wxT("Open the source folder in the file explorer.")); - pSourceLocationsz->Add(pSourceLocationtc, 0, wxALIGN_CENTER, 0); + pSourceLocationsz->Add(pSourceLocationtc, 1, wxALIGN_CENTER, 1); pSourceLocationsz->Add(pSourceLocationbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10); // buildLocation wxBoxSizer* pBuildLocationsz = new wxBoxSizer(wxHORIZONTAL); this->buildPathtc = new wxStaticText(propertiesPanel, -1, crea::std2wx(this->project->GetBuildPath())); - this->buildPathtc->SetMaxSize(wxSize(350,-1)); + //this->buildPathtc->SetMaxSize(wxSize(350,-1)); wxButton* pBuildLocationbt = new wxButton(propertiesPanel, ID_BUTTON_SET_BUILD_PATH, wxT("Choose")); pBuildLocationbt->SetToolTip(wxT("Select a new location for compiling the project.")); - pBuildLocationsz->Add(this->buildPathtc, 0, wxALIGN_CENTER, 0); + pBuildLocationsz->Add(this->buildPathtc, 1, wxALIGN_CENTER, 1); pBuildLocationsz->Add(pBuildLocationbt, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10); propertiesGridSizer->Add(pVersion, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); @@ -150,12 +150,12 @@ void wxCDMProjectDescriptionPanel::CreateControls() propertiesGridSizer->AddGrowableCol(1,1); - propertiesPanelSizer-> Add(propertiesGridSizer, 0, wxALL | wxEXPAND, 5); + propertiesPanelSizer-> Add(propertiesGridSizer, 1, wxALL | wxEXPAND, 5); //SetPanel sizer and box propertiesPanel->SetSizer(propertiesPanelSizer); propertiesPanelSizer->Fit(propertiesPanel); - propertiesBox->Add(propertiesPanel, 0, wxEXPAND); + propertiesBox->Add(propertiesPanel, 1, wxEXPAND); sizer->Add(propertiesBox, 0, wxEXPAND | wxALL, 10); //----------------------------------Project Actions-------------------------------------- @@ -170,7 +170,7 @@ void wxCDMProjectDescriptionPanel::CreateControls() // package manager wxButton* packageMgrbt = new wxButton(actionsPanel, ID_BUTTON_GOTO_PACKAGE_MANAGER, _T("Package Manager")); packageMgrbt->SetToolTip(wxT("Find the current available packages into this project. You can also create new Packages in this section.")); - actionsPanelSizer->Add(packageMgrbt, 0, wxALL, 5); + actionsPanelSizer->Add(packageMgrbt, 1, wxALL, 5); // lib manager // show only if there is a lib folder if(this->project->GetLib() != NULL) @@ -179,7 +179,7 @@ void wxCDMProjectDescriptionPanel::CreateControls() libMgrbt->SetToolTip(wxT("Find the current available libraries into this project. You can also create new Libraries in this section as well as edit the lib folder's CMakeLists.txt file.")); libMgrbt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnLibMouseEnter,NULL,this); libMgrbt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnLibMouseExit,NULL,this); - actionsPanelSizer->Add(libMgrbt, 0, wxALL, 5); + actionsPanelSizer->Add(libMgrbt, 1, wxALL, 5); } // appli manager // show only if there is a appli folder @@ -189,19 +189,19 @@ void wxCDMProjectDescriptionPanel::CreateControls() appliMgrbt->SetToolTip(wxT("Find the current available applications into this project. You can also create new Applications in this section as well as edit the appli folder's CMakeLists.txt file.")); appliMgrbt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnAppliMouseEnter,NULL,this); appliMgrbt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnAppliMouseExit,NULL,this); - actionsPanelSizer->Add(appliMgrbt, 0, wxALL, 5); + actionsPanelSizer->Add(appliMgrbt, 1, wxALL, 5); } // edit CMakeLists file wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("Edit CMakeLists File")); editCMakebt->SetToolTip(wxT("Edit the CMakeLists.txt file of this project.")); editCMakebt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnCMakeMouseEnter,NULL,this); editCMakebt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMProjectDescriptionPanel::OnCMakeMouseExit,NULL,this); - actionsPanelSizer->Add(editCMakebt, 0, wxALL, 5); + actionsPanelSizer->Add(editCMakebt, 1, wxALL, 5); //SetPanel sizer and box actionsPanel->SetSizer(actionsPanelSizer); actionsPanelSizer->Fit(actionsPanel); - actionsBox->Add(actionsPanel, 0, wxALL, 5); + actionsBox->Add(actionsPanel, 1, wxALL | wxEXPAND, 5); sizer->Add(actionsBox, 0, wxEXPAND | wxALL, 10); @@ -300,14 +300,10 @@ wxCDMProjectDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event) void wxCDMProjectDescriptionPanel::OnBtnSetVersion(wxCommandEvent& event) { - //TODO: implement method - std::cerr << "Event OnBtnSetVersion not implemented" << std::endl; - event.Skip(); - - //get name + //get version wxString libraryName = wxGetTextFromUser( wxT("Enter the new version name"), - wxT("New Library - creaDevManager"), + wxT("Change Project Version - creaDevManager"), crea::std2wx(this->project->GetVersion()) ); //check name