Example usage for com.vaadin.ui Image Image

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

Introduction

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

Prototype

public Image(String caption, Resource source) 

Source Link

Document

Creates a new Image whose contents is loaded from given resource.

Usage

From source file:com.haulmont.cuba.web.LoginWindow.java

License:Apache License

@Nullable
protected Image getLogoImage() {
    final String loginLogoImagePath = messages.getMainMessage("loginWindow.logoImage", resolvedLocale);
    if (StringUtils.isBlank(loginLogoImagePath) || "loginWindow.logoImage".equals(loginLogoImagePath))
        return null;

    return new Image(null, new VersionedThemeResource(loginLogoImagePath));
}

From source file:com.logicbomb.newschool.MyAppWidgetSet.core.UserDetailsWidgetOld.java

public UserDetailsWidgetOld() {

    setSpacing(true);//from www.  j a va 2s. c  o m
    Panel iPanel = new Panel();
    iPanel.setWidth("50px");
    iPanel.setHeight("50px");
    iPanel.setStyleName("backColorWhite");
    addComponent(iPanel);
    String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath();

    // Image as a file resource
    FileResource resource = new FileResource(new File(basepath + "/VAADIN/themes/mytheme/img/loginPage.jpg"));

    // Show the image in the application
    Image image = new Image("", resource);
    image.setSizeFull();
    iPanel.setContent(image);

}

From source file:com.m4gik.views.component.LibraryScreen.java

/**
 * This method creates image for cover.//from   w  w w .j  av a 2 s.c o m
 * 
 * @param cover
 *            The external cover for current track.
 * @return The image with set resource.
 */
private Image createImageCover(ExternalResource cover) {
    Image image = new Image(null, cover);
    image.setHeight("120px");
    image.setWidth("120px");

    return image;
}

From source file:com.mcparland.john.ComponentCollection.java

License:Apache License

/**
 * @param size//www  . j a  va2s  .  co m
 * @param icon
 * @return
 */
private Image createImage(String size, String icon) {
    final Resource imageResource = new ThemeResource("../runo/icons/" + size + "/" + icon);
    final Image image = new Image(null, imageResource);
    return image;
}

From source file:com.mcparland.john.vaadin_mvn_arch.samples.Menu.java

License:Apache License

public Menu(Navigator navigator) {
    this.navigator = navigator;
    setPrimaryStyleName(ValoTheme.MENU_ROOT);
    menuPart = new CssLayout();
    menuPart.addStyleName(ValoTheme.MENU_PART);

    // header of the menu
    final HorizontalLayout top = new HorizontalLayout();
    top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    top.addStyleName(ValoTheme.MENU_TITLE);
    top.setSpacing(true);//from w  w  w  . j av  a  2 s . co m
    Label title = new Label("My CRUD");
    title.addStyleName(ValoTheme.LABEL_H3);
    title.setSizeUndefined();
    Image image = new Image(null, new ThemeResource("img/table-logo.png"));
    image.setStyleName("logo");
    top.addComponent(image);
    top.addComponent(title);
    menuPart.addComponent(top);

    // logout menu item
    MenuBar logoutMenu = new MenuBar();
    logoutMenu.addItem("Logout", FontAwesome.SIGN_OUT, new Command() {

        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void menuSelected(MenuItem selectedItem) {
            VaadinSession.getCurrent().getSession().invalidate();
            Page.getCurrent().reload();
        }
    });

    logoutMenu.addStyleName("user-menu");
    menuPart.addComponent(logoutMenu);

    // button for toggling the visibility of the menu when on a small screen
    final Button showMenu = new Button("Menu", new ClickListener() {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            if (menuPart.getStyleName().contains(VALO_MENU_VISIBLE)) {
                menuPart.removeStyleName(VALO_MENU_VISIBLE);
            } else {
                menuPart.addStyleName(VALO_MENU_VISIBLE);
            }
        }
    });
    showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY);
    showMenu.addStyleName(ValoTheme.BUTTON_SMALL);
    showMenu.addStyleName(VALO_MENU_TOGGLE);
    showMenu.setIcon(FontAwesome.NAVICON);
    menuPart.addComponent(showMenu);

    // container for the navigation buttons, which are added by addView()
    menuItemsLayout = new CssLayout();
    menuItemsLayout.setPrimaryStyleName(VALO_MENUITEMS);
    menuPart.addComponent(menuItemsLayout);

    addComponent(menuPart);
}

From source file:com.mycollab.community.shell.view.components.AboutWindow.java

License:Open Source License

