Example usage for com.vaadin.ui Label getStyleName

List of usage examples for com.vaadin.ui Label getStyleName

Introduction

In this page you can find the example usage for com.vaadin.ui Label getStyleName.

Prototype

@Override
    public String getStyleName() 

Source Link

Usage

From source file:org.eclipse.hawkbit.ui.artifacts.upload.UploadConfirmationWindow.java

License:Open Source License

/**
 * Warning icon is displayed, if an artifact exists with same provided file
 * name. Error icon is displayed, if file name entered is duplicate.
 *
 * @param warningIconLabel//w ww .j a  v  a 2  s .  com
 *            warning/error label
 * @param fileName
 *            provided file name
 * @param itemId
 *            item id of the current row
 */
private void setWarningIcon(final Label warningIconLabel, final String fileName, final Object itemId) {
    final Item item = uploadDetailsTable.getItem(itemId);
    if (StringUtils.hasText(fileName)) {
        final String fileNameTrimmed = StringUtils.trimWhitespace(fileName);
        final Long baseSwId = (Long) item.getItemProperty(BASE_SOFTWARE_ID).getValue();
        final Optional<Artifact> artifact = artifactManagement.getByFilenameAndSoftwareModule(fileNameTrimmed,
                baseSwId);
        if (artifact.isPresent()) {
            warningIconLabel.setVisible(true);
            if (isErrorIcon(warningIconLabel)) {
                warningIconLabel.removeStyleName(SPUIStyleDefinitions.ERROR_LABEL);
                redErrorLabelCount--;
            }
            warningIconLabel.setDescription(i18n.getMessage(ALREADY_EXISTS_MSG));
            if (checkForDuplicate(fileNameTrimmed, itemId, baseSwId)) {
                warningIconLabel.setDescription(i18n.getMessage("message.duplicate.filename"));
                warningIconLabel.addStyleName(SPUIStyleDefinitions.ERROR_LABEL);
                redErrorLabelCount++;
            }
        } else {
            warningIconLabel.setVisible(false);
            if (warningIconLabel.getStyleName().contains(SPUIStyleDefinitions.ERROR_LABEL)) {
                warningIconLabel.removeStyleName(SPUIStyleDefinitions.ERROR_LABEL);
                warningIconLabel.setDescription(i18n.getMessage(ALREADY_EXISTS_MSG));
                redErrorLabelCount--;
            }
        }
    }
}

From source file:org.eclipse.hawkbit.ui.artifacts.upload.UploadConfirmationWindow.java

License:Open Source License

/**
 * Check if icon is error icon and visible.
 *
 * @param icon/*www . j  a v  a  2  s  .  c o m*/
 *            label
 * @return Boolean
 */
private static boolean isErrorIcon(final Label icon) {
    return icon.isVisible() && icon.getStyleName().contains(SPUIStyleDefinitions.ERROR_LABEL);
}

From source file:org.eclipse.hawkbit.ui.artifacts.upload.UploadConfirmationWindow.java

License:Open Source License

private void newFileNameIsDuplicate(final Object itemId, final Long currentSwId,
        final String currentChangedText) {
    for (final Object rowId : tableContainer.getItemIds()) {
        final Item currentItem = tableContainer.getItem(itemId);
        final Item newItem = tableContainer.getItem(rowId);
        final Long newBaseSwId = (Long) newItem.getItemProperty(BASE_SOFTWARE_ID).getValue();
        final String fileName = (String) newItem.getItemProperty(FILE_NAME).getValue();
        if (!rowId.equals(itemId) && newBaseSwId.equals(currentSwId) && fileName.equals(currentChangedText)) {
            final HorizontalLayout layout = (HorizontalLayout) currentItem.getItemProperty(FILE_NAME_LAYOUT)
                    .getValue();//from w  w  w .  j a  v a  2 s .  c o m
            final Label iconLabel = (Label) layout.getComponent(1);
            if (!iconLabel.getStyleName().contains(SPUIStyleDefinitions.ERROR_LABEL)) {
                iconLabel.setVisible(true);
                iconLabel.setDescription(i18n.getMessage("message.duplicate.filename"));
                iconLabel.addStyleName(SPUIStyleDefinitions.ERROR_LABEL);
                redErrorLabelCount++;
            }
            break;
        }
    }
}

From source file:org.eclipse.hawkbit.ui.artifacts.upload.UploadConfirmationWindow.java

License:Open Source License

private void reValidateOtherFileNamesOfSameBaseSw(final Object itemId, final Long currentSwId,
        final String oldFileName) {
    Label warningLabel = null;/*w w  w  .  j  av  a2 s.c o  m*/
    Label errorLabel = null;
    int errorLabelCount = 0;
    int duplicateCount = 0;
    for (final Object rowId : tableContainer.getItemIds()) {
        final Item newItem = tableContainer.getItem(rowId);
        final Long newBaseSwId = (Long) newItem.getItemProperty(BASE_SOFTWARE_ID).getValue();
        final String newFileName = (String) newItem.getItemProperty(FILE_NAME).getValue();
        if (!rowId.equals(itemId) && newBaseSwId.equals(currentSwId) && newFileName.equals(oldFileName)) {
            final HorizontalLayout layout = (HorizontalLayout) newItem.getItemProperty(FILE_NAME_LAYOUT)
                    .getValue();
            final Label icon = (Label) layout.getComponent(1);
            duplicateCount++;
            if (icon.isVisible()) {
                if (!icon.getStyleName().contains(SPUIStyleDefinitions.ERROR_LABEL)) {
                    warningLabel = icon;
                    break;
                }
                errorLabel = icon;
                errorLabelCount++;
            }
        }
    }
    hideErrorIcon(warningLabel, errorLabelCount, duplicateCount, errorLabel, oldFileName, currentSwId);
}

From source file:org.ripla.web.controllers.RiplaBody.java

License:Open Source License

/**
 * We have to clone the separator label defined in the skin.
 * /*from w ww.  j a v  a 2 s  .c o m*/
 * @param inSeparator
 *            Label
 * @return {@link Label} the cloned label
 */
private Label getSeparator(final Label inSeparator) {
    final Label out = new Label(inSeparator.getValue().toString(), inSeparator.getContentMode());
    out.setWidth(inSeparator.getWidth(), inSeparator.getWidthUnits());
    out.setStyleName(inSeparator.getStyleName());
    return out;
}