Java Code Examples for com.vaadin.shared.ui.ContentMode

The following examples show how to use com.vaadin.shared.ui.ContentMode. These examples are extracted from open source projects. 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 Project: cuba   Source File: OperationResultWindow.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void init(Map<String, Object> params) {
    super.init(params);

    if (exception != null) {
        Label<String> traceLabel = uiComponents.create(Label.NAME);
        traceLabel.setValue(getExceptionMessage(exception));

        traceLabel.withUnwrapped(com.vaadin.ui.Label.class, vLabel ->
                vLabel.setContentMode(ContentMode.PREFORMATTED));

        resultLabel.setValue(getMessage("operationResult.exception"));
        resultContainer.add(traceLabel);
    } else if (result != null) {
        Label<String> valueHolder = uiComponents.create(Label.NAME);
        valueHolder.setValue(AttributeHelper.convertToString(result));

        valueHolder.withUnwrapped(com.vaadin.ui.Label.class, vLabel ->
                vLabel.setContentMode(ContentMode.PREFORMATTED));

        resultLabel.setValue(getMessage("operationResult.result"));
        resultContainer.add(valueHolder);
    } else {
        resultLabel.setValue(getMessage("operationResult.void"));
    }
}
 
Example 2
Source Project: vaadin-sliderpanel   Source File: DemoUI.java    License: MIT License 6 votes vote down vote up
private Component genInfo() {
    VerticalLayout info = new VerticalLayout();
    info.setMargin(true);
    info.setWidth("320px");
    info.setHeight("100%");
    info.addStyleName("black-bg");

    Label details = new Label("<h3>Vaadin SliderPanel</h3>"
            + "<p>Developed by Marten Prieß<br/>"
            + "<a href=\"http://www.rocketbase.io\">www.rocketbase.io</a><p>"
            + "<p>Sample & Sourcecode:<br/><a href=\"https://github.com/melistik/vaadin-sliderpanel/\">github.com</a><br/>"
            + "Vaadin Addon-Site:<br/><a href=\"https://vaadin.com/directory#!addon/sliderpanel\">vaadin.com</a></p>", ContentMode.HTML);
    details.setSizeFull();
    info.addComponentsAndExpand(details);
    info.addComponent(new Label("<p class=\"version\">Version: " + buildVersion + "</p>", ContentMode.HTML));

    return info;
}
 
Example 3
Source Project: vaadin-sliderpanel   Source File: DemoUI.java    License: MIT License 6 votes vote down vote up
private VerticalLayout dummyContent(final String title, final int length) {
    String text = "";
    for (int x = 0; x <= length; x++) {
        text += LOREM_IPSUM + " ";
    }
    Label htmlDummy = new Label(String.format("<h3>%s</h3>%s", title, text.trim()), ContentMode.HTML);
    VerticalLayout component = new VerticalLayout(htmlDummy);
    component.setExpandRatio(htmlDummy, 1);
    component.addComponent(new Button(title, new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            Notification.show("clicked: " + title, Type.HUMANIZED_MESSAGE);
        }
    }));
    component.setMargin(true);
    component.setSpacing(true);
    return component;
}
 
Example 4
TicketAssigneeLink(final String assignee, String assigneeAvatarId, final String assigneeFullName) {
    super(StringUtils.trim(assigneeFullName, 25, true));

    this.withListener(clickEvent -> {
        ProjectTicketSearchCriteria criteria = BeanUtility.deepClone(searchCriteria);
        criteria.setAssignUser(StringSearchField.and(assignee));
        criteria.setTypes(CurrentProjectVariables.getRestrictedTicketTypes());
        EventBusFactory.getInstance().post(new TicketEvent.SearchRequest(UnresolvedTicketsByAssigneeWidget.this,
                criteria));
    }).withWidth("100%").withIcon(UserAvatarControlFactory.createAvatarResource(assigneeAvatarId, 16))
            .withStyleName(WebThemes.BUTTON_LINK, WebThemes.TEXT_ELLIPSIS);
    UserService service = AppContextUtil.getSpringBean(UserService.class);
    SimpleUser user = service.findUserByUserNameInAccount(assignee, AppUI.getAccountId());
    this.setDescription(CommonTooltipGenerator.generateTooltipUser(UserUIContext.getUserLocale(), user,
            AppUI.getSiteUrl(), UserUIContext.getUserTimeZone()), ContentMode.HTML);
}
 
