예제 #1
0
void ecBuildOptionsDialog::Redisplay (wxTreeItemId item)
{
    ecConfigItem *pti= ((ecBuildOptionsData*) m_treeCtrl->GetItemData(item))->GetConfigItem();

    const CdlValuable valuable = pti->GetCdlValuable();
    std::string name;
    const CdlBuildInfo_Loadable *pe=NULL;
    if(valuable){
        const char *pszname=valuable->get_name().c_str();
        for(EntriesArray::size_type j=0;j<m_arEntries.size();j++){
            if(0==strcmp(m_arEntries[j].name.c_str(),pszname)){
                pe=&m_arEntries[j];
                break;
            }
        }
    }

    wxString strCat = ((wxChoice*) FindWindow(ecID_BUILD_OPTIONS_CATEGORY))->GetStringSelection();

    const wxString strFlags=get_flags(wxGetApp().GetConfigToolDoc()->GetCdlConfig(), pe, ecUtils::UnicodeToStdStr(strCat)).c_str();

    wxArrayString ar;
    ecUtils::Chop(strFlags,ar, wxT(' '), FALSE, FALSE);

    wxListBox* listBox = (wxListBox*) FindWindow( ecID_BUILD_OPTIONS_FLAGS );
    
    wxString strEdit;
    bool bRedraw=(listBox->Number() != ar.GetCount());
    if(!bRedraw)
    {
        for(int i=0;i<ar.GetCount();i++){
            wxString strOld = listBox->GetString(i);

            if(strOld!=ar[i])
            {
                bRedraw = TRUE;
                break;
            }
        }
    }
    if(bRedraw){
        listBox->Clear();
        for(int i=0;i<ar.GetCount();i++){
            listBox->Append(ar[i]);
        }
    }
}
예제 #2
0
void ecResolveConflictsDialog::OnContinue(wxCommandEvent& event)
{
    // Ensure we have the current conflict check array
    int i;
    for (i = 0; i < m_conflictsCtrl->GetItemCount(); i++)
    {
        if (m_conflictsCtrl->GetItemState(i, wxLIST_STATE_SELECTED) & wxLIST_STATE_SELECTED)
            RemoveConflictSolutions((CdlConflict) m_conflictsCtrl->GetItemData(i));
    }

    // Dismiss the window
    EndModal(wxID_OK);

    std::list<CdlConflict>::const_iterator conf_i;

    for (conf_i= m_conflicts.begin (); conf_i != m_conflicts.end (); conf_i++) // for each conflict
    {
        CdlConflict conflict=*conf_i;
        //int nSolutions=conflict->get_solution().size();
        SolutionInfo &info=Info(conflict);
        int nIndex=0;
        const std::vector<std::pair<CdlValuable, CdlValue> >&Solution=conflict->get_solution();
        for (std::vector<std::pair<CdlValuable, CdlValue> >::const_iterator soln_i = Solution.begin();soln_i != Solution.end(); soln_i++) {
            if(SolutionInfo::CHECKED==info.arItem[nIndex++]){
                CdlValuable valuable  = soln_i->first;
                CdlValue value=soln_i->second;
                CdlValueFlavor flavor = valuable->get_flavor();
                const wxString strName(valuable->get_name().c_str());
                const wxString strValue(value.get_value().c_str());
                bool rc = TRUE;
                wxString str;
                try
                {
                    switch(flavor)
                    {
                    case CdlValueFlavor_None :
                        str = wxT("set CdlValueFlavor_None");
                        rc = FALSE;
                        break;
                    case CdlValueFlavor_Bool :
                        str.Printf(_("%s %s\n"), (const wxChar*) (value.is_enabled()?_("disable"):_("enable")), (const wxChar*) strName);
                        valuable->set_enabled (m_Transaction, value.is_enabled(), CdlValueSource_User);
                        break;
                    case CdlValueFlavor_BoolData :
                        {
                            bool bEnabled=value.is_enabled();
                            str.Printf(_("%s %s and set value to %s\n"), (const wxChar*) (bEnabled? _("disable"):_("enable")), (const wxChar*) strName, (const wxChar*) strValue);
                            // Surely this is wrong - we don't want to set the same value, we want to
                            // set a NEW value.
                            // CdlSimpleValue simple_value = valuable->get_simple_value ();
                            //valuable->set_enabled_and_value (m_Transaction, bEnabled, simple_value, CdlValueSource_User);
                            valuable->set_enabled_and_value (m_Transaction, bEnabled, ecUtils::UnicodeToStdStr (strValue), CdlValueSource_User);
                        }
                        break;
                    case CdlValueFlavor_Data :
                        str.Printf(_("set %s to %s\n"), (const wxChar*) strName, (const wxChar*) strValue);
                        valuable->set_value (m_Transaction, ecUtils::UnicodeToStdStr (strValue), CdlValueSource_User);
                        break;
                    }
                }
                catch(...)
                {
                    rc = FALSE;
                }
                if(rc)
                {
                    wxGetApp().GetConfigToolDoc()->Modify(TRUE);
                } else
                {
                    wxString msg;
                    msg.Printf(_("Failed to %s\n"), (const wxChar*) str);
                    wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);
                }
            }
        }
    }
}
void CFailingRulesDialog::OnOK() 
{
  // Ensure we have the current conflict check array
  for(POSITION pos = m_RulesList.GetFirstSelectedItemPosition();pos;){
    int nItem = m_RulesList.GetNextSelectedItem(pos);
    RemoveConflictSolutions((CdlConflict)m_RulesList.GetItemData(nItem));
  }

  // Dismiss the window
  CeCosDialog::OnOK();

  for (std::list<CdlConflict>::const_iterator conf_i= m_conflicts.begin (); conf_i != m_conflicts.end (); conf_i++) { // for each conflict
    CdlConflict conflict=*conf_i;
    //int nSolutions=conflict->get_solution().size();
    SolutionInfo &info=Info(conflict);
    int nIndex=0;
    const std::vector<std::pair<CdlValuable, CdlValue> >&Solution=conflict->get_solution();
    for (std::vector<std::pair<CdlValuable, CdlValue> >::const_iterator soln_i = Solution.begin();soln_i != Solution.end(); soln_i++) {
      if(SolutionInfo::CHECKED==info.arItem[nIndex++]){
        CdlValuable valuable  = soln_i->first;
        CdlValue value=soln_i->second;
        CdlValueFlavor flavor = valuable->get_flavor();
        const CString strName(valuable->get_name().c_str());
        const CString strValue(value.get_value().c_str());
        bool rc=true;
        CString str;
        try {
          switch(flavor) {
            case CdlValueFlavor_None :
              str=_T("set CdlValueFlavor_None");
              rc=false;
              break;
            case CdlValueFlavor_Bool :
              str.Format(_T("%s %s\n"),value.is_enabled()?_T("disable"):_T("enable"),strName);
              valuable->set_enabled (m_Transaction, value.is_enabled(), CdlValueSource_User);
              break;
            case CdlValueFlavor_BoolData :
              {
                bool bEnabled=value.is_enabled();
                str.Format(_T("%s %s and set value to %s\n"),bEnabled?_T("disable"):_T("enable"),strName,strValue);
                // This is wrong: it should set the NEW value. This is the cause of a long-standing bug...
                // CdlSimpleValue simple_value = valuable->get_simple_value ();
                //valuable->set_enabled_and_value (m_Transaction, bEnabled, simple_value, CdlValueSource_User);
                valuable->set_enabled_and_value (m_Transaction, bEnabled, CUtils::UnicodeToStdStr (strValue), CdlValueSource_User);

              }
              break;
            case CdlValueFlavor_Data :
              str.Format(_T("set %s to %s\n"),strName,strValue);
              valuable->set_value (m_Transaction, CUtils::UnicodeToStdStr (strValue), CdlValueSource_User);
              break;
          }
        }
        catch(...){
          rc=false;
        }
        if(rc){
          CConfigTool::GetConfigToolDoc()->SetModifiedFlag();
        } else {
          CUtils::MessageBoxF(_T("Failed to %s\n"),str);
        }
      }
    }
  }
}