]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Sync git svn branch with SVN repository r33382.
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Wed, 9 Nov 2016 22:22:14 +0000 (00:22 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Wed, 9 Nov 2016 22:22:14 +0000 (00:22 +0200)
refs #6803
[PRIVATE-12714]

bundles/org.simantics.annotation.ontology/graph.tg
bundles/org.simantics.annotation.ontology/graph/Annotation.pgraph
bundles/org.simantics.annotation.ontology/src/org/simantics/annotation/ontology/AnnotationResource.java
bundles/org.simantics.annotation.ui/src/org/simantics/annotation/ui/AnnotationUtils.java

index 2a28024a302837e5e154a0d77475359f2025c8d5..2898f00845cb681e793447b895084b4d4774174d 100644 (file)
Binary files a/bundles/org.simantics.annotation.ontology/graph.tg and b/bundles/org.simantics.annotation.ontology/graph.tg differ
index 09b40fcc2895b32895602964dd1eeaf8f50557ec..2a9827acb526ee5909fbfd7d16c13f146fdbd243 100644 (file)
@@ -20,6 +20,10 @@ ANNO.Functions : L0.Library
 
 ANNO.AnnotationType <T L0.Type : MOD.TypeWithChangeInformation
     L0.HasDescription "An entity consisting of arbitrary properties."
+    >-- ANNO.AnnotationType.systemAnnotation ==> "Boolean" <R L0.HasProperty : L0.FunctionalRelation : SEL.GenericParameterType
+        L0.HasLabel "Is System Annotation?"
+        L0.HasDescription "If true, this annotation type and its instances should be hidden from user interfaces while still allowing programmatic use."
+    @L0.assert ANNO.AnnotationType.systemAnnotation true
 
 ANNO.Annotation <T L0.Value : ANNO.AnnotationType : MOD.TypeWithChangeInformation
     L0.HasDescription "Abstract base class for annotation object types."
index f2fb52856b28a103ac50ea953e6ab3ed57560135..a9b49aca4db263795087bf06c2958b5d2fa086e1 100644 (file)
@@ -25,6 +25,8 @@ public class AnnotationResource {
     @Deprecated public final Resource AnnotationTypeLibrary;\r
     @Deprecated public final Resource AnnotationTypeLibraryUI;\r
     @Deprecated public final Resource AnnotationTypeUI;\r
+    public final Resource AnnotationType_systemAnnotation;\r
+    public final Resource AnnotationType_systemAnnotation_Inverse;\r
     @Deprecated public final Resource AnnotationUI;\r
     public final Resource Annotation_HasEntry;\r
     public final Resource Annotation_HasEntry_Inverse;\r
@@ -84,6 +86,8 @@ public class AnnotationResource {
         @Deprecated public static final String AnnotationTypeLibrary = "http://www.simantics.org/Annotation-1.0/AnnotationTypeLibrary";\r
         @Deprecated public static final String AnnotationTypeLibraryUI = "http://www.simantics.org/Annotation-1.0/AnnotationTypeLibraryUI";\r
         @Deprecated public static final String AnnotationTypeUI = "http://www.simantics.org/Annotation-1.0/AnnotationTypeUI";\r
+        public static final String AnnotationType_systemAnnotation = "http://www.simantics.org/Annotation-1.0/AnnotationType/systemAnnotation";\r
+        public static final String AnnotationType_systemAnnotation_Inverse = "http://www.simantics.org/Annotation-1.0/AnnotationType/systemAnnotation/Inverse";\r
         @Deprecated public static final String AnnotationUI = "http://www.simantics.org/Annotation-1.0/AnnotationUI";\r
         public static final String Annotation_HasEntry = "http://www.simantics.org/Annotation-1.0/Annotation/HasEntry";\r
         public static final String Annotation_HasEntry_Inverse = "http://www.simantics.org/Annotation-1.0/Annotation/HasEntry/Inverse";\r
@@ -153,6 +157,8 @@ public class AnnotationResource {
         AnnotationTypeLibrary = getResourceOrNull(graph, URIs.AnnotationTypeLibrary);\r
         AnnotationTypeLibraryUI = getResourceOrNull(graph, URIs.AnnotationTypeLibraryUI);\r
         AnnotationTypeUI = getResourceOrNull(graph, URIs.AnnotationTypeUI);\r
+        AnnotationType_systemAnnotation = getResourceOrNull(graph, URIs.AnnotationType_systemAnnotation);\r
+        AnnotationType_systemAnnotation_Inverse = getResourceOrNull(graph, URIs.AnnotationType_systemAnnotation_Inverse);\r
         AnnotationUI = getResourceOrNull(graph, URIs.AnnotationUI);\r
         Annotation_HasEntry = getResourceOrNull(graph, URIs.Annotation_HasEntry);\r
         Annotation_HasEntry_Inverse = getResourceOrNull(graph, URIs.Annotation_HasEntry_Inverse);\r
index 3bc50dae9b5fed14f871136a05f4f425d34e7fb9..2abd2d6706d90d28e3f97ff49053197312dd16c7 100644 (file)
@@ -101,9 +101,9 @@ public class AnnotationUtils {
                return Pair.make(property, type);\r
        }\r
 \r
-       public static void newAnnotation(ReadGraph graph, final Resource parent, Resource model) throws DatabaseException {\r
+       public static void newAnnotation(ReadGraph graph, Resource parent, Resource model) throws DatabaseException {\r
 \r
-        final Map<Resource, Pair<String, ImageDescriptor>> map = new HashMap<Resource, Pair<String,ImageDescriptor>>();\r
+        Map<Resource, Pair<String, ImageDescriptor>> map = new HashMap<>();\r
         findAnnotationTypes(graph, model, map);\r
         findAnnotations(graph, model, map);\r
         queryUserSelectedAnnotationType(map, selected -> {\r
@@ -130,9 +130,9 @@ public class AnnotationUtils {
        }\r
        }\r
        \r
-       public static void newAnnotation(ReadGraph graph, final Variable position, Resource model) throws DatabaseException {\r
+       public static void newAnnotation(ReadGraph graph, Variable position, Resource model) throws DatabaseException {\r
 \r
-        final Map<Resource, Pair<String, ImageDescriptor>> map = new HashMap<Resource, Pair<String,ImageDescriptor>>();\r
+        Map<Resource, Pair<String, ImageDescriptor>> map = new HashMap<>();\r
         findAnnotationTypes(graph, model, map);\r
         findAnnotations(graph, model, map);\r
         queryUserSelectedAnnotationType(map, selected -> {\r
@@ -163,7 +163,7 @@ public class AnnotationUtils {
         * @param model\r
         * @throws DatabaseException\r
         */\r
-       public static void newAnnotation(final Resource parent, final Resource model) throws DatabaseException {\r
+       public static void newAnnotation(Resource parent, Resource model) throws DatabaseException {\r
                if (model == null)\r
                        return;\r
                Simantics.getSession().syncRequest(new ReadRequest() {\r
@@ -174,7 +174,7 @@ public class AnnotationUtils {
                });\r
        }\r
 \r
-       public static void newAnnotation(final Resource parent) throws DatabaseException {\r
+       public static void newAnnotation(Resource parent) throws DatabaseException {\r
         Simantics.getSession().syncRequest(new ReadRequest() {\r
             @Override\r
             public void run(ReadGraph graph) throws DatabaseException {\r
@@ -185,7 +185,7 @@ public class AnnotationUtils {
         });\r
        }\r
 \r
-       public static void newAnnotation(final Variable position) throws DatabaseException {\r
+       public static void newAnnotation(Variable position) throws DatabaseException {\r
         Simantics.getSession().syncRequest(new ReadRequest() {\r
             @Override\r
             public void run(ReadGraph graph) throws DatabaseException {\r
@@ -196,14 +196,13 @@ public class AnnotationUtils {
         });\r
        }\r
 \r
-       public static void newAnnotationInstance(final Resource parent, final Resource model) throws DatabaseException {\r
+       public static void newAnnotationInstance(Resource parent, Resource model) throws DatabaseException {\r
         if (model == null)\r
             return;\r
         Simantics.getSession().syncRequest(new ReadRequest() {\r
             @Override\r
             public void run(ReadGraph graph) throws DatabaseException {\r
-                \r
-                final Map<Resource, Pair<String, ImageDescriptor>> map = new HashMap<Resource, Pair<String,ImageDescriptor>>();\r
+                Map<Resource, Pair<String, ImageDescriptor>> map = new HashMap<>();\r
                 findAnnotationTypes(graph, model, map);\r
                 queryUserSelectedAnnotationType(map, selected -> {\r
                     Simantics.getSession().async(new WriteRequest() {\r
@@ -240,6 +239,11 @@ public class AnnotationUtils {
                        if (graph.hasStatement(_res, L0.Abstract))\r
                                continue;\r
 \r
+                       // Don't allow instantiation of non-user-selectable annotation types\r
+                       Boolean userSelectable = graph.getPossibleRelatedValue2(_res, ANNO.AnnotationType_systemAnnotation, Bindings.BOOLEAN);\r
+                       if (Boolean.TRUE.equals(userSelectable))\r
+                               continue;\r
+\r
                        Resource res = graph.getPossibleObject(_res, L0.HasRange_Inverse);\r
                        if(res == null) {\r
                                \r
@@ -265,7 +269,7 @@ public class AnnotationUtils {
 \r
                                name = name + " - " + URIStringUtils.unescape(parentURI);\r
 \r
-                               map.put(_res, new Pair<String, ImageDescriptor>(name, descriptor));\r
+                               map.put(_res, Pair.make(name, descriptor));\r
                                \r
                        } else {\r
                                \r
@@ -291,7 +295,7 @@ public class AnnotationUtils {
 \r
                                name = name + " - " + URIStringUtils.unescape(parentURI);\r
 \r
-                               map.put(_res, new Pair<String, ImageDescriptor>(name, descriptor));\r
+                               map.put(_res, Pair.make(name, descriptor));\r
                        \r
                        }\r
                        \r
@@ -311,8 +315,6 @@ public class AnnotationUtils {
         ImageDescriptor descriptor = graph.adapt(ANNO.Images_Annotation, ImageDescriptor.class);\r
 \r
         for(Resource _res : query.find(graph, model)) {\r
-            // Don't allow instantiation of abstract annotation types.\r
-\r
             String name = graph.getPossibleRelatedValue(_res, L0.HasName, Bindings.STRING);\r
             if (name == null)\r
                 continue;\r
@@ -334,8 +336,13 @@ public class AnnotationUtils {
 \r
             Resource type = graph.getPossibleType(_res, ANNO.Annotation);\r
             if(type != null) {\r
-               Resource relation = graph.getPossibleObject(type, L0.HasRange_Inverse);\r
-               if(relation != null) {\r
+                // Don't list instances of non-user-selectable annotation types\r
+                Boolean userSelectable = graph.getPossibleRelatedValue2(type, ANNO.AnnotationType_systemAnnotation, Bindings.BOOLEAN);\r
+                if (Boolean.TRUE.equals(userSelectable))\r
+                    continue;\r
+\r
+                Resource relation = graph.getPossibleObject(type, L0.HasRange_Inverse);\r
+                if(relation != null) {\r
                     String rName = graph.getPossibleRelatedValue(relation, L0.HasName, Bindings.STRING);\r
                     if(rName != null) {\r
                        name = name + " - " + rName;\r
@@ -345,7 +352,7 @@ public class AnnotationUtils {
             \r
             name = name + " - " + URIStringUtils.unescape(parentURI);\r
             \r
-            map.put(_res, new Pair<String, ImageDescriptor>(name, descriptor));\r
+            map.put(_res, Pair.make(name, descriptor));\r
             \r
         }\r
 \r
@@ -380,7 +387,7 @@ public class AnnotationUtils {
                        @Override\r
                        public Map<Resource, Pair<String, ImageDescriptor>> perform(ReadGraph graph) throws DatabaseException {\r
 \r
-                               Map<Resource, Pair<String, ImageDescriptor>> result = new HashMap<Resource, Pair<String,ImageDescriptor>>();\r
+                               Map<Resource, Pair<String, ImageDescriptor>> result = new HashMap<>();\r
 \r
                                Layer0 L0 = Layer0.getInstance(graph);\r
                                AnnotationResource ANNO = AnnotationResource.getInstance(graph);\r
@@ -399,7 +406,7 @@ public class AnnotationUtils {
                                        if(!path.startsWith(modelURI)) continue;\r
                                        String suffix = URIStringUtils.unescape(path.substring(modelPos));\r
                                        if(suffix.startsWith("/")) suffix = suffix.substring(1);\r
-                                       result.put(lib, new Pair<String, ImageDescriptor>(suffix, descriptor));\r
+                                       result.put(lib, Pair.make(suffix, descriptor));\r
 \r
                                }\r
 \r
@@ -532,48 +539,40 @@ public class AnnotationUtils {
         * @param selectionCallback\r
         */\r
        public static void queryUserSelectedAnnotationType(\r
-                       final Map<Resource, Pair<String, ImageDescriptor>> map,\r
-                       final Consumer<Resource> selectionCallback)\r
+                       Map<Resource, Pair<String, ImageDescriptor>> map,\r
+                       Consumer<Resource> selectionCallback)\r
        {\r
-               Display.getDefault().asyncExec(new Runnable() {\r
-                       @Override\r
-                       public void run() {\r
-                               Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();\r
-                               ResourceSelectionDialog3<Resource> dialog = new ResourceSelectionDialog3<Resource>(shell, map, "Select annotation type from list") {\r
-                                       @Override\r
-                                       protected IDialogSettings getBaseDialogSettings() {\r
-                                               return Activator.getDefault().getDialogSettings();\r
-                                       }\r
-                               };\r
-                               if (dialog.open() == Window.OK) {\r
-                                       Object[] result = dialog.getResult();\r
-                                       if (result != null && result.length == 1) {\r
-                                               final Resource res = (Resource)result[0];\r
-                                               selectionCallback.accept(res);\r
-                                       }\r
+               Display.getDefault().asyncExec(() -> {\r
+                       Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();\r
+                       ResourceSelectionDialog3<Resource> dialog = new ResourceSelectionDialog3<Resource>(shell, map, "Select annotation type from list") {\r
+                               @Override\r
+                               protected IDialogSettings getBaseDialogSettings() {\r
+                                       return Activator.getDefault().getDialogSettings();\r
+                               }\r
+                       };\r
+                       if (dialog.open() == Window.OK) {\r
+                               Object[] result = dialog.getResult();\r
+                               if (result != null && result.length == 1) {\r
+                                       selectionCallback.accept((Resource) result[0]);\r
                                }\r
                        }\r
                });\r
        }\r
 \r
        public static void queryLibrary(\r
-                       final Map<Resource, Pair<String, ImageDescriptor>> map,\r
-                       final Consumer<Pair<Resource,String>> selectionCallback)\r
+                       Map<Resource, Pair<String, ImageDescriptor>> map,\r
+                       Consumer<Pair<Resource,String>> selectionCallback)\r
        {\r
-               Display.getDefault().asyncExec(new Runnable() {\r
-                       @Override\r
-                       public void run() {\r
-                               Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();\r
-                               SaveAnnotationDialog page = new SaveAnnotationDialog(shell, map, "Select library");\r
-                               if (page.open() == Window.OK) {\r
-                                       Object[] result = page.getResult();\r
-                                       if (result != null && result.length == 1) {\r
-                                               final Resource res = (Resource)result[0];\r
-                                               selectionCallback.accept(Pair.make(res, page.getName()));\r
-                                       }\r
+               Display.getDefault().asyncExec(() -> {\r
+                       Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();\r
+                       SaveAnnotationDialog page = new SaveAnnotationDialog(shell, map, "Select library");\r
+                       if (page.open() == Window.OK) {\r
+                               Object[] result = page.getResult();\r
+                               if (result != null && result.length == 1) {\r
+                                       selectionCallback.accept(Pair.make((Resource)result[0], page.getName()));\r
                                }\r
                        }\r
                });\r
        }\r
        \r
-}
\ No newline at end of file
+}\r