Esempio n. 1
0
void UmlClass::generalizeDependRealize(UmlItem * target, FileIn & in, int context, WrapperStr label, WrapperStr constraint)
{
    static const struct {
        aRelationKind rk;
        const char * err;
    } r[] = {
        { aGeneralisation, "cannot create generalization from '" },
        { aDependency, "cannot create dependency from '" },
        { aRealization, "cannot create realization from '" },
        { aDependency, "cannot create usage from '" },
        { aDependency, "cannot create import from '" }
    };
    UmlItem * rel;

    if (target->kind() == aClass)
        rel = UmlRelation::create(r[context].rk, this, (UmlClass *) target);
    else
        rel = UmlNcRelation::create(r[context].rk, this, target);

    if (rel == 0)
        in.warning(r[context].err + name() + "' to '" + target->name() + "'");
    else {
        if (! label.isEmpty())
            rel->set_Name(label);

        if (! constraint.isEmpty() && (target->kind() == aClass))
            ((UmlRelation *) rel)->set_Constraint(constraint);
    }
}
Esempio n. 2
0
void UmlItem::solveGeneralizationDependencyRealization(int context, WrapperStr idref, WrapperStr label, WrapperStr)
{
    QMap<QString, UmlItem *>::Iterator it = All.find(idref);

    if (it != All.end()) {
        static const struct {
            aRelationKind rk;
            const char * err;
        } r[] = {
            { aGeneralisation, "cannot create generalization from '" },
            { aDependency, "cannot create dependency from '" },
            { aRealization, "cannot create realization from '" },
            { aDependency, "cannot create usage from '" },
            { aDependency, "cannot create import from '" }
        };
        UmlItem * target = *it;
        UmlItem * rel = UmlNcRelation::create(r[context].rk, this, target);

        if (rel == 0)
            UmlCom::trace(r[context].err + name() + "' to '" + target->name() + "'<br>");
        else {
            if (! label.isEmpty())
                rel->set_Name(label);

            switch (context) {
            case 3:
                rel->set_Stereotype("use");
                break;

            case 4:
                rel->set_Stereotype("import");
                break;

            default:
                break;
            }
        }
    }
    else if (!FileIn::isBypassedId(idref))
        UmlCom::trace("relation : unknown target reference '" + idref + "'<br>");

}