]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/wxCDMMainFrame.cpp
open project fixed for model creation. Model not created yet
[crea.git] / lib / creaDevManagerLib / wxCDMMainFrame.cpp
index e1578f94db44b5f5e95723a688da7b8a0dbcc39d..d60b3173dc21433c11ce50cb26bd9f6e56fec003 100755 (executable)
@@ -23,7 +23,7 @@
 #  The fact that you are presently reading this means that you have had
 #  knowledge of the CeCILL-B license and that you accept its terms.
 # ------------------------------------------------------------------------ 
-*/ 
+ */
 
 
 #include "wxCDMMainFrame.h"
 
 
 BEGIN_EVENT_TABLE(wxCDMMainFrame, wxFrame)
-  EVT_MENU(ID_MENU_NEW_PROJECT, wxCDMMainFrame::OnMenuNewProject)
-  EVT_MENU(ID_MENU_OPEN_PROJECT, wxCDMMainFrame::OnMenuOpenProject)
-  EVT_MENU(ID_MENU_OPEN_RECENT, wxCDMMainFrame::OnMenuOpenRecent)
-  EVT_MENU(ID_MENU_CLOSE_PROJECT, wxCDMMainFrame::OnMenuCloseProject)
-  EVT_MENU(ID_MENU_CLOSE_ALL_PROJECTS, wxCDMMainFrame::OnMenuCloseAllProjects)
-  EVT_MENU(ID_MENU_EXPORT_HIERARCHY, wxCDMMainFrame::OnMenuExportHierarchy)
-  EVT_MENU(ID_MENU_EXIT, wxCDMMainFrame::OnMenuExit)
-  EVT_MENU(ID_MENU_REFRESH_PROJECT, wxCDMMainFrame::OnMenuRefreshProject)
-  EVT_MENU(ID_MENU_CUT, wxCDMMainFrame::OnMenuMenuCut)
-  EVT_MENU(ID_MENU_COPY, wxCDMMainFrame::OnMenuMenuCopy)
-  EVT_MENU(ID_MENU_PASTE, wxCDMMainFrame::OnMenuMenuPaste)
-  EVT_MENU(ID_MENU_DELETE, wxCDMMainFrame::OnMenuMenuDelete)
-  EVT_MENU(ID_MENU_SELECT_ALL, wxCDMMainFrame::OnMenuSelectAll)
-  EVT_MENU(ID_MENU_SELECT_NONE, wxCDMMainFrame::OnMenuSelectNone)
-  EVT_MENU(ID_MENU_EVENT_LOG, wxCDMMainFrame::OnMenuEventLog)
-  EVT_MENU(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxCDMMainFrame::OnMenuBBTKGraphicalEditor)
-  EVT_MENU(ID_MENU_MINITOOLS, wxCDMMainFrame::OnMenuMiniTools)
-  EVT_MENU(ID_MENU_CODE_EDITOR, wxCDMMainFrame::OnMenuCodeEditor)
-  EVT_MENU(ID_MENU_COMMAND_LINE, wxCDMMainFrame::OnMenuCommandLine)
-  EVT_MENU(ID_MENU_HELP, wxCDMMainFrame::OnMenuHelp)
-  EVT_MENU(ID_MENU_REPORT_BUG, wxCDMMainFrame::OnMenuReportBug)
-  EVT_MENU(ID_MENU_ABOUT_CREADEVMANAGER, wxCDMMainFrame::OnMenuAboutCreaDevManager)
-  EVT_MENU(ID_MENU_ABOUT_CREATIS, wxCDMMainFrame::OnMenuAboutCreatis)
-  EVT_BUTTON(ID_BUTTON_NEWPROJECT, wxCDMMainFrame::OnMenuNewProject)
-  EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMMainFrame::OnMenuOpenProject)
+EVT_MENU(ID_MENU_NEW_PROJECT, wxCDMMainFrame::OnMenuNewProject)
+EVT_MENU(ID_MENU_OPEN_PROJECT, wxCDMMainFrame::OnMenuOpenProject)
+EVT_MENU(ID_MENU_OPEN_RECENT, wxCDMMainFrame::OnMenuOpenRecent)
+EVT_MENU(ID_MENU_CLOSE_PROJECT, wxCDMMainFrame::OnMenuCloseProject)
+EVT_MENU(ID_MENU_CLOSE_ALL_PROJECTS, wxCDMMainFrame::OnMenuCloseAllProjects)
+EVT_MENU(ID_MENU_EXPORT_HIERARCHY, wxCDMMainFrame::OnMenuExportHierarchy)
+EVT_MENU(ID_MENU_EXIT, wxCDMMainFrame::OnMenuExit)
+EVT_MENU(ID_MENU_REFRESH_PROJECT, wxCDMMainFrame::OnMenuRefreshProject)
+EVT_MENU(ID_MENU_CUT, wxCDMMainFrame::OnMenuMenuCut)
+EVT_MENU(ID_MENU_COPY, wxCDMMainFrame::OnMenuMenuCopy)
+EVT_MENU(ID_MENU_PASTE, wxCDMMainFrame::OnMenuMenuPaste)
+EVT_MENU(ID_MENU_DELETE, wxCDMMainFrame::OnMenuMenuDelete)
+EVT_MENU(ID_MENU_SELECT_ALL, wxCDMMainFrame::OnMenuSelectAll)
+EVT_MENU(ID_MENU_SELECT_NONE, wxCDMMainFrame::OnMenuSelectNone)
+EVT_MENU(ID_MENU_EVENT_LOG, wxCDMMainFrame::OnMenuEventLog)
+EVT_MENU(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxCDMMainFrame::OnMenuBBTKGraphicalEditor)
+EVT_MENU(ID_MENU_MINITOOLS, wxCDMMainFrame::OnMenuMiniTools)
+EVT_MENU(ID_MENU_CODE_EDITOR, wxCDMMainFrame::OnMenuCodeEditor)
+EVT_MENU(ID_MENU_COMMAND_LINE, wxCDMMainFrame::OnMenuCommandLine)
+EVT_MENU(ID_MENU_HELP, wxCDMMainFrame::OnMenuHelp)
+EVT_MENU(ID_MENU_REPORT_BUG, wxCDMMainFrame::OnMenuReportBug)
+EVT_MENU(ID_MENU_ABOUT_CREADEVMANAGER, wxCDMMainFrame::OnMenuAboutCreaDevManager)
+EVT_MENU(ID_MENU_ABOUT_CREATIS, wxCDMMainFrame::OnMenuAboutCreatis)
+EVT_BUTTON(ID_BUTTON_NEWPROJECT, wxCDMMainFrame::OnMenuNewProject)
+EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMMainFrame::OnMenuOpenProject)
 END_EVENT_TABLE()
 
 wxCDMMainFrame::wxCDMMainFrame(
-  wxWindow* parent,
-  wxWindowID id,
-  const wxString& caption,
-  const wxPoint& pos,
-  const wxSize& size,
-  long style
+    wxWindow* parent,
+    wxWindowID id,
+    const wxString& caption,
+    const wxPoint& pos,
+    const wxSize& size,
+    long style
 )
 {
   Create(parent, id, caption, pos, size, style);
@@ -85,12 +85,12 @@ wxCDMMainFrame::~wxCDMMainFrame()
 }
 
 bool wxCDMMainFrame::Create(
-  wxWindow* parent,
-  wxWindowID id,
-  const wxString& caption,
-  const wxPoint& pos,
-  const wxSize& size,
-  long style
+    wxWindow* parent,
+    wxWindowID id,
+    const wxString& caption,
+    const wxPoint& pos,
+    const wxSize& size,
+    long style
 )
 {
   wxFrame::Create(parent, id, caption, pos, size, style);
@@ -168,32 +168,32 @@ void wxCDMMainFrame::CreateControls()
 
 
   tree_Projects = new wxCDMProjectsTreeCtrl(
-    this,
-    ID_TREE_PROJECTS,
-    wxDefaultPosition,
-    wxSize(300,400),
-    wxTR_HAS_BUTTONS | wxTR_AQUA_BUTTONS
+      this,
+      ID_TREE_PROJECTS,
+      wxDefaultPosition,
+      wxSize(300,400),
+      wxTR_HAS_BUTTONS | wxTR_AQUA_BUTTONS
   );
   tree_Projects->SetMinSize(wxSize(200,200));
 
   panel_Properties = new wxCDMMainDescriptionPanel(
-    this,
-    ID_WINDOW_PROPERTIES,
-    wxT("Description Panel"),
-    wxDefaultPosition,
-    wxSize(300, 400),
-    0
+      this,
+      ID_WINDOW_PROPERTIES,
+      wxT("Description Panel"),
+      wxDefaultPosition,
+      wxSize(300, 400),
+      0
   );
 
 
 
   panel_ProjectActions = new wxCDMProjectActionsPanel(
-    this,
-    ID_WINDOW_PROJ_ACTIONS,
-    wxT("Project Actions Panel"),
-    wxDefaultPosition,
-    wxSize(600,200),
-    0
+      this,
+      ID_WINDOW_PROJ_ACTIONS,
+      wxT("Project Actions Panel"),
+      wxDefaultPosition,
+      wxSize(600,200),
+      0
   );
   panel_ProjectActions->SetMinSize(wxSize(500, 100));
 
@@ -215,11 +215,26 @@ void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event)
   userResponse = dialog->ShowModal();
 
   if(userResponse == wxID_FORWARD)
