[Uml-devel] kdesdk/umbrello/umbrello
Oliver Kellogg
okellogg at users.sourceforge.net
Mon Dec 13 15:51:01 UTC 2004
CVS commit by okellogg:
Constructor: Add optional UMLAssociation arg.
M +20 -8 associationwidget.cpp 1.136
M +3 -1 associationwidget.h 1.57
--- kdesdk/umbrello/umbrello/associationwidget.cpp #1.135:1.136
@@ -53,5 +53,6 @@ AssociationWidget::AssociationWidget(UML
// the preferred constructor
AssociationWidget::AssociationWidget(UMLView *view, UMLWidget* pWidgetA,
- Association_Type assocType, UMLWidget* pWidgetB )
+ Association_Type assocType, UMLWidget* pWidgetB,
+ UMLAssociation *umlassoc /* = NULL */)
: WidgetBase(view)
{
@@ -59,4 +60,7 @@ AssociationWidget::AssociationWidget(UML
UMLDoc *umldoc = UMLApp::app()->getDocument();
+ if (umlassoc)
+ setUMLAssociation(umlassoc);
+ else
// set up UMLAssociation obj if assoc is represented and both roles are UML objects
if (UMLAssociation::assocTypeHasUMLRepresentation(assocType)) {
@@ -72,6 +76,10 @@ AssociationWidget::AssociationWidget(UML
// But lets leave check in here for the time being so that debugging
// output is shown, in case there is a collision with code elsewhere.
- UMLAssociation * testAssoc = umldoc->findAssociation( assocType, umlRoleA, umlRoleB, &swap );
- if (testAssoc != NULL)
+ UMLAssociation * myAssoc = umldoc->findAssociation( assocType, umlRoleA, umlRoleB, &swap );
+ if (myAssoc != NULL) {
+ if (assocType == at_Generalization) {
+ kdDebug() << " Ignoring second construction of same generalization"
+ << endl;
+ } else {
kdDebug() << " constructing a similar or exact same assoc " <<
"as an already existing assoc (swap=" << swap << ")" << endl;
@@ -76,7 +84,10 @@ AssociationWidget::AssociationWidget(UML
kdDebug() << " constructing a similar or exact same assoc " <<
"as an already existing assoc (swap=" << swap << ")" << endl;
-
// now, just create a new association anyways
- UMLAssociation * myAssoc = new UMLAssociation( assocType, umlRoleA, umlRoleB );
+ myAssoc = NULL;
+ }
+ }
+ if (myAssoc == NULL)
+ myAssoc = new UMLAssociation( assocType, umlRoleA, umlRoleB );
setUMLAssociation(myAssoc);
}
@@ -858,4 +869,5 @@ QString AssociationWidget::toString() {
}
+ string.append(":");
if(m_role[B].m_pRole) {
string += m_role[B].m_pRole -> getText();
--- kdesdk/umbrello/umbrello/associationwidget.h #1.56:1.57
@@ -78,7 +78,9 @@ public:
* @param Type The Association_Type for this association.
* @param WidgetB Pointer the role B widget for the association.
+ * @param umlassoc Pointer the underlying UMLAssociation (if applicable.)
*/
AssociationWidget(UMLView *view, UMLWidget* WidgetA,
- Uml::Association_Type Type, UMLWidget* WidgetB);
+ Uml::Association_Type Type, UMLWidget* WidgetB,
+ UMLAssociation *umlassoc = NULL);
/**
More information about the umbrello-devel
mailing list