svn commit: r18207 - branches/BRANCH_0_30_x: . src/argouml-app src/argouml-app/tests/org/argouml/profile src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui

Linus Tolke <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: linus
Date: 2010-04-01 11:03:20-0700
New Revision: 18207

Removed:
   branches/BRANCH_0_30_x/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLSignalReceptionListModel.java
Modified:
   branches/BRANCH_0_30_x/   (props changed)
   branches/BRANCH_0_30_x/src/argouml-app/   (props changed)
   branches/BRANCH_0_30_x/src/argouml-app/tests/org/argouml/profile/   (props changed)
   branches/BRANCH_0_30_x/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/GetterSetterManagerImpl.java
   branches/BRANCH_0_30_x/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ListFactory.java

Log:
Merged:
Revision 18204 (Issue 6039).

Modified: branches/BRANCH_0_30_x/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/GetterSetterManagerImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/BRANCH_0_30_x/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/GetterSetterManagerImpl.java?view=diff&pathrev=18207&r1=18206&r2=18207
==============================================================================
--- branches/BRANCH_0_30_x/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/GetterSetterManagerImpl.java	(original)
+++ branches/BRANCH_0_30_x/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/GetterSetterManagerImpl.java	2010-04-01 11:03:20-0700
@@ -26,6 +26,7 @@
 import org.argouml.i18n.Translator;
 import org.argouml.kernel.Command;
 import org.argouml.kernel.NonUndoableCommand;
+import org.argouml.kernel.ProjectManager;
 import org.argouml.model.Model;
 import org.argouml.uml.ui.UMLAddDialog;
 import org.argouml.util.ArgoFrame;
@@ -85,6 +86,7 @@
         addGetterSetter("trigger", new TriggerGetterSetter());
         addGetterSetter("elementImport", new ElementImportGetterSetter());
         addGetterSetter("templateParameter", new TemplateParameterGetterSetter());
+        addGetterSetter("reception", new ReceptionGetterSetter());
         
         // UML2 only
         addGetterSetter("ownedOperation", new FeatureGetterSetter());
@@ -1091,14 +1093,11 @@
         
         private class AddElementImportCommand extends AddModelElementCommand {
 
-        	final Object target;
-        	
             /**
              * Constructor for ActionAddPackageImport.
              */
             public AddElementImportCommand(Object target) {
-                super();
-                this.target = target;
+                super(target);
             }
 
 
@@ -1108,14 +1107,14 @@
                  * in the model subsystem for 
                  * issue 1942: */
                 list.addAll(Model.getModelManagementHelper()
-                        .getAllPossibleImports(target));
+                        .getAllPossibleImports(getTarget()));
                 return list;
             }
 
 
             protected List getSelected() {
                 List list = new ArrayList();
-                list.addAll(Model.getFacade().getImportedElements(target));
+                list.addAll(Model.getFacade().getImportedElements(getTarget()));
                 return list;
             }
 
@@ -1130,7 +1129,7 @@
             	if (LOG.isInfoEnabled()) {
                 	LOG.info("Setting " + selected.size() + "imported elements");
             	}
-                Model.getModelManagementHelper().setImportedElements(target, selected);
+                Model.getModelManagementHelper().setImportedElements(getTarget(), selected);
             }
         }
         
@@ -1157,117 +1156,218 @@
     	        return null;
     	    }
     	}