Example 5
public ProjectMemberLink(Integer projectId, String username, String userAvatarId, String displayName) {
    if (StringUtils.isBlank(username)) {
        return;
    }
    this.setContentMode(ContentMode.HTML);

    DivLessFormatter div = new DivLessFormatter();
    Img userAvatar = new Img("", StorageUtils.getAvatarPath(userAvatarId, 16)).setCSSClass(WebThemes.CIRCLE_BOX);
    A userLink = new A().setId("tag" + TooltipHelper.TOOLTIP_ID).
            setHref(ProjectLinkGenerator.generateProjectMemberLink(projectId, username))
            .appendText(StringUtils.trim(displayName, 30, true));
    userLink.setAttribute("onmouseover", TooltipHelper.userHoverJsFunction(username));
    userLink.setAttribute("onmouseleave", TooltipHelper.itemMouseLeaveJsFunction());
    div.appendChild(userAvatar, DivLessFormatter.EMPTY_SPACE, userLink);
    this.setValue(div.write());
}
 
Example 6
private void displayInfo(SimpleUser user) {
    Div infoDiv = new Div().appendText("You have not setup SMTP account properly. So we can not send the invitation by email automatically. Please copy/paste below paragraph and inform to the user by yourself").setStyle("font-weight:bold;color:red");
    Label infoLbl = new Label(infoDiv.write(), ContentMode.HTML);

    Div userInfoDiv = new Div().appendText("Your username is ").appendChild(new B().appendText(user.getEmail()));
    Label userInfoLbl = ELabel.html(userInfoDiv.write());

    if (Boolean.TRUE.equals(user.isAccountOwner())) {
        user.setRoleName(UserUIContext.getMessage(RoleI18nEnum.OPT_ACCOUNT_OWNER));
    }
    Div roleInfoDiv = new Div().appendText("Your role is ").appendChild(new B().appendText(user.getRoleName()));
    Label roleInfoLbl = new Label(roleInfoDiv.write(), ContentMode.HTML);
    contentLayout.with(infoLbl, userInfoLbl, roleInfoLbl);

    final Button addNewBtn = new Button("Create another user", clickEvent -> {
        EventBusFactory.getInstance().post(new UserEvent.GotoAdd(GetStartedInstructionWindow.this, null));
        close();
    });
    addNewBtn.setStyleName(WebThemes.BUTTON_ACTION);

    Button doneBtn = new Button(UserUIContext.getMessage(GenericI18Enum.ACTION_DONE), clickEvent -> close());
    doneBtn.setStyleName(WebThemes.BUTTON_ACTION);

    final MHorizontalLayout controlsBtn = new MHorizontalLayout(addNewBtn, doneBtn).withMargin(true);
    contentLayout.with(controlsBtn).withAlign(controlsBtn, Alignment.MIDDLE_RIGHT);
}
 
Example 7
ProgressIndicator() {
    this.withDraggable(false).withClosable(false).withModal(true).withCenter().withStyleName("lazyload-progress");

    Div div = new Div().appendChild(new Div().setCSSClass("sk-cube sk-cube1"))
            .appendChild(new Div().setCSSClass("sk-cube sk-cube2"))
            .appendChild(new Div().setCSSClass("sk-cube sk-cube3"))
            .appendChild(new Div().setCSSClass("sk-cube sk-cube4"))
            .appendChild(new Div().setCSSClass("sk-cube sk-cube5"))
            .appendChild(new Div().setCSSClass("sk-cube sk-cube6"))
            .appendChild(new Div().setCSSClass("sk-cube sk-cube7"))
            .appendChild(new Div().setCSSClass("sk-cube sk-cube8"))
            .appendChild(new Div().setCSSClass("sk-cube sk-cube9"));
    Label loadingIcon = new Label(div.write(), ContentMode.HTML);
    loadingIcon.addStyleName("sk-cube-grid");
    this.setContent(loadingIcon);
}
 
