Example usage for com.vaadin.ui Embedded setMimeType

List of usage examples for com.vaadin.ui Embedded setMimeType

Introduction

In this page you can find the example usage for com.vaadin.ui Embedded setMimeType.

Prototype

public void setMimeType(String mimeType) 

Source Link

Document

Sets the mimeType, the MIME-Type of the object.

Usage

From source file:annis.visualizers.component.AbstractDotVisualizer.java

License:Apache License

@Override
public ImagePanel createComponent(final VisualizerInput visInput, VisualizationToggle visToggle) {
    try {//from  w ww. j  a v a2  s .  co m

        final PipedOutputStream out = new PipedOutputStream();
        final PipedInputStream in = new PipedInputStream(out);

        new Thread(new Runnable() {
            @Override
            public void run() {
                writeOutput(visInput, out);
            }
        }).start();

        String fileName = "dotvis_" + new Random().nextInt(Integer.MAX_VALUE) + ".png";
        StreamResource resource = new StreamResource(new StreamResource.StreamSource() {

            @Override
            public InputStream getStream() {
                return in;
            }
        }, fileName);

        Embedded emb = new Embedded("", resource);
        emb.setMimeType("image/png");
        emb.setSizeFull();
        emb.setStandby("loading image");
        emb.setAlternateText("DOT graph visualization");
        return new ImagePanel(emb);

    } catch (IOException ex) {
        log.error(null, ex);
    }
    return new ImagePanel(new Embedded());
}

From source file:annis.visualizers.component.AbstractImageVisualizer.java

License:Apache License

@Override
public ImagePanel createComponent(final VisualizerInput visInput, VisualizationToggle visToggle) {

    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    writeOutput(visInput, out);//from www .ja va2s.c  o m

    String fileName = "vis_" + UUID.randomUUID().toString() + ".png";
    StreamResource resource = new StreamResource(new StreamResource.StreamSource() {
        @Override
        public InputStream getStream() {
            return new ByteArrayInputStream(out.toByteArray());
        }
    }, fileName);

    Embedded emb = new Embedded("", resource);
    emb.setMimeType(getContentType());
    emb.setSizeUndefined();
    emb.setStandby("loading image");
    emb.setAlternateText("Visualization of the result");

    return new ImagePanel(emb);
}

From source file:eu.lod2.LOD2Demo.java

License:Apache License

public void home() {
    workspace.removeAllComponents();/*from   w w  w  .j  ava  2 s  .  c  om*/
    workspace.setHeight("80%");

    HorizontalLayout introH = new HorizontalLayout();
    Embedded lod2cycle = new Embedded("", new ThemeResource("app_images/lod-lifecycle-small.png"));
    lod2cycle.setMimeType("image/png");
    introH.addComponent(lod2cycle);
    introH.setComponentAlignment(lod2cycle, Alignment.MIDDLE_LEFT);

    VerticalLayout introV = new VerticalLayout();
    introH.addComponent(introV);

    Label introtextl = new Label(introtext, Label.CONTENT_XHTML);
    introV.addComponent(introtextl);
    introtextl.setWidth("400px");

    HorizontalLayout introVH = new HorizontalLayout();
    introV.addComponent(introVH);

    Embedded euflag = new Embedded("", new ThemeResource("app_images/eu-flag.gif"));
    euflag.setMimeType("image/gif");
    introVH.addComponent(euflag);
    euflag.addStyleName("eugif");
    euflag.setHeight("50px");
    Embedded fp7 = new Embedded("", new ThemeResource("app_images/fp7-gen-rgb_small.gif"));
    fp7.setMimeType("image/gif");
    fp7.addStyleName("eugif");
    fp7.setHeight("50px");
    introVH.addComponent(fp7);

    workspace.addComponent(introH);

}

From source file:eu.lod2.stat.StatLOD2Demo.java

License:Apache License

public void home() {
    workspace.removeAllComponents();//from w  ww .j  a  v a  2s .  c om
    workspace.setHeight("80%");

    HorizontalLayout introH = new HorizontalLayout();
    Embedded lod2cycle = new Embedded("", new ThemeResource("app_images/lod-lifecycle-cube.jpg"));
    lod2cycle.setMimeType("image/png");
    introH.addComponent(lod2cycle);
    introH.setComponentAlignment(lod2cycle, Alignment.MIDDLE_LEFT);

    VerticalLayout introV = new VerticalLayout();
    introH.addComponent(introV);

    Label introtextl = new Label(introtext, Label.CONTENT_XHTML);
    introV.addComponent(introtextl);
    introtextl.setWidth("400px");

    HorizontalLayout introVH = new HorizontalLayout();
    introV.addComponent(introVH);

    Embedded euflag = new Embedded("", new ThemeResource("app_images/eu-flag.gif"));
    euflag.setMimeType("image/gif");
    introVH.addComponent(euflag);
    euflag.addStyleName("eugif");
    euflag.setHeight("50px");
    Embedded fp7 = new Embedded("", new ThemeResource("app_images/fp7-gen-rgb_small.gif"));
    fp7.setMimeType("image/gif");
    fp7.addStyleName("eugif");
    fp7.setHeight("50px");
    introVH.addComponent(fp7);

    workspace.addComponent(introH);

}

