From e68ce22b493bddde9484aaeb59a550014a4ea0fe Mon Sep 17 00:00:00 2001 From: luukkainen Date: Thu, 5 Aug 2010 13:02:06 +0000 Subject: [PATCH] Model browser Import node to correct place under Model git-svn-id: https://www.simantics.org/svn/simantics/interoperability/trunk@16968 ac1ea38d-2e2b-0410-8846-a27921b304fc --- org.simantics.interop/META-INF/MANIFEST.MF | 3 +- .../interop/browsing/ImportNode.java | 28 ++++++++++------ .../interop/handlers/Contributor1.java | 33 ++++++++++++++++--- 3 files changed, 49 insertions(+), 15 deletions(-) diff --git a/org.simantics.interop/META-INF/MANIFEST.MF b/org.simantics.interop/META-INF/MANIFEST.MF index 99a5c99..bf52f70 100644 --- a/org.simantics.interop/META-INF/MANIFEST.MF +++ b/org.simantics.interop/META-INF/MANIFEST.MF @@ -13,6 +13,7 @@ Require-Bundle: org.eclipse.ui, org.simantics.browsing.ui.common;bundle-version="0.9.0", 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.layer0.utils;bundle-version="0.8.0", + org.simantics.structural.ui;bundle-version="1.0.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy diff --git a/org.simantics.interop/src/org/simantics/interop/browsing/ImportNode.java b/org.simantics.interop/src/org/simantics/interop/browsing/ImportNode.java index 6af1cad..9ed9392 100644 --- a/org.simantics.interop/src/org/simantics/interop/browsing/ImportNode.java +++ b/org.simantics.interop/src/org/simantics/interop/browsing/ImportNode.java @@ -19,10 +19,11 @@ import org.simantics.modeling.ui.modelBrowser.model.INode; public class ImportNode implements INode { - private Resource project; + //private Resource project; + private Resource model; public ImportNode(Resource project) { - this.project = project; + this.model = project; } @Override @@ -74,14 +75,21 @@ public class ImportNode implements INode { 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 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(model, b.ConsistsOf); + for (Resource o : objs) { + if (graph.isInstanceOf(o, i.ImportLibrary)) { + INode node = graph.adapt(o, INode.class); + nodes.add(node); } } return nodes; diff --git a/org.simantics.interop/src/org/simantics/interop/handlers/Contributor1.java b/org.simantics.interop/src/org/simantics/interop/handlers/Contributor1.java index 26d63a6..2ca4391 100644 --- a/org.simantics.interop/src/org/simantics/interop/handlers/Contributor1.java +++ b/org.simantics.interop/src/org/simantics/interop/handlers/Contributor1.java @@ -10,19 +10,21 @@ import org.simantics.db.exception.DatabaseException; import org.simantics.interop.browsing.ImportNode; import org.simantics.layer0.utils.direct.GraphUtils; import org.simantics.modeling.ui.modelBrowser.model.INode; +import org.simantics.structural.ui.modelBrowser.nodes.ModelNode; -public class Contributor1 extends ViewpointContributor { + +public class Contributor1 extends ViewpointContributor { public Contributor1() { super(); } @Override - public Collection getContribution(ReadGraph graph, Resource input) + public Collection getContribution(ReadGraph graph, ModelNode input) throws DatabaseException { Collection nodes = new ArrayList(); - System.out.println("Contributor 1 " + input + " " + GraphUtils.getReadableName(graph, input)); - nodes.add(new ImportNode(input)); + System.out.println("Contributor 1 " + input + " " + GraphUtils.getReadableName(graph, input.resource)); + nodes.add(new ImportNode(input.resource)); return nodes; } @@ -34,3 +36,26 @@ public class Contributor1 extends ViewpointContributor { } +//public class Contributor1 extends ViewpointContributor { +// +// +// public Contributor1() { +// 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 ImportNode(input)); +// return nodes; +// } +// +// @Override +// public String getViewpointId() { +// return "Standard"; +// } +// +// +// +//} -- 2.47.1