Ejemplo n.º 1
0
ecConfigItem *ecConflictListCtrl::AssociatedItem(int nRow,int nCol)
{
    const CdlConflict conflict = (CdlConflict) GetItemData (nRow);
    wxASSERT (conflict != NULL);
    
    ecConfigItem *pItem=NULL;
    switch(nCol)
    {
    case 2:
        {
            const CdlGoalExpression goal = dynamic_cast<CdlGoalExpression> (conflict->get_property ());
            if (! goal) // if the item is not a goal expression
                break; // do nothing
            const CdlExpression expression = goal->get_expression ();
            if (1 == expression->references.size ()) // if the property contains a single reference
            {
                // assume that the reference is to another user visible node and try to find it
                const wxString strName(expression->references [0].get_destination_name ().c_str());
                pItem = wxGetApp().GetConfigToolDoc ()->Find(strName);
            }
        }
        break;
    case 0:
        pItem = wxGetApp().GetConfigToolDoc ()->Find(wxString(conflict->get_node ()->get_name ().c_str()));
        break;
    default:
        break;
    }
    return pItem;
}
void CFailingRulesDialog::AddConflictSolutions(CdlConflict conflict)
{
  SolutionInfo &info=Info(conflict);

  const std::vector<std::pair<CdlValuable, CdlValue> >&Solution=conflict->get_solution();

  int i=0;
  for (std::vector<std::pair<CdlValuable, CdlValue> >::const_iterator soln_i = Solution.begin();
       soln_i != Solution.end(); soln_i++) {
    CdlValuable valuable  = soln_i->first;
    CdlValue value=soln_i->second;
    CdlValueFlavor flavor = valuable->get_flavor();

    CString strValue;
    switch(flavor) {
      case CdlValueFlavor_None :
        break;
      case CdlValueFlavor_Bool :
        strValue=value.is_enabled() ? _T("Enabled") : _T("Disabled");
        break;
      case CdlValueFlavor_BoolData :
        strValue.Format(_T("%s, %s"), value.is_enabled() ? _T("Enabled") : _T("Disabled"), CString(value.get_value().c_str()));
        break;
      case CdlValueFlavor_Data :
        strValue=value.get_value().c_str();
        break;
    }
    
    const CString strName(soln_i->first->get_name().c_str());
    LVFINDINFO fi;
    fi.flags=LVFI_STRING;
    fi.psz=strName;
    int nIndex=m_List.FindItem(&fi);
    if(-1==nIndex || strValue!=m_List.GetItemText(nIndex,1)){
      // We don't have an existing solution that matches this one
      nIndex=m_List.GetItemCount();
      m_List.InsertItem(nIndex,strName);
      m_List.SetItemData(nIndex,1);
      m_List.SetItemText(nIndex,1,strValue);
      ASSERT(info.arItem[i]<0);
      m_List.SetCheck(nIndex,SolutionInfo::CHECKED==info.arItem[i]);
    } else {
      // We do - to avoid duplicates, increment the "ref count"
      m_List.SetItemData(nIndex,m_List.GetItemData(nIndex)+1);
    }
    info.arItem[i++]=nIndex; 
  }
  if(0==i){
    SetDlgItemText(IDC_STATIC1,_T("No solution is available for this conflict"));
    m_List.ShowWindow(SW_HIDE);
  } else {
    SetDlgItemText(IDC_STATIC1,_T("Proposed solution:"));
    m_List.ShowWindow(SW_SHOW);
    m_List.SetColumnWidth(0,LVSCW_AUTOSIZE);
    CRect rect;
    m_List.GetClientRect(rect);
    m_List.SetColumnWidth(1,rect.Width()-m_List.GetColumnWidth(0));
  }
}
Ejemplo n.º 3
0
void ecConflictListCtrl::AddConflict (const CdlConflict &conf)
{
    // set the item column string
    wxString strMacroName = (conf)->get_node ()->get_name ().c_str ();
    int nIndex = InsertItem (GetItemCount (), strMacroName);

    nIndex = GetItemCount() - 1;

    SetItemData (nIndex, (long) (conf));
    
    // set the conflict column string
    if (0 != dynamic_cast<CdlConflict_Unresolved> (conf)) {// a conflict of type 'unresolved'
        SetItem (nIndex, 1, wxT("Unresolved"));
    } else if (0 != dynamic_cast<CdlConflict_IllegalValue> (conf)) { // a conflict of type 'illegal value'
        SetItem (nIndex, 1, wxT("Illegal"));
    } else if (0 != dynamic_cast<CdlConflict_EvalException> (conf)) { // a conflict of type 'evaluation exception'
        SetItem (nIndex, 1, wxT("Exception"));
    } else if (0 != dynamic_cast<CdlConflict_Requires> (conf)) { // a conflict of type 'goal unsatisfied'
        SetItem (nIndex, 1, wxT("Unsatisfied"));
    } else if (0 != dynamic_cast<CdlConflict_Data> (conf)) { // a conflict of type 'bad data'
        SetItem (nIndex, 1, wxT("Bad data"));
    } else {
        wxASSERT (0);
    }
    
    // set the property column string
    wxString strProperty = conf->get_property ()->get_property_name ().c_str ();
    strProperty += wxT(" ");
    const std::vector<std::string> & argv = conf->get_property ()->get_argv ();
    std::vector<std::string>::const_iterator argv_i;
    for (argv_i = argv.begin (); argv_i != argv.end (); argv_i++) {// for each property argument...
        if (argv_i != argv.begin ())                              // ...except the first
        {
            strProperty += argv_i->c_str (); // add the argument to the string
            strProperty += wxT (" "); // separate arguments by a space character
        }
    }
    strProperty.Trim (TRUE); // remove the trailing space character
    SetItem (nIndex, 2, strProperty);
}
Ejemplo n.º 4
0
void ecResolveConflictsDialog::AddConflictSolutions(CdlConflict conflict)
{
    // SolutionInfo allows each conflict to know which solutions have been found for it
    SolutionInfo &info=Info(conflict);
    
    const std::vector<std::pair<CdlValuable, CdlValue> >&Solution=conflict->get_solution();
    
    int i=0;
    for (std::vector<std::pair<CdlValuable, CdlValue> >::const_iterator soln_i = Solution.begin();
         soln_i != Solution.end(); soln_i++)
    {
        CdlValuable valuable = soln_i->first;
        CdlValue value = soln_i->second;
        CdlValueFlavor flavor = valuable->get_flavor();
        
        wxString strValue;
        switch(flavor)
        {
        case CdlValueFlavor_None :
            break;
        case CdlValueFlavor_Bool :
            strValue = value.is_enabled() ? _("Enabled") : _("Disabled");
            break;
        case CdlValueFlavor_BoolData :
            strValue.Printf(wxT("%s, %s"), (const wxChar*) (value.is_enabled() ? _("Enabled") : _("Disabled")), (const wxChar*) value.get_value().c_str());
            break;
        case CdlValueFlavor_Data :
            strValue = value.get_value().c_str();
            break;
        }
        
        const wxString strName(soln_i->first->get_name().c_str());

        long nIndex = m_solutionsCtrl->FindItem(0, strName);
        wxListItem listItem;
        listItem.m_mask = wxLIST_MASK_TEXT;
        listItem.m_itemId = nIndex;
        listItem.m_col = 1;
        if (nIndex != -1)
            m_solutionsCtrl->GetItem(listItem);

        if (-1 == nIndex || strValue != listItem.m_text)
        {
            // We don't have an existing solution that matches this one
            nIndex = m_solutionsCtrl->GetItemCount();
            m_solutionsCtrl->InsertItem(nIndex, strName);
            m_solutionsCtrl->SetItemData(nIndex, 1);
            m_solutionsCtrl->SetItem(nIndex, 1, strValue);

            wxASSERT(info.arItem[i]<0);

            m_solutionsCtrl->SetChecked(nIndex, SolutionInfo::CHECKED==info.arItem[i]);
        } else {
            // We do - to avoid duplicates, increment the "ref count"
            m_solutionsCtrl->SetItemData(nIndex, m_solutionsCtrl->GetItemData(nIndex)+1);
        }
        info.arItem[i++]=nIndex; 

    }
    wxStaticText* staticCtrl = (wxStaticText*) FindWindow(ecID_CONFLICTS_MSG);

    if(0==i){
        staticCtrl->SetLabel(_("No solution is available for this conflict"));
        m_solutionsCtrl->Show(FALSE);
    } else {
        staticCtrl->SetLabel(_("Proposed solution:"));
        m_solutionsCtrl->Show(TRUE);
        // TODO (if necessary)
#if 0
        m_List.SetColumnWidth(0,LVSCW_AUTOSIZE);
        CRect rect;
        m_List.GetClientRect(rect);
        m_List.SetColumnWidth(1,rect.Width()-m_List.GetColumnWidth(0));
#endif
    }
}