From: Marko Luukkainen Date: Tue, 12 Mar 2019 17:00:49 +0000 (+0000) Subject: Merge "Remove outdated model browser contribution" X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=fe01e79b1d38a4ec134be381d485bc0a61685e17;hp=3dddcb9694df9a9da950b625345ba218344b9a37;p=simantics%2Finterop.git Merge "Remove outdated model browser contribution" --- diff --git a/org.simantics.interop/adapters.xml b/org.simantics.interop/adapters.xml deleted file mode 100644 index 532ad94..0000000 --- a/org.simantics.interop/adapters.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/org.simantics.interop/build.properties b/org.simantics.interop/build.properties index 60db7c3..0df298c 100644 --- a/org.simantics.interop/build.properties +++ b/org.simantics.interop/build.properties @@ -1,8 +1,7 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - plugin.xml,\ - graph.tg,\ - adapters.xml,\ - icons/ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + graph.tg,\ + icons/ diff --git a/org.simantics.interop/graph.tg b/org.simantics.interop/graph.tg index 0aba0de..5cc6c8e 100644 Binary files a/org.simantics.interop/graph.tg and b/org.simantics.interop/graph.tg differ diff --git a/org.simantics.interop/graph/Interop.pgraph b/org.simantics.interop/graph/Interop.pgraph index 361c0c9..3c53620 100644 --- a/org.simantics.interop/graph/Interop.pgraph +++ b/org.simantics.interop/graph/Interop.pgraph @@ -1,47 +1,26 @@ -L0 = -PROJ = - -MOD = -VP = - - -INTEROP = : L0.Ontology - L0.HasResourceClass "org.simantics.interop.stubs.InteropResource" - @L0.new - -INTEROP.HasImportData + +INTEROP = : L0.Ontology + L0.HasResourceClass "org.simantics.interop.stubs.InteropResource" + @L0.new + +INTEROP.HasImportData - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/org.simantics.interop/src/org/simantics/interop/browsing/INode.java b/org.simantics.interop/src/org/simantics/interop/browsing/INode.java deleted file mode 100644 index 473af20..0000000 --- a/org.simantics.interop/src/org/simantics/interop/browsing/INode.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.simantics.interop.browsing; - -import java.util.Collection; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.resource.ImageDescriptor; -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; - -public interface INode extends IAdaptable { - String getLabel(ReadGraph graph) throws DatabaseException; - int getCategory(ReadGraph graph) throws DatabaseException; - Collection getChildren(ReadGraph graph) throws DatabaseException; - boolean hasChildren(ReadGraph graph) throws DatabaseException; - ImageDescriptor getImage(ReadGraph graph) throws DatabaseException; - - -} diff --git a/org.simantics.interop/src/org/simantics/interop/browsing/INodeEvaluators.java b/org.simantics.interop/src/org/simantics/interop/browsing/INodeEvaluators.java deleted file mode 100644 index 7329345..0000000 --- a/org.simantics.interop/src/org/simantics/interop/browsing/INodeEvaluators.java +++ /dev/null @@ -1,186 +0,0 @@ -package org.simantics.interop.browsing; - -import java.util.Collection; -import java.util.Collections; -import java.util.Map; -import java.util.function.Consumer; -import java.util.function.Supplier; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.simantics.browsing.ui.BuiltinKeys; -import org.simantics.browsing.ui.BuiltinKeys.ImagerKey; -import org.simantics.browsing.ui.BuiltinKeys.LabelerKey; -import org.simantics.browsing.ui.BuiltinKeys.ViewpointKey; -import org.simantics.browsing.ui.DataSource; -import org.simantics.browsing.ui.NodeContext; -import org.simantics.browsing.ui.PrimitiveQueryUpdater; -import org.simantics.browsing.ui.common.ColumnKeys; -import org.simantics.browsing.ui.common.EvaluatorData.Evaluator; -import org.simantics.browsing.ui.common.EvaluatorImpl; -import org.simantics.browsing.ui.common.comparators.AlphanumericComparatorFactory; -import org.simantics.browsing.ui.common.imagers.ContainerImager; -import org.simantics.browsing.ui.content.Imager; -import org.simantics.browsing.ui.content.ImagerFactory; -import org.simantics.browsing.ui.content.Labeler; -import org.simantics.browsing.ui.content.LabelerFactory; -import org.simantics.browsing.ui.content.Viewpoint; -import org.simantics.browsing.ui.content.ViewpointFactory; -import org.simantics.browsing.ui.graph.impl.LazyGraphLabeler; -import org.simantics.browsing.ui.graph.impl.LazyViewpoint; -import org.simantics.browsing.ui.graph.impl.MissingImageDescriptor; -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.modeling.ui.modelBrowser.model.IChildrenCallback; -import org.simantics.modeling.ui.modelBrowser.model.IDisposable; -import org.simantics.modeling.ui.modelBrowser.model.IUpdateable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class INodeEvaluators { - public static Evaluator createEvaluator() { - Evaluator nodeEvaluator = new EvaluatorImpl(); - - nodeEvaluator.addViewpoint(new NodeViewpointFactory(), 1.0); - nodeEvaluator.addComparator(new AlphanumericComparatorFactory(ColumnKeys.SINGLE), 2.0); - nodeEvaluator.addLabeler(new NodeLabelerFactory(), 1.0); - nodeEvaluator.addImager(new NodeImagerFactory(), 1.0); - - return nodeEvaluator; - } -} - -abstract class BaseViewpointFactory implements ViewpointFactory { - protected abstract class VPB extends LazyViewpoint implements Supplier, IChildrenCallback { - PrimitiveQueryUpdater updater; - - public VPB(PrimitiveQueryUpdater updater, NodeContext context, ViewpointKey key) { - super(updater, context, key); - this.updater = updater; - } - - @Override - public String toString() { - return BaseViewpointFactory.this.toString(); - } - - @Override - public Object getIdentity() { - // This is necessary to give graph requests related to this - // LazyViewpoint a unique-enough identity so that they don't collide - // unexpectedly with other users of ModelEvaluators. - // This makes requests created with different concrete classes of - // BaseViewpointFactory unique. - return BaseViewpointFactory.this.getClass(); - } - - @Override - public Boolean get() { - return Boolean.valueOf(updater.isDisposed()); - } - - @Override - public void refreshChildren(Collection newChildren) { - NodeContext[] ncs = toContextsWithInput(newChildren); - setHasChildren(ncs.length > 0); - setChildren(updater,ncs); - updater.scheduleReplace(context, key, this); - } - - @Override - public Boolean hasChildren(ReadGraph graph) throws DatabaseException { - // hasChildren must do the same graph operations as children - // since they both share the same PrimitiveQueryUpdater. - return children(graph).length > 0; - } - }; -} - -class NodeViewpointFactory extends BaseViewpointFactory { - @Override - public String toString() { - return "Standard"; - } - - class VP extends VPB { - public VP(PrimitiveQueryUpdater updater, NodeContext context, ViewpointKey key) { - super(updater, context, key); - } - - @Override - public NodeContext[] children(ReadGraph graph) throws DatabaseException { - INode node = (INode) context.getConstant(BuiltinKeys.INPUT); - if (node instanceof IUpdateable) - ((IUpdateable) node).setChildrenCallback(this); - - Collection children = node.getChildren(graph); - for (Object child : children) { - if (child instanceof IDisposable) - ((IDisposable) child).setDisposedCallable(this); - } - return toContextsWithInput(children); - } - }; - - @Override - public Viewpoint create(PrimitiveQueryUpdater updater, NodeContext context, ViewpointKey key) { - return new VP(updater, context, key); - } -} - -class NodeLabelerFactory implements LabelerFactory { - @Override - public Labeler create(PrimitiveQueryUpdater updater, final NodeContext context, LabelerKey key) { - return new LazyGraphLabeler(updater, context, key) { - @Override - public Object getIdentity(LabelerKey key) { - return NodeLabelerFactory.this.getClass(); - } - - @Override - public Map labels(ReadGraph graph) throws DatabaseException { - return Collections.singletonMap(ColumnKeys.SINGLE, - ((INode) context.getConstant(BuiltinKeys.INPUT)).getLabel(graph)); - } - - @Override - public int category(ReadGraph graph) throws DatabaseException { - return ((INode) context.getConstant(BuiltinKeys.INPUT)).getCategory(graph); - } - - @Override - public Logger getLogger() { - return LoggerFactory.getLogger(NodeLabelerFactory.class); - } - }; - } -} - -class NodeImagerFactory implements ImagerFactory { - - @Override - public Imager create(final PrimitiveQueryUpdater updater, final NodeContext context, final ImagerKey key) { - final ContainerImager result = new ContainerImager(); - result.setImage(MissingImageDescriptor.getInstance()); - - DataSource source = updater.getDataSource(ReadGraph.class); - - source.schedule(new Consumer() { - - @Override - public void accept(ReadGraph g) { - try { - INode node = (INode)context.getConstant(BuiltinKeys.INPUT); - ImageDescriptor descriptor = node.getImage(g); - result.setImage(descriptor); - updater.scheduleReplace(context, key, result); - } catch (DatabaseException e) { - e.printStackTrace(); - } - } - }); - - return result; - } - -} \ No newline at end of file diff --git a/org.simantics.interop/src/org/simantics/interop/browsing/ImportNode2.java b/org.simantics.interop/src/org/simantics/interop/browsing/ImportNode2.java deleted file mode 100644 index 804882d..0000000 --- a/org.simantics.interop/src/org/simantics/interop/browsing/ImportNode2.java +++ /dev/null @@ -1,66 +0,0 @@ -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.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.interop.Activator; -import org.simantics.interop.stubs.InteropResource; - -public class ImportNode2 implements INode { - - private Resource project; - - public ImportNode2(Resource project) { - this.project = project; - } - - @Override - public T getAdapter(Class adapter) { - return null; - } - - - - @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 boolean hasChildren(ReadGraph graph) throws DatabaseException { - return getChildren(graph).size() > 0; - } - - @Override - public Collection getChildren(ReadGraph graph) throws DatabaseException { - List nodes = new ArrayList(); - InteropResource i = InteropResource.getInstance(graph); - - Collection objs = graph.getObjects(project, i.HasImportData); - for (Resource o : objs) { - if (graph.isInstanceOf(o, i.ImportLibrary)) { - INode node = graph.adapt(o, INode.class); - nodes.add(node); - } - } - return nodes; - - } - - @Override - public int getCategory(ReadGraph graph) throws DatabaseException { - return 0; - } - - -} diff --git a/org.simantics.interop/src/org/simantics/interop/browsing/InteropChildRule.java b/org.simantics.interop/src/org/simantics/interop/browsing/InteropChildRule.java deleted file mode 100644 index dacd74d..0000000 --- a/org.simantics.interop/src/org/simantics/interop/browsing/InteropChildRule.java +++ /dev/null @@ -1,36 +0,0 @@ -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; - -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/EvaluatorFactory1.java b/org.simantics.interop/src/org/simantics/interop/handlers/EvaluatorFactory1.java deleted file mode 100644 index 1028e36..0000000 --- a/org.simantics.interop/src/org/simantics/interop/handlers/EvaluatorFactory1.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.simantics.interop.handlers; - -import java.util.Collection; - -import org.simantics.browsing.ui.common.EvaluatorData.Evaluator; -import org.simantics.browsing.ui.common.extension.EvaluatorFactory; -import org.simantics.interop.browsing.INode; -import org.simantics.interop.browsing.INodeEvaluators; - -public class EvaluatorFactory1 implements EvaluatorFactory { - - public EvaluatorFactory1() { - } - - @Override - public Evaluator create(Collection browseContexts) { - - - return INodeEvaluators.createEvaluator(); - } - - @Override - public Class getClazz() { - return INode.class; - } - - -} - - - - 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 c8445be..53ca523 100644 --- a/org.simantics.interop/src/org/simantics/interop/stubs/InteropResource.java +++ b/org.simantics.interop/src/org/simantics/interop/stubs/InteropResource.java @@ -16,12 +16,8 @@ public class InteropResource { 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"; @@ -30,12 +26,8 @@ public class InteropResource { 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) { @@ -54,12 +46,8 @@ public class InteropResource { 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) {