Example usage for com.vaadin.ui CheckBoxGroup CheckBoxGroup

List of usage examples for com.vaadin.ui CheckBoxGroup CheckBoxGroup

Introduction

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

Prototype

public CheckBoxGroup(String caption) 

Source Link

Document

Constructs a new CheckBoxGroup with caption.

Usage

From source file:org.jpos.qi.eeuser.ConsumersView.java

License:Open Source License

protected Component buildAndBindCustomComponent(String propertyId) {
    if ("roles".equalsIgnoreCase(propertyId)) {
        CheckBoxGroup<Role> checkBoxGroup = new CheckBoxGroup<>(QIUtils.getCaptionFromId(propertyId));
        checkBoxGroup.setItems(((ConsumersHelper) getHelper()).getRoles());
        checkBoxGroup.setItemCaptionGenerator(role -> StringUtils.capitalize(role.getName()));
        formatField(propertyId, checkBoxGroup).bind(propertyId);
        return checkBoxGroup;
    }//  w  w  w . j  ava 2s  . c  o m
    if ("user".equalsIgnoreCase(propertyId)) {
        ComboBox<User> box = createUserBox();
        formatField(propertyId, box).bind(propertyId);
        box.setEnabled(false);
        box.setValue(this.selectedUser);
        return box;
    }
    if ("startdate".equalsIgnoreCase(propertyId) || "endDate".equalsIgnoreCase(propertyId)) {
        return buildAndBindDateField(propertyId);
    }
    return null;
}

From source file:org.jpos.qi.eeuser.RolesView.java

License:Open Source License

@Override
protected Component buildAndBindCustomComponent(String propertyId) {
    List<Validator> validators = getValidators(propertyId);
    if ("permissions".equals(propertyId)) {
        CheckBoxGroup<Permission> f = new CheckBoxGroup("Permissions");
        List<SysConfig> sysconfigs = ((RolesHelper) getHelper()).getPermissions();
        List<Permission> allPermissions = new ArrayList<>();
        //convert SysConfigs to Permissions
        for (SysConfig sys : sysconfigs) {
            Permission p = Permission.valueOf(sys.getId().substring(5));
            allPermissions.add(p);//  w ww. ja  va2s.co  m
        }
        f.setItems(allPermissions);
        f.setItemCaptionGenerator((ItemCaptionGenerator<Permission>) item -> sysconfigs
                .get(allPermissions.indexOf(item)).getId().substring(5) + " : " + //remove "perm." prefix
                sysconfigs.get(allPermissions.indexOf(item)).getValue());
        Binder.BindingBuilder builder = getBinder().forField(f);
        validators.forEach(builder::withValidator);
        builder.bind(propertyId);
        return f;
    }
    return null;
}

From source file:org.jpos.qi.eeuser.UsersView.java

License:Open Source License

protected Component buildAndBindCustomComponent(String propertyId) {
    if ("roles".equals(propertyId)) {
        CheckBoxGroup g = new CheckBoxGroup(StringUtils.capitalize(getCaptionFromId(propertyId)));
        g.setItems(((UsersHelper) getHelper()).getRoles());
        g.setItemCaptionGenerator((ItemCaptionGenerator<Role>) item -> StringUtils.capitalize(item.getName()));
        List<Validator> v = getValidators(propertyId);
        Binder.BindingBuilder builder = getBinder().forField(g);
        for (Validator val : v) {
            builder.withValidator(val);
        }//from w ww .  ja  v  a2  s  .co  m
        builder.bind(propertyId);
        return g;
    }
    return null;
}

From source file:org.jpos.qi.minigl.AccountsView.java

License:Open Source License

private Panel createEntriesPanel() {
    Panel entriesPanel = new Panel(getCaptionFromId("entries"));
    entriesPanel.setIcon(VaadinIcons.EXCHANGE);
    entriesPanel.addStyleName("color1");
    entriesPanel.addStyleName("margin-top-panel");

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);/* w w w.j  a v a  2 s . c o  m*/
    layout.setSpacing(true);
    Panel filterPanel = new Panel();
    filterPanel.addStyleName("v-panel-well");

    journals = new JournalsCombo(true);

    rangeLabelTitle = new Label();
    rangeLabelTitle.addStyleName(ValoTheme.LABEL_BOLD);
    dateRangeComponent = new DateRangeComponent(DateRange.ALL_TIME, true) {
        @Override
        protected Button.ClickListener createRefreshListener() {
            return event -> {
                refreshDetails();
            };
        }
    };
    VerticalLayout detailsLayout = new VerticalLayout();

    entryGrid = new EntryGrid(null, false);
    formatEntriesGrid();
    detailsLayout.addComponent(entryGrid);
    detailsLayout.setMargin(false);

    HorizontalLayout layersLayout = new HorizontalLayout();
    layersLayout.setSizeFull();
    layersLayout.setSpacing(true);

    layersCheckBox = new CheckBoxGroup<>(getCaptionFromId("layers").toUpperCase());
    layersCheckBox.setItemCaptionGenerator(item -> item.getId() + " - " + item.getName());
    layersCheckBox.addValueChangeListener(listener -> refreshDetails());

    layersLayout.addComponentsAndExpand(layersCheckBox);
    VerticalLayout vbar = new VerticalLayout(journals, dateRangeComponent, layersLayout);
    vbar.setSpacing(true);
    vbar.setMargin(true);
    filterPanel.setContent(vbar);
    layout.addComponents(rangeLabelTitle, detailsLayout, filterPanel);
    entriesPanel.setContent(layout);
    refreshDetails();
    return entriesPanel;

}