Xcos I/O: decode more properties and store them
[scilab.git] / scilab / modules / xcos / src / java / org / scilab / modules / xcos / io / sax / CustomHandler.java
index c015e70..f263d78 100644 (file)
@@ -16,6 +16,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map.Entry;
 import java.util.Optional;
+import java.util.logging.Level;
 import java.util.stream.Stream;
 
 import org.scilab.modules.xcos.Kind;
@@ -26,14 +27,15 @@ import org.scilab.modules.xcos.graph.ScicosParameters;
 import org.scilab.modules.xcos.graph.model.ScicosObjectOwner;
 import org.scilab.modules.xcos.graph.model.XcosCell;
 import org.scilab.modules.xcos.graph.model.XcosCellFactory;
-import org.scilab.modules.xcos.io.sax.SAXHandler.UnresolvedReference;
+import org.scilab.modules.xcos.io.HandledElement;
+import org.scilab.modules.xcos.io.sax.XcosSAXHandler.UnresolvedReference;
 import org.scilab.modules.xcos.port.BasicPort;
 import org.scilab.modules.xcos.port.Orientation;
 import org.xml.sax.Attributes;
 
 class CustomHandler implements ScilabHandler {
 
-    private final SAXHandler saxHandler;
+    private final XcosSAXHandler saxHandler;
 
     /**
      * Default constructor
@@ -41,7 +43,7 @@ class CustomHandler implements ScilabHandler {
      * @param saxHandler
      *            the shared sax handler
      */
-    CustomHandler(SAXHandler saxHandler) {
+    CustomHandler(XcosSAXHandler saxHandler) {
         this.saxHandler = saxHandler;
     }
 
@@ -71,6 +73,10 @@ class CustomHandler implements ScilabHandler {
                 return null;
             }
             case XcosDiagram:
+                if (XcosSAXHandler.LOG.isLoggable(Level.FINER)) {
+                    XcosSAXHandler.LOG.entering(CustomHandler.class.getName(), "startElement(\"XcosDiagram\", ...)");
+                }
+
                 // do not allocate this is already allocated as #root
                 uid = saxHandler.root.getUID();
 
@@ -81,6 +87,10 @@ class CustomHandler implements ScilabHandler {
                 if (v != null) {
                     saxHandler.controller.setObjectProperty(uid, Kind.DIAGRAM, ObjectProperties.PATH, v);
                 }
+                v = atts.getValue("debugLevel");
+                if (v != null) {
+                    saxHandler.controller.setObjectProperty(uid, Kind.DIAGRAM, ObjectProperties.DEBUG_LEVEL, Integer.valueOf(v));
+                }
 
                 /*
                  * Decode simulation properties
@@ -173,6 +183,10 @@ class CustomHandler implements ScilabHandler {
                 resolve();
                 saxHandler.allChildren.pop();
                 XcosCellFactory.insertChildren(saxHandler.controller, saxHandler.root);
+
+                if (XcosSAXHandler.LOG.isLoggable(Level.FINER)) {
+                    XcosSAXHandler.LOG.exiting(CustomHandler.class.getName(), "endElement(\"XcosDiagram\")");
+                }
                 break;
             case SuperBlockDiagram:
                 resolve();