X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=org.simantics.interop.update%2Fsrc%2Forg%2Fsimantics%2Finterop%2Fupdate%2Fmodel%2FModelUpdate.java;h=d76c47bdf655998c902de59f6f2b7f08c58f7bd8;hb=ab4fc05981803ce2c430f93f34b8b6a8f85a53ce;hp=2149fc5dd5710ce207efab5378683e9f6583de15;hpb=ed79a91bdd86658d28be3d50322a0d4d8cff98dc;p=simantics%2Finterop.git diff --git a/org.simantics.interop.update/src/org/simantics/interop/update/model/ModelUpdate.java b/org.simantics.interop.update/src/org/simantics/interop/update/model/ModelUpdate.java index 2149fc5..d76c47b 100644 --- a/org.simantics.interop.update/src/org/simantics/interop/update/model/ModelUpdate.java +++ b/org.simantics.interop.update/src/org/simantics/interop/update/model/ModelUpdate.java @@ -3,6 +3,7 @@ package org.simantics.interop.update.model; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.Deque; import java.util.List; import java.util.Map.Entry; @@ -70,7 +71,7 @@ public abstract class ModelUpdate { showWarning(result2.second); comparator2.test(getSession()); changes2 = comparator2.getChanges(); - changes2 = getSession().syncRequest(new FilterChangesRead(changes2, filters)); + changes2 = getSession().syncRequest(createFilterRead(changes2, filters)); updateTree2 = getUpdateTree(changes2); updateList2 = getUpdateList(changes2); @@ -81,7 +82,7 @@ public abstract class ModelUpdate { showWarning(result3.second); comparator3.test(getSession()); changes3 = comparator3.getChanges(); - changes3 = getSession().syncRequest(new FilterChangesRead(changes3, filters)); + changes3 = getSession().syncRequest(createFilterRead(changes3, filters)); } Pair result = getChanges(oldModel,newModel); @@ -123,7 +124,7 @@ public abstract class ModelUpdate { } comparator.test(getSession()); changes = comparator.getChanges(); - changes = getSession().syncRequest(new FilterChangesRead(changes, filters)); + changes = getSession().syncRequest(createFilterRead(changes, filters)); updateTree = getUpdateTree(changes); updateList = getUpdateList(changes); if (userFilters.size() != 0) { @@ -145,6 +146,10 @@ public abstract class ModelUpdate { } + public List getFilters() { + return Collections.unmodifiableList(filters); + } + /** * Adds an user filter. Use refreshUserFilters() to apply the changes. * @param filter @@ -168,6 +173,10 @@ public abstract class ModelUpdate { userFilters.clear(); } + public List getUserFilters() { + return userFilters; + } + public void refreshUserFilters() throws DatabaseException{ // use user filters to set visible flags of changes. // First, set all changes visible. @@ -185,7 +194,7 @@ public abstract class ModelUpdate { // Create filtered changes List combined = new ArrayList<>(filters); combined.addAll(userFilters); - GraphChanges filteredChanges = getSession().syncRequest(new FilterChangesRead(changes, combined)); + GraphChanges filteredChanges = getSession().syncRequest(createFilterRead(changes, combined)); UpdateTree updateTreeF = getUpdateTree(filteredChanges); UpdateList updateListF = getUpdateList(filteredChanges); // hide changes that are not contained within the filtered changes. @@ -231,8 +240,13 @@ public abstract class ModelUpdate { for (PropertyChange rc : r) { if (comparable.containsRight(rc)) continue; - if (lc.getFirst().equals(rc.getFirst())) { + if (lc.getFirst() != null && lc.getFirst().equals(rc.getFirst())) { comparable.map(lc, rc); + break; + } + if (lc.getSecond() != null && lc.getSecond().equals(rc.getSecond())) { + comparable.map(lc, rc); + break; } } } @@ -329,9 +343,13 @@ public abstract class ModelUpdate { return Simantics.getSession(); } + public Read createFilterRead(GraphChanges changes, List filters) { + return new FilterChangesRead(changes, filters); + } + - private class FilterChangesRead implements Read { + public static class FilterChangesRead implements Read { private GraphChanges changes; private List filters; @@ -347,7 +365,7 @@ public abstract class ModelUpdate { /** * Filters changes: - * 1. Changes that are not essential for model update (changes that can be found when the models are axcatly the same) + * 1. Changes that are not essential for model update (changes that can be found when the models are exactly the same) * 2. Runs custom filters for value changes. * * @param g @@ -457,7 +475,7 @@ public abstract class ModelUpdate { if (pair.getFirst() != null) { boolean found = false; for (PropertyChange pair2 : updateList2.getChanges()) { - if (pair.getFirst().equals(pair2.getSecond())) { + if (pair.getFirst() != null && pair.getFirst().equals(pair2.getSecond())) { found = true; break; }