com.vaadin.shared.ui.ContentMode Java Examples

The following examples show how to use com.vaadin.shared.ui.ContentMode. 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: GetStartedInstructionWindow.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
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 #2
Source File: DemoUI.java    From vaadin-sliderpanel with 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 #3
Source File: DemoUI.java    From vaadin-sliderpanel with 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 #4
Source File: AbstractLazyPageView.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
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 #5
Source File: UnresolvedTicketsByAssigneeWidget.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
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 #6
Source File: OperationResultWindow.java    From cuba with 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 #7
Source File: ProjectMemberLink.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
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 #8
Source File: WindowBreadCrumbs.java    From cuba with 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 File: MultiFileUpload.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 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 #10
Source File: VDragCaptionProvider.java    From cuba with 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 #11
Source File: UserLink.java    From mycollab with 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 #12
Source File: Header.java    From viritin with 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 #13
Source File: VerticalTabsheet.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
void hideCaption() {
    this.setCaption("");
    this.setDescription(String.format("<div class=\"v-label-h3 no-margin\">%s</div>", caption), ContentMode.HTML);
}
 
Example #14
Source File: LabelLink.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
public LabelLink(String title, String href) {
    super("", ContentMode.HTML);
    createContent(title, href);
    this.setValue(div.write());
}
 
Example #15
Source File: UploadField.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
protected Component createDisplayComponent() {
    defaultDisplay = new Label("", ContentMode.HTML);
    return defaultDisplay;
}
 
Example #16
Source File: StyleViewField.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
public StyleViewField(String value) {
    this.value = value;
    label = new ELabel(value, ContentMode.HTML).withFullWidth().withStyleName(WebThemes.LABEL_WORD_WRAP)
            .withUndefinedWidth().withDescription(value);
}
 
Example #17
Source File: DefaultViewField.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
public DefaultViewField(String value) {
    this(value, ContentMode.TEXT);
}
 
Example #18
Source File: ProjectPagedList.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
@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 #19
Source File: DefaultViewField.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
public DefaultViewField(String value, ContentMode contentMode) {
    this.value = value;
    label = new ELabel(value, contentMode).withFullWidth().withStyleName(WebThemes.LABEL_WORD_WRAP).withDescription(value);
}
 
Example #20
Source File: I18nFormViewField.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
public I18nFormViewField(Class<? extends Enum> enumCls, Enum defaultValue) {
    this.enumCls = enumCls;
    this.defaultValue = defaultValue;
    label = new ELabel(UserUIContext.getMessage(defaultValue), ContentMode.TEXT).withUndefinedWidth().withStyleName(WebThemes.LABEL_WORD_WRAP);
}
 
Example #21
Source File: SafeHtmlLabel.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
public SafeHtmlLabel(String value) {
    super(StringUtils.formatRichText(value), ContentMode.HTML);
    this.addStyleName(WebThemes.LABEL_WORD_WRAP);
}
 
Example #22
Source File: ELabel.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
public ELabel(ContentMode mode) {
    this("", mode);
}
 
Example #23
Source File: ELabel.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
public ELabel(String content, ContentMode mode) {
    super(content, mode);
}
 
Example #24
Source File: ELabel.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
public ELabel withDescription(String description) {
    this.setDescription(description, ContentMode.HTML);
    return this;
}
 
Example #25
Source File: ELabel.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
public static ELabel html(String value) {
    return new ELabel(value, ContentMode.HTML);
}
 
Example #26
Source File: ELabel.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
public static ELabel html(String value, String link) {
    return new ELabel(new A(link).appendText(value).write(), ContentMode.HTML);
}
 
Example #27
Source File: StepConnector.java    From gantt with Apache License 2.0 4 votes vote down vote up
@Override
public TooltipInfo getTooltipInfo(Element element) {
    return new TooltipInfo(getState().step.getDescription(), ContentMode.HTML, getState().errorMessage);
}
 
Example #28
Source File: SubStepConnector.java    From gantt with Apache License 2.0 4 votes vote down vote up
@Override
public TooltipInfo getTooltipInfo(Element element) {
    return new TooltipInfo(getState().step.getDescription(), ContentMode.HTML, getState().errorMessage);
}
 
Example #29
Source File: FileDownloadWindow.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
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 #30
Source File: Calendar.java    From calendar-component with Apache License 2.0 4 votes vote down vote up
/**
 * @return The content mode
 */
public ContentMode getContentMode() {
    return getState(false).descriptionContentMode;
}