svn commit: r17448 - trunk/src/argouml-app/src/org/argouml/kernel/ProjectManager.java

Thomas Neustupny <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: thn
Date: 2009-11-02 09:19:08-0800
New Revision: 17448

Modified:
   trunk/src/argouml-app/src/org/argouml/kernel/ProjectManager.java

Log:
make sure that all profiles are applied to newly created models

Modified: trunk/src/argouml-app/src/org/argouml/kernel/ProjectManager.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/kernel/ProjectManager.java?view=diff&pathrev=17448&r1=17447&r2=17448
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/kernel/ProjectManager.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/kernel/ProjectManager.java	2009-11-02 09:19:08-0800
@@ -40,6 +40,8 @@
 import org.argouml.model.Model;
 import org.argouml.model.ModelCommand;
 import org.argouml.model.ModelCommandCreationObserver;
+import org.argouml.profile.Profile;
+import org.argouml.profile.ProfileException;
 import org.argouml.uml.cognitive.ProjectMemberTodoList;
 import org.argouml.uml.diagram.ArgoDiagram;
 import org.argouml.uml.diagram.DiagramFactory;
@@ -362,6 +364,31 @@
     }
 
     /**
+     * Apply all profiles from the profile configuration to a model (can be a
+     * profile too).
+     * 
+     * @param project The project with the profile configuration.
+     * @param model The model to apply the profiles to.
+     */
+    private void applyProfileConfiguration(Project project, Object model) {
+        Collection<Profile> c =
+            project.getProfileConfiguration().getProfiles();
+        if (c != null) {
+            for (Profile p : c) {
+                try {
+                    for (Object profile : p.getProfilePackages()) {
+                        Model.getExtensionMechanismsHelper()
+                            .applyProfile(model, profile);
+                    }
+                } catch (ProfileException pe) {
+                    LOG.warn("Failed to get profile packages from profile "
+                            + p.getDisplayName());
+                }
+            }
+        }
+    }
+
+    /**
      * Create the default diagrams for the project. Currently a Class Diagram
      * and a UseCase diagram.
      * 
@@ -425,6 +452,8 @@
         project.setRoots(roots);
         project.setCurrentNamespace(model);
         project.addMember(model);
+        // finally, apply profile configuration to the model
+        applyProfileConfiguration(project, model);
     }
 
     /**
@@ -442,6 +471,8 @@
         project.setRoots(roots);
         project.setCurrentNamespace(model);
         project.addMember(model);
+        // finally, apply profile configuration to the model
+        applyProfileConfiguration(project, model);
     }
     
     /**

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

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.