public AboutWindow() {

    MHorizontalLayout content = new MHorizontalLayout().withMargin(true).withFullWidth();
    this.setContent(content);

    Image about = new Image("",
            new ExternalResource(StorageFactory.generateAssetRelativeLink(WebResourceIds._about)));
    MVerticalLayout rightPanel = new MVerticalLayout();
    ELabel versionLbl = ELabel.h2(String.format("MyCollab Community Edition %s", Version.getVersion()));
    Label javaNameLbl = new Label(String.format("%s, %s", System.getProperty("java.vm.name"),
            System.getProperty("java.runtime.version")));
    Label homeFolderLbl = new Label("Home folder: " + FileUtils.getHomeFolder().getAbsolutePath());
    WebBrowser browser = Page.getCurrent().getWebBrowser();
    Label osLbl = new Label(
            String.format("%s, %s", System.getProperty("os.name"), browser.getBrowserApplication()));
    osLbl.addStyleName(UIConstants.LABEL_WORD_WRAP);
    Div licenseDiv = new Div().appendChild(new Text("Powered by: "))
            .appendChild(new A("https://www.mycollab.com").appendText("MyCollab"))
            .appendChild(new Text(". Open source under GPL license"));
    Label licenseLbl = new Label(licenseDiv.write(), ContentMode.HTML);
    Label copyRightLbl = new Label(String.format("© %s - %s MyCollab Ltd. All rights reserved", "2011",
            new GregorianCalendar().get(Calendar.YEAR) + ""), ContentMode.HTML);
    rightPanel.with(versionLbl, javaNameLbl, osLbl, homeFolderLbl, licenseLbl, copyRightLbl)
            .withAlign(copyRightLbl, Alignment.BOTTOM_LEFT);
    content.with(about, rightPanel).expand(rightPanel);
}

From source file:com.mycollab.mobile.module.user.view.LoginViewImpl.java

License:Open Source License

private void initUI() {
    MVerticalLayout contentLayout = new MVerticalLayout().withStyleName("content-wrapper").withFullWidth();
    contentLayout.setDefaultComponentAlignment(Alignment.TOP_CENTER);

    Image mainLogo = new Image(null,
            AccountAssetsResolver.createLogoResource(MyCollabUI.getBillingAccount().getLogopath(), 150));
    contentLayout.addComponent(mainLogo);

    CssLayout welcomeTextWrapper = new CssLayout();
    ELabel welcomeText = new ELabel(
            LocalizationHelper.getMessage(MyCollabUI.getDefaultLocale(), ShellI18nEnum.BUTTON_LOG_IN))
                    .withStyleName("h1");
    welcomeTextWrapper.addComponent(welcomeText);
    contentLayout.addComponent(welcomeText);

    final EmailField emailField = new EmailField();
    new Dom(emailField).setAttribute("placeholder",
            LocalizationHelper.getMessage(MyCollabUI.getDefaultLocale(), GenericI18Enum.FORM_EMAIL));
    emailField.setWidth("100%");
    contentLayout.addComponent(emailField);

    final PasswordField pwdField = new PasswordField();
    pwdField.setWidth("100%");
    new Dom(pwdField).setAttribute("placeholder",
            LocalizationHelper.getMessage(MyCollabUI.getDefaultLocale(), ShellI18nEnum.FORM_PASSWORD));
    contentLayout.addComponent(pwdField);

    final CheckBox rememberPassword = new CheckBox(
            LocalizationHelper.getMessage(MyCollabUI.getDefaultLocale(), ShellI18nEnum.OPT_REMEMBER_PASSWORD),
            true);//from w w  w.  jav  a2 s  .  c o m
    rememberPassword.setWidth("100%");
    contentLayout.addComponent(rememberPassword);

    MButton signInBtn = new MButton(
            LocalizationHelper.getMessage(MyCollabUI.getDefaultLocale(), ShellI18nEnum.BUTTON_LOG_IN),
            clickEvent -> {
                try {
                    LoginViewImpl.this.fireEvent(new ViewEvent<>(LoginViewImpl.this, new UserEvent.PlainLogin(
                            emailField.getValue(), pwdField.getValue(), rememberPassword.getValue())));
                } catch (Exception e) {
                    throw new MyCollabException(e);
                }
            }).withStyleName(MobileUIConstants.BUTTON_ACTION);
    contentLayout.addComponent(signInBtn);

    this.addComponent(contentLayout);
}

From source file:com.mycollab.mobile.shell.view.MainView.java

License:Open Source License

public MainView() {
    super();//from  w w w  . j  a  va  2 s .c  om
    this.setSizeFull();

    MVerticalLayout contentLayout = new MVerticalLayout().withStyleName("content-wrapper").withFullWidth();
    contentLayout.setDefaultComponentAlignment(Alignment.TOP_CENTER);

    Image mainLogo = new Image(null, new ThemeResource("icons/logo_m.png"));
    contentLayout.addComponent(mainLogo);

    Label introText = new Label(
            "MyCollab helps you do all your office jobs on the computers, phones and tablets you use");
    introText.setStyleName("intro-text");
    contentLayout.addComponent(introText);

    CssLayout welcomeTextWrapper = new CssLayout();
    welcomeTextWrapper.setStyleName("welcometext-wrapper");
    welcomeTextWrapper.setWidth("100%");
    welcomeTextWrapper.setHeight("15px");
    contentLayout.addComponent(welcomeTextWrapper);

    Button crmButton = new Button(UserUIContext.getMessage(GenericI18Enum.MODULE_CRM),
            clickEvent -> EventBusFactory.getInstance().post(new ShellEvent.GotoCrmModule(this, null)));
    crmButton.addStyleName(MobileUIConstants.BUTTON_ACTION);
    crmButton.setWidth("100%");

    contentLayout.addComponent(crmButton);

    Button pmButton = new Button(UserUIContext.getMessage(GenericI18Enum.MODULE_PROJECT),
            clickEvent -> EventBusFactory.getInstance().post(new ShellEvent.GotoProjectModule(this, null)));
    pmButton.setWidth("100%");
    pmButton.addStyleName(MobileUIConstants.BUTTON_ACTION);
    contentLayout.addComponent(pmButton);

    this.addComponent(contentLayout);
}

