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

The following examples show how to use com.vaadin.shared.ui.ContentMode#HTML . 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: 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 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: 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 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: 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 6
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 7
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 8
Source File: WebLabel.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isHtmlEnabled() {
    return component.getContentMode() == ContentMode.HTML;
}
 
Example 9
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 10
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 11
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 12
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 13
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 14
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 15
Source File: ComponentReadViewImpl.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
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 16
Source File: CubaCapsLockIndicator.java    From cuba with Apache License 2.0 4 votes vote down vote up
protected void initCapsLockIndicatorContent() {
    getState().contentMode = ContentMode.HTML;
    getState().text = "<span></span>";
}
 
Example 17
Source File: DocumentDataPageModContentFactoryImpl.java    From cia with Apache License 2.0 2 votes vote down vote up
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
	final VerticalLayout panelContent = createPanelContent();

	final String pageId = getPageId(parameters);

	getDocumentMenuItemFactory().createDocumentMenuBar(menuBar, pageId);

	LabelFactory.createHeader2Label(panelContent, DOCUMENT_DATA);

	final DataContainer<DocumentContentData, String> documentContentDataDataContainer = getApplicationManager()
			.getDataContainer(DocumentContentData.class);

	final List<DocumentContentData> documentContentlist = documentContentDataDataContainer
			.getAllBy(DocumentContentData_.id, pageId);

	if (!documentContentlist.isEmpty()) {

		final Panel formPanel = new Panel();
		formPanel.setSizeFull();

		panelContent.addComponent(formPanel);

		final FormLayout formContent = new FormLayout();
		formPanel.setContent(formContent);

		final String cleanContent = Jsoup.clean(documentContentlist.get(0).getContent(), "", Whitelist.simpleText(),
				new OutputSettings().indentAmount(4));

		final Label htmlContent = new Label(cleanContent, ContentMode.PREFORMATTED);

		formContent.addComponent(htmlContent);

		final DocumentWordCountRequest documentWordCountRequest = new DocumentWordCountRequest();
		documentWordCountRequest.setDocumentId(pageId);
		documentWordCountRequest.setMaxResults(MAX_RESULTS);
		documentWordCountRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
		final DocumentWordCountResponse resp = (DocumentWordCountResponse) getApplicationManager()
				.service(documentWordCountRequest);

		if (resp.getWordCountMap() != null) {
			final Label wordCloud = new Label(createWordCloud(resp.getWordCountMap()), ContentMode.HTML);
			formContent.addComponent(wordCloud);
		}

		panelContent.setExpandRatio(formPanel, ContentRatio.GRID);

	}

	panel.setContent(panelContent);
	getPageActionEventHelper().createPageEvent(ViewAction.VISIT_DOCUMENT_VIEW, ApplicationEventGroup.USER, NAME,
			parameters, pageId);

	return panelContent;

}