use of com.vaadin.terminal.StreamResource.StreamSource in project Activiti by Activiti.
the class ProfilePanel method initPicture.
protected void initPicture() {
StreamResource imageresource = new StreamResource(new StreamSource() {
private static final long serialVersionUID = 1L;
public InputStream getStream() {
return picture.getInputStream();
}
}, user.getId(), ExplorerApp.get());
imageresource.setCacheTime(0);
Embedded picture = new Embedded(null, imageresource);
picture.setType(Embedded.TYPE_IMAGE);
picture.setHeight(200, UNITS_PIXELS);
picture.setWidth(200, UNITS_PIXELS);
picture.addStyleName(ExplorerLayout.STYLE_PROFILE_PICTURE);
imageLayout.addComponent(picture);
imageLayout.setWidth(picture.getWidth() + 5, picture.getWidthUnits());
// Change picture button
if (isCurrentLoggedInUser) {
Upload changePictureButton = initChangePictureButton();
imageLayout.addComponent(changePictureButton);
imageLayout.setComponentAlignment(changePictureButton, Alignment.MIDDLE_CENTER);
}
}
use of com.vaadin.terminal.StreamResource.StreamSource in project Activiti by Activiti.
the class EditorProcessDefinitionInfoComponent method initImage.
protected void initImage() {
processImageContainer = new VerticalLayout();
Label processTitle = new Label(i18nManager.getMessage(Messages.PROCESS_HEADER_DIAGRAM));
processTitle.addStyleName(ExplorerLayout.STYLE_H3);
processImageContainer.addComponent(processTitle);
StreamSource streamSource = null;
final byte[] editorSourceExtra = repositoryService.getModelEditorSourceExtra(modelData.getId());
if (editorSourceExtra != null) {
streamSource = new StreamSource() {
private static final long serialVersionUID = 1L;
public InputStream getStream() {
InputStream inStream = null;
try {
inStream = new ByteArrayInputStream(editorSourceExtra);
} catch (Exception e) {
LOGGER.warn("Error reading PNG in StreamSource", e);
}
return inStream;
}
};
}
if (streamSource != null) {
Embedded embedded = new Embedded(null, new ImageStreamSource(streamSource, ExplorerApp.get()));
embedded.setType(Embedded.TYPE_IMAGE);
embedded.setSizeUndefined();
// using panel for scrollbars
Panel imagePanel = new Panel();
imagePanel.addStyleName(Reindeer.PANEL_LIGHT);
imagePanel.setWidth(100, UNITS_PERCENTAGE);
imagePanel.setHeight(700, UNITS_PIXELS);
HorizontalLayout panelLayout = new HorizontalLayout();
panelLayout.setSizeUndefined();
imagePanel.setContent(panelLayout);
imagePanel.addComponent(embedded);
processImageContainer.addComponent(imagePanel);
} else {
Label noImageAvailable = new Label(i18nManager.getMessage(Messages.PROCESS_NO_DIAGRAM));
processImageContainer.addComponent(noImageAvailable);
}
addComponent(processImageContainer);
}
use of com.vaadin.terminal.StreamResource.StreamSource in project Activiti by Activiti.
the class UserDetailPanel method loadPicture.
protected void loadPicture() {
Component pictureComponent = null;
final Picture userPicture = identityService.getUserPicture(user.getId());
if (userPicture != null) {
StreamResource imageresource = new StreamResource(new StreamSource() {
private static final long serialVersionUID = 1L;
public InputStream getStream() {
return userPicture.getInputStream();
}
}, user.getId() + "." + Constants.MIMETYPE_EXTENSION_MAPPING.get(userPicture.getMimeType()), ExplorerApp.get());
pictureComponent = new Embedded(null, imageresource);
} else {
pictureComponent = new Label("");
}
pictureComponent.setHeight("200px");
pictureComponent.setWidth("200px");
pictureComponent.addStyleName(ExplorerLayout.STYLE_PROFILE_PICTURE);
userDetailsLayout.addComponent(pictureComponent);
userDetailsLayout.setComponentAlignment(pictureComponent, Alignment.MIDDLE_CENTER);
}
use of com.vaadin.terminal.StreamResource.StreamSource in project Activiti by Activiti.
the class ProcessDefinitionImageStreamResourceBuilder method buildStreamResource.
public StreamResource buildStreamResource(ProcessDefinition processDefinition, RepositoryService repositoryService) {
StreamResource imageResource = null;
if (processDefinition.getDiagramResourceName() != null) {
final InputStream definitionImageStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), processDefinition.getDiagramResourceName());
StreamSource streamSource = new InputStreamStreamSource(definitionImageStream);
// Creating image name based on process-definition ID is fine, since the diagram image cannot
// be altered once deployed.
String imageExtension = extractImageExtension(processDefinition.getDiagramResourceName());
String fileName = processDefinition.getId() + "." + imageExtension;
imageResource = new StreamResource(streamSource, fileName, ExplorerApp.get());
}
return imageResource;
}
use of com.vaadin.terminal.StreamResource.StreamSource in project Activiti by Activiti.
the class DeploymentDetailPanel method addResourceLinks.
protected void addResourceLinks() {
List<String> resourceNames = repositoryService.getDeploymentResourceNames(deployment.getId());
// small nr of elements, so we can do it in-memory
Collections.sort(resourceNames);
if (!resourceNames.isEmpty()) {
Label resourceHeader = new Label(i18nManager.getMessage(Messages.DEPLOYMENT_HEADER_RESOURCES));
resourceHeader.setWidth("95%");
resourceHeader.addStyleName(ExplorerLayout.STYLE_H3);
resourceHeader.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
addDetailComponent(resourceHeader);
// resources
VerticalLayout resourceLinksLayout = new VerticalLayout();
resourceLinksLayout.setSpacing(true);
resourceLinksLayout.setMargin(true, false, false, false);
addDetailComponent(resourceLinksLayout);
for (final String resourceName : resourceNames) {
StreamResource.StreamSource streamSource = new StreamSource() {
public InputStream getStream() {
return repositoryService.getResourceAsStream(deployment.getId(), resourceName);
}
};
Link resourceLink = new Link(resourceName, new StreamResource(streamSource, resourceName, ExplorerApp.get()));
resourceLinksLayout.addComponent(resourceLink);
}
}
}
Aggregations