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();
}
}
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;
}
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);
}
}
}
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;
}
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;
}
Aggregations