(mbaudier) update code while working on generic FormPageEditor
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / viewers / AbstractPageViewer.java
index 331275c44dd3484dbd8e0bd071bfc7e08109fa58..837cf99292368b9617eeb8cecdfc39d296a57574 100644 (file)
@@ -40,6 +40,7 @@ public abstract class AbstractPageViewer extends ContentViewer implements
 
        // FIXME Added by BSinou to manage non-section Composite.
        // Is it the correct method?
+       @Deprecated
        protected AbstractPageViewer(Composite parent, int style,
                        CmsEditable cmsEditable) {
                // read only at UI level
@@ -223,6 +224,20 @@ public abstract class AbstractPageViewer extends ContentViewer implements
                page.layout(controls);
        }
 
+       /**
+        * Find the first {@link EditablePart} in the parents hierarchy of this
+        * control
+        */
+       protected EditablePart findDataParent(Control parent) {
+               if (parent instanceof EditablePart) {
+                       return (EditablePart) parent;
+               }
+               if (parent.getParent() != null)
+                       return findDataParent(parent.getParent());
+               else
+                       throw new CmsException("No data parent found");
+       }
+
        // UTILITIES
        /** Check whether the edited part is in a proper state */
        protected void checkEdited() {