svn commit: r15892 - trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFigUtil.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2008-10-06 11:42:37-0700
New Revision: 15892

Modified:
   trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFigUtil.java

Log:
Handle case where graph model doesn't contain the project.  Add Javadoc

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFigUtil.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFigUtil.java?view=diff&rev=15892&p1=trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFigUtil.java&p2=trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFigUtil.java&r1=15891&r2=15892
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFigUtil.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFigUtil.java	2008-10-06 11:42:37-0700
@@ -41,6 +41,13 @@
  */
 public class ArgoFigUtil {
     
+    /**
+     * Find the Project that contains a given figure.  Because we don't have
+     * a single reliable way to do this, we try a bunch of different approachs.
+     * 
+     * @param fig the Fig to return the project of
+     * @return the project containing the given fig
+     */
     public static Project getProject(ArgoFig fig) {
         if (fig instanceof Fig) {
             Fig f = (Fig) fig;
@@ -51,8 +58,8 @@
                  * Why is the Layer not set in the constructor? */
                 Editor editor = Globals.curEditor();
                 if (editor == null) {
-                    // TODO: The above doesn't work reliably in a constructor.  We
-                    // need a better way of getting default fig settings 
+                    // TODO: The above doesn't work reliably in a constructor.
+                    // We need a better way of getting default fig settings 
                     // for the owning project rather than using the 
                     // project manager singleton. - tfm
                     return ProjectManager.getManager().getCurrentProject();
@@ -67,10 +74,12 @@
             }
             GraphModel gm = layer.getGraphModel();
             if (gm instanceof UMLMutableGraphSupport) {
-                return ((UMLMutableGraphSupport) gm).getProject();
-            } else {
-                return ProjectManager.getManager().getCurrentProject();
+                Project project = ((UMLMutableGraphSupport) gm).getProject();
+                if (project != null) {
+                    return project;
+                }
             }
+            return ProjectManager.getManager().getCurrentProject();
         }
         return null;
     }
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.