use of com.haulmont.chile.core.model.MetaPropertyPath in project cuba by cuba-platform.
the class DesktopPickerField method checkDatasourceProperty.
public void checkDatasourceProperty(Datasource datasource, String property) {
checkNotNullArgument(datasource);
checkNotNullArgument(property);
MetaPropertyPath metaPropertyPath = getResolvedMetaPropertyPath(datasource.getMetaClass(), property);
if (!metaPropertyPath.getRange().isClass()) {
throw new DevelopmentException(String.format("property '%s.%s' should have Entity type", datasource.getMetaClass().getName(), property));
}
}
use of com.haulmont.chile.core.model.MetaPropertyPath in project cuba by cuba-platform.
the class StatisticsWindow method setNode.
protected void setNode(JmxInstance currentNode) {
statisticsDs.clear();
startTime = System.currentTimeMillis();
statisticsDs.refresh(ParamsMap.of("node", currentNode, "refreshPeriod", timerDelay));
statisticsDs.groupBy(new Object[] { new MetaPropertyPath(parameterClass, parameterClass.getPropertyNN("parameterGroup")) });
paramsTable.expandAll();
}
use of com.haulmont.chile.core.model.MetaPropertyPath in project cuba by cuba-platform.
the class WebAbstractField method getResolvedMetaPropertyPath.
protected MetaPropertyPath getResolvedMetaPropertyPath(MetaClass metaClass, String property) {
MetaPropertyPath metaPropertyPath = AppBeans.get(MetadataTools.NAME, MetadataTools.class).resolveMetaPropertyPath(metaClass, property);
Preconditions.checkNotNullArgument(metaPropertyPath, "Could not resolve property path '%s' in '%s'", property, metaClass);
return metaPropertyPath;
}
use of com.haulmont.chile.core.model.MetaPropertyPath in project cuba by cuba-platform.
the class WebAbstractTable method getPropertyColumns.
protected List<MetaPropertyPath> getPropertyColumns() {
List<MetaPropertyPath> result = new ArrayList<>();
MetaClass metaClass = datasource.getMetaClass();
for (Column column : columnsOrder) {
if (column.getId() instanceof MetaPropertyPath) {
MetaPropertyPath propertyPath = (MetaPropertyPath) column.getId();
if (security.isEntityAttrReadPermitted(metaClass, propertyPath.toString())) {
result.add((MetaPropertyPath) column.getId());
}
}
}
return result;
}
use of com.haulmont.chile.core.model.MetaPropertyPath in project cuba by cuba-platform.
the class WebAbstractTable method applyColumnSettings.
protected void applyColumnSettings(Element element) {
final Element columnsElem = element.element("columns");
Object[] oldColumns = component.getVisibleColumns();
List<Object> newColumns = new ArrayList<>();
// add columns from saved settings
for (Element colElem : Dom4j.elements(columnsElem, "columns")) {
for (Object column : oldColumns) {
if (column.toString().equals(colElem.attributeValue("id"))) {
newColumns.add(column);
String width = colElem.attributeValue("width");
if (width != null) {
component.setColumnWidth(column, Integer.parseInt(width));
} else {
component.setColumnWidth(column, -1);
}
String visible = colElem.attributeValue("visible");
if (visible != null) {
if (component.isColumnCollapsingAllowed()) {
// throws exception if not
component.setColumnCollapsed(column, !Boolean.parseBoolean(visible));
}
}
break;
}
}
}
// add columns not saved in settings (perhaps new)
for (Object column : oldColumns) {
if (!newColumns.contains(column)) {
newColumns.add(column);
}
}
// if the table contains only one column, always show it
if (newColumns.size() == 1) {
if (component.isColumnCollapsingAllowed()) {
// throws exception if not
component.setColumnCollapsed(newColumns.get(0), false);
}
}
component.setVisibleColumns(newColumns.toArray());
if (isSortable()) {
// apply sorting
String sortProp = columnsElem.attributeValue("sortProperty");
if (!StringUtils.isEmpty(sortProp)) {
MetaPropertyPath sortProperty = datasource.getMetaClass().getPropertyPath(sortProp);
if (newColumns.contains(sortProperty)) {
boolean sortAscending = Boolean.parseBoolean(columnsElem.attributeValue("sortAscending"));
component.setSortContainerPropertyId(null);
component.setSortAscending(sortAscending);
component.setSortContainerPropertyId(sortProperty);
}
} else {
component.setSortContainerPropertyId(null);
}
}
}
Aggregations