svn commit: r18644 - trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels: model ui

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: bobtarling
Date: 2010-08-16 12:35:49-0700
New Revision: 18644

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

Log:
Issue 6126
Make the getter setters aware of all the different metatypes they can hold.
Make the SimpleListModel reject any model element that is not in this list.

Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/GetterSetterManager.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/GetterSetterManager.java?view=diff&pathrev=18644&r1=18643&r2=18644
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/GetterSetterManager.java	(original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/GetterSetterManager.java	2010-08-16 12:35:49-0700
@@ -50,11 +50,11 @@
     
     public abstract Object create(String propertyName, String language, String body);
 
-    public abstract Collection getOptions(Object umlElement, String propertyName, Class<?> type);
+    public abstract Collection getOptions(Object umlElement, String propertyName, Collection<Class<?>> types);
     
     public abstract Object getMetaType(String propertyName);
     
-    public abstract boolean isValidElement(String propertyName, Class<?> type, Object umlElement);
+    public abstract boolean isValidElement(String propertyName, Collection<Class<?>> types, Object umlElement);
     
     public abstract Command getRemoveCommand(String propertyName, Object umlElement, Object objectToRemove);
     
@@ -94,14 +94,14 @@
             this.options = options;
         }
 
-        protected Collection getOptions(Object modelElement, Class<?> type) {
+        protected Collection getOptions(Object modelElement, Collection<Class<?>> types) {
             return options;
         }
     }
     
     
     protected abstract class ListGetterSetter extends OptionGetterSetter {
-        abstract boolean isValidElement(Object modelElement, Class<?> type);
+        abstract boolean isValidElement(Object modelElement, Collection<Class<?>> types);
         abstract Object getMetaType();
         boolean isFullBuildOnly() {
         	return false;

Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/GetterSetterManagerImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/GetterSetterManagerImpl.java?view=diff&pathrev=18644&r1=18643&r2=18644
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/GetterSetterManagerImpl.java	(original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/GetterSetterManagerImpl.java	2010-08-16 12:35:49-0700
@@ -148,13 +148,15 @@
     public Collection getOptions(
             final Object umlElement,
             final String propertyName,
-            final Class<?> type) {
+            final Collection<Class<?>> types) {
         BaseGetterSetter bgs = getterSetterByPropertyName.get(propertyName);
         if (bgs instanceof OptionGetterSetter) {
-            LOG.info("OptionGetterSetter found for " + propertyName + " of " + bgs);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("OptionGetterSetter found for "
+                	+ propertyName + " of " + bgs);
+            }
             final OptionGetterSetter ogs = (OptionGetterSetter) bgs;
-            final Collection options = ogs.getOptions(umlElement, type);
-            return options;
+            return ogs.getOptions(umlElement, types);
         }
         
         return null;
@@ -182,11 +184,11 @@
     
     public boolean isValidElement(
             final String propertyName,
-            final Class<?> type,
+            final Collection<Class<?>> types,
             final Object element) {
         BaseGetterSetter bgs = getterSetterByPropertyName.get(propertyName);
         if (bgs instanceof ListGetterSetter) {
-            return ((ListGetterSetter) bgs).isValidElement(element, type);
+            return ((ListGetterSetter) bgs).isValidElement(element, types);
         }
         
         return false;
@@ -664,18 +666,18 @@
         /**
          * Get all the features for the model
          * @param modelElement
-         * @param type
+         * @param types
          * @return
-         * @see org.argouml.core.propertypanels.model.GetterSetterManager.OptionGetterSetter#getOptions(java.lang.Object, java.lang.String)
+         * @see org.argouml.core.propertypanels.model.GetterSetterManager.OptionGetterSetter#getOptions(java.lang.Object, Collection)
          */
         public Collection getOptions(
                 final Object modelElement,
-                final Class<?> type) {
-            
-            if (Model.getMetaTypes().getAttribute().equals(type)) {
-                return Model.getFacade().getAttributes(modelElement);
-            } else if (Model.getMetaTypes().getOperation().equals(type)) {
+                final Collection<Class<?>> types) {
+
+            if (types.contains(Model.getMetaTypes().getOperation()) && types.contains(Model.getMetaTypes().getReception())) {
                 return Model.getFacade().getOperationsAndReceptions(modelElement);
+            } else if (types.contains(Model.getMetaTypes().getAttribute())) {
+                return Model.getFacade().getAttributes(modelElement);
             } else {
                 return Collections.EMPTY_LIST;
             }
@@ -692,8 +694,8 @@
 
         public boolean isValidElement(
                 final Object element,
-                final Class<?> type) {
-            return getOptions(element, type).contains(element);
+                final Collection<Class<?>> types) {
+            return getOptions(element, types).contains(element);
         }
         
         public Object getMetaType() {
@@ -708,13 +710,13 @@
         /**
          * Get all the owned elements for the namespace
          * @param modelElement
-         * @param type
+         * @param types
          * @return
-         * @see org.argouml.core.propertypanels.model.GetterSetterManager.OptionGetterSetter#getOptions(java.lang.Object, java.lang.String)
+         * @see org.argouml.core.propertypanels.model.GetterSetterManager.OptionGetterSetter#getOptions(java.lang.Object, Collection)
          */
         public Collection getOptions(
                 final Object modelElement,
-                final Class<?> type) {
+                final Collection<Class<?>> types) {
             
             return Model.getFacade().getOwnedElements(modelElement);
         }
@@ -730,8 +732,8 @@
 
         public boolean isValidElement(
                 final Object element,
-                final Class<?> type) {
-            return getOptions(element, type).contains(element);
+                final Collection<Class<?>> types) {
+            return getOptions(element, types).contains(element);
         }
         
         public Object getMetaType() {
@@ -745,13 +747,13 @@
         /**
          * Get all the owned elements for the namespace
          * @param modelElement
-         * @param type
+         * @param types
          * @return
-         * @see org.argouml.core.propertypanels.model.GetterSetterManager.OptionGetterSetter#getOptions(java.lang.Object, java.lang.String)
+         * @see org.argouml.core.propertypanels.model.GetterSetterManager.OptionGetterSetter#getOptions(java.lang.Object, Collection)
          */
         public Collection getOptions(
                 final Object modelElement,
-                final Class<?> type) {
+                final Collection<Class<?>> types) {
             return Model.getFacade().getRaisedExceptions(modelElement);
         }
       
@@ -766,8 +768,8 @@
 
         public boolean isValidElement(
                 final Object element,
-                final Class<?> type) {
-            return getOptions(element, type).contains(element);
+                final Collection<Class<?>> types) {
+            return getOptions(element, types).contains(element);
         }
         
         public Object getMetaType() {
@@ -780,13 +782,13 @@
         /**
          * Get all the method for the operation
          * @param modelElement
-         * @param type
+         * @param types
          * @return
-         * @see org.argouml.core.propertypanels.model.GetterSetterManager.OptionGetterSetter#getOptions(java.lang.Object, java.lang.String)
+         * @see org.argouml.core.propertypanels.model.GetterSetterManager.OptionGetterSetter#getOptions(java.lang.Object, Collection)
          */
         public Collection getOptions(
                 final Object modelElement,
-                final Class<?> type) {
+                final Collection<Class<?>> types) {
             return Model.getFacade().getMethods(modelElement);
         }
       
@@ -801,8 +803,8 @@
 
         public boolean isValidElement(
                 final Object element,
-                final Class<?> type) {
-            return getOptions(element, type).contains(element);
+                final Collection<Class<?>> types) {
+            return getOptions(element, types).contains(element);
         }
         
         public Object getMetaType() {
@@ -816,13 +818,13 @@
         /**
          * Get all the method for the operation
          * @param modelElement
-         * @param type
+         * @param types
          * @return
-         * @see org.argouml.core.propertypanels.model.GetterSetterManager.OptionGetterSetter#getOptions(java.lang.Object, java.lang.String)
+         * @see org.argouml.core.propertypanels.model.GetterSetterManager.OptionGetterSetter#getOptions(java.lang.Object, Collection)
          */
         public Collection getOptions(
                 final Object modelElement,
-                final Class<?> type) {
+                final Collection<Class<?>> types) {
             return Model.getFacade().getMessages(modelElement);
         }
       
@@ -837,8 +839,8 @@
 
         public boolean isValidElement(
                 final Object element,
-                final Class<?> type) {
-            return getOptions(element, type).contains(element);
+                final Collection<Class<?>> types) {
+            return getOptions(element, types).contains(element);
         }
         
         public Object getMetaType() {
@@ -852,13 +854,13 @@
         /**
          * Get all the method for the operation
          * @param modelElement
-         * @param type
+         * @param types
          * @return
-         * @see org.argouml.core.propertypanels.model.GetterSetterManager.OptionGetterSetter#getOptions(java.lang.Object, java.lang.String)
+         * @see org.argouml.core.propertypanels.model.GetterSetterManager.OptionGetterSetter#getOptions(java.lang.Object, Collection)
          */
         public Collection getOptions(
                 final Object modelElement,
-                final Class<?> type) {
+                final Collection<Class<?>> types) {
             return Model.getFacade().getArguments(modelElement);
         }
       
@@ -873,8 +875,8 @@
 
         public boolean isValidElement(
                 final Object element,
-                final Class<?> type) {
-            return getOptions(element, type).contains(element);
+                final Collection<Class<?>> types) {
+            return getOptions(element, types).contains(element);
         }
         
         public Object getMetaType() {
@@ -888,13 +890,13 @@
         /**
          * Get all the extension points
          * @param modelElement
-         * @param type
+         * @param types
          * @return
-         * @see org.argouml.core.propertypanels.model.GetterSetterManager.OptionGetterSetter#getOptions(java.lang.Object, java.lang.String)
+         * @see org.argouml.core.propertypanels.model.GetterSetterManager.OptionGetterSetter#getOptions(java.lang.Object, Collection)
          */
         public Collection getOptions(
                 final Object modelElement,
-                final Class<?> type) {
+                final Collection<Class<?>> types) {
             return Model.getFacade().getExtensionPoints(modelElement);
         }
       
@@ -909,8 +911,8 @@
 
         public boolean isValidElement(
                 final Object element,
-                final Class<?> type) {
-            return getOptions(element, type).contains(element);
+                final Collection<Class<?>> types) {
+            return getOptions(element, types).contains(element);
         }
         
         public Object getMetaType() {
@@ -923,13 +925,13 @@
         /**
          * Get all the guards
          * @param modelElement
-         * @param type
+         * @param types
          * @return
-         * @see org.argouml.core.propertypanels.model.GetterSetterManager.OptionGetterSetter#getOptions(java.lang.Object, java.lang.String)
+         * @see org.argouml.core.propertypanels.model.GetterSetterManager.OptionGetterSetter#getOptions(java.lang.Object, Collection)
          */
         public Collection getOptions(
                 final Object modelElement,
-                final Class<?> type) {
+                final Collection<Class<?>> types) {
             final ArrayList l = new ArrayList(1);
             l.add(Model.getFacade().getGuard(modelElement));
             return l;
@@ -946,8 +948,8 @@
 
         public boolean isValidElement(
                 final Object element,
-                final Class<?> type) {
-            return getOptions(element, type).contains(element);
+                final Collection<Class<?>> types) {
+            return getOptions(element, types).contains(element);
         }
         
         public Object getMetaType() {
@@ -960,13 +962,13 @@
         /**
          * Get all the effects
          * @param modelElement
-         * @param type
+         * @param types
          * @return
-         * @see org.argouml.core.propertypanels.model.GetterSetterManager.OptionGetterSetter#getOptions(java.lang.Object, java.lang.String)
+         * @see org.argouml.core.propertypanels.model.GetterSetterManager.OptionGetterSetter#getOptions(java.lang.Object, Collection)
          */
         public Collection getOptions(
                 final Object modelElement,
-                final Class<?> type) {
+                final Collection<Class<?>> types) {
             final ArrayList l = new ArrayList(1);
             l.add(Model.getFacade().getEffect(modelElement));
             return l;
@@ -983,8 +985,8 @@
 
         public boolean isValidElement(
                 final Object element,
-                final Class<?> type) {
-            return getOptions(element, type).contains(element);
+                final Collection<Class<?>> types) {
+            return getOptions(element, types).contains(element);
         }
         
         public Object getMetaType() {
@@ -997,13 +999,13 @@
         /**
          * Get all the effects
          * @param modelElement
-         * @param type
+         * @param types
          * @return
-         * @see org.argouml.core.propertypanels.model.GetterSetterManager.OptionGetterSetter#getOptions(java.lang.Object, java.lang.String)
+         * @see org.argouml.core.propertypanels.model.GetterSetterManager.OptionGetterSetter#getOptions(java.lang.Object, Collection)
          */
         public Collection getOptions(
                 final Object modelElement,
-                final Class<?> type) {
+                final Collection<Class<?>> types) {
             final ArrayList l = new ArrayList(1);
             l.add(Model.getFacade().getTrigger(modelElement));
             return l;
@@ -1020,8 +1022,8 @@
 
         public boolean isValidElement(
                 final Object element,
-                final Class<?> type) {
-            return getOptions(element, type).contains(element);
+                final Collection<Class<?>> types) {
+            return getOptions(element, types).contains(element);
         }
         
         public Object getMetaType() {
@@ -1033,7 +1035,7 @@
         
         public Collection getOptions(
         	final Object modelElement,
-        	final Class<?> type) {
+        	final Collection<Class<?>> types) {
             return Model.getFacade().getParameters(modelElement);
         }
       
@@ -1046,8 +1048,8 @@
             // not needed
         }
 
-        public boolean isValidElement(Object element, Class<?> type) {
-            return getOptions(element, type).contains(element);
+        public boolean isValidElement(Object element, Collection<Class<?>> types) {
+            return getOptions(element, types).contains(element);
         }
         
         public Object getMetaType() {
@@ -1057,7 +1059,7 @@
     
     private class EntryActionGetterSetter extends ListGetterSetter {
         
-        public Collection getOptions(Object modelElement, Class<?> type) {
+        public Collection getOptions(Object modelElement, Collection<Class<?>> types) {
             final ArrayList list = new ArrayList(1);
             list.add(Model.getFacade().getEntry(modelElement));
             return list;
@@ -1072,8 +1074,8 @@
             // not needed
         }
 
-        public boolean isValidElement(Object element, Class<?> type) {
-            return getOptions(element, type).contains(element);
+        public boolean isValidElement(Object element, Collection<Class<?>> types) {
+            return getOptions(element, types).contains(element);
         }
         
         public Object getMetaType() {
@@ -1083,7 +1085,7 @@
     
     private class ExitActionGetterSetter extends ListGetterSetter {
         
-        public Collection getOptions(Object modelElement, Class<?> type) {
+        public Collection getOptions(Object modelElement, Collection<Class<?>> types) {
             final ArrayList list = new ArrayList(1);
             list.add(Model.getFacade().getExit(modelElement));
             return list;
@@ -1098,8 +1100,8 @@
             // not needed
         }
 
-        public boolean isValidElement(Object element, Class<?> type) {
-            return getOptions(element, type).contains(element);
+        public boolean isValidElement(Object element, Collection<Class<?>> types) {
+            return getOptions(element, types).contains(element);
         }
         
         public Object getMetaType() {
@@ -1109,7 +1111,7 @@
     
     private class DoActivityActionGetterSetter extends ListGetterSetter {
         
-        public Collection getOptions(Object modelElement, Class<?> type) {
+        public Collection getOptions(Object modelElement, Collection<Class<?>> types) {
             final ArrayList list = new ArrayList(1);
             list.add(Model.getFacade().getDoActivity(modelElement));
             return list;
@@ -1124,8 +1126,8 @@
             // not needed
         }
 
-        public boolean isValidElement(Object element, Class<?> type) {
-            return getOptions(element, type).contains(element);
+        public boolean isValidElement(Object element, Collection<Class<?>> types) {
+            return getOptions(element, types).contains(element);
         }
         
         public Object getMetaType() {
@@ -1135,7 +1137,7 @@
     
     private class ActionGetterSetter extends ListGetterSetter {
         
-        public Collection getOptions(Object modelElement, Class<?> type) {
+        public Collection getOptions(Object modelElement, Collection<Class<?>> types) {
             return Model.getFacade().getActions(modelElement);
         }
       
@@ -1148,8 +1150,8 @@
             // not needed
         }
 
-        public boolean isValidElement(Object element, Class<?> type) {
-            return getOptions(element, type).contains(element);
+        public boolean isValidElement(Object element, Collection<Class<?>> types) {
+            return getOptions(element, types).contains(element);
         }
         
         public Object getMetaType() {
@@ -1159,7 +1161,7 @@
 
     private class SubvertexGetterSetter extends ListGetterSetter {
         
-        public Collection getOptions(Object modelElement, Class<?> type) {
+        public Collection getOptions(Object modelElement, Collection<Class<?>> types) {
             return Model.getFacade().getSubvertices(modelElement);
         }
       
@@ -1172,8 +1174,8 @@
             // not needed
         }
 
-        public boolean isValidElement(Object element, Class<?> type) {
-            return getOptions(element, type).contains(element);
+        public boolean isValidElement(Object element, Collection<Class<?>> types) {
+            return getOptions(element, types).contains(element);
         }
         
         public Object getMetaType() {
@@ -1267,8 +1269,10 @@
     
     private class TemplateParameterGetterSetter extends ListGetterSetter {
         
-        public Collection getOptions(Object modelElement, Class<?> type) {
-            LOG.info("Getting template parameters for " + modelElement);
+        public Collection getOptions(Object modelElement, Collection<Class<?>> types) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Getting template parameters for " + modelElement);
+            }
             return Model.getFacade().getTemplateParameters(modelElement);
         }
       
@@ -1281,8 +1285,8 @@
             // not needed
         }
 
-        public boolean isValidElement(Object element, Class<?> type) {
-            return getOptions(element, type).contains(element);
+        public boolean isValidElement(Object element, Collection<Class<?>> types) {
+            return getOptions(element, types).contains(element);
         }
         
         public Object getMetaType() {
@@ -1292,7 +1296,7 @@
     
     private class ElementImportGetterSetter extends ListGetterSetter implements Addable, Removeable {
         
-        public Collection getOptions(Object modelElement, Class<?> type) {
+        public Collection getOptions(Object modelElement, Collection<Class<?>> types) {
             return Model.getFacade().getImportedElements(modelElement);
         }
       
@@ -1309,8 +1313,8 @@
             // not needed
         }
 
-        public boolean isValidElement(Object element, Class<?> type) {
-            return getOptions(element, type).contains(element);
+        public boolean isValidElement(Object element, Collection<Class<?>> types) {
+            return getOptions(element, types).contains(element);
         }
         
         public Object getMetaType() {
@@ -1394,7 +1398,7 @@
     
     private class DeferrableEventGetterSetter extends ListGetterSetter implements Addable, Removeable {
         
-        public Collection getOptions(Object modelElement, Class<?> type) {
+        public Collection getOptions(Object modelElement, Collection<Class<?>> types) {
             return Model.getFacade().getDeferrableEvents(modelElement);
         }
       
@@ -1411,8 +1415,8 @@
             // not needed
         }
 
-        public boolean isValidElement(Object element, Class<?> type) {
-            return getOptions(element, type).contains(element);
+        public boolean isValidElement(Object element, Collection<Class<?>> types) {
+            return getOptions(element, types).contains(element);
         }
         
         public Object getMetaType() {
@@ -1504,7 +1508,7 @@
     
     private class ReceptionGetterSetter extends ListGetterSetter implements Addable, Removeable {
         
-        public Collection getOptions(Object modelElement, Class<?> type) {
+        public Collection getOptions(Object modelElement, Collection<Class<?>> types) {
             return Model.getFacade().getReceptions(modelElement);
         }
       
@@ -1517,8 +1521,8 @@
             // not needed
         }
 
-        public boolean isValidElement(Object element, Class<?> type) {
-            return getOptions(element, type).contains(element);
+        public boolean isValidElement(Object element, Collection<Class<?>> types) {
+            return getOptions(element, types).contains(element);
         }
         
         public Object getMetaType() {
@@ -1732,7 +1736,7 @@
     
     private class SenderGetterSetter extends ListGetterSetter {
         
-        public Collection getOptions(Object modelElement, Class<?> type) {
+        public Collection getOptions(Object modelElement, Collection<Class<?>> types) {
             return Model.getFacade().getSentStimuli(modelElement);
         }
       
@@ -1745,9 +1749,9 @@
             // not needed
         }
 
-        public boolean isValidElement(Object element, Class<?> type) {
+        public boolean isValidElement(Object element, Collection<Class<?>> types) {
           
-            return getOptions(element, type).contains(element);
+            return getOptions(element, types).contains(element);
         }
         
         public Object getMetaType() {
@@ -1757,7 +1761,7 @@
     
     private class LiteralGetterSetter extends ListGetterSetter {
         
-        public Collection getOptions(Object modelElement, Class<?> type) {
+        public Collection getOptions(Object modelElement, Collection<Class<?>> types) {
             return Model.getFacade().getEnumerationLiterals(modelElement);
         }
       
@@ -1770,9 +1774,9 @@
             // not needed
         }
 
-        public boolean isValidElement(Object element, Class<?> type) {
+        public boolean isValidElement(Object element, Collection<Class<?>> types) {
           
-            return getOptions(element, type).contains(element);
+            return getOptions(element, types).contains(element);
         }
         
         public Object getMetaType() {
@@ -1782,7 +1786,7 @@
     
     private class ReceiverGetterSetter extends ListGetterSetter {
         
-        public Collection getOptions(Object modelElement, Class<?> type) {
+        public Collection getOptions(Object modelElement, Collection<Class<?>> types) {
             return Model.getFacade().getReceivedStimuli(modelElement);
         }
       
@@ -1795,9 +1799,9 @@
             // not needed
         }
 
-        public boolean isValidElement(Object element, Class<?> type) {
+        public boolean isValidElement(Object element, Collection<Class<?>> types) {
           
-            return getOptions(element, type).contains(element);
+            return getOptions(element, types).contains(element);
         }
         
         public Object getMetaType() {
@@ -1806,7 +1810,7 @@
     }
     private class InternalTransitionGetterSetter extends ListGetterSetter {
         
-        public Collection getOptions(Object modelElement, Class<?> type) {
+        public Collection getOptions(Object modelElement, Collection<Class<?>> types) {
             return Model.getFacade().getInternalTransitions(modelElement);
         }
       
@@ -1819,9 +1823,9 @@
             // not needed
         }
 
-        public boolean isValidElement(Object element, Class<?> type) {
+        public boolean isValidElement(Object element, Collection<Class<?>> types) {
           
-            return getOptions(element, type).contains(element);
+            return getOptions(element, types).contains(element);
         }
         
         public Object getMetaType() {
@@ -1832,7 +1836,7 @@
 
     private class ClassifierGetterSetter extends ListGetterSetter implements Addable, Removeable {
         
-        public Collection getOptions(Object modelElement, Class<?> type) {
+        public Collection getOptions(Object modelElement, Collection<Class<?>> types) {
             return Model.getFacade().getClassifiers(modelElement);
         }
       
@@ -1845,8 +1849,8 @@
             // not needed
         }
 
-        public boolean isValidElement(Object element, Class<?> type) {
-            return getOptions(element, type).contains(element);
+        public boolean isValidElement(Object element, Collection<Class<?>> types) {
+            return getOptions(element, types).contains(element);
         }
         
         public Object getMetaType() {
@@ -1943,7 +1947,7 @@
     
     private class BaseClassGetterSetter extends ListGetterSetter implements Addable, Removeable {
         
-        public Collection getOptions(Object modelElement, Class<?> type) {
+        public Collection getOptions(Object modelElement, Collection<Class<?>> types) {
             LinkedList<String> list = new LinkedList<String>(
                     Model.getFacade().getBaseClasses(modelElement));
             Collections.sort(list);
@@ -1959,8 +1963,8 @@
             // not needed
         }
 
-        public boolean isValidElement(Object element, Class<?> type) {
-            return getOptions(element, type).contains(element);
+        public boolean isValidElement(Object element, Collection<Class<?>> types) {
+            return getOptions(element, types).contains(element);
         }
         
         public Object getMetaType() {
@@ -2078,7 +2082,7 @@
     
     private class QualifierGetterSetter extends ListGetterSetter {
         
-        public Collection getOptions(Object modelElement, Class<?> type) {
+        public Collection getOptions(Object modelElement, Collection<Class<?>> types) {
             return Model.getFacade().getQualifiers(modelElement);
         }
       
@@ -2091,8 +2095,8 @@
             // not needed
         }
 
-        public boolean isValidElement(Object element, Class<?> type) {
-            return getOptions(element, type).contains(element);
+        public boolean isValidElement(Object element, Collection<Class<?>> types) {
+            return getOptions(element, types).contains(element);
         }
         
         public Object getMetaType() {

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=18644&r1=18643&r2=18644
==============================================================================
--- 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-08-16 12:35:49-0700
@@ -122,14 +122,14 @@
 		                    removeElement(objectToRemove);
 		                } else if (e instanceof AddAssociationEvent) {
 		                    Object newElement = ((AddAssociationEvent) e).getChangedValue();
-		                        
-		                    if (!SimpleListModel.this.contains(newElement)) {
+		                    if (metaTypes.contains(newElement.getClass())
+		                	    && !SimpleListModel.this.contains(newElement)) {
 			                if (Model.getUmlHelper().isMovable(getMetaType())) {
 			                    final Collection c =
 			                        (Collection) getterSetterManager.getOptions( 
 			                            umlElement, 
 			                            propertyName, 
-			                            metaTypes.get(0));
+			                            metaTypes);
 			                    final int index =
 			                        CollectionUtil.indexOf(c, newElement);
 			                    if (index < 0 || index > getSize() - 1) {
@@ -173,12 +173,14 @@
      */
     private void build() {
         try {
-            final Class<?> metaType = metaTypes.get(0);
-            LOG.info("Getting options for " + umlElement + " " + propertyName + " " + metaType);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Getting options for " + umlElement
+                	+ " " + propertyName + " " + metaTypes);
+            }
             final Collection c = (Collection) getterSetterManager.getOptions( 
                     umlElement, 
                     propertyName, 
-                    metaType);
+                    metaTypes);
             for (Object o : c) {
                 addElement(o);
             }

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

To unsubscribe from this discussion, e-mail: [[email protected]].
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.