#include "wxCDMMainFrame.h"
#include <iostream>
+#include <sstream>
#include <creaWx.h>
#include "creaSystem.h"
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);
}
ID_TREE_PROJECTS,
wxDefaultPosition,
wxSize(200,400),
- wxTR_HAS_BUTTONS | wxTR_AQUA_BUTTONS
+ wxTR_HAS_BUTTONS | wxTR_AQUA_BUTTONS
);
panel_Properties = new wxCDMMainDescriptionPanel(
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.Update();
- auiManager.LoadPerspective(pers,true);
+ //auiManager.LoadPerspective(pers,true);
wxToolTip::Enable(true);
wxToolTip::SetDelay(0);
}
}
}
+
if(!this->model->CreateProject(
crea::wx2std(dialog->GetProjectName()),
crea::wx2std(dialog->GetProjectLocation()),
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);
-
-
+
//show project actions panel
if(this->panel_ProjectActions != NULL)
{
this->panel_ProjectActions->Destroy();
this->panel_ProjectActions = NULL;
}
-
+
panel_ProjectActions = new wxCDMProjectActionsPanel(
this,
this->model->GetProject(),
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();
- //wxMessageBox(_T("New Project created!"),_T("New Project - Success!"), wxOK | wxICON_INFORMATION);
-
+ //populate tree control
+ tree_Projects->BuildTree(this->model->GetModelElements(),this->model->GetProject());
+ tree_Projects->Unselect();
+ tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId());
+ wxMessageBox(wxT("ProjectSelected") ,_T("New Project - Success!"),wxOK | wxICON_ERROR);
}
-
- event.Skip();
}
void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event)
{
//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();
+ tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
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)
{
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)
{
this->panel_ProjectActions->Destroy();
this->panel_ProjectActions = NULL;
}
-
+
Close();
- event.Skip();
}
//Edit Menu
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);
+ this->tree_Projects->Unselect();
+ this->tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true);
}
event.Skip();
}
html = new wxHtmlWindow(&dlg, wxID_ANY, wxDefaultPosition, wxSize(380, 160), wxHW_SCROLLBAR_NEVER);
html -> SetBorders(0);
- html -> LoadPage(wxT("about.html"));
+
+ std::string content = ""
+ "<html>"
+ "<body bgcolor=\"#3333CC\">"
+ "<table cellspacing=3 cellpadding=4 width=\"100%\">"
+ " <tr>"
+ " <td bgcolor=\"#3333CC\">"
+ " <center>"
+ " <font size=+2 color=\"#FFFFFF\"><b>CREA Development Manager</b>"
+ " </font>"
+ " </center>"
+ " </td>"
+ " </tr>"
+ " <tr>"
+ " <td bgcolor=\"#FFFFFF\">"
+ " <p><b><font size=+1>Creatis 2012 - Lyon, France</font></b></p>"
+ " <font size=-1>"
+ " <table cellpadding=0 cellspacing=0 width=\"100%\">"
+ " <tr>"
+ " <td width=\"65%\">"
+ " <p>Created by Daniel González - daniel.gonzalez@creatis.insa-lyon.fr</p>"
+ " </td>"
+ " </tr>"
+ " </table>"
+ " <font size=1>"
+ " <p>This software is governed by the CeCILL-B license under French law and abiding by the rules of distribution of free software.</p>"
+ " </font>"
+ " </font>"
+ " </td>"
+ " </tr>"
+ "</table>"
+ "</body>"
+ "</html>"
+ ;
+
+ html -> SetPage(crea::std2wx(content));
html -> SetSize(html -> GetInternalRepresentation() -> GetWidth(),
html -> GetInternalRepresentation() -> GetHeight());
//get selected element
wxTreeItemId elementId = event.GetItem();
- if(this->tree_Projects->IsSelected(elementId))
+ if(elementId.IsOk() && this->tree_Projects->IsSelected(elementId))
{
std::cout << "Tree Selection id: " << elementId << std::endl;
//get element from model
modelCDMIProjectTreeNode* element = this->model->GetModelElements()[elementId];
- std::cout << "Tree Selection: " << element->GetName() << std::endl;
+ if (element == NULL)
+ return;
+ std::cout << "Tree Selection: " << element->GetName() << std::endl;
+
//TODO get element type
//project
modelCDMProject* elementProject = dynamic_cast<modelCDMProject*>(element);
{
//application
modelCDMApplication* elementApplication = dynamic_cast<modelCDMApplication*>(element);
- if(elementApplication != NULL)
+ if(elementApplication != NULL)
{
//create element description
description = new wxCDMApplicationDescriptionPanel(
}
}
- 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.AddPane(panel_Properties, wxAuiPaneInfo().Center().Name(wxT("panel_Properties")).Caption(wxT("Properties")).BestSize(600,400).CloseButton(false));
auiManager.Update();
event.Skip();
}
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->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(), true);
+ 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());
+ //this->tree_Projects->Expand(this->model->GetProject()->GetId());
+ //this->tree_Projects->Unselect();
description = new wxCDMPackageManagerPanel(
this,
this->model->GetProject(),
}
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(), true);
+ 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(), true);
+ 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();
description = new wxCDMBlackBoxDescriptionPanel(
this,
);
}
- 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;
}
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();
}