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:org.diretto.web.richwebclient.view.sections.UploadSection.java

/**
 * Uploads the currently processed file.
 * /*from w  w w .  j a va2s . c o  m*/
 * @param uploadSettings The {@code UploadSettings} of the file
 * @param filesWithSameSettings A {@code List} with the names of the files
 *        which should get the given {@code UploadSettings} as presetting
 */
public void upload(final UploadSettings uploadSettings, List<String> filesWithSameSettings) {
    final FileInfo fileInfo = currentFile;

    settings.put(fileInfo.getName(), uploadSettings);

    for (String fileName : filesWithSameSettings) {
        preSettings.put(fileName, uploadSettings);
    }

    new Thread(new Runnable() {
        @Override
        public void run() {
            ProgressIndicator progressIndicator = multipleUpload.upload(fileInfo);

            synchronized (application) {
                VerticalLayout uploadBoxLayout = new VerticalLayout();
                mainLayout.addComponent(uploadBoxLayout);

                HorizontalLayout fileInfoLayout = new HorizontalLayout();
                uploadBoxLayout.addComponent(fileInfoLayout);

                Label nameLabel = StyleUtils.getLabelBold(fileInfo.getName());
                fileInfoLayout.addComponent(nameLabel);
                fileInfoLayout.addComponent(StyleUtils.getLabelSmallHTML("&nbsp;&nbsp;&nbsp;"));
                fileInfoLayout.setComponentAlignment(nameLabel, Alignment.MIDDLE_LEFT);

                BigDecimal fileSize = new BigDecimal((((double) fileInfo.getSize()) / 1000000.0d));
                fileSize = fileSize.setScale(2, BigDecimal.ROUND_HALF_UP);

                Label typeSizeLabel = StyleUtils.getLabelSmallHTML(
                        fileInfo.getType() + "&nbsp;&nbsp;--&nbsp;&nbsp;" + fileSize.toPlainString() + " MB");
                fileInfoLayout.addComponent(typeSizeLabel);
                fileInfoLayout.setComponentAlignment(typeSizeLabel, Alignment.MIDDLE_LEFT);

                uploadBoxLayout.addComponent(StyleUtils.getVerticalSpace("100%", "8px"));

                uploadBoxLayout.addComponent(progressIndicator);

                uploadBoxLayout.addComponent(StyleUtils.getVerticalSpace("100%", "8px"));

                HorizontalLayout resultLayout = new HorizontalLayout();
                uploadBoxLayout.addComponent(resultLayout);

                Label uploadedLabel = StyleUtils.getLabelSmallHTML("Uploaded:&nbsp;");
                resultLayout.addComponent(uploadedLabel);
                resultLayout.setComponentAlignment(uploadedLabel, Alignment.MIDDLE_LEFT);

                Embedded uploadedEmbedded = new Embedded(null, ResourceUtils.RUNO_ICON_32_GLOBE_RESOURCE);
                uploadedEmbedded.addStyleName("image-opacity-65");
                uploadedEmbedded.setType(Embedded.TYPE_IMAGE);
                uploadedEmbedded.setImmediate(true);
                uploadedEmbedded.setWidth("22px");
                uploadedEmbedded.setHeight("22px");
                resultLayout.addComponent(uploadedEmbedded);

                uploadedEmbeddeds.put(fileInfo, uploadedEmbedded);

                resultLayout.addComponent(StyleUtils.getLabelSmallHTML("&nbsp;&nbsp;&nbsp;"));

                Label publishedLabel = StyleUtils.getLabelSmallHTML("Published:&nbsp;");
                resultLayout.addComponent(publishedLabel);
                resultLayout.setComponentAlignment(publishedLabel, Alignment.MIDDLE_LEFT);

                Embedded publishedEmbedded = new Embedded(null, ResourceUtils.RUNO_ICON_32_GLOBE_RESOURCE);
                publishedEmbedded.addStyleName("image-opacity-65");
                publishedEmbedded.setType(Embedded.TYPE_IMAGE);
                publishedEmbedded.setImmediate(true);
                publishedEmbedded.setWidth("22px");
                publishedEmbedded.setHeight("22px");
                resultLayout.addComponent(publishedEmbedded);

                publishedEmbeddeds.put(fileInfo, publishedEmbedded);

                mainLayout.addComponent(StyleUtils.getVerticalSpace("100%", "5px"));

                requestRepaint();
            }
        }
    }).start();

    handleNextFile();
}

