Example usage for com.vaadin.ui Embedded Embedded

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

Introduction

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

Prototype

public Embedded(String caption, Resource source) 

Source Link

Document

Creates a new Embedded object whose contents is loaded from given resource.

Usage

From source file:edu.nps.moves.mmowgli.utility.MediaLocator.java

License:Open Source License

public Embedded getGuestLogin97w24h() {
    Embedded emb = new Embedded(null,
            locate(new Media("guestLogin97w24h.png", "", "", MediaType.IMAGE, Source.GAME_IMAGES_REPOSITORY)));
    emb.setWidth("97px");
    emb.setHeight("24px");
    return emb;//  w ww . j a  va2 s .  c  o  m
}

From source file:edu.vcu.csbc.vahmpexplorer.main.VaHMPExplorer.java

public Component createToolBar(boolean loggedIn) {
    HorizontalLayout h = new HorizontalLayout();
    h.setMargin(true);/*from  w ww .  j  av  a  2  s.  com*/
    h.setWidth("100%");

    Embedded headerImg = new Embedded(null, new ThemeResource("../vahmpexplorer/img/header.png"));
    headerImg.setWidth(311, Embedded.UNITS_PIXELS);
    headerImg.setHeight(45, Embedded.UNITS_PIXELS);
    headerImg.setType(Embedded.TYPE_IMAGE);
    headerImg.setStyleName(BaseTheme.BUTTON_LINK);
    headerImg.setDescription("Version " + HelpMessages.VERSION);
    h.addComponent(headerImg);

    if (loggedIn) {
        Panel panel = new Panel();
        Label loggedInUser = new Label(
                "Welcome: " + user.getFirstName() + " " + user.getLastName() + " (" + user.getLogin() + ")");
        changePassword = new Button("Change Password");
        changePassword.setStyleName(BaseTheme.BUTTON_LINK);
        changePassword.addListener((Button.ClickListener) this);

        logout = new Button("Logout");
        logout.setStyleName(BaseTheme.BUTTON_LINK);
        logout.addListener((Button.ClickListener) this);

        HorizontalLayout hl = new HorizontalLayout();
        hl.setSpacing(true);
        hl.addComponent(changePassword);
        hl.addComponent(logout);

        panel.addComponent(loggedInUser);
        panel.addComponent(hl);
        h.addComponent(panel);
        h.setComponentAlignment(panel, Alignment.MIDDLE_RIGHT);
    }
    PopupView help = new PopupView(new MainHelpPopup());
    h.addComponent(help);
    h.setComponentAlignment(help, Alignment.MIDDLE_RIGHT);
    h.setComponentAlignment(headerImg, Alignment.MIDDLE_LEFT);
    return h;
}

From source file:eu.lod2.LOD2Demo.java

License:Apache License

