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();
}
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();
}
}
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));
}
}
}
Aggregations