+
+ //get selected element
+ wxTreeItemId elementId = event.GetItem();
+ if(this->tree_Projects->IsSelected(elementId))
+ {
+ std::cout << "Tree Selection id: " << elementId << 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
+ //project
+ modelCDMProject* elementProject = dynamic_cast<modelCDMProject*>(element);
+ wxPanel* description;
+ if(elementProject != NULL)
+ {
+ //create element description
+ description = new wxCDMProjectDescriptionPanel(
+ this,
+ elementProject,
+ ID_WINDOW_PROPERTIES,
+ wxT("Description Panel"),
+ wxDefaultPosition,
+ wxSize(600, 400),
+ 0
+ );
+
+ }
+ else
+ {
+ //appli
+ modelCDMAppli* elementAppli = dynamic_cast<modelCDMAppli*>(element);
+ if(elementAppli != NULL)
+ {
+ //create element description
+ description = new wxCDMAppliDescriptionPanel(
+ this,
+ elementAppli,
+ ID_WINDOW_PROPERTIES,
+ wxT("Description Panel"),
+ wxDefaultPosition,
+ wxSize(600, 400),
+ 0
+ );
+
+ }
+ else
+ {
+ //application
+ modelCDMApplication* elementApplication = dynamic_cast<modelCDMApplication*>(element);
+ if(elementApplication != NULL)
+ {
+ //create element description
+ description = new wxCDMApplicationDescriptionPanel(
+ this,
+ elementApplication,
+ ID_WINDOW_PROPERTIES,
+ wxT("Description Panel"),
+ wxDefaultPosition,
+ wxSize(600, 400),
+ 0
+ );
+ }
+ else
+ {
+ //lib
+ modelCDMLib* elementLib = dynamic_cast<modelCDMLib*>(element);
+ if(elementLib != NULL)
+ {
+ //create element description
+ description = new wxCDMLibDescriptionPanel(
+ this,
+ elementLib,
+ ID_WINDOW_PROPERTIES,
+ wxT("Description Panel"),
+ wxDefaultPosition,
+ wxSize(600, 400),
+ 0
+ );
+ }
+ else
+ {
+ //library
+ modelCDMLibrary* elementLibrary = dynamic_cast<modelCDMLibrary*>(element);
+ if(elementLibrary != NULL)
+ {
+ //create element description
+ description = new wxCDMLibraryDescriptionPanel(
+ this,
+ elementLibrary,
+ ID_WINDOW_PROPERTIES,
+ wxT("Description Panel"),
+ wxDefaultPosition,
+ wxSize(600, 400),
+ 0
+ );
+ }
+ else
+ {
+ //package
+ modelCDMPackage* elementPackage = dynamic_cast<modelCDMPackage*>(element);
+ if(elementPackage != NULL)
+ {
+ //create element description
+ description = new wxCDMPackageDescriptionPanel(
+ this,
+ elementPackage,
+ ID_WINDOW_PROPERTIES,
+ wxT("Description Panel"),
+ wxDefaultPosition,
+ wxSize(600, 400),
+ 0
+ );
+ }
+ else
+ {
+ //black box
+ modelCDMBlackBox* elementBlackBox = dynamic_cast<modelCDMBlackBox*>(element);
+ if(elementBlackBox != NULL)
+ {
+ //create element description
+ description = new wxCDMBlackBoxDescriptionPanel(
+ this,
+ elementBlackBox,
+ ID_WINDOW_PROPERTIES,
+ wxT("Description Panel"),
+ wxDefaultPosition,
+ wxSize(600, 400),
+ 0
+ );
+ }
+ else
+ {
+ //CMakeLists
+ modelCDMCMakeListsFile* elementCMakeLists = dynamic_cast<modelCDMCMakeListsFile*>(element);
+ if(elementCMakeLists != NULL)
+ {
+ //create element description
+ description = new wxCDMCMakeListsDescriptionPanel(
+ this,
+ elementCMakeLists,
+ ID_WINDOW_PROPERTIES,
+ wxT("Description Panel"),
+ wxDefaultPosition,
+ wxSize(600, 400),
+ 0
+ );
+ }
+ else
+ {
+ //folder
+ modelCDMFolder* elementFolder = dynamic_cast<modelCDMFolder*>(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<modelCDMFile*>(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
+ );
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ //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();
+ event.Skip();
+ }
+
+ return;
+
+}
+
+void wxCDMMainFrame::OnChangeView(wxCommandEvent& event)
+{
+ modelCDMIProjectTreeNode* myItem = NULL;
+ switch(event.GetId())
+ {
+ case 0:
+ myItem = ((modelCDMIProjectTreeNode*)event.GetClientData());
+ //select out old one to generate selection event
+ this->tree_Projects->Unselect();
+ this->tree_Projects->SelectItem(myItem->GetId(), true);
+ this->tree_Projects->Expand(myItem->GetId());
+ break;
+ case 1:
+ wxPanel* description = NULL;
+ if(event.GetString() == wxT("manage_packages"))
+ {
+ //this->tree_Projects->Expand(this->model->GetProject()->GetId());
+ //this->tree_Projects->Unselect();
+ description = new wxCDMPackageManagerPanel(
+ this,
+ this->model->GetProject(),
+ ID_WINDOW_PROPERTIES,
+ wxT("Description Panel"),
+ wxDefaultPosition,
+ wxSize(600, 400),
+ 0
+ );
+ }
+ 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());
+ 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());
+ break;
+ }
+ else if(event.GetString() == wxT("blackbox"))
+ {
+ modelCDMBlackBox* bb = (modelCDMBlackBox*)event.GetClientData();
+ description = new wxCDMBlackBoxDescriptionPanel(
+ this,
+ bb,
+ ID_WINDOW_PROPERTIES,
+ wxT("Description Panel"),
+ wxDefaultPosition,
+ wxSize(600, 400),
+ 0
+ );
+ }
+
+ //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;
+ }