Bug 83834 - Can't create more then one "message" from class A to class B in collaboration diagram
Summary: Can't create more then one "message" from class A to class B in collaboration...
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-22 23:35 UTC by Anthony Parent
Modified: 2005-02-23 00:22 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Anthony Parent 2004-06-22 23:35:55 UTC
Version:           1.2.90 (using KDE 3.2.2, compiled sources)
Compiler:          gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
OS:                Linux (i686) release 2.4.20-6

CVS Head as of 06/22/04

When editing a collaboration diagram I can't generate more then one "message" (f(x)) from a class to any other class. There are times when one class may send several different messages to another class. While I can create more then one instance of the second class and send one message to each, that seems confusing to me in that it seems to imply that you have multiple instances in the program of each class. When in fact there are only one instance of each class talking back and forth.
Comment 1 Jonathan Riddell 2004-07-05 20:13:21 UTC
This isn't one of the rules in assocwidget, it causes an error message:

umbrello: UMLView::addWidget: Not adding (id=120/type=312/name=new_class_1) because it's already there
umbrello: ERROR: cannot addAssocInViewAndDoc(), deleting
Comment 2 Rafael Ávila de Espíndola 2004-10-23 16:09:05 UTC
the bug is also present in version 1.3.0 with kde 3.3.
How about having a link option instead of a message one?
The link would be a simple line and multiples messages (in both directions) would be properties of this link, each message represented be an arrow.
Comment 3 Oliver Kellogg 2005-02-23 00:22:16 UTC
CVS commit by okellogg: 

Permit more than one message from one collaborating object to another.
BUG:83834


  M +14 -8     associationwidget.cpp   1.140
  M +5 -0      umlview.cpp   1.207
  M +10 -0     umlview.h   1.72


--- kdesdk/umbrello/umbrello/associationwidget.cpp  #1.139:1.140
@@ -106,16 +106,18 @@ AssociationWidget::AssociationWidget(UML
         mergeAssociationDataIntoUMLRepresentation();
 
-        //collaboration messages need a name label because it's that
-        //which handles the right click menu options
+        // 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) {
                 // Create a temporary name to bring on setName()
-                ObjectWidget *ow = static_cast<ObjectWidget*>(m_role[B].m_pWidget);
-                QString localIdStr = ID2STR(ow->getLocalID());
-                setName("m" + localIdStr);
-                if (m_pObject)
+                int collabID = m_pView->generateCollaborationId();
+                setName("m" + QString::number(collabID));
+                if (m_pObject) {
                         m_pName->setUMLObject( m_pObject );
-                else
+                } else {
+                        ObjectWidget *ow = static_cast<ObjectWidget*>(m_role[B].m_pWidget);
                         m_pName->setUMLObject( ow->getUMLObject() );
         }
+        }
 }
 
@@ -216,5 +218,9 @@ bool AssociationWidget::operator==(Assoc
         }
 
-        return true;
+        // Two objects in a collaboration can have multiple messages between each other.
+        // Here we depend on the messages having names, and the names must be different.
+        // That is the reason why collaboration messages have strange initial names like
+        // "m29997" or similar.
+        return (getName() == Other.getName());
 }
 

--- kdesdk/umbrello/umbrello/umlview.cpp  #1.206:1.207
@@ -130,4 +130,5 @@ void UMLView::init() {
         m_nCanvasWidth = UMLView::defaultCanvasSize;
         m_nCanvasHeight = UMLView::defaultCanvasSize;
+        m_nCollaborationId = 0;
 
         // Initialize other data
@@ -221,4 +222,8 @@ void UMLView::setName(const QString &nam
 }
 
+int UMLView::generateCollaborationId() {
+        return ++m_nCollaborationId;
+}
+
 void UMLView::print(KPrinter *pPrinter, QPainter & pPainter) {
         int height, width;

--- kdesdk/umbrello/umbrello/umlview.h  #1.71:1.72
@@ -948,4 +948,9 @@ public:
         }
 
+        /**
+         * Used for creating unique name of collaboration messages.
+         */
+        int generateCollaborationId();
+
 protected:
 
@@ -1148,4 +1153,9 @@ protected:
         void forceUpdateWidgetFontMetrics(QPainter *painter);
 
+        /**
+         * Used for creating unique name of collaboration messages.
+         */
+        int m_nCollaborationId;
+
         QPoint m_Pos, m_LineToPos;
         bool m_bCreateObject, m_bDrawRect, m_bDrawSelectedOnly, m_bPaste;