pl.fhframework.model.forms.optimized.TableOptimized Maven / Gradle / Ivy
package pl.fhframework.model.forms.optimized;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;
import pl.fhframework.BindingResult;
import pl.fhframework.annotations.*;
import pl.fhframework.binding.*;
import pl.fhframework.core.FhBindingException;
import pl.fhframework.core.FhException;
import pl.fhframework.core.forms.IHasBoundableLabel;
import pl.fhframework.core.logging.FhLogger;
import pl.fhframework.core.util.CollectionsUtils;
import pl.fhframework.events.IEventSource;
import pl.fhframework.events.IEventSourceContainer;
import pl.fhframework.model.dto.ElementChanges;
import pl.fhframework.model.dto.InMessageEventData;
import pl.fhframework.model.dto.ValueChange;
import pl.fhframework.model.forms.Iterator;
import pl.fhframework.model.forms.*;
import pl.fhframework.model.forms.attribute.RowHeight;
import pl.fhframework.model.forms.attribute.TableGrid;
import pl.fhframework.model.forms.attribute.TableStripes;
import pl.fhframework.model.forms.designer.BindingExpressionDesignerPreviewProvider;
import pl.fhframework.model.forms.designer.IDesignerEventListener;
import pl.fhframework.model.forms.table.LowLevelRowMetadata;
import pl.fhframework.model.forms.table.RowIteratorMetadata;
import pl.fhframework.model.forms.TableRowOptimized;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import static pl.fhframework.annotations.DesignerXMLProperty.PropertyFunctionalArea.*;
/**
* Table is component which describes and operates on tabular data. Table consists of TableRowOprimized and
* ColumnOptimized components, handles user actions as well as binds model data to its elements.
* Attributes:
*
* collection
- table model
* selected
- selected row
* iterator
- bind variable used in ColumnOptimized components
* onRowClick
- server side action executed when table row is chosen
*
* Example
* {@code
* rowList::= class Car {id, name}
*
*
*
*
}
*/
@Control(parents = {Tab.class, GroupingComponent.class, Row.class, Form.class, Repeater.class}, invalidParents = {TableOptimized.class}, canBeDesigned = true)
@DocumentedComponent(category = DocumentedComponent.Category.TABLE_AND_TREE, documentationExample = true, value = "TableOptimized", icon = "fa fa-table")
public class TableOptimized extends Repeater implements ITabular, IChangeableByClient, IEventSourceContainer, IRowNumberOffsetSupplier, Boundable, CompactLayout, IDesignerEventListener, IHasBoundableLabel {
protected static final String LABEL_ATTR = "label";
@Getter
@Setter
@XMLProperty
@DocumentedComponentAttribute(defaultValue = "false", value = "Determines if multiselect is enabled in table. If multiselect is set to true, selectedElement has to be set to Collection.")
@DesignerXMLProperty(functionalArea = SPECIFIC, priority = 10)
private boolean multiselect;
@Getter
@Setter
@XMLProperty
@DocumentedComponentAttribute(defaultValue = "false", value = "Determines if horizontal scrolling is enabled in table.")
@DesignerXMLProperty(functionalArea = LOOK_AND_STYLE, priority = 68)
private boolean horizontalScrolling;
@Getter
@Setter
@XMLProperty
@DocumentedComponentAttribute(value = "Allows row selection using checkbox. Works only if multiselect is also enabled.")
@DesignerXMLProperty(functionalArea = SPECIFIC, priority = 5)
private boolean selectionCheckboxes;
@Getter
@Setter
@XMLProperty
@DocumentedComponentAttribute(value = "Enables row selection feature.")
@DesignerXMLProperty(functionalArea = SPECIFIC, priority = 15)
private boolean selectable;
@Getter
@Setter
@XMLProperty
@DocumentedComponentAttribute(value = "Enables fixed headers when scrolling. Works only if table height is set.")
@DesignerXMLProperty(functionalArea = SPECIFIC, priority = 15)
protected boolean fixedHeader;
@JsonIgnore
@Getter
@Setter
@XMLProperty(SELECTED)
@DocumentedComponentAttribute(boundable = true, value = "Selected table row")
@DesignerXMLProperty(functionalArea = CONTENT, priority = 11, bindingOnly = true)
protected ModelBinding selectedElementBinding;
@Getter
// @JsonView(IWithSubelements.class)
protected List