Example usage for com.vaadin.ui Label setVisible

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

Introduction

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

Prototype

@Override
    public void setVisible(boolean visible) 

Source Link

Usage

From source file:fi.semantum.strategia.Utils.java

License:Open Source License

public static void modifyAccount(final Main main) {

    final Database database = main.getDatabase();

    FormLayout content = new FormLayout();
    content.setSizeFull();/*from  w w w.  j  a va2  s. c  o  m*/

    final Label l = new Label(main.account.getId(database));
    l.setCaption("Kyttjn nimi:");
    l.setWidth("100%");
    content.addComponent(l);

    final TextField tf = new TextField();
    tf.setWidth("100%");
    tf.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    tf.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
    tf.setCaption("Kyttjn nimi:");
    tf.setId("loginUsernameField");
    tf.setValue(main.account.getText(database));
    content.addComponent(tf);

    final TextField tf2 = new TextField();
    tf2.setWidth("100%");
    tf2.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    tf2.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
    tf2.setCaption("Shkpostiosoite:");
    tf2.setId("loginUsernameField");
    tf2.setValue(main.account.getEmail());
    content.addComponent(tf2);

    final PasswordField pf = new PasswordField();
    pf.setCaption("Vanha salasana:");
    pf.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    pf.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
    pf.setWidth("100%");
    pf.setId("loginPasswordField");
    content.addComponent(pf);

    final PasswordField pf2 = new PasswordField();
    pf2.setCaption("Uusi salasana:");
    pf2.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    pf2.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
    pf2.setWidth("100%");
    pf2.setId("loginPasswordField");
    content.addComponent(pf2);

    final PasswordField pf3 = new PasswordField();
    pf3.setCaption("Uusi salasana uudestaan:");
    pf3.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    pf3.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
    pf3.setWidth("100%");
    pf3.setId("loginPasswordField");
    content.addComponent(pf3);

    final Label err = new Label("Vr kyttjtunnus tai salasana");
    err.addStyleName(ValoTheme.LABEL_FAILURE);
    err.addStyleName(ValoTheme.LABEL_TINY);
    err.setVisible(false);
    content.addComponent(err);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.setMargin(false);

    Button apply = new Button("Tee muutokset");

    buttons.addComponent(apply);

    final Window dialog = Dialogs.makeDialog(main, "450px", "480px", "Kyttjtilin asetukset", "Poistu",
            content, buttons);
    apply.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = 1992235622970234624L;

        public void buttonClick(ClickEvent event) {

            String valueHash = Utils.hash(pf.getValue());
            if (!valueHash.equals(main.account.getHash())) {
                err.setValue("Vr salasana");
                err.setVisible(true);
                return;
            }

            if (pf2.isEmpty()) {
                err.setValue("Tyhj salasana ei kelpaa");
                err.setVisible(true);
                return;
            }

            if (!pf2.getValue().equals(pf3.getValue())) {
                err.setValue("Uudet salasanat eivt tsm");
                err.setVisible(true);
                return;
            }

            main.account.text = tf.getValue();
            main.account.email = tf2.getValue();
            main.account.hash = Utils.hash(pf2.getValue());

            Updates.update(main, true);

            main.removeWindow(dialog);

        }

    });

}

From source file:fi.semantum.strategia.widget.NumberTrafficValuation.java

License:Open Source License

