+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r\r
-
-<adapters>\r
-\r <target interface="org.simantics.browsing.ui.model.children.ChildRule">\r <baseType uri="http://www.simantics.org/Viewpoint-1.2/ChildRule" />\r <resource\r uri="http://www.simantics.org/Interop-1.0/InteropBrowseContext/InteropChildRule"\r class="org.simantics.interop.browsing.InteropChildRule"/>\r </target>\r\r \r\r
-</adapters>
\ No newline at end of file
-source.. = src/\r
-output.. = bin/\r
-bin.includes = META-INF/,\\r
- .,\\r
- plugin.xml,\\r
- graph.tg,\\r
- adapters.xml,\\r
- icons/\r
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ graph.tg,\
+ icons/
-L0 = <http://www.simantics.org/Layer0-1.1>\r
-PROJ = <http://www.simantics.org/Project-1.2>\r
-\r
-MOD = <http://www.simantics.org/Modeling-1.2>\r
-VP = <http://www.simantics.org/Viewpoint-1.2>\r
-\r
- \r
-INTEROP = <http://www.simantics.org/Interop-1.0> : L0.Ontology\r
- L0.HasResourceClass "org.simantics.interop.stubs.InteropResource"\r
- @L0.new\r
- \r
-INTEROP.HasImportData <R L0.IsWeaklyRelatedTo\r
- L0.InverseOf INTEROP.ImportDataOf <R L0.IsWeaklyRelatedTo\r
-\r
-// Root node of imported data \r
-INTEROP.ImportLibrary <T L0.Library\r
-\r
-// Relation from generated model to its input data (Import Library).\r
-INTEROP.HasSource <R L0.IsWeaklyRelatedTo\r
- L0.InverseOf INTEROP.HasDestination <R L0.IsWeaklyRelatedTo\r
- L0.HasRange INTEROP.ImportLibrary\r
-\r
-// Relation from generated model to its input data (User selected resources in imported data). \r
-INTEROP.HasInputResource <R L0.IsWeaklyRelatedTo\r
-\r
-// Id of the generator, which generated the model.\r
-INTEROP.HasGeneratorID <R L0.HasProperty\r
- L0.HasRange L0.String\r
-\r
- \r
-IBC = INTEROP.InteropBrowseContext : VP.BrowseContext\r
- VP.BrowseContext.IsIncludedIn MOD.ModelingBrowseContext\r
- \r
-\r
-\r
-INTEROP.INodeType <T VP.NodeType\r
- @L0.assert VP.HasContentType "org.simantics.interop.browsing.INode"\r
-\r
-IBC.InteropNode : INTEROP.INodeType\r
-IBC.InteropChildRule : VP.ChildRule\r
- \r
-IBC\r
- VP.BrowseContext.HasChildContribution _ : VP.ChildContribution\r
- VP.ChildContribution.HasParentNodeType PROJ.Project\r
- VP.ChildContribution.HasChildNodeType IBC.InteropNode\r
- VP.ChildContribution.HasRule IBC.InteropChildRule\r
- \r
+L0 = <http://www.simantics.org/Layer0-1.1>
+
+INTEROP = <http://www.simantics.org/Interop-1.0> : L0.Ontology
+ L0.HasResourceClass "org.simantics.interop.stubs.InteropResource"
+ @L0.new
+
+INTEROP.HasImportData <R L0.IsWeaklyRelatedTo
+ L0.InverseOf INTEROP.ImportDataOf <R L0.IsWeaklyRelatedTo
+
+// Root node of imported data
+INTEROP.ImportLibrary <T L0.Library
+
+// Relation from generated model to its input data (Import Library).
+INTEROP.HasSource <R L0.IsWeaklyRelatedTo
+ L0.InverseOf INTEROP.HasDestination <R L0.IsWeaklyRelatedTo
+ L0.HasRange INTEROP.ImportLibrary
+
+// Relation from generated model to its input data (User selected resources in imported data).
+INTEROP.HasInputResource <R L0.IsWeaklyRelatedTo
+
+// Id of the generator, which generated the model.
+INTEROP.HasGeneratorID <R L0.HasProperty
+ L0.HasRange L0.String
+
+
+
-<?xml version="1.0" encoding="UTF-8"?>\r
-<?eclipse version="3.4"?>\r
-<plugin>\r
- \r
- <extension\r
- point="org.simantics.browsing.ui.common.evaluatorBinding">\r
- \r
- <binding\r
- browseContext="http://www.simantics.org/Interop-1.0/InteropBrowseContext">\r
- <implementation\r
- class="org.simantics.interop.handlers.EvaluatorFactory1"\r
- preference="1">\r
- </implementation>\r
- </binding>\r
- </extension>\r
- \r
- <extension\r
- point="org.eclipse.ui.views">\r
- <view\r
- category="org.simantics.debug.ui"\r
- class="org.simantics.interop.test.GraphComparatorViewer"\r
- icon="platform:/plugin/com.famfamfam.silk/icons/arrow_refresh.png"\r
- id="org.simantics.interop.comparator"\r
- name="Comparator"\r
- restorable="true">\r
- </view>\r
- </extension>\r
- <extension\r
- point="org.eclipse.ui.importWizards">\r
- <category\r
- id="org.simantics.interop.category"\r
- name="Interoperability">\r
- </category>\r
- </extension>\r
-\r
-</plugin>\r
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+
+ <extension
+ point="org.eclipse.ui.views">
+ <view
+ category="org.simantics.debug.ui"
+ class="org.simantics.interop.test.GraphComparatorViewer"
+ icon="platform:/plugin/com.famfamfam.silk/icons/arrow_refresh.png"
+ id="org.simantics.interop.comparator"
+ name="Comparator"
+ restorable="true">
+ </view>
+ </extension>
+ <extension
+ point="org.eclipse.ui.importWizards">
+ <category
+ id="org.simantics.interop.category"
+ name="Interoperability">
+ </category>
+ </extension>
+
+</plugin>
+++ /dev/null
-package org.simantics.interop.browsing;\r
-\r
-import java.util.Collection;\r
-\r
-import org.eclipse.core.runtime.IAdaptable;\r
-import org.eclipse.jface.resource.ImageDescriptor;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-\r
-public interface INode extends IAdaptable {\r
- String getLabel(ReadGraph graph) throws DatabaseException;\r
- int getCategory(ReadGraph graph) throws DatabaseException;\r
- Collection<?> getChildren(ReadGraph graph) throws DatabaseException;\r
- boolean hasChildren(ReadGraph graph) throws DatabaseException;\r
- ImageDescriptor getImage(ReadGraph graph) throws DatabaseException;\r
-\r
-\r
-}\r
+++ /dev/null
-package org.simantics.interop.browsing;\r
-\r
-import java.util.Collection;\r
-import java.util.Collections;\r
-import java.util.Map;\r
-import java.util.function.Consumer;\r
-import java.util.function.Supplier;\r
-\r
-import org.eclipse.jface.resource.ImageDescriptor;\r
-import org.simantics.browsing.ui.BuiltinKeys;\r
-import org.simantics.browsing.ui.BuiltinKeys.ImagerKey;\r
-import org.simantics.browsing.ui.BuiltinKeys.LabelerKey;\r
-import org.simantics.browsing.ui.BuiltinKeys.ViewpointKey;\r
-import org.simantics.browsing.ui.DataSource;\r
-import org.simantics.browsing.ui.NodeContext;\r
-import org.simantics.browsing.ui.PrimitiveQueryUpdater;\r
-import org.simantics.browsing.ui.common.ColumnKeys;\r
-import org.simantics.browsing.ui.common.EvaluatorData.Evaluator;\r
-import org.simantics.browsing.ui.common.EvaluatorImpl;\r
-import org.simantics.browsing.ui.common.comparators.AlphanumericComparatorFactory;\r
-import org.simantics.browsing.ui.common.imagers.ContainerImager;\r
-import org.simantics.browsing.ui.content.Imager;\r
-import org.simantics.browsing.ui.content.ImagerFactory;\r
-import org.simantics.browsing.ui.content.Labeler;\r
-import org.simantics.browsing.ui.content.LabelerFactory;\r
-import org.simantics.browsing.ui.content.Viewpoint;\r
-import org.simantics.browsing.ui.content.ViewpointFactory;\r
-import org.simantics.browsing.ui.graph.impl.LazyGraphLabeler;\r
-import org.simantics.browsing.ui.graph.impl.LazyViewpoint;\r
-import org.simantics.browsing.ui.graph.impl.MissingImageDescriptor;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.modeling.ui.modelBrowser.model.IChildrenCallback;\r
-import org.simantics.modeling.ui.modelBrowser.model.IDisposable;\r
-import org.simantics.modeling.ui.modelBrowser.model.IUpdateable;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-\r
-public class INodeEvaluators {\r
- public static Evaluator createEvaluator() {\r
- Evaluator nodeEvaluator = new EvaluatorImpl();\r
-\r
- nodeEvaluator.addViewpoint(new NodeViewpointFactory(), 1.0);\r
- nodeEvaluator.addComparator(new AlphanumericComparatorFactory(ColumnKeys.SINGLE), 2.0);\r
- nodeEvaluator.addLabeler(new NodeLabelerFactory(), 1.0);\r
- nodeEvaluator.addImager(new NodeImagerFactory(), 1.0);\r
- \r
- return nodeEvaluator;\r
- }\r
-}\r
-\r
-abstract class BaseViewpointFactory implements ViewpointFactory {\r
- protected abstract class VPB extends LazyViewpoint implements Supplier<Boolean>, IChildrenCallback {\r
- PrimitiveQueryUpdater updater;\r
- \r
- public VPB(PrimitiveQueryUpdater updater, NodeContext context, ViewpointKey key) {\r
- super(updater, context, key);\r
- this.updater = updater;\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return BaseViewpointFactory.this.toString();\r
- }\r
-\r
- @Override\r
- public Object getIdentity() {\r
- // This is necessary to give graph requests related to this\r
- // LazyViewpoint a unique-enough identity so that they don't collide\r
- // unexpectedly with other users of ModelEvaluators.\r
- // This makes requests created with different concrete classes of\r
- // BaseViewpointFactory unique.\r
- return BaseViewpointFactory.this.getClass();\r
- }\r
- \r
- @Override\r
- public Boolean get() {\r
- return Boolean.valueOf(updater.isDisposed());\r
- }\r
-\r
- @Override\r
- public void refreshChildren(Collection<?> newChildren) {\r
- NodeContext[] ncs = toContextsWithInput(newChildren);\r
- setHasChildren(ncs.length > 0);\r
- setChildren(updater,ncs);\r
- updater.scheduleReplace(context, key, this);\r
- }\r
-\r
- @Override\r
- public Boolean hasChildren(ReadGraph graph) throws DatabaseException {\r
- // hasChildren must do the same graph operations as children\r
- // since they both share the same PrimitiveQueryUpdater.\r
- return children(graph).length > 0;\r
- }\r
- };\r
-}\r
-\r
-class NodeViewpointFactory extends BaseViewpointFactory {\r
- @Override\r
- public String toString() {\r
- return "Standard";\r
- }\r
-\r
- class VP extends VPB {\r
- public VP(PrimitiveQueryUpdater updater, NodeContext context, ViewpointKey key) {\r
- super(updater, context, key);\r
- }\r
-\r
- @Override\r
- public NodeContext[] children(ReadGraph graph) throws DatabaseException {\r
- INode node = (INode) context.getConstant(BuiltinKeys.INPUT);\r
- if (node instanceof IUpdateable)\r
- ((IUpdateable) node).setChildrenCallback(this);\r
-\r
- Collection<?> children = node.getChildren(graph);\r
- for (Object child : children) {\r
- if (child instanceof IDisposable)\r
- ((IDisposable) child).setDisposedCallable(this);\r
- }\r
- return toContextsWithInput(children);\r
- }\r
- };\r
-\r
- @Override\r
- public Viewpoint create(PrimitiveQueryUpdater updater, NodeContext context, ViewpointKey key) {\r
- return new VP(updater, context, key);\r
- }\r
-}\r
-\r
-class NodeLabelerFactory implements LabelerFactory {\r
- @Override\r
- public Labeler create(PrimitiveQueryUpdater updater, final NodeContext context, LabelerKey key) {\r
- return new LazyGraphLabeler(updater, context, key) {\r
- @Override\r
- public Object getIdentity(LabelerKey key) {\r
- return NodeLabelerFactory.this.getClass();\r
- }\r
- \r
- @Override\r
- public Map<String, String> labels(ReadGraph graph) throws DatabaseException {\r
- return Collections.singletonMap(ColumnKeys.SINGLE,\r
- ((INode) context.getConstant(BuiltinKeys.INPUT)).getLabel(graph));\r
- }\r
-\r
- @Override\r
- public int category(ReadGraph graph) throws DatabaseException {\r
- return ((INode) context.getConstant(BuiltinKeys.INPUT)).getCategory(graph);\r
- }\r
-\r
- @Override\r
- public Logger getLogger() {\r
- return LoggerFactory.getLogger(NodeLabelerFactory.class);\r
- }\r
- };\r
- }\r
-}\r
-\r
-class NodeImagerFactory implements ImagerFactory {\r
-\r
- @Override\r
- public Imager create(final PrimitiveQueryUpdater updater, final NodeContext context, final ImagerKey key) {\r
- final ContainerImager<ImageDescriptor> result = new ContainerImager<ImageDescriptor>();\r
- result.setImage(MissingImageDescriptor.getInstance());\r
-\r
- DataSource<ReadGraph> source = updater.getDataSource(ReadGraph.class);\r
-\r
- source.schedule(new Consumer<ReadGraph>() {\r
- \r
- @Override\r
- public void accept(ReadGraph g) {\r
- try {\r
- INode node = (INode)context.getConstant(BuiltinKeys.INPUT);\r
- ImageDescriptor descriptor = node.getImage(g);\r
- result.setImage(descriptor);\r
- updater.scheduleReplace(context, key, result);\r
- } catch (DatabaseException e) {\r
- e.printStackTrace();\r
- }\r
- }\r
- });\r
-\r
- return result;\r
- }\r
-\r
-}
\ No newline at end of file
+++ /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.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.interop.Activator;\r
-import org.simantics.interop.stubs.InteropResource;\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 <T> T getAdapter(Class<T> adapter) {\r
- return null;\r
- }\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 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
- InteropResource i = InteropResource.getInstance(graph);\r
-\r
- Collection<Resource> objs = graph.getObjects(project, i.HasImportData);\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
- }\r
- \r
- @Override\r
- public int getCategory(ReadGraph graph) throws DatabaseException {\r
- return 0;\r
- }\r
- \r
-\r
-}\r
+++ /dev/null
-package org.simantics.interop.browsing;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Collection;\r
-import java.util.Collections;\r
-import java.util.List;\r
-\r
-import org.simantics.browsing.ui.model.children.ChildRule;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.exception.DatabaseException;\r
-\r
-public class InteropChildRule implements ChildRule{\r
- @Override\r
- public boolean isCompatible(Class<?> contentType) {\r
- return Resource.class.isAssignableFrom(contentType);\r
- }\r
- @Override\r
- public Collection<?> getChildren(ReadGraph graph, Object parent_)\r
- throws DatabaseException {\r
- Resource parent = (Resource)parent_;\r
-\r
- \r
- List<INode> nodes = new ArrayList<INode>();\r
- nodes.add(new ImportNode2(parent));\r
- return nodes;\r
- \r
-\r
- }\r
- @Override\r
- public Collection<?> getParents(ReadGraph graph, Object child)\r
- throws DatabaseException {\r
- return Collections.emptyList(); // It is not necessary to support this\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.simantics.interop.handlers;\r
-\r
-import java.util.Collection;\r
-\r
-import org.simantics.browsing.ui.common.EvaluatorData.Evaluator;\r
-import org.simantics.browsing.ui.common.extension.EvaluatorFactory;\r
-import org.simantics.interop.browsing.INode;\r
-import org.simantics.interop.browsing.INodeEvaluators;\r
-\r
-public class EvaluatorFactory1 implements EvaluatorFactory {\r
-\r
- public EvaluatorFactory1() {\r
- }\r
- \r
- @Override\r
- public Evaluator create(Collection<String> browseContexts) {\r
- \r
-\r
- return INodeEvaluators.createEvaluator();\r
- }\r
- \r
- @Override\r
- public Class<?> getClazz() {\r
- return INode.class;\r
- }\r
- \r
- \r
-}\r
- \r
- \r
-\r
-\r
public final Resource HasImportData;
public final Resource HasInputResource;
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 HasInputResource = "http://www.simantics.org/Interop-1.0/HasInputResource";
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) {
HasImportData = getResourceOrNull(graph, URIs.HasImportData);
HasInputResource = getResourceOrNull(graph, URIs.HasInputResource);
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) {