use of io.jmix.ui.component.GroupTable 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.component.GroupTable in project jmix by jmix-framework.
the class GroupTableLoader method loadColumns.
@Override
protected List<Table.Column> loadColumns(Table component, Element columnsElement, MetaClass metaClass, FetchPlan fetchPlan) {
List<Table.Column> columns = super.loadColumns(component, columnsElement, metaClass, fetchPlan);
Element groupElement = columnsElement.element("group");
if (groupElement != null) {
final List<Object> groupProperties = new ArrayList<>(columns.size());
List<Element> columnElements = groupElement.elements("column");
for (Element columnElement : columnElements) {
String visible = columnElement.attributeValue("visible");
if (StringUtils.isEmpty(visible) || Boolean.parseBoolean(visible)) {
Object id = loadColumnId(columnElement, metaClass);
Table.Column column = component.getColumn(id.toString());
if (column == null) {
column = loadColumn(component, columnElement, metaClass);
}
if (column.isCollapsed()) {
String msg = String.format("Can't group by collapsed column: %s", column.getId());
throw new GuiDevelopmentException(msg, context);
}
if (column instanceof GroupTable.GroupColumn && ((GroupTable.GroupColumn<?>) column).isGroupAllowed()) {
groupProperties.add(column.getId());
}
}
}
getComponentContext().addPostInitTask((context1, window) -> {
// enable grouping columns from descriptor if columnReorderingAllowed = false
boolean reorderDisabled = !component.getColumnReorderingAllowed();
component.setColumnReorderingAllowed(true);
((GroupTable) component).groupBy(groupProperties.toArray());
if (reorderDisabled) {
component.setColumnReorderingAllowed(false);
}
});
}
return columns;
}
use of io.jmix.ui.component.GroupTable 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.component.GroupTable 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