Java Code Examples for com.vaadin.ui.Label#setContentMode()

The following examples show how to use com.vaadin.ui.Label#setContentMode() . 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: TargetTable.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
private Label getTargetPollTime(final Object itemId) {
    final Label statusLabel = new Label();
    statusLabel.addStyleName(ValoTheme.LABEL_SMALL);
    statusLabel.setHeightUndefined();
    statusLabel.setContentMode(ContentMode.HTML);
    final String pollStatusToolTip = (String) getContainerDataSource().getItem(itemId)
            .getItemProperty(SPUILabelDefinitions.VAR_POLL_STATUS_TOOL_TIP).getValue();
    if (StringUtils.hasText(pollStatusToolTip)) {
        statusLabel.setValue(FontAwesome.EXCLAMATION_CIRCLE.getHtml());
        statusLabel.setDescription(pollStatusToolTip);
    } else {
        statusLabel.setValue(FontAwesome.CLOCK_O.getHtml());
        statusLabel.setDescription(getI18n().getMessage(UIMessageIdProvider.TOOLTIP_IN_TIME));
    }

    return statusLabel;
}
 
Example 2
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 3
Source File: CreateOrUpdateFilterTable.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private Component getStatusIcon(final Object itemId) {
    final Item row1 = getItem(itemId);
    final TargetUpdateStatus targetStatus = (TargetUpdateStatus) row1
            .getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).getValue();
    final Label label = new LabelBuilder().name("").buildLabel();
    label.setContentMode(ContentMode.HTML);
    if (targetStatus == TargetUpdateStatus.PENDING) {
        label.setDescription(i18n.getMessage(UIMessageIdProvider.TOOLTIP_STATUS_PENDING));
        label.setStyleName(SPUIStyleDefinitions.STATUS_ICON_YELLOW);
        label.setValue(FontAwesome.ADJUST.getHtml());
    } else if (targetStatus == TargetUpdateStatus.REGISTERED) {
        label.setDescription(i18n.getMessage(UIMessageIdProvider.TOOLTIP_STATUS_REGISTERED));
        label.setStyleName(SPUIStyleDefinitions.STATUS_ICON_LIGHT_BLUE);
        label.setValue(FontAwesome.DOT_CIRCLE_O.getHtml());
    } else if (targetStatus == TargetUpdateStatus.ERROR) {
        label.setDescription(i18n.getMessage(i18n.getMessage(UIMessageIdProvider.TOOLTIP_STATUS_ERROR)));
        label.setStyleName(SPUIStyleDefinitions.STATUS_ICON_RED);
        label.setValue(FontAwesome.EXCLAMATION_CIRCLE.getHtml());
    } else if (targetStatus == TargetUpdateStatus.IN_SYNC) {
        label.setStyleName(SPUIStyleDefinitions.STATUS_ICON_GREEN);
        label.setDescription(i18n.getMessage(UIMessageIdProvider.TOOLTIP_STATUS_INSYNC));
        label.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
    } else if (targetStatus == TargetUpdateStatus.UNKNOWN) {
        label.setStyleName(SPUIStyleDefinitions.STATUS_ICON_BLUE);
        label.setDescription(i18n.getMessage(UIMessageIdProvider.TOOLTIP_TARGET_STATUS_UNKNOWN));
        label.setValue(FontAwesome.QUESTION_CIRCLE.getHtml());
    }
    return label;
}
 
Example 4
Source File: AutoCompleteTextFieldComponent.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private static Label createStatusIcon() {
    final Label statusIcon = new Label();
    statusIcon.setImmediate(true);
    statusIcon.setContentMode(ContentMode.HTML);
    statusIcon.setSizeFull();
    setInitialStatusIconStyle(statusIcon);
    statusIcon.setId(UIComponentIdProvider.VALIDATION_STATUS_ICON_ID);
    return statusIcon;
}
 
Example 5
Source File: SPUIComponentProvider.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Method to CreateName value labels.
 *
 * @param label
 *            as string
 * @param values
 *            as string
 * @return HorizontalLayout
 */
