Author: bobtarling
Date: 2011-05-13 04:40:27-0700
New Revision: 19418

Modified:
   
trunk/src/argouml-app/src/org/argouml/uml/diagram/collaboration/CollabDiagramGraphModel.java
   
trunk/src/argouml-app/src/org/argouml/uml/diagram/collaboration/ui/ActionAddClassifierRole.java

Log:
Allow lifelines to appear in collaboration diagram

Modified: 
trunk/src/argouml-app/src/org/argouml/uml/diagram/collaboration/CollabDiagramGraphModel.java
Url: 
http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/collaboration/CollabDiagramGraphModel.java?view=diff&pathrev=19418&r1=19417&r2=19418
==============================================================================
--- 
trunk/src/argouml-app/src/org/argouml/uml/diagram/collaboration/CollabDiagramGraphModel.java
        (original)
+++ 
trunk/src/argouml-app/src/org/argouml/uml/diagram/collaboration/CollabDiagramGraphModel.java
        2011-05-13 04:40:27-0700
@@ -39,6 +39,7 @@
 package org.argouml.uml.diagram.collaboration;
 
 import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
 import java.beans.VetoableChangeListener;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -47,6 +48,7 @@
 import java.util.List;
 
 import org.apache.log4j.Logger;
+import org.argouml.model.DeleteInstanceEvent;
 import org.argouml.model.Model;
 import org.argouml.uml.CommentEdge;
 import org.argouml.uml.diagram.UMLMutableGraphSupport;
@@ -57,7 +59,13 @@
  * GEF.  This class handles only UML Collaboration Diagrams.
  */
 public class CollabDiagramGraphModel extends UMLMutableGraphSupport
-    implements VetoableChangeListener {
+    implements PropertyChangeListener, VetoableChangeListener {
+    
+    /**
+     * The interaction that is shown on the communication diagram.
+     */
+    private Object interaction;
+    
     /**
      * Logger.
      */
@@ -84,7 +92,21 @@
         }
         setHomeModel(collaboration);
     }
-
+    
+    /**
+     * Gets the interaction that is shown on the sequence diagram.
+     * @return the interaction of the diagram.
+     */
+    private Object getInteraction() {
+        if (interaction == null) {
+            interaction =
+                Model.getCollaborationsFactory().buildInteraction(
+                    getHomeModel());
+            LOG.debug("Interaction built.");
+            Model.getPump().addModelEventListener(this, interaction);
+        }
+        return interaction;
+    }
 
     ////////////////////////////////////////////////////////////////
     // GraphModel implementation
@@ -373,6 +395,33 @@
            }
        }
     }
+    
+    /**
+     * In UML1.4 the sequence diagram is owned by a collaboration.
+     * In UML2 it is owned by an Interaction (which might itself be owned by a
+     * collaboration or some other namespace)
+     * @return the owner of the sequence diagram
+     */
+    public Object getOwner() {
+        if (Model.getFacade().getUmlVersion().charAt(0) == '1') {
+            return getHomeModel();
+        } else {
+            return getInteraction();
+        }
+    }
+    
+    /**
+     * Look for delete events of the interaction that this diagram
+     * represents. Null our interaction reference if detected.
+     * @param evt the property change event
+     */
+    public void propertyChange(PropertyChangeEvent evt) {
+        if (evt instanceof DeleteInstanceEvent
+                && evt.getSource() == interaction) {
+            Model.getPump().removeModelEventListener(this, interaction);
+            interaction = null;
+        }
+    }
 
     /**
      * The UID.

Modified: 
trunk/src/argouml-app/src/org/argouml/uml/diagram/collaboration/ui/ActionAddClassifierRole.java
Url: 
http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/collaboration/ui/ActionAddClassifierRole.java?view=diff&pathrev=19418&r1=19417&r2=19418
==============================================================================
--- 
trunk/src/argouml-app/src/org/argouml/uml/diagram/collaboration/ui/ActionAddClassifierRole.java
     (original)
+++ 
trunk/src/argouml-app/src/org/argouml/uml/diagram/collaboration/ui/ActionAddClassifierRole.java
     2011-05-13 04:40:27-0700
@@ -70,10 +70,9 @@
         GraphModel gm = ce.getGraphModel();
         if (gm instanceof CollabDiagramGraphModel) {
             Object collaboration =
-                ((CollabDiagramGraphModel) gm).getHomeModel();
+                ((CollabDiagramGraphModel) gm).getOwner();
             node =
-                Model.getCollaborationsFactory().buildClassifierRole(
-                        collaboration);
+                Model.getCollaborationsFactory().buildLifeline(collaboration);
         } else {
             throw new IllegalStateException("Graphmodel is not a "
                     + "collaboration diagram graph model");

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

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

Reply via email to