/** * Returns an identifier computed from this definition so that an identical definition will have the same id. * * @since 5.5 */ public static String computeLayoutRowDefinitionId(LayoutRowDefinition layoutRowDef) { StringBuffer builder = new StringBuffer(); builder.append(layoutRowDef.getName()).append(";"); builder.append(layoutRowDef.isSelectedByDefault()).append(";"); builder.append(layoutRowDef.isAlwaysSelected()).append(";"); WidgetReference[] widgets = layoutRowDef.getWidgetReferences(); if (widgets != null) { for (WidgetReference widget : widgets) { if (widget != null) { builder.append(widget.getName() + "(" + widget.getCategory() + ")").append(","); } } } builder.append(";"); Map<String, Map<String, Serializable>> properties = layoutRowDef.getProperties(); if (properties != null) { builder.append(properties.toString()); } builder.append(";"); Integer intValue = new Integer(builder.toString().hashCode()); return intValue.toString(); }
public int getColumns() { if (columns == null) { // compute it columns = Integer.valueOf(0); LayoutRowDefinition[] rows = getRows(); for (LayoutRowDefinition def : rows) { int current = def.getWidgetReferences().length; if (current > columns.intValue()) { columns = Integer.valueOf(current); } } } return columns.intValue(); }
for (LayoutRowDefinition layoutRowDef : rowDefinitions) { rowIndex++; writeRawDefinition(layoutRowDef, layoutRowDef.getDefaultName(rowIndex), jg); WidgetReference[] widgets = layoutRowDef.getWidgetReferences(); if (widgets != null) { widgetsToExport.addAll(Arrays.asList(widgets));
crows = new LayoutRowDefinition[rows.length]; for (int i = 0; i < rows.length; i++) { crows[i] = rows[i].clone();
@Override public int getColumns() { if (columns == null) { // compute it columns = new Integer(0); LayoutRowDefinition[] rows = getRows(); for (LayoutRowDefinition def : rows) { int current = def.getWidgetReferences().length; if (current > columns.intValue()) { columns = new Integer(current); } } } return columns.intValue(); }
protected void writeRawDefinition(LayoutRowDefinition layoutRowDef, String defaultName, JsonGenerator jg) throws IOException { jg.writeStartObject(); String name = layoutRowDef.getName(); if (name != null) { jg.writeStringField("name", name); } else if (defaultName != null) { jg.writeStringField("name", defaultName); } // fill selection info only if that's not the default value from the definition if (layoutRowDef.isAlwaysSelected()) { jg.writeBooleanField("alwaysSelected", true); } if (!layoutRowDef.isSelectedByDefault()) { jg.writeBooleanField("selectedByDefault", false); } Map<String, Map<String, Serializable>> properties = layoutRowDef.getProperties(); if (MapUtils.isNotEmpty(properties) && properties.values().stream().anyMatch(MapUtils::isNotEmpty)) { writeSerializableMapMapField("properties", cleanAndSort(properties), jg); } WidgetReference[] defWidgets = layoutRowDef.getWidgetReferences(); if (ArrayUtils.isNotEmpty(defWidgets)) { writeSerializableListField("widgets", Arrays.asList(defWidgets), jg); } jg.writeEndObject(); }
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; }