Example 8
Source Project: cuba   Source File: WindowBreadCrumbs.java    License: Apache License 2.0 5 votes vote down vote up
public void update() {
    boolean isTestMode = ui.isTestMode();

    linksLayout.removeAllComponents();
    for (Iterator<Window> it = windows.iterator(); it.hasNext();) {
        Window window = it.next();

        Button button = new NavigationButton(window);
        button.setCaption(StringUtils.trimToEmpty(window.getCaption()));
        button.addClickListener(this::navigationButtonClicked);
        button.setSizeUndefined();
        button.setStyleName(ValoTheme.BUTTON_LINK);
        button.setTabIndex(-1);

        if (isTestMode) {
            button.setCubaId("breadCrubms_Button_" + window.getId());
        }

        if (ui.isPerformanceTestMode()) {
            button.setId(ui.getTestIdManager().getTestId("breadCrubms_Button_" + window.getId()));
        }

        if (it.hasNext()) {
            linksLayout.addComponent(button);

            Label separatorLab = new Label("&nbsp;&gt;&nbsp;");
            separatorLab.setStyleName("c-breadcrumbs-separator");
            separatorLab.setSizeUndefined();
            separatorLab.setContentMode(ContentMode.HTML);
            linksLayout.addComponent(separatorLab);
        } else {
            Label captionLabel = new Label(window.getCaption());
            captionLabel.setStyleName("c-breadcrumbs-win-caption");
            captionLabel.setSizeUndefined();
            linksLayout.addComponent(captionLabel);
        }
    }
}
 
Example 9
Source Project: cuba   Source File: VDragCaptionProvider.java    License: Apache License 2.0 5 votes vote down vote up
public Element getDragCaptionElement(Widget w) {
    ComponentConnector component = Util.findConnectorFor(w);
    DDLayoutState state = ((DragAndDropAwareState) root.getState()).getDragAndDropState();
    DragCaptionInfo dci = state.dragCaptions.get(component);

    Document document = Document.get();

    Element dragCaptionImage = document.createDivElement();
    Element dragCaption = document.createSpanElement();

    String dragCaptionText = dci.caption;
    if (dragCaptionText != null) {
        if (dci.contentMode == ContentMode.TEXT) {
            dragCaption.setInnerText(dragCaptionText);
        } else if (dci.contentMode == ContentMode.HTML) {
            dragCaption.setInnerHTML(dragCaptionText);
        } else if (dci.contentMode == ContentMode.PREFORMATTED) {
            PreElement preElement = document.createPreElement();
            preElement.setInnerText(dragCaptionText);
            dragCaption.appendChild(preElement);
        }
    }

    String dragIconKey = state.dragCaptions.get(component).iconKey;
    if (dragIconKey != null) {
        String resourceUrl = root.getResourceUrl(dragIconKey);
        Icon icon = component.getConnection().getIcon(resourceUrl);
        dragCaptionImage.appendChild(icon.getElement());
    }

    dragCaptionImage.appendChild(dragCaption);

    return dragCaptionImage;
}
 
Example 10
Source Project: viritin   Source File: Header.java    License: Apache License 2.0 5 votes vote down vote up
private void render() {
    if (text != null) {
        setContentMode(ContentMode.HTML);
        StringBuilder sb = new StringBuilder("<h");
        sb.append(headerLevel);
        sb.append(">");
        sb.append(Jsoup.clean(text, getWhitelist()));
        sb.append("</h");
        sb.append(headerLevel);
        sb.append(">");
        super.setValue(sb.toString());
        text = null;
    }
}
 
Example 11
/**
 * Sets up DragAndDropWrapper to accept multi file drops.
 */
protected void prepareDropZone() {
    if (dropZone == null) {
        Component label = new Label(getAreaText(), ContentMode.HTML);
        label.setSizeUndefined();
        dropZone = new DragAndDropWrapper(label);
        dropZone.setStyleName("v-multifileupload-dropzone");
        dropZone.setSizeUndefined();
        addComponent(dropZone, 1);
        dropZone.setDropHandler(this);
        addStyleName("no-horizontal-drag-hints");
        addStyleName("no-vertical-drag-hints");
    }
}
 
Example 12
Source Project: mycollab   Source File: UserLink.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
public UserLink(String username, String userAvatarId, String displayName) {
    if (StringUtils.isBlank(username)) {
        return;
    }
    this.setContentMode(ContentMode.HTML);

    DivLessFormatter div = new DivLessFormatter();
    Img userAvatar = new Img("", StorageUtils.getAvatarPath(userAvatarId, 16)).setCSSClass(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());
    div.appendChild(userAvatar, DivLessFormatter.EMPTY_SPACE, userLink);
    this.setValue(div.write());
}
 
