]> gerrit.simantics Code Review - simantics/interop.git/commitdiff
StructuralBrowser Interop contribution
authorluukkainen <luukkainen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 27 Apr 2011 12:17:07 +0000 (12:17 +0000)
committerMarko Luukkainen <marko.luukkainen@vtt.fi>
Thu, 2 Feb 2017 09:22:14 +0000 (11:22 +0200)
git-svn-id: https://www.simantics.org/svn/simantics/interoperability/trunk@20590 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.interop/META-INF/MANIFEST.MF
org.simantics.interop/adapters.xml [new file with mode: 0644]
org.simantics.interop/graph.tg
org.simantics.interop/graph/Interop.pgraph
org.simantics.interop/plugin.xml
org.simantics.interop/src/org/simantics/interop/browsing/InteropChildRule.java [new file with mode: 0644]
org.simantics.interop/src/org/simantics/interop/handlers/Contributor2.java
org.simantics.interop/src/org/simantics/interop/stubs/InteropResource.java

index 003303034e6655b122fc786e778bd39bfe037657..d11a18602a47a58c8d61a9bc76d94cc722515278 100644 (file)
@@ -15,7 +15,9 @@ Require-Bundle: org.eclipse.ui,
  org.simantics.ui;bundle-version="1.0.0",
  org.simantics.layer0.utils;bundle-version="0.8.0",
  org.simantics.structural.ui;bundle-version="1.0.0",
- org.simantics.layer0;bundle-version="1.0.0"
+ org.simantics.layer0;bundle-version="1.0.0",
+ org.simantics.diagram.ontology;bundle-version="1.1.1",
+ org.simantics.browsing.ui.model;bundle-version="1.0.0"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-ActivationPolicy: lazy
 Export-Package: org.simantics.interop.issues,
diff --git a/org.simantics.interop/adapters.xml b/org.simantics.interop/adapters.xml
new file mode 100644 (file)
index 0000000..9de4ffa
--- /dev/null
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>\r\r
+
+<adapters>\r
+\r      <target interface="org.simantics.browsing.ui.model.children.ChildRule">\r       <baseType uri="http://www.simantics.org/Viewpoint-1.0/ChildRule" />\r       <resource\r           uri="http://www.simantics.org/Interop-1.0/InteropBrowseContext/InteropChildRule"\r           class="org.simantics.interop.browsing.InteropChildRule"/>\r   </target>\r\r     \r\r
+</adapters>
\ No newline at end of file
index 537da89056c25c010df240e87acf72edd63af6d3..1c5f136f4ff94200865c29ddd267a7dfcbba22ec 100644 (file)
Binary files a/org.simantics.interop/graph.tg and b/org.simantics.interop/graph.tg differ
index ae2fd712048624e91f8dbf2b3ed78d29aa9a3ce0..e69b289f839ffca69c3bdb37fa8de5b1a0e5819e 100644 (file)
@@ -1,6 +1,10 @@
 L0 = <http://www.simantics.org/Layer0-1.0>\r
 PROJ = <http://www.simantics.org/Project-1.0>\r
 \r
+MOD = <http://www.simantics.org/Modeling-1.0>\r
+VP = <http://www.simantics.org/Viewpoint-1.0>\r
+\r
+\r
     \r
 INTEROP = <http://www.simantics.org/Interop-1.0> : L0.Ontology\r
     L0.HasResourceClass "org.simantics.interop.stubs.InteropResource"\r
@@ -13,3 +17,19 @@ INTEROP.ImportLibrary <T L0.Library
 \r
 INTEROP.HasSource <R L0.IsWeaklyRelatedTo\r
     L0.InverseOf INTEROP.HasDestination <R L0.IsWeaklyRelatedTo\r
+    \r
+IBC = INTEROP.InteropBrowseContext : VP.BrowseContext\r
+    VP.BrowseContext.IsIncludedIn MOD.ModelingBrowseContext\r
+\r
+INTEROP.INodeType <T VP.NodeType\r
+   @L0.assert VP.HasContentType "org.simantics.modeling.ui.modelBrowser.model.INode"\r
+\r
+IBC.InteropNode : INTEROP.INodeType\r
+IBC.InteropChildRule : VP.ChildRule\r
+  \r
+IBC\r
+    VP.BrowseContext.HasChildContribution _ : VP.ChildContribution\r
+        VP.ChildContribution.HasParentNodeType PROJ.Project\r
+        VP.ChildContribution.HasChildNodeType IBC.InteropNode\r
+        VP.ChildContribution.HasRule IBC.InteropChildRule\r
+        \r
index e558611122762e61ef5ed980c1e66a7bf199492f..74fdd2de60b78f3fec91d83387c35de16513b963 100644 (file)
@@ -6,14 +6,19 @@
       <binding\r
             browseContext="http://www.apros.fi/Apros-6.0/AprosModelBrowser">\r
          <implementation\r
-               class="org.simantics.interop.handlers.Contributor1"\r
+               class="org.simantics.interop.handlers.Contributor2"\r
                preference="1.0">\r
          </implementation>\r
+      </binding>\r
+      <!--\r
+      <binding\r
+            browseContext="http://www.simantics.org/Project-1.0/ProjectBrowseContext">\r
          <implementation\r
                class="org.simantics.interop.handlers.Contributor2"\r
-               preference="1.0">\r
+               preference="-1.0">\r
          </implementation>\r
       </binding>\r
