Permalink
Browse files

NXP-9892: Add API to check if a layout definition is empty

  • Loading branch information...
atchertchian committed Aug 17, 2012
1 parent eb43c5a commit 7fd57ab81828eaa1594090fdf9555ea5bb8684e5
@@ -127,4 +127,11 @@
*/
LayoutDefinition clone();
+ /**
+ * Returns true if all widget references in this layout are empty
+ *
+ * @since 5.6
+ */
+ boolean isEmpty();
+
}
@@ -27,6 +27,7 @@
import org.nuxeo.ecm.platform.forms.layout.api.LayoutRowDefinition;
import org.nuxeo.ecm.platform.forms.layout.api.RenderingInfo;
import org.nuxeo.ecm.platform.forms.layout.api.WidgetDefinition;
+import org.nuxeo.ecm.platform.forms.layout.api.WidgetReference;
/**
* Default implementation for a layout definition.
@@ -262,4 +263,22 @@ public LayoutDefinition clone() {
return clone;
}
+ public boolean isEmpty() {
+ LayoutRowDefinition[] rows = getRows();
+ if (rows == null) {
+ return true;
+ }
+ for (LayoutRowDefinition row : rows) {
+ WidgetReference[] refs = row.getWidgetReferences();
+ if (refs != null) {
+ for (WidgetReference ref : refs) {
+ if (ref.getName() != null && !ref.getName().isEmpty()) {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
+
}

0 comments on commit 7fd57ab

Please sign in to comment.