@Override public void write(WidgetReference entity, JsonGenerator jg) throws IOException { jg.writeStartObject(); jg.writeStringField("name", entity.getName()); String category = entity.getCategory(); if (StringUtils.isNotBlank(category)) { jg.writeStringField("category", category); } 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; }
/** * 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(); }
protected WidgetDefinition lookupWidget(LayoutDefinition layoutDef, WidgetReference widgetRef) { String widgetName = widgetRef.getName(); WidgetDefinition wDef = null; if (layoutDef != null) { wDef = layoutDef.getWidgetDefinition(widgetName); if (wDef != null && wDef.getType() == null) { // consider it's a reference for a global widget wDef = null; } } if (wDef == null) { // try in global registry wDef = lookupWidget(widgetRef); } return wDef; }
protected WidgetDefinition lookupWidget(WidgetReference widgetRef) { String widgetName = widgetRef.getName(); String cat = widgetRef.getCategory(); WidgetDefinition wDef; if (StringUtils.isBlank(cat)) { wDef = getWidgetDefinition(widgetName); } else { wDef = getLayoutStore().getWidgetDefinition(cat, widgetName); } if (wDef != null) { wDef.setGlobal(true); } return wDef; }
for (WidgetReference widget : subWidgetRefs) { if (widget != null) { builder.append(widget.getName() + "(" + widget.getCategory() + ")").append(",");
protected WidgetDefinition getWidgetDefinition(WidgetReference widgetReference, String category, LayoutDefinition layoutDefinition, LayoutConversionContext ctx, List<WidgetDefinitionConverter> widgetConverters) { String widgetName = widgetReference.getName(); WidgetDefinition widgetDefinition = layoutDefinition.getWidgetDefinition(widgetName); if (widgetDefinition == null) { String cat = widgetReference.getCategory(); if (cat == null) { cat = category; } widgetDefinition = webLayoutManager.getWidgetDefinition(cat, widgetName); } if (widgetDefinition == null) { log.error(String.format("No definition found for widget '%s' in layout '%s' => cannot export", widgetName, layoutDefinition.getName())); } else { if (widgetConverters != null) { for (WidgetDefinitionConverter conv : widgetConverters) { widgetDefinition = conv.getWidgetDefinition(widgetDefinition, ctx); } } } return widgetDefinition; }