]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Utility for creating NodeContext with NodeType from SCL 86/2386/3
authorjsimomaa <jani.simomaa@gmail.com>
Tue, 30 Oct 2018 09:05:32 +0000 (11:05 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Tue, 30 Oct 2018 09:44:46 +0000 (09:44 +0000)
gitlab #170

Change-Id: I88b163f6ca30d5dfebc42ff3aa590a7426614e48

bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/browsecontexts/BrowseContexts.java
bundles/org.simantics.modeling.ui/scl/Simantics/Testing/BrowseContext.scl

index 760f866e3d463d167b2e62a24d30a2dd2705641c..d8d02e014738f52044e7f20e9df08dbfba02c4d7 100644 (file)
@@ -5,10 +5,11 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
 
-import org.simantics.browsing.ui.BuiltinKeys;
 import org.simantics.browsing.ui.NodeContext;
 import org.simantics.browsing.ui.common.NodeContextBuilder;
 import org.simantics.browsing.ui.model.actions.ActionBrowseContext;
+import org.simantics.browsing.ui.model.nodetypes.EntityNodeType;
+import org.simantics.browsing.ui.model.nodetypes.NodeType;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.RequestProcessor;
 import org.simantics.db.Resource;
@@ -69,7 +70,17 @@ public final class BrowseContexts {
        }
        
        public static NodeContext getNodeContextForResource(Resource resource) {
-           return NodeContextBuilder.buildWithData(BuiltinKeys.INPUT, resource);
+               return NodeContextBuilder.buildWithInput(resource);
+       }
+
+       public static NodeContext getNodeContextWithTypeForResource(ReadGraph graph, Resource resource) {
+               try {
+                       return NodeContextBuilder.buildWithData(
+                                       NodeType.KEY_SEQUENCE,
+                                       new Object[] { resource, EntityNodeType.getNodeTypeFor(graph, resource) });
+               } catch (DatabaseException e) {
+                       return NodeContextBuilder.buildWithInput(resource);
+               }
        }
 
        public static class URIsToBrowseContext extends UnaryRead<List<String>, BrowseContext> {
index 436557f31e613d10760f593a8b7288b5b64ef518..106d93bb322410cbc6e2d2d4728c53174bda04e2 100644 (file)
@@ -115,6 +115,7 @@ importJava "org.simantics.browsing.ui.content.Labeler$Modifier" where
 importJava "org.simantics.browsing.ui.model.browsecontexts.BrowseContexts" where
     toBrowseContextG :: Vector String -> <ReadGraph> BrowseContext
     getNodeContextForResource :: Resource -> <Proc> NodeContext
+    getNodeContextWithTypeForResource :: Resource -> <Proc, ReadGraph> NodeContext
 
 """
 Creates a new BrowseContext for the given Collection of Resources.