[Uml-devel] branches/KDE/3.5/kdesdk/umbrello

Oliver Kellogg okellogg at users.sourceforge.net
Tue Nov 21 19:09:35 UTC 2006


SVN commit 606778 by okellogg:

Apply FixCollaborationAssocWidget.diff by Achim Spangler, see
 http://www.geeksoc.org/~jr/umbrello/uml-devel/9857.html
I factored out a new method, isCollaboration(). Many thanks Achim.


 M  +4 -0      ChangeLog  
 M  +16 -12    umbrello/associationwidget.cpp  
 M  +5 -0      umbrello/associationwidget.h  


--- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #606777:606778
@@ -1,4 +1,8 @@
 Version 1.5.6
+
+* Fixed save/reload of association widgets for collaboration diagrams
+  http://www.geeksoc.org/~jr/umbrello/uml-devel/9825.html
+  http://www.geeksoc.org/~jr/umbrello/uml-devel/9857.html
 * Bugs/wishes from http://bugs.kde.org:
 * Artifacts of a component diagram are wrongly placed in Deployment View folder (137564)
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/associationwidget.cpp #606777:606778
@@ -113,7 +113,7 @@
     // Collaboration messages need a name label because it's that
     // which lets operator== distinguish them, which in turn
     // permits us to have more than one message between two objects.
-    if (getAssocType() == at_Coll_Message) {
+    if (isCollaboration()) {
         // Create a temporary name to bring on setName()
         int collabID = m_pView->generateCollaborationId();
         setName("m" + QString::number(collabID));
@@ -449,7 +449,7 @@
 
 void AssociationWidget::setMessageText(FloatingTextWidget *ft) {
     QString message;
-    if (getAssocType() == at_Coll_Message) {
+    if (isCollaboration()) {
         if (m_pObject != NULL) {
             message = getMulti(A) + ": " + getOperationText(m_pView);
         } else {
@@ -842,6 +842,11 @@
     return (widget == m_role[A].m_pWidget || widget == m_role[B].m_pWidget);
 }
 
+bool AssociationWidget::isCollaboration() {
+    Uml::Association_Type at = getAssocType();
+    return (at == at_Coll_Message || at == at_Coll_Message_Self);
+}
+
 Association_Type AssociationWidget::getAssocType() const {
     if (m_pObject == NULL || m_pObject->getBaseType() != ot_Association)
         return m_AssocType;
@@ -2265,7 +2270,7 @@
     if( menuType == ListPopupMenu::mt_Undefined ) {
         if (type == at_Anchor || onAssocClassLine(p))
             menuType = ListPopupMenu::mt_Anchor;
-        else if( type == at_Coll_Message )
+        else if (isCollaboration())
             menuType = ListPopupMenu::mt_Collaboration_Message;
         else if( AssocRules::allowRole( type ) )
             menuType = ListPopupMenu::mt_FullAssociation;
@@ -2315,7 +2320,7 @@
 
     //if it's a collaboration message we now just use the code in floatingtextwidget
     //this means there's some redundant code below but that's better than duplicated code
-    if (atype == at_Coll_Message && sel != ListPopupMenu::mt_Delete) {
+    if (isCollaboration() && sel != ListPopupMenu::mt_Delete) {
         m_pName->slotMenuSelection(sel);
         return;
     }
@@ -3256,8 +3261,7 @@
 }
 
 UMLClassifier *AssociationWidget::getOperationOwner() {
-    Association_Type atype = getAssocType();
-    Role_Type role = (atype == at_Coll_Message ? B : A);
+    Role_Type role = (isCollaboration() ? B : A);
     UMLObject *o = getWidget(role)->getUMLObject();
     if (o == NULL)
         return NULL;
@@ -3383,6 +3387,9 @@
     setWidget(pWidgetA, A);
     setWidget(pWidgetB, B);
 
+    QString type = qElement.attribute( "type", "-1" );
+    Uml::Association_Type aType = (Uml::Association_Type) type.toInt();
+
     QString id = qElement.attribute( "xmi.id", "-1" );
     bool oldStyleLoad = false;
     if (id == "-1") {
@@ -3393,8 +3400,6 @@
         // Create the UMLAssociation if both roles are UML objects;
         // else load the info locally.
 
-        QString type = qElement.attribute( "type", "-1" );
-        Uml::Association_Type aType = (Uml::Association_Type) type.toInt();
         if (UMLAssociation::assocTypeHasUMLRepresentation(aType)) {
             // lack of an association in our widget AND presence of
             // both uml objects for each role clearly identifies this
@@ -3475,13 +3480,11 @@
             return false;
         } else {
             const Uml::Object_Type ot = myObj->getBaseType();
-            if (ot == ot_Attribute || ot == ot_EntityAttribute) {
+            if (ot != ot_Association) {
                 setUMLObject(myObj);
-                QString type = qElement.attribute( "type", "-1" );
-                Uml::Association_Type aType = (Uml::Association_Type) type.toInt();
                 setAssocType(aType);
             } else {
-                UMLAssociation * myAssoc = (UMLAssociation*)myObj;
+                UMLAssociation * myAssoc = static_cast<UMLAssociation*>(myObj);
                 setUMLAssociation(myAssoc);
                 m_LinePath.setAssocType( myAssoc->getAssocType() );
             }
@@ -3576,6 +3579,7 @@
                 break;
 
             case Uml::tr_Coll_Message:
+            case Uml::tr_Coll_Message_Self:
                 m_pName = ft;
                 ft->setLink(this);
                 ft->setActivated();
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/associationwidget.h #606777:606778
@@ -243,6 +243,11 @@
     bool contains(UMLWidget* widget);
 
     /**
+     * Returns true if this AssociationWidget represents a collaboration message.
+     */
+    bool isCollaboration();
+
+    /**
      * Gets the association's type.
      *
      * @return  This AssociationWidget's Association_Type.




More information about the umbrello-devel mailing list