Search in sources :

Example 1 with BelongToFrame

use of io.jmix.ui.component.Component.BelongToFrame in project jmix by jmix-framework.

the class TableFieldFactoryImpl method createField.

@SuppressWarnings("unchecked")
@Override
public com.vaadin.v7.ui.Field<?> createField(com.vaadin.v7.data.Container container, Object itemId, Object propertyId, Component uiContext) {
    String fieldPropertyId = String.valueOf(propertyId);
    Table.Column columnConf = webTable.getColumnsInternal().get(propertyId);
    TableDataContainer tableDataContainer = (TableDataContainer) container;
    Object entity = tableDataContainer.getInternalItem(itemId);
    InstanceContainer instanceContainer = webTable.getInstanceContainer((E) entity);
    io.jmix.ui.component.Component columnComponent = createField(new ContainerValueSource(instanceContainer, fieldPropertyId), fieldPropertyId, columnConf.getXmlDescriptor());
    if (columnComponent instanceof Field) {
        Field jmixField = (Field) columnComponent;
        Map<Table.Column, String> requiredColumns = webTable.getRequiredColumnsInternal();
        if (requiredColumns != null && requiredColumns.containsKey(columnConf)) {
            jmixField.setRequired(true);
            jmixField.setRequiredMessage(requiredColumns.get(columnConf));
        }
    }
    if (!(columnComponent instanceof CheckBox)) {
        // todo get rid of concrete CheckBox class !
        columnComponent.setWidthFull();
    }
    if (columnComponent instanceof BelongToFrame) {
        BelongToFrame belongToFrame = (BelongToFrame) columnComponent;
        if (belongToFrame.getFrame() == null) {
            belongToFrame.setFrame(webTable.getFrame());
        }
    }
    applyPermissions(columnComponent);
    columnComponent.setParent(webTable);
    Component componentImpl = getComponentImplementation(columnComponent);
    if (componentImpl instanceof com.vaadin.v7.ui.Field) {
        return (com.vaadin.v7.ui.Field<?>) componentImpl;
    }
    return new EditableColumnFieldWrapper(componentImpl, columnComponent);
}
Also used : AbstractTable(io.jmix.ui.component.impl.AbstractTable) BelongToFrame(io.jmix.ui.component.Component.BelongToFrame) InstanceContainer(io.jmix.ui.model.InstanceContainer) ContainerValueSource(io.jmix.ui.component.data.value.ContainerValueSource) io.jmix.ui.component(io.jmix.ui.component) Component(com.vaadin.ui.Component)

Aggregations

Component (com.vaadin.ui.Component)1 io.jmix.ui.component (io.jmix.ui.component)1 BelongToFrame (io.jmix.ui.component.Component.BelongToFrame)1 ContainerValueSource (io.jmix.ui.component.data.value.ContainerValueSource)1 AbstractTable (io.jmix.ui.component.impl.AbstractTable)1 InstanceContainer (io.jmix.ui.model.InstanceContainer)1