Commit 62ff3886 authored by Ralf Habacker's avatar Ralf Habacker

Auto create attributes on adding aggregations and compositions

parent cc11848d
......@@ -16,6 +16,7 @@
#include "association.h"
#include "associationline.h"
#include "associationwidget.h"
#include "classifier.h"
#include "classifierwidget.h"
#include "cmds/widget/cmdcreatewidget.h"
#include "floatingtextwidget.h"
......@@ -236,6 +237,19 @@ void ToolBarStateAssociation::setSecondWidget()
widgetA->updateGeometry();
if (widgetB->changesShape())
widgetB->updateGeometry();
if (widgetA->isClassWidget() && widgetB->isClassWidget()) {
if (temp->associationType() == Uml::AssociationType::Composition) {
UMLClassifier *c = widgetA->umlObject()->asUMLClassifier();
UMLAttribute *attr = new UMLAttribute(c, c->uniqChildName(UMLObject::ot_Attribute));
attr->setType(widgetB->umlObject());
c->addAttribute(attr);
} else if (temp->associationType() == Uml::AssociationType::Aggregation) {
UMLClassifier *c = widgetA->umlObject()->asUMLClassifier();
UMLAttribute *attr = new UMLAttribute(c, c->uniqChildName(UMLObject::ot_Attribute));
attr->setTypeName(QString(QLatin1String("%1*")).arg(widgetB->umlObject()->name()));
c->addAttribute(attr);
}
}
FloatingTextWidget *wt = temp->textWidgetByRole(Uml::TextRole::Coll_Message);
if (wt)
wt->showOperationDialog();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment