*******************************************************************************/
package org.simantics.diagram.adapter;
+import java.util.List;
+
import org.simantics.db.AsyncReadGraph;
import org.simantics.db.Resource;
import org.simantics.db.common.primitiverequest.Adapter;
import org.simantics.diagram.synchronization.ErrorHandler;
import org.simantics.g2d.canvas.ICanvasContext;
import org.simantics.g2d.diagram.IDiagram;
+import org.simantics.g2d.diagram.handler.SubstituteElementClass;
import org.simantics.g2d.element.ElementClass;
import org.simantics.g2d.element.IElement;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @author Antti Villberg
*/
public class NodeRequest extends BaseRequest2<Resource, IElement> {
+ private static final Logger LOGGER = LoggerFactory.getLogger(NodeRequest.class);
+
final IDiagram diagram;
final Listener<IElement> loadListener;
@Override
public void exception(AsyncReadGraph graph, Throwable throwable) {
- throwable.printStackTrace();
+ LOGGER.error("Unexpected error in GetElementClassRequest", throwable);
procedure.execute(graph, null);
}
@Override
- public void execute(AsyncReadGraph graph, final ElementClass clazz) {
-
+ public void execute(AsyncReadGraph graph, ElementClass mutableClazz) {
+ List<SubstituteElementClass> substitutes = diagram.getDiagramClass().getItemsByClass(SubstituteElementClass.class);
+ for (SubstituteElementClass subs : substitutes) {
+ mutableClazz = subs.substitute(diagram, mutableClazz);
+ }
+ final ElementClass clazz = mutableClazz;
graph.asyncRequest(new SpawnRequest(canvas, clazz, data), new TransientCacheAsyncListener<IElement>() {
@Override
public void exception(AsyncReadGraph graph, Throwable throwable) {
- throwable.printStackTrace();
+ LOGGER.error("Unexpected error in SpawnRequest", throwable);
procedure.execute(graph, null);
}
factory.load(graph, canvas, diagram, data, element, new AsyncProcedure<IElement>() {
@Override
public void exception(AsyncReadGraph graph, Throwable throwable) {
- // TODO: proper logging
- throwable.printStackTrace();
+ LOGGER.error("Unexpected error in ElementFactory.load (factory=" + factory + ")", throwable);
}
@Override
public void execute(AsyncReadGraph graph, IElement result) {