From source file:org.eclipse.skalli.view.component.Tray.java

License:Open Source License

private ComponentContainer createContent(String caption, String description, ThemeResource icon,
        boolean isRequired) {
    CssLayout layout = new CssLayout();
    layout.setStyleName(STYLE_TRAY);//from w  w w  . ja va  2 s .  co m
    layout.setMargin(true);

    HorizontalLayout header = new HorizontalLayout();
    header.setSpacing(true);
    header.setStyleName(STYLE_TRAY_HEADER);
    header.setWidth("100%");

    this.icon = icon;
    trayIcon = new Embedded(null, icon);
    trayIcon.setStyleName(STYLE_TRAY_HEADER_ICON);
    header.addComponent(trayIcon);
    header.setComponentAlignment(trayIcon, Alignment.MIDDLE_LEFT);
    header.setExpandRatio(trayIcon, 0);

    Label captionLabel = new Label(StringEscapeUtils.escapeHtml(caption), Label.CONTENT_XHTML);
    captionLabel.setStyleName(STYLE_TRAY_HEADER_LABEL);
    header.addComponent(captionLabel);
    header.setExpandRatio(captionLabel, 1);
    header.setComponentAlignment(captionLabel, Alignment.MIDDLE_LEFT);

    this.isRequired = isRequired;
    if (!isRequired) {
        activator = new NativeButton("", new ToggleEnabledListener());
        header.addComponent(activator);
        header.setExpandRatio(activator, 0);
        header.setComponentAlignment(activator, Alignment.MIDDLE_RIGHT);
    }

    opener = new NativeButton("", new ToggleVisibleListener());
    header.addComponent(opener);
    header.setExpandRatio(opener, 0);
    header.setComponentAlignment(opener, Alignment.MIDDLE_RIGHT);

    layout.addComponent(header);

    CssLayout content = new CssLayout();
    Label descriptionLabel = new Label(HtmlUtils.clean(description), Label.CONTENT_XHTML);
    descriptionLabel.setStyleName(STYLE_TRAY_DESCRIPTION);
    content.addComponent(descriptionLabel);

    layout.addComponent(content);
    setCompositionRoot(layout);
    return content;
}

From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.ReviewComponent.java

License:Open Source License

private void paintReviewGrid() {
    if (reviewGrid == null) {
        reviewGrid = new GridLayout(2, currentPageLength);
        reviewGrid.setSizeFull();/*from  w  w w  .ja v a 2 s  .  co  m*/
        reviewGrid.setSpacing(true);
        layout.addComponent(reviewGrid);
    } else {
        reviewGrid.removeAllComponents();
    }
    int rows = reviewGrid.getRows();
    if (rows != currentPageLength) {
        reviewGrid.setRows(Math.min(size, currentPageLength));
    }

    int row = 0;
    List<ReviewEntry> latestReviews = getLatestReviews(currentPage, currentPageLength);
    for (ReviewEntry review : latestReviews) {
        ProjectRating rating = review.getRating();
        Embedded e = new Embedded(null, getIcon(rating));
        e.setDescription(getDescription(rating));
        e.setWidth("22px"); //$NON-NLS-1$
        e.setHeight("22px"); //$NON-NLS-1$
        reviewGrid.addComponent(e, 0, row);

        StringBuilder sb = new StringBuilder();
        sb.append("<span style=\"white-space:normal\">"); //$NON-NLS-1$
        sb.append(HtmlUtils.clean(review.getComment()));
        sb.append("<br>"); //$NON-NLS-1$
        sb.append("<span style=\"font-size:x-small\">").append(" posted by "); //$NON-NLS-1$
        sb.append(StringEscapeUtils.escapeHtml(review.getVoter()));
        sb.append(" "); //$NON-NLS-1$

        long deltaMillis = System.currentTimeMillis() - review.getTimestamp();
        long deltaDays = deltaMillis / MILLIS_PER_DAY;
        if (deltaDays > 0) {
            sb.append(deltaDays);
            sb.append(" days ago");
        } else {
            long deltaHours = deltaMillis / MILLIS_PER_HOUR;
            if (deltaHours > 0) {
                sb.append(deltaHours).append(" hours ago");
            } else {
                long deltaMinutes = deltaMillis / MILLIS_PER_MINUTE;
                if (deltaMinutes > 0) {
                    sb.append(deltaMinutes).append(" minutes ago");
                } else {
                    sb.append(" just now");
                }
            }
            sb.append("</span></span>"); //$NON-NLS-1$
        }
        CssLayout css = new CssLayout();
        css.setSizeFull();
        Label comment = new Label(sb.toString(), Label.CONTENT_XHTML);
        comment.setSizeUndefined();
        css.addComponent(comment);
        reviewGrid.addComponent(css, 1, row);
        reviewGrid.setColumnExpandRatio(1, 1.0f);
        ++row;
    }
}

