From 6fd88055dcf1a4982cc607222e77907a786173a8 Mon Sep 17 00:00:00 2001 From: Marko Luukkainen Date: Tue, 24 Oct 2017 11:16:33 +0300 Subject: [PATCH] Ability to reset the default selections --- .../scl/Interop/Update.scl | 3 ++ .../interop/update/model/ModelUpdate.java | 40 ++++++++++++++++--- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/org.simantics.interop.update/scl/Interop/Update.scl b/org.simantics.interop.update/scl/Interop/Update.scl index 1498a86..8397844 100644 --- a/org.simantics.interop.update/scl/Interop/Update.scl +++ b/org.simantics.interop.update/scl/Interop/Update.scl @@ -38,6 +38,9 @@ importJava "org.simantics.interop.update.model.ModelUpdate" where @JavaName getChanges getGraphChanges3 :: ModelUpdate -> Maybe GraphChanges + @JavaName defaultSelections + setDefaultSelections :: ModelUpdate -> () + importJava "org.simantics.interop.update.model.UpdateTree" where data UpdateTree 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 553396b..bf391d4 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 @@ -20,15 +20,19 @@ import org.simantics.utils.datastructures.Pair; public abstract class ModelUpdate { - private GraphChanges changes; + private Resource oldModel; // old model that is going to be updated (User modified model) + private Resource newModel; // new model that contains the updates (New design model) + private Resource originalModel; // original model (optional) that is used for detecting and retaining user made changes (Old design model) + + private GraphChanges changes; // changes between old /new private UpdateTree updateTree; private UpdateList updateList; - private GraphChanges changes2; + private GraphChanges changes2; // changes between original / old private UpdateTree updateTree2; private UpdateList updateList2; - private GraphChanges changes3; + private GraphChanges changes3; // changes between original / new private UpdateTree updateTree3; private UpdateList updateList3; @@ -40,7 +44,18 @@ public abstract class ModelUpdate { setInput(oldModel, newModel, null, false); } + /** + * Initialises the ModelUpdate with given input + * @param oldModel the model that is going to be updated (User modified model) + * @param newModel the model containing updates (New design model) + * @param originalModel the model that is used for detecting and retaining user made changes (Old design model). Parameter can be null. + * @param newDistinct when originalModel is given, additions to the old and the new model (when compared to the original model) are forced to be distinct. + * @throws DatabaseException + */ public void setInput(Resource oldModel, Resource newModel, Resource originalModel, boolean newDistinct) throws DatabaseException{ + this.oldModel = oldModel; + this.newModel = newModel; + this.originalModel = originalModel; addFilters(filters); if (originalModel != null) { // tree way comparison @@ -110,7 +125,7 @@ public abstract class ModelUpdate { if (originalModel != null) { - createDefaultSelections(); + defaultSelections(); } init = true; @@ -128,6 +143,18 @@ public abstract class ModelUpdate { } + public Resource getOldModel() { + return oldModel; + } + + public Resource getNewModel() { + return newModel; + } + + public Resource getOriginalModel() { + return originalModel; + } + public boolean isInit() { return init; } @@ -304,7 +331,10 @@ public abstract class ModelUpdate { } } - protected void createDefaultSelections() { + public void defaultSelections() { + if (changes3 == null) { + return; + } // select all changes for (Entry op : updateTree.getUpdateOps().getResourceMap().entrySet()) { op.getValue().select(true); -- 2.45.2