From: Marko Luukkainen Date: Tue, 22 Feb 2022 14:41:58 +0000 (+0200) Subject: Progress Monitor support X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=e9c2e1be3035e043674052acc916e1d3446114fb;p=simantics%2Finterop.git Progress Monitor support Check monitor cancel status more often in ModelUpdate. gitlab #35 Change-Id: I90ecfac649c6cea45ce95d9a32a3ee8774d79291 --- 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 32da62b..51cd1eb 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 @@ -82,8 +82,10 @@ public abstract class ModelUpdate { showWarning(result2.second); comparator2.test(getSession(), monitor); changes2 = comparator2.getChanges(); - if (monitor.isCanceled()) + if (monitor.isCanceled()) { + dispose(); return; + } changes2 = getSession().syncRequest(createFilterRead(changes2, filters)); Pair chg2 = createChangeObjects(changes2, null); updateTree2 = chg2.first; @@ -98,8 +100,10 @@ public abstract class ModelUpdate { changes3 = comparator3.getChanges(); changes3 = getSession().syncRequest(createFilterRead(changes3, filters)); } - if (monitor.isCanceled()) + if (monitor.isCanceled()) { + dispose(); return; + } Pair result = getChanges(oldModel,newModel); GraphComparator comparator = result.first; @@ -138,14 +142,20 @@ public abstract class ModelUpdate { } } } - if (monitor.isCanceled()) + if (monitor.isCanceled()) { + dispose(); return; + } comparator.test(getSession(), monitor); monitor.setTaskName("Processing changes..."); monitor.subTask(""); changes = comparator.getChanges(); changes = getSession().syncRequest(createFilterRead(changes, filters)); Pair chg = createChangeObjects(changes, monitor); + if (chg == null) { + dispose(); + return; + } updateTree = chg.first; updateList = chg.second; if (userFilters.size() != 0) { @@ -270,14 +280,23 @@ public abstract class ModelUpdate { protected abstract Pair getChanges(Resource r1, Resource r2) throws DatabaseException; protected Pair createChangeObjects(GraphChanges changes, IProgressMonitor monitor) throws DatabaseException{ - if (monitor != null) + if (monitor != null) { + if (monitor.isCanceled()) + return null; monitor.subTask("Processing structural changes"); + } UpdateTree updateTree = getUpdateTree(changes); - if (monitor != null) + if (monitor != null) { + if (monitor.isCanceled()) + return null; monitor.subTask("Processing property changes"); + } UpdateList updateList = getUpdateList(changes); - if (monitor != null) + if (monitor != null) { + if (monitor.isCanceled()) + return null; monitor.subTask("Postprocessing changes"); + } postProcess(updateTree, updateList); return new Pair(updateTree, updateList); } @@ -342,9 +361,9 @@ public abstract class ModelUpdate { } public UpdateList getUpdateList3() throws DatabaseException { if (updateList3 == null && changes3 != null) { - Pair chg3 = createChangeObjects(changes3, null); - updateTree3 = chg3.first; - updateList3 = chg3.second; + Pair chg3 = createChangeObjects(changes3, null); + updateTree3 = chg3.first; + updateList3 = chg3.second; } return updateList3; } @@ -622,5 +641,6 @@ public abstract class ModelUpdate { updateTree2 = null; updateTree3 = null; updateNode3 = null; + init = false; } }