From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.ReviewComponent.java

License:Open Source License

@SuppressWarnings("serial")
private Window createReviewWindow(final ProjectRating rating) {
    final Window subwindow = new Window("Rate and Review");
    subwindow.setModal(true);// w w  w .ja  v  a 2s  .  c o  m
    subwindow.setWidth("420px"); //$NON-NLS-1$
    subwindow.setHeight("320px"); //$NON-NLS-1$

    VerticalLayout vl = (VerticalLayout) subwindow.getContent();
    vl.setSpacing(true);
    vl.setSizeFull();

    HorizontalLayout hl = new HorizontalLayout();
    hl.setSizeUndefined();

    Embedded icon = new Embedded(null, getIcon(rating));
    Label iconLabel = new Label("<b>" + HSPACE + getReviewComment(rating) + "</b>", Label.CONTENT_XHTML); //$NON-NLS-1$ //$NON-NLS-2$
    String captionTextField = getReviewCommentQuestion(rating);
    hl.addComponent(icon);
    hl.addComponent(iconLabel);
    hl.setComponentAlignment(iconLabel, Alignment.MIDDLE_LEFT);
    vl.addComponent(hl);

    final TextField editor = new TextField(captionTextField);
    editor.setRows(3);
    editor.setColumns(30);
    editor.setImmediate(true);
    vl.addComponent(editor);

    final User user = util.getLoggedInUser();
    final ArrayList<String> userSelects = new ArrayList<String>(2);
    userSelects.add("I want to vote as " + user.getDisplayName());
    if (extension.getAllowAnonymous()) {
        userSelects.add("I want to vote as Anonymous!");
    }
    final OptionGroup userSelect = new OptionGroup(null, userSelects);
    userSelect.setNullSelectionAllowed(false);
    userSelect.select(userSelects.get(0));
    vl.addComponent(userSelect);

    CssLayout css = new CssLayout() {
        @Override
        protected String getCss(Component c) {
            return "margin-left:5px;margin-right:5px;margin-top:10px"; //$NON-NLS-1$
        }
    };

    Button okButton = new Button("OK");
    okButton.setIcon(ICON_BUTTON_OK);
    okButton.setDescription("Commit changes");
    okButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            String comment = (String) editor.getValue();
            if (StringUtils.isBlank(comment)) {
                comment = "No Comment";
            }
            ((Window) subwindow.getParent()).removeWindow(subwindow);
            String userName = "Anonymous";
            if (userSelects.get(0).equals(userSelect.getValue())) {
                userName = user.getDisplayName();
            }
            ReviewEntry review = new ReviewEntry(rating, comment, userName, System.currentTimeMillis());
            extension.addReview(review);
            util.persist(project);
            reviews = extension.getReviews();
            size = reviews.size();
            currentPage = 0;
            lastPage = size / currentPageLength;
            paintReviewList();
        }
    });
    css.addComponent(okButton);

    Button cancelButton = new Button("Cancel");
    cancelButton.setIcon(ICON_BUTTON_CANCEL);
    cancelButton.setDescription("Discard changes");
    cancelButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            ((Window) subwindow.getParent()).removeWindow(subwindow);
        }
    });
    css.addComponent(cancelButton);

    vl.addComponent(css);
    vl.setComponentAlignment(css, Alignment.MIDDLE_CENTER);

    return subwindow;
}

