]> gerrit.simantics Code Review - simantics/interop.git/commitdiff
Moved to SPM.
authorluukkainen <luukkainen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 24 Aug 2010 12:54:28 +0000 (12:54 +0000)
committerMarko Luukkainen <marko.luukkainen@vtt.fi>
Thu, 2 Feb 2017 09:22:11 +0000 (11:22 +0200)
Import is now done to project, model generator generates a model, not just a diagram.
Added some rules to handle current Comos database correctly.

git-svn-id: https://www.simantics.org/svn/simantics/interoperability/trunk@17511 ac1ea38d-2e2b-0410-8846-a27921b304fc

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

index 784434a80d335df0024fc02975dbd836ae12a4c0..3942c1f6c8697c6cf51622bc0b56bab04615cce3 100644 (file)
          version="0.0.0"\r
          unpack="false"/>\r
 \r
-   <plugin\r
-         id="org.simantics.threadlog"\r
-         download-size="0"\r
-         install-size="0"\r
-         version="0.0.0"\r
-         unpack="false"/>\r
-\r
    <plugin\r
          id="org.simantics.interop.apros"\r
          download-size="0"\r
index 4bf9b0a14f351c09f5962c2b6ae3663ced683974..d9b39742bc7f243052dfb492452eb266c5af8734 100644 (file)
@@ -5,6 +5,11 @@
        <projects>\r
        </projects>\r
        <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.simantics.graph.builder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
                <buildCommand>\r
                        <name>org.eclipse.jdt.core.javabuilder</name>\r
                        <arguments>\r
@@ -24,5 +29,6 @@
        <natures>\r
                <nature>org.eclipse.pde.PluginNature</nature>\r
                <nature>org.eclipse.jdt.core.javanature</nature>\r
+               <nature>org.simantics.graph.nature</nature>\r
        </natures>\r
 </projectDescription>\r
index bf52f70c9cac85133133690434836322b5e14a87..6171d9ef0654edc5048d995fb3c1a304d1f58b32 100644 (file)
@@ -14,6 +14,7 @@ Require-Bundle: org.eclipse.ui,
  org.simantics.modeling.ui;bundle-version="1.0.0",
  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.structural.ui;bundle-version="1.0.0",
+ org.simantics.layer0;bundle-version="1.0.0"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-ActivationPolicy: lazy
diff --git a/org.simantics.interop/graph.tg b/org.simantics.interop/graph.tg
new file mode 100644 (file)
index 0000000..ffc5ef7
Binary files /dev/null and b/org.simantics.interop/graph.tg differ
diff --git a/org.simantics.interop/graph/Interop.pgraph b/org.simantics.interop/graph/Interop.pgraph
new file mode 100644 (file)
index 0000000..074ac7a
--- /dev/null
@@ -0,0 +1,13 @@
+L0 = <http://www.simantics.org/Layer0-1.0>\r
+PROJ = <http://www.simantics.org/Project-1.0>\r
+\r
+    \r
+INTEROP = <http://www.simantics.org/Interop-1.0> : L0.Ontology\r
+    L0.HasResourceClass "org.simantics.interop.stubs.InteropResource"\r
+    @L0.new\r
+    \r
+INTEROP.InteropFeature : PROJ.Feature\r
+   L0.HasDescription "Interop feature."\r
+   \r
+   \r
+INTEROP.ImportLibrary <T L0.Library
\ No newline at end of file
index 250fcbc19307d4e1d650f6faf007f1173cd41cfb..ba3f9841dadd9b0a5fffd20f323db22e1b1b7877 100644 (file)
@@ -9,6 +9,10 @@
                class="org.simantics.interop.handlers.Contributor1"\r
                preference="1.0">\r
          </implementation>\r
+         <implementation\r
+               class="org.simantics.interop.handlers.Contributor2"\r
+               preference="1.0">\r
+         </implementation>\r
       </binding>\r
    </extension>\r
    <extension\r
             restorable="true">\r
       </view>\r
    </extension>\r
+   <extension\r
+         point="org.eclipse.ui.importWizards">\r
+      <category\r
+            id="org.simantics.interop.category"\r
+            name="Interoperability">\r
+      </category>\r
+   </extension>\r
 \r
 </plugin>\r
