--- /dev/null
+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
--- /dev/null
+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
*******************************************************************************/\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
\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