From: luukkainen Date: Tue, 24 Aug 2010 12:54:28 +0000 (+0000) Subject: Moved to SPM. X-Git-Tag: v1.31.0~134 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=23c438c2c5f4ceb6a2e72b13a8fa0d576722831c;p=simantics%2Finterop.git Moved to SPM. 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 --- diff --git a/org.simantics.interop.feature/feature.xml b/org.simantics.interop.feature/feature.xml index 784434a..3942c1f 100644 --- a/org.simantics.interop.feature/feature.xml +++ b/org.simantics.interop.feature/feature.xml @@ -45,13 +45,6 @@ version="0.0.0" unpack="false"/> - - + + org.simantics.graph.builder + + + org.eclipse.jdt.core.javabuilder @@ -24,5 +29,6 @@ org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature + org.simantics.graph.nature diff --git a/org.simantics.interop/META-INF/MANIFEST.MF b/org.simantics.interop/META-INF/MANIFEST.MF index bf52f70..6171d9e 100644 --- a/org.simantics.interop/META-INF/MANIFEST.MF +++ b/org.simantics.interop/META-INF/MANIFEST.MF @@ -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 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 index 0000000..074ac7a --- /dev/null +++ b/org.simantics.interop/graph/Interop.pgraph @@ -0,0 +1,13 @@ +L0 = +PROJ = + + +INTEROP = : L0.Ontology + L0.HasResourceClass "org.simantics.interop.stubs.InteropResource" + @L0.new + +INTEROP.InteropFeature : PROJ.Feature + L0.HasDescription "Interop feature." + + +INTEROP.ImportLibrary + + + + + + 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 index 0000000..38fb562 --- /dev/null +++ b/org.simantics.interop/src/org/simantics/interop/browsing/ImportNode2.java @@ -0,0 +1,115 @@ +package org.simantics.interop.browsing; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.ISelection; +import org.simantics.browsing.ui.content.Labeler.Modifier; +import org.simantics.db.Builtins; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.Session; +import org.simantics.db.WriteGraph; +import org.simantics.db.exception.DatabaseException; +import org.simantics.interop.Activator; +import org.simantics.interop.stubs.InteropResource; +import org.simantics.modeling.ui.modelBrowser.model.INode; + +public class ImportNode2 implements INode { + + private Resource project; + + public ImportNode2(Resource project) { + this.project = project; + } + + @Override + public Object getAdapter(Class adapter) { + return null; + } + + @Override + public int getCategory(ReadGraph graph) throws DatabaseException { + return 0; + } + + + @Override + public ImageDescriptor getImage(ReadGraph graph) throws DatabaseException { + return Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/silk/database_connect.png"); + } + + @Override + public String getLabel(ReadGraph graph) throws DatabaseException { + return "Imports"; + } + + @Override + public Modifier getModifier(Session session, String columnId) { + // TODO Auto-generated method stub + return null; + } + + @Override + public void handleDelete(WriteGraph graph) throws DatabaseException { + // TODO Auto-generated method stub + + } + + @Override + public void handleDrop(Session session, ISelection selection) { + // TODO Auto-generated method stub + + } + + @Override + public boolean hasChildren(ReadGraph graph) throws DatabaseException { + return getChildren(graph).size() > 0; + } + + @Override + public Collection getChildren(ReadGraph graph) throws DatabaseException { + List nodes = new ArrayList(); + Builtins b = graph.getBuiltins(); + InteropResource i = InteropResource.getInstance(graph); +// Collection models = graph.getObjects(project, b.ConsistsOf); +// for (Resource m : models) { +// Collection objs = graph.getObjects(m, b.ConsistsOf); +// for (Resource o : objs) { +// if (graph.isInstanceOf(o, i.ImportLibrary)) { +// INode node = graph.adapt(o, INode.class); +// nodes.add(node); +// } +// } +// } + Collection objs = graph.getObjects(project, b.ConsistsOf); + for (Resource o : objs) { + if (graph.isInstanceOf(o, i.ImportLibrary)) { + INode node = graph.adapt(o, INode.class); + nodes.add(node); + } + } + return nodes; + +// ComosResource c = ComosResource.getInstance(graph); +// Collection models = graph.getObjects(project, b.ConsistsOf); +// Collection comosImports = new ArrayList(); +// for (Resource m : models) { +// Collection objs = graph.getObjects(m, b.ConsistsOf); +// for (Resource o : objs) { +// if (graph.isInstanceOf(o, c.ComosImportLibrary)) { +// String icon_db_path = ComosGraphTools.getIconPath(o, graph); +// if (icon_db_path == null) +// continue; +// ComosIconReader iconReader = new ComosIconReader(icon_db_path); +// comosImports.add(new ComosGraphNode(o, iconReader)); +// } +// } +// } +// return comosImports; + } + + +} 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 index 0000000..2826886 --- /dev/null +++ b/org.simantics.interop/src/org/simantics/interop/handlers/Contributor2.java @@ -0,0 +1,35 @@ +package org.simantics.interop.handlers; + +import java.util.ArrayList; +import java.util.Collection; + +import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.exception.DatabaseException; +import org.simantics.interop.browsing.ImportNode2; +import org.simantics.layer0.utils.direct.GraphUtils; +import org.simantics.modeling.ui.modelBrowser.model.INode; + + +public class Contributor2 extends ViewpointContributor { + + + public Contributor2() { + super(); + } + @Override + public Collection getContribution(ReadGraph graph, Resource input) + throws DatabaseException { + Collection nodes = new ArrayList(); + System.out.println("Contributor 1 " + input + " " + GraphUtils.getReadableName(graph, input)); + nodes.add(new ImportNode2(input)); + return nodes; + } + + @Override + public String getViewpointId() { + return "Standard"; + } + +} diff --git a/org.simantics.interop/src/org/simantics/interop/stubs/InteropResource.java b/org.simantics.interop/src/org/simantics/interop/stubs/InteropResource.java index bfa3c47..c88629f 100644 --- a/org.simantics.interop/src/org/simantics/interop/stubs/InteropResource.java +++ b/org.simantics.interop/src/org/simantics/interop/stubs/InteropResource.java @@ -11,7 +11,6 @@ *******************************************************************************/ package org.simantics.interop.stubs; - import org.simantics.db.Resource; import org.simantics.db.ReadGraph; import org.simantics.db.request.Read; @@ -22,10 +21,10 @@ public class InteropResource { public final Resource ImportLibrary; public final Resource InteropFeature; - + public static class URIs { - public static final String ImportLibrary = "http://www.simantics.org/Interoperability-1.0/Types/ImportLibrary"; - public static final String InteropFeature = "http://www.simantics.org/Interoperability-1.0/InteropFeature"; + public static final String ImportLibrary = "http://www.simantics.org/Interop-1.0/ImportLibrary"; + public static final String InteropFeature = "http://www.simantics.org/Interop-1.0/InteropFeature"; } public static Resource getResourceOrNull(ReadGraph graph, String uri) {