svn commit: r15361 - trunk/src/argouml-app/src/org/argouml/profile/internal/ProfileManagerImpl.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: maurelio1234
Date: 2008-07-24 05:23:22-0700
New Revision: 15361

Modified:
   trunk/src/argouml-app/src/org/argouml/profile/internal/ProfileManagerImpl.java

Log:

the old code failed when the uml profile was not in the user preferences file, 
i changed the profilemanager to be robust to errors in this file



Modified: trunk/src/argouml-app/src/org/argouml/profile/internal/ProfileManagerImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/profile/internal/ProfileManagerImpl.java?view=diff&rev=15361&p1=trunk/src/argouml-app/src/org/argouml/profile/internal/ProfileManagerImpl.java&p2=trunk/src/argouml-app/src/org/argouml/profile/internal/ProfileManagerImpl.java&r1=15360&r2=15361
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/profile/internal/ProfileManagerImpl.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/profile/internal/ProfileManagerImpl.java	2008-07-24 05:23:22-0700
@@ -76,6 +76,8 @@
     private List<String> searchDirectories = new ArrayList<String>();
 
     private Profile profileUML;
+    
+    private Profile profileJava;
 
     /**
      * Constructor - includes initialization of built-in default profiles.
@@ -83,9 +85,14 @@
     public ProfileManagerImpl() {
         try {
             profileUML = new ProfileUML();
-            addToDefaultProfiles(profileUML);
+            profileJava = new ProfileJava(profileUML);
+            
             registerProfile(profileUML);
-            registerProfile(new ProfileJava(profileUML));
+            addToDefaultProfiles(profileUML); 
+                // the UML Profile is always present and default
+            
+            // register the built-in profiles
+            registerProfile(profileJava);                
             registerProfile(new ProfileMeta());
         } catch (ProfileException e) {
             throw new RuntimeException(e);
@@ -101,26 +108,34 @@
     private void loadDefaultProfilesfromConfiguration() {    
         disableConfigurationUpdate = true;
         
-        StringTokenizer tokenizer = new StringTokenizer(Configuration
-                .getString(KEY_DEFAULT_PROFILES), DIRECTORY_SEPARATOR, false);
-
-        while (tokenizer.hasMoreTokens()) {
-            String desc = tokenizer.nextToken();
-            Profile p = null;
+        String defaultProfilesList = Configuration
+                        .getString(KEY_DEFAULT_PROFILES);
+        if (defaultProfilesList.equals("")) {
+            // if the list does not exist
+            // add the Java profile as default
             
-            if (desc.charAt(0) == 'U') {
-                String fileName = desc.substring(1);
-                p = findUserDefinedProfile(new File(fileName));                
-            } else if (desc.charAt(0) == 'C') {
-                String className = desc.substring(1);
-                p = getProfileForClass(className);
-            }
+            addToDefaultProfiles(profileJava);
+        } else {
+            StringTokenizer tokenizer = new StringTokenizer(
+                    defaultProfilesList, DIRECTORY_SEPARATOR, false);
+
+            while (tokenizer.hasMoreTokens()) {
+                String desc = tokenizer.nextToken();
+                Profile p = null;
+
+                if (desc.charAt(0) == 'U') {
+                    String fileName = desc.substring(1);
+                    p = findUserDefinedProfile(new File(fileName));
+                } else if (desc.charAt(0) == 'C') {
+                    String className = desc.substring(1);
+                    p = getProfileForClass(className);
+                }
 
-            if (p != null) {
-                addToDefaultProfiles(p);
+                if (p != null) {
+                    addToDefaultProfiles(p);
+                }
             }
         }
-
         disableConfigurationUpdate = false;
     }
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.