#include "wxCDMProjectDescriptionPanel.h"
#include "wxCDMMainFrame.h"
+#include "wxCDMNewPackageDialog.h"
#include "creaDevManagerIds.h"
#include "images/PrIcon64.xpm"
void wxCDMProjectDescriptionPanel::OnBtnCreatePackage(wxCommandEvent& event)
{
- //TODO: implement method
- //TODO: call project to create package : use bbCreatePackage <path> <name> [author] [description]
- std::cerr << "Event OnBtnCreatePackage not implemented" << std::endl;
+ std::string* result;
+
+ wxCDMNewPackageDialog* dialog = new wxCDMNewPackageDialog(this);
+ long userResponse;
+ userResponse = dialog->ShowModal();
+
+ if(userResponse == wxID_FORWARD)
+ {
+ modelCDMIProjectTreeNode* package = this->project->CreatePackage(
+ crea::wx2std(dialog->GetPackageName()),
+ result,
+ crea::wx2std(dialog->GetPackageAuthor()),
+ crea::wx2std(dialog->GetPackageAuthorEmail()),
+ crea::wx2std(dialog->GetPackageDescription())
+ );
+ if(package == NULL)
+ {
+ std::cout << "error creating package: " << *result << std::endl;
+ wxMessageBox(crea::std2wx(*result),_T("New Package - Error!"),wxOK | wxICON_ERROR);
+ event.Skip();
+ return;
+ }
+ wxMessageBox(crea::std2wx("Package successfully created."),_T("New Package - Success!"),wxOK | wxICON_INFORMATION);
+
+ //refreshing tree and description
+ //send event instead of calling parent to avoid crashing
+
+ ((wxCDMMainFrame*)this->GetParent())->RefreshProject();
+
+ wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
+ newEvent->SetInt(package->GetId());
+ wxPostEvent(this->GetParent(), *newEvent);
+ event.Skip();
+ }
+
event.Skip();
}
void wxCDMProjectDescriptionPanel::OnBtnCreateApplication(wxCommandEvent& event)
{
- //TODO: implement method
- std::cerr << "Event OnBtnCreatePackage not implemented" << std::endl;
- event.Skip();
+ //get name
+ wxString applicationName = wxGetTextFromUser(
+ _T("Enter the new application name"),
+ _T("New Application - creaDevManager"),
+ _T("")
+ );
+ //check name
+ if(applicationName.Len() > 0)
+ {
+ std::string* result;
+ //create library
+ modelCDMIProjectTreeNode* application = this->project->CreateApplication(crea::wx2std(applicationName),result);
+ //check library created
+ if(application == NULL)
+ {
+ wxMessageBox(crea::std2wx(*result),_T("New Application - Error!"),wxOK | wxICON_ERROR);
+ event.Skip();
+ return;
+ }
+ wxMessageBox(crea::std2wx("Application successfully created."),_T("New Application - Success!"),wxOK | wxICON_INFORMATION);
+
+ //refreshing tree and description
+ //send event instead of calling parent to avoid crashing
+
+ ((wxCDMMainFrame*)this->GetParent())->RefreshProject();
+
+ wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
+ newEvent->SetInt(application->GetId());
+ wxPostEvent(this->GetParent(), *newEvent);
+ event.Skip();
+ }
}
void wxCDMProjectDescriptionPanel::OnBtnEditCMakeLists(wxCommandEvent& event)