From 53e033dd7424799749f7bc170b741ddf6767d33e Mon Sep 17 00:00:00 2001 From: luukkainen Date: Wed, 27 Apr 2011 12:17:07 +0000 Subject: [PATCH] StructuralBrowser Interop contribution git-svn-id: https://www.simantics.org/svn/simantics/interoperability/trunk@20590 ac1ea38d-2e2b-0410-8846-a27921b304fc --- org.simantics.interop/META-INF/MANIFEST.MF | 4 +- org.simantics.interop/adapters.xml | 5 +++ org.simantics.interop/graph.tg | Bin 955 -> 1860 bytes org.simantics.interop/graph/Interop.pgraph | 20 +++++++++ org.simantics.interop/plugin.xml | 18 +++++++- .../interop/browsing/InteropChildRule.java | 39 ++++++++++++++++++ .../interop/handlers/Contributor2.java | 2 +- .../interop/stubs/InteropResource.java | 12 ++++++ 8 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 org.simantics.interop/adapters.xml create mode 100644 org.simantics.interop/src/org/simantics/interop/browsing/InteropChildRule.java diff --git a/org.simantics.interop/META-INF/MANIFEST.MF b/org.simantics.interop/META-INF/MANIFEST.MF index 0033030..d11a186 100644 --- a/org.simantics.interop/META-INF/MANIFEST.MF +++ b/org.simantics.interop/META-INF/MANIFEST.MF @@ -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 index 0000000..9de4ffa --- /dev/null +++ b/org.simantics.interop/adapters.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/org.simantics.interop/graph.tg b/org.simantics.interop/graph.tg index 537da89056c25c010df240e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;9RJGGWlgpxRg^ANwx7egY_Tae1@Wt> zn*VkgaW(Dv4&UN^>(_Yon9mM}!`zm8fdg;tT$>k^!U5HD{q;f)K;UEMqfWbg2A!NtPV}+d7-5dUeQK|lJ&L0= zcfN&dV*SawsiiTpVqf-%xR5Or?niAUvxM0cU98&wTM297a7&dWS*TZOti-xt>Cgk- z{f1FaXTYJJ@C%{4Vi>QTDHYw*lym%}@6wcxtm6||DyJ*`Lg% PROJ = +MOD = +VP = + + INTEROP = : L0.Ontology L0.HasResourceClass "org.simantics.interop.stubs.InteropResource" @@ -13,3 +17,19 @@ INTEROP.ImportLibrary + + @@ -24,6 +29,15 @@ preference="1"> + + + + + + 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 index 0000000..3b6d25e --- /dev/null +++ b/org.simantics.interop/src/org/simantics/interop/browsing/InteropChildRule.java @@ -0,0 +1,39 @@ +package org.simantics.interop.browsing; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import org.simantics.browsing.ui.model.children.ChildRule; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.exception.DatabaseException; +import org.simantics.interop.stubs.InteropResource; +import org.simantics.layer0.Layer0; +import org.simantics.modeling.ui.modelBrowser.model.INode; + +public class InteropChildRule implements ChildRule{ + @Override + public boolean isCompatible(Class contentType) { + return Resource.class.isAssignableFrom(contentType); + } + @Override + public Collection getChildren(ReadGraph graph, Object parent_) + throws DatabaseException { + Resource parent = (Resource)parent_; + + + List nodes = new ArrayList(); + nodes.add(new ImportNode2(parent)); + return nodes; + + + } + @Override + public Collection getParents(ReadGraph graph, Object child) + throws DatabaseException { + return Collections.emptyList(); // It is not necessary to support this + } + +} diff --git a/org.simantics.interop/src/org/simantics/interop/handlers/Contributor2.java b/org.simantics.interop/src/org/simantics/interop/handlers/Contributor2.java index 2826886..cc9f838 100644 --- a/org.simantics.interop/src/org/simantics/interop/handlers/Contributor2.java +++ b/org.simantics.interop/src/org/simantics/interop/handlers/Contributor2.java @@ -22,7 +22,7 @@ public class Contributor2 extends ViewpointContributor { public Collection getContribution(ReadGraph graph, Resource input) throws DatabaseException { Collection nodes = new ArrayList(); - System.out.println("Contributor 1 " + input + " " + GraphUtils.getReadableName(graph, input)); + System.out.println("Contributor 2 " + input + " " + GraphUtils.getReadableName(graph, input)); nodes.add(new ImportNode2(input)); return nodes; } 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 de2e123..fd1d7ed 100644 --- a/org.simantics.interop/src/org/simantics/interop/stubs/InteropResource.java +++ b/org.simantics.interop/src/org/simantics/interop/stubs/InteropResource.java @@ -11,15 +11,23 @@ public class InteropResource { public final Resource HasDestination; public final Resource HasImportData; public final Resource HasSource; + public final Resource INodeType; public final Resource ImportDataOf; public final Resource ImportLibrary; + public final Resource InteropBrowseContext; + public final Resource InteropBrowseContext_InteropChildRule; + public final Resource InteropBrowseContext_InteropNode; public static class URIs { public static final String HasDestination = "http://www.simantics.org/Interop-1.0/HasDestination"; public static final String HasImportData = "http://www.simantics.org/Interop-1.0/HasImportData"; public static final String HasSource = "http://www.simantics.org/Interop-1.0/HasSource"; + public static final String INodeType = "http://www.simantics.org/Interop-1.0/INodeType"; public static final String ImportDataOf = "http://www.simantics.org/Interop-1.0/ImportDataOf"; public static final String ImportLibrary = "http://www.simantics.org/Interop-1.0/ImportLibrary"; + public static final String InteropBrowseContext = "http://www.simantics.org/Interop-1.0/InteropBrowseContext"; + public static final String InteropBrowseContext_InteropChildRule = "http://www.simantics.org/Interop-1.0/InteropBrowseContext/InteropChildRule"; + public static final String InteropBrowseContext_InteropNode = "http://www.simantics.org/Interop-1.0/InteropBrowseContext/InteropNode"; } public static Resource getResourceOrNull(ReadGraph graph, String uri) { @@ -35,8 +43,12 @@ public class InteropResource { HasDestination = getResourceOrNull(graph, URIs.HasDestination); HasImportData = getResourceOrNull(graph, URIs.HasImportData); HasSource = getResourceOrNull(graph, URIs.HasSource); + INodeType = getResourceOrNull(graph, URIs.INodeType); ImportDataOf = getResourceOrNull(graph, URIs.ImportDataOf); ImportLibrary = getResourceOrNull(graph, URIs.ImportLibrary); + InteropBrowseContext = getResourceOrNull(graph, URIs.InteropBrowseContext); + InteropBrowseContext_InteropChildRule = getResourceOrNull(graph, URIs.InteropBrowseContext_InteropChildRule); + InteropBrowseContext_InteropNode = getResourceOrNull(graph, URIs.InteropBrowseContext_InteropNode); } public static InteropResource getInstance(ReadGraph graph) { -- 2.47.1