Example 13
Source Project: calendar-component   Source File: Calendar.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * @return The content mode
 */
public ContentMode getContentMode() {
    return getState(false).descriptionContentMode;
}
 
Example 14
Source Project: sample-timesheets   Source File: CalendarScreen.java    License: Apache License 2.0 4 votes vote down vote up
protected void updateSummaryColumn() {
    summaryBox.removeAll();
    CubaVerticalActionsLayout summaryLayout = (CubaVerticalActionsLayout) WebComponentsHelper.unwrap(summaryBox);
    CubaVerticalActionsLayout summaryCaptionVbox = new CubaVerticalActionsLayout();
    summaryCaptionVbox.setHeight("30px");
    summaryCaptionVbox.setWidth("100%");
    com.vaadin.ui.Label summaryCaption = new com.vaadin.ui.Label();
    summaryCaption.setContentMode(ContentMode.HTML);
    summaryCaption.setValue(messageBundle.getMessage("label.summaryCaption"));
    summaryCaption.setWidthUndefined();
    summaryCaptionVbox.addComponent(summaryCaption);
    summaryCaptionVbox.setComponentAlignment(summaryCaption, Alignment.MIDDLE_CENTER);
    summaryLayout.addComponent(summaryCaptionVbox);

    FactAndPlan[] summariesByWeeks = calculateSummariesByWeeks();
    FactAndPlan summaryForMonth = new FactAndPlan();
    for (int i = 1; i < summariesByWeeks.length; i++) {
        com.vaadin.ui.Label hourLabel = new com.vaadin.ui.Label();
        hourLabel.setContentMode(ContentMode.HTML);
        FactAndPlan summaryForTheWeek = summariesByWeeks[i];
        if (summaryForTheWeek == null) {
            summaryForTheWeek = new FactAndPlan();
        }
        if (summaryForTheWeek.isMatch()) {
            hourLabel.setValue(messages.formatMessage(CalendarScreen.class, "label.hoursSummary",
                    summaryForTheWeek.fact.getHours(), summaryForTheWeek.fact.getMinutes()));
        } else {
            hourLabel.setValue(messages.formatMessage(CalendarScreen.class, "label.hoursSummaryNotMatch",
                    summaryForTheWeek.fact.getHours(), summaryForTheWeek.fact.getMinutes(),
                    summaryForTheWeek.plan.getHours(), summaryForTheWeek.plan.getMinutes()));
            hourLabel.addStyleName("overtime");
        }
        hourLabel.setWidthUndefined();
        summaryLayout.addComponent(hourLabel);
        summaryLayout.setExpandRatio(hourLabel, 1);
        summaryLayout.setComponentAlignment(hourLabel, Alignment.MIDDLE_CENTER);

        summaryForMonth.fact.add(summaryForTheWeek.fact);
        summaryForMonth.plan.add(summaryForTheWeek.plan);
    }

    if (summaryForMonth.isMatch()) {
        monthSummary.setValue(messages.formatMessage(CalendarScreen.class, "label.monthSummaryFormat",
                summaryForMonth.fact.getHours(), summaryForMonth.fact.getMinutes()));
        monthSummary.setStyleName("month-summary");
    } else {
        monthSummary.setValue(messages.formatMessage(CalendarScreen.class, "label.monthSummaryFormatNotMatch",
                summaryForMonth.fact.getHours(), summaryForMonth.fact.getMinutes(),
                summaryForMonth.plan.getHours(), summaryForMonth.plan.getMinutes()));
        monthSummary.setStyleName("month-summary-overtime");
    }
}
 
Example 15
Source Project: cuba   Source File: WebLabel.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public boolean isHtmlEnabled() {
    return component.getContentMode() == ContentMode.HTML;
}
 
Example 16
Source Project: cuba   Source File: WebLabel.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void setHtmlEnabled(boolean htmlEnabled) {
    component.setContentMode(htmlEnabled ? ContentMode.HTML : ContentMode.TEXT);
}
 
Example 17
Source Project: cuba   Source File: CubaTreeGrid.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ContentMode getRowDescriptionContentMode() {
    return getState(false).rowDescriptionContentMode;
}
 
