1 package org.simantics.structural.synchronization.utils;
3 import java.util.Collection;
5 import org.simantics.structural.synchronization.protocol.ChildInfo;
6 import org.simantics.structural.synchronization.protocol.Connection;
7 import org.simantics.structural.synchronization.protocol.SerializedVariable;
8 import org.simantics.structural.synchronization.protocol.SynchronizationEventHandler;
9 import org.simantics.structural.synchronization.protocol.SynchronizationException;
10 import org.slf4j.Logger;
11 import org.slf4j.LoggerFactory;
13 public class DiagnosticSynchronizationEventHandler implements SynchronizationEventHandler {
15 private static final Logger LOGGER = LoggerFactory.getLogger(DiagnosticSynchronizationEventHandler.class);
19 public void beginSynchronization() {
23 public void endSynchronization() {
27 public void beginComponent(String name, String typeId,
28 Collection<SerializedVariable> properties,
29 Collection<Connection> connections, Collection<ChildInfo> children)
30 throws SynchronizationException {
31 StringBuilder indent = new StringBuilder();
32 for(int i=0;i<indentation;++i)
36 indent.append(" :: " + typeId);
37 LOGGER.info(indent.toString());
38 for(SerializedVariable var : properties) {
39 indent = new StringBuilder();
40 for(int i=0;i<=indentation;++i)
42 indent.append(SerializedVariable.print(var, indentation*2+2));
43 LOGGER.info(indent.toString());
45 for(Connection connection : connections) {
46 indent = new StringBuilder();
47 for(int i=0;i<=indentation;++i)
49 indent.append(connection);
50 LOGGER.info(indent.toString());
52 if(!children.isEmpty()) {
53 indent = new StringBuilder();
54 for(int i=0;i<=indentation;++i)
56 indent.append("Children ");
58 indent.append(children);
59 LOGGER.info(indent.toString());
65 public void endComponent() {
70 public void beginType(String id, Collection<SerializedVariable> properties) {
71 LOGGER.info("--- Type " + id + " --------------------------------");
72 for(SerializedVariable var : properties)
73 LOGGER.info(SerializedVariable.print(var, 2));
77 public void endType() {
78 LOGGER.info("----------------------------------------------------");
82 public void reportProblem(String description) {
83 LOGGER.error(description);
87 public void reportProblem(String description, Exception e) {
88 LOGGER.error(description, e);