Search in sources :

Example 1 with HierarchicalDsWrapper

use of com.haulmont.cuba.web.gui.data.HierarchicalDsWrapper in project cuba by cuba-platform.

the class WebTree method setDatasource.

@Override
public void setDatasource(HierarchicalDatasource datasource) {
    Preconditions.checkNotNullArgument(datasource, "datasource is null");
    if (this.datasource != null) {
        throw new UnsupportedOperationException("Changing datasource is not supported by the Tree component");
    }
    this.datasource = datasource;
    this.hierarchyProperty = datasource.getHierarchyPropertyName();
    collectionDsListenersWrapper = createCollectionDsListenersWrapper();
    component.setContainerDataSource(new HierarchicalDsWrapper(datasource, collectionDsListenersWrapper));
    tryToAssignCaptionProperty();
    Security security = AppBeans.get(Security.NAME);
    if (security.isSpecificPermitted(ShowInfoAction.ACTION_PERMISSION)) {
        ShowInfoAction action = (ShowInfoAction) getAction(ShowInfoAction.ACTION_ID);
        if (action == null) {
            action = new ShowInfoAction();
            addAction(action);
        }
        action.setDatasource(datasource);
    }
    collectionDsListenersWrapper.bind(datasource);
    for (Action action : getActions()) {
        action.refreshState();
    }
    assignAutoDebugId();
}
Also used : ShowInfoAction(com.haulmont.cuba.gui.components.ShowInfoAction) ShowInfoAction(com.haulmont.cuba.gui.components.ShowInfoAction) Action(com.haulmont.cuba.gui.components.Action) Security(com.haulmont.cuba.core.global.Security) HierarchicalDsWrapper(com.haulmont.cuba.web.gui.data.HierarchicalDsWrapper)

Example 2 with HierarchicalDsWrapper

use of com.haulmont.cuba.web.gui.data.HierarchicalDsWrapper in project cuba by cuba-platform.

the class WebWidgetsTree method setDatasource.

@Override
public void setDatasource(HierarchicalDatasource datasource) {
    Preconditions.checkNotNullArgument(datasource, "datasource is null");
    if (this.datasource != null) {
        throw new UnsupportedOperationException("Changing datasource is not supported by the WidgetsTree component");
    }
    this.datasource = datasource;
    this.hierarchyProperty = datasource.getHierarchyPropertyName();
    collectionDsListenersWrapper = createCollectionDsListenersWrapper();
    HierarchicalDsWrapper wrapper = new HierarchicalDsWrapper(datasource, collectionDsListenersWrapper);
    component.setContainerDataSource(wrapper);
    for (Action action : getActions()) {
        action.refreshState();
    }
}
Also used : Action(com.haulmont.cuba.gui.components.Action) HierarchicalDsWrapper(com.haulmont.cuba.web.gui.data.HierarchicalDsWrapper)

Example 3 with HierarchicalDsWrapper

use of com.haulmont.cuba.web.gui.data.HierarchicalDsWrapper in project cuba by cuba-platform.

the class WebTree method tryToAssignCaptionProperty.

protected void tryToAssignCaptionProperty() {
    if (datasource != null && captionProperty != null && captionMode == CaptionMode.PROPERTY) {
        MetaPropertyPath propertyPath = datasource.getMetaClass().getPropertyPath(captionProperty);
        if (propertyPath != null && component.getContainerDataSource() != null) {
            ((HierarchicalDsWrapper) component.getContainerDataSource()).addProperty(propertyPath);
            component.setItemCaptionPropertyId(propertyPath);
        } else {
            throw new IllegalArgumentException(String.format("Can't find property for given caption property: %s", captionProperty));
        }
    }
}
Also used : MetaPropertyPath(com.haulmont.chile.core.model.MetaPropertyPath) HierarchicalDsWrapper(com.haulmont.cuba.web.gui.data.HierarchicalDsWrapper)

Aggregations

HierarchicalDsWrapper (com.haulmont.cuba.web.gui.data.HierarchicalDsWrapper)3 Action (com.haulmont.cuba.gui.components.Action)2 MetaPropertyPath (com.haulmont.chile.core.model.MetaPropertyPath)1 Security (com.haulmont.cuba.core.global.Security)1 ShowInfoAction (com.haulmont.cuba.gui.components.ShowInfoAction)1