svn commit: r19581 - 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: 2011-07-07 15:46:11-0700
New Revision: 19581

Removed:
   trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLClassifierRoleBaseListModel.java
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

Log:
Use new GetterSetter instead of old style ListModel for coding behaviour of Base control

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=19581&r1=19580&r2=19581
==============================================================================
--- 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	2011-07-07 15:46:11-0700
@@ -68,7 +68,7 @@
         addGetterSetter("actualArgument", new ArgumentGetterSetter());
         addGetterSetter("aggregation", new AggregationGetterSetter());
         addGetterSetter("baseClass", new BaseClassGetterSetter());
-        //addGetterSetter("base", new BaseGetterSetter());
+        addGetterSetter("base", new BaseGetterSetter());
         addGetterSetter("body", new MethodExpressionGetterSetter());
         addGetterSetter("changeability", new ChangeabilityGetterSetter());
         addGetterSetter("classifier", new ClassifierGetterSetter());
@@ -2336,141 +2336,95 @@
 	}
     }
     
-//    private class BaseGetterSetter extends ListGetterSetter {
-//	//implements Addable, Removeable {
-//        
-////        public Collection getOptions(Object modelElement, Collection<Class<?>> types) {
-////            return Model.getFacade().getBases(modelElement);
-////        }
-//      
-//        public Object get(Object modelElement, Class<?> type) {
-//            // not needed
-//            return null;
-//        }
-//      
-//        public void set(Object element, Object x) {
-//            // not needed
-//        }
-//
-//        public boolean isValidElement(Object element, Collection<Class<?>> types) {
-//            return getOptions(element, types).contains(element);
-//        }
-//        
-//        public Object getMetaType() {
-//            return Model.getMetaTypes().getClassifier();
-//        }
-//
-////        public Command getAddCommand(Object modelElement) {
-////            return new AddCommand(modelElement);
-////        }
-////    
-////        public Command getRemoveCommand(Object modelElement, Object objectToRemove) {
-////    	    return new RemoveCommand(modelElement, objectToRemove);
-////        }
-////    
-////        private class AddCommand extends AddModelElementCommand {
-////
-////            final private List<String> metaClasses;
-////            
-////            /**
-////             * Constructor for ActionAddPackageImport.
-////             */
-////            public AddCommand(Object target) {
-////                super(target);
-////                LOG.info("Creating AddCommand");
-////                metaClasses = initMetaClasses();
-////            }
-////            
-////            /**
-////             * Initialize the meta-classes list. <p>
-////             * 
-////             * All this code is necessary to be independent of 
-////             * model repository implementation, 
-////             * i.e. to ensure that we have a 
-////             * sorted list of strings.
-////             */
-////            private List<String> initMetaClasses() {
-////                Collection<String> tmpMetaClasses = 
-////                    Model.getCoreHelper().getAllMetatypeNames();
-////                List<String> metaClasses;
-////                if (tmpMetaClasses instanceof List) {
-////                    metaClasses = (List<String>) tmpMetaClasses;
-////                } else {
-////                    metaClasses = new LinkedList<String>(tmpMetaClasses);
-////                }
-////                try {
-////                    Collections.sort(metaClasses);
-////                } catch (UnsupportedOperationException e) {
-////                    // We got passed an unmodifiable List.  Copy it and sort the result
-////                    metaClasses = new LinkedList<String>(tmpMetaClasses);
-////                    Collections.sort(metaClasses);
-////                }
-////                
-////                return metaClasses;
-////            }
-////            
-////            protected List getChoices() {
-////                List vec = new ArrayList();
-////                vec.addAll(Model.getCollaborationsHelper()
-////                        .getAllPossibleBases(getTarget()));
-////                return vec;
-////            }
-////    
-////            protected List getSelected() {
-////                List list = new ArrayList();
-////                list.addAll(Model.getFacade().getBases(getTarget()));
-////                return list;
-////            }
-////    
-////    
-////            protected String getDialogTitle() {
-////                return Translator.localize("dialog.title.add-bases");
-////            }
-////    
-////    
-////            @Override
-////            protected void doIt(Collection selected) {
-////                Object stereo = getTarget();
-////                Set<Object> oldSet = new HashSet<Object>(getSelected());
-////                Set toBeRemoved = new HashSet<Object>(oldSet);
-////
-////                for (Object o : selected) {
-////                    if (oldSet.contains(o)) {
-////                        toBeRemoved.remove(o);
-////                    } else {
-////                        Model.getExtensionMechanismsHelper()
-////                                .addBaseClass(stereo, o);
-////                    }
-////                }
-////                for (Object o : toBeRemoved) {
-////                    Model.getExtensionMechanismsHelper().removeBaseClass(stereo, o);
-////                }
-////            }
-////        }
-////    
-////        private class RemoveCommand
-////	    extends NonUndoableCommand {
-////    	
-////            private final Object target;
-////            private final Object objectToRemove;
-////    	
-////	    /**
-////	     * Constructor for RemoveCommand.
-////	     */
-////	    public RemoveCommand(final Object target, final Object objectToRemove) {
-////	        this.target = target;
-////	        this.objectToRemove = objectToRemove;
-////	    }
-////	    
-////	    /*
-////	     * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
-////	     */
-////	    public Object execute() {
-////                Model.getExtensionMechanismsHelper().removeBaseClass(target, objectToRemove);
-////	        return null;
-////	    }
-////	}
-//    }
+    private class BaseGetterSetter extends ListGetterSetter implements Addable, Removeable {
+        
+        public Collection getOptions(Object modelElement, Collection<Class<?>> types) {
+            return Model.getFacade().getBases(modelElement);
+        }
+      
+        public Object get(Object modelElement, Class<?> type) {
+            // not needed
+            return null;
+        }
+      
+        public void set(Object element, Object x) {
+            // not needed
+        }
+
+        public boolean isValidElement(Object element, Collection<Class<?>> types) {
+            return getOptions(element, types).contains(element);
+        }
+        
+        public Object getMetaType() {
+            return Model.getMetaTypes().getClassifier();
+        }
+
+        public Command getAddCommand(Object modelElement) {
+            return new AddCommand(modelElement);
+        }
+    
+        public Command getRemoveCommand(Object modelElement, Object objectToRemove) {
+    	    return new RemoveCommand(modelElement, objectToRemove);
+        }
+    
+        private class AddCommand extends AddModelElementCommand {
+
+            /**
+             * Constructor for ActionAddPackageImport.
+             */
+            public AddCommand(Object target) {
+                super(target);
+            }
+            
+            protected List getChoices() {
+                List vec = new ArrayList();
+                vec.addAll(Model.getCollaborationsHelper()
+                        .getAllPossibleBases(getTarget()));
+                return vec;
+            }
+    
+            protected List getSelected() {
+                List list = new ArrayList();
+                list.addAll(Model.getFacade().getBases(getTarget()));
+                return list;
+            }
+    
+    
+            protected String getDialogTitle() {
+                return Translator.localize("dialog.title.add-bases");
+            }
+    
+    
+            @Override
+            protected void doIt(Collection selected) {
+                Object role = getTarget();
+                Model.getCollaborationsHelper().setBases(role, selected);
+            }
+        }
+    
+        private class RemoveCommand
+	    extends NonUndoableCommand {
+    	
+            private final Object target;
+            private final Object objectToRemove;
+    	
+	    /**
+	     * Constructor for RemoveCommand.
+	     */
+	    public RemoveCommand(final Object target, final Object objectToRemove) {
+	        this.target = target;
+	        this.objectToRemove = objectToRemove;
+	    }
+	    
+	    /*
+	     * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+	     */
+	    public Object execute() {
+		Model.getCollaborationsHelper().removeBase(target, objectToRemove);
+	        return null;
+	    }
+	}
+    }
     
     private class QualifierGetterSetter extends ListGetterSetter {
         

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=19581&r1=19580&r2=19581
==============================================================================
--- 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	2011-07-07 15:46:11-0700
@@ -71,8 +71,6 @@
             model = new UMLClassifierRoleAvailableContentsListModel(modelElement);
         } else if ("availableFeature".equals(propName)) {
             model = new UMLClassifierRoleAvailableFeaturesListModel(modelElement);
-        } else if ("base".equals(propName)) {
-            model = new UMLClassifierRoleBaseListModel(modelElement);
         } else if ("classifierInState".equals(propName)) {
             model = new UMLOFSStateListModel(modelElement);
         } else if ("client".equals(propName)) {

Removed: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLClassifierRoleBaseListModel.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLClassifierRoleBaseListModel.java?view=markup&pathrev=19580

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

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.