From 23c438c2c5f4ceb6a2e72b13a8fa0d576722831c Mon Sep 17 00:00:00 2001 From: luukkainen Date: Tue, 24 Aug 2010 12:54:28 +0000 Subject: [PATCH] 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 --- org.simantics.interop.feature/feature.xml | 7 -- org.simantics.interop/.project | 6 + org.simantics.interop/META-INF/MANIFEST.MF | 3 +- org.simantics.interop/graph.tg | Bin 0 -> 873 bytes org.simantics.interop/graph/Interop.pgraph | 13 ++ org.simantics.interop/plugin.xml | 11 ++ .../interop/browsing/ImportNode2.java | 115 ++++++++++++++++++ .../interop/handlers/Contributor2.java | 35 ++++++ .../interop/stubs/InteropResource.java | 7 +- 9 files changed, 185 insertions(+), 12 deletions(-) create mode 100644 org.simantics.interop/graph.tg create mode 100644 org.simantics.interop/graph/Interop.pgraph create mode 100644 org.simantics.interop/src/org/simantics/interop/browsing/ImportNode2.java create mode 100644 org.simantics.interop/src/org/simantics/interop/handlers/Contributor2.java 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 0000000000000000000000000000000000000000..ffc5ef7cde957dc2861b48af5b1f77b8872f5b77 GIT binary patch literal 873 zcmZ`%+fKqj5Cyrk7D4d(;)CyMgWupKl8|7)A6UwOYhbt8-BS5`=d4{ZCN|l&bIzIB z*)to}@HBaK4Ov~7j2?8M+(E6D$OS1Uog^DaUdCW84l*bfw3Lb!T6G{mndVe$x0g4S z*iaj|+vWZT!uaXakx^p37q)X@css88lj4<=9OYTrLf%MKd5HXzSSK89IMv4Jue}xP z;@^&2o{j5Ovj1H2`+N_8^ZcMJ%hbw^U=uQ%YO})m8sIv<51rrLr^6mVZ{TQ?Yvaap zZiLw-0q#}WXA-V3gdXdtk&MNT%n&7xfPv_}2>VDjGt!^>0yxNMq_$)%odjVALgB<4 zo7xXxRBa7!e7R(#*d3M8WO*7eWCj>>@xpkboL=kI4nBCKGb?g3nAv1`96+}Jos4uA zWAm~;SDS`=vliB#fdL&_J`B=^qH+*|_RJZnRt?17&{v~BD06TFSE&vrsw}(Wf4Gc3 z&>#*R^TIiCE>!LQiD5sSgN5J_2R$~xz|bc8MJ>dEhb@=}@LOItJo;Z3LE;YTJhiTv V+q9Z)Fadj^pMHg3FTcm0egWl?o16du literal 0 HcmV?d00001 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) { -- 2.45.2