use of io.jmix.ui.settings.component.TableSettings.ColumnSettings in project jmix by jmix-framework.
the class LegacyTableSettingsConverter method convertToComponentSettings.
@SuppressWarnings("unchecked")
@Override
public TableSettings convertToComponentSettings(Element settings) {
TableSettings tableSettings = createSettings();
tableSettings.setId(settings.attributeValue("name"));
String textSelection = settings.attributeValue("textSelection");
if (StringUtils.isNotBlank(textSelection)) {
tableSettings.setTextSelection(Boolean.parseBoolean(textSelection));
}
String presentationId = settings.attributeValue("presentation");
if (StringUtils.isNotBlank(presentationId) && tableSettings instanceof HasSettingsPresentation) {
((HasSettingsPresentation) tableSettings).setPresentationId(UuidProvider.fromString(presentationId));
}
Element columnsElem = settings.element("columns");
if (columnsElem != null) {
String sortProperty = columnsElem.attributeValue("sortProperty");
if (StringUtils.isNotBlank(sortProperty)) {
tableSettings.setSortProperty(sortProperty);
String sortAscending = columnsElem.attributeValue("sortAscending");
tableSettings.setSortAscending(Boolean.parseBoolean(sortAscending));
}
List<Element> columns = columnsElem.elements("columns");
List<ColumnSettings> columnsSett = new ArrayList<>(columns.size());
for (Element column : columns) {
ColumnSettings columnSett = new ColumnSettings();
columnSett.setId(column.attributeValue("id"));
String width = column.attributeValue("width");
if (StringUtils.isNotBlank(width)) {
columnSett.setWidth(Integer.parseInt(width));
}
String visible = column.attributeValue("visible");
if (StringUtils.isNotBlank(visible)) {
columnSett.setVisible(Boolean.parseBoolean(visible));
}
columnsSett.add(columnSett);
}
tableSettings.setColumns(columnsSett);
}
return tableSettings;
}
use of io.jmix.ui.settings.component.TableSettings.ColumnSettings in project jmix by jmix-framework.
the class LegacyTableSettingsConverter method copySettingsToElement.
protected void copySettingsToElement(TableSettings tableSettings, Element element) {
element.addAttribute("name", tableSettings.getId());
Boolean textSelection = tableSettings.getTextSelection();
if (textSelection != null)
element.addAttribute("textSelection", textSelection.toString());
if (tableSettings instanceof HasSettingsPresentation) {
UUID presentationId = ((HasSettingsPresentation) tableSettings).getPresentationId();
if (presentationId != null) {
element.addAttribute("presentation", presentationId.toString());
}
}
List<ColumnSettings> columns = tableSettings.getColumns();
if (columns != null) {
Element columnsElem = element.addElement("columns");
if (tableSettings.getSortProperty() != null) {
columnsElem.addAttribute("sortProperty", tableSettings.getSortProperty());
columnsElem.addAttribute("sortAscending", tableSettings.getSortAscending().toString());
}
for (ColumnSettings column : columns) {
Element columnElem = columnsElem.addElement("columns");
columnElem.addAttribute("id", column.getId());
if (column.getWidth() != null) {
columnElem.addAttribute("width", column.getWidth().toString());
}
if (column.getVisible() != null) {
columnElem.addAttribute("visible", column.getVisible().toString());
}
}
}
}
Aggregations