Search in sources :

Example 36 with MetaPropertyPath

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));
    }
}
Also used : MetaPropertyPath(com.haulmont.chile.core.model.MetaPropertyPath)

Example 37 with MetaPropertyPath

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();
}
Also used : MetaPropertyPath(com.haulmont.chile.core.model.MetaPropertyPath)

Example 38 with MetaPropertyPath

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;
}
Also used : MetadataTools(com.haulmont.cuba.core.global.MetadataTools) MetaPropertyPath(com.haulmont.chile.core.model.MetaPropertyPath)

Example 39 with 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;
}
Also used : MetaClass(com.haulmont.chile.core.model.MetaClass) MetaPropertyPath(com.haulmont.chile.core.model.MetaPropertyPath)

Example 40 with MetaPropertyPath

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);
        }
    }
}
Also used : Element(org.dom4j.Element) MetaPropertyPath(com.haulmont.chile.core.model.MetaPropertyPath)

Aggregations

MetaPropertyPath (com.haulmont.chile.core.model.MetaPropertyPath)84 MetaClass (com.haulmont.chile.core.model.MetaClass)34 MetaProperty (com.haulmont.chile.core.model.MetaProperty)27 Element (org.dom4j.Element)16 CategoryAttribute (com.haulmont.cuba.core.entity.CategoryAttribute)11 Entity (com.haulmont.cuba.core.entity.Entity)9 MetadataTools (com.haulmont.cuba.core.global.MetadataTools)9 Datasource (com.haulmont.cuba.gui.data.Datasource)6 Table (com.haulmont.cuba.gui.components.Table)5 CollectionDatasource (com.haulmont.cuba.gui.data.CollectionDatasource)5 MessageTools (com.haulmont.cuba.core.global.MessageTools)4 Instance (com.haulmont.chile.core.model.Instance)3 Op (com.haulmont.cuba.core.global.filter.Op)3 FocusableTable (com.haulmont.cuba.desktop.sys.vcl.FocusableTable)3 GuiDevelopmentException (com.haulmont.cuba.gui.GuiDevelopmentException)3 Formatter (com.haulmont.cuba.gui.components.Formatter)3 Window (com.haulmont.cuba.gui.components.Window)3 CollectionFormatter (com.haulmont.cuba.gui.components.formatters.CollectionFormatter)3 GroupInfo (com.haulmont.cuba.gui.data.GroupInfo)3 java.util (java.util)3