private void applyValues(Main main, Meter meter, ComboBox combo, VerticalLayout vl1, Label l1,
        VerticalLayout vl2, Label l2, VerticalLayout vl3, Label l3, TextField tf1, TextField tf2) {

    inApply = true;/* w  ww .  j  av  a2s  .co m*/

    Indicator indicator = meter.getPossibleIndicator(main.getDatabase());
    String unit = indicator.getUnit();

    combo.select(getState());

    final double highDouble = getHighLimit().doubleValue();
    final double lowDouble = getLowLimit().doubleValue();

    String highLimit = df.format(highDouble);
    String lowLimit = df.format(lowDouble);

    tf1.setValue(highLimit);
    l1.setValue(highLimit + " < arvo " + unit);

    if (isIncrease()) {
        vl1.setStyleName("greenBlock");
    } else {
        vl1.setStyleName("redBlock");
    }

    tf1.removeAllValidators();
    tf1.addValidator(new Validator() {

        private static final long serialVersionUID = 5929569929930454714L;

        @Override
        public void validate(Object value) throws InvalidValueException {
            try {
                double d = Double.parseDouble((String) value);
                if (d < lowDouble)
                    throw new InvalidValueException("Value is too small");
            } catch (NumberFormatException e) {
                throw new InvalidValueException(e.getMessage());
            }
        }

    });

    if (isTwo()) {

        l3.setVisible(false);
        vl3.setVisible(false);
        tf2.setVisible(false);
        tf1.setCaption("Raja-arvo");

        if (isIncrease()) {
            vl2.setStyleName("redBlock");
        } else {
            vl2.setStyleName("greenBlock");
        }

        l2.setValue("arvo < " + lowLimit + " " + unit);

    } else {

        vl3.setVisible(true);
        l3.setVisible(true);
        tf2.setVisible(true);
        tf1.setCaption("Suurempi raja-arvo");
        tf2.setCaption("Pienempi raja-arvo");
        vl2.setStyleName("yellowBlock");

        l2.setValue(lowLimit + " < arvo < " + highLimit + " " + unit);
        l3.setValue("arvo < " + lowLimit + " " + unit);
        tf2.setValue(lowLimit);

        if (isIncrease()) {
            vl3.setStyleName("redBlock");
        } else {
            vl3.setStyleName("greenBlock");
        }

        tf2.removeAllValidators();
        tf2.addValidator(new Validator() {

            private static final long serialVersionUID = 5929569929930454714L;

            @Override
            public void validate(Object value) throws InvalidValueException {
                try {
                    double d = Double.parseDouble((String) value);
                    if (d > highDouble)
                        throw new InvalidValueException("Value is too large");
                } catch (NumberFormatException e) {
                    throw new InvalidValueException(e.getMessage());
                }
            }

        });

    }

    inApply = false;

}

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./* w  w w  . 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.apache.usergrid.chop.webapp.view.user.KeyListLayout.java

License:Apache License

public void disableKeyLabels() {
    for (Label l : keyLabels) {
        l.setVisible(false);
    }
}

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//from   w  w w  . 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

private static Label getWarningLabel() {
    final Label warningIconLabel = new Label();
    warningIconLabel.addStyleName(ValoTheme.LABEL_SMALL);
    warningIconLabel.setHeightUndefined();
    warningIconLabel.setContentMode(ContentMode.HTML);
    warningIconLabel.setValue(FontAwesome.WARNING.getHtml());
    warningIconLabel.addStyleName("warningLabel");
    warningIconLabel.setVisible(false);
    return warningIconLabel;
}

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();//w ww .j  av a 2 s.c om
            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 hideErrorIcon(final Label warningLabel, final int errorLabelCount, final int duplicateCount,
        final Label errorLabel, final String oldFileName, final Long currentSwId) {
    if (warningLabel == null && (errorLabelCount > 1 || (duplicateCount == 1 && errorLabelCount == 1))) {

        final Optional<Artifact> artifactList = artifactManagement.getByFilenameAndSoftwareModule(oldFileName,
                currentSwId);/*ww w  . j a  v a 2  s. c om*/
        if (errorLabel == null) {
            return;
        }
        errorLabel.removeStyleName(SPUIStyleDefinitions.ERROR_LABEL);
        errorLabel.setDescription(i18n.getMessage(ALREADY_EXISTS_MSG));
        if (!artifactList.isPresent()) {
            errorLabel.setVisible(false);
        }
        redErrorLabelCount--;
    }
}

From source file:org.eclipse.hawkbit.ui.common.builder.LabelBuilder.java

License:Open Source License

private Label createLabel() {
    final Label label = new Label(name);
    label.setVisible(visible);
    final StringBuilder style = new StringBuilder(ValoTheme.LABEL_SMALL);
    style.append(' ');
    style.append(ValoTheme.LABEL_BOLD);//from  w  w  w  . j  a v  a  2s .  co  m
    label.addStyleName(style.toString());
    if (id != null) {
        label.setId(id);
    }

    return label;
}

From source file:org.eclipse.hawkbit.ui.management.targettable.TargetBulkUpdateWindowLayout.java

License:Open Source License

private static Label getStatusCountLabel() {
    final Label countLabel = new Label();
    countLabel.setImmediate(true);/*from w w w  .  ja  v a 2 s  .  c o m*/
    countLabel.addStyleName("bulk-upload-label");
    countLabel.setVisible(false);
    countLabel.setCaptionAsHtml(true);
    countLabel.setId(UIComponentIdProvider.BULK_UPLOAD_COUNT);
    return countLabel;
}