Example usage for com.vaadin.ui Label isVisible

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

Introduction

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

Prototype

@Override
    public boolean isVisible() 

Source Link

Usage

From source file:nz.co.senanque.vaadinsupport.application.MaduraSessionManager.java

License:Apache License

/**
 * Check all the other fields to ensure they are still valid
 * this includes any buttons that were registered because they
 * get disabled if there are errors on the relevant form or
 * if the requiredness is incomplete.//from www  .  j a  v a 2s  .c om
 * 
 * @param field
 */
public void updateOtherFields(AbstractField field) {
    PermissionManager permissionmanager = getPermissionManager();
    Collection<AbstractField> fields = getFields();
    Collection<Label> labels = getLabels();
    for (Label fieldx : labels) {
        com.vaadin.data.Property p = fieldx.getPropertyDataSource();
        if (p != null && p instanceof LabelProperty) {
            fieldx.requestRepaint();
        }
    }
    for (AbstractField fieldx : fields) {
        if (fieldx.equals(field))
            continue;
        if ((fieldx instanceof Button) && !(fieldx instanceof CheckBox)) {
            com.vaadin.data.Property p = fieldx.getPropertyDataSource();
            if (p != null && p instanceof ButtonProperty) {
                ((ButtonProperty) p).getPainter().paint((Button) fieldx);
                fieldx.requestRepaint();
            }
            continue;
        }
        if (fieldx instanceof MenuItemWrapper) {
            MenuItemPainter menuItemPainter = ((MenuItemWrapper) fieldx).getMenuItemPainter();
            MenuItem menuItem = (MenuItem) fieldx.getData();
            if (menuItemPainter != null) {
                menuItemPainter.paint(menuItem);
                fieldx.requestRepaint();
            }
            continue;
        }
        MaduraPropertyWrapper property = null;
        try {
            property = (MaduraPropertyWrapper) fieldx.getPropertyDataSource();
        } catch (Exception e) {
            // ignore
            property = null;
        }
        if (property != null) {
            if (logger.isDebugEnabled()) {
                logger.debug("evaluating field: {}", property.getName());
                if (fieldx.isEnabled() != property.isEnabled()) {
                    logger.debug("Enabled: {} {}", fieldx.isEnabled(), property.isEnabled());
                }
                if (fieldx.isReadOnly() != property.isReadOnly()) {
                    logger.debug("ReadOnly: {} {}", fieldx.isReadOnly(), property.isReadOnly());
                }
                if (fieldx.isRequired() != property.isRequired()) {
                    logger.debug("Required: {} {}", fieldx.isRequired(), property.isRequired());
                }
                if (fieldx.isVisible() != property.isVisible()) {
                    logger.debug("Visible: {} {}", fieldx.isVisible(), property.isVisible());
                }
            }
            fieldx.setEnabled(property.isEnabled());
            fieldx.setReadOnly(property.isReadOnly());
            fieldx.setRequired(property.isRequired());
            fieldx.setVisible(property.isVisible());
            // Permissions trump rules
            if (!permissionmanager.hasPermission(property.getReadPermission())) {
                fieldx.setVisible(false);
            }
            if (!permissionmanager.hasPermission(property.getWritePermission())) {
                fieldx.setEnabled(false);
            }
            if (fieldx instanceof AbstractSelect) {
                AbstractSelect select = (AbstractSelect) fieldx;
                List<ChoiceBase> availableList = new ArrayList<ChoiceBase>();
                for (ChoiceBase v : property.getAvailableValues()) {
                    availableList.add(v);
                }
                logger.debug("{} availableList {}", property.getName(), availableList);
                Collection<?> itemIds = select.getItemIds();
                List<Object> killList = new ArrayList<Object>();
                for (Object itemId : itemIds) {
                    if (availableList.contains(itemId))
                        continue;
                    killList.add(itemId);
                }
                for (Object kill : killList) {
                    select.removeItem(kill);
                }
                for (ChoiceBase cb : availableList) {
                    select.addItem(cb);
                }
                logger.debug("Select {} value \"{}\", updated to {}",
                        new Object[] { property.getName(), select.getValue(), select.getItemIds() });
            }
        }
        fieldx.requestRepaint();
    }
}

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

License:Open Source License

private void onFileNameChange(final TextChangeEvent event, final Label warningIconLabel, final Item newItem) {

    final String itemId = (String) ((TextField) event.getComponent()).getData();
    final String fileName = event.getText();

    final Boolean isWarningIconDisplayed = isWarningIcon(warningIconLabel);
    setWarningIcon(warningIconLabel, fileName, itemId);

    final Long currentSwId = (Long) newItem.getItemProperty(BASE_SOFTWARE_ID).getValue();
    final String oldFileName = (String) newItem.getItemProperty(FILE_NAME).getValue();
    newItem.getItemProperty(FILE_NAME).setValue(event.getText());

    // if warning was displayed prior and not displayed currently
    if (isWarningIconDisplayed && !warningIconLabel.isVisible()) {
        modifyIconOfSameSwId(itemId, currentSwId, oldFileName);
    }/*  w w w.ja  v  a 2  s  .c  om*/
    checkDuplicateEntry(itemId, currentSwId, event.getText(), oldFileName);
    enableOrDisableUploadBtn();
}

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

License:Open Source License

/**
 * If warning was displayed prior and not displayed currently ,the update
 * other warning labels accordingly./*  w  w  w  . j a  v a  2s  .  com*/
 *
 * @param itemId
 *            id of row which is deleted/whose file name modified.
 * @param oldSwId
 *            software module id
 * @param oldFileName
 *            file name before modification
 */
private void modifyIconOfSameSwId(final Object itemId, final Long oldSwId, final String oldFileName) {
    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(oldSwId) && newFileName.equals(oldFileName)) {
            final HorizontalLayout layout = (HorizontalLayout) newItem.getItemProperty(FILE_NAME_LAYOUT)
                    .getValue();
            final Label warningLabel = (Label) layout.getComponent(1);
            if (warningLabel.isVisible()) {
                warningLabel.removeStyleName(SPUIStyleDefinitions.ERROR_LABEL);
                warningLabel.setDescription(i18n.getMessage(ALREADY_EXISTS_MSG));
                newItem.getItemProperty(WARNING_ICON).setValue(warningLabel);
                redErrorLabelCount--;
                break;
            }
        }
    }
}

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/*from ww  w  . java  2s  .c om*/
 *            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 reValidateOtherFileNamesOfSameBaseSw(final Object itemId, final Long currentSwId,
        final String oldFileName) {
    Label warningLabel = null;/*from w  w w . j  a  v  a 2s  . c om*/
    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);
}