svn commit: r13792 - trunk/src_new/org/argouml: kernel persistence

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: mvw
Date: 2007-11-19 13:59:15-0800
New Revision: 13792

Modified:
   trunk/src_new/org/argouml/kernel/ProjectSettings.java
   trunk/src_new/org/argouml/persistence/ArgoParser.java

Log:
Prevent that loading a project with an unavailable Notation leads to an exception when showing the Notation selection menu-item.
Currently, just fall back on the default notation. Better would be to also warn the user that his file was changed while loading.

Modified: trunk/src_new/org/argouml/kernel/ProjectSettings.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/kernel/ProjectSettings.java?view=diff&rev=13792&p1=trunk/src_new/org/argouml/kernel/ProjectSettings.java&p2=trunk/src_new/org/argouml/kernel/ProjectSettings.java&r1=13791&r2=13792
==============================================================================
--- trunk/src_new/org/argouml/kernel/ProjectSettings.java	(original)
+++ trunk/src_new/org/argouml/kernel/ProjectSettings.java	2007-11-19 13:59:15-0800
@@ -188,9 +188,14 @@
 
     /**
      * @param newLanguage the notation language.
+     * @return true if the notation is set - false if it does not exist
      */
-    public void setNotationLanguage(final String newLanguage) {
-        if (notationLanguage.equals(newLanguage)) return;
+    public boolean setNotationLanguage(final String newLanguage) {
+        if (notationLanguage.equals(newLanguage)) return true;
+        if (Notation.findNotation(newLanguage) == null) {
+            /* This Notation is not available! */
+            return false;
+        }
         
         final String oldLanguage = notationLanguage;
         
@@ -214,6 +219,7 @@
         }
         memento.redo();
         ProjectManager.getManager().setSaveEnabled(true);
+        return true;
     }
     
     /**

Modified: trunk/src_new/org/argouml/persistence/ArgoParser.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/persistence/ArgoParser.java?view=diff&rev=13792&p1=trunk/src_new/org/argouml/persistence/ArgoParser.java&p2=trunk/src_new/org/argouml/persistence/ArgoParser.java&r1=13791&r2=13792
==============================================================================
--- trunk/src_new/org/argouml/persistence/ArgoParser.java	(original)
+++ trunk/src_new/org/argouml/persistence/ArgoParser.java	2007-11-19 13:59:15-0800
@@ -346,7 +346,12 @@
      */
     protected void handleNotationLanguage(XMLElement e) {
         String language = e.getText().trim();
-        ps.setNotationLanguage(language);
+        boolean success = ps.setNotationLanguage(language);
+        /* TODO: Here we should e.g. show the user a message that 
+         * the loaded project was using a Notation that is not 
+         * currently available and a fall back on the default Notation 
+         * was done. Maybe this can be implemented in the 
+         * PersistenceManager? */
     }
 
     /**
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.