Examples of StreamResource


Examples of com.vaadin.server.StreamResource

    @Override
    protected void init(VaadinRequest request) {
        Button downloadButton = new Button("Download image");

        StreamResource myResource = createResource();
        FileDownloader fileDownloader = new FileDownloader(myResource);
        fileDownloader.extend(downloadButton);

        setContent(downloadButton);
    }
View Full Code Here

Examples of com.vaadin.server.StreamResource

        setContent(downloadButton);
    }

    private StreamResource createResource() {
        return new StreamResource(new StreamSource() {
            @Override
            public InputStream getStream() {
                String text = "My image";
                BufferedImage bi = new BufferedImage(100, 30,
                        BufferedImage.TYPE_3BYTE_BGR);
View Full Code Here

Examples of com.vaadin.server.StreamResource

    protected void setup() {

        final Styles stylesheet = Page.getCurrent().getStyles();

        // Inject some resources initially
        final StreamResource initialResource = new StreamResource(
                new StreamResource.StreamSource() {

                    @Override
                    public InputStream getStream() {
                        return new ByteArrayInputStream(
                                ".hello, .world { color:silver; }".getBytes());
                    }
                }, "mystyles-" + System.currentTimeMillis() + ".css");
        stylesheet.add(initialResource);

        Label hello = new Label(
                "<span class='hello'>Hello</span> <span class='world'>world</span>",
                ContentMode.HTML);
        addComponent(hello);

        final TextArea cssToInject = new TextArea();
        cssToInject.setImmediate(true);
        addComponent(cssToInject);

        Button inject = new Button("Inject!", new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                stylesheet.add(cssToInject.getValue());
                cssToInject.setValue("");
            }
        });
        addComponent(inject);

        Button injectRandom = new Button("Inject as resource!",
                new Button.ClickListener() {

                    @Override
                    public void buttonClick(ClickEvent event) {

                        final String css = cssToInject.getValue();

                        stylesheet.add(new StreamResource(
                                new StreamResource.StreamSource() {

                                    @Override
                                    public InputStream getStream() {
                                        return new ByteArrayInputStream(css
View Full Code Here

Examples of com.vaadin.server.StreamResource

*/
public class TestStreamResource {

    @Test
    public void testEqualsWithNullFields() {
        StreamResource resource1 = new StreamResource(null, null);
        StreamResource resource2 = new StreamResource(null, null);

        Assert.assertEquals(resource1, resource2);
    }
View Full Code Here

Examples of com.vaadin.server.StreamResource

        Assert.assertEquals(resource1, resource2);
    }

    @Test
    public void testNotEqualsWithNullFields() {
        StreamResource resource1 = new StreamResource(null, null);
        StreamResource resource2 = new StreamResource(
                EasyMock.createMock(StreamSource.class), "");

        Assert.assertNotEquals(resource1, resource2);
    }
View Full Code Here

Examples of com.vaadin.server.StreamResource

        Assert.assertNotEquals(resource1, resource2);
    }

    @Test
    public void testHashCodeForNullFields() {
        StreamResource resource = new StreamResource(null, null);
        // No NPE
        resource.hashCode();
    }
View Full Code Here

Examples of com.vaadin.server.StreamResource

        final Label label = new Label(labelText());
        addComponent(label);

        final Image image = new Image();
        final MyImageSource imageSource = new MyImageSource();
        final StreamResource imageResource = new StreamResource(imageSource,
                "testimage.png");
        image.setSource(imageResource);
        image.addClickListener(new ClickListener() {

            @Override
            public void click(ClickEvent event) {
                ++clickCounter;
                imageResource.setFilename("testimage.png?"
                        + new Date().getTime());
                image.markAsDirty();
                label.setValue(labelText());
            }
View Full Code Here

Examples of com.vaadin.server.StreamResource

                        return new ByteArrayInputStream(byteArray);
                    }
                    return null;
                }
            };
            return new StreamResource(streamSource, getName());
        }
View Full Code Here

Examples of com.vaadin.server.StreamResource

        // addComponents(resource, components);
        // resource = new ExternalResource(
        // "https://vaadin.com/download/book-of-vaadin/current/pdf/book-of-vaadin.pdf");
        // addComponents(resource, components);
        ConnectorResource resource;
        resource = new StreamResource(new StreamResource.StreamSource() {

            @Override
            public InputStream getStream() {
                try {
                    BufferedImage img = getImage2("demo.png");
View Full Code Here

Examples of com.vaadin.server.StreamResource

        embedded.setDescription("Click on the grid cells to switch them.");
        addComponent(embedded);

        // Attach it to a resource.
        final MyImageSource imageSource = new MyImageSource();
        final StreamResource imageResource = new StreamResource(imageSource,
                "testimage.png");
        imageResource.setCacheTime(0);
        embedded.setSource(imageResource);

        // The button requests repainting the embedded.
        Button button = new Button("refr");
        button.addListener(new Button.ClickListener() {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.