use of com.haulmont.cuba.gui.components.StreamResource in project cuba by cuba-platform.
the class WebImage method createImageResource.
protected Resource createImageResource(final Object resourceObject) {
if (resourceObject == null) {
return null;
}
if (resourceObject instanceof FileDescriptor) {
FileDescriptorResource imageResource = createResource(FileDescriptorResource.class);
imageResource.setFileDescriptor((FileDescriptor) resourceObject);
return imageResource;
}
if (resourceObject instanceof byte[]) {
StreamResource imageResource = createResource(StreamResource.class);
Supplier<InputStream> streamSupplier = () -> new ByteArrayDataProvider((byte[]) resourceObject).provide();
imageResource.setStreamSupplier(streamSupplier);
return imageResource;
}
throw new GuiDevelopmentException("The Image component supports only FileDescriptor and byte[] datasource property value binding", getFrame().getId());
}
Aggregations