modelCDMApplication::modelCDMApplication()
{
+ mainFile = NULL;
}
modelCDMApplication::modelCDMApplication(const std::string& path, const std::string& name, const int& level)
{
std::cout << "creating application: " + path + "\n";
+ this->mainFile = NULL;
//folder name
this->name = name;
//path
//if is an unknown file, create file
else
{
- this->children.push_back(new modelCDMFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
+ modelCDMFile* file = new modelCDMFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
+ std::string extension = stdfileName.substr(stdfileName.size()-4);
+ if (mainFile == NULL && (extension == ".cxx" || extension == ".cpp"))
+ {
+ std::ifstream fileStream;
+ std::string word;
+ fileStream.open((this->path + CDMUtilities::SLASH + stdfileName).c_str());
+ while (fileStream.is_open() && !fileStream.eof())
+ {
+ //get sets
+ std::getline(fileStream,word,'(');
+ std::vector<std::string> wordBits;
+ CDMUtilities::splitter::split(wordBits,word," \n",CDMUtilities::splitter::no_empties);
+ if (wordBits[wordBits.size() - 1] == "main")
+ {
+ this->mainFile = file;
+ }
+ }
+ fileStream.close();
+ }
+ this->children.push_back(file);
}
cont = dir.GetNext(&fileName);
return this->executableName;
}
+modelCDMFile* modelCDMApplication::GetMainFile() const
+{
+ return this->mainFile;
+}
+
bool modelCDMApplication::SetExecutableName(const std::string& fileName, std::string*& result)
{
std::vector<std::string> words;
const bool modelCDMApplication::Refresh(std::string*& result)
{
+ this->mainFile = NULL;
std::cout << "refreshing application: " << this->executableName << std::endl;
//set attributes
this->type = wxDIR_DIRS;
{
found = true;
checked[i] = true;
+
if(!this->children[i]->Refresh(result))
return false;
+
+ std::string extension = stdfileName.substr(stdfileName.size()-4);
+ if (mainFile == NULL && (extension == ".cxx" || extension == ".cpp"))
+ {
+ std::ifstream fileStream;
+ std::string word;
+ fileStream.open((this->path + CDMUtilities::SLASH + stdfileName).c_str());
+ while (fileStream.is_open() && !fileStream.eof())
+ {
+ //get sets
+ std::getline(fileStream,word,'(');
+ std::vector<std::string> wordBits;
+ CDMUtilities::splitter::split(wordBits,word," \n",CDMUtilities::splitter::no_empties);
+ if (wordBits[wordBits.size() - 1] == "main")
+ {
+ this->mainFile = dynamic_cast<modelCDMFile*>(children[i]);
+ }
+ }
+ fileStream.close();
+ }
}
}
if(!found)
{
modelCDMFile* file = new modelCDMFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
+
+ std::string extension = stdfileName.substr(stdfileName.size()-4);
+ if (mainFile == NULL && (extension == ".cxx" || extension == ".cpp"))
+ {
+ std::ifstream fileStream;
+ std::string word;
+ fileStream.open((this->path + CDMUtilities::SLASH + stdfileName).c_str());
+ while (fileStream.is_open() && !fileStream.eof())
+ {
+ //get sets
+ std::getline(fileStream,word,'(');
+ std::vector<std::string> wordBits;
+ CDMUtilities::splitter::split(wordBits,word," \n",CDMUtilities::splitter::no_empties);
+ if (wordBits[wordBits.size() - 1] == "main")
+ {
+ this->mainFile = file;
+ }
+ }
+ fileStream.close();
+ }
+
this->children.push_back(file);
}
}
EVT_BUTTON(ID_BUTTON_CREATE_FOLDER, wxCDMApplicationDescriptionPanel::OnBtnCreateFolder)
EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMApplicationDescriptionPanel::OnBtnEditCMakeLists)
EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMApplicationDescriptionPanel::OnBtnOpenFolder)
+EVT_BUTTON(ID_BUTTON_OPEN_CXX, wxCDMApplicationDescriptionPanel::OnBtnOpenMain)
END_EVENT_TABLE()
wxCDMApplicationDescriptionPanel::wxCDMApplicationDescriptionPanel(
//actions Sizer
wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL);
//actionsGrid Sizer
- wxFlexGridSizer* actionsGridSizer = new wxFlexGridSizer(2, 2, 9, 15);
+ wxFlexGridSizer* actionsGridSizer = new wxFlexGridSizer(3, 2, 9, 15);
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."));
+ wxButton* openMainbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_CXX, _T("A. Open Main File (Optional)"));
+ openMainbt->SetToolTip(wxT("Open the main file in the application folder with the default code editor."));
+ openMainbt->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationDescriptionPanel::OnMainMouseEnter,NULL,this);
+ openMainbt->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMApplicationDescriptionPanel::OnMainMouseExit,NULL,this);
wxButton* editCMakebt = new wxButton(actionsPanel, ID_BUTTON_EDIT_CMAKELISTSFILE, _T("B. 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("A. Open Application Folder"));
+ wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("C. Open Application Folder"));
openFolderbt->SetToolTip(wxT("Open the application folder in the file explorer."));
- actionsGridSizer->Add(openFolderbt, 1, wxALL | wxEXPAND, 5);
+ actionsGridSizer->Add(openMainbt, 1, wxALL | wxEXPAND, 5);
actionsGridSizer->Add(editCMakebt, 1, wxALL | wxEXPAND, 5);
+ actionsGridSizer->Add(openFolderbt, 1, wxALL | wxEXPAND, 5);
actionsGridSizer->Add(createClassbt, 1, wxALL | wxEXPAND, 5);
actionsGridSizer->Add(createFolderbt, 1, wxALL | wxEXPAND, 5);
}
event.Skip();
}
+
+void wxCDMApplicationDescriptionPanel::OnBtnOpenMain(wxCommandEvent& event)
+{
+ if (this->application->GetMainFile() != NULL)
+ {
+ if (CDMUtilities::openTextEditor(this->application->GetMainFile()->GetPath()))
+ {
+ wxMessageBox(crea::std2wx("The main file couldn't be opened."),_T("Open Main File - Error!"),wxOK | wxICON_ERROR);
+ }
+
+ wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
+
+ int MId = this->application->GetMainFile()->GetId();
+ newEvent->SetInt(MId);
+ newEvent->SetId(0);
+ wxPostEvent(this->GetParent(), *newEvent);
+
+ event.Skip();
+ }
+ else
+ {
+ wxMessageBox(crea::std2wx("There is no main file or it couldn't be detected."),_T("Open Main File - Error!"),wxOK | wxICON_ERROR);
+ }
+}
+
+void wxCDMApplicationDescriptionPanel::OnMainMouseEnter(wxMouseEvent& event)
+{
+ wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED);
+
+ if(this->application->GetMainFile() != NULL)
+ {
+ int MId = this->application->GetMainFile()->GetId();
+ newEvent->SetInt(MId);
+ newEvent->SetId(0);
+ wxPostEvent(this->GetParent(), *newEvent);
+ }
+ event.Skip();
+}
+
+void wxCDMApplicationDescriptionPanel::OnMainMouseExit(wxMouseEvent& event)
+{
+ wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
+
+ if(this->application->GetMainFile() != NULL)
+ {
+ int MId = this->application->GetMainFile()->GetId();
+ newEvent->SetInt(MId);
+ newEvent->SetId(0);
+ wxPostEvent(this->GetParent(), *newEvent);
+ }
+ event.Skip();
+}