Make searching for next section part more robust.
authorMathieu Baudier <mbaudier@argeo.org>
Tue, 2 Feb 2021 13:16:19 +0000 (14:16 +0100)
committerMathieu Baudier <mbaudier@argeo.org>
Tue, 2 Feb 2021 13:16:19 +0000 (14:16 +0100)
org.argeo.cms.ui/src/org/argeo/cms/ui/viewers/Section.java

index 730ba671d71def6011c3d025a8beed39fb8cc58b..88585e18506844551527d98f29b96db63459337a 100644 (file)
@@ -106,13 +106,20 @@ public class Section extends JcrComposite {
        public SectionPart nextSectionPart(SectionPart sectionPart) {
                Control[] children = getChildren();
                for (int i = 0; i < children.length; i++) {
-                       if (sectionPart == children[i])
-                               if (i + 1 < children.length) {
-                                       Composite next = (Composite) children[i + 1];
-                                       return (SectionPart) next;
-                               } else {
-                                       // next section
+                       if (sectionPart == children[i]) {
+                               for (int j = i + 1; j < children.length; j++) {
+                                       if (children[i + 1] instanceof SectionPart) {
+                                               return (SectionPart) children[i + 1];
+                                       }
                                }
+
+//                             if (i + 1 < children.length) {
+//                                     Composite next = (Composite) children[i + 1];
+//                                     return (SectionPart) next;
+//                             } else {
+//                                     // next section
+//                             }
+                       }
                }
                return null;
        }