use of com.haulmont.cuba.gui.model.HasLoader in project cuba by cuba-platform.
the class RefreshAction method execute.
/**
* Executes the action.
*/
@Override
public void execute() {
if (target == null) {
throw new IllegalStateException("RefreshAction target is not set");
}
if (target.getItems() instanceof EmptyDataUnit) {
return;
}
if (!(target.getItems() instanceof ContainerDataUnit)) {
throw new IllegalStateException("RefreshAction target is null or does not implement SupportsContainerBinding");
}
CollectionContainer container = ((ContainerDataUnit) target.getItems()).getContainer();
if (container == null) {
throw new IllegalStateException("RefreshAction target is not bound to CollectionContainer");
}
DataLoader loader = null;
if (container instanceof HasLoader) {
loader = ((HasLoader) container).getLoader();
}
if (loader != null) {
DataContext dataContext = loader.getDataContext();
if (dataContext != null) {
for (Object entity : container.getItems()) {
dataContext.evict((Entity) entity);
}
}
loader.load();
} else {
log.warn("RefreshAction '{}' target container has no loader, refresh is impossible", getId());
}
}
Aggregations