com.vaadin.ui.Image Java Examples

The following examples show how to use com.vaadin.ui.Image. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AdminUI.java    From sensorhub with Mozilla Public License 2.0 6 votes vote down vote up
protected Component buildHeader()
{
    HorizontalLayout header = new HorizontalLayout();
    header.setMargin(false);
    header.setHeight(100.0f, Unit.PIXELS);
    header.setWidth(100.0f, Unit.PERCENTAGE);
    Image img = new Image(null, LOGO_ICON);
    img.setHeight(90, Unit.PIXELS);
    img.setStyleName(STYLE_LOGO);
    header.addComponent(img);
    Label title = new Label("SensorHub");
    title.addStyleName(UIConstants.STYLE_H1);
    title.addStyleName(STYLE_LOGO);
    title.setWidth(null);
    header.addComponent(title);
    header.setExpandRatio(img, 0);
    header.setExpandRatio(title, 1);
    header.setComponentAlignment(img, Alignment.MIDDLE_LEFT);
    header.setComponentAlignment(title, Alignment.MIDDLE_RIGHT);
    return header;
}
 
Example #2
Source File: AboutWindow.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
public AboutWindow() {
    MHorizontalLayout content = new MHorizontalLayout().withMargin(true).withFullWidth();
    this.setContent(content);

    Image about = new Image("", new ExternalResource(StorageUtils.generateAssetRelativeLink(WebResourceIds._about)));

    MVerticalLayout rightPanel = new MVerticalLayout();
    ELabel versionLbl = ELabel.h2(String.format("MyCollab Community Edition %s", Version.getVersion())).withFullWidth();
    ELabel javaNameLbl = new ELabel(String.format("%s, %s", System.getProperty("java.vm.name"),
            System.getProperty("java.runtime.version"))).withFullWidth();
    Label homeFolderLbl = new Label("Home folder: " + AppContextUtil.getSpringBean(ServerConfiguration.class).getHomeDir().getAbsolutePath());
    WebBrowser browser = Page.getCurrent().getWebBrowser();
    ELabel osLbl = new ELabel(String.format("%s, %s", System.getProperty("os.name"), browser.getBrowserApplication())).withFullWidth();
    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"));
    ELabel licenseLbl = ELabel.html(licenseDiv.write()).withFullWidth();
    Label copyRightLbl = ELabel.html(String.format("© %s - %s MyCollab Ltd. All rights reserved", "2011",
            LocalDate.now().getYear() + "")).withFullWidth();
    rightPanel.with(versionLbl, javaNameLbl, osLbl, homeFolderLbl, licenseLbl, copyRightLbl).withAlign(copyRightLbl, Alignment.BOTTOM_LEFT);
    content.with(about, rightPanel).expand(rightPanel);
}
 
Example #3
Source File: AbstractMainView.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
private CustomLayout createTopMenu() {
    headerLayout = CustomLayoutExt.createLayout("topNavigation");
    headerLayout.setStyleName("topNavigation");
    headerLayout.setHeight("45px");
    headerLayout.setWidth("100%");

    Resource logoResource = AccountAssetsResolver.createLogoResource(AppUI.getBillingAccount().getLogopath(), 150);

    headerLayout.addComponent(new Image("", logoResource), "mainLogo");

    accountLayout = new MHorizontalLayout().withMargin(new MarginInfo(false, true, false, false)).withHeight("45px");
    accountLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    buildAccountMenuLayout();

    headerLayout.addComponent(accountLayout, "accountMenu");
    return headerLayout;
}
 
Example #4
Source File: AbstractView.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
 * Adds the logo to header.
 *
 * @param topHeader
 *            the top header
 */
private static void addLogoToHeader(final HorizontalLayout topHeader) {
	final ThemeResource ciaLogoResource = new ThemeResource("cia-logo.png");
	final Image ciaLogoImage = new Image(null,ciaLogoResource);
	topHeader.addComponent(ciaLogoImage);
	ciaLogoImage.setWidth("60px");
	ciaLogoImage.setHeight("60px");
	topHeader.setComponentAlignment(ciaLogoImage, Alignment.MIDDLE_LEFT);
	topHeader.setExpandRatio(ciaLogoImage, ContentRatio.SMALL);
}
 