-  {
-    //TODO createProject
-    std::cerr << "should create Project here" << std::endl;
-    //tree_Projects->BuildTree(this->model->GetActiveProjects());
-  }
+    {
+      std::string* result;
+      if(!this->model->CreateProject(
+          crea::wx2std(dialog->GetProjectName()),
+          crea::wx2std(dialog->GetProjectLocation()),
+          result,
+          crea::wx2std(dialog->GetPackageAuthor()),
+          crea::wx2std(dialog->GetPackageDescription())
+          ))
+        {
+          wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR);
+        }
+      wxMessageBox(_T("New Project created!"),_T("New Project - Success!"), wxOK | wxICON_INFORMATION);
+
+      //TODO: populate model
+      //TODO: populate tree control
+
+      //tree_Projects->BuildTree(this->model->GetActiveProjects());
+      auiManager.Update();
+    }
 
   event.Skip();
 }
@@ -230,21 +245,23 @@ void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event)
   long userResponse;
   userResponse = FD->ShowModal();
   if(userResponse == wxID_OK)
-  {
-    std::cout << "selection: " << crea::wx2std (FD->GetPath()) << std::endl;
-    std::string path = CDMUtilities::fixPath(crea::wx2std (FD->GetPath()));
-    std::cout << "fixed selection: " << path << std::endl;
-    std::string* result;
-    if (!this->model->OpenProject(path, result))
     {
-      wxMessageBox( crea::std2wx(result->c_str()), wxT("Open Project - Error"), wxICON_ERROR);
-      event.Skip();
-    };
-    //TODO: Create tree control
-    //((wxCreaDevManagerTreeCtrl*)tree_Projects)->BuildTree(controller->GetActiveProjects());
-
-    auiManager.Update();
-  }
+      std::cout << "Selection to open: " << crea::wx2std (FD->GetPath()) << std::endl;
+      std::string path = crea::wx2std (FD->GetPath());
+
+      std::string* result;
+      if (!this->model->OpenProject(path, result))
+        {
+          wxMessageBox( crea::std2wx(result->c_str()), wxT("Open Project - Error"), wxICON_ERROR);
+          event.Skip();
+        };
+
+      //TODO: populate model
+      //TODO: populate tree control
+
+      //((wxCreaDevManagerTreeCtrl*)tree_Projects)->BuildTree(controller->GetActiveProjects());
+      auiManager.Update();
+    }
 
   event.Skip();
 }