+    }
+    
+    private class ReceptionGetterSetter extends ListGetterSetter implements Addable, Removeable {
+        
+        public Collection getOptions(Object modelElement, String type) {
+            return Model.getFacade().getReceptions(modelElement);
+        }
+      
+        public Object get(Object modelElement, String type) {
+            // not needed
+            return null;
+        }
         
-        public abstract class AddModelElementCommand extends NonUndoableCommand {
+        public void set(Object element, Object x) {
+            // not needed
+        }
 
-            private Object target;
-            private boolean multiSelect = true;
-            private boolean exclusive = true;
+        public boolean isValidElement(Object element, String type) {
+            return getOptions(element, type).contains(element);
+        }
+        
+        public Object getMetaType() {
+            return Model.getMetaTypes().getReception();
+        }
+        
+        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 {
 
             /**
-             * Construct a command to add a model element to some list.
+             * Constructor for ActionAddPackageImport.
              */
-            protected AddModelElementCommand() {
+            public AddCommand(final Object target) {
+                super(target);
             }
 
-            /*
-             * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
-             */
-            public Object execute() {
-                UMLAddDialog dialog =
-                    new UMLAddDialog(getChoices(), getSelected(), getDialogTitle(),
-                                     isMultiSelect(),
-                                     isExclusive());
-                int result = dialog.showDialog(ArgoFrame.getFrame());
-                if (result == JOptionPane.OK_OPTION) {
-                    doIt(dialog.getSelected());
-                }
-                return null;
-            }
-            
-            /**
-             * Returns the choices the user has in the UMLAddDialog. The choices are
-             * depicted on the left side of the UMLAddDialog (sorry Arabic users) and
-             * can be moved via the buttons on the dialog to the right side. On the
-             * right side are the selected modelelements.
-             * @return List of choices
-             */
-            protected abstract List getChoices();
 
-            
-            /**
-             * The modelelements already selected BEFORE the dialog is shown.
-             * @return List of model elements
-             */
-            protected abstract List getSelected();
+            protected List getChoices() {
+                List list = new ArrayList();
+                /* TODO: correctly implement next function 
+                 * in the model subsystem for 
+                 * issue 1942: */
+                Object model =
+                    ProjectManager.getManager().getCurrentProject().getModel();
+                list.addAll(Model.getModelManagementHelper()
+                        .getAllModelElementsOfKind(model, 
+                            Model.getMetaTypes().getReception()));
+                return list;
+            }
 
-            /**
-             * The action that has to be done by ArgoUml after the user clicks ok in the
-             * UMLAddDialog.
-             * @param selected The choices the user has selected in the UMLAddDialog
-             */
-            protected abstract void doIt(Collection selected);
 
-            /**
-             * Returns the UML model target.
-             * @return UML ModelElement
-             */
-            protected Object getTarget() {
-                return target;
+            protected List getSelected() {
+                List list = new ArrayList();
+                list.addAll(Model.getFacade().getReceptions(getTarget()));
+                return list;
             }
 
-            /**
-             * Sets the UML model target.
-             * @param theTarget The target to set
-             */
-            public void setTarget(Object theTarget) {
-                target = theTarget;
+
+            protected String getDialogTitle() {
+                return Translator.localize("dialog.title.add-imported-elements");
             }
 
-            /**
-             * Returns the title of the dialog.
-             * @return String
-             */
-            protected abstract String getDialogTitle();
 
-            /**
-             * Returns the exclusive.
-             * @return boolean
-             */
-            public boolean isExclusive() {
-                return exclusive;
+            @Override
+            protected void doIt(Collection selected) {
+                Model.getCommonBehaviorHelper().setReception(getTarget(), selected);
             }
+        }
+        
+        private class RemoveCommand
+    	    extends NonUndoableCommand {
+        	
+        	private final Object target;
+        	private final Object objectToRemove;
+        	
+    	    /**
+    	     * Constructor for ActionRemovePackageImport.
+    	     */
+    	    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.getCommonBehaviorHelper()
+    	            .removeReception(target, objectToRemove);
+    	        return null;
+    	    }
+    	}
+    }
+    
+    
+    
+    private abstract class AddModelElementCommand extends NonUndoableCommand {
 
-            /**
-             * Returns the multiSelect.
-             * @return boolean
-             */
-            public boolean isMultiSelect() {
-                return multiSelect;
-            }
+        private Object target;
+        private boolean multiSelect = true;
+        private boolean exclusive = true;
 
-            /**
-             * Sets the exclusive.
-             * @param theExclusive The exclusive to set
-             */
-            public void setExclusive(boolean theExclusive) {
-                exclusive = theExclusive;
+        /**
+         * Construct a command to add a model element to some list.
+         */
+        protected AddModelElementCommand(final Object target) {
+            if (target == null) {
+            	throw new IllegalArgumentException("target expected");
             }
+        	this.target = target;
+        }
 
-            /**
-             * Sets the multiSelect.
-             * @param theMultiSelect The multiSelect to set
-             */
-            public void setMultiSelect(boolean theMultiSelect) {
-                multiSelect = theMultiSelect;
+        /*
+         * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+         */
+        public Object execute() {
+            UMLAddDialog dialog =
+                new UMLAddDialog(getChoices(), getSelected(), getDialogTitle(),
+                                 isMultiSelect(),
+                                 isExclusive());
+            int result = dialog.showDialog(ArgoFrame.getFrame());
+            if (result == JOptionPane.OK_OPTION) {
+                doIt(dialog.getSelected());
             }
-
+            return null;
         }
         
+        /**
+         * Returns the choices the user has in the UMLAddDialog. The choices are
+         * depicted on the left side of the UMLAddDialog (sorry Arabic users) and
+         * can be moved via the buttons on the dialog to the right side. On the
+         * right side are the selected modelelements.
+         * @return List of choices
+         */
+        protected abstract List getChoices();
+
         
+        /**
+         * The modelelements already selected BEFORE the dialog is shown.
+         * @return List of model elements
+         */
+        protected abstract List getSelected();
+
+        /**
+         * The action that has to be done by ArgoUml after the user clicks ok in the
+         * UMLAddDialog.
+         * @param selected The choices the user has selected in the UMLAddDialog
+         */
+        protected abstract void doIt(Collection selected);
+
+        /**
+         * Returns the UML model target.
+         * @return UML ModelElement
+         */
+        protected Object getTarget() {
+            return target;
+        }
+
+        /**
+         * Sets the UML model target.
+         * @param theTarget The target to set
+         */
+        public void setTarget(Object theTarget) {
+            target = theTarget;
+        }
+
+        /**
+         * Returns the title of the dialog.
+         * @return String
+         */
+        protected abstract String getDialogTitle();
+
+        /**
+         * Returns the exclusive.
+         * @return boolean
+         */
+        public boolean isExclusive() {
+            return exclusive;
+        }
+
+        /**
+         * Returns the multiSelect.
+         * @return boolean
+         */
+        public boolean isMultiSelect() {
+            return multiSelect;
+        }
+
+        /**
+         * Sets the exclusive.
+         * @param theExclusive The exclusive to set
+         */
+        public void setExclusive(boolean theExclusive) {
+            exclusive = theExclusive;
+        }
+
+        /**
+         * Sets the multiSelect.
+         * @param theMultiSelect The multiSelect to set
+         */
+        public void setMultiSelect(boolean theMultiSelect) {
+            multiSelect = theMultiSelect;
+        }
+
     }
     
-    
     private class MethodExpressionGetterSetter extends ExpressionGetterSetter {
         
         @Override

Modified: branches/BRANCH_0_30_x/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ListFactory.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/BRANCH_0_30_x/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ListFactory.java?view=diff&pathrev=18207&r1=18206&r2=18207
==============================================================================
--- branches/BRANCH_0_30_x/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ListFactory.java	(original)
+++ branches/BRANCH_0_30_x/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ListFactory.java	2010-04-01 11:03:20-0700
@@ -139,8 +139,6 @@
             model = new UMLMessagePredecessorListModel(modelElement);
         } else if ("qualifier".equals(propName)) {
             model = new UMLAssociationEndQualifiersListModel(modelElement);
-        } else if ("reception".equals(propName)) {
-            model = new UMLSignalReceptionListModel(modelElement);
         } else if ("resident".equals(propName)) {
             model = new UMLContainerResidentListModel(modelElement);
         } else if ("residentElement".equals(propName)) {

Removed: branches/BRANCH_0_30_x/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLSignalReceptionListModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/BRANCH_0_30_x/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLSignalReceptionListModel.java?view=markup&pathrev=18206

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

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.