当前位置: 首页>>代码示例>>Java>>正文


Java FileDownloader类代码示例

本文整理汇总了Java中com.vaadin.server.FileDownloader的典型用法代码示例。如果您正苦于以下问题:Java FileDownloader类的具体用法?Java FileDownloader怎么用?Java FileDownloader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FileDownloader类属于com.vaadin.server包,在下文中一共展示了FileDownloader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createDownloadButton

import com.vaadin.server.FileDownloader; //导入依赖的package包/类
@SuppressWarnings("serial")
private Button createDownloadButton() {
    this.download = new Button(VmidcMessages.getString(VmidcMessages_.SUMMARY_DOWNLOAD_LOG)) {
        @Override
        public void setEnabled(boolean enabled) {
            if (enabled) {
                // because setEnabled(false) calls are ignored and button is disabled
                // on client because of setDisableOnClick(true), by doing this we
                // make sure that the button is actually disabled so that setEnabled(true)
                // has effect
                getUI().getConnectorTracker().getDiffState(this).put("enabled", false);
                super.setEnabled(enabled);
            }
        }
    };
    SummaryLayout.this.download.setDisableOnClick(true);
    if (this.checkbox != null && this.checkbox.getValue()) {
        this.download.setCaption(VmidcMessages.getString(VmidcMessages_.SUMMARY_DOWNLOAD_BUNDLE));
    }
    StreamResource zipStream = getZipStream();
    FileDownloader fileDownloader = new FileDownloader(zipStream);
    fileDownloader.extend(this.download);
    return this.download;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:25,代码来源:SummaryLayout.java

示例2: init

import com.vaadin.server.FileDownloader; //导入依赖的package包/类
@PostConstruct
public void init() {
    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setWidthUndefined();
    layout.addComponent(attendeeExportBtn);
    FileDownloader attendeeDownloader = new FileDownloader(handler.createAttendeeExport(this));
    attendeeDownloader.extend(attendeeExportBtn);

    layout.addComponent(tillExportBtn);
    FileDownloader tillDownloader = new FileDownloader(handler.createTillExport(this));
    tillDownloader.extend(tillExportBtn);

    layout.setComponentAlignment(attendeeExportBtn, Alignment.TOP_CENTER);
    layout.setComponentAlignment(tillExportBtn, Alignment.TOP_CENTER);
    addComponent(layout);
}
 
开发者ID:kumoregdev,项目名称:kumoreg,代码行数:18,代码来源:ExportView.java

示例3: initializeDownload

import com.vaadin.server.FileDownloader; //导入依赖的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,代码来源:PolicyEditor.java

示例4: fileLinkComponent

import com.vaadin.server.FileDownloader; //导入依赖的package包/类
protected Component fileLinkComponent(Table source, Object itemId, Object propertyId) {
    if (itemId instanceof FileInfo) {
        final FileInfo file = (FileInfo) itemId;
        if (!file.isDirectory()) {
            final Button button = new Button(file.getName());
            button.addStyleName(ValoTheme.BUTTON_LINK);
            button.addStyleName(ValoTheme.BUTTON_SMALL);
            button.setIcon(FontAwesome.FILE);
            StreamResource resource = new StreamResource(() -> stream(file), file.getName());
            FileDownloader fileDownloader = new FileDownloader(resource);
            fileDownloader.extend(button);
            return button;
        } else {
            return new Label(file.getName());
        }
    } else {
        return new Label(((DirectoryResource) itemId).getName());

    }
}
 
开发者ID:JumpMind,项目名称:metl,代码行数:21,代码来源:ExploreDirectoryView.java

示例5: createDownloader

import com.vaadin.server.FileDownloader; //导入依赖的package包/类
private FileDownloader createDownloader(final byte[] file, final String fileName) {

		// Подготовить имя файла
		final String webFileName = encodeWebFileName(fileName);


		return new OnDemandFileDownloader(new OnDemandFileDownloader.OnDemandStreamResource() {
			@Override
			public String getFilename() {
				return webFileName;
			}

			@Override
			public InputStream getStream() {
				return new ByteArrayInputStream(file);
			}
		});
//        return new FileDownloader(
//                new StreamResource(new StreamResource.StreamSource() {
//                    @Override
//                    public InputStream getStream() {
//                        return new ByteArrayInputStream(file);
//                    }
//
//                }, webFileName));
	}
 
开发者ID:ExtaSoft,项目名称:extacrm,代码行数:27,代码来源:DownloadFileWindow.java

示例6: zipProject

import com.vaadin.server.FileDownloader; //导入依赖的package包/类
/**
 * Zips project.
 *
 * @param projectName the name of the project to be zipped
 */
protected void zipProject() {
	try {
		File zipFile = File.createTempFile("mideaas-"+project.getName(), ".zip");
		
		zipProjectToFile(zipFile, settings);
		FileResource zip = new FileResource(zipFile);
		FileDownloader fd = new FileDownloader(zip);
		Button downloadButton = new Button("Download project");
		fd.extend(downloadButton);

		//filedonwnloader can not be connected to menuitem :( So I connected it to popupwindow :)
		Window zipButtonWindow = new Window();
		zipButtonWindow.setCaption("Zip and download project");
		zipButtonWindow.setWidth(200, Unit.PIXELS);
		zipButtonWindow.setContent(downloadButton);
		UI.getCurrent().addWindow(zipButtonWindow);
	} catch (IOException e) {
		e.printStackTrace();
		Notification.show("Error: " + e.getMessage(), Notification.Type.ERROR_MESSAGE);
	}

}
 
开发者ID:ahn,项目名称:mideaas,代码行数:28,代码来源:ZipPlugin.java

示例7: getDownloadSdkButtonForSdnController

import com.vaadin.server.FileDownloader; //导入依赖的package包/类
private Button getDownloadSdkButtonForSdnController() throws URISyntaxException, MalformedURLException {
    SdkUtil sdkUtil = new SdkUtil();
    Button downloadSdk = new Button(VmidcMessages.getString(VmidcMessages_.MAINTENANCE_SDNPLUGIN_DOWNLOAD_SDK));
    URI currentLocation = UI.getCurrent().getPage().getLocation();
    URI downloadLocation = new URI(currentLocation.getScheme(), null, currentLocation.getHost(),
            currentLocation.getPort(), sdkUtil.getSdk(SdkUtil.sdkType.SDN_CONTROLLER), null, null);
    FileDownloader downloader = new FileDownloader(new ExternalResource(downloadLocation.toURL().toString()));
    downloader.extend(downloadSdk);
    return downloadSdk;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:11,代码来源:PluginsLayout.java

示例8: getDownloadSdkButtonForManager

import com.vaadin.server.FileDownloader; //导入依赖的package包/类
private Button getDownloadSdkButtonForManager() throws URISyntaxException, MalformedURLException {
    SdkUtil sdkUtil = new SdkUtil();
    Button downloadSdk = new Button(VmidcMessages.getString(VmidcMessages_.MAINTENANCE_MANAGERPLUGIN_DOWNLOAD_SDK));
    URI currentLocation = UI.getCurrent().getPage().getLocation();
    URI downloadLocation = new URI(currentLocation.getScheme(), null, currentLocation.getHost(),
            currentLocation.getPort(), sdkUtil.getSdk(SdkUtil.sdkType.MANAGER), null, null);
    FileDownloader downloader = new FileDownloader(new ExternalResource(downloadLocation.toURL().toString()));
    downloader.extend(downloadSdk);
    return downloadSdk;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:11,代码来源:PluginsLayout.java

示例9: getDownloadButton

import com.vaadin.server.FileDownloader; //导入依赖的package包/类
private Button getDownloadButton(Application app) {
	// Download logs button : download file
	StreamResource resource = getLogsStream(app);

	// Download logs button
	Button downloadButton = new Button("Download full logfile");

	FileDownloader fileDownloader = new FileDownloader(resource);
	fileDownloader.setOverrideContentType(false);
	fileDownloader.extend(downloadButton);

	// Download logs button : on click
	downloadButton.addClickListener(e -> fileDownloader.setFileDownloadResource(getLogsStream(app)));
	return downloadButton;
}
 
开发者ID:vianneyfaivre,项目名称:Persephone,代码行数:16,代码来源:LogsPage.java

示例10: updateDetails

import com.vaadin.server.FileDownloader; //导入依赖的package包/类
private void updateDetails(ListEntry item) {
    LOG.info("Display details for {}", item);

    ObjectMetadata objectMetadata = s3Client.getObjectMetadata(item.getBucket(), item.getKey());

    VerticalLayout detailsContent = new VerticalLayout();
    detailsContent.setSpacing(true);
    detailsContent.setMargin(true);
    Label caption = new Label(item.getKey());
    caption.addStyleName(ValoTheme.LABEL_H3);
    detailsContent.addComponent(caption);

    if (objectMetadata.getLastModified() != null) {
        detailsContent.addComponent(buildDetailsTextField("LastModified", objectMetadata.getLastModified().toString()));
    }
    detailsContent.addComponent(buildDetailsTextField("ContentLength", Long.toString(objectMetadata.getContentLength())));
    if (objectMetadata.getContentType() != null) {
        detailsContent.addComponent(buildDetailsTextField("ContentType", objectMetadata.getContentType()));
    }
    if (objectMetadata.getETag() != null) {
        detailsContent.addComponent(buildDetailsTextField("ETag", objectMetadata.getETag()));
    }

    Button downloadButton = new Button("Download");

    FileDownloader fileDownloader = new FileDownloader(new StreamResource(() -> {
        LOG.info("Download {}/{}", item.getBucket(), item.getKey());
        return s3Client.getObject(item.getBucket(), item.getKey()).getObjectContent();
    }, item.getKey()));
    fileDownloader.extend(downloadButton);
    detailsContent.addComponent(downloadButton);

    details.setContent(detailsContent);
}
 
开发者ID:jenshadlich,项目名称:s3browser,代码行数:35,代码来源:BrowseUI.java

示例11: download

import com.vaadin.server.FileDownloader; //导入依赖的package包/类
/**
 * Download actual file
 */
public void download() {
	StreamResource resource = new StreamResource(source, fileName);
	resource.getStream().setParameter("Content-Disposition", "attachment;filename=\"" + fileName + "\"");
	resource.setMIMEType ("application/octet-stream");
	resource.setCacheTime (0);
	FileDownloader downloader = new FileDownloader(resource); 
	downloader.extend(ui);
}
 
开发者ID:lkumarjain,项目名称:jain-I18n,代码行数:12,代码来源:JDownloader.java

示例12: buildDownloadButton

import com.vaadin.server.FileDownloader; //导入依赖的package包/类
private void buildDownloadButton(String title) {
 	downloadButton = new Button("Download");
 	final byte[] lobData = getLobData(title);
 	if (lobData != null) {
  	Resource resource = new StreamResource(new StreamSource() {
	
	private static final long serialVersionUID = 1L;
	
	public InputStream getStream() {
		return new ByteArrayInputStream(lobData);
	}
	
}, title);
  	FileDownloader fileDownloader = new FileDownloader(resource);
  	fileDownloader.extend(downloadButton);
  	buttonLayout.addComponent(downloadButton);
  	buttonLayout.setComponentAlignment(downloadButton, Alignment.BOTTOM_CENTER);
  	
  	long fileSize = lobData.length;
  	String sizeText = fileSize + " Bytes";
  	if (fileSize / 1024 > 0) {
  		sizeText = Math.round(fileSize / 1024.0) + " kB";
  		fileSize /= 1024;
  	}
  	if (fileSize / 1024 > 0) {
  		sizeText = Math.round(fileSize / 1024.0) + " MB";
  		fileSize /= 1024;
  	}
  	if (fileSize / 1024 > 0) {
  		sizeText = Math.round(fileSize / 1024.0) + " GB";
  	}
  	Label sizeLabel = new Label(sizeText);
  	buttonLayout.addComponent(sizeLabel);
  	buttonLayout.setExpandRatio(sizeLabel, 1.0f);
  	buttonLayout.setComponentAlignment(sizeLabel, Alignment.BOTTOM_CENTER);
 	}
 }
 
开发者ID:JumpMind,项目名称:sqlexplorer-vaadin,代码行数:38,代码来源:ReadOnlyTextAreaDialog.java

示例13: initContent

import com.vaadin.server.FileDownloader; //导入依赖的package包/类
@Override
public void initContent() {
    removeAllComponents();
    MHorizontalLayout header = new MHorizontalLayout().withFullWidth();

    ELabel layoutHeader = ELabel.h2(String.format("%s %s", FontAwesome.EYE.getHtml(), UserUIContext.getMessage(FollowerI18nEnum
            .OPT_MY_FOLLOWING_TICKETS, 0))).withWidthUndefined();

    Button exportBtn = new Button(UserUIContext.getMessage(GenericI18Enum.ACTION_EXPORT), clickEvent -> exportButtonControl.setPopupVisible(true));
    exportButtonControl = new SplitButton(exportBtn);
    exportButtonControl.addStyleName(WebThemes.BUTTON_OPTION);
    exportButtonControl.setIcon(FontAwesome.EXTERNAL_LINK);

    OptionPopupContent popupButtonsControl = new OptionPopupContent();
    exportButtonControl.setContent(popupButtonsControl);

    Button exportPdfBtn = new Button(UserUIContext.getMessage(FileI18nEnum.PDF));
    FileDownloader pdfDownloader = new FileDownloader(constructStreamResource(ReportExportType.PDF));
    pdfDownloader.extend(exportPdfBtn);
    exportPdfBtn.setIcon(FontAwesome.FILE_PDF_O);
    popupButtonsControl.addOption(exportPdfBtn);

    Button exportExcelBtn = new Button(UserUIContext.getMessage(FileI18nEnum.EXCEL));
    FileDownloader excelDownloader = new FileDownloader(constructStreamResource(ReportExportType.EXCEL));
    excelDownloader.extend(exportExcelBtn);
    exportExcelBtn.setIcon(FontAwesome.FILE_EXCEL_O);
    popupButtonsControl.addOption(exportExcelBtn);

    header.with(layoutHeader, exportButtonControl).withAlign(layoutHeader, Alignment.MIDDLE_LEFT).withAlign(exportButtonControl,
            Alignment.MIDDLE_RIGHT);
    this.addComponent(layoutHeader);

    searchPanel = new FollowingTicketSearchPanel();
    this.addComponent(searchPanel);

    this.ticketTable = new FollowingTicketTableDisplay();
    this.ticketTable.setMargin(new MarginInfo(true, false, false, false));
    this.addComponent(this.ticketTable);
}
 
开发者ID:MyCollab,项目名称:mycollab,代码行数:40,代码来源:FollowingTicketViewImpl.java

示例14: buildExportButton

import com.vaadin.server.FileDownloader; //导入依赖的package包/类
private Component buildExportButton() {
	Button exportButton = new Button(Messages.getString("Caption.Button.Export"));
	Resource exportResource = getExportResource();
	FileDownloader fileDownloader = new FileDownloader(exportResource);
	fileDownloader.extend(exportButton);
	return exportButton;
}
 
开发者ID:tilioteo,项目名称:hypothesis,代码行数:8,代码来源:AbstractManagementPresenter.java

示例15: NamedQueryImportExport

import com.vaadin.server.FileDownloader; //导入依赖的package包/类
public NamedQueryImportExport() {
    setSizeFull();
    setSpacing(true);
    setMargin(true);

    Panel importPanel = new Panel("Import");
    importPanel.setSizeFull();

    Panel exportPanel = new Panel("Export");
    exportPanel.setSizeFull();

    VerticalLayout exportLayout = new VerticalLayout();
    exportLayout.setSizeFull();
    exportLayout.setMargin(true);
    exportLayout.setSpacing(true);
    Button exportButton = new Button("Export Named Queries");
    exportLayout.addComponent(exportButton);

    StreamResource streamResource = getNamedQueriesExportStream();
    FileDownloader fileDownloader = new FileDownloader(streamResource);
    fileDownloader.extend(exportButton);

    exportPanel.setContent(exportLayout);
    addComponent(exportPanel);

    FormLayout importLayout = new FormLayout();
    importLayout.setSizeFull();
    importLayout.setMargin(true);
    importLayout.setSpacing(true);
    importLayout.addComponent(cleanBeforeImportCheckbox);

    CSVReceiver uploadReceiver = new CSVReceiver();
    Upload upload = new Upload("", uploadReceiver);
    upload.setButtonCaption("Import Named Queries");
    upload.addStyleName(ValoTheme.BUTTON_LARGE);
    upload.addStyleName(ValoTheme.BUTTON_FRIENDLY);
    upload.addSucceededListener(uploadReceiver);
    upload.addFailedListener(uploadReceiver);

    importLayout.addComponent(upload);
    importPanel.setContent(importLayout);

    addComponent(importPanel);
}
 
开发者ID:tokenmill,项目名称:crawling-framework,代码行数:45,代码来源:NamedQueryImportExport.java


注:本文中的com.vaadin.server.FileDownloader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。