From efab78668519c0b74f28f2cb1132e6bad4ef7e20 Mon Sep 17 00:00:00 2001 From: lempinen Date: Fri, 20 May 2011 07:55:54 +0000 Subject: [PATCH] git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@21040 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../simantics/sysdyn/manager/SysdynModel.java | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java index 748841a9..40bbf5ae 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java @@ -11,9 +11,11 @@ *******************************************************************************/ package org.simantics.sysdyn.manager; +import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.io.StringReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -285,8 +287,45 @@ public class SysdynModel implements IMappingListener, IModel { } private boolean hasStructureChanged(String modelText, Map inits) { - if (!modelText.equals(previousModelStructure)) + + + BufferedReader current = new BufferedReader( + new StringReader(modelText)); + BufferedReader previous = new BufferedReader( + new StringReader(previousModelStructure)); + + String c, p; + try { + c = current.readLine(); + p = previous.readLine(); + + while (c != null && p != null) { + if(!c.equals(p)) { + if(c.contains("parameter") && p.contains("parameter")) { + int i = c.indexOf("="); + if(!c.substring(0, i).equals(p.substring(0, i))) { + // different parameter definition + return true; + } + } else { + // other than a line containing parameters differs + return true; + } + } + c = current.readLine(); + p = previous.readLine(); + } + + if((c == null && p != null) || (c != null && p == null)) { + // different lengths + return true; + } + + } catch(IOException e) { + //e.printStackTrace(); return true; + } + for(String key : previousImportantInits.keySet()) { if(!inits.containsKey(key) || !previousImportantInits.get(key).equals(inits.get(key))) return true; -- 2.47.1