X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcreaDevManagerLib%2FwxCDMMainFrame.cpp;h=41052d4014f611fd1fb851511810008d63390ec8;hb=bae167768b5d3ccae6ec9b04c844d80e0368a52d;hp=143d23977ce318ac20e1872eb64758304bbb624e;hpb=5af1633cdea030f5189c57c51bd843685eecd8b6;p=crea.git diff --git a/lib/creaDevManagerLib/wxCDMMainFrame.cpp b/lib/creaDevManagerLib/wxCDMMainFrame.cpp index 143d239..41052d4 100755 --- a/lib/creaDevManagerLib/wxCDMMainFrame.cpp +++ b/lib/creaDevManagerLib/wxCDMMainFrame.cpp @@ -29,12 +29,18 @@ #include "wxCDMMainFrame.h" #include +#include #include +#include "creaSystem.h" #include "wx/treectrl.h" #include "wx/treebase.h" #include "wx/tooltip.h" +#include "wx/wxhtml.h" +#include "wx/statline.h" +#include "wx/config.h" #include "CDMUtilities.h" +#include "images/CIcon64.xpm" #include "creaDevManagerIds.h" #include "wxCDMMainDescriptionPanel.h" @@ -45,10 +51,16 @@ #include "wxCDMLibraryDescriptionPanel.h" #include "wxCDMPackageDescriptionPanel.h" #include "wxCDMBlackBoxDescriptionPanel.h" +#include "wxCDMBBSFileDescriptionPanel.h" +#include "wxCDMBBGFileDescriptionPanel.h" +#include "wxCDMCodeFileDescriptionPanel.h" #include "wxCDMCMakeListsDescriptionPanel.h" #include "wxCDMFolderDescriptionPanel.h" #include "wxCDMFileDescriptionPanel.h" #include "wxCDMPackageManagerPanel.h" +#include "wxCDMProjectMapDialog.h" + +#include "wxCDMSettingsDialog.h" #include "wxCDMProjectActionsPanel.h" #include "wxCDMNewProjectDialog.h" @@ -56,27 +68,26 @@ BEGIN_EVENT_TABLE(wxCDMMainFrame, wxFrame) +EVT_MENU_OPEN(wxCDMMainFrame::OnMenuBarOpen) 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_OPEN_RECENT1, wxCDMMainFrame::OnMenuOpenRecent) +EVT_MENU(ID_MENU_OPEN_RECENT2, wxCDMMainFrame::OnMenuOpenRecent) +EVT_MENU(ID_MENU_OPEN_RECENT3, wxCDMMainFrame::OnMenuOpenRecent) +EVT_MENU(ID_MENU_OPEN_RECENT4, wxCDMMainFrame::OnMenuOpenRecent) +EVT_MENU(ID_MENU_OPEN_RECENT5, 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_SETTINGS, wxCDMMainFrame::OnMenuSettings) 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_TOGGLE_HELP, wxCDMMainFrame::OnMenuToggleHelp) EVT_MENU(ID_MENU_HELP, wxCDMMainFrame::OnMenuHelp) +EVT_MENU(ID_MENU_SHOW_PROJECT_MAP, wxCDMMainFrame::OnMenuShowProjectMap) EVT_MENU(ID_MENU_REPORT_BUG, wxCDMMainFrame::OnMenuReportBug) EVT_MENU(ID_MENU_ABOUT_CREADEVMANAGER, wxCDMMainFrame::OnMenuAboutCreaDevManager) EVT_MENU(ID_MENU_ABOUT_CREATIS, wxCDMMainFrame::OnMenuAboutCreatis) @@ -86,9 +97,9 @@ EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMMainFrame::OnMenuOpenProject) EVT_TREE_SEL_CHANGED(ID_TREE_PROJECTS, wxCDMMainFrame::OnTreeSelectionChanged) -EVT_COMMAND(wxID_ANY, wxEVT_DISPLAY_CHANGED, wxCDMMainFrame::OnCreationComplete) -EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LIST_ITEM_SELECTED, wxCDMMainFrame::OnElementSelected) -EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxCDMMainFrame::OnElementDeselected) +EVT_COMMAND(wxID_ANY, wxEVT_DISPLAY_CHANGED, wxCDMMainFrame::OnChangeView) +EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCDMMainFrame::OnElementSelected) +EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_SELECTED, wxCDMMainFrame::OnElementDeselected) EVT_CHECKBOX(ID_CHECKBOX_DISABLE_HELP, wxCDMMainFrame::OnDisableHelp) @@ -103,11 +114,21 @@ wxCDMMainFrame::wxCDMMainFrame( long style ) { + this->menu_File = NULL; + this->menu_Edit = NULL; + this->menu_Tools = NULL; + this->menu_Help = NULL; + this->panel_Properties = NULL; + this->panel_ProjectActions = NULL; + this->tree_Projects = NULL; Create(parent, id, caption, pos, size, style); } wxCDMMainFrame::~wxCDMMainFrame() { + wxConfigBase* pConfig = wxConfigBase::Get(); + pConfig->Write(wxT("HELP"), this->help); + auiManager.UnInit(); } @@ -121,10 +142,16 @@ bool wxCDMMainFrame::Create( ) { wxFrame::Create(parent, id, caption, pos, size, style); - this->model = new modelCDMMain(); this->help = true; + + wxConfigBase* pConfig = wxConfigBase::Get(); + this->help = pConfig->Read(wxT("HELP"), this->help) != 0; + + this->model = new modelCDMMain(); + CreateMenus(); CreateControls(); + this->SetIcon(wxIcon(CIcon64)); return TRUE; } @@ -150,20 +177,50 @@ void wxCDMMainFrame::RefreshProject() this->model->RefreshProject(result); std::cout << "rebuilding project tree" << std::endl; this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject()); + this->tree_Projects->Unselect(); + this->actualTreeItem.Unset(); } void wxCDMMainFrame::CreateMenus() { wxMenuBar* menuBar = new wxMenuBar; + //Recently opened projects + menu_Recent = new wxMenu(); + wxConfigBase* pConfig = wxConfigBase::Get(); + std::string rp = crea::wx2std(pConfig->Read(wxT("RECENT1"), wxT(""))); + if(rp != "") + { + menu_Recent->Append(ID_MENU_OPEN_RECENT1, crea::std2wx(rp)); + rp = crea::wx2std(pConfig->Read(wxT("RECENT2"), wxT(""))); + if(rp != "") + { + menu_Recent->Append(ID_MENU_OPEN_RECENT2, crea::std2wx(rp)); + rp = crea::wx2std(pConfig->Read(wxT("RECENT3"), wxT(""))); + if(rp != "") + { + menu_Recent->Append(ID_MENU_OPEN_RECENT3, crea::std2wx(rp)); + rp = crea::wx2std(pConfig->Read(wxT("RECENT4"), wxT(""))); + if(rp != "") + { + menu_Recent->Append(ID_MENU_OPEN_RECENT4, crea::std2wx(rp)); + rp = crea::wx2std(pConfig->Read(wxT("RECENT5"), wxT(""))); + if(rp != "") + { + menu_Recent->Append(ID_MENU_OPEN_RECENT5, crea::std2wx(rp)); + } + } + } + } + } + //FileMenu menu_File = new wxMenu(); menu_File->Append(ID_MENU_NEW_PROJECT, wxT("&New Project...")); menu_File->Append(ID_MENU_OPEN_PROJECT, wxT("&Open Project...")); - menu_File->Append(ID_MENU_OPEN_RECENT, wxT("Open &Recent")); + menu_File->AppendSubMenu(menu_Recent,wxT("Open &Recent"),wxT("Open a recently opened project.")); menu_File->AppendSeparator(); menu_File->Append(ID_MENU_CLOSE_PROJECT, wxT("&Close Project")); - menu_File->Append(ID_MENU_CLOSE_ALL_PROJECTS, wxT("C&lose All Projects")); menu_File->AppendSeparator(); menu_File->Append(ID_MENU_EXPORT_HIERARCHY, wxT("&Export Project Hierarchy...")); menu_File->AppendSeparator(); @@ -174,24 +231,16 @@ void wxCDMMainFrame::CreateMenus() //EditMenu menu_Edit = new wxMenu(); menu_Edit->Append(ID_MENU_REFRESH_PROJECT, wxT("&Refresh Project")); - menu_Edit->AppendSeparator(); - menu_Edit->Append(ID_MENU_CUT, wxT("Cu&t")); - menu_Edit->Append(ID_MENU_COPY, wxT("&Copy")); - menu_Edit->Append(ID_MENU_PASTE, wxT("&Paste")); - menu_Edit->AppendSeparator(); - menu_Edit->Append(ID_MENU_DELETE, wxT("&Delete")); - menu_Edit->Append(ID_MENU_SELECT_ALL, wxT("Select &All")); - menu_Edit->Append(ID_MENU_SELECT_NONE, wxT("Ca&ncel Selection")); + menu_Edit->Append(ID_MENU_SETTINGS, wxT("&Settings")); menuBar->Append(menu_Edit, wxT("&Edit")); //ToolsMenu menu_Tools = new wxMenu(); - menu_Tools->Append(ID_MENU_EVENT_LOG, wxT("Event &Log")); - menu_Tools->Append(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxT("BBTK &Graphical Editor")); - menu_Tools->Append(ID_MENU_MINITOOLS, wxT("&MiniTools")); - menu_Tools->Append(ID_MENU_CODE_EDITOR, wxT("&Code Editor")); - menu_Tools->Append(ID_MENU_COMMAND_LINE, wxT("&Command Line")); + menu_Tools->Append(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxT("Open BBEditor (BBTK &Graphical Editor)")); + menu_Tools->Append(ID_MENU_MINITOOLS, wxT("Open &CreaTools")); + menu_Tools->Append(ID_MENU_CODE_EDITOR, wxT("Open Code &Editor")); + menu_Tools->Append(ID_MENU_COMMAND_LINE, wxT("Open Command &Line")); menuBar->Append(menu_Tools, wxT("&Tools")); @@ -199,6 +248,7 @@ void wxCDMMainFrame::CreateMenus() menu_Help = new wxMenu(); menu_Help->AppendCheckItem(ID_MENU_TOGGLE_HELP, wxT("He&lp Dialogs")); menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help); + menu_Help->Append(ID_MENU_SHOW_PROJECT_MAP, wxT("&Show Project Map")); menu_Help->Append(ID_MENU_HELP, wxT("&Help")); menu_Help->Append(ID_MENU_REPORT_BUG, wxT("Report &Bug")); menu_Help->Append(ID_MENU_ABOUT_CREADEVMANAGER, wxT("&About CreaDevManager")); @@ -226,8 +276,9 @@ void wxCDMMainFrame::CreateControls() ID_TREE_PROJECTS, wxDefaultPosition, wxSize(200,400), - wxTR_HAS_BUTTONS | wxTR_AQUA_BUTTONS + wxTR_HAS_BUTTONS | wxTR_AQUA_BUTTONS ); + this->actualTreeItem.Unset(); panel_Properties = new wxCDMMainDescriptionPanel( this, @@ -238,24 +289,52 @@ void wxCDMMainFrame::CreateControls() 0 ); - - - - - - auiManager.AddPane(panel_Properties, wxAuiPaneInfo().BestSize(600,400).CenterPane().Name(wxT("panel_Properties")).Caption(wxT("")).CloseButton(false)); - auiManager.AddPane(tree_Projects, wxAuiPaneInfo().Right().MinSize(300,300).BestSize(300,400).CloseButton(false).Name(wxT("tree_Projects")).Caption(wxT("Project Tree")).CloseButton(false)); - - wxString pers = auiManager.SavePerspective(); - + auiManager.AddPane(tree_Projects, wxAuiPaneInfo().Left().MinSize(250,300).BestSize(250,400).CloseButton(false).Name(wxT("tree_Projects")).Caption(wxT("Project Tree")).CloseButton(false)); auiManager.Update(); - auiManager.LoadPerspective(pers,true); + //auiManager.LoadPerspective(pers,true); wxToolTip::Enable(true); wxToolTip::SetDelay(0); } //Event Handlers + +void wxCDMMainFrame::OnMenuBarOpen(wxMenuEvent& event) +{ + //clean recent menu + int tam = menu_Recent->GetMenuItemCount(); + for (int i = 0; i < tam; ++i) { + menu_Recent->Delete(menu_Recent->FindItemByPosition(0)); + } + //populate recent menu + wxConfigBase* pConfig = wxConfigBase::Get(); + std::string rp = crea::wx2std(pConfig->Read(wxT("RECENT1"), wxT(""))); + if(rp != "") + { + menu_Recent->Append(ID_MENU_OPEN_RECENT1, crea::std2wx(rp)); + rp = crea::wx2std(pConfig->Read(wxT("RECENT2"), wxT(""))); + if(rp != "") + { + menu_Recent->Append(ID_MENU_OPEN_RECENT2, crea::std2wx(rp)); + rp = crea::wx2std(pConfig->Read(wxT("RECENT3"), wxT(""))); + if(rp != "") + { + menu_Recent->Append(ID_MENU_OPEN_RECENT3, crea::std2wx(rp)); + rp = crea::wx2std(pConfig->Read(wxT("RECENT4"), wxT(""))); + if(rp != "") + { + menu_Recent->Append(ID_MENU_OPEN_RECENT4, crea::std2wx(rp)); + rp = crea::wx2std(pConfig->Read(wxT("RECENT5"), wxT(""))); + if(rp != "") + { + menu_Recent->Append(ID_MENU_OPEN_RECENT5, crea::std2wx(rp)); + } + } + } + } + } +} + //File menu void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event) { @@ -267,7 +346,7 @@ void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event) if(userResponse == wxID_FORWARD) { - //create project + //close open project if(this->model->GetProject() != NULL) { if(!this->model->CloseProject(result)) @@ -277,8 +356,21 @@ void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event) event.Skip(); return; } + + if(this->panel_Properties != NULL) + { + auiManager.DetachPane(this->panel_Properties); + this->panel_Properties->Hide(); + } + if(this->panel_ProjectActions != NULL) + { + auiManager.DetachPane(this->panel_ProjectActions); + this->panel_ProjectActions->Hide(); + } + } + //create project if(!this->model->CreateProject( crea::wx2std(dialog->GetProjectName()), crea::wx2std(dialog->GetProjectLocation()), @@ -292,11 +384,17 @@ void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event) event.Skip(); return; } - - //populate tree control - tree_Projects->BuildTree(this->model->GetModelElements(),this->model->GetProject()); - tree_Projects->SelectItem(this->model->GetProject()->GetId(), false); - tree_Projects->SelectItem(this->model->GetProject()->GetId(), true); + + //update recently open projects + wxConfigBase* pConfig = wxConfigBase::Get(); + if(pConfig->Read(wxT("RECENT1"),wxT("")) != crea::std2wx(this->model->GetProject()->GetPath())) + { + pConfig->Write(wxT("RECENT5"), pConfig->Read(wxT("RECENT4"),wxT(""))); + pConfig->Write(wxT("RECENT4"), pConfig->Read(wxT("RECENT3"),wxT(""))); + pConfig->Write(wxT("RECENT3"), pConfig->Read(wxT("RECENT2"),wxT(""))); + pConfig->Write(wxT("RECENT2"), pConfig->Read(wxT("RECENT1"),wxT(""))); + pConfig->Write(wxT("RECENT1"), crea::std2wx(this->model->GetProject()->GetPath())); + } //show project actions panel @@ -306,7 +404,7 @@ void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event) this->panel_ProjectActions->Destroy(); this->panel_ProjectActions = NULL; } - + panel_ProjectActions = new wxCDMProjectActionsPanel( this, this->model->GetProject(), @@ -316,18 +414,115 @@ void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event) wxSize(800,200), 0 ); - panel_ProjectActions->SetMinSize(wxSize(500, 100)); + + auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false)); + auiManager.Update(); + //populate tree control + tree_Projects->BuildTree(this->model->GetModelElements(),this->model->GetProject()); + tree_Projects->Unselect(); + this->actualTreeItem.Unset(); + tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true); + //wxMessageBox(wxT("ProjectSelected") ,_T("New Project - Success!"),wxOK | wxICON_ERROR); + } +} +void wxCDMMainFrame::OnMenuOpenRecent(wxCommandEvent& event) +{ + std::string* result; - auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false)); + //((wxMenuItem*)(event.GetEventObject()))->GetItemLabel(); - auiManager.Update(); + std::string path = ""; + wxConfigBase* pConfig = wxConfigBase::Get(); + if(event.GetId() == ID_MENU_OPEN_RECENT1) + path = crea::wx2std (pConfig->Read(wxT("RECENT1"),wxT(""))); + else if(event.GetId() == ID_MENU_OPEN_RECENT2) + path = crea::wx2std (pConfig->Read(wxT("RECENT2"),wxT(""))); + else if(event.GetId() == ID_MENU_OPEN_RECENT3) + path = crea::wx2std (pConfig->Read(wxT("RECENT3"),wxT(""))); + else if(event.GetId() == ID_MENU_OPEN_RECENT4) + path = crea::wx2std (pConfig->Read(wxT("RECENT4"),wxT(""))); + else if(event.GetId() == ID_MENU_OPEN_RECENT5) + path = crea::wx2std (pConfig->Read(wxT("RECENT5"),wxT(""))); + + std::cout << "Selection to open: " << path << std::endl; + std::cout.flush(); + + + //populate model + if(this->model->GetProject() != NULL) + { + std::cout << "Project not null, closing it" << std::endl; + if(!this->model->CloseProject(result)) + { + std::cout << "error closing project: " << *result << std::endl; + wxMessageBox(crea::std2wx(result->c_str()),_T("New Project - Error!"),wxOK | wxICON_ERROR); + event.Skip(); + return; + } + + if(this->panel_Properties != NULL) + { + auiManager.DetachPane(this->panel_Properties); + this->panel_Properties->Hide(); + } + if(this->panel_ProjectActions != NULL) + { + auiManager.DetachPane(this->panel_ProjectActions); + this->panel_ProjectActions->Hide(); + } + } - //wxMessageBox(_T("New Project created!"),_T("New Project - Success!"), wxOK | wxICON_INFORMATION); + if (!this->model->OpenProject(path, result)) + { + std::cout << "error opening project: " << *result << std::endl; + wxMessageBox( crea::std2wx(result->c_str()), wxT("Open Project - Error"), wxICON_ERROR); + event.Skip(); + return; + }; + //update recently open projects + if(pConfig->Read(wxT("RECENT1"),wxT("")) != crea::std2wx(this->model->GetProject()->GetPath())) + { + pConfig->Write(wxT("RECENT5"), pConfig->Read(wxT("RECENT4"),wxT(""))); + pConfig->Write(wxT("RECENT4"), pConfig->Read(wxT("RECENT3"),wxT(""))); + pConfig->Write(wxT("RECENT3"), pConfig->Read(wxT("RECENT2"),wxT(""))); + pConfig->Write(wxT("RECENT2"), pConfig->Read(wxT("RECENT1"),wxT(""))); + pConfig->Write(wxT("RECENT1"), crea::std2wx(this->model->GetProject()->GetPath())); } - event.Skip(); + std::cout << "building ui" << std::endl; + + //populate tree control + tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject()); + tree_Projects->Unselect(); + this->actualTreeItem.Unset(); + tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true); + + + //change project's actions panel + if(this->panel_ProjectActions!= NULL) + { + auiManager.DetachPane(this->panel_ProjectActions); + this->panel_ProjectActions->Destroy(); + this->panel_ProjectActions = NULL; + } + panel_ProjectActions = new wxCDMProjectActionsPanel( + this, + this->model->GetProject(), + ID_WINDOW_PROJ_ACTIONS, + wxT("Project Actions Panel"), + wxDefaultPosition, + wxSize(800,200), + 0 + ); + panel_ProjectActions->SetMinSize(wxSize(500, 100)); + + + auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("General Project Actions")).BestSize(800,70).CloseButton(false)); + + auiManager.Update(); + } void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event) { @@ -356,6 +551,17 @@ void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event) event.Skip(); return; } + + if(this->panel_Properties != NULL) + { + auiManager.DetachPane(this->panel_Properties); + this->panel_Properties->Hide(); + } + if(this->panel_ProjectActions != NULL) + { + auiManager.DetachPane(this->panel_ProjectActions); + this->panel_ProjectActions->Hide(); + } } if (!this->model->OpenProject(path, result)) @@ -366,13 +572,24 @@ void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event) return; }; - std::cout << "building ui" << std::endl; + //update recently open projects + wxConfigBase* pConfig = wxConfigBase::Get(); + if(pConfig->Read(wxT("RECENT1"),wxT("")) != crea::std2wx(this->model->GetProject()->GetPath())) + { + pConfig->Write(wxT("RECENT5"), pConfig->Read(wxT("RECENT4"),wxT(""))); + pConfig->Write(wxT("RECENT4"), pConfig->Read(wxT("RECENT3"),wxT(""))); + pConfig->Write(wxT("RECENT3"), pConfig->Read(wxT("RECENT2"),wxT(""))); + pConfig->Write(wxT("RECENT2"), pConfig->Read(wxT("RECENT1"),wxT(""))); + pConfig->Write(wxT("RECENT1"), crea::std2wx(this->model->GetProject()->GetPath())); + } + std::cout << "building ui" << std::endl; //populate tree control tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject()); - tree_Projects->SelectItem(this->model->GetProject()->GetId(), false); - tree_Projects->SelectItem(this->model->GetProject()->GetId(), true); + tree_Projects->Unselect(); + this->actualTreeItem.Unset(); + tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true); //change project's actions panel @@ -398,16 +615,9 @@ void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event) auiManager.Update(); - } - - event.Skip(); -} -void wxCDMMainFrame::OnMenuOpenRecent(wxCommandEvent& event) -{ - std::cerr << "Event OnMenuOpenRecent not implemented" << std::endl; - event.Skip(); } + void wxCDMMainFrame::OnMenuCloseProject(wxCommandEvent& event) { std::cout << "closing project" << std::endl; @@ -419,18 +629,16 @@ void wxCDMMainFrame::OnMenuCloseProject(wxCommandEvent& event) } tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject()); - + this->actualTreeItem.Unset(); if(this->panel_Properties != NULL) { auiManager.DetachPane(this->panel_Properties); - this->panel_Properties->Destroy(); - this->panel_Properties = NULL; + this->panel_Properties->Hide(); } if(this->panel_ProjectActions != NULL) { auiManager.DetachPane(this->panel_ProjectActions); - this->panel_ProjectActions->Destroy(); - this->panel_ProjectActions = NULL; + this->panel_ProjectActions->Hide(); } this->panel_Properties = new wxCDMMainDescriptionPanel( @@ -445,46 +653,8 @@ void wxCDMMainFrame::OnMenuCloseProject(wxCommandEvent& event) auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false)); auiManager.Update(); - event.Skip(); } -void wxCDMMainFrame::OnMenuCloseAllProjects(wxCommandEvent& event) -{ - 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(); - this->panel_Properties = NULL; - } - if(this->panel_ProjectActions != NULL) - { - auiManager.DetachPane(this->panel_ProjectActions); - this->panel_ProjectActions->Destroy(); - this->panel_ProjectActions = NULL; - } - - this->panel_Properties = new wxCDMMainDescriptionPanel( - this, - ID_WINDOW_PROPERTIES, - wxT("Description Panel"), - wxDefaultPosition, - wxSize(600, 400), - 0 - ); - auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400)); - - auiManager.Update(); - event.Skip(); -} void wxCDMMainFrame::OnMenuExportHierarchy(wxCommandEvent& event) { std::cerr << "Event OnMenuExportHierarchy not implemented" << std::endl; @@ -497,9 +667,7 @@ void wxCDMMainFrame::OnMenuExit(wxCommandEvent& event) if(this->model->GetProject() != NULL && !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) { @@ -507,6 +675,13 @@ void wxCDMMainFrame::OnMenuExit(wxCommandEvent& event) this->panel_Properties->Destroy(); this->panel_Properties = NULL; } + + if(this->tree_Projects != NULL) + { + auiManager.DetachPane(this->tree_Projects); + this->tree_Projects->Destroy(); + this->tree_Projects = NULL; + } if(this->panel_ProjectActions != NULL) { @@ -514,9 +689,8 @@ void wxCDMMainFrame::OnMenuExit(wxCommandEvent& event) this->panel_ProjectActions->Destroy(); this->panel_ProjectActions = NULL; } - + Close(); - event.Skip(); } //Edit Menu @@ -527,53 +701,31 @@ void wxCDMMainFrame::OnMenuRefreshProject(wxCommandEvent& event) { wxMessageBox( crea::std2wx(result->c_str()), wxT("Refresh Project - Error"), wxICON_ERROR); } - this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject()); - - this->auiManager.Update(); - - this->tree_Projects->SelectItem(this->model->GetProject()->GetId(), false); - this->tree_Projects->SelectItem(this->model->GetProject()->GetId(), true); + if(this->model->GetProject() != NULL) + { + this->tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject()); + this->auiManager.Update(); - //TODO: Show possible problems in CMakeLists files - event.Skip(); -} -void wxCDMMainFrame::OnMenuMenuCut(wxCommandEvent& event) -{ - std::cerr << "Event OnMenuMenuCut not implemented" << std::endl; - event.Skip(); -} -void wxCDMMainFrame::OnMenuMenuCopy(wxCommandEvent& event) -{ - std::cerr << "Event OnMenuMenuCopy not implemented" << std::endl; - event.Skip(); -} -void wxCDMMainFrame::OnMenuMenuPaste(wxCommandEvent& event) -{ - std::cerr << "Event OnMenuMenuPaste not implemented" << std::endl; - event.Skip(); -} -void wxCDMMainFrame::OnMenuMenuDelete(wxCommandEvent& event) -{ - std::cerr << "Event OnMenuMenuDelete not implemented" << std::endl; - event.Skip(); -} -void wxCDMMainFrame::OnMenuSelectAll(wxCommandEvent& event) -{ - std::cerr << "Event OnMenuSelectAll not implemented" << std::endl; - event.Skip(); -} -void wxCDMMainFrame::OnMenuSelectNone(wxCommandEvent& event) -{ - std::cerr << "Event OnMenuSelectNone not implemented" << std::endl; + this->tree_Projects->Unselect(); + this->actualTreeItem.Unset(); + this->tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true); + } event.Skip(); } -//Tools Menu -void wxCDMMainFrame::OnMenuEventLog(wxCommandEvent& event) +void wxCDMMainFrame::OnMenuSettings(wxCommandEvent& event) { - std::cerr << "Event OnMenuEventLog not implemented" << std::endl; - event.Skip(); + wxCDMSettingsDialog* settingsDialog = new wxCDMSettingsDialog(this, -1); + settingsDialog->SetHelpEnabled(this->help); + + int res = settingsDialog->ShowModal(); + if(res == wxID_OK) + { + this->help = settingsDialog->IsHelpEnabled(); + this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help); + } } + void wxCDMMainFrame::OnMenuBBTKGraphicalEditor(wxCommandEvent& event) { std::cerr << "Event OnMenuBBTKGraphicalEditor not implemented" << std::endl; @@ -605,26 +757,91 @@ void wxCDMMainFrame::OnMenuCommandLine(wxCommandEvent& event) } } +//Help Menu +void wxCDMMainFrame::OnMenuShowProjectMap(wxCommandEvent& event) +{ + wxCDMProjectMapDialog* dialog = new wxCDMProjectMapDialog(this); + + dialog->Show(true); +} + //Help Menu void wxCDMMainFrame::OnMenuHelp(wxCommandEvent& event) { - std::cerr << "Event OnMenuHelp not implemented" << std::endl; - event.Skip(); + wxLaunchDefaultBrowser(_T("http://www.creatis.insa-lyon.fr/~gonzalez/documentationSWDoc.html"), 0); } void wxCDMMainFrame::OnMenuReportBug(wxCommandEvent& event) { - std::cerr << "Event OnMenuReportBug not implemented" << std::endl; - event.Skip(); + wxLaunchDefaultBrowser(_T("http://vip.creatis.insa-lyon.fr:9002/projects/crea"), 0); } void wxCDMMainFrame::OnMenuAboutCreaDevManager(wxCommandEvent& event) { - std::cerr << "Event OnMenuAboutCreaDevManager not implemented" << std::endl; - event.Skip(); + wxBoxSizer *topsizer; + wxHtmlWindow *html; + wxDialog dlg(this, wxID_ANY, wxString(_("About"))); + + topsizer = new wxBoxSizer(wxVERTICAL); + + html = new wxHtmlWindow(&dlg, wxID_ANY, wxDefaultPosition, wxSize(380, 160), wxHW_SCROLLBAR_NEVER); + html -> SetBorders(0); + + std::string content = "" + "" + "" + "" + " " + " " + " " + " " + " " + " " + "
" + "
" + " CREA Development Manager" + " " + "
" + "
" + "

