void clCxxWorkspace::RemoveProjectFromBuildMatrix(ProjectPtr prj)
{
    BuildMatrixPtr matrix = GetBuildMatrix();
    wxString selConfName = matrix->GetSelectedConfigurationName();

    std::list<WorkspaceConfigurationPtr> wspList = matrix->GetConfigurations();
    std::list<WorkspaceConfigurationPtr>::iterator iter = wspList.begin();
    for(; iter != wspList.end(); iter++) {
        WorkspaceConfiguration::ConfigMappingList prjList = (*iter)->GetMapping();

        WorkspaceConfiguration::ConfigMappingList::iterator it = prjList.begin();
        for(; it != prjList.end(); it++) {
            if((*it).m_project == prj->GetName()) {
                prjList.erase(it);
                break;
            }
        }

        (*iter)->SetConfigMappingList(prjList);
        matrix->SetConfiguration((*iter));
    }

    // and set the configuration name
    matrix->SetSelectedConfigurationName(selConfName);

    // this will also reset the build matrix pointer
    SetBuildMatrix(matrix);
}
void ConfigurationManagerDlg::PopulateConfigurations()
{
	//popuplate the configurations
	BuildMatrixPtr matrix = ManagerST::Get()->GetWorkspaceBuildMatrix();
	if (!matrix) {
		return;
	}

	wxFlexGridSizer *mainSizer = dynamic_cast<wxFlexGridSizer*>(m_scrolledWindow->GetSizer());
	if (!mainSizer) return;

	Freeze();
	// remove old entries from the configuration table
	wxSizerItemList list = mainSizer->GetChildren();
	for ( wxSizerItemList::Node *node = list.GetFirst(); node; node = node->GetNext() ) {
		wxSizerItem *current = node->GetData();
		current->GetWindow()->Destroy();
	}
	m_projSettingsMap.clear();

	std::list<CSolitionConfigurationPtr> configs = matrix->GetConfigurations();
	std::list<CSolitionConfigurationPtr>::iterator iter = configs.begin();

	m_choiceConfigurations->Clear();
	for (; iter != configs.end(); iter++) {
		m_choiceConfigurations->Append((*iter)->GetName());
	}

	// append the 'New' & 'Delete' commands
	m_choiceConfigurations->Append(clCMD_NEW);
	m_choiceConfigurations->Append(clCMD_EDIT);

	int sel = m_choiceConfigurations->FindString(matrix->GetSelectedConfigurationName());
	if (sel != wxNOT_FOUND) {
		m_choiceConfigurations->SetSelection(sel);
	} else if (m_choiceConfigurations->GetCount() > 2) {
		m_choiceConfigurations->SetSelection(2);
	} else {
		m_choiceConfigurations->Append(wxT("Debug"));
		m_choiceConfigurations->SetSelection(2);
	}

	// keep the current workspace configuration
	m_currentWorkspaceConfiguration = m_choiceConfigurations->GetStringSelection();

	wxArrayString projects;
	ManagerST::Get()->GetProjectList(projects);
	projects.Sort(wxStringCmpFunc);
	
	for (size_t i=0; i<projects.GetCount(); i++) {
		wxString selConf = matrix->GetProjectSelectedConf(matrix->GetSelectedConfigurationName(),  projects.Item(i));
		AddEntry(projects.Item(i), selConf);
	}

	Thaw();
	mainSizer->Fit(m_scrolledWindow);
	Layout();

}
void
CMakeProjectSettingsPanel::SetSettings(CMakeProjectSettings* settings, const wxString& project, const wxString& config)
{
    // Remove old projects
    m_choiceParent->Clear();

    // Get all available projects
    wxArrayString projects;
    m_plugin->GetManager()->GetWorkspace()->GetProjectList(projects);

    // Get build matrix
    // Required for translation between current config and other projects' configs.
    BuildMatrixPtr matrix = m_plugin->GetManager()->GetWorkspace()->GetBuildMatrix();

    // We have to find name of workspace configuration by project name and selected config
    // Name of workspace config
    const wxString workspaceConfig = FindWorkspaceConfig(
        matrix->GetConfigurations(), project, config
    );

    // Foreach projects
    for (wxArrayString::const_iterator it = projects.begin(),
        ite = projects.end(); it != ite; ++it) {
        // Translate project config
        const wxString projectConfig = matrix->GetProjectSelectedConf(workspaceConfig, *it);

        const CMakeSettingsManager* mgr = m_plugin->GetSettingsManager();
        wxASSERT(mgr);
        const CMakeProjectSettings* projectSettings = mgr->GetProjectSettings(*it, projectConfig);

        const bool append =
            projectSettings &&
            projectSettings->enabled &&
            projectSettings != settings &&
            projectSettings->parentProject.IsEmpty()
        ;

        // Add project if CMake is enabled for it
        if (append)
            m_choiceParent->Append(*it);
    }

    m_settings = settings;
    LoadSettings();
}
Exemple #4
0
void WorkspaceTab::DoWorkspaceConfig()
{
    // Update the workspace configuration
    BuildMatrixPtr matrix = WorkspaceST::Get()->GetBuildMatrix();
    std::list<WorkspaceConfigurationPtr> confs = matrix->GetConfigurations();

    m_workspaceConfig->Freeze();
    m_workspaceConfig->Enable(true);
    m_workspaceConfig->Clear();
    for (std::list<WorkspaceConfigurationPtr>::iterator iter = confs.begin() ; iter != confs.end(); iter++) {
        m_workspaceConfig->Append((*iter)->GetName());
    }
    if (m_workspaceConfig->GetCount() > 0) {
        m_workspaceConfig->SetStringSelection(matrix->GetSelectedConfigurationName());
    }
    m_workspaceConfig->Append(OPEN_CONFIG_MGR_STR);
    m_workspaceConfig->Thaw();

    clMainFrame::Get()->SelectBestEnvSet();
}
void clCxxWorkspace::AddProjectToBuildMatrix(ProjectPtr prj)
{
    if(!prj) {
        wxMessageBox(_("AddProjectToBuildMatrix was called with NULL project"), _("CodeLite"), wxICON_WARNING | wxOK);
        return;
    }

    BuildMatrixPtr matrix = GetBuildMatrix();
    wxString selConfName = matrix->GetSelectedConfigurationName();

    std::list<WorkspaceConfigurationPtr> wspList = matrix->GetConfigurations();
    std::list<WorkspaceConfigurationPtr>::iterator iter = wspList.begin();
    for(; iter != wspList.end(); iter++) {
        WorkspaceConfigurationPtr workspaceConfig = (*iter);
        WorkspaceConfiguration::ConfigMappingList prjList = workspaceConfig->GetMapping();
        wxString wspCnfName = workspaceConfig->GetName();

        ProjectSettingsCookie cookie;

        // getSettings is a bit misleading, since it actually create new instance which represents the layout
        // of the XML
        ProjectSettingsPtr settings = prj->GetSettings();
        BuildConfigPtr prjBldConf = settings->GetFirstBuildConfiguration(cookie);
        BuildConfigPtr matchConf;

        if(!prjBldConf) {
            // the project does not have any settings, create new one and add it
            prj->SetSettings(settings);

            settings = prj->GetSettings();
            prjBldConf = settings->GetFirstBuildConfiguration(cookie);
            matchConf = prjBldConf;

        } else {

            matchConf = prjBldConf;

            // try to locate the best match to add to the workspace
            while(prjBldConf) {
                wxString projBldConfName = prjBldConf->GetName();
                if(wspCnfName == projBldConfName) {
                    // we found a suitable match use it instead of the default one
                    matchConf = prjBldConf;
                    break;
                }
                prjBldConf = settings->GetNextBuildConfiguration(cookie);
            }
        }

        ConfigMappingEntry entry(prj->GetName(), matchConf->GetName());
        prjList.push_back(entry);
        (*iter)->SetConfigMappingList(prjList);
        matrix->SetConfiguration((*iter));
    }

    // and set the configuration name
    matrix->SetSelectedConfigurationName(selConfName);

    // this will also reset the build matrix pointer
    SetBuildMatrix(matrix);
}