本文整理匯總了Java中com.vaadin.server.StreamResource.StreamSource方法的典型用法代碼示例。如果您正苦於以下問題:Java StreamResource.StreamSource方法的具體用法?Java StreamResource.StreamSource怎麽用?Java StreamResource.StreamSource使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.vaadin.server.StreamResource的用法示例。
在下文中一共展示了StreamResource.StreamSource方法的28個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。
示例1: getHttpSourcesExportStream
點讚 3
import com.vaadin.server.StreamResource; //導入方法依賴的package包/類
public static StreamResource getHttpSourcesExportStream() {
StreamResource.StreamSource source = (StreamResource.StreamSource) () -> {
LOG.info("Exporting http sources data...");
List sources = ElasticSearch.getHttpSourceOperations().all();
StringWriter writer = new StringWriter();
CSVWriter csvWriter = CSVUtils.createDefaultWriter(writer);
// Header line creation
csvWriter.writeNext(CSV_COLUMNS);
for (HttpSource ld : sources) {
csvWriter.writeNext(mapHttpSourceToCsvRow(ld));
}
String csv = writer.getBuffer().toString();
return new ByteArrayInputStream(csv.getBytes(Charsets.UTF_8));
};
return new StreamResource(source, "http-sources-exported-" +
new SimpleDateFormat("yyyyMMdd").format(new Date()) + ".csv");
}
開發者ID:tokenmill,項目名稱:crawling-framework,代碼行數:19,
示例2: showBadgesInBrowser
點讚 3
import com.vaadin.server.StreamResource; //導入方法依賴的package包/類
public void showBadgesInBrowser(List attendeeList) {
if (attendeeList.size() > 0) {
StreamResource.StreamSource source = handler.getBadgeFormatter(this, attendeeList);
String filename = "testbadge" + System.currentTimeMillis() + ".pdf";
StreamResource resource = new StreamResource(source, filename);
resource.setMIMEType("application/pdf");
resource.getStream().setParameter("Content-Disposition", "attachment; filename="+filename);
Window window = new Window();
window.setWidth(800, Sizeable.Unit.PIXELS);
window.setHeight(600, Sizeable.Unit.PIXELS);
window.setModal(true);
window.center();
BrowserFrame pdf = new BrowserFrame("test", resource);
pdf.setSizeFull();
window.setContent(pdf);
getUI().addWindow(window);
} else {
Notification.show("No attendees selected");
}
}
開發者ID:kumoregdev,項目名稱:kumoreg,代碼行數:24,
示例3: getNamedQueriesExportStream
點讚 3
import com.vaadin.server.StreamResource; //導入方法依賴的package包/類
public static StreamResource getNamedQueriesExportStream() {
StreamResource.StreamSource source = (StreamResource.StreamSource) () -> {
LOG.info("Exporting http sources data...");
List namedQueries = ElasticSearch.getNamedQueryOperations().all();
StringWriter writer = new StringWriter();
CSVWriter csvWriter = CSVUtils.createDefaultWriter(writer);
csvWriter.writeNext(CSV_COLUMNS);
for (NamedQuery nq : namedQueries) {
csvWriter.writeNext(new String[]{
nq.getName(),
nq.getNotStemmedCaseSensitive(),
nq.getNotStemmedCaseInSensitive(),
nq.getStemmedCaseSensitive(),
nq.getStemmedCaseInSensitive(),
nq.getAdvanced()
});
}
String csv = writer.getBuffer().toString();
return new ByteArrayInputStream(csv.getBytes(Charsets.UTF_8));
};
return new StreamResource(source, "named-queries-exported-" +
new SimpleDateFormat("yyyyMMdd").format(new Date()) + ".csv");
}
開發者ID:tokenmill,項目名稱:crawling-framework,代碼行數:25,
示例4: getHttpSourcesExportStream
點讚 3
import com.vaadin.server.StreamResource; //導入方法依賴的package包/類
public static StreamResource getHttpSourcesExportStream() {
StreamResource.StreamSource source = (StreamResource.StreamSource) () -> {
LOG.info("Exporting http sources data...");
List tests = ElasticSearch.getHttpSourceTestOperations().all();
StringWriter writer = new StringWriter();
CSVWriter csvWriter = CSVUtils.createDefaultWriter(writer);
// Header line creation
csvWriter.writeNext(CSV_COLUMNS);
for (HttpSourceTest hst : tests) {
csvWriter.writeNext(mapHttpSourceTestToCsvRow(hst));
}
String csv = writer.getBuffer().toString();
return new ByteArrayInputStream(csv.getBytes(Charsets.UTF_8));
};
return new StreamResource(source, "http-source-tests-exported-" +
new SimpleDateFormat("yyyyMMdd").format(new Date()) + ".csv");
}
開發者ID:tokenmill,項目名稱:crawling-framework,代碼行數:19,
示例5: setImage
點讚 3
import com.vaadin.server.StreamResource; //導入方法依賴的package包/類
/**
* Sets the image to be edited.
*/
public void setImage(final byte[] imageData) {
this.imageData = imageData;
String imageFileName = "image-file-name-" + getConnectorId();
StreamResource resource = new StreamResource(new StreamResource.StreamSource() {
@Override
public InputStream getStream() {
return new ByteArrayInputStream(imageData);
}
}, imageFileName);
setResource(IMAGE_KEY, resource);
String imageUrl = getResourceUrl(IMAGE_KEY);
callFunction("setImageUrl", imageUrl);
callFunction("setBackgroundColor", red, green, blue);
}
開發者ID:alejandro-du,項目名稱:live-image-editor,代碼行數:19,
示例6: setSource
點讚 3
import com.vaadin.server.StreamResource; //導入方法依賴的package包/類
@Override
public void setSource(String fileName, final InputStream src) {
if (src != null) {
resource = new StreamResource((StreamResource.StreamSource) () -> {
try {
src.reset();
} catch (IOException e) {
Logger log = LoggerFactory.getLogger(WebEmbedded.this.getClass());
log.debug("Ignored IOException on stream reset", e);
}
return src;
}, fileName);
component.setSource(resource);
} else {
resetSource();
}
}
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:18,
示例7: loadData
點讚 3
import com.vaadin.server.StreamResource; //導入方法依賴的package包/類
public void loadData(BookEntry bookEntry) {
this.bookEntry = bookEntry;
titleLabel.setValue(bookEntry.getTitle() + "-" + bookEntry.getAuthor());
descriptionLabel.setValue(bookEntry.getDescription());
StreamResource.StreamSource source = new ByteStreamResource(bookEntry.getCover());
image.setSource(new StreamResource(source, bookEntry.getId() + ".png"));
likeButton.setCaption(bookEntry.getLikes() + " likes");
downloadCount.setValue(bookEntry.getDownloads() + " downloads");
try {
byte[] data = presenter.getEbookFile(bookEntry.getId());
fileDownloader.setFileDownloadResource(new StreamResource(new BookStreamSource(data), bookEntry.getTitle() + "-" + bookEntry.getAuthor()+".epub"));
} catch(SolrServerException ex) {
logger.error(ex, ex);
}
if (presenter.isOnWatchList(bookEntry, SecurityUtils.getSubject().getPrincipal().toString())) {
watchListButton.setCaption("vergessen");
watchListButton.setIcon(FontAwesome.STAR);
}
else {
watchListButton.setCaption("merken");
watchListButton.setIcon(FontAwesome.STAR_O);
}
}
開發者ID:felixhusse,項目名稱:bookery,代碼行數:26,
示例8: initializeDownload
點讚 3
import com.vaadin.server.StreamResource; //導入方法依賴的package包/類
protected void initializeDownload() {
//
// Create a stream resource pointing to the file
//
StreamResource r = new StreamResource(new StreamResource.StreamSource() {
private static final long serialVersionUID = 1L;
@Override
public InputStream getStream() {
try {
return new FileInputStream(self.file);
} catch (Exception e) {
logger.error("Failed to open input stream " + self.file);
}
return null;
}
}, self.file.getName());
r.setCacheTime(-1);
r.setMIMEType("application/xml");
//
// Extend a downloader to attach to the Export Button
//
FileDownloader downloader = new FileDownloader(r);
downloader.extend(this.buttonExport);
}
開發者ID:apache,項目名稱:incubator-openaz,代碼行數:26,
示例9: getDownloadStream
點讚 2
import com.vaadin.server.StreamResource; //導入方法依賴的package包/類
private StreamResource getDownloadStream() {
return new StreamResource((StreamResource.StreamSource) () -> {
String output = lblReport.getValue();
if (output == null) { output = "Empty report"; }
return new ByteArrayInputStream(output.getBytes(Charset.forName("UTF-8")));
}, generateFilename(title));
}
開發者ID:kumoregdev,項目名稱:kumoreg,代碼行數:8,
示例10: initializeButtons
點讚 2
import com.vaadin.server.StreamResource; //導入方法依賴的package包/類
protected void initializeButtons() {
//
// The Save button
//
this.buttonSave.addClickListener(new ClickListener() {
private static final long serialVersionUID = 1L;
@Override
public void buttonClick(ClickEvent event) {
self.savePolicy();
}
});
//
// Attach a window opener to the View XML button
//
BrowserWindowOpener opener = new BrowserWindowOpener(new StreamResource(new StreamResource.StreamSource() {
private static final long serialVersionUID = 1L;
@Override
public InputStream getStream() {
try {
if (logger.isDebugEnabled()) {
logger.debug("Setting view xml button to: " + self.file.getAbsolutePath());
}
return new FileInputStream(self.file);
} catch (Exception e) {
logger.error("Failed to open input stream " + self.file);
}
return null;
}
}, self.file.getName()));
opener.setWindowName("_new");
opener.extend(this.buttonViewXML);
}
開發者ID:apache,項目名稱:incubator-openaz,代碼行數:35,
示例11: generateCell
點讚 2
import com.vaadin.server.StreamResource; //導入方法依賴的package包/類
@Override
public Object generateCell(Table source, Object itemId, Object columnId) {
User user = (User) itemId;
Image image = new Image();
image.addStyleName("users-menu-image");
if (user.getImage() != null) {
StreamResource.StreamSource imagesource = new UserImageSource(user.getImage().toStream());
StreamResource resource = new StreamResource(imagesource, UUID.randomUUID().toString());
image.setSource(resource);
} else {
image.setSource(new ThemeResource("img/profile-pic-300px.jpg"));
}
ValoUserItemButton btnUsername = new ValoUserItemButton(user, ValoUserItemButton.TYPE.USER_NAME);
ValoUserItemButton btnFullName = new ValoUserItemButton(user, ValoUserItemButton.TYPE.FULL_NAME);
VerticalLayout nameLayout = new VerticalLayout(btnFullName, btnUsername);
nameLayout.setSizeFull();
nameLayout.setComponentAlignment(btnFullName, Alignment.BOTTOM_LEFT);
nameLayout.setComponentAlignment(btnUsername, Alignment.TOP_LEFT);
HorizontalLayout usersHorizontalLayout = new HorizontalLayout(image, nameLayout);
usersHorizontalLayout.setComponentAlignment(image, Alignment.MIDDLE_CENTER);
usersHorizontalLayout.setComponentAlignment(nameLayout, Alignment.MIDDLE_LEFT);
usersHorizontalLayout.setExpandRatio(nameLayout, 1f);
usersHorizontalLayout.addStyleName("users-horizontal-layout");
usersHorizontalLayout.setWidth(100, Unit.PERCENTAGE);
usersHorizontalLayout.setHeight(45, Unit.PIXELS);
usersHorizontalLayout.setSpacing(true);
return usersHorizontalLayout;
}
開發者ID:hybridbpm,項目名稱:hybridbpm,代碼行數:33,
示例12: setUserImage
點讚 2
import com.vaadin.server.StreamResource; //導入方法依賴的package包/類
public void setUserImage() {
User user = HybridbpmUI.getUser();
settingsItem.setText(user.getUsername());
if (user.getImage() != null) {
StreamResource.StreamSource imagesource = new UserImageSource(user.getImage().toStream());
StreamResource resource = new StreamResource(imagesource, UUID.randomUUID().toString());
userImage.setSource(resource);
} else {
userImage.setSource(new ThemeResource("img/profile-pic-300px.jpg"));
}
}
開發者ID:hybridbpm,項目名稱:hybridbpm,代碼行數:12,
示例13: setUserImage
點讚 2
import com.vaadin.server.StreamResource; //導入方法依賴的package包/類
public void setUserImage() {
User user = HybridbpmUI.getUser();
if (user.getImage() != null) {
StreamResource.StreamSource imagesource = new UserImageSource(user.getImage().toStream());
StreamResource resource = new StreamResource(imagesource, UUID.randomUUID().toString());
userImage.setSource(resource);
} else {
userImage.setSource(new ThemeResource("img/profile-pic-300px.jpg"));
}
}
開發者ID:hybridbpm,項目名稱:hybridbpm,代碼行數:11,
示例14: uploadSucceeded
點讚 2
import com.vaadin.server.StreamResource; //導入方法依賴的package包/類
@Override
public void uploadSucceeded(SucceededEvent event) {
image = baos.toByteArray();
StreamResource.StreamSource imagesource = new UserImageSource(image);
StreamResource resource = new StreamResource(imagesource, filename);
userImage.setSource(resource);
}
開發者ID:hybridbpm,項目名稱:hybridbpm,代碼行數:8,
示例15: setUserImage
點讚 2
import com.vaadin.server.StreamResource; //導入方法依賴的package包/類
public void setUserImage() {
User user = HybridbpmUI.getAccessAPI().getUserById(comment.getCreator());
if (user.getImage() != null) {
StreamResource.StreamSource imagesource = new UserImageSource(user.getImage().toStream());
StreamResource resource = new StreamResource(imagesource, UUID.randomUUID().toString());
userImage.setSource(resource);
} else {
userImage.setSource(new ThemeResource("img/profile-pic-300px.jpg"));
}
senderUsername.setCaption("@" + user.getUsername());
senderName.setValue(user.getFullName());
}
開發者ID:hybridbpm,項目名稱:hybridbpm,代碼行數:13,
示例16: OnDemandStreamResource
點讚 2
import com.vaadin.server.StreamResource; //導入方法依賴的package包/類
public OnDemandStreamResource() {
super(new StreamResource.StreamSource() {
@Override
public InputStream getStream() {
return new ByteArrayInputStream(new byte[1]);
}
}, "");
}
開發者ID:hybridbpm,項目名稱:hybridbpm,代碼行數:10,
示例17: handleConnectorRequest
點讚 2
import com.vaadin.server.StreamResource; //導入方法依賴的package包/類
@Override
public boolean handleConnectorRequest(VaadinRequest request, VaadinResponse response, String path) throws IOException {
StreamResource resource = new StreamResource(new StreamResource.StreamSource() {
@Override
public InputStream getStream() {
byte[] doc = HybridbpmUI.getDocumentAPI().getDocumentBodyByVersionId(documentVersionId);
return new ByteArrayInputStream(doc);
}
}, name);
this.setResource("dl", resource);
return super.handleConnectorRequest(request, response, path);
}
開發者ID:hybridbpm,項目名稱:hybridbpm,代碼行數:14,
示例18: attach
點讚 2
import com.vaadin.server.StreamResource; //導入方法依賴的package包/類
@Override
public void attach() {
super.attach();
final StreamResource.StreamSource source = new StreamResource.StreamSource() {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 1L;
@Override
public InputStream getStream() {
try {
return new URL(fileUrl).openStream();
} catch (final IOException e) {
LOGGER.warn("Problem opening url:"+ fileUrl,e);
return new ByteArrayInputStream(new byte[0]);
}
}
};
final StreamResource resource = new StreamResource(source, fileName);
resource.getStream().setParameter("Content-Disposition", "attachment;filename=\"" + fileName + "\"");
resource.setMIMEType("application/" + fileType);
resource.setCacheTime(0);
setResource(resource);
}
開發者ID:Hack23,項目名稱:cia,代碼行數:30,
示例19: getImageResourceForComponentType
點讚 2
import com.vaadin.server.StreamResource; //導入方法依賴的package包/類
protected StreamResource getImageResourceForComponentType(String projectVersionId, XMLComponentDefinition componentDefinition) {
StreamResource.StreamSource source = new StreamResource.StreamSource() {
private static final long serialVersionUID = 1L;
@Override
public InputStream getStream() {
return UiUtils.getComponentImageInputStream(projectVersionId, componentDefinition.getId(), context);
}
};
return new StreamResource(source, componentDefinition.getId());
}
開發者ID:JumpMind,項目名稱:metl,代碼行數:12,
示例20: createButtonControls
點讚 2
import com.vaadin.server.StreamResource; //導入方法依賴的package包/類
@Override
protected HorizontalLayout createButtonControls() {
ProjectPreviewFormControlsGenerator pagesPreviewForm = new ProjectPreviewFormControlsGenerator<>(previewForm);
HorizontalLayout buttonControls = pagesPreviewForm.createButtonControls(
ProjectPreviewFormControlsGenerator.ADD_BTN_PRESENTED
| ProjectPreviewFormControlsGenerator.EDIT_BTN_PRESENTED
| ProjectPreviewFormControlsGenerator.DELETE_BTN_PRESENTED,
ProjectRolePermissionCollections.PAGES);
MButton exportPdfBtn = new MButton("").withIcon(FontAwesome.FILE_PDF_O).withStyleName(WebThemes
.BUTTON_OPTION).withDescription(UserUIContext.getMessage(GenericI18Enum.BUTTON_EXPORT_PDF));
OnDemandFileDownloader fileDownloader = new OnDemandFileDownloader(new LazyStreamSource() {
@Override
protected StreamResource.StreamSource buildStreamSource() {
return new PageReportStreamSource(beanItem);
}
@Override
public String getFilename() {
return "Document.pdf";
}
});
fileDownloader.extend(exportPdfBtn);
pagesPreviewForm.insertToControlBlock(exportPdfBtn);
return buttonControls;
}
開發者ID:MyCollab,項目名稱:mycollab,代碼行數:29,
示例21: ByteArrayImageResource
點讚 2
import com.vaadin.server.StreamResource; //導入方法依賴的package包/類
public ByteArrayImageResource(final byte[] imageData, String mimeType) {
super(new StreamResource.StreamSource() {
private static final long serialVersionUID = 1L;
public InputStream getStream() {
return new ByteArrayInputStream(imageData);
}
}, "avatar");
this.setMIMEType(mimeType);
}
開發者ID:MyCollab,項目名稱:mycollab,代碼行數:12,
示例22: download
點讚 2
import com.vaadin.server.StreamResource; //導入方法依賴的package包/類
protected void download(String filename, final JRExporter exporter) {
StreamResource resource = new StreamResource(new StreamResource.StreamSource() {
private static final long serialVersionUID = 1L;
@Override
public InputStream getStream() {
return new ByteArrayInputStream(getOutputStream(exporter).toByteArray());
}
}, filename);
EnterpriseApplication.getInstance().getMainWindow().open(resource, "", true);
}
開發者ID:alejandro-du,項目名稱:enterprise-app,代碼行數:14,
示例23: getExportResource
點讚 2
import com.vaadin.server.StreamResource; //導入方法依賴的package包/類
@Override
protected Resource getExportResource() {
StreamResource.StreamSource source = () -> getExportFile();
String filename = Messages.getString("Caption.Export.UserFileName");
return new StreamResource(source, filename);
}
開發者ID:tilioteo,項目名稱:hypothesis,代碼行數:8,
示例24: getStream
點讚 2
import com.vaadin.server.StreamResource; //導入方法依賴的package包/類
public StreamResource getStream() {
return new StreamResource((StreamResource.StreamSource) () -> {
String output = buildTable();
return new ByteArrayInputStream(output.getBytes(Charset.forName("UTF-8")));
}, getFilename());
}
開發者ID:kumoregdev,項目名稱:kumoreg,代碼行數:7,
示例25: getStream
點讚 2
import com.vaadin.server.StreamResource; //導入方法依賴的package包/類
public StreamResource getStream() {
return new StreamResource((StreamResource.StreamSource) () -> {
String output = buildTable(attendeeRepository.findAll());
return new ByteArrayInputStream(output.getBytes(Charset.forName("UTF-8")));
}, getFilename());
}
開發者ID:kumoregdev,項目名稱:kumoreg,代碼行數:7,
示例26: getExportResource
點讚 2
import com.vaadin.server.StreamResource; //導入方法依賴的package包/類
private StreamResource getExportResource() {
final InputStream inputStream = getExportFile();
if (inputStream != null) {
StreamResource.StreamSource source = () -> inputStream;
String filename = Messages.getString("Caption.Export.TestFileName");
StreamResource resource = new StreamResource(source, filename);
resource.setMIMEType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
return resource;
}
return null;
}
開發者ID:tilioteo,項目名稱:hypothesis,代碼行數:17,
示例27: getExportScoresResource
點讚 2
import com.vaadin.server.StreamResource; //導入方法依賴的package包/類
private StreamResource getExportScoresResource() {
final InputStream inputStream = getExportScoresFile();
if (inputStream != null) {
StreamResource.StreamSource source = () -> inputStream;
String filename = Messages.getString("Caption.Export.ScoreFileName");
StreamResource resource = new StreamResource(source, filename);
resource.setMIMEType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
return resource;
}
return null;
}
開發者ID:tilioteo,項目名稱:hypothesis,代碼行數:17,
示例28: getExportResource
點讚 2
import com.vaadin.server.StreamResource; //導入方法依賴的package包/類
@Override
protected Resource getExportResource() {
StreamResource.StreamSource source = () -> getExportFile();
return new StreamResource(source, Messages.getString("Caption.Export.GroupFileName"));
}
開發者ID:tilioteo,項目名稱:hypothesis,代碼行數:7,
注:本文中的com.vaadin.server.StreamResource.StreamSource方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。