]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Maintain info about changed resources in virtual graph 41/3641/2
authorAntti Villberg <antti.villberg@semantum.fi>
Fri, 29 Nov 2019 07:57:07 +0000 (09:57 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 29 Nov 2019 10:25:47 +0000 (10:25 +0000)
gitlab #428

Change-Id: Ia697012400c7a0a4bd07462eafbf08ffa082890d

bundles/org.simantics.modeling.ontology/graph/Modeling.pgraph
bundles/org.simantics.modeling.ontology/graph/ModelingViewpoint.pgraph
bundles/org.simantics.modeling.ui/adapters.xml
bundles/org.simantics.modeling.ui/icons/changed_decorator.png [new file with mode: 0644]
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/Activator.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser2/image/ChangedResourceImageDecorationRule.java [new file with mode: 0644]
bundles/org.simantics.modeling/src/org/simantics/modeling/ModelingUtils.java
bundles/org.simantics.modeling/src/org/simantics/modeling/utils/OntologicalRequirementEnforceRequest.java

index a45e7419cb19c38363b330c0d5c1db4dad7146f1..e566026b12fa14bd8e4082e0d10c70d2dd4b8755 100644 (file)
@@ -411,6 +411,10 @@ MOD.changeInformation <R L0.HasProperty : L0.FunctionalRelation : SEL.GenericPar
     SEL.canBeLifted false
     SEL.HasStandardPropertyInfo MOD.SystemPropertyInfo
 
     SEL.canBeLifted false
     SEL.HasStandardPropertyInfo MOD.SystemPropertyInfo
 
+MOD.changed
+    @L0.defTag
+    L0.HasDescription "Indicates that the change information of this object has been modified after import into this database."
+
 MOD.TypeWithChangeInformation <T L0.Entity
 
 L0.HasName : SEL.GenericParameterType
 MOD.TypeWithChangeInformation <T L0.Entity
 
 L0.HasName : SEL.GenericParameterType
@@ -420,11 +424,6 @@ L0.HasName : SEL.GenericParameterType
 L0.HasLabel : SEL.GenericParameterType
 L0X.HasGeneratedNamePrefix : SEL.GenericParameterType
 
 L0.HasLabel : SEL.GenericParameterType
 L0X.HasGeneratedNamePrefix : SEL.GenericParameterType
 
-//MOD.HasNameBrowseContextContribution : VP.BrowseContextContribution
-//    VP.BrowseContextContribution.HasType L0.String
-//    VP.BrowseContextContribution.HasBrowseContext
-//      _ : VP.BrowseContext
-
 L0.SCLModule : MOD.TypeWithChangeInformation
 L0.SCLScript : MOD.TypeWithChangeInformation
 L0.Library : MOD.TypeWithChangeInformation
 L0.SCLModule : MOD.TypeWithChangeInformation
 L0.SCLScript : MOD.TypeWithChangeInformation
 L0.Library : MOD.TypeWithChangeInformation
index b97753e5fc5c920061de1be78cd1f8b7adde20d9..c68b03dbcb0abc370173276dc91bbf63599c7e41 100644 (file)
@@ -266,6 +266,7 @@ MBC.Symbol : VP.ResourceNodeType
     // that has already unwanted contributions.
 
 MBC.ComponentTypeLockStatusImageDecorationRule : VP.ImageDecorationRule
     // that has already unwanted contributions.
 
 MBC.ComponentTypeLockStatusImageDecorationRule : VP.ImageDecorationRule
+MBC.ChangedResourceImageDecorationRule : VP.ImageDecorationRule
 
 // Labels
 MBC
 
 // Labels
 MBC
@@ -364,6 +365,7 @@ MBC
     @VP.namedConstantImageRule           MOD.Contributions.SheetBookImage        SHEET.Book                           SILK.folder_table
     @VP.namedConstantImageRule           MOD.Contributions.SheetImage            SHEET.Spreadsheet                    SILK.table
     @VP.customImageDecorationRule        STR.ComponentType                       MBC.ComponentTypeLockStatusImageDecorationRule
     @VP.namedConstantImageRule           MOD.Contributions.SheetBookImage        SHEET.Book                           SILK.folder_table
     @VP.namedConstantImageRule           MOD.Contributions.SheetImage            SHEET.Spreadsheet                    SILK.table
     @VP.customImageDecorationRule        STR.ComponentType                       MBC.ComponentTypeLockStatusImageDecorationRule
+    @VP.customImageDecorationRule        L0.Entity                               MBC.ChangedResourceImageDecorationRule
     
 IMAGES = MBC.Images : L0.Library
 IMAGES.SubscriptionsFolder : IMAGE.PngImage
     
 IMAGES = MBC.Images : L0.Library
 IMAGES.SubscriptionsFolder : IMAGE.PngImage
@@ -450,6 +452,13 @@ MOD.Contributions.NewSheetBook : VP.ActionContribution
     VP.ActionContribution.HasNodeType L0.Library
     VP.ActionContribution.HasAction ACTIONS.NewSheetBook
 
     VP.ActionContribution.HasNodeType L0.Library
     VP.ActionContribution.HasAction ACTIONS.NewSheetBook
 
+MOD.Contributions.ImportSheetBook : VP.ActionContribution
+    L0.HasLabel "Spreadsheet"
+    VP.ActionContribution.HasImage SILK.star
+    VP.ActionContribution.HasCategory VP.ImportActionCategory
+    VP.ActionContribution.HasNodeType L0.Library
+    VP.ActionContribution.HasAction ACTIONS.ImportSheetBook
+
 MOD.Contributions.ActivateModel : VP.ActionContribution
     L0.HasLabel "Activate"
     VP.ActionContribution.HasImage SILK.bullet_go
 MOD.Contributions.ActivateModel : VP.ActionContribution
     L0.HasLabel "Activate"
     VP.ActionContribution.HasImage SILK.bullet_go
@@ -693,6 +702,7 @@ MAC
     VP.BrowseContext.SupportsRenamingOf MBC.Symbol
     VP.BrowseContext.HasActionContribution
         MOD.Contributions.NewSheetBook
     VP.BrowseContext.SupportsRenamingOf MBC.Symbol
     VP.BrowseContext.HasActionContribution
         MOD.Contributions.NewSheetBook
+        MOD.Contributions.ImportSheetBook
 
     @VP.renamingTestContribution
         L0.SharedOntology
 
     @VP.renamingTestContribution
         L0.SharedOntology
@@ -732,6 +742,8 @@ ACTIONS.NewSCLQueryType
   @MOD.sclAction "createSCLQueryTypeAction"
 ACTIONS.NewSheetBook
   @MOD.sclAction "createSpreadsheetBookAction"
   @MOD.sclAction "createSCLQueryTypeAction"
 ACTIONS.NewSheetBook
   @MOD.sclAction "createSpreadsheetBookAction"
+ACTIONS.ImportSheetBook
+  @MOD.sclAction "importSpreadsheetBookAction"
 ACTIONS.ActivateModel
   @MOD.sclAction "activateModelAction"
 ACTIONS.ActivateExperiment
 ACTIONS.ActivateModel
   @MOD.sclAction "activateModelAction"
 ACTIONS.ActivateExperiment
index fdb55072aac219cec9a6deebf273f0aa172bb43f..de492168e58ca7ae6249dc9e0f556213ad3cc6a1 100644 (file)
@@ -97,6 +97,9 @@
         <resource
             uri="http://www.simantics.org/Modeling-0.0/ModelingBrowseContext/ComponentTypeLockStatusImageDecorationRule"
             class="org.simantics.structural.ui.modelBrowser.contributions.ComponentTypeLockStatusImageDecorationRule"/>
         <resource
             uri="http://www.simantics.org/Modeling-0.0/ModelingBrowseContext/ComponentTypeLockStatusImageDecorationRule"
             class="org.simantics.structural.ui.modelBrowser.contributions.ComponentTypeLockStatusImageDecorationRule"/>
+        <resource
+            uri="http://www.simantics.org/Modeling-0.0/ModelingBrowseContext/ChangedResourceImageDecorationRule"
+            class="org.simantics.modeling.ui.modelBrowser2.image.ChangedResourceImageDecorationRule"/>
     </target>
 
        <target interface="org.simantics.db.layer0.variable.Expression">
     </target>
 
        <target interface="org.simantics.db.layer0.variable.Expression">
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 (file)
index 0000000..f0476a4
Binary files /dev/null and b/bundles/org.simantics.modeling.ui/icons/changed_decorator.png differ
index 565c30895da465eec60cfbaf72298d312ee77b4f..dfce14c6b6c53a32e3b687fc5e7abb210a902edc 100644 (file)
@@ -41,6 +41,8 @@ public class Activator extends AbstractUIPlugin {
     public static String          INFO_SVG_TEXT;
     public static String          NOTE_SVG_TEXT;
     
     public static String          INFO_SVG_TEXT;
     public static String          NOTE_SVG_TEXT;
     
+    public static ImageDescriptor CHANGED_DECORATOR_ICON;
+
     public static ImageDescriptor BULLET_GREEN_ICON;
     public static ImageDescriptor BULLET_YELLOW_ICON;
 
     public static ImageDescriptor BULLET_GREEN_ICON;
     public static ImageDescriptor BULLET_YELLOW_ICON;
 
@@ -109,6 +111,8 @@ public class Activator extends AbstractUIPlugin {
         INFO_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/info.svg")); //$NON-NLS-1$
         NOTE_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/note4.svg")); //$NON-NLS-1$
 
         INFO_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/info.svg")); //$NON-NLS-1$
         NOTE_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/note4.svg")); //$NON-NLS-1$
 
+        CHANGED_DECORATOR_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/changed_decorator.png")); //$NON-NLS-1$
+
         BULLET_GREEN_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/bullet_green.png")); //$NON-NLS-1$
         BULLET_YELLOW_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/bullet_yellow.png")); //$NON-NLS-1$
 
         BULLET_GREEN_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/bullet_green.png")); //$NON-NLS-1$
         BULLET_YELLOW_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/bullet_yellow.png")); //$NON-NLS-1$
 
diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser2/image/ChangedResourceImageDecorationRule.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser2/image/ChangedResourceImageDecorationRule.java
new file mode 100644 (file)
index 0000000..586387b
--- /dev/null
@@ -0,0 +1,43 @@
+package org.simantics.modeling.ui.modelBrowser2.image;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IDecoration;
+import org.simantics.browsing.ui.content.ImageDecorator;
+import org.simantics.browsing.ui.model.imagedecorators.ImageDecorationRule;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.modeling.ModelingResources;
+import org.simantics.modeling.ui.Activator;
+import org.simantics.utils.ui.gfx.DecorationOverlayIcon;
+
+public class ChangedResourceImageDecorationRule implements ImageDecorationRule {
+
+    private ImageDecorator CHANGED_DECORATOR = new ImageDecorator() {
+        @Override
+        public <Image> 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;
+    }
+
+}
index ea960c1d0de2fe97dfae468331b0521f69219ccd..4a4d97a18a2b254f0be58c2a928483dcecd234c6 100644 (file)
@@ -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.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;
 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);
     }
 
         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);
+            }
+        });
+    }
+    
 }
 }
index dd547ffe382bf7bc1dd47c8f31bd3df2c62f6d4e..3f8ffb15b94d81282f275b7edd7246d78c29e948 100644 (file)
@@ -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.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;
 
 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);
                        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);
                        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) {
                }
                
                for (Resource r : ids) {