com.vaadin.server.FileResource Java Examples

The following examples show how to use com.vaadin.server.FileResource. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestGenerationView.java    From RDFUnit with Apache License 2.0 6 votes vote down vote up
@Override
public void sourceGenerationExecuted(final Source source, final TestGenerationType generationType, final long testsCreated) {
    UI.getCurrent().access(() -> {
        Item item = resultsTable.getItem(source);
        if (testsCreated == 0 || item == null)
            return;

        String column = (generationType.equals(TestGenerationType.AutoGenerated) ? "Automatic" : "Manual");
        Property<Link> statusProperty = item.getItemProperty(column);
        String fileName;
        if (generationType.equals(TestGenerationType.AutoGenerated)) {
            fileName = CacheUtils.getSourceAutoTestFile(RDFUnitDemoSession.getBaseDir() + "tests/", source);
            statusProperty.setValue(new Link("" + testsCreated, new FileResource(new File(fileName))));
        } else {
            fileName = CacheUtils.getSourceManualTestFile("/org/aksw/rdfunit/tests/", source);
            statusProperty.setValue(new Link("" + testsCreated, new ClassResource(fileName)));
        }
        CommonAccessUtils.pushToClient();
    });

}
 
Example #2
Source File: HomePageUI.java    From dubbox with Apache License 2.0 5 votes vote down vote up
private FileResource getFileResource(String path,String type){
    InputStream inputStream = null;
    try {
        ClassPathResource resource = new ClassPathResource(path);
        inputStream = resource.getInputStream();
        File tempFile = File.createTempFile("ds_" + System.currentTimeMillis(), type);
        FileUtils.copyInputStreamToFile(inputStream, tempFile);
        return new FileResource(tempFile);
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    } finally {
        IOUtils.closeQuietly(inputStream);
    }
}
 
Example #3
Source File: HomePageUI.java    From dubbo-switch with Apache License 2.0 5 votes vote down vote up
private FileResource getFileResource(String path,String type){
    InputStream inputStream = null;
    try {
        ClassPathResource resource = new ClassPathResource(path);
        inputStream = resource.getInputStream();
        File tempFile = File.createTempFile("ds_" + System.currentTimeMillis(), type);
        FileUtils.copyInputStreamToFile(inputStream, tempFile);
        return new FileResource(tempFile);
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    } finally {
        IOUtils.closeQuietly(inputStream);
    }
}
 
Example #4
Source File: FileIconProvider.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public Resource getIconResource(String iconPath) {
    Preconditions.checkNotEmptyString(iconPath, "Icon path should not be empty");

    String icon = iconPath.substring(FILE_PREFIX.length());
    File iconFile = new File(icon);
    if (!iconFile.exists()) {
        throw new IllegalArgumentException("Icon file does not exist: " + icon);
    }

    return new FileResource(iconFile);
}
 
Example #5
Source File: Icon.java    From chipster with MIT License 4 votes vote down vote up
public static Resource getResource(String path) {
	return new FileResource(new File(path));
}