Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit 7fd57ab81828eaa1594090fdf9555ea5bb8684e5 1 parent eb43c5a
Anahide Tchertchian atchertchian authored
7 nuxeo-platform-forms-layout-api/src/main/java/org/nuxeo/ecm/platform/forms/layout/api/LayoutDefinition.java
@@ -127,4 +127,11 @@
127 127 */
128 128 LayoutDefinition clone();
129 129
  130 + /**
  131 + * Returns true if all widget references in this layout are empty
  132 + *
  133 + * @since 5.6
  134 + */
  135 + boolean isEmpty();
  136 +
130 137 }
19 ...rm-forms-layout-api/src/main/java/org/nuxeo/ecm/platform/forms/layout/api/impl/LayoutDefinitionImpl.java
@@ -27,6 +27,7 @@
27 27 import org.nuxeo.ecm.platform.forms.layout.api.LayoutRowDefinition;
28 28 import org.nuxeo.ecm.platform.forms.layout.api.RenderingInfo;
29 29 import org.nuxeo.ecm.platform.forms.layout.api.WidgetDefinition;
  30 +import org.nuxeo.ecm.platform.forms.layout.api.WidgetReference;
30 31
31 32 /**
32 33 * Default implementation for a layout definition.
@@ -262,4 +263,22 @@ public LayoutDefinition clone() {
262 263 return clone;
263 264 }
264 265
  266 + public boolean isEmpty() {
  267 + LayoutRowDefinition[] rows = getRows();
  268 + if (rows == null) {
  269 + return true;
  270 + }
  271 + for (LayoutRowDefinition row : rows) {
  272 + WidgetReference[] refs = row.getWidgetReferences();
  273 + if (refs != null) {
  274 + for (WidgetReference ref : refs) {
  275 + if (ref.getName() != null && !ref.getName().isEmpty()) {
  276 + return false;
  277 + }
  278 + }
  279 + }
  280 + }
  281 + return true;
  282 + }
  283 +
265 284 }

0 comments on commit 7fd57ab

Please sign in to comment.
Something went wrong with that request. Please try again.