diff --git a/org.simantics.interop/src/org/simantics/interop/browsing/ImportNode2.java b/org.simantics.interop/src/org/simantics/interop/browsing/ImportNode2.java
new file mode 100644 (file)
index 0000000..38fb562
--- /dev/null
@@ -0,0 +1,115 @@
+package org.simantics.interop.browsing;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.List;\r
+\r
+import org.eclipse.jface.resource.ImageDescriptor;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.simantics.browsing.ui.content.Labeler.Modifier;\r
+import org.simantics.db.Builtins;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.Session;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.interop.Activator;\r
+import org.simantics.interop.stubs.InteropResource;\r
+import org.simantics.modeling.ui.modelBrowser.model.INode;\r
+\r
+public class ImportNode2 implements INode {\r
+       \r
+       private Resource project;\r
+       \r
+       public ImportNode2(Resource project) {\r
+               this.project = project;\r
+       }\r
+       \r
+       @Override\r
+       public Object getAdapter(Class adapter) {\r
+               return null;\r
+       }\r
+       \r
+       @Override\r
+       public int getCategory(ReadGraph graph) throws DatabaseException {\r
+               return 0;\r
+       }\r
+       \r
+       \r
+       @Override\r
+       public ImageDescriptor getImage(ReadGraph graph) throws DatabaseException {\r
+               return Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/silk/database_connect.png");\r
+       }\r
+       \r
+       @Override\r
+       public String getLabel(ReadGraph graph) throws DatabaseException {\r
+               return "Imports";\r
+       }\r
+       \r
+       @Override\r
+       public Modifier getModifier(Session session, String columnId) {\r
+               // TODO Auto-generated method stub\r
+               return null;\r
+       }\r
+       \r
+       @Override\r
+       public void handleDelete(WriteGraph graph) throws DatabaseException {\r
+               // TODO Auto-generated method stub\r
+               \r
+       }\r
+       \r
+       @Override\r
+       public void handleDrop(Session session, ISelection selection) {\r
+               // TODO Auto-generated method stub\r
+               \r
+       }\r
+       \r
+       @Override\r
+       public boolean hasChildren(ReadGraph graph) throws DatabaseException {\r
+               return getChildren(graph).size() > 0;\r
+       }\r
+       \r
+       @Override\r
+       public Collection<?> getChildren(ReadGraph graph) throws DatabaseException {\r
+               List<INode> nodes = new ArrayList<INode>();\r
+               Builtins b = graph.getBuiltins();\r
+               InteropResource i = InteropResource.getInstance(graph);\r
+//             Collection<Resource> models = graph.getObjects(project, b.ConsistsOf);\r
+//             for (Resource m : models) {\r
+//                     Collection<Resource> objs = graph.getObjects(m, b.ConsistsOf);\r
+//                     for (Resource o : objs) {\r
+//                             if (graph.isInstanceOf(o, i.ImportLibrary)) {\r
+//                                     INode node = graph.adapt(o, INode.class);\r
+//                                     nodes.add(node);\r
+//                             }\r
+//                     }\r
+//             }\r
+               Collection<Resource> objs = graph.getObjects(project, b.ConsistsOf);\r
+               for (Resource o : objs) {\r
+                       if (graph.isInstanceOf(o, i.ImportLibrary)) {\r
+                               INode node = graph.adapt(o, INode.class);\r
+                               nodes.add(node);\r
+                       }\r
+               }\r
+               return nodes;\r
+               \r
+//             ComosResource c = ComosResource.getInstance(graph);\r
+//             Collection<Resource> models = graph.getObjects(project, b.ConsistsOf);\r
+//             Collection<ComosGraphNode> comosImports = new ArrayList<ComosGraphNode>();\r
+//             for (Resource m : models) {\r
+//                     Collection<Resource> objs = graph.getObjects(m, b.ConsistsOf);\r
+//                     for (Resource o : objs) {\r
+//                             if (graph.isInstanceOf(o, c.ComosImportLibrary)) {\r
+//                                     String icon_db_path = ComosGraphTools.getIconPath(o, graph);\r
+//                                     if (icon_db_path == null)\r
+//                                             continue;\r
+//                                     ComosIconReader iconReader = new ComosIconReader(icon_db_path);\r
+//                                     comosImports.add(new ComosGraphNode(o, iconReader));\r
+//                             }\r
+//                     }\r
+//             }\r
+//             return comosImports;\r
+       }\r
+       \r
+\r
+}\r
diff --git a/org.simantics.interop/src/org/simantics/interop/handlers/Contributor2.java b/org.simantics.interop/src/org/simantics/interop/handlers/Contributor2.java
new file mode 100644 (file)
index 0000000..2826886
--- /dev/null
@@ -0,0 +1,35 @@
+package org.simantics.interop.handlers;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.interop.browsing.ImportNode2;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.modeling.ui.modelBrowser.model.INode;\r
+\r
+\r
+public class Contributor2 extends ViewpointContributor<Resource> {\r
+\r
+       \r
+       public Contributor2() {\r
+               super();\r
+       }\r
+       @Override\r
+       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
+               nodes.add(new ImportNode2(input));\r
+               return nodes;\r
+       }\r
+       \r
+       @Override\r
+       public String getViewpointId() {\r
+               return "Standard";\r
+       }\r
+\r
+}\r
index bfa3c47f70d2fe3d6f89497ac22342285fd22a1f..c88629f26ff8830ed9eb703e02470748785fddc6 100644 (file)
@@ -11,7 +11,6 @@
  *******************************************************************************/\r
 package org.simantics.interop.stubs;\r
 \r
-\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.request.Read;\r
@@ -22,10 +21,10 @@ public class InteropResource {
     \r
     public final Resource ImportLibrary;\r
     public final Resource InteropFeature;\r
-    \r
+        \r
     public static class URIs {\r
-        public static final String ImportLibrary = "http://www.simantics.org/Interoperability-1.0/Types/ImportLibrary";\r
-        public static final String InteropFeature = "http://www.simantics.org/Interoperability-1.0/InteropFeature";\r
+        public static final String ImportLibrary = "http://www.simantics.org/Interop-1.0/ImportLibrary";\r
+        public static final String InteropFeature = "http://www.simantics.org/Interop-1.0/InteropFeature";\r
     }\r
     \r
     public static Resource getResourceOrNull(ReadGraph graph, String uri) {\r