Creatis 2012 - Lyon, France

" + " " + " " + " " + " " + " " + "
" + "

Created by Daniel González - daniel.gonzalez@creatis.insa-lyon.fr

" + "
" + " " + "

This software is governed by the CeCILL-B license under French law and abiding by the rules of distribution of free software.

" + "
" + "
" + "
" + "" + "" + ; + + html -> SetPage(crea::std2wx(content)); + html -> SetSize(html -> GetInternalRepresentation() -> GetWidth(), + html -> GetInternalRepresentation() -> GetHeight()); + + topsizer -> Add(html, 1, wxALL, 10); + +#if wxUSE_STATLINE + topsizer -> Add(new wxStaticLine(&dlg, wxID_ANY), 0, wxEXPAND | wxLEFT | wxRIGHT, 10); +#endif // wxUSE_STATLINE + + wxButton *bu1 = new wxButton(&dlg, wxID_OK, _("OK")); + bu1 -> SetDefault(); + + topsizer -> Add(bu1, 0, wxALL | wxALIGN_RIGHT, 15); + + dlg.SetSizer(topsizer); + topsizer -> Fit(&dlg); + + dlg.ShowModal(); } void wxCDMMainFrame::OnMenuAboutCreatis(wxCommandEvent& event) { - std::cerr << "Event OnMenuAboutCreatis not implemented" << std::endl; - event.Skip(); + wxLaunchDefaultBrowser(_T("http://www.creatis.insa-lyon.fr/site/en"), 0); } void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event) @@ -632,14 +849,25 @@ void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event) //get selected element wxTreeItemId elementId = event.GetItem(); - if(this->tree_Projects->IsSelected(elementId)) + //std::cout << "Tree Selection id: " << elementId.m_pItem << this->actualTreeItem.m_pItem << std::endl; + //elementId.IsOk() && this->tree_Projects->IsSelected(elementId) + if(elementId.IsOk() && this->actualTreeItem != elementId) { - std::cout << "Tree Selection id: " << elementId << std::endl; + + //std::cout << "Valid tree selection id: " << elementId.m_pItem << std::endl; //get element from model modelCDMIProjectTreeNode* element = this->model->GetModelElements()[elementId]; + + if (element == NULL) + return; std::cout << "Tree Selection: " << element->GetName() << std::endl; - //TODO get element type + //std::stringstream ss; + //ss << this->actualTreeItem.m_pItem << ":" << event.GetOldItem().m_pItem << " --> " << elementId.m_pItem; + //wxMessageBox( wxT("Tree Selection id: " + ss.str() + " by " + element->GetName()), wxT("Refresh Project - Error"), wxICON_ERROR); + this->actualTreeItem = elementId; + + //get element type //project modelCDMProject* elementProject = dynamic_cast(element); wxPanel* description; @@ -679,7 +907,7 @@ void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event) { //application modelCDMApplication* elementApplication = dynamic_cast(element); - if(elementApplication != NULL) + if(elementApplication != NULL) { //create element description description = new wxCDMApplicationDescriptionPanel( @@ -779,14 +1007,14 @@ void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event) } else { - //folder - modelCDMFolder* elementFolder = dynamic_cast(element); - if(elementFolder != NULL) + //CodeFile + modelCDMCodeFile* elementCodeFile = dynamic_cast(element); + if(elementCodeFile != NULL) { //create element description - description = new wxCDMFolderDescriptionPanel( + description = new wxCDMCodeFileDescriptionPanel( this, - elementFolder, + elementCodeFile, ID_WINDOW_PROPERTIES, wxT("Description Panel"), wxDefaultPosition, @@ -796,14 +1024,14 @@ void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event) } else { - //file - modelCDMFile* elementFile = dynamic_cast(element); - if(elementFile != NULL) + //BBSFile + modelCDMBBSFile* elementBBSFile = dynamic_cast(element); + if(elementBBSFile != NULL) { //create element description - description = new wxCDMFileDescriptionPanel( + description = new wxCDMBBSFileDescriptionPanel( this, - elementFile, + elementBBSFile, ID_WINDOW_PROPERTIES, wxT("Description Panel"), wxDefaultPosition, @@ -813,17 +1041,71 @@ void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event) } else { - - //main if not any - //create element description - description = new wxCDMMainDescriptionPanel( - this, - ID_WINDOW_PROPERTIES, - wxT("Description Panel"), - wxDefaultPosition, - wxSize(600, 400), - 0 - ); + //BBSFile + modelCDMBBGFile* elementBBGFile = dynamic_cast(element); + if(elementBBGFile != NULL) + { + //create element description + description = new wxCDMBBGFileDescriptionPanel( + this, + elementBBGFile, + ID_WINDOW_PROPERTIES, + wxT("Description Panel"), + wxDefaultPosition, + wxSize(600, 400), + 0 + ); + } + else + { + //folder + modelCDMFolder* elementFolder = dynamic_cast(element); + if(elementFolder != NULL) + { + //create element description + description = new wxCDMFolderDescriptionPanel( + this, + elementFolder, + ID_WINDOW_PROPERTIES, + wxT("Description Panel"), + wxDefaultPosition, + wxSize(600, 400), + 0 + ); + } + else + { + //file + modelCDMFile* elementFile = dynamic_cast(element); + if(elementFile != NULL) + { + //create element description + description = new wxCDMFileDescriptionPanel( + this, + elementFile, + ID_WINDOW_PROPERTIES, + wxT("Description Panel"), + wxDefaultPosition, + wxSize(600, 400), + 0 + ); + } + else + { + + //main if not any + //create element description + description = new wxCDMMainDescriptionPanel( + this, + ID_WINDOW_PROPERTIES, + wxT("Description Panel"), + wxDefaultPosition, + wxSize(600, 400), + 0 + ); + } + } + } } } } @@ -835,49 +1117,50 @@ void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event) } } - if(this->panel_Properties!= NULL) - this->panel_Properties->Hide(); - - auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false)); - auiManager.Update(); - //delete old view if(this->panel_Properties!= NULL) { + this->panel_Properties->Hide(); auiManager.DetachPane(this->panel_Properties); - this->panel_Properties->Destroy(); - this->panel_Properties = NULL; + //this->panel_Properties->Destroy(); + //this->panel_Properties = NULL; } //set new view - + auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false)); this->panel_Properties = description; - //auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("Properties")).BestSize(600,400).CloseButton(false)); auiManager.Update(); - event.Skip(); } + else + { + event.Skip(); + } return; } -void wxCDMMainFrame::OnCreationComplete(wxCommandEvent& event) +void wxCDMMainFrame::OnChangeView(wxCommandEvent& event) { - switch(event.GetId() != 0) + modelCDMIProjectTreeNode* myItem = NULL; + wxPanel* description = NULL; + switch(event.GetId()) { case 0: + myItem = ((modelCDMIProjectTreeNode*)event.GetClientData()); //select out old one to generate selection event - this->tree_Projects->SelectItem(event.GetInt(), false); - this->tree_Projects->SelectItem(event.GetInt(), true); - this->tree_Projects->Expand(event.GetInt()); + this->tree_Projects->Unselect(); + this->tree_Projects->SelectItem(myItem->GetId().GetWxId()); + this->tree_Projects->Expand(myItem->GetId().GetWxId()); break; case 1: - wxPanel* description = NULL; + if(event.GetString() == wxT("manage_packages")) { - this->tree_Projects->SelectItem(this->model->GetProject()->GetId(), false); - this->tree_Projects->Expand(this->model->GetProject()->GetId()); - description = new wxCDMPackageManagerPanel( + //this->tree_Projects->Expand(this->model->GetProject()->GetId()); + //this->tree_Projects->Unselect(); + this->actualTreeItem.Unset(); + description = new wxCDMPackageManagerPanel( this, this->model->GetProject(), ID_WINDOW_PROPERTIES, @@ -889,20 +1172,21 @@ void wxCDMMainFrame::OnCreationComplete(wxCommandEvent& event) } else if(event.GetString() == wxT("manage_libraries")) { - this->tree_Projects->SelectItem(this->model->GetProject()->GetLib()->GetId(), true); - this->tree_Projects->Expand(this->model->GetProject()->GetLib()->GetId()); + this->tree_Projects->SelectItem(this->model->GetProject()->GetLib()->GetId().GetWxId()); + this->tree_Projects->Expand(this->model->GetProject()->GetLib()->GetId().GetWxId()); break; } else if(event.GetString() == wxT("manage_applications")) { - this->tree_Projects->SelectItem(this->model->GetProject()->GetAppli()->GetId(), true); - this->tree_Projects->Expand(this->model->GetProject()->GetAppli()->GetId()); + this->tree_Projects->SelectItem(this->model->GetProject()->GetAppli()->GetId().GetWxId()); + this->tree_Projects->Expand(this->model->GetProject()->GetAppli()->GetId().GetWxId()); break; } else if(event.GetString() == wxT("blackbox")) { - this->tree_Projects->SelectItem(this->model->GetProject()->GetId(), false); modelCDMBlackBox* bb = (modelCDMBlackBox*)event.GetClientData(); + this->actualTreeItem.Unset(); + this->tree_Projects->SelectItem(bb->GetHeaderFile()->GetId().GetWxId()); description = new wxCDMBlackBoxDescriptionPanel( this, bb, @@ -912,46 +1196,48 @@ void wxCDMMainFrame::OnCreationComplete(wxCommandEvent& event) wxSize(600, 400), 0 ); - } - if(this->panel_Properties!= NULL) - this->panel_Properties->Hide(); - - auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false)); - auiManager.Update(); + + } //delete old view if(this->panel_Properties!= NULL) { + this->panel_Properties->Hide(); auiManager.DetachPane(this->panel_Properties); this->panel_Properties->Destroy(); this->panel_Properties = NULL; } //set new view - + auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false)); this->panel_Properties = description; auiManager.Update(); break; + default: + event.Skip(); + break; } - event.Skip(); + } void wxCDMMainFrame::OnElementSelected(wxCommandEvent& event) { //std::cout << "element " << event.GetInt() << std::endl; - this->tree_Projects->EnsureVisible(event.GetInt()); - this->tree_Projects->SetItemBold(event.GetInt(), true); - this->tree_Projects->SetItemTextColour(event.GetInt(), wxColour(0,0,255)); - this->tree_Projects->SetItemBackgroundColour(event.GetInt(), wxColour(230,230,255)); + modelCDMIProjectTreeNode* item = (modelCDMIProjectTreeNode*)event.GetClientData(); + this->tree_Projects->EnsureVisible(item->GetId().GetWxId()); + this->tree_Projects->SetItemBold(item->GetId().GetWxId(), true); + this->tree_Projects->SetItemTextColour(item->GetId().GetWxId(), wxColour(0,0,255)); + this->tree_Projects->SetItemBackgroundColour(item->GetId().GetWxId(), wxColour(230,230,255)); this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE); auiManager.Update(); } void wxCDMMainFrame::OnElementDeselected(wxCommandEvent& event) { - this->tree_Projects->SetItemBold(event.GetInt(), false); - this->tree_Projects->SetItemTextColour(event.GetInt(), wxColour(0,0,0)); - this->tree_Projects->SetItemBackgroundColour(event.GetInt(), wxColour(255,255,255)); + modelCDMIProjectTreeNode* item = (modelCDMIProjectTreeNode*)event.GetClientData(); + this->tree_Projects->SetItemBold(item->GetId().GetWxId(), false); + this->tree_Projects->SetItemTextColour(item->GetId().GetWxId(), wxColour(0,0,0)); + this->tree_Projects->SetItemBackgroundColour(item->GetId().GetWxId(), wxColour(255,255,255)); this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE); auiManager.Update(); }