]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@21040 ac1ea38d-2e2b...
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 20 May 2011 07:55:54 +0000 (07:55 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 20 May 2011 07:55:54 +0000 (07:55 +0000)
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java

index 748841a9f204e75008a2a51e29e0463fd800100c..40bbf5ae84f2d6f33fc9f4cab510314a843e041d 100644 (file)
  *******************************************************************************/\r
 package org.simantics.sysdyn.manager;\r
 \r
+import java.io.BufferedReader;\r
 import java.io.File;\r
 import java.io.FileNotFoundException;\r
 import java.io.IOException;\r
+import java.io.StringReader;\r
 import java.util.ArrayList;\r
 import java.util.Arrays;\r
 import java.util.Collection;\r
@@ -285,8 +287,45 @@ public class SysdynModel implements IMappingListener, IModel {
        }\r
 \r
        private boolean hasStructureChanged(String modelText, Map<String, String> inits) {\r
-               if (!modelText.equals(previousModelStructure))\r
+               \r
+               \r
+               BufferedReader current = new BufferedReader(\r
+                               new StringReader(modelText));\r
+               BufferedReader previous = new BufferedReader(\r
+                               new StringReader(previousModelStructure));\r
+\r
+               String c, p;\r
+               try {\r
+                       c = current.readLine();\r
+                       p = previous.readLine();\r
+                       \r
+                       while (c != null && p != null) {\r
+                               if(!c.equals(p)) {\r
+                                       if(c.contains("parameter") && p.contains("parameter")) {\r
+                                               int i = c.indexOf("=");\r
+                                               if(!c.substring(0, i).equals(p.substring(0, i))) {\r
+                                                       // different parameter definition\r
+                                                       return true;\r
+                                               }\r
+                                       } else {\r
+                                               // other than a line containing parameters differs\r
+                                               return true;\r
+                                       }\r
+                               }\r
+                               c = current.readLine();\r
+                               p = previous.readLine();\r
+                       }\r
+                       \r
+                       if((c == null && p != null) || (c != null && p == null)) {\r
+                               // different lengths\r
+                               return true;\r
+                       }\r
+\r
+               } catch(IOException e) {\r
+                       //e.printStackTrace();\r
                        return true;\r
+               }\r
+\r
                for(String key : previousImportantInits.keySet()) {\r
                        if(!inits.containsKey(key) || !previousImportantInits.get(key).equals(inits.get(key)))\r
                                return true;\r