Author: bobtarling
Date: 2010-04-24 07:17:24-0700
New Revision: 18331

Modified:
   
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SimpleListModel.java

Log:
Sometimes it seems we get duplicate events. If the model element added is 
already in the control then ignore subsequent.

Modified: 
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SimpleListModel.java
Url: 
http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SimpleListModel.java?view=diff&pathrev=18331&r1=18330&r2=18331
==============================================================================
--- 
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SimpleListModel.java
        (original)
+++ 
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SimpleListModel.java
        2010-04-24 07:17:24-0700
@@ -130,38 +130,40 @@
                Runnable doWorkRunnable = new Runnable() {
                    public void run() {
                        try {
-                               if 
(getterSetterManager.isFullBuildOnly(propertyName)) {
-                                       removeAllElements();
-                                       build();
-                               } else {
-                                   if (e instanceof RemoveAssociationEvent) {
-                                       final Object objectToRemove =
+                           if 
(getterSetterManager.isFullBuildOnly(propertyName)) {
+                               removeAllElements();
+                               build();
+                           } else {
+                               if (e instanceof RemoveAssociationEvent) {
+                                   final Object objectToRemove =
                                                ((RemoveAssociationEvent) 
e).getChangedValue();
-                                       removeElement(objectToRemove);
-                                   } else if (e instanceof 
AddAssociationEvent) {
-                                       Object newElement = 
((AddAssociationEvent) e).getChangedValue();
+                                   removeElement(objectToRemove);
+                               } else if (e instanceof AddAssociationEvent) {
+                                   Object newElement = ((AddAssociationEvent) 
e).getChangedValue();
                                        
-                                       if 
(Model.getUmlHelper().isMovable(getMetaType())) {
-                                           final Collection c =
-                                               (Collection) 
getterSetterManager.getOptions( 
-                                                   umlElement, 
-                                                   propertyName, 
-                                                   type);
-                                           final int index =
-                                               CollectionUtil.indexOf(c, 
newElement);
-                                           if (index < 0 || index > getSize() 
- 1) {
-                                               LOG.warn(
-                                                       "Unable to add element 
at correct position "
-                                                       + index + " added to 
end instead");
-                                               addElement(newElement);
-                                           } else {
-                                               add(index, newElement);
-                                           }
-                                       } else {
-                                           addElement(newElement);
-                                       }
+                                   if 
(!SimpleListModel.this.contains(newElement)) {
+                                       if 
(Model.getUmlHelper().isMovable(getMetaType())) {
+                                           final Collection c =
+                                               (Collection) 
getterSetterManager.getOptions( 
+                                                   umlElement, 
+                                                   propertyName, 
+                                                   type);
+                                           final int index =
+                                               CollectionUtil.indexOf(c, 
newElement);
+                                           if (index < 0 || index > getSize() 
- 1) {
+                                               LOG.warn(
+                                                       "Unable to add element 
at correct position "
+                                                       + index + " added to 
end instead");
+                                               addElement(newElement);
+                                           } else {
+                                               add(index, newElement);
+                                           }
+                                       } else {
+                                           addElement(newElement);
+                                       }
                                    }
-                               }
+                               }
+                           }
                        } catch (InvalidElementException e) {
                            LOG.debug("propertyChange accessed a deleted 
element ", e);
                        }

------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2594297

To unsubscribe from this discussion, e-mail: 
[[email protected]].

Reply via email to