]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/DefinedElementFactory.java
Configurable prefix and suffix text for monitors
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / adapter / DefinedElementFactory.java
index 03250d726c403ee9a864c3407584c7cb717e979b..d58f383e2aea334eabb88a62f9c242661e5b6b44 100644 (file)
@@ -20,6 +20,8 @@ import java.util.concurrent.atomic.AtomicInteger;
 import org.simantics.databoard.Bindings;
 import org.simantics.db.AsyncReadGraph;
 import org.simantics.db.Resource;
+import org.simantics.db.common.primitiverequest.PossibleAdapter;
+import org.simantics.db.common.procedure.adapter.AsyncProcedureAdapter;
 import org.simantics.db.common.procedure.adapter.ProcedureAdapter;
 import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener;
 import org.simantics.db.common.procedure.guarded.GuardedAsyncProcedureWrapper;
@@ -37,15 +39,14 @@ import org.simantics.g2d.diagram.IDiagram;
 import org.simantics.g2d.element.ElementClass;
 import org.simantics.g2d.element.ElementUtils;
 import org.simantics.g2d.element.IElement;
+import org.simantics.g2d.element.handler.impl.DefaultParameters;
 import org.simantics.g2d.element.handler.impl.DefaultTransform;
 import org.simantics.g2d.element.handler.impl.ObjectTerminal;
 import org.simantics.g2d.element.handler.impl.SimpleElementLayers;
 import org.simantics.g2d.element.handler.impl.StaticObjectAdapter;
 import org.simantics.g2d.element.handler.impl.StaticSymbolImageInitializer;
 import org.simantics.g2d.element.handler.impl.StaticSymbolImpl;
-import org.simantics.g2d.element.handler.impl.Terminals;
 import org.simantics.g2d.element.handler.impl.TextImpl;
-import org.simantics.g2d.elementclass.ImageClass;
 import org.simantics.g2d.elementclass.PlainElementPropertySetter;
 import org.simantics.g2d.tooltip.TerminalTooltipProvider;
 import org.simantics.g2d.tooltip.TooltipParticipant;
@@ -228,10 +229,11 @@ public class DefinedElementFactory extends ElementFactoryAdapter {
                                             TextImpl.INSTANCE,
                                             new StaticObjectAdapter(elementType),
                                             DefaultTransform.INSTANCE,
+                                            DefaultParameters.INSTANCE,
                                             StaticSymbolImageInitializer.INSTANCE,
                                             new StaticSymbolImpl(img),
-                                            ImageClass.ImageElementHandler.INSTANCE,
-                                            new Terminals(terminals),
+                                            DefinedElementHandler.INSTANCE,
+                                            new DefinedElementTerminals(terminals),
                                             SimpleElementLayers.INSTANCE,
                                             PlainElementPropertySetter.INSTANCE
                                             ).setId(id));
@@ -257,7 +259,19 @@ public class DefinedElementFactory extends ElementFactoryAdapter {
         // This is needed for terminal tooltips.
         e.setHint(TooltipParticipant.TOOLTIP_KEY, TerminalTooltipProvider.INSTANCE);
 
-        GuardedAsyncProcedureWrapper<IElement> guard = new GuardedAsyncProcedureWrapper<IElement>(procedure, 1);
+        graph.asyncRequest(new PossibleAdapter<ElementFactory>(element, ElementFactory.class), new AsyncProcedureAdapter<ElementFactory>() {
+            @Override
+            public void execute(AsyncReadGraph graph, ElementFactory factory) {
+                if (factory != null) {
+                    graph.asyncRequest(new GetElementClassRequest(factory, element, canvas, diagram));
+                }
+            }
+        });
+
+        ElementFactoryUtil.readParameters(graph, element, e);
+
+        GuardedAsyncProcedureWrapper<IElement> guard = new GuardedAsyncProcedureWrapper<IElement>(procedure, 2);
+        ElementFactoryUtil.loadLayersForElement(graph, diagram, e, element, guard);
         ElementFactoryUtil.readTransform(graph, element, e, guard);
 
 //        graph.asyncRequest(new SafeName(resource), new ProcedureAdapter<String>() {