X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.g3d%2Fsrc%2Forg%2Fsimantics%2Fg3d%2Fscl%2FScriptNodeMap.java;h=fc63fffc381cb2b5cb8da82d4ee349828496aa3d;hb=e7804ee146821cf2ea38e4671c5efdeaf73bf479;hp=b7a7de03e8b52f244e42aa49f45b73e308f8c389;hpb=1d826bb0c72c83895289b905fe0da9583a79c57b;p=simantics%2F3d.git diff --git a/org.simantics.g3d/src/org/simantics/g3d/scl/ScriptNodeMap.java b/org.simantics.g3d/src/org/simantics/g3d/scl/ScriptNodeMap.java index b7a7de03..fc63fffc 100644 --- a/org.simantics.g3d/src/org/simantics/g3d/scl/ScriptNodeMap.java +++ b/org.simantics.g3d/src/org/simantics/g3d/scl/ScriptNodeMap.java @@ -27,6 +27,8 @@ import org.simantics.objmap.graph.IMapping; import org.simantics.objmap.graph.IMappingListener; import org.simantics.utils.datastructures.MapSet; import org.simantics.utils.datastructures.Pair; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * NodeMap implementation used with SCL scripts. @@ -44,7 +46,7 @@ import org.simantics.utils.datastructures.Pair; */ public abstract class ScriptNodeMap implements NodeMap, IMappingListener, NodeListener { - private static final boolean DEBUG = false; + private static final Logger LOGGER = LoggerFactory.getLogger(ScriptNodeMap.class); protected RequestProcessor session; protected IMapping mapping; @@ -126,7 +128,7 @@ public abstract class ScriptNodeMap implements NodeMap @SuppressWarnings("unchecked") private void receiveAdd(E node, String id, boolean db) { - if (DEBUG) System.out.println("receiveAdd " + debugString(node) + " " + id + " " + db); + if (LOGGER.isTraceEnabled()) LOGGER.trace("receiveAdd " + debugString(node) + " " + id + " " + db); synchronized (syncMutex) { for (Pair n : added) { if (n.first.equals(node)) @@ -143,7 +145,7 @@ public abstract class ScriptNodeMap implements NodeMap @SuppressWarnings("unchecked") private void receiveRemove(E node, String id, boolean db) { - if (DEBUG) System.out.println("receiveRemove " + debugString(node) + " " + id + " " + db); + if (LOGGER.isTraceEnabled()) LOGGER.trace("receiveRemove " + debugString(node) + " " + id + " " + db); synchronized (syncMutex) { for (Pair n : removed) { if (n.first.equals(node)) @@ -158,7 +160,7 @@ public abstract class ScriptNodeMap implements NodeMap } private void receiveUpdate(E node, String id, boolean db) { - if (DEBUG) System.out.println("receiveUpdate " + debugString(node) + " " + id + " " + db); + if (LOGGER.isTraceEnabled()) LOGGER.trace("receiveUpdate " + debugString(node) + " " + id + " " + db); synchronized (syncMutex) { // for (Pair n : updated) { // if (n.first.equals(node)) @@ -190,7 +192,7 @@ public abstract class ScriptNodeMap implements NodeMap @Override public void perform(WriteGraph graph) throws DatabaseException { - if (DEBUG) System.out.println("Commit " + commitMessage); + if (LOGGER.isTraceEnabled()) LOGGER.trace("Commit " + commitMessage); if (commitMessage != null) { Layer0Utils.addCommentMetadata(graph, commitMessage); graph.markUndoPoint(); @@ -204,12 +206,12 @@ public abstract class ScriptNodeMap implements NodeMap protected void commit(WriteGraph graph) throws DatabaseException { synchronized(syncMutex) { - if (DEBUG) System.out.println("Commit"); + if (LOGGER.isTraceEnabled()) LOGGER.trace("Commit"); graphUpdates = true; mapping.updateDomain(graph); graphUpdates = false; clearDeletes(); - if (DEBUG) System.out.println("Commit done"); + if (LOGGER.isTraceEnabled()) LOGGER.trace("Commit done"); } } @@ -219,7 +221,7 @@ public abstract class ScriptNodeMap implements NodeMap public void domainModified() { if (graphUpdates) return; - if (DEBUG)System.out.println("domainModified"); + if (LOGGER.isTraceEnabled()) LOGGER.trace("domainModified"); // FIXME : this is called by IMapping id DB thread dirty = true; // session.asyncRequest(new ReadRequest() { @@ -234,7 +236,7 @@ public abstract class ScriptNodeMap implements NodeMap } protected void reset(ReadGraph graph) throws MappingException { - if (DEBUG) System.out.println("Reset"); + if (LOGGER.isTraceEnabled()) LOGGER.trace("Reset"); synchronized (syncMutex) { graphUpdates = true; mapping.getRangeModified().clear(); @@ -247,7 +249,7 @@ public abstract class ScriptNodeMap implements NodeMap } protected void update(ReadGraph graph) throws DatabaseException { - if (DEBUG) System.out.println("Graph update start"); + if (LOGGER.isTraceEnabled()) LOGGER.trace("Graph update start"); synchronized (syncMutex) { graphUpdates = true; for (DBObject domainObject : mapping.getDomainModified()) { @@ -267,7 +269,7 @@ public abstract class ScriptNodeMap implements NodeMap //if (mapping.isRangeModified() && !runUndo) // FIXME : redo? if (mapping.isRangeModified()) commit((String)null); - if (DEBUG) System.out.println("Graph update done"); + if (LOGGER.isTraceEnabled()) LOGGER.trace("Graph update done"); } @Override @@ -324,10 +326,10 @@ public abstract class ScriptNodeMap implements NodeMap for (Pair n : added) { deleteUC.remove(n.first); } - if (DEBUG && deleteUC.size() > 0) { - System.out.println("Delete sync"); + if (LOGGER.isTraceEnabled() && deleteUC.size() > 0) { + LOGGER.trace("Delete sync"); for (E n : delete) { - System.out.println(debugString(n)); + LOGGER.trace(debugString(n)); } } delete.addAll(deleteUC); @@ -339,9 +341,9 @@ public abstract class ScriptNodeMap implements NodeMap */ @SuppressWarnings("unused") protected void clearDeletes() { - if (DEBUG && delete.size() > 0) System.out.println("Delete"); + if (LOGGER.isTraceEnabled() && delete.size() > 0) LOGGER.trace("Delete"); for (E n : delete) { - if (DEBUG) System.out.println(debugString(n)); + if (LOGGER.isTraceEnabled()) LOGGER.trace(debugString(n)); mapping.getRange().remove(n); } delete.clear(); @@ -512,7 +514,7 @@ public abstract class ScriptNodeMap implements NodeMap @Override public void nodeAdded(ParentNode node, INode child, String rel) { - if (DEBUG) System.out.println("Node added " + child + " parent " + node); + if (LOGGER.isTraceEnabled()) LOGGER.trace("Node added " + child + " parent " + node); //receiveAdd((E)child, rel ,graphUpdates); receiveAdd((E)child, rel ,graphModified.contains(node)); @@ -522,7 +524,7 @@ public abstract class ScriptNodeMap implements NodeMap @Override public void nodeRemoved(ParentNode node, INode child, String rel) { - if (DEBUG) System.out.println("Node removed " + child + " parent " + node); + if (LOGGER.isTraceEnabled()) LOGGER.trace("Node removed " + child + " parent " + node); //receiveRemove((E)child, rel, graphUpdates); receiveRemove((E)child, rel, graphModified.contains(node));