Make searching for next section part more robust.
[lgpl/argeo-commons.git] / org.argeo.cms.ui / src / org / argeo / cms / ui / viewers / Section.java
index 6f870509981ccc180f2ef5b20625864e1a55f47b..88585e18506844551527d98f29b96db63459337a 100644 (file)
@@ -13,6 +13,7 @@ import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 
+/** A structured UI related to a JCR context. */
 public class Section extends JcrComposite {
        private static final long serialVersionUID = -5933796173755739207L;
 
@@ -94,9 +95,9 @@ public class Section extends JcrComposite {
        public SectionPart getSectionPart(String partId) {
                for (Control child : getChildren()) {
                        if (child instanceof SectionPart) {
-                               SectionPart paragraph = (SectionPart) child;
-                               if (paragraph.getPartId().equals(partId))
-                                       return paragraph;
+                               SectionPart sectionPart = (SectionPart) child;
+                               if (sectionPart.getPartId().equals(partId))
+                                       return sectionPart;
                        }
                }
                return null;
@@ -105,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;
        }