Xcos: Mixed (Implicit-Explicit) superblocks I/O blocks produced warnings 30/3730/2
Clément DAVID [Tue, 5 Apr 2011 14:12:17 +0000 (16:12 +0200)]
Bug: 8735
Change-Id: I5956a0ed1c4cdd69c0301e8a7c9aca0b0b1f52fa

scilab/CHANGES_5.3.X
scilab/modules/xcos/src/java/org/scilab/modules/xcos/block/SuperBlock.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/utils/XcosMessages.java
scilab/modules/xcos/tests/nonreg_tests/bug_8735.tst [new file with mode: 0644]
scilab/modules/xcos/tests/nonreg_tests/bug_8735.xcos [new file with mode: 0644]

index 06a2779..976074c 100644 (file)
@@ -70,6 +70,9 @@ Xcos:
 
 * bug 8692 fixed - Null block parameters was not checked before encoding.
 
+* bug 8735 fixed - Mixed (Implicit-Explicit) superblocks I/O blocks produced 
+                   warnings.
+
 * bug 9024 fixed - Opening a non existing file lead to palette closing issues.
 
 * bug 9077 fixed - Automotive Suspension demo was modified on loading.
index de2daae..8ee844b 100644 (file)
@@ -379,6 +379,19 @@ public final class SuperBlock extends BasicBlock {
        }
        
        /**
+        * @param <T> The type to work on
+        * @param klass the class instance list to work on
+        * @return list of typed block
+        */
+       protected < T extends BasicBlock> List<T> getAllTypedBlock(Class<T>[] klasses) {
+               final List<T> list = new ArrayList<T>();
+               for (Class<T> klass : klasses) {
+                       list.addAll(getAllTypedBlock(klass));
+               }
+               return list;
+       }
+       
+       /**
         * @return list of input explicit block
         */
        @Deprecated
@@ -467,10 +480,14 @@ public final class SuperBlock extends BasicBlock {
        /**
         * force blocks update
         */
+       @SuppressWarnings("unchecked")
        public void updateAllBlocksColor() {
-               for (IOBlocks block : IOBlocks.values()) {
-                       updateBlocksColor(getAllTypedBlock(block.getReferencedClass()));
-               }
+               updateBlocksColor(getAllTypedBlock(new Class[] {ExplicitInBlock.class, ImplicitInBlock.class}));
+               updateBlocksColor(getAllTypedBlock(new Class[] {ExplicitOutBlock.class, ImplicitOutBlock.class}));
+               
+               updateBlocksColor(getAllTypedBlock(EventInBlock.class));
+               updateBlocksColor(getAllTypedBlock(EventOutBlock.class));
+               
        }
 
        /**
@@ -495,7 +512,7 @@ public final class SuperBlock extends BasicBlock {
                                final int index = (int) data.getRealPart()[0][0];
                                if (index > countUnique || isDone[index - 1]) {
                                        child.getAsComponent().setCellWarning(blocks.get(i),
-                                                       "Wrong port number");
+                                                       XcosMessages.WRONG_PORT_NUMBER);
                                } else {
                                        isDone[index - 1] = true;
                                        child.getAsComponent().setCellWarning(blocks.get(i), null);
index 7e6f5ed..7dbbad6 100644 (file)
@@ -274,6 +274,9 @@ public final class XcosMessages {
     /* Blocks values */
     public static final String BLOCK_FROM = Messages.gettext("From %s");
     public static final String BLOCK_GOTO = Messages.gettext("Goto %s");
+
+       /* Error checking */
+       public static final String WRONG_PORT_NUMBER =  Messages.gettext("Wrong port number");
     
 // CSON: JavadocVariable
 // CSON: LineLength
diff --git a/scilab/modules/xcos/tests/nonreg_tests/bug_8735.tst b/scilab/modules/xcos/tests/nonreg_tests/bug_8735.tst
new file mode 100644 (file)
index 0000000..798442b
--- /dev/null
@@ -0,0 +1,21 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Clément DAVID
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- INTERACTIVE TEST -->
+// <-- TEST WITH XCOS -->
+//
+// <-- Non-regression test for bug 8735 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=8735
+//
+// <-- Short Description -->
+// Mixed (Implicit-Explicit) superblocks I/O blocks produced warnings
+
+xcos(SCI + "/modules/xcos/tests/nonreg_tests/bug_8735.xcos");
+// Open the super-block, check that it does not contains errors
+
diff --git a/scilab/modules/xcos/tests/nonreg_tests/bug_8735.xcos b/scilab/modules/xcos/tests/nonreg_tests/bug_8735.xcos
new file mode 100644 (file)
index 0000000..5ce5816
Binary files /dev/null and b/scilab/modules/xcos/tests/nonreg_tests/bug_8735.xcos differ