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

Sharan Rao sharanrao at gmail.com
Fri Nov 16 12:32:43 UTC 2007


SVN commit 737525 by sharan:

In the properties page of an association widget, dynamically load all possible associations to which the current association can change to.


 M  +4 -3      association.cpp  
 M  +11 -1     assocrules.cpp  
 M  +18 -3     dialogs/assocgenpage.cpp  


--- trunk/KDE/kdesdk/umbrello/umbrello/association.cpp #737524:737525
@@ -99,7 +99,8 @@
             i18n("Activity"),                   // at_Activity
             i18n("Exception"),                  // at_Activity
             i18n("Category to Parent"),         // at_Category2Parent
-            i18n("Child to Category")           // at_Child2Category
+            i18n("Child to Category"),          // at_Child2Category
+            i18n("Relationship" )               // at_Relationship
         };
 
 Uml::Association_Type UMLAssociation::getAssocType() const {
@@ -394,10 +395,10 @@
                     "state",            // at_State
                     "activity",         // at_Activity
                     "exception",        // at_Exception
-                    "relationship"      // at_Relationship
                     "category2parent"   // at_Category2Parent
                     "child2category"    // at_Child2Category
-            };
+                    "relationship"      // at_Relationship
+        };
 
         unsigned index;
         for (index = 0; index < nAssocTypes; index++)
--- trunk/KDE/kdesdk/umbrello/umbrello/assocrules.cpp #737524:737525
@@ -133,6 +133,11 @@
     Widget_Type widgetTypeA = widgetA->getBaseType();
     Widget_Type widgetTypeB = widgetB->getBaseType();
     bool bValid = false;
+
+    if ( widgetA->getUMLObject() == widgetB->getUMLObject() ) {
+        return allowSelf( assocType, widgetTypeA );
+    }
+
     for (int i = 0; i < m_nNumRules; i++) {
         if (assocType == m_AssocRules[i].assoc_type) {
             if( (widgetTypeA == m_AssocRules[i].widgetA_type &&
@@ -151,11 +156,16 @@
     if (!bValid) {
         return false;
     }
+
     AssociationWidgetList list = widgetB -> getAssocList();
 
     switch( assocType ) {
+    case at_Association_Self:
+        if ( widgetA->getUMLObject() == widgetB->getUMLObject() )
+            return true;
+        break;
+
     case at_Association:
-    case at_Association_Self:
     case at_UniAssociation:
     case at_Dependency:
     case at_Coll_Message:
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/assocgenpage.cpp #737524:737525
@@ -29,6 +29,7 @@
 // local includes
 #include "../association.h"
 #include "../dialog_utils.h"
+#include "../assocrules.h"
 
 AssocGenPage::AssocGenPage (UMLDoc *d, QWidget *parent, AssociationWidget *assoc)
         : QWidget(parent)
@@ -87,10 +88,24 @@
 
     /* Here is a list of all the supported choices for changing
        association types */
+
     m_AssocTypes.clear();
-    m_AssocTypes <<  Uml::at_Aggregation
-        << Uml::at_Composition << Uml::at_Containment;
 
+    m_AssocTypes<<currentType;
+
+    // dynamically load all allowed associations
+    for ( int i = Uml::at_Generalization; i<= Uml::at_Relationship ;  ++i ) {
+        // we don't need to check for current type
+        if (  ( Uml::Association_Type )i == currentType )
+            continue;
+
+        if ( AssocRules::allowAssociation( ( Uml::Association_Type )i, m_pAssociationWidget->getWidget( Uml::A ),
+                                           m_pAssociationWidget->getWidget( Uml::B ))
+             ) {
+            m_AssocTypes<<( Uml::Association_Type )i;
+        }
+    }
+
     bool found=false;
     m_AssocTypeStrings.clear();
     for (int i = 0; i < m_AssocTypes.size(); ++i) {
@@ -110,7 +125,7 @@
     pTypeL->setBuddy(m_pTypeCB);
     m_pTypeCB->addItems(m_AssocTypeStrings);
     m_pTypeCB->setCompletedItems(m_AssocTypeStrings);
-    m_pTypeCB->setItemText(m_pTypeCB->currentIndex(), currentTypeAsString);
+
     m_pTypeCB->setDuplicatesEnabled(false);//only allow one of each type in box
     m_pTypeCB->setCompletionMode( KGlobalSettings::CompletionPopup );
     m_pDoc->setWordWrap(Q3MultiLineEdit::WidgetWidth);




More information about the umbrello-devel mailing list