2
* This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
3
* http://www.gnu.org/licenses/lgpl-3.0.html
6
* $Id: projectdepsdlg.cpp 4909 2008-02-27 13:15:26Z mortenmacfly $
7
* $HeadURL: svn://svn.berlios.de/codeblocks/tags/8.02/src/sdk/projectdepsdlg.cpp $
10
#include "sdk_precomp.h"
13
#include "cbproject.h"
15
#include "projectmanager.h"
17
#include <wx/xrc/xmlres.h>
18
#include <wx/combobox.h>
19
#include <wx/msgdlg.h>
20
#include <wx/checklst.h>
23
#include "projectdepsdlg.h"
26
BEGIN_EVENT_TABLE(ProjectDepsDlg, wxDialog)
27
EVT_COMBOBOX(XRCID("cmbProject"), ProjectDepsDlg::OnProjectChange)
30
ProjectDepsDlg::ProjectDepsDlg(wxWindow* parent, cbProject* sel)
34
wxXmlResource::Get()->LoadDialog(this, parent, _T("dlgConfigureProjectDeps"));
36
wxComboBox* cmb = XRCCTRL(*this, "cmbProject", wxComboBox);
39
ProjectsArray* mainarr = Manager::Get()->GetProjectManager()->GetProjects();
40
for (size_t i = 0; i < mainarr->GetCount(); ++i)
42
cbProject* prj = mainarr->Item(i);
43
cmb->Append(prj->GetTitle(), prj);
47
cmb->SetSelection(idx);
52
ProjectDepsDlg::~ProjectDepsDlg()
57
bool ProjectDepsDlg::SaveList()
59
wxComboBox* cmb = XRCCTRL(*this, "cmbProject", wxComboBox);
60
wxCheckListBox* lst = XRCCTRL(*this, "lstDeps", wxCheckListBox);
65
cbProject* thisprj = static_cast<cbProject*>(cmb->GetClientData(m_LastSel));
69
// first clear all deps for this project
70
Manager::Get()->GetProjectManager()->ClearProjectDependencies(thisprj);
72
// now set the the new deps
73
for (int i = 0; i < (int)lst->GetCount(); ++i)
75
if (!lst->IsChecked(i))
80
ProjectsArray* mainarr = Manager::Get()->GetProjectManager()->GetProjects();
81
for (size_t x = 0; x < mainarr->GetCount(); ++x)
83
if (mainarr->Item(x)->GetTitle() == lst->GetString(i))
85
prj = mainarr->Item(x);
92
if (!Manager::Get()->GetProjectManager()->AddProjectDependency(thisprj, prj))
94
cbMessageBox(wxString::Format(_("Cannot add project '%s' as a dependency to '%s' because this "
95
"would cause a circular dependency error..."),
96
thisprj->GetTitle().c_str(), prj->GetTitle().c_str()),
97
_("Error"), wxICON_ERROR);
104
void ProjectDepsDlg::FillList()
106
wxComboBox* cmb = XRCCTRL(*this, "cmbProject", wxComboBox);
107
wxCheckListBox* lst = XRCCTRL(*this, "lstDeps", wxCheckListBox);
109
int idx = cmb->GetSelection();
110
if (m_LastSel != idx && m_LastSel != -1)
119
cbProject* thisprj = static_cast<cbProject*>(cmb->GetClientData(idx));
122
const ProjectsArray* arr = Manager::Get()->GetProjectManager()->GetDependenciesForProject(thisprj);
125
ProjectsArray* mainarr = Manager::Get()->GetProjectManager()->GetProjects();
126
for (size_t i = 0; i < mainarr->GetCount(); ++i)
128
cbProject* prj = mainarr->Item(i);
131
lst->Append(prj->GetTitle());
134
lst->Check(lst->GetCount() - 1, arr && arr->Index(prj) != wxNOT_FOUND);
138
void ProjectDepsDlg::OnProjectChange(wxCommandEvent& event)
143
void ProjectDepsDlg::EndModal(int retCode)
146
return wxDialog::EndModal(retCode);