Example usage for com.vaadin.ui Label setEnabled

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

Introduction

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

Prototype

@Override
    public void setEnabled(boolean enabled) 

Source Link

Usage

From source file:org.vaadin.tori.component.DebugControlPanel.java

License:Apache License

private Component createPostControl(final Method setter, final List<Post> posts) throws Exception {
    if (posts == null || posts.isEmpty()) {
        final Label label = new Label(getNameForCheckBox(setter));
        label.setEnabled(false);
        return label;
    }//from   ww  w . j a v a2 s. c  o m

    Component content = new CustomComponent() {
        {
            final CssLayout root = new CssLayout();
            root.addStyleName("postselect-content");
            root.addStyleName(setter.getName());
            setCompositionRoot(root);
            root.setWidth("100%");
            setWidth("400px");

            root.addComponent(new Label(setter.getName()));

            for (final Post post : posts) {
                final Method getter = getGetterFrom(setter);
                final boolean getterValue = (Boolean) getter.invoke(authorizationService, post.getId());

                final String authorName = post.getAuthor().getDisplayedName();

                String postBody = post.getBodyRaw();
                if (postBody.length() > 20) {
                    postBody = postBody.substring(0, 20);
                }

                final CheckBox checkbox = new CheckBox(authorName + " :: " + postBody);
                checkbox.setValue(getterValue);
                checkbox.addValueChangeListener(new PostCheckboxListener(post, setter));
                checkbox.setImmediate(true);
                checkbox.setWidth("100%");
                root.addComponent(checkbox);
            }
        }
    };
    final PopupView popup = new PopupView(getNameForCheckBox(setter), content);
    popup.setHideOnMouseOut(false);
    popup.setHeight(30.0f, Unit.PIXELS);
    return popup;
}