예제 #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;
}
예제 #2
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);
}