From source file:gov.va.ds4p.ds4pmobileportal.ui.eHealthExchange.java

License:Open Source License

private Popover getPopoverPDF(String val, String title) {
    Popover popover = new Popover();
    popover.setModal(true);/*from  www  .j a v  a 2  s.c om*/
    popover.setClosable(true);
    popover.setWidth("700px");
    popover.setHeight("100%");
    CssLayout popLayout = new CssLayout();
    popLayout.setSizeFull();
    popLayout.setMargin(true);

    NavigationView navView = new NavigationView(popLayout);
    navView.setCaption(title);

    CssLayout layout2 = new CssLayout();
    Embedded pdf = new Embedded();
    pdf.setType(Embedded.TYPE_BROWSER);
    pdf.setMimeType("application/pdf");
    pdf.setSizeFull();
    pdf.setWidth("100%");
    pdf.setHeight("700px");

    pdf.setSource(createPdf(val));

    layout2.addComponent(pdf);

    popLayout.addComponent(layout2);

    Button close = new Button(null, new ClickListener() {

        public void buttonClick(ClickEvent event) {
            event.getButton().getWindow().getParent().removeWindow(event.getButton().getWindow());
        }
    });
    close.setIcon(new ThemeResource("../runo/icons/64/cancel.png"));
    navView.setRightComponent(close);

    popover.setContent(navView);

    return popover;
}

From source file:nl.amc.biolab.nsg.display.component.ProcessingStatusForm.java

License:Open Source License

private void showHTML(final String htmlContent, final Application app)
        throws IllegalArgumentException, NullPointerException {
    app.getMainWindow().addWindow(new Window() {
        private static final long serialVersionUID = -2307854110750435145L;

        {// w ww . j a  v a2 s .  c o m
            center();
            setWidth("75%");
            setHeight("600px");
            StreamResource.StreamSource source = new StreamResource.StreamSource() {
                private static final long serialVersionUID = -3745013501121916404L;

                public InputStream getStream() {
                    return new ByteArrayInputStream(htmlContent.getBytes());
                }
            };
            StreamResource resource = new StreamResource(source, "TestReport.html", app);
            Embedded e = new Embedded();
            e.setMimeType("text/html");
            e.setType(Embedded.TYPE_BROWSER);
            e.setWidth("100%");
            e.setHeight("590px");
            e.setSource(resource);
            addComponent(e);
        }
    });
}

From source file:org.eclipse.hawkbit.ui.decorators.SPUIEmbedDecorator.java

License:Open Source License

/**
 * Decorate.// w  ww .j  a  v a 2 s.  c  om
 * 
 * @param spUIEmbdValue
 *            as DTO
 * @return Embedded as UI
 */
public static Embedded decorate(final SPUIEmbedValue spUIEmbdValue) {
    final Embedded spUIEmbd = new Embedded();
    spUIEmbd.setImmediate(spUIEmbdValue.isImmediate());
    spUIEmbd.setType(spUIEmbdValue.getType());

    if (null != spUIEmbdValue.getId()) {
        spUIEmbd.setId(spUIEmbdValue.getId());
    }

    if (null != spUIEmbdValue.getData()) {
        spUIEmbd.setData(spUIEmbdValue.getData());
    }

    if (null != spUIEmbdValue.getStyleName()) {
        spUIEmbd.setStyleName(spUIEmbdValue.getStyleName());
    }

    if (null != spUIEmbdValue.getSource()) {
        spUIEmbd.setSource(new ThemeResource(spUIEmbdValue.getSource()));
    }

    if (null != spUIEmbdValue.getMimeType()) {
        spUIEmbd.setMimeType(spUIEmbdValue.getMimeType());
    }

    if (null != spUIEmbdValue.getDescription()) {
        spUIEmbd.setDescription(spUIEmbdValue.getDescription());
    }

    return spUIEmbd;
}