public static HorizontalLayout createNameValueLayout(final String label, final String... values) {
    final String valueStr = StringUtils.arrayToDelimitedString(values, " ");

    final Label nameValueLabel = new Label( label );
    nameValueLabel.setContentMode(ContentMode.TEXT);
    nameValueLabel.addStyleName(SPUIDefinitions.TEXT_STYLE);
    nameValueLabel.addStyleName("text-bold");
    nameValueLabel.setSizeUndefined();

    final Label valueStrLabel = new Label(valueStr);
    valueStrLabel.setWidth("100%");
    valueStrLabel.addStyleName("text-cut");
    valueStrLabel.addStyleName(SPUIDefinitions.TEXT_STYLE);
    valueStrLabel.addStyleName(LABEL_STYLE);

    final HorizontalLayout nameValueLayout = new HorizontalLayout();
    nameValueLayout.setMargin(false);
    nameValueLayout.setSpacing(true);
    nameValueLayout.setSizeFull();

    nameValueLayout.addComponent(nameValueLabel);
    nameValueLayout.setComponentAlignment(nameValueLabel, Alignment.TOP_LEFT);
    nameValueLayout.setExpandRatio(nameValueLabel, 0.0F);

    nameValueLayout.addComponent(valueStrLabel);
    nameValueLayout.setComponentAlignment(valueStrLabel, Alignment.TOP_LEFT);
    nameValueLayout.setExpandRatio(valueStrLabel, 1.0F);

    return nameValueLayout;
}
 
Example 6
Source File: StorageAdminPanel.java    From sensorhub with Mozilla Public License 2.0 5 votes vote down vote up
protected void buildDataPanel(GridLayout form, IRecordStorageModule<?> storage)
{        
    // measurement outputs
    int i = 1;        
    if (storage.isEnabled())
    {
        for (IRecordStoreInfo dsInfo: storage.getRecordStores().values())
        {
            Panel panel = newPanel("Stream #" + i++);                
            GridLayout panelLayout = ((GridLayout)panel.getContent());
            panelLayout.setSpacing(true);
            
            // stored time period
            double[] timeRange = storage.getRecordsTimeRange(dsInfo.getName());
            Label l = new Label("<b>Time Range:</b> " + new DateTimeFormat().formatIso(timeRange[0], 0)
                                 + " / " + new DateTimeFormat().formatIso(timeRange[1], 0));
            l.setContentMode(ContentMode.HTML);
            panelLayout.addComponent(l, 0, 0, 1, 0);
            
            // time line
            panelLayout.addComponent(buildGantt(storage, dsInfo), 0, 1, 1, 1);
            
            // data structure
            DataComponent dataStruct = dsInfo.getRecordDescription();
            Component sweForm = new SWECommonForm(dataStruct);
            panelLayout.addComponent(sweForm);
            
            // data table
            panelLayout.addComponent(buildTable(storage, dsInfo));
            
            if (oldPanel != null)
                form.replaceComponent(oldPanel, panel);
            else
                form.addComponent(panel);
            oldPanel = panel;
        }
    }
}
 
Example 7
Source File: BasicModel.java    From chipster with MIT License 5 votes vote down vote up
private void initHeadeer() {
	lbTitle = new Label();
	lbTitle.setContentMode(ContentMode.HTML);
	lbTitleDescription = new Label();
	lbTitleDescription.setContentMode(ContentMode.HTML);
	lbTitleDescription.setImmediate(true);
	addRow(lbTitle, lbTitleDescription);
}
 
Example 8
Source File: JobLogView.java    From chipster with MIT License 5 votes vote down vote up
private void showTextWindow(String caption, String content) {
	
	Label textComponent = new Label(content);
	textComponent.setContentMode(ContentMode.PREFORMATTED);
	
	Window subWindow = new Window(caption);
	subWindow.setContent(textComponent);
	
	subWindow.setWidth(70, Unit.PERCENTAGE);
	subWindow.setHeight(90, Unit.PERCENTAGE);
	subWindow.center();
	
	this.getUI().addWindow(subWindow);
}
 
Example 9
Source File: AddUpdateRolloutWindowLayout.java    From hawkbit with Eclipse Public License 1.0 4 votes vote down vote up
private Label getMandatoryLabel(final String key) {
    final Label mandatoryLabel = getLabel(i18n.getMessage(key));
    mandatoryLabel.setContentMode(ContentMode.HTML);
    mandatoryLabel.setValue(mandatoryLabel.getValue().concat(" <span style='color:#ed473b'>*</span>"));
    return mandatoryLabel;
}
 
Example 10
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);
}