void AdvancedCompilerOptionsDlg::SaveCommands(int cmd, int ext)
{
    if (cmd == -1 || ext == -1)
        return;
    if (CompilerTool* tool = GetCompilerTool(cmd, ext))
    {
        wxTextCtrl* text = XRCCTRL(*this, "txtCommand",   wxTextCtrl);
        wxTextCtrl* gen  = XRCCTRL(*this, "txtGenerated", wxTextCtrl);
        if (text->GetValue() != tool->command) // last command was changed; save it
            tool->command = text->GetValue();
        wxString gens = GetStringFromArray(tool->generatedFiles, _T("\n"), false);
        if (gen->GetValue() != gens) // last genfiles are changed; save it
            tool->generatedFiles = GetArrayFromString(gen->GetValue(), _T("\n"));
    }
}
void AdvancedCompilerOptionsDlg::OnAddExt(wxCommandEvent& WXUNUSED(event))
{
	wxString ext = wxGetTextFromUser(_("Please enter a semi-colon separated list of extensions, without the leading dot:"), _("New extension"));
	ext.Trim(false);
	ext.Trim(true);
	if (!ext.IsEmpty())
	{
		int nr = XRCCTRL(*this, "lstCommands", wxChoice)->GetSelection();
		CompilerTool* ptool = GetCompilerTool(nr,0);
		CompilerTool tool(ptool ? ptool->command : wxString(), ext);
		m_Commands[nr].push_back(tool);
		ReadExtensions(nr);
		wxChoice* cmb = XRCCTRL(*this, "lstExt", wxChoice);
		cmb->SetStringSelection(ext);
		DisplayCommand(nr,cmb->GetSelection());
	}
}
void AdvancedCompilerOptionsDlg::DisplayCommand(int cmd, int ext)
{
    wxTextCtrl* text = XRCCTRL(*this, "txtCommand", wxTextCtrl);
    wxTextCtrl* gen = XRCCTRL(*this, "txtGenerated", wxTextCtrl);
	if (CompilerTool* tool = GetCompilerTool(cmd,ext))
	{
		text->SetValue(tool->command);
		gen->SetValue(GetStringFromArray(tool->generatedFiles, _T("\n"), false));
	}
	else
	{
		text->Clear();
		gen->Clear();
	}
	m_LastCmdIndex = cmd;
	m_LastExtIndex = ext;
} // end of DisplayCommand