Beispiel #1
0
void EnvVarsTableDlg::OnButtonOk( wxCommandEvent& event )
{
	EvnVarList vars;

	std::map<wxString, wxString> envSets;

	wxString content = m_textCtrlDefault->GetText();
	wxString name    = wxT("Default");
	content.Trim().Trim(false);
	envSets[name] = content;

	for (size_t i=1; i<m_notebook1->GetPageCount(); i++) {
		if (i == (size_t)m_notebook1->GetSelection()) {
			vars.SetActiveSet(m_notebook1->GetPageText(i));
		}

		EnvVarSetPage *page = (EnvVarSetPage*) m_notebook1->GetPage(i);
		wxString content = page->m_textCtrl->GetText();
		wxString name    = m_notebook1->GetPageText(i);
		content.Trim().Trim(false);
		envSets[name] = content;
	}
	vars.SetEnvVarSets(envSets);
	EnvironmentConfig::Instance()->WriteObject(wxT("Variables"), &vars);
	event.Skip();
}
Beispiel #2
0
void EnvVarsTableDlg::OnButtonOk(wxCommandEvent& event)
{
    EvnVarList vars;

    std::map<wxString, wxString> envSets;

    wxString content = m_textCtrlDefault->GetText();
    wxString name = wxT("Default");
    content.Trim().Trim(false);
    envSets[name] = content;

    for(size_t i = 1; i < m_notebook1->GetPageCount(); i++) {
        if(i == (size_t)m_notebook1->GetSelection()) {
            vars.SetActiveSet(m_notebook1->GetPageText(i));
        }

        EnvVarSetPage* page = (EnvVarSetPage*)m_notebook1->GetPage(i);
        wxString content = page->m_textCtrl->GetText();
        wxString name = m_notebook1->GetPageText(i);
        content.Trim().Trim(false);
        envSets[name] = content;
    }
    vars.SetEnvVarSets(envSets);
    EnvironmentConfig::Instance()->WriteObject(wxT("Variables"), &vars);
    
    // Notify that the environment variables were modified
    clCommandEvent eventSave(wxEVT_ENVIRONMENT_VARIABLES_MODIFIED);
    EventNotifier::Get()->AddPendingEvent(eventSave);
    
    event.Skip();
}
bool EnvironmentConfig::Load()
{
    bool loaded = ConfigurationToolBase::Load( wxT("config/environment_variables.xml") );
    if(loaded) {
        // make sure that we are using the new format
        wxXmlNode *node = XmlUtils::FindFirstByTagName(m_doc.GetRoot(), wxT("ArchiveObject"));
        if(node) {
            node = XmlUtils::FindFirstByTagName(node, wxT("StringMap"));
            if(node) {

                // this is an old version, convert it to the new format
                EvnVarList vars;
                std::map<wxString, wxString> envSets;
                wxString content;

                wxXmlNode *child = node->GetChildren();
                while(child) {
                    if(child->GetName() == wxT("MapEntry")) {
                        wxString key = child->GetPropVal(wxT("Key"),   wxT(""));
                        wxString val = child->GetPropVal(wxT("Value"), wxT(""));
                        content << key << wxT("=") << val << wxT("\n");
                    }
                    child = child->GetNext();
                }
                envSets[wxT("Default")] = content.Trim().Trim(false);
                vars.SetEnvVarSets(envSets);
                SetSettings(vars);
            }
        }
    }
    return loaded;
}