Example 18
Source Project: cuba   Source File: CubaGrid.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ContentMode getRowDescriptionContentMode() {
    return getState(false).rowDescriptionContentMode;
}
 
Example 19
Source Project: cuba   Source File: CubaCapsLockIndicator.java    License: Apache License 2.0 4 votes vote down vote up
protected void initCapsLockIndicatorContent() {
    getState().contentMode = ContentMode.HTML;
    getState().text = "<span></span>";
}
 
Example 20
Source Project: cuba   Source File: DragCaption.java    License: Apache License 2.0 4 votes vote down vote up
public DragCaption(String caption, Resource icon, ContentMode contentMode) {
    this.caption = caption;
    this.icon = icon;
    this.contentMode = contentMode;
}
 
Example 21
Source Project: cuba   Source File: DragCaption.java    License: Apache License 2.0 4 votes vote down vote up
public ContentMode getContentMode() {
    return contentMode;
}
 
Example 22
Source Project: viritin   Source File: RichText.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void beforeClientResponse(boolean initial) {
    setContentMode(ContentMode.HTML);
    super.setValue(Jsoup.clean(richText, getWhitelist()));
    super.beforeClientResponse(initial);
}
 
Example 23
Source Project: viritin   Source File: RichText.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public RichText withContentMode(ContentMode mode) {
    setContentMode(mode);
    return this;
}
 
Example 24
Source Project: viritin   Source File: MLabel.java    License: Apache License 2.0 4 votes vote down vote up
public MLabel withContentMode(ContentMode mode) {
    setContentMode(mode);
    return this;
}
 