From source file:org.escidoc.browser.ui.mainpage.HeaderContainer.java

License:Open Source License

private void addNormalLayout() {
    headerContainer = new HorizontalLayout();
    headerContainer.setStyleName(Reindeer.LAYOUT_WHITE);
    headerContainer.setWidth("100%");
    headerContainer.setHeight("55px");
    headerContainer.addStyleName("header");
    HorizontalLayout hlLogo = new HorizontalLayout();

    Resource res = new ThemeResource("images/escidoc-logo-klein.jpg");
    Embedded e = new Embedded(null, res);
    e.setHeight(50 + "px");
    hlLogo.addComponent(e);//from   www  . j a  v a 2  s  . co  m

    headerContainer.addComponent(hlLogo);
    headerContainer.setExpandRatio(hlLogo, 0.2f);

    hl = new HorizontalLayout();
    headerContainer.addComponent(hl);
    headerContainer.setExpandRatio(hl, 0.8f);
    this.addComponent(headerContainer);
    headerContainer.setComponentAlignment(hl, Alignment.MIDDLE_RIGHT);

}

From source file:org.fossa.rolp.demo.DemoWelcomeScreen.java

License:Open Source License

public DemoWelcomeScreen(RolpApplication app, FossaAuthorizer authorizer) {
    super(app);/* w  ww  . jav a 2  s .c  o m*/
    this.app = app;
    setStyleName("demo");
    setWidth("900px");
    center();
    this.authorizer = authorizer;
    CustomLayout layout = new CustomLayout("./demo/welcomeScreen");
    CustomLayout layoutTop = new CustomLayout("./demo/welcomeScreenTop");
    CustomLayout layoutMiddle = new CustomLayout("./demo/welcomeScreenMiddle");
    CustomLayout layoutBottom = new CustomLayout("./demo/welcomeScreenBottom");

    Embedded logoRolp = new Embedded(null, new ThemeResource(DEMO_LOGO_ROLP_PATH));
    logoRolp.setType(Embedded.TYPE_IMAGE);
    logoRolp.setWidth("100px");
    logoRolp.setHeight("96px");

    Label rolpDemoText = new Label(
            "<h2>Wilkommen</h2>Dies ist eine Demoversion der Software ROLP. Whlen Sie eine Rolle aus, um in das entsprechende Szenario zu gelangen. Der Schulleiter hat eine eigene Verwaltungsoberflche, wo er die Lehrer und Klassen berblicken und zuweisen kann. Als Klassenlehrer und Fachlehrer gelangt man auf den Startbildschirm. Von da aus gelangt man zum Klassenlehrer-Dashboard und dem Fachlehrer-Dashboard. Der Klassenlehrer hat Zugang zu beiden Dashboards, da er im Normalfall auch Fcher unterrichtet.",
            Label.CONTENT_XHTML);
    Label githubLinkDummy = new Label(
            "ROLP auf <a href=\"https://github.com/fossaag/rolp\" target=\"_blank\">GitHub.com</a>",
            Label.CONTENT_XHTML);

    Embedded logoFossa = new Embedded(null, new ThemeResource(DEMO_LOGO_FOSSA_PATH));
    logoFossa.setType(Embedded.TYPE_IMAGE);
    logoFossa.setWidth("150px");

    Label roleSelectCaption = new Label("Bitte whlen Sie eine Rolle aus:", Label.CONTENT_XHTML);

    BeanItemContainer<String> roles = new BeanItemContainer<String>(String.class);
    roles.addBean("Fachlehrer");
    roles.addBean("Klassenlehrer");
    roles.addBean("Schulleiter");
    roleSelect.setContainerDataSource(roles);
    roleSelect.setWidth("200px");

    layoutTop.addComponent(logoRolp, "logoRolp");
    layoutTop.addComponent(rolpDemoText, "rolpDemoText");
    layoutTop.addComponent(logoFossa, "logoFossa");
    layout.addComponent(layoutTop, "layoutTop");

    layoutMiddle.addComponent(roleSelectCaption, "roleSelectCaption");
    layoutMiddle.addComponent(roleSelect, "roleSelect");
    layoutMiddle.addComponent(okButton, "okButton");
    layout.addComponent(layoutMiddle, "layoutMiddle");

    layoutBottom.addComponent(githubLinkDummy, "githubLinkDummy");
    layout.addComponent(layoutBottom, "layoutBottom");
    setContent(layout);
}