public void home() {
    workspace.removeAllComponents();//from  w w w .j  ava  2s  .co m
    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.OntoWikiQuery.java

License:Apache License

public OntoWikiQuery(LOD2DemoState st) {

    // The internal state and 
    state = st;//from w w  w .j a v a2 s .  c  om
    initLogin();

    VerticalLayout queryingTab = new VerticalLayout();

    final String query = "SELECT * where {?s ?p ?o.} LIMIT 20";
    String encodedQuery = "";
    String encodedGraphName = "";
    try {
        encodedQuery = URLEncoder.encode(query, "UTF-8");
        encodedGraphName = URLEncoder.encode(state.getCurrentGraph(), "UTF-8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    ;

    if (encodedGraphName.equals("")) {
        Label l = new Label("One must select a current graph to use this functionality.");
        queryingTab.addComponent(l);
    } else {
        String redirecturi = service + "/queries/editor/?query=" + encodedQuery + "&m=" + encodedGraphName;
        URL request = loginandqueryRequest(redirecturi);
        if (request == null) {
            Label l = new Label(
                    "The settings are incorrect to result in a valid URL which gives access to this functionality.");
            queryingTab.addComponent(l);
        } else {
            Embedded browser = new Embedded("", new ExternalResource(request));
            browser.setType(Embedded.TYPE_BROWSER);
            browser.setSizeFull();
            queryingTab.addComponent(browser);
        }
    }
    /*
       Label l = new Label(service + "/queries/editor/?query="+ encodedQuery + "&m=" + encodedGraphName);
       queryingTab.addComponent(l);
            
       Embedded browser = new Embedded();
       try { 
       URL url;
       if (encodedGraphName.equals("")) {
       url = new URL(service + "/queries/editor/?query="+ encodedQuery);
       } else {
       url = new URL(service + "/queries/editor/?query="+ encodedQuery + "&m=" + encodedGraphName);
       };
       browser = new Embedded("", new ExternalResource(url));
       browser.setType(Embedded.TYPE_BROWSER);
       browser.setSizeFull();
       } catch (MalformedURLException e) {
       e.printStackTrace();
       };
            
       queryingTab.addComponent(browser);
     */
    // The composition root MUST be set
    queryingTab.setSizeFull();
    setCompositionRoot(queryingTab);
}

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

License:Apache License

public void home() {
    workspace.removeAllComponents();// w  w  w  .ja v  a2s .c  o  m
    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:fi.racetrace.adminpanel.ui.columngenerator.DeviceIconGC.java

License:Open Source License

@Override
public Object generateCell(Table source, Object itemId, Object columnId) {
    Component c = null;// w  w w .  j av  a 2 s  .c  om

    if (source.isEditable() && itemId.equals(source.getValue())) {
        // TODO bindaus modeliin
        ComboBox cb = new ComboBox("Icon", new BeanItemContainer<fi.racetrace.adminpanel.data.DeviceIcon>(
                fi.racetrace.adminpanel.data.DeviceIcon.class, icons));
        cb.setWidth(100, Unit.PIXELS);

        final Item sdItem = source.getItem(itemId);

        cb.setValue(sdItem.getItemProperty("icon"));

        cb.addValueChangeListener(new ValueChangeListener() {

            @Override
            public void valueChange(ValueChangeEvent event) {
                sdItem.getItemProperty("icon").setValue(event.getProperty().getValue());
            }
        });

        c = cb;
    } else {
        Item item = source.getItem(itemId);
        DeviceIcon di = ((DeviceIcon) item.getItemProperty("icon").getValue());
        if (di != null) {
            String icon = di.getPath();
            Embedded e = new Embedded("icon", new ThemeResource("img/" + icon));
            c = e;
        } else {
            Label l = new Label("N/A");
            c = l;
        }
    }
    return c;
}

From source file:fi.vtt.RVaadin.RContainer.java

License:Apache License

/**
 * Get a Vaadin Embedded image object that contains the corresponding R plot
 * generated by submitting and evaluating the RPlotCall String. The
 * imageName corresponds to the downloadable .png image name. The full name
 * of the images shown in the browser are
 * imageName_ISODate_runningId_[sessionId].png, e.g.
 * 'Image_2012-08-29_001_[bmgolmfgvk].png' to keep them chronologically
 * ordered.//from w ww  .  ja v a  2  s . c  o  m
 * 
 * @param RPlotCall
 *            the String to be evaluated by R
 * @param width
 *            plot width in pixels
 * @param height
 *            plot height in pixels
 * @return The image as Embedded Vaadin object
 */
public Embedded getEmbeddedGraph(String RPlotCall, int width, int height, String imageName) {

    StreamResource imageresource = getImageResource(RPlotCall, width, height, imageName, "png");

    /*
     * Create an embedded component that gets its contents from the
     * resource.
     */
    return new Embedded(null, imageresource);
}

From source file:foo.MyVaadinApplication.java

License:Apache License

/**
 * Initializes the top banner/* w w  w.j a va2 s  .  c  o  m*/
 * 
 * @return initialized top banner
 */
private Panel initTopBanner() {
    Panel topBanner = new Panel();
    topBanner.setWidth("100%");

    String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath();

    FileResource resource = new FileResource(new File(basepath + "/WEB-INF/images/topBannerPlaceholder.png"));

    Embedded image = new Embedded("", resource);

    VerticalLayout v = new VerticalLayout();
    v.addComponent(image);
    topBanner.setContent(v);

    return topBanner;
}

From source file:foo.MyVaadinApplication.java

License:Apache License

/**
 * Initializes the bottom banner//from   ww w  .  j  a  v  a  2s.  c o m
 * 
 * @return initialized bottom banner
 */
private Panel initBottomBanner() {
    Panel bottomBanner = new Panel();
    bottomBanner.setWidth("100%");

    String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath();

    FileResource resource = new FileResource(
            new File(basepath + "/WEB-INF/images/bottomBannerPlaceholder.png"));

    Embedded image = new Embedded("", resource);

    VerticalLayout v = new VerticalLayout();
    v.addComponent(image);
    bottomBanner.setContent(v);

    return bottomBanner;
}

From source file:infodoc.ui.module.help.AboutWindow.java

License:Open Source License

public AboutWindow() {
    super(InfodocConstants.uiAbout);
    addStyleName(InfodocTheme.WINDOW_OPAQUE);
    setIcon(new ThemeResource(InfodocTheme.iconAbout));
    setSizeUndefined();//from   ww w .j  a  v  a2s  .  c  o m
    setWidth("580px");
    setResizable(false);

    String installedModules = InfodocConstants.infodocModules.replace(" ", "");
    String installedModulesHtml = "";

    for (String module : installedModules.split(",")) {
        installedModulesHtml += "<span style='margin-left: 20px;'>" + module + "</span><br/>";
    }

    String top = "<h2><i>InfoDoc " + InfodocConstants.infodocVersion + "</i></h2>" + "Modules:" + "<pre><small>"
            + installedModulesHtml + "</small></pre>" + "<br/>License granted to:"
            + "<pre><small><span style='margin-left: 20px;'>" + InfodocConstants.infodocCompanyName + "</span>"
            + (InfodocConstants.infodocCompanyId == null ? ""
                    : "<br/><span style='margin-left: 20px;'> " + InfodocConstants.infodocCompanyId + "</span>")
            + (InfodocConstants.infodocCompanyAddress == null ? ""
                    : "<br/><span style='margin-left: 20px;'>" + InfodocConstants.infodocCompanyAddress
                            + "</span></pre></small>")
            + "<br/><br/>";

    String lower = "<br/>Contact the developer: <a href='" + InfodocConstants.infodocDeveloperUrl + "'>"
            + InfodocConstants.infodocDeveloperUrl + "</a>," + "<br/><b>All rights reserved</b>.";

    Label topLabel = new Label(top, Label.CONTENT_XHTML);
    Label lowerLabel = new Label(lower, Label.CONTENT_XHTML);
    lowerLabel.addStyleName(InfodocTheme.LABEL_TINY);

    VerticalLayout rightLayout = new VerticalLayout();
    rightLayout.setMargin(true);
    rightLayout.setStyleName(InfodocTheme.PANEL_LIGHT);
    rightLayout.addStyleName(InfodocTheme.PANEL_BORDERLESS);
    rightLayout.addStyleName(InfodocTheme.COOL_FONT);
    rightLayout.addComponent(topLabel);
    rightLayout.addComponent(lowerLabel);

    VerticalLayout leftLayout = new VerticalLayout();
    leftLayout.setWidth("130px");
    leftLayout.addComponent(new Label("<h2></h2>", Label.CONTENT_XHTML));
    leftLayout.addComponent(new Embedded(null, new ThemeResource(InfodocTheme.infodocBoxImage)));

    HorizontalLayout layout = new HorizontalLayout();
    layout.setSizeFull();
    layout.addComponent(leftLayout);
    layout.addComponent(rightLayout);
    layout.setExpandRatio(rightLayout, 1);

    Panel panel = new Panel();
    panel.addComponent(layout);

    setContent(panel);
}