Example 25
@Override
public Component generateRow(IBeanList<SimpleProject> host, SimpleProject project, int rowIndex) {
    MHorizontalLayout layout = new MHorizontalLayout().withMargin(false).withFullWidth().withStyleName(WebThemes.BORDER_LIST_ROW);
    layout.addComponent(ProjectAssetsUtil.projectLogoComp(project.getShortname(), project.getId(), project.getAvatarid(), 64));
    if (project.isArchived()) {
        layout.addStyleName("project-archived");
    }
    MVerticalLayout mainLayout = new MVerticalLayout().withMargin(false);

    A projectDiv = new A(ProjectLinkGenerator.generateProjectLink(project.getId())).appendText(project.getName());
    ELabel projectLbl = ELabel.h3(projectDiv.write()).withStyleName(WebThemes.TEXT_ELLIPSIS).withFullWidth();
    projectLbl.setDescription(ProjectTooltipGenerator.generateToolTipProject(UserUIContext.getUserLocale(),
            AppUI.getDateFormat(), project, AppUI.getSiteUrl(), UserUIContext.getUserTimeZone()), ContentMode.HTML);

    mainLayout.addComponent(projectLbl);

    MHorizontalLayout metaInfo = new MHorizontalLayout().withFullWidth();
    metaInfo.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    Div activeMembersDiv = new Div().appendText(VaadinIcons.USERS.getHtml() + " " + project.getNumActiveMembers())
            .setTitle(UserUIContext.getMessage(ProjectMemberI18nEnum.OPT_ACTIVE_MEMBERS));
    Div createdTimeDiv = new Div().appendText(VaadinIcons.CLOCK.getHtml() + " " + UserUIContext
            .formatPrettyTime(project.getCreatedtime())).setTitle(UserUIContext.getMessage(GenericI18Enum.FORM_CREATED_TIME));
    Div billableHoursDiv = new Div().appendText(VaadinIcons.MONEY.getHtml() + " " + NumberUtils.roundDouble(2, project.getTotalBillableHours())).
            setTitle(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_BILLABLE_HOURS));
    Div nonBillableHoursDiv = new Div().appendText(VaadinIcons.GIFT.getHtml() + " " + NumberUtils.roundDouble(2,
            project.getTotalNonBillableHours())).setTitle(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_NON_BILLABLE_HOURS));
    Div metaDiv = new Div().appendChild(activeMembersDiv, DivLessFormatter.EMPTY_SPACE, createdTimeDiv,
            DivLessFormatter.EMPTY_SPACE, billableHoursDiv, DivLessFormatter.EMPTY_SPACE,
            nonBillableHoursDiv, DivLessFormatter.EMPTY_SPACE);
    if (project.getMemlead() != null) {
        Div leadDiv = new Div().appendChild(new Img("", StorageUtils.getAvatarPath(project
                        .getLeadAvatarId(), 16)).setCSSClass(WebThemes.CIRCLE_BOX), DivLessFormatter.EMPTY_SPACE,
                new A(ProjectLinkGenerator.generateProjectMemberLink(project.getId(), project.getMemlead()))
                        .appendText(StringUtils.trim(project.getLeadFullName(), 30, true))).setTitle
                (UserUIContext.getMessage(ProjectI18nEnum.FORM_LEADER));
        metaDiv.appendChild(0, leadDiv);
        metaDiv.appendChild(1, DivLessFormatter.EMPTY_SPACE);
    }

    if (project.getClientid() != null) {
        Div accountDiv = new Div();
        if (project.getClientAvatarId() == null) {
            accountDiv.appendText(VaadinIcons.INSTITUTION.getHtml() + " ");
        } else {
            Img clientImg = new Img("", StorageUtils.getEntityLogoPath(AppUI.getAccountId(),
                    project.getClientAvatarId(), 16)).setCSSClass(WebThemes.CIRCLE_BOX);
            accountDiv.appendChild(clientImg).appendChild(DivLessFormatter.EMPTY_SPACE);
        }

        accountDiv.appendChild(new A(ProjectLinkGenerator.generateClientPreviewLink(project.getClientid()))
                .appendText(StringUtils.trim(project.getClientName(), 30, true))).setCSSClass(WebThemes.BLOCK)
                .setTitle(project.getClientName());
        metaDiv.appendChild(0, accountDiv);
        metaDiv.appendChild(1, DivLessFormatter.EMPTY_SPACE);
    }
    metaDiv.setCSSClass(WebThemes.FLEX_DISPLAY);
    metaInfo.addComponent(ELabel.html(metaDiv.write()).withStyleName(WebThemes.META_INFO).withUndefinedWidth());

    mainLayout.addComponent(metaInfo);

    int openAssignments = project.getNumOpenBugs() + project.getNumOpenTasks() + project.getNumOpenRisks();
    int totalAssignments = project.getNumBugs() + project.getNumTasks() + project.getNumRisks();
    ELabel progressInfoLbl;
    if (totalAssignments > 0) {
        progressInfoLbl = new ELabel(UserUIContext.getMessage(ProjectI18nEnum.OPT_PROJECT_TICKET,
                (totalAssignments - openAssignments), totalAssignments, (totalAssignments - openAssignments)
                        * 100 / totalAssignments)).withStyleName(WebThemes.META_INFO);
    } else {
        progressInfoLbl = new ELabel(UserUIContext.getMessage(ProjectI18nEnum.OPT_NO_TICKET))
                .withStyleName(WebThemes.META_INFO);
    }
    mainLayout.addComponent(progressInfoLbl);
    layout.with(mainLayout).expand(mainLayout);
    return layout;
}
 
Example 26
void displayEntryPeople(ValuedBean bean) {
    this.removeAllComponents();
    this.withMargin(false);

    Label peopleInfoHeader = new Label(VaadinIcons.USER.getHtml() + " " +
            UserUIContext.getMessage(ProjectCommonI18nEnum.SUB_INFO_PEOPLE), ContentMode.HTML);
    peopleInfoHeader.setStyleName("info-hdr");
    this.addComponent(peopleInfoHeader);

    GridLayout layout = new GridLayout(2, 2);
    layout.setSpacing(true);
    layout.setWidth("100%");
    layout.setMargin(new MarginInfo(false, false, false, true));
    try {
        Label createdLbl = new Label(UserUIContext.getMessage(ProjectCommonI18nEnum.ITEM_CREATED_PEOPLE));
        createdLbl.setSizeUndefined();
        layout.addComponent(createdLbl, 0, 0);

        String createdUserName = (String) PropertyUtils.getProperty(bean, "createduser");
        String createdUserAvatarId = (String) PropertyUtils.getProperty(bean, "createdUserAvatarId");
        String createdUserDisplayName = (String) PropertyUtils.getProperty(bean, "createdUserFullName");

        ProjectMemberLink createdUserLink = new ProjectMemberLink(createdUserName,
                createdUserAvatarId, createdUserDisplayName);
        layout.addComponent(createdUserLink, 1, 0);
        layout.setColumnExpandRatio(1, 1.0f);

        Label assigneeLbl = new Label(UserUIContext.getMessage(ProjectCommonI18nEnum.ITEM_ASSIGN_PEOPLE));
        assigneeLbl.setSizeUndefined();
        layout.addComponent(assigneeLbl, 0, 1);
        String assignUserName = (String) PropertyUtils.getProperty(bean, "userlead");
        String assignUserAvatarId = (String) PropertyUtils.getProperty(bean, "userLeadAvatarId");
        String assignUserDisplayName = (String) PropertyUtils.getProperty(bean, "userLeadFullName");

        ProjectMemberLink assignUserLink = new ProjectMemberLink(assignUserName,
                assignUserAvatarId, assignUserDisplayName);
        layout.addComponent(assignUserLink, 1, 1);
    } catch (Exception e) {
        LOG.error("Can not build user link {} ", BeanUtility.printBeanObj(bean));
    }

    this.addComponent(layout);
}
 