From source file:com.mycollab.mobile.ui.MobileAttachmentUtils.java

License:Open Source License

public static Component renderAttachmentRow(final Content attachment) {
    String docName = attachment.getPath();
    int lastIndex = docName.lastIndexOf("/");
    MHorizontalLayout attachmentRow = new MHorizontalLayout().withSpacing(false).withFullWidth()
            .withStyleName("attachment-row");
    attachmentRow.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    CssLayout thumbnailWrap = new CssLayout();
    thumbnailWrap.setWidth("25px");
    thumbnailWrap.setStyleName("thumbnail-wrap");

    Component thumbnail;//  ww  w .  java 2 s .  c  o  m

    if (StringUtils.isNotBlank(attachment.getThumbnail())) {
        thumbnail = new Image(null, VaadinResourceFactory.getResource(attachment.getThumbnail()));
    } else {
        thumbnail = new ELabel(FileAssetsUtil.getFileIconResource(attachment.getName()).getHtml(),
                ContentMode.HTML);
    }
    thumbnail.setWidth("100%");
    thumbnailWrap.addComponent(thumbnail);
    attachmentRow.addComponent(thumbnailWrap);

    if (lastIndex != -1) {
        docName = docName.substring(lastIndex + 1, docName.length());
    }

    if (MimeTypesUtil.isImageType(docName)) {
        MButton b = new MButton(attachment.getTitle(), clickEvent -> {
            AttachmentPreviewView previewView = new AttachmentPreviewView(
                    VaadinResourceFactory.getResource(attachment.getPath()));
            EventBusFactory.getInstance().post(new ShellEvent.PushView(attachment, previewView));
        }).withStyleName(UIConstants.TEXT_ELLIPSIS);
        b.setWidth("100%");
        attachmentRow.with(b).expand(b);
    } else {
        Label l = new Label(attachment.getTitle());
        l.setWidth("100%");
        attachmentRow.addComponent(l);
        attachmentRow.setExpandRatio(l, 1.0f);
    }
    return attachmentRow;
}

From source file:com.mycollab.mobile.ui.MobileAttachmentUtils.java

License:Open Source License

public static Component renderAttachmentFieldRow(final Content attachment,
        Button.ClickListener additionalListener) {
    String docName = attachment.getPath();
    int lastIndex = docName.lastIndexOf("/");
    if (lastIndex != -1) {
        docName = docName.substring(lastIndex + 1, docName.length());
    }/* w  ww.  j  a v  a 2s .c  o  m*/

    final MHorizontalLayout attachmentLayout = new MHorizontalLayout().withStyleName("attachment-row")
            .withFullWidth();
    attachmentLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    CssLayout thumbnailWrap = new CssLayout();
    thumbnailWrap.setWidth("25px");
    thumbnailWrap.setStyleName("thumbnail-wrap");

    Component thumbnail;
    if (StringUtils.isNotBlank(attachment.getThumbnail())) {
        thumbnail = new Image(null, VaadinResourceFactory.getResource(attachment.getThumbnail()));
    } else {
        thumbnail = ELabel.fontIcon(FileAssetsUtil.getFileIconResource(attachment.getName()));
    }
    thumbnail.setWidth("100%");
    thumbnailWrap.addComponent(thumbnail);
    attachmentLayout.addComponent(thumbnailWrap);

    ELabel attachmentLink = new ELabel(docName).withStyleName(UIConstants.META_INFO, UIConstants.TEXT_ELLIPSIS);
    attachmentLayout.with(attachmentLink).expand(attachmentLink);

    MButton removeAttachment = new MButton("", clickEvent -> {
        ConfirmDialog.show(UI.getCurrent(), UserUIContext.getMessage(GenericI18Enum.CONFIRM_DELETE_ATTACHMENT),
                UserUIContext.getMessage(GenericI18Enum.BUTTON_YES),
                UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), dialog -> {
                    if (dialog.isConfirmed()) {
                        ResourceService attachmentService = AppContextUtil.getSpringBean(ResourceService.class);
                        attachmentService.removeResource(attachment.getPath(), UserUIContext.getUsername(),
                                true, MyCollabUI.getAccountId());
                        ((ComponentContainer) attachmentLayout.getParent()).removeComponent(attachmentLayout);
                    }
                });
    }).withIcon(FontAwesome.TRASH_O).withStyleName(MobileUIConstants.BUTTON_LINK);
    if (additionalListener != null) {
        removeAttachment.addClickListener(additionalListener);
    }
    removeAttachment.setHtmlContentAllowed(true);
    attachmentLayout.addComponent(removeAttachment);

    return attachmentLayout;
}