From source file:org.fossa.rolp.RolpApplication.java

License:Open Source License

@Override
public void buildMainLayout() {
    Embedded logo = new Embedded(null, new ThemeResource(MAINPAGE_PANEL_ANMELDEN_LOGO_PATH));
    logo.setType(Embedded.TYPE_IMAGE);//from  w w w.  j a v  a2s . c o  m
    logo.setWidth("100px");
    logo.setHeight("96px");
    headlineApp.addComponent(logo, "logo");
    headlineApp.addComponent(authorizerLayout, "authorizerLayout");
    headlineApp.addStyleName("headlineApp");

    layout.addComponent(headlineApp, "headlineApp");

    getMainWindow().setContent(layout);
    getMainWindow().addComponent(getAnimator());

    if (getLoginLehrer().getIsAdmin()) {
        layout.addComponent(getAdminDashboard(), "admin");
    } else {
        layout.addComponent(main, "main");
        buildAppLayout();
    }
}

From source file:org.fossa.rolp.ui.dashboard.FachlehrerDashboard.java

License:Open Source License

public FachlehrerDashboard(RolpApplication app) {
    super(app);/*  w ww.  j  av  a  2 s.  com*/
    this.app = app;
    setCaption(" - FachlehrerDashboard - ");
    setWidth("100%");
    setHeight("100%");

    buildButtonBatteries();

    CustomLayout layout = new CustomLayout("./lehrerDashboards/fachLehrerDashboardMain");
    setContent(layout);

    CustomLayout headline = new CustomLayout("./lehrerDashboards/headline");
    headline.addStyleName("headline");

    Embedded logo = new Embedded(null, new ThemeResource(MAINPAGE_PANEL_ANMELDEN_LOGO_PATH));
    logo.setType(Embedded.TYPE_IMAGE);
    logo.setWidth("100px");
    logo.setHeight("96px");

    headline.addComponent(logo, "logo");

    CustomLayout faecherListe = new CustomLayout("./lehrerDashboards/liste");
    faecherListe.addStyleName("liste");
    faecherList = getFaecherList();
    faecherList.setHeight("250px");
    faecherList.setStyleName("list");
    faecherListe.addComponent(faecherList, "list");
    faecherListe.setHeight("260px");

    layout.addComponent(faecherListe, "liste");
    layout.addComponent(headline, "headline");
    layout.addComponent(horizontalButtonBattery, "horizontalButtonBattery");

    lehrerBlog = getLehrerBlog();
    layout.addComponent(lehrerBlog, "blog");
    windowCloseButton.setWidth("100%");
    layout.addComponent(windowCloseButton, "windowCloseButton");

}

From source file:org.fossa.rolp.ui.dashboard.KlassenlehrerDashboard.java

License:Open Source License

