From 38cf4e45bf3648896fb2ba1bfb38378098ac3cc6 Mon Sep 17 00:00:00 2001 From: Antti Villberg Date: Fri, 29 Nov 2019 09:57:07 +0200 Subject: [PATCH] Maintain info about changed resources in virtual graph gitlab #428 Change-Id: Ia697012400c7a0a4bd07462eafbf08ffa082890d --- .../graph/Modeling.pgraph | 9 ++-- .../graph/ModelingViewpoint.pgraph | 12 +++++ .../org.simantics.modeling.ui/adapters.xml | 3 ++ .../icons/changed_decorator.png | Bin 0 -> 244 bytes .../org/simantics/modeling/ui/Activator.java | 4 ++ .../ChangedResourceImageDecorationRule.java | 43 ++++++++++++++++++ .../org/simantics/modeling/ModelingUtils.java | 13 ++++++ .../OntologicalRequirementEnforceRequest.java | 3 ++ 8 files changed, 82 insertions(+), 5 deletions(-) create mode 100644 bundles/org.simantics.modeling.ui/icons/changed_decorator.png create mode 100644 bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser2/image/ChangedResourceImageDecorationRule.java diff --git a/bundles/org.simantics.modeling.ontology/graph/Modeling.pgraph b/bundles/org.simantics.modeling.ontology/graph/Modeling.pgraph index a45e7419c..e566026b1 100644 --- a/bundles/org.simantics.modeling.ontology/graph/Modeling.pgraph +++ b/bundles/org.simantics.modeling.ontology/graph/Modeling.pgraph @@ -411,6 +411,10 @@ MOD.changeInformation + diff --git a/bundles/org.simantics.modeling.ui/icons/changed_decorator.png b/bundles/org.simantics.modeling.ui/icons/changed_decorator.png new file mode 100644 index 0000000000000000000000000000000000000000..f0476a43da9f70cb0bf2de9afa7c2c94a8928227 GIT binary patch literal 244 zcmeAS@N?(olHy`uVBq!ia0vp^>>$j+1|*LJg z#}J9|*uIUN2NXnH^cD3KA}pGmceFI`YMk1;x7Rvj?IPDh+Xc>K%azY>u0JYqKZxtu z9Es$d;&X+T&*P3s{97`mVEeVO6PC`|dws4%6@I@LZg5Oy*~Pf1Z2rp`@~r|N?&%9( ju@CZU5$N+j>7`jSv&L7rBq4q>&~gS(S3j3^P6 Image decorateImage(Image image, String column, int itemIndex) { + ImageDescriptor original = (ImageDescriptor)image; + ImageDescriptor decorated = (original == null || original.getImageData() == null) ? Activator.CHANGED_DECORATOR_ICON + : new DecorationOverlayIcon(original, Activator.CHANGED_DECORATOR_ICON, IDecoration.BOTTOM_RIGHT); + return (Image)decorated; + } + }; + + @Override + public boolean isCompatible(Class contentType) { + return Resource.class.isAssignableFrom(contentType); + } + + @Override + public ImageDecorator getImageDecorator(ReadGraph graph, Object content) + throws DatabaseException + { + Resource resource = (Resource) content; + ModelingResources MOD = ModelingResources.getInstance(graph); + if (!graph.hasStatement(resource, MOD.changed)) + return null; + + return CHANGED_DECORATOR; + } + +} diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/ModelingUtils.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/ModelingUtils.java index ea960c1d0..4a4d97a18 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/ModelingUtils.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/ModelingUtils.java @@ -67,6 +67,7 @@ import org.simantics.db.RequestProcessor; import org.simantics.db.Resource; import org.simantics.db.Session; import org.simantics.db.Statement; +import org.simantics.db.VirtualGraph; import org.simantics.db.WriteGraph; import org.simantics.db.common.Indexing; import org.simantics.db.common.NamedResource; @@ -2464,4 +2465,16 @@ public class ModelingUtils { return DiagramGraphUtil.getModelingRules(graph, diagramResource, null); } + public static void markChanged(WriteGraph graph, Resource r) throws DatabaseException { + VirtualGraphSupport support = Simantics.getSession().getService(VirtualGraphSupport.class); + VirtualGraph vg = support.getWorkspacePersistent("changeInformation"); + graph.syncRequest(new WriteRequest(vg) { + @Override + public void perform(WriteGraph graph) throws DatabaseException { + ModelingResources MOD = ModelingResources.getInstance(graph); + graph.claim(r, MOD.changed, MOD.changed, r); + } + }); + } + } diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/utils/OntologicalRequirementEnforceRequest.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/utils/OntologicalRequirementEnforceRequest.java index dd547ffe3..3f8ffb15b 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/utils/OntologicalRequirementEnforceRequest.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/utils/OntologicalRequirementEnforceRequest.java @@ -11,6 +11,7 @@ import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.util.Layer0Utils; import org.simantics.layer0.Layer0; import org.simantics.modeling.ModelingResources; +import org.simantics.modeling.ModelingUtils; import org.simantics.modeling.adapters.ChangeHistoryUpdated; import org.simantics.modeling.adapters.ChangeInformation; @@ -92,6 +93,7 @@ public class OntologicalRequirementEnforceRequest extends WriteRequest { for (Resource c : creates) { CommonDBUtils.selectClusterSet(graph, c); graph.claimLiteral(c, MOD.changeInformation, MOD.changeInformation_Inverse, MOD.ChangeInformation, info, ChangeInformation.BINDING); + ModelingUtils.markChanged(graph, c); } } @@ -107,6 +109,7 @@ public class OntologicalRequirementEnforceRequest extends WriteRequest { info.modifiedBy = author; CommonDBUtils.selectClusterSet(graph, m); graph.claimLiteral(m, MOD.changeInformation, MOD.changeInformation_Inverse, MOD.ChangeInformation, info, ChangeInformation.BINDING); + ModelingUtils.markChanged(graph, m); } for (Resource r : ids) { -- 2.47.1