modelCDMApplication::modelCDMApplication(const std::string& path, const int& level)
{
- this->name = "application";
+ std::vector<std::string> 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->path = path;
this->type = wxDIR_DIRS;
this->level = level;
#include "modelCDMCMakeListsFile.h"
+#include<creaWx.h>
+#include<wx/dir.h>
+
modelCDMCMakeListsFile::modelCDMCMakeListsFile()
{
}
modelCDMCMakeListsFile::modelCDMCMakeListsFile(const std::string& path,
const int& level)
{
+ this->children.clear();
+ this->level = level;
+ this->type = wxDIR_FILES;
+ this->name = "CMakeFileLists.txt";
+ this->path = path;
}
modelCDMCMakeListsFile::~modelCDMCMakeListsFile()
#include "modelCDMFile.h"
+#include <creaWx.h>
+#include <wx/dir.h>
+
+#include "CDMUtilities.h"
+
modelCDMFile::modelCDMFile()
{
}
modelCDMFile::modelCDMFile(const std::string& path, const int& level)
{
+ this->children.clear();
+ this->level = level;
+
+ std::vector<std::string> 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->path = path;
+ this->type = wxDIR_FILES;
}
modelCDMFile::~modelCDMFile()
#include "modelCDMFolder.h"
+#include <creaWx.h>
+#include <wx/dir.h>
+
+#include "CDMUtilities.h"
+
modelCDMFolder::modelCDMFolder()
{
+ this->CMakeLists = NULL;
}
modelCDMFolder::modelCDMFolder(const std::string& path, const int& level)
{
+ //set attributes
+ this->children.clear();
+ this->level = level;
+ this->CMakeLists = NULL;
+
+ std::vector<std::string> 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->path = path;
+ this->type = wxDIR_DIRS;
+
+ std::string pathFixed(CDMUtilities::fixPath(path));
+ //check all folders
+ wxDir dir(crea::std2wx((pathFixed).c_str()));
+ if (dir.IsOpened())
+ {
+ wxString fileName;
+ bool cont = dir.GetFirst(&fileName, wxEmptyString, wxDIR_DIRS);
+ while (cont)
+ {
+ std::string stdfileName = crea::wx2std(fileName);
+
+ //if is an unknown folder, create folder
+ this->children.push_back(new modelCDMFolder(pathFixed + "/" + stdfileName, this->level + 1));
+
+ cont = dir.GetNext(&fileName);
+ }
+
+ cont = dir.GetFirst(&fileName, wxEmptyString, wxDIR_FILES);
+ while (cont)
+ {
+ std::string stdfileName = crea::wx2std(fileName);
+
+ //if CMakeLists, create CMakeLists
+ if(stdfileName == "CMakeLists.txt")
+ {
+ this->CMakeLists = new modelCDMCMakeListsFile(pathFixed + "/" + stdfileName, this->level + 1);
+ this->children.push_back(this->CMakeLists);
+ }
+ else
+ {
+ this->children.push_back(new modelCDMFile(pathFixed + "/" + stdfileName, this->level + 1));
+ }
+ //if is an unknown file, create file
+ cont = dir.GetNext(&fileName);
+ }
+ }
+
+ this->SortChildren();
}
modelCDMFolder::~modelCDMFolder()
{
+ for (int i = 0; i < this->children.size(); i++)
+ {
+ if(this->children[i] != NULL)
+ {
+ delete this->children[i];
+ this->children[i] = NULL;
+ }
+ }
}
bool modelCDMFolder::CreateFolder(const std::string& name, std::string*& result,
#include<vector>
#include "modelCDMIProjectTreeNode.h"
+#include "modelCDMCMakeListsFile.h"
class modelCDMFolder : public modelCDMIProjectTreeNode
{
private:
std::vector<modelCDMFolder*> folders;
+ modelCDMCMakeListsFile* CMakeLists;
};
#endif /* MODELCDMFOLDER_H_ */
modelCDMLibrary::modelCDMLibrary(const std::string& path, const int& level)
{
- this->name = "library";
+ std::vector<std::string> 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->path = path;
this->type = wxDIR_DIRS;
this->level = level;
}
}
+std::map<wxTreeItemId, modelCDMIProjectTreeNode*>& modelCDMMain::GetModelElements()
+{
+ return this->modelElements;
+}
+
bool modelCDMMain::CloseProject(
std::string*& result
)
#define MODELCDMMAIN_H_
#include<iostream>
+#include<map>
+#include<creaWx.h>
+#include<wx/treectrl.h>
+
+#include "modelCDMIProjectTreeNode.h"
#include "modelCDMProject.h"
class modelCDMMain
~modelCDMMain();
modelCDMProject* GetProject() const;
+ std::map< wxTreeItemId, modelCDMIProjectTreeNode* >& GetModelElements();
+
bool CreateProject(
const std::string& name,
std::string*& result
);
+
private:
modelCDMProject* project;
+ std::map< wxTreeItemId, modelCDMIProjectTreeNode* > modelElements;
};
#include "creaWx.h"
#include "wx/dir.h"
+#include "CDMUtilities.h"
modelCDMPackage::modelCDMPackage()
{
modelCDMPackage::modelCDMPackage(const std::string& path, const int& level)
{
this->type = wxDIR_DIRS;
- //TODO: Get Package Name
- this->name = "Package";
+ //Get Package Name
+ std::vector<std::string> 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].substr(5, words[words.size()-1].size()-9);
this->namePackage = this->name;
this->level = level;
this->path = path;
std::cout << "in constructor1" << std::endl;
this->appli = NULL;
this->lib = NULL;
+ this->CMakeLists = NULL;
}
modelCDMProject::modelCDMProject(
std::vector<std::string> nameBits;
CDMUtilities::splitter::split(nameBits, word, " ", CDMUtilities::splitter::no_empties);
- this->name = "";
+ this->name = this->nameProject = "";
for (int i = 0; i < nameBits.size(); i++)
{
if(i != 0)
this->name += " ";
this->name += nameBits[i];
}
+ this->nameProject = this->name;
}
this->type = wxDIR_DIRS;
this->level = 0;
- //TODO: implement method
- //if appli exist create Appli
+ this->children.clear();
this->appli = NULL;
- wxDir dir(crea::std2wx((pathFixed + "/appli").c_str()));
- if (dir.IsOpened())
- {
- this->appli = new modelCDMAppli(pathFixed + "/appli", this->level + 1);
- this->children.push_back(this->appli);
- }
-
- //if lib exist create Lib
this->lib = NULL;
- dir.Open(crea::std2wx((pathFixed + "/lib").c_str()));
- if (dir.IsOpened())
- {
- this->lib = new modelCDMLib(pathFixed + "/lib", this->level + 1);
- this->children.push_back(this->lib);
- }
-
- //if bbtk_* exist create Packages
this->packages.clear();
- dir.Open(crea::std2wx((pathFixed).c_str()));
+
+
+ //check all folders
+ wxDir dir(crea::std2wx((pathFixed).c_str()));
if (dir.IsOpened())
{
wxString fileName;
{
std::string stdfileName = crea::wx2std(fileName);
- if(stdfileName.size() > 9 && stdfileName.substr(0,5) == "bbtk_" && stdfileName.substr(stdfileName.size()-4,4) == "_PKG")
+ //if appli, create appli
+ if(stdfileName == "appli")
+ {
+ this->appli = new modelCDMAppli(pathFixed + "/appli", this->level + 1);
+ this->children.push_back(this->appli);
+ }
+ //if lib, create lib
+ else if(stdfileName == "lib")
+ {
+ this->lib = new modelCDMLib(pathFixed + "/lib", this->level + 1);
+ this->children.push_back(this->lib);
+ }
+ //if package , create package
+ else if(stdfileName.size() > 9 && stdfileName.substr(0,5) == "bbtk_" && stdfileName.substr(stdfileName.size()-4,4) == "_PKG")
{
modelCDMPackage* package = new modelCDMPackage(pathFixed + "/" + stdfileName, this->level + 1);
this->packages.push_back(package);
this->children.push_back(package);
}
+ //if is an unknown folder, create folder
+ else
+ {
+ this->children.push_back(new modelCDMFolder(pathFixed + "/" + stdfileName, this->level + 1));
+ }
cont = dir.GetNext(&fileName);
}
+ cont = dir.GetFirst(&fileName, wxEmptyString, wxDIR_FILES);
+ while (cont)
+ {
+ std::string stdfileName = crea::wx2std(fileName);
+
+ //if CMakeLists, create CMakeLists
+ if(stdfileName == "CMakeLists.txt")
+ {
+ this->CMakeLists = new modelCDMCMakeListsFile(pathFixed + "/" + stdfileName, this->level + 1);
+ this->children.push_back(this->CMakeLists);
+ }
+ else
+ {
+ this->children.push_back(new modelCDMFile(pathFixed + "/" + stdfileName, this->level + 1));
+ }
+ //if is an unknown file, create file
+ cont = dir.GetNext(&fileName);
+ }
}
+
this->SortChildren();
}
modelCDMProject::~modelCDMProject()
{
- if(this->appli != NULL)
- {
- delete this->appli;
- this->appli = NULL;
- }
- if(this->lib != NULL)
- {
- delete this->lib;
- this->lib = NULL;
- }
- for (int i = 0; i < this->packages.size(); i++)
+ for (int i = 0; i < this->children.size(); i++)
{
- if(this->packages[i] != NULL)
+ if(this->children[i] != NULL)
{
- delete this->packages[i];
- this->packages[i] = NULL;
+ delete this->children[i];
+ this->children[i] = NULL;
}
}
}
-const std::string&
-modelCDMProject::GetName() const
+const std::string& modelCDMProject::GetNameProject() const
{
- return this->name;
+ return this->nameProject;
}
-const std::string&
-modelCDMProject::GetVersion() const
+const std::string& modelCDMProject::GetVersion() const
{
return this->version;
}
-const std::string&
-modelCDMProject::GetVersionDate() const
+const std::string& modelCDMProject::GetVersionDate() const
{
return this->versionDate;
}
-const std::string&
-modelCDMProject::GetBuildPath() const
+const std::string& modelCDMProject::GetBuildPath() const
{
return this->buildPath;
}
#include "modelCDMLib.h"
#include "modelCDMAppli.h"
#include "modelCDMPackage.h"
+#include "modelCDMCMakeListsFile.h"
class modelCDMProject : public modelCDMFolder
{
void PopulateProject();
- const std::string& GetName() const;
+ const std::string& GetNameProject() const;
const std::string& GetVersion() const;
const std::string& GetVersionDate() const;
const std::string& GetBuildPath() const;
private:
- std::string name;
+ std::string nameProject;
std::string version;
std::string versionDate;
std::string buildPath;
modelCDMLib* lib;
modelCDMAppli* appli;
std::vector<modelCDMPackage*> packages;
+ modelCDMCMakeListsFile* CMakeLists;
};
}
//populate tree control
- tree_Projects->BuildTree(this->model->GetProject());
+ tree_Projects->BuildTree(this->model->GetModelElements(),this->model->GetProject());
tree_Projects->SelectItem(this->model->GetProject()->GetId());
//change description panel
//populate tree control
- tree_Projects->BuildTree(this->model->GetProject());
+ tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
tree_Projects->SelectItem(this->model->GetProject()->GetId());
//change description panel
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->GetProject());
+ tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject());
if(this->panel_Properties != NULL)
{
}
void wxCDMMainFrame::OnMenuCloseAllProjects(wxCommandEvent& event)
{
- std::cerr << "Event OnMenuCloseAllProjects not implemented" << std::endl;
+ std::cerr << "Event OnMenuCloseAllProjects closing only one project" << std::endl;
+ std::string* result;
+ if(!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();
+ }
+ if(this->panel_ProjectActions != NULL)
+ {
+ auiManager.DetachPane(this->panel_ProjectActions);
+ this->panel_ProjectActions->Destroy();
+ }
+
+ this->panel_Properties = new wxCDMMainDescriptionPanel(
+ this,
+ ID_WINDOW_PROPERTIES,
+ wxT("Description Panel"),
+ wxDefaultPosition,
+ wxSize(300, 400),
+ 0
+ );
+
+ auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties"));
+
+ auiManager.Update();
event.Skip();
}
void wxCDMMainFrame::OnMenuExportHierarchy(wxCommandEvent& event)
void wxCDMMainFrame::OnMenuExit(wxCommandEvent& event)
{
std::cout << "Closing CreaDevManager..." << std::endl;
+ std::string* result;
+ if(!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();
+ }
+ if(this->panel_ProjectActions != NULL)
+ {
+ auiManager.DetachPane(this->panel_ProjectActions);
+ this->panel_ProjectActions->Destroy();
+ }
+
+ this->panel_Properties = new wxCDMMainDescriptionPanel(
+ this,
+ ID_WINDOW_PROPERTIES,
+ wxT("Description Panel"),
+ wxDefaultPosition,
+ wxSize(300, 400),
+ 0
+ );
Close();
event.Skip();
}
void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
{
- std::cerr << "Event OnTreeSelectionChange not implemented" << std::endl;
+ std::cout << "New Tree Selection" << std::endl;
+ //get selected element
+ wxTreeItemId elementId = event.GetItem();
+
+ //get element from model
+ modelCDMIProjectTreeNode* element = this->model->GetModelElements()[elementId];
+ std::cout << "Tree Selection: " << element->GetName() << std::endl;
+
+ //TODO get element type
+ //TODO create element description
+ //TODO delete old view
+ //TODO set new view
event.Skip();
+
}
return TRUE;
}
-void wxCDMProjectsTreeCtrl::BuildTree(modelCDMProject* projectTree)
+void wxCDMProjectsTreeCtrl::BuildTree(std::map< wxTreeItemId, modelCDMIProjectTreeNode* >& modelElements, modelCDMProject* projectTree)
{
this->DeleteAllItems();
+ modelElements.clear();
if(projectTree != NULL)
{
wxTreeItemId rootIndex;
rootIndex= this-> AddRoot(crea::std2wx(projectTree->GetName()));
projectTree->SetId(rootIndex);
+ modelElements[rootIndex] = projectTree;
std::cout << "Building TreeCtrl for " << projectTree->GetName() << std::endl;
- this->BuildTree(projectTree->GetChildren(), rootIndex);
+ this->BuildTree(projectTree->GetChildren(), modelElements, rootIndex);
this->Expand(rootIndex);
}
}
-void wxCDMProjectsTreeCtrl::BuildTree(const std::vector<modelCDMIProjectTreeNode*>& treeNodes, wxTreeItemId parent)
+void wxCDMProjectsTreeCtrl::BuildTree(const std::vector<modelCDMIProjectTreeNode*>& treeNodes, std::map< wxTreeItemId, modelCDMIProjectTreeNode* >& modelElements, wxTreeItemId parent)
{
for (int i = 0; i < treeNodes.size(); i++)
{
wxString nodeName((treeNodes[i]->GetName()).c_str(), wxConvUTF8);
parentNodeIndex = this->AppendItem(parent, nodeName);
treeNodes[i]->SetId(parentNodeIndex);
+ modelElements[parentNodeIndex] = treeNodes[i];
std::vector<modelCDMIProjectTreeNode*> innerChildren = treeNodes[i]->GetChildren();
if(innerChildren.size() > 0)
{
- this->BuildTree(innerChildren, parentNodeIndex);
+ this->BuildTree(innerChildren, modelElements, parentNodeIndex);
}
}
#include "modelCDMIProjectTreeNode.h"
#include <vector>
+#include <map>
class wxCDMProjectsTreeCtrl: public wxTreeCtrl
{
const wxString &name=_("Projects tree")
);
- void BuildTree(modelCDMProject* tree = NULL);
+ void BuildTree(std::map< wxTreeItemId, modelCDMIProjectTreeNode* >& modelElements, modelCDMProject* tree = NULL);
private:
- void BuildTree(const std::vector<modelCDMIProjectTreeNode*>& tree, wxTreeItemId parent);
+ void BuildTree(const std::vector<modelCDMIProjectTreeNode*>& tree, std::map< wxTreeItemId, modelCDMIProjectTreeNode* >& modelElements, wxTreeItemId parent);
};
#endif /* WXCDMPROJECTSTREECTRL_H_ */