Xcos GUI: fixed Annotations loading 88/17388/3
Paul Bignier [Fri, 23 Oct 2015 15:40:15 +0000 (17:40 +0200)]
// Does not pass yet but getting closer
--> importXcosDiagram(SCI + "/modules/xcos/demos/Simple_Demo.zcos");

Change-Id: I23dfd5870043ce724a6a0b16061f4a1f0cc4604e

scilab/modules/xcos/src/java/org/scilab/modules/xcos/graph/model/XcosCellFactory.java

index 37e33ba..0dd8a11 100644 (file)
@@ -272,7 +272,11 @@ public final class XcosCellFactory {
 
     private static BasicBlock createBlock(final JavaController controller, long uid, Kind kind) {
         String[] interfaceFunction = new String[1];
-        controller.getObjectProperty(uid, kind, ObjectProperties.INTERFACE_FUNCTION, interfaceFunction);
+        if (kind == Kind.BLOCK) {
+            controller.getObjectProperty(uid, kind, ObjectProperties.INTERFACE_FUNCTION, interfaceFunction);
+        } else { // ANNOTATION
+            interfaceFunction[0] = "TEXT_f";
+        }
 
         final BlockInterFunction func = lookForInterfunction(interfaceFunction[0]);
 
@@ -317,8 +321,12 @@ public final class XcosCellFactory {
 
         /*
          * Synchronize model information back to the JGraphX data
+         *
+         * Annotations have no inputs/outputs
          */
-        insertPortChildren(controller, block);
+        if (block.getKind() == Kind.BLOCK) {
+            insertPortChildren(controller, block);
+        }
 
         String[] strUID = new String[1];
         controller.getObjectProperty(block.getUID(), block.getKind(), ObjectProperties.UID, strUID);
@@ -417,10 +425,6 @@ public final class XcosCellFactory {
      *            is the parent {@link mxCell} to modify
      */
     private static void insertPortChildren(final JavaController controller, final ObjectProperties property, final XcosCell parent) {
-        if (parent.getKind() != Kind.BLOCK) {
-            return;
-        }
-
         VectorOfScicosID modelChildren = new VectorOfScicosID();
         controller.getObjectProperty(parent.getUID(), parent.getKind(), property, modelChildren);