Example 27
private void constructBody() {
    final MVerticalLayout layout = new MVerticalLayout().withFullWidth();
    CssLayout iconWrapper = new CssLayout();
    final ELabel iconEmbed = ELabel.fontIcon(FileAssetsUtil.getFileIconResource(content.getName()));
    iconEmbed.addStyleName("icon-48px");
    iconWrapper.addComponent(iconEmbed);
    layout.with(iconWrapper).withAlign(iconWrapper, Alignment.MIDDLE_CENTER);

    final GridFormLayoutHelper infoLayout = GridFormLayoutHelper.defaultFormLayoutHelper(LayoutType.ONE_COLUMN);

    if (content.getDescription() != null) {
        final Label descLbl = new Label();
        if (!content.getDescription().equals("")) {
            descLbl.setData(content.getDescription());
        } else {
            descLbl.setValue("&nbsp;");
            descLbl.setContentMode(ContentMode.HTML);
        }
        infoLayout.addComponent(descLbl, UserUIContext.getMessage(GenericI18Enum.FORM_DESCRIPTION), 0, 0);
    }

    UserService userService = AppContextUtil.getSpringBean(UserService.class);
    SimpleUser user = userService.findUserByUserNameInAccount(content.getCreatedUser(), AppUI.getAccountId());
    if (user == null) {
        infoLayout.addComponent(new UserLink(UserUIContext.getUsername(), UserUIContext.getUserAvatarId(),
                UserUIContext.getUserDisplayName()), UserUIContext.getMessage(GenericI18Enum.OPT_CREATED_BY), 0, 1);
    } else {
        infoLayout.addComponent(new UserLink(user.getUsername(), user.getAvatarid(), user.getDisplayName()),
                UserUIContext.getMessage(GenericI18Enum.OPT_CREATED_BY), 0, 1);
    }

    final Label size = new Label(FileUtils.getVolumeDisplay(content.getSize()));
    infoLayout.addComponent(size, UserUIContext.getMessage(FileI18nEnum.OPT_SIZE), 0, 2);

    ELabel dateCreate = new ELabel().prettyDateTime(DateTimeUtils.toLocalDateTime(content.getCreated()));
    infoLayout.addComponent(dateCreate, UserUIContext.getMessage(GenericI18Enum.FORM_CREATED_TIME), 0, 3);

    layout.addComponent(infoLayout.getLayout());

    MButton downloadBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_DOWNLOAD))
            .withIcon(VaadinIcons.DOWNLOAD).withStyleName(WebThemes.BUTTON_ACTION);
    List<Resource> resources = new ArrayList<>();
    resources.add(content);

    StreamResource downloadResource = StreamDownloadResourceUtil.getStreamResourceSupportExtDrive(resources);

    FileDownloader fileDownloader = new FileDownloader(downloadResource);
    fileDownloader.extend(downloadBtn);

    MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL), clickEvent -> close())
            .withStyleName(WebThemes.BUTTON_OPTION);
    MHorizontalLayout buttonControls = new MHorizontalLayout(cancelBtn, downloadBtn);
    layout.with(buttonControls).withAlign(buttonControls, Alignment.MIDDLE_RIGHT);
    this.setContent(layout);
}
 
