Search in sources :

Example 1 with GroupTableSettings

use of io.jmix.ui.settings.component.GroupTableSettings in project jmix by jmix-framework.

the class GroupTableSettingsBinder method applyColumnSettings.

@Override
protected void applyColumnSettings(TableSettings tableSettings, Table table) {
    super.applyColumnSettings(tableSettings, table);
    GroupTableSettings groupTableSettings = (GroupTableSettings) tableSettings;
    List<String> groupProperties = groupTableSettings.getGroupProperties();
    if (groupProperties != null) {
        MetaClass metaClass = ((EntityTableItems) table.getItems()).getEntityMetaClass();
        List<MetaPropertyPath> properties = new ArrayList<>(groupProperties.size());
        for (String id : groupProperties) {
            MetaPropertyPath property = metadataTools.resolveMetaPropertyPathOrNull(metaClass, id);
            if (property != null) {
                properties.add(property);
            } else {
                log.warn("Ignored group property '{}'", id);
            }
        }
        ((GroupTable) table).groupBy(properties.toArray());
    } else {
        ((GroupTable) table).ungroup();
    }
}
Also used : GroupTable(io.jmix.ui.component.GroupTable) JmixGroupTable(io.jmix.ui.widget.JmixGroupTable) MetaClass(io.jmix.core.metamodel.model.MetaClass) MetaPropertyPath(io.jmix.core.metamodel.model.MetaPropertyPath) ArrayList(java.util.ArrayList) EntityTableItems(io.jmix.ui.component.data.meta.EntityTableItems) GroupTableSettings(io.jmix.ui.settings.component.GroupTableSettings)

Example 2 with GroupTableSettings

use of io.jmix.ui.settings.component.GroupTableSettings in project jmix by jmix-framework.

the class LegacyGroupTableSettingsConverter method convertToComponentSettings.

@Override
public GroupTableSettings convertToComponentSettings(Element settings) {
    GroupTableSettings groupTableSettings = (GroupTableSettings) super.convertToComponentSettings(settings);
    Element groupPropertiesElem = settings.element("groupProperties");
    if (groupPropertiesElem != null) {
        List<Element> properties = groupPropertiesElem.elements("property");
        if (properties.isEmpty()) {
            return groupTableSettings;
        }
        List<String> groupProperties = new ArrayList<>(properties.size());
        for (Element property : properties) {
            groupProperties.add(property.attributeValue("id"));
        }
        groupTableSettings.setGroupProperties(groupProperties);
    }
    return groupTableSettings;
}
Also used : Element(org.dom4j.Element) ArrayList(java.util.ArrayList) GroupTableSettings(io.jmix.ui.settings.component.GroupTableSettings) CubaGroupTableSettings(com.haulmont.cuba.settings.component.CubaGroupTableSettings)

Example 3 with GroupTableSettings

use of io.jmix.ui.settings.component.GroupTableSettings in project jmix by jmix-framework.

the class LegacyGroupTableSettingsConverter method copySettingsToElement.

@Override
protected void copySettingsToElement(TableSettings tableSettings, Element element) {
    super.copySettingsToElement(tableSettings, element);
    GroupTableSettings settings = (GroupTableSettings) tableSettings;
    List<String> groupProperties = settings.getGroupProperties();
    if (groupProperties != null) {
        Element groupPropertiesElem = element.addElement("groupProperties");
        for (String property : groupProperties) {
            Element propertyElem = groupPropertiesElem.addElement("property");
            propertyElem.addAttribute("id", property);
        }
    }
}
Also used : Element(org.dom4j.Element) GroupTableSettings(io.jmix.ui.settings.component.GroupTableSettings) CubaGroupTableSettings(com.haulmont.cuba.settings.component.CubaGroupTableSettings)

Example 4 with GroupTableSettings

use of io.jmix.ui.settings.component.GroupTableSettings in project jmix by jmix-framework.

the class GroupTableSettingsBinder method getSettings.

@Override
public GroupTableSettings getSettings(Table component) {
    GroupTable groupTable = (GroupTable) component;
    GroupTableSettings groupTableSettings = (GroupTableSettings) super.getSettings(component);
    List<String> groupProperties = getGroupProperties(groupTable);
    if (!groupProperties.isEmpty()) {
        groupTableSettings.setGroupProperties(groupProperties);
    }
    return groupTableSettings;
}
Also used : GroupTable(io.jmix.ui.component.GroupTable) JmixGroupTable(io.jmix.ui.widget.JmixGroupTable) GroupTableSettings(io.jmix.ui.settings.component.GroupTableSettings)

Example 5 with GroupTableSettings

use of io.jmix.ui.settings.component.GroupTableSettings in project jmix by jmix-framework.

the class GroupTableSettingsBinder method saveSettings.

@Override
public boolean saveSettings(Table component, SettingsWrapper wrapper) {
    GroupTable groupTable = (GroupTable) component;
    GroupTableSettings groupTableSettings = wrapper.getSettings();
    boolean commonTableSettingsChanged = super.saveSettings(component, wrapper);
    boolean groupTableSettingsChanged = isGroupTableSettingsChanged(groupTable, groupTableSettings);
    if (!groupTableSettingsChanged && !commonTableSettingsChanged) {
        return false;
    }
    if (groupTableSettingsChanged) {
        // save columns settings if they were not saved
        if (groupTableSettings.getColumns() == null) {
            groupTableSettings.setColumns(getTableColumnSettings(groupTable));
        }
        groupTableSettings.setGroupProperties(getGroupProperties(groupTable));
    }
    return true;
}
Also used : GroupTable(io.jmix.ui.component.GroupTable) JmixGroupTable(io.jmix.ui.widget.JmixGroupTable) GroupTableSettings(io.jmix.ui.settings.component.GroupTableSettings)

Aggregations

GroupTableSettings (io.jmix.ui.settings.component.GroupTableSettings)5 GroupTable (io.jmix.ui.component.GroupTable)3 JmixGroupTable (io.jmix.ui.widget.JmixGroupTable)3 CubaGroupTableSettings (com.haulmont.cuba.settings.component.CubaGroupTableSettings)2 ArrayList (java.util.ArrayList)2 Element (org.dom4j.Element)2 MetaClass (io.jmix.core.metamodel.model.MetaClass)1 MetaPropertyPath (io.jmix.core.metamodel.model.MetaPropertyPath)1 EntityTableItems (io.jmix.ui.component.data.meta.EntityTableItems)1