public KlassenlehrerDashboard(RolpApplication app) {
    super(app);//  ww w . jav  a2 s  . c o  m
    this.app = app;
    setCaption(" - KlassenlehrerDashboard - ");
    setWidth("100%");
    setHeight("100%");

    buildButtonBatteries();

    CustomLayout layout = new CustomLayout("./lehrerDashboards/klassenLehrerDashboardMain");
    setContent(layout);

    CustomLayout headline = new CustomLayout("./lehrerDashboards/headline");
    headline.addStyleName("headline");

    Embedded logo = new Embedded(null, new ThemeResource(MAINPAGE_PANEL_ANMELDEN_LOGO_PATH));
    logo.setType(Embedded.TYPE_IMAGE);
    logo.setWidth("100px");
    logo.setHeight("96px");

    headline.addComponent(logo, "logo");
    headline.addComponent(headdataEditingPanel, "headdataEditingPanel");

    Panel hints = new Panel();
    hints.addStyleName("hints");
    hinweistext = new Label();
    hinweistext.setContentMode(Label.CONTENT_XHTML);
    hinweistext.setReadOnly(true);
    hinweistext.setHeight("250px");
    hints.setHeight("250px");
    hints.setScrollable(true);
    hints.addComponent(hinweistext);
    refreshHinweistext();

    CustomLayout schuelerListe = new CustomLayout("./lehrerDashboards/liste");
    schuelerListe.addStyleName("liste");
    schuelerList = getSchuelerList();
    schuelerList.setHeight("250px");
    schuelerList.setStyleName("list");
    schuelerListe.addComponent(schuelerList, "list");
    schuelerListe.setHeight("260px");
    layout.addComponent(schuelerListe, "liste");

    layout.addComponent(headline, "headline");
    layout.addComponent(horizontalButtonBattery, "horizontalButtonBattery");
    layout.addComponent(verticalButtonBattery, "verticalButtonBattery");

    layout.addComponent(hints, "hints");
    windowCloseButton.setWidth("100%");
    layout.addComponent(windowCloseButton, "windowCloseButton");
    //      app.getAnimator().animate(horizontalButtonBattery, AnimType.ROLL_DOWN_OPEN_POP).setDuration(500).setDelay(500);
}

From source file:org.generationcp.breeding.manager.crossingmanager.EmbeddedGermplasmListDetailComponent.java

License:Open Source License

@Override
public void afterPropertiesSet() throws Exception {
    setMargin(false);/*from  ww w  .j  ava 2  s .c  o m*/
    setSpacing(true);
    setWidth("800px");

    Tool tool = null;
    try {
        tool = workbenchDataManager.getToolWithName(ToolName.germplasm_list_browser.toString());
    } catch (MiddlewareQueryException qe) {
        LOG.error("QueryException", qe);
    }

    ExternalResource listBrowserLink = null;
    if (tool == null) {
        listBrowserLink = new ExternalResource(
                "http://localhost:18080/GermplasmStudyBrowser/main/germplasmlist-" + listId);
    } else {
        listBrowserLink = new ExternalResource(
                tool.getPath().replace("germplasmlist/", "germplasmlist-") + listId);
    }

    VerticalLayout layoutForList = new VerticalLayout();
    layoutForList.setMargin(false);
    layoutForList.setSpacing(false);

    Embedded listInfoPage = new Embedded("", listBrowserLink);
    listInfoPage.setType(Embedded.TYPE_BROWSER);
    listInfoPage.setSizeFull();
    layoutForList.setHeight("550px");
    layoutForList.addComponent(listInfoPage);

    CrossingManagerImportButtonClickListener listener = new CrossingManagerImportButtonClickListener(this);

    exportButton = new Button();
    exportButton.setData(EXPORT_BUTTON_ID);
    exportButton.addListener(listener);

    makeCrossesButton = new Button();
    makeCrossesButton.setData(MAKE_CROSSES_BUTTON_ID);
    makeCrossesButton.addListener(listener);

    HorizontalLayout buttonArea = new HorizontalLayout();
    buttonArea.setMargin(true);
    buttonArea.setSpacing(true);
    buttonArea.addComponent(exportButton);
    buttonArea.addComponent(makeCrossesButton);

    addComponent(layoutForList);
    addComponent(buttonArea);
    setComponentAlignment(buttonArea, Alignment.BOTTOM_RIGHT);
}