X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcreaDevManagerLib%2FwxCDMMainFrame.cpp;h=dc2843edbed71b79d5c1465ac4ce1dc099358041;hb=609d8d48cae96384e664ec6b000e8ecfcbad6459;hp=98ff113ef689c82150b9145d44fd993bef9ce14f;hpb=5413640f931dc9bc9b3c24a27f42c3cf40c35072;p=crea.git diff --git a/lib/creaDevManagerLib/wxCDMMainFrame.cpp b/lib/creaDevManagerLib/wxCDMMainFrame.cpp index 98ff113..dc2843e 100755 --- a/lib/creaDevManagerLib/wxCDMMainFrame.cpp +++ b/lib/creaDevManagerLib/wxCDMMainFrame.cpp @@ -33,6 +33,7 @@ #include #include "wx/treectrl.h" #include "wx/treebase.h" +#include "wx/tooltip.h" #include "CDMUtilities.h" #include "creaDevManagerIds.h" @@ -81,6 +82,8 @@ EVT_BUTTON(ID_BUTTON_NEWPROJECT, wxCDMMainFrame::OnMenuNewProject) EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMMainFrame::OnMenuOpenProject) EVT_TREE_SEL_CHANGING(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) END_EVENT_TABLE() wxCDMMainFrame::wxCDMMainFrame( @@ -220,13 +223,15 @@ void wxCDMMainFrame::CreateControls() - auiManager.AddPane(panel_Properties, wxAuiPaneInfo().BestSize(600,400).CenterPane().Name(wxT("panel_Properties")).Caption(wxT("Properties"))); - auiManager.AddPane(tree_Projects, wxAuiPaneInfo().Left().MinSize(300,300).BestSize(300,400).CloseButton(false).Name(wxT("tree_Projects")).Caption(wxT("Projects Tree"))); + 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.Update(); auiManager.LoadPerspective(pers,true); + wxToolTip::Enable(true); + wxToolTip::SetDelay(0); } //Event Handlers @@ -276,6 +281,7 @@ void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event) { auiManager.DetachPane(this->panel_Properties); this->panel_Properties->Destroy(); + this->panel_Properties = NULL; } this->panel_Properties = new wxCDMProjectDescriptionPanel( @@ -291,6 +297,7 @@ void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event) { auiManager.DetachPane(this->panel_Properties); this->panel_ProjectActions->Destroy(); + this->panel_ProjectActions = NULL; } panel_ProjectActions = new wxCDMProjectActionsPanel( @@ -304,8 +311,8 @@ void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event) panel_ProjectActions->SetMinSize(wxSize(500, 100)); - auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("Properties")).BestSize(600,400)); - auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("Project Actions")).BestSize(800,70).CloseButton(false)); + auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false)); + 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(); @@ -363,6 +370,7 @@ void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event) { auiManager.DetachPane(this->panel_Properties); this->panel_Properties->Destroy(); + this->panel_Properties = NULL; } this->panel_Properties = new wxCDMProjectDescriptionPanel( @@ -380,6 +388,7 @@ void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event) { auiManager.DetachPane(this->panel_ProjectActions); this->panel_ProjectActions->Destroy(); + this->panel_ProjectActions = NULL; } panel_ProjectActions = new wxCDMProjectActionsPanel( this, @@ -392,8 +401,8 @@ void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event) panel_ProjectActions->SetMinSize(wxSize(500, 100)); - auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("Properties")).BestSize(600,400)); - auiManager.AddPane(panel_ProjectActions, wxAuiPaneInfo().Bottom().MinSize(800,50).Name(wxT("panel_ProjectActions")).Caption(wxT("Project Actions")).BestSize(800,70).CloseButton(false)); + auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false)); + 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(); } @@ -421,11 +430,13 @@ void wxCDMMainFrame::OnMenuCloseProject(wxCommandEvent& event) { 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( @@ -437,7 +448,7 @@ void wxCDMMainFrame::OnMenuCloseProject(wxCommandEvent& event) 0 ); - auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("Properties")).BestSize(600,400)); + auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400).CloseButton(false)); auiManager.Update(); event.Skip(); @@ -457,11 +468,13 @@ void wxCDMMainFrame::OnMenuCloseAllProjects(wxCommandEvent& event) { 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( @@ -473,7 +486,7 @@ void wxCDMMainFrame::OnMenuCloseAllProjects(wxCommandEvent& event) 0 ); - auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("Properties")).BestSize(600,400)); + auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("")).BestSize(600,400)); auiManager.Update(); event.Skip(); @@ -487,7 +500,7 @@ void wxCDMMainFrame::OnMenuExit(wxCommandEvent& event) { std::cout << "Closing CreaDevManager..." << std::endl; std::string* result; - if(!this->model->CloseProject(result)) + 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); @@ -498,21 +511,16 @@ void wxCDMMainFrame::OnMenuExit(wxCommandEvent& event) { 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 - ); Close(); event.Skip(); } @@ -571,21 +579,31 @@ void wxCDMMainFrame::OnMenuBBTKGraphicalEditor(wxCommandEvent& event) { std::cerr << "Event OnMenuBBTKGraphicalEditor not implemented" << std::endl; event.Skip(); + if(CDMUtilities::openBBEditor()) + { + wxMessageBox( wxT("Can't open the BB Graphical Editor. Please check your Crea Tools installation."), wxT("Refresh Project - Error"), wxICON_ERROR); + } } void wxCDMMainFrame::OnMenuMiniTools(wxCommandEvent& event) { - std::cerr << "Event OnMenuMiniTools not implemented" << std::endl; - event.Skip(); + if(CDMUtilities::openCreaToolsTools()) + { + wxMessageBox( wxT("Can't open the Minitools. Please check your Crea Tools installation."), wxT("Refresh Project - Error"), wxICON_ERROR); + } } void wxCDMMainFrame::OnMenuCodeEditor(wxCommandEvent& event) { - std::cerr << "Event OnMenuCodeEditor not implemented" << std::endl; - event.Skip(); + if(CDMUtilities::openTextEditor()) + { + wxMessageBox( wxT("Can't open the Text Editor. Please check the default text editor command in the Crea Development Manager settings (Edit -> Settings)."), wxT("Refresh Project - Error"), wxICON_ERROR); + } } void wxCDMMainFrame::OnMenuCommandLine(wxCommandEvent& event) { - std::cerr << "Event OnMenuCommandLine not implemented" << std::endl; - event.Skip(); + if(CDMUtilities::openTerminal()) + { + wxMessageBox( wxT("Can't open Terminal. Please check the default terminal command in the Crea Development Manager settings (Edit -> Settings)."), wxT("Refresh Project - Error"), wxICON_ERROR); + } } //Help Menu @@ -612,14 +630,6 @@ void wxCDMMainFrame::OnMenuAboutCreatis(wxCommandEvent& event) void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event) { - std::cout << "New Tree Selection" << std::endl; - - if(event.GetId() != 0) - { - event.Skip(); - } - - //get selected element wxTreeItemId elementId = event.GetItem(); @@ -825,19 +835,20 @@ 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("Properties")).BestSize(600,400)); + 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->Destroy(); auiManager.DetachPane(this->panel_Properties); + this->panel_Properties->Destroy(); + this->panel_Properties = NULL; } //set new view this->panel_Properties = description; - //auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("Properties")).BestSize(600,400)); + //auiManager.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("Properties")).BestSize(600,400).CloseButton(false)); auiManager.Update(); event.Skip(); return; @@ -846,17 +857,19 @@ void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event) void wxCDMMainFrame::OnCreationComplete(wxCommandEvent& event) { - std::cout << "inMainFrame id: " << event.GetId() << ", tree element: "<< event.GetInt() << std::endl; switch(event.GetId() != 0) { case 0: - this->tree_Projects->SelectItem(event.GetInt(), false); + //select out old one to generate selection event this->tree_Projects->SelectItem(event.GetInt(), true); + this->tree_Projects->Expand(event.GetInt()); 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, this->model->GetProject(), @@ -869,40 +882,29 @@ void wxCDMMainFrame::OnCreationComplete(wxCommandEvent& event) } else if(event.GetString() == wxT("manage_libraries")) { - description = new wxCDMLibDescriptionPanel( - this, - this->model->GetProject()->GetLib(), - ID_WINDOW_PROPERTIES, - wxT("Description Panel"), - wxDefaultPosition, - wxSize(600, 400), - 0 - ); + this->tree_Projects->SelectItem(this->model->GetProject()->GetLib()->GetId(), true); + this->tree_Projects->Expand(this->model->GetProject()->GetLib()->GetId()); + break; } else if(event.GetString() == wxT("manage_applications")) { - description = new wxCDMAppliDescriptionPanel( - this, - this->model->GetProject()->GetAppli(), - ID_WINDOW_PROPERTIES, - wxT("Description Panel"), - wxDefaultPosition, - wxSize(600, 400), - 0 - ); + this->tree_Projects->SelectItem(this->model->GetProject()->GetAppli()->GetId(), true); + this->tree_Projects->Expand(this->model->GetProject()->GetAppli()->GetId()); + break; } if(this->panel_Properties!= NULL) this->panel_Properties->Hide(); - auiManager.AddPane(description, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("Properties")).BestSize(600,400)); + 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->Destroy(); auiManager.DetachPane(this->panel_Properties); + this->panel_Properties->Destroy(); + this->panel_Properties = NULL; } //set new view @@ -912,3 +914,20 @@ void wxCDMMainFrame::OnCreationComplete(wxCommandEvent& event) } event.Skip(); } + +void wxCDMMainFrame::OnElementSelected(wxCommandEvent& event) +{ + //std::cout << "element " << event.GetInt() << std::endl; + this->tree_Projects->SetItemBold(event.GetInt(), true); + this->tree_Projects->SetItemTextColour(event.GetInt(), wxColour(0,0,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->UpdateWindowUI(wxUPDATE_UI_RECURSE); + auiManager.Update(); +}