From: Antti Villberg Date: Thu, 10 Aug 2017 07:32:41 +0000 (+0300) Subject: More type information for diagram elements X-Git-Tag: v1.31.0~257 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=060886da1e94e4a6bb1e09d56e96a6ad289ba7d0;p=simantics%2Fplatform.git More type information for diagram elements refs #7420 Change-Id: Iab051ea3f367f6d421e2ae88d2290af35314a454 --- diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/CompositeImage.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/CompositeImage.java index 98f229b91..1c6e4df40 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/CompositeImage.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/CompositeImage.java @@ -142,6 +142,7 @@ public class CompositeImage implements Image { //SingleElementNode holder = parent.getOrCreateNode(ElementUtils.generateNodeId(e), SingleElementNode.class); holder.setZIndex(++zIndex); holder.setKey(e.getHint(ElementHints.KEY_OBJECT)); + holder.setTypeClass(e.getHint(ElementHints.KEY_TYPE_CLASS)); List nodeHandlers = ec.getItemsByClass(SceneGraph.class); for(SceneGraph n : nodeHandlers) { diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/ElementPainter.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/ElementPainter.java index eb9e33607..ec6e8cba0 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/ElementPainter.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/ElementPainter.java @@ -558,6 +558,7 @@ public class ElementPainter extends AbstractDiagramParticipant implements Compos if (holder == null) { holder = parentNode.addNode(ElementUtils.generateNodeId(e), ConnectionNode.class); holder.setKey(e.getHint(ElementHints.KEY_OBJECT)); + holder.setTypeClass(e.getHint(ElementHints.KEY_TYPE_CLASS)); holder.setTransferableProvider(new ElementTransferableProvider(getContext(), e)); e.setHint(sgKey, holder); holder.setZIndex(parentNode.getNodeCount() + 1); @@ -569,6 +570,7 @@ public class ElementPainter extends AbstractDiagramParticipant implements Compos if (holder == null) { holder = parentNode.addNode(ElementUtils.generateNodeId(e), SingleElementNode.class); holder.setKey(e.getHint(ElementHints.KEY_OBJECT)); + holder.setTypeClass(e.getHint(ElementHints.KEY_TYPE_CLASS)); holder.setTransferableProvider(new ElementTransferableProvider(getContext(), e)); e.setHint(sgKey, holder); holder.setZIndex(parentNode.getNodeCount() + 1); diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/ElementHints.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/ElementHints.java index f272044f1..9710fab68 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/ElementHints.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/ElementHints.java @@ -101,6 +101,7 @@ public class ElementHints { /** Source of data in external data model */ public static final Key KEY_OBJECT = new KeyOf(Object.class, "OBJECT"); + public static final Key KEY_TYPE_CLASS = new KeyOf(String.class, "TYPE_CLASS"); /** * Used for identifying elements that should be ignored in all matters diff --git a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/SingleElementNode.java b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/SingleElementNode.java index beee2538a..61353557d 100644 --- a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/SingleElementNode.java +++ b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/SingleElementNode.java @@ -34,15 +34,24 @@ public class SingleElementNode extends TransformNode implements InitValueSupport protected Boolean visible = Boolean.TRUE; protected Boolean hidden = Boolean.FALSE; private transient Object key; + private transient String typeClass; public void setKey(Object key) { this.key = key; } + public void setTypeClass(String typeClass) { + this.typeClass = typeClass; + } + public Object getKey() { return key; } + public String getTypeClass() { + return typeClass; + } + public void setTransferableProvider(TransferableProvider transferableProvider) { if (transferableProvider != this.transferableProvider) { if (this.transferableProvider != null)