Example 28
private void addAttachmentRow(Content attachment) {
    String docName = attachment.getPath();
    int lastIndex = docName.lastIndexOf("/");
    if (lastIndex != -1) {
        docName = docName.substring(lastIndex + 1);
    }

    final AbsoluteLayout attachmentLayout = new AbsoluteLayout();
    attachmentLayout.setWidth(WebUIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH);
    attachmentLayout.setHeight(WebUIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_HEIGHT);
    attachmentLayout.setStyleName("attachment-block");

    MCssLayout thumbnailWrap = new MCssLayout().withFullSize().withStyleName("thumbnail-wrap");

    Link thumbnail = new Link();
    thumbnail.setTargetName("_blank");
    if (StringUtils.isBlank(attachment.getThumbnail())) {
        thumbnail.setIcon(FileAssetsUtil.getFileIconResource(attachment.getName()));
    } else {
        thumbnail.setIcon(VaadinResourceFactory.getResource(attachment.getThumbnail()));
    }

    if (MimeTypesUtil.isImageType(docName)) {
        thumbnail.setResource(VaadinResourceFactory.getResource(attachment.getPath()));
    }

    Div contentTooltip = new Div().appendChild(new Span().appendText(docName).setStyle("font-weight:bold"));
    Ul ul = new Ul().appendChild(new Li().appendText(UserUIContext.getMessage(FileI18nEnum.OPT_SIZE_VALUE,
            FileUtils.getVolumeDisplay(attachment.getSize())))).setStyle("line-height:1.5em");
    ul.appendChild(new Li().appendText(UserUIContext.getMessage(GenericI18Enum.OPT_LAST_MODIFIED,
            UserUIContext.formatPrettyTime(DateTimeUtils.toLocalDateTime(attachment.getLastModified())))));
    contentTooltip.appendChild(ul);
    thumbnail.setDescription(contentTooltip.write(), ContentMode.HTML);
    thumbnail.setWidth(WebUIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH);
    thumbnailWrap.addComponent(thumbnail);

    attachmentLayout.addComponent(thumbnailWrap, "top: 0px; left: 0px; bottom: 0px; right: 0px; z-index: 0;");

    MCssLayout attachmentNameWrap = new MCssLayout().withWidth(WebUIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH)
            .withStyleName("attachment-name-wrap");

    Label attachmentName = new ELabel(docName).withStyleName(WebThemes.TEXT_ELLIPSIS);
    attachmentNameWrap.addComponent(attachmentName);
    attachmentLayout.addComponent(attachmentNameWrap, "bottom: 0px; left: 0px; right: 0px; z-index: 1;");

    MButton trashBtn = new MButton("", clickEvent -> {
        ConfirmDialogExt.show(UI.getCurrent(), UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE,
                AppUI.getSiteName()), UserUIContext.getMessage(GenericI18Enum.CONFIRM_DELETE_ATTACHMENT),
                UserUIContext.getMessage(GenericI18Enum.ACTION_YES),
                UserUIContext.getMessage(GenericI18Enum.ACTION_NO),
                confirmDialog -> {
                    if (confirmDialog.isConfirmed()) {
                        resourceService.removeResource(attachment.getPath(), UserUIContext.getUsername(), true, AppUI.getAccountId());
                        ((ComponentContainer) attachmentLayout.getParent()).removeComponent(attachmentLayout);
                    }
                });
    }).withIcon(VaadinIcons.TRASH).withStyleName("attachment-control");
    attachmentLayout.addComponent(trashBtn, "top: 9px; left: 9px; z-index: 1;");

    MButton downloadBtn = new MButton().withIcon(VaadinIcons.DOWNLOAD).withStyleName("attachment-control");
    FileDownloader fileDownloader = new FileDownloader(VaadinResourceFactory.getInstance().getStreamResource(attachment.getPath()));
    fileDownloader.extend(downloadBtn);
    attachmentLayout.addComponent(downloadBtn, "right: 9px; top: 9px; z-index: 1;");
    this.addComponent(attachmentLayout);
}
 
Example 29
Source Project: mycollab   Source File: UploadField.java    License: GNU Affero General Public License v3.0 4 votes vote down vote up
protected Component createDisplayComponent() {
    defaultDisplay = new Label("", ContentMode.HTML);
    return defaultDisplay;
}
 
Example 30
void hideCaption() {
    this.setCaption("");
    this.setDescription(String.format("<div class=\"v-label-h3 no-margin\">%s</div>", caption), ContentMode.HTML);
}