+      -->\r
    </extension>\r
    <extension\r
          point="org.simantics.browsing.ui.common.evaluatorBinding">\r
                preference="1">\r
          </implementation>\r
       </binding>\r
+\r
+      <binding\r
+            browseContext="http://www.simantics.org/Project-1.0/ProjectBrowseContext">\r
+         <implementation\r
+               class="org.simantics.interop.handlers.EvaluatorFactory1"\r
+               preference="1">\r
+         </implementation>\r
+      </binding>\r
+     \r
    </extension>\r
    <extension\r
          point="org.eclipse.ui.views">\r
diff --git a/org.simantics.interop/src/org/simantics/interop/browsing/InteropChildRule.java b/org.simantics.interop/src/org/simantics/interop/browsing/InteropChildRule.java
new file mode 100644 (file)
index 0000000..3b6d25e
--- /dev/null
@@ -0,0 +1,39 @@
+package org.simantics.interop.browsing;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.Collections;\r
+import java.util.List;\r
+\r
+import org.simantics.browsing.ui.model.children.ChildRule;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.interop.stubs.InteropResource;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ui.modelBrowser.model.INode;\r
+\r
+public class InteropChildRule implements ChildRule{\r
+       @Override\r
+    public boolean isCompatible(Class<?> contentType) {\r
+        return Resource.class.isAssignableFrom(contentType);\r
+    }\r
+    @Override\r
+    public Collection<?> getChildren(ReadGraph graph, Object parent_)\r
+            throws DatabaseException {\r
+        Resource parent = (Resource)parent_;\r
+\r
+               \r
+               List<INode> nodes = new ArrayList<INode>();\r
+               nodes.add(new ImportNode2(parent));\r
+               return nodes;\r
+               \r
+\r
+    }\r
+    @Override\r
+    public Collection<?> getParents(ReadGraph graph, Object child)\r
+            throws DatabaseException {\r
+        return Collections.emptyList(); // It is not necessary to support this\r
+    }\r
+\r
+}\r
index 2826886eaf2940dc34020bdb3792f0f8f81196e5..cc9f838af1a4956e4e8f1887217a78867304da14 100644 (file)
@@ -22,7 +22,7 @@ public class Contributor2 extends ViewpointContributor<Resource> {
        public Collection<?> getContribution(ReadGraph graph, Resource input)\r
                        throws DatabaseException {\r
                Collection<INode> nodes = new ArrayList<INode>();\r
-               System.out.println("Contributor 1 " + input + " " + GraphUtils.getReadableName(graph, input));\r
+               System.out.println("Contributor 2 " + input + " " + GraphUtils.getReadableName(graph, input));\r
                nodes.add(new ImportNode2(input));\r
                return nodes;\r
        }\r
index de2e123892720e91f4017bc99166798a0b2e7ca6..fd1d7ed5d776fb11746743018b864f02bd7962fd 100644 (file)
@@ -11,15 +11,23 @@ public class InteropResource {
     public final Resource HasDestination;\r
     public final Resource HasImportData;\r
     public final Resource HasSource;\r
+    public final Resource INodeType;\r
     public final Resource ImportDataOf;\r
     public final Resource ImportLibrary;\r
+    public final Resource InteropBrowseContext;\r
+    public final Resource InteropBrowseContext_InteropChildRule;\r
+    public final Resource InteropBrowseContext_InteropNode;\r
         \r
     public static class URIs {\r
         public static final String HasDestination = "http://www.simantics.org/Interop-1.0/HasDestination";\r
         public static final String HasImportData = "http://www.simantics.org/Interop-1.0/HasImportData";\r
         public static final String HasSource = "http://www.simantics.org/Interop-1.0/HasSource";\r
+        public static final String INodeType = "http://www.simantics.org/Interop-1.0/INodeType";\r
         public static final String ImportDataOf = "http://www.simantics.org/Interop-1.0/ImportDataOf";\r
         public static final String ImportLibrary = "http://www.simantics.org/Interop-1.0/ImportLibrary";\r
+        public static final String InteropBrowseContext = "http://www.simantics.org/Interop-1.0/InteropBrowseContext";\r
+        public static final String InteropBrowseContext_InteropChildRule = "http://www.simantics.org/Interop-1.0/InteropBrowseContext/InteropChildRule";\r
+        public static final String InteropBrowseContext_InteropNode = "http://www.simantics.org/Interop-1.0/InteropBrowseContext/InteropNode";\r
     }\r
     \r
     public static Resource getResourceOrNull(ReadGraph graph, String uri) {\r
@@ -35,8 +43,12 @@ public class InteropResource {
         HasDestination = getResourceOrNull(graph, URIs.HasDestination);\r
         HasImportData = getResourceOrNull(graph, URIs.HasImportData);\r
         HasSource = getResourceOrNull(graph, URIs.HasSource);\r
+        INodeType = getResourceOrNull(graph, URIs.INodeType);\r
         ImportDataOf = getResourceOrNull(graph, URIs.ImportDataOf);\r
         ImportLibrary = getResourceOrNull(graph, URIs.ImportLibrary);\r
+        InteropBrowseContext = getResourceOrNull(graph, URIs.InteropBrowseContext);\r
+        InteropBrowseContext_InteropChildRule = getResourceOrNull(graph, URIs.InteropBrowseContext_InteropChildRule);\r
+        InteropBrowseContext_InteropNode = getResourceOrNull(graph, URIs.InteropBrowseContext_InteropNode);\r
     }\r
     \r
     public static InteropResource getInstance(ReadGraph graph) {\r