Example #5
Source File: ProjectMembersWidget.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public Component generateRow(IBeanList<SimpleProjectMember> host, SimpleProjectMember member, int rowIndex) {
    MHorizontalLayout layout = new MHorizontalLayout().withFullWidth().withStyleName("list-row");
    Image userAvatar = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(member.getMemberAvatarId(), 48);
    userAvatar.addStyleName(WebThemes.CIRCLE_BOX);
    layout.addComponent(userAvatar);

    MVerticalLayout content = new MVerticalLayout().withMargin(false);
    content.addComponent(ELabel.html(buildAssigneeValue(member)).withStyleName(WebThemes.TEXT_ELLIPSIS));
    layout.with(content).expand(content);

    CssLayout footer = new CssLayout();

    String roleVal = member.getRoleName() + "&nbsp;&nbsp;";
    ELabel memberRole = ELabel.html(roleVal).withDescription(UserUIContext.getMessage(ProjectRoleI18nEnum.SINGLE))
            .withStyleName(WebThemes.META_INFO);
    footer.addComponent(memberRole);

    String memberWorksInfo = ProjectAssetsManager.getAsset(ProjectTypeConstants.TASK).getHtml() +
            new Span().appendText("" + member.getNumOpenTasks()).setTitle(UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_OPEN_TASKS)) +
            "&nbsp;&nbsp;" +
            ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG).getHtml() +
            new Span().appendText("" + member.getNumOpenBugs()).setTitle(UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_OPEN_BUGS)) + "&nbsp;&nbsp;"
            + VaadinIcons.MONEY.getHtml() + "&nbsp;" + new Span().appendText("" + NumberUtils.roundDouble(2,
            member.getTotalBillableLogTime())).setTitle(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_BILLABLE_HOURS)) + "&nbsp;&nbsp;" +
            VaadinIcons.GIFT.getHtml() + new Span().appendText("" + NumberUtils.roundDouble(2, member.getTotalNonBillableLogTime()))
            .setTitle(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_NON_BILLABLE_HOURS));

    ELabel memberWorkStatus = ELabel.html(memberWorksInfo).withStyleName(WebThemes.META_INFO);
    footer.addComponent(memberWorkStatus);

    content.addComponent(footer);
    return layout;
}
 
Example #6
Source File: ProjectMemberBlock.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
public ProjectMemberBlock(String username, String userAvatarId, String displayName) {
    withMargin(false).withWidth("80px");
    Image userAvatar = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(userAvatarId, 48, displayName);
    userAvatar.addStyleName(WebThemes.CIRCLE_BOX);
    A userLink = new A().setId("tag" + TooltipHelper.TOOLTIP_ID).
            setHref(ProjectLinkGenerator.generateProjectMemberLink(CurrentProjectVariables.getProjectId(),
                    username)).appendText(StringUtils.trim(displayName, 30, true)).setTitle(displayName);
    userLink.setAttribute("onmouseover", TooltipHelper.userHoverJsFunction(username));
    userLink.setAttribute("onmouseleave", TooltipHelper.itemMouseLeaveJsFunction());
    ELabel userLbl = ELabel.html(userLink.write()).withStyleName(ValoTheme.LABEL_SMALL).withFullWidth();
    with(userAvatar, userLbl).withAlign(userAvatar, Alignment.TOP_CENTER);
}
 
Example #7
Source File: UserBlock.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
public UserBlock(String username, String userAvatarId, String displayName) {
    withMargin(false).withWidth("80px");
    Image avatar = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(userAvatarId, 48);
    avatar.addStyleName(WebThemes.CIRCLE_BOX);

    A userLink = new A().setId("tag" + TooltipHelper.TOOLTIP_ID).setHref(AccountLinkGenerator.generateUserLink(username))
            .appendText(StringUtils.trim(displayName, 30, true));
    userLink.setAttribute("onmouseover", TooltipHelper.userHoverJsFunction(username));
    userLink.setAttribute("onmouseleave", TooltipHelper.itemMouseLeaveJsFunction());

    with(avatar, ELabel.html(userLink.write()));
}
 
Example #8
Source File: ForgotPasswordViewImpl.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
ForgotPwdForm() {
    CustomLayout customLayout = CustomLayoutExt.createLayout("forgotPassword");
    customLayout.setStyleName("forgotPwdForm");

    Resource logoResource = AccountAssetsResolver.createLogoResource(AppUI.getBillingAccount().getLogopath(), 150);
    customLayout.addComponent(new Image(null, logoResource), "logo-here");

    customLayout.addComponent(new ELabel(LocalizationHelper.getMessage(AppUI.getDefaultLocale(),
            ShellI18nEnum.BUTTON_FORGOT_PASSWORD)), "formHeader");
    customLayout.addComponent(ELabel.html(LocalizationHelper.getMessage(AppUI.getDefaultLocale(),
            ShellI18nEnum.OPT_FORGOT_PASSWORD_INTRO)), "intro-text");
    nameOrEmailField = new TextField(LocalizationHelper.getMessage(AppUI.getDefaultLocale(), GenericI18Enum.FORM_EMAIL));
    customLayout.addComponent(nameOrEmailField, "nameoremail");

    MButton sendEmail = new MButton(LocalizationHelper.getMessage(AppUI.getDefaultLocale(), ShellI18nEnum.BUTTON_RESET_PASSWORD), clickEvent -> {
        String username = nameOrEmailField.getValue();
        if (StringUtils.isValidEmail(username)) {
            UserService userService = AppContextUtil.getSpringBean(UserService.class);
            User user = userService.findUserByUserName(username);

            if (user == null) {
                NotificationUtil.showErrorNotification(LocalizationHelper.getMessage(AppUI.getDefaultLocale(), GenericI18Enum.ERROR_USER_IS_NOT_EXISTED, username));
            } else {
                userService.requestToResetPassword(user.getUsername());
                NotificationUtil.showNotification(LocalizationHelper.getMessage(AppUI.getDefaultLocale(), GenericI18Enum.OPT_SUCCESS),
                        LocalizationHelper.getMessage(AppUI.getDefaultLocale(), ShellI18nEnum.OPT_EMAIL_SENDER_NOTIFICATION));
                EventBusFactory.getInstance().post(new ShellEvent.LogOut(this, null));
            }
        } else {
            NotificationUtil.showErrorNotification(LocalizationHelper.getMessage(AppUI.getDefaultLocale(), ErrorI18nEnum.NOT_VALID_EMAIL, username));
        }
    }).withStyleName(WebThemes.BUTTON_ACTION).withClickShortcut(ShortcutAction.KeyCode.ENTER);
    customLayout.addComponent(sendEmail, "loginButton");

    MButton memoBackBtn = new MButton(LocalizationHelper.getMessage(AppUI.getDefaultLocale(), ShellI18nEnum.BUTTON_IGNORE_RESET_PASSWORD),
            clickEvent -> EventBusFactory.getInstance().post(new ShellEvent.LogOut(this, null)))
            .withStyleName(WebThemes.BUTTON_LINK);
    customLayout.addComponent(memoBackBtn, "forgotLink");

    this.setCompositionRoot(customLayout);
}
 
Example #9
Source File: PoliticianOverviewPageModContentFactoryImpl.java    From cia with Apache License 2.0 3 votes vote down vote up
/**
 * Creates the overview content.
 *
 * @param panelContent the panel content
 * @param personData the person data
 * @param viewRiksdagenPolitician the view riksdagen politician
 * @param pageId the page id
 */
private void createOverviewContent(final VerticalLayout panelContent, final PersonData personData,
		final ViewRiksdagenPolitician viewRiksdagenPolitician, final String pageId) {
	LabelFactory.createHeader2Label(panelContent, OVERVIEW);

	final Link createPoliticianPageLink = getPageLinkFactory().createPoliticianPageLink(personData);
	panelContent.addComponent(createPoliticianPageLink);

	final Image image = new Image("",
			new ExternalResource(personData.getImageUrl192().replace("http://", "https://")));

	final HorizontalLayout horizontalLayout = new HorizontalLayout();
	horizontalLayout.setSizeFull();

	panelContent.addComponent(horizontalLayout);

	horizontalLayout.addComponent(image);

	getFormFactory().addFormPanelTextFields(horizontalLayout, viewRiksdagenPolitician,
			ViewRiksdagenPolitician.class, AS_LIST);

	final VerticalLayout overviewLayout = new VerticalLayout();
	overviewLayout.setSizeFull();

	panelContent.addComponent(overviewLayout);
	panelContent.setExpandRatio(overviewLayout, ContentRatio.LARGE_FORM);

	getPoliticianMenuItemFactory().createOverviewPage(overviewLayout, pageId);

	panelContent.setExpandRatio(createPoliticianPageLink, ContentRatio.SMALL);
	panelContent.setExpandRatio(horizontalLayout, ContentRatio.GRID);

}