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

Bob Tarling <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: bobtarling
Date: 2010-03-14 09:27:15-0800
New Revision: 18094

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

Log:
Make the parameters list use SimpleListModel so that the ScrollList toolbar generates a new element toolbar action. Factories in model/MDR adapted to create parameter for Operation, Event and ObjectFlowState

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=18094&r1=18093&r2=18094
==============================================================================
--- 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-03-14 09:27:15-0800
@@ -17,6 +17,7 @@
 import java.util.Collection;
 import java.util.Collections;
 
+import org.apache.log4j.Logger;
 import org.argouml.model.Model;
 
 /**
@@ -25,6 +26,9 @@
  */
 class GetterSetterManagerImpl extends GetterSetterManager {
     
+    private static final Logger LOG =
+        Logger.getLogger(GetterSetterManagerImpl.class);
+    
     /**
      * The constructor
      */
@@ -55,6 +59,7 @@
         addGetterSetter("changeability", new ChangeabilityGetterSetter());
         addGetterSetter("concurrency", new ConcurrencyGetterSetter());
         addGetterSetter("feature", new FeatureGetterSetter(type));
+        addGetterSetter("parameter", new ParameterGetterSetter());
         addGetterSetter("receiver", new ReceiverGetterSetter());
         addGetterSetter("sender", new SenderGetterSetter());
         addGetterSetter("body", new MethodExpressionGetterSetter());
@@ -131,7 +136,7 @@
             return ((ListGetterSetter) bgs).getMetaType();
         }
         
-        return false;
+        return null;
     }
     
     /**
@@ -595,6 +600,31 @@
     }
     
     
+    private class ParameterGetterSetter extends ListGetterSetter {
+        
+        public Collection getOptions(Object modelElement, String type) {
+            return Model.getFacade().getParameters(modelElement);
+        }
+      
+        public Object get(Object modelElement, String type) {
+            // not needed
+            return null;
+        }
+      
+        public void set(Object element, Object x) {
+            // not needed
+        }
+
+        protected boolean isValidElement(Object element, String type) {
+            return getOptions(element, type).contains(element);
+        }
+        
+        public Object getMetaType() {
+            return Model.getMetaTypes().getParameter();
+        }
+    }
+    
+    
     private class MethodExpressionGetterSetter extends ExpressionGetterSetter {
         
         @Override

Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ListFactory.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ListFactory.java?view=diff&pathrev=18094&r1=18093&r2=18094
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ListFactory.java	(original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ListFactory.java	2010-03-14 09:27:15-0800
@@ -159,12 +159,12 @@
             model = new UMLNamespaceOwnedElementListModel(modelElement);
         } else if ("outgoing".equals(propName)) {
             model = new UMLStateVertexOutgoingListModel(modelElement);
-        } else if ("parameter".equals(propName)) {
-            if (Model.getFacade().isAObjectFlowState(modelElement)) {
-                model = new UMLObjectFlowStateParameterListModel(modelElement, propName);
-            } else {
-                model = new UMLClassifierParameterListModel(modelElement, propName);
-            }
+//        } else if ("parameter".equals(propName)) {
+//            if (Model.getFacade().isAObjectFlowState(modelElement)) {
+//                model = new UMLObjectFlowStateParameterListModel(modelElement, propName);
+//            } else {
+//                model = new UMLClassifierParameterListModel(modelElement, propName);
+//            }
         } else if ("partition".equals(propName)) {
             model = new UMLActivityGraphPartitionListModel(modelElement);
         } else if ("predecessor".equals(propName)) {

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=18094&r1=18093&r2=18094
==============================================================================
--- 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-03-14 09:27:15-0800
@@ -97,7 +97,14 @@
                                     type);
                             final int index =
                                 CollectionUtil.indexOf(c, newElement);
-                            add(index, 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);
                         }

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

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.