svn commit: r16847 - trunk/src/argouml-app/src/org/argouml/uml/diagram: activity/ui ui

Bob Tarling <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: bobtarling
Date: 2009-03-02 12:22:31-0800
New Revision: 16847

Modified:
   trunk/src/argouml-app/src/org/argouml/uml/diagram/activity/ui/FigPartition.java
   trunk/src/argouml-app/src/org/argouml/uml/diagram/activity/ui/FigPool.java
   trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigNodeModelElement.java

Log:
Issue 5705: Allow null owner and null stereotype Fig

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/activity/ui/FigPartition.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/activity/ui/FigPartition.java?view=diff&pathrev=16847&r1=16846&r2=16847
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/activity/ui/FigPartition.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/activity/ui/FigPartition.java	2009-03-02 12:22:31-0800
@@ -288,7 +288,7 @@
                 getOwner(), activityGraph);
 	
 	if (partitions.size() == 1) {
-	    FigPool fp = new FigPool(getOwner(), getBounds(), getSettings());
+	    FigPool fp = new FigPool(null, getBounds(), getSettings());
 	    getLayer().add(fp);
 	    getLayer().bringToFront(this);
 	} else if (partitions.size() > 1) {

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/activity/ui/FigPool.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/activity/ui/FigPool.java?view=diff&pathrev=16847&r1=16846&r2=16847
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/activity/ui/FigPool.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/activity/ui/FigPool.java	2009-03-02 12:22:31-0800
@@ -33,6 +33,7 @@
 import org.argouml.uml.diagram.DiagramSettings;
 import org.argouml.uml.diagram.ui.FigEmptyRect;
 import org.argouml.uml.diagram.ui.FigNodeModelElement;
+import org.argouml.uml.diagram.ui.FigStereotypesGroup;
 import org.tigris.gef.presentation.Fig;
 import org.tigris.gef.presentation.FigRect;
 
@@ -79,6 +80,16 @@
     }
 
 
+    /**
+     * Get the Fig containing the stereotype(s). As there is no stereotype
+     * display for this Fig we return null
+     *
+     * @return the stereotype FigGroup
+     */
+    protected FigStereotypesGroup getStereotypeFig() {
+        return null;
+    }
+
     /*
      * @see org.argouml.uml.diagram.ui.FigNodeModelElement#clone()
      */

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigNodeModelElement.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigNodeModelElement.java?view=diff&pathrev=16847&r1=16846&r2=16847
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigNodeModelElement.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigNodeModelElement.java	2009-03-02 12:22:31-0800
@@ -416,13 +416,14 @@
         bigPort = new FigRect(X0, Y0, 0, 0, DEBUG_COLOR, DEBUG_COLOR);
         nameFig = new FigNameWithAbstractAndBold(element, 
                 new Rectangle(X0, Y0, WIDTH, NAME_FIG_HEIGHT), getSettings(), true);
-        stereotypeFig = new FigStereotypesGroup(element, 
-                new Rectangle(X0, Y0, WIDTH, STEREOHEIGHT), settings);
         constructFigs();
-        if (element == null) {
-            throw new IllegalArgumentException("An owner must be supplied");
-        }
-        if (!Model.getFacade().isAUMLElement(element)) {
+        
+        // TODO: For a FigPool the element will be null.
+        // When issue 5031 is resolved this constraint can be reinstated
+//        if (element == null) {
+//            throw new IllegalArgumentException("An owner must be supplied");
+//        }
+        if (element != null && !Model.getFacade().isAUMLElement(element)) {
             throw new IllegalArgumentException(
                     "The owner must be a model element - got a "
                     + element.getClass().getName());
@@ -430,17 +431,19 @@
 
         nameFig.setText(placeString());
         
-        notationProviderName =
-            NotationProviderFactory2.getInstance().getNotationProvider(
-                    getNotationProviderType(), element, this);
+        if (element != null) {
+            notationProviderName =
+                NotationProviderFactory2.getInstance().getNotationProvider(
+                        getNotationProviderType(), element, this);
 
-        /* This next line presumes that the 1st fig with this owner 
-         * is the previous port - and consequently nullifies the owner 
-         * of this 1st fig. */
-        bindPort(element, bigPort);
+            /* This next line presumes that the 1st fig with this owner 
+             * is the previous port - and consequently nullifies the owner 
+             * of this 1st fig. */
+            bindPort(element, bigPort);
 
-        // Add a listener for changes to any property
-        addElementListener(element);
+            // Add a listener for changes to any property
+            addElementListener(element);
+        }
 
         if (bounds != null) {
             setLocation(bounds.x, bounds.y);
@@ -502,7 +505,7 @@
                  * BTW: In some other FigNodeModelElement 
                  * classes I see the same mistake. */
             }
-            if (thisFig == stereotypeFig) {
+            if (thisFig == getStereotypeFig()) {
                 clone.stereotypeFig = (FigStereotypesGroup) thisFig;
                 /* Idem here:
                  * clone.stereotypeFig = (FigStereotypesGroup) cloneFig; */
@@ -1506,7 +1509,7 @@
         }
         super.setOwner(owner);
         nameFig.setOwner(owner); // for setting abstract
-        stereotypeFig.setOwner(owner);
+        getStereotypeFig().setOwner(owner);
         initNotationProviders(owner);
         readyToEdit = true;
         renderingChanged();
@@ -1574,7 +1577,7 @@
                     + this.getClass());
             return;
         }
-        stereotypeFig.populate();
+        getStereotypeFig().populate();
     }
 
     /**
@@ -1962,7 +1965,7 @@
         setShadowSize(0);
         super.removeFromDiagram();
         // Get model listeners removed:
-        stereotypeFig.removeFromDiagram();
+        getStereotypeFig().removeFromDiagram();
     }
 
     /**
@@ -1971,6 +1974,10 @@
      * @return the stereotype FigGroup
      */
     protected FigStereotypesGroup getStereotypeFig() {
+        if (stereotypeFig == null) {
+            stereotypeFig = new FigStereotypesGroup(getOwner(), 
+                    new Rectangle(X0, Y0, WIDTH, STEREOHEIGHT), settings);
+        }
         return stereotypeFig;
     }
 
@@ -2524,7 +2531,9 @@
         super.setLineWidth(w);
         // Default for name and stereotype is no border
         getNameFig().setLineWidth(0);
-        getStereotypeFig().setLineWidth(0);
+        if (getStereotypeFig() != null) {
+            getStereotypeFig().setLineWidth(0);
+        }
     }
     
     /**

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

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.