Example usage for com.vaadin.ui CheckBox setValue

List of usage examples for com.vaadin.ui CheckBox setValue

Introduction

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

Prototype

@Override
public void setValue(Boolean value) 

Source Link

Document

Sets the value of this CheckBox.

Usage

From source file:com.esofthead.mycollab.module.project.ui.components.ProjectSubscribersComp.java

License:Open Source License

@Override
protected Component initContent() {
    ProjectMemberService projectMemberService = ApplicationContextUtil
            .getSpringBean(ProjectMemberService.class);
    List<SimpleUser> members = projectMemberService.getActiveUsersInProject(projectId,
            AppContext.getAccountId());//from w  ww . ja v  a2s .  co  m
    CssLayout container = new CssLayout();
    container.setStyleName("followers-container");
    final CheckBox selectAllCheckbox = new CheckBox("All", defaultSelectAll);
    selectAllCheckbox.addValueChangeListener(new ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            boolean val = selectAllCheckbox.getValue();
            for (FollowerCheckbox followerCheckbox : memberSelections) {
                followerCheckbox.setValue(val);
            }
        }
    });
    container.addComponent(selectAllCheckbox);
    for (SimpleUser user : members) {
        final FollowerCheckbox memberCheckbox = new FollowerCheckbox(user);
        memberCheckbox.addValueChangeListener(new ValueChangeListener() {
            @Override
            public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
                if (!memberCheckbox.getValue()) {
                    selectAllCheckbox.setValue(false);
                }
            }
        });
        if (defaultSelectAll || selectedUsers.contains(user.getUsername())) {
            memberCheckbox.setValue(true);
        }
        memberSelections.add(memberCheckbox);
        container.addComponent(memberCheckbox);
    }
    return container;
}

From source file:com.esofthead.mycollab.module.project.ui.form.ProjectFormWatcherSelectField.java

License:Open Source License

public void checkItem(String name) {
    for (int i = 0; i < wrapper.getComponentCount(); i++) {
        CheckBox checkBox = ((CheckBox) wrapper.getComponent(i));
        if (checkBox.getCaption().equals(name)) {
            checkBox.setValue(true);
            break;
        }//  w w w. ja  va2 s.  c o m
    }
}

From source file:com.esofthead.mycollab.module.project.ui.form.ProjectFormWatcherSelectField.java

License:Open Source License

@Override
protected Component initContent() {
    wrapper.setWidth("100%");
    final CheckBox selectAllCheckbox = new CheckBox("All");
    selectAllCheckbox.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override/*from w  ww.  ja  v a2  s  .c o  m*/
        public void valueChange(Property.ValueChangeEvent event) {
            boolean isSelected = (Boolean) event.getProperty().getValue();
            for (int i = 0; i < wrapper.getComponentCount(); i++) {
                ((CheckBox) wrapper.getComponent(i)).setValue(isSelected);
            }
        }
    });
    selectAllCheckbox.addStyleName("watcher-field");
    wrapper.addComponent(selectAllCheckbox);

    List<SimpleMonitorItem> preselectedMonitorItems = getPreselectedMonitorItems();
    projectMembers = getActiveMembers();
    for (int i = 0; i < projectMembers.size(); i++) {
        final SimpleProjectMember member = projectMembers.get(i);
        String fullname = member.getMemberFullName();

        CheckBox checkbox = new CheckBox(fullname);
        checkbox.setIcon(UserAvatarControlFactory.createAvatarResource(member.getMemberAvatarId(), 16));
        checkbox.addStyleName("watcher-field");
        checkbox.addValueChangeListener(new ValueChangeListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void valueChange(Property.ValueChangeEvent event) {
                if ((Boolean) event.getProperty().getValue()) {
                    selectedMembers.add(member);
                    if (selectedMembers.size() == projectMembers.size()) {
                        selectAllCheckbox.setValue(true);
                    }
                } else {
                    selectedMembers.remove(member);
                    selectAllCheckbox.setValue(false);
                }
            }
        });
        if (member.getUsername().equals(AppContext.getUsername())) {
            checkbox.setValue(true);
        }
        wrapper.addComponent(checkbox);

        if (checkAll) {
            checkbox.setValue(true);
        } else {
            for (SimpleMonitorItem monitorItem : preselectedMonitorItems) {
                if (member.getUsername().equals(monitorItem.getUser())) {
                    checkbox.setValue(true);
                }
            }
        }
    }
    return wrapper;
}

From source file:com.esofthead.mycollab.module.project.view.milestone.AllMilestoneTimelineWidget.java

License:Open Source License

public void display() {
    this.withMargin(new MarginInfo(true, false, true, false));
    this.setWidth("100%");
    this.addStyleName("tm-container");

    MHorizontalLayout headerLayout = new MHorizontalLayout()
            .withMargin(new MarginInfo(false, true, false, true));
    ELabel titleLbl = ELabel.h2("Phase Timeline");

    final CheckBox includeNoDateSet = new CheckBox("No date set");
    includeNoDateSet.setValue(false);

    final CheckBox includeClosedMilestone = new CheckBox("Closed phase");
    includeClosedMilestone.setValue(false);

    includeNoDateSet.addValueChangeListener(new Property.ValueChangeListener() {
        @Override//w  w  w.j  av a  2 s.c o m
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            displayTimelines(includeNoDateSet.getValue(), includeClosedMilestone.getValue());
        }
    });
    includeClosedMilestone.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            displayTimelines(includeNoDateSet.getValue(), includeClosedMilestone.getValue());
        }
    });
    headerLayout.with(titleLbl, includeNoDateSet, includeClosedMilestone).expand(titleLbl)
            .withAlign(includeNoDateSet, Alignment.MIDDLE_RIGHT)
            .withAlign(includeClosedMilestone, Alignment.MIDDLE_RIGHT);

    MilestoneSearchCriteria searchCriteria = new MilestoneSearchCriteria();
    UserDashboardView userDashboardView = UIUtils.getRoot(this, UserDashboardView.class);
    searchCriteria.setProjectIds(new SetSearchField<>(userDashboardView.getInvolvedProjectKeys()));
    searchCriteria.setOrderFields(
            Collections.singletonList(new SearchCriteria.OrderField(Milestone.Field.enddate.name(), "ASC")));
    MilestoneService milestoneService = AppContextUtil.getSpringBean(MilestoneService.class);
    milestones = milestoneService
            .findPagableListByCriteria(new BasicSearchRequest<>(searchCriteria, 0, Integer.MAX_VALUE));

    this.addComponent(headerLayout);
    timelineContainer = new CssLayout();
    timelineContainer.setWidth("100%");
    this.addComponent(timelineContainer);
    timelineContainer.addStyleName("tm-wrapper");
    displayTimelines(false, false);
}

From source file:com.esofthead.mycollab.module.project.view.milestone.MilestoneTimelineWidget.java

License:Open Source License

public void display() {
    this.setWidth("100%");
    this.addStyleName("tm-container");

    MHorizontalLayout headerLayout = new MHorizontalLayout();
    ELabel titleLbl = ELabel.h2("Phase Timeline");

    final CheckBox noDateSetMilestone = new CheckBox("No date set");
    noDateSetMilestone.setValue(false);

    final CheckBox includeClosedMilestone = new CheckBox("Closed phase");
    includeClosedMilestone.setValue(false);

    noDateSetMilestone.addValueChangeListener(new Property.ValueChangeListener() {
        @Override//from w w  w .  j  a  v  a 2  s.  co m
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            displayTimelines(noDateSetMilestone.getValue(), includeClosedMilestone.getValue());
        }
    });
    includeClosedMilestone.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            displayTimelines(noDateSetMilestone.getValue(), includeClosedMilestone.getValue());
        }
    });
    headerLayout.with(titleLbl, noDateSetMilestone, includeClosedMilestone).expand(titleLbl)
            .withAlign(noDateSetMilestone, Alignment.MIDDLE_RIGHT)
            .withAlign(includeClosedMilestone, Alignment.MIDDLE_RIGHT);

    MilestoneSearchCriteria searchCriteria = new MilestoneSearchCriteria();
    searchCriteria.setProjectIds(new SetSearchField<>(CurrentProjectVariables.getProjectId()));
    searchCriteria.setOrderFields(
            Collections.singletonList(new SearchCriteria.OrderField(Milestone.Field.enddate.name(), "ASC")));
    MilestoneService milestoneService = AppContextUtil.getSpringBean(MilestoneService.class);
    milestones = milestoneService
            .findPagableListByCriteria(new BasicSearchRequest<>(searchCriteria, 0, Integer.MAX_VALUE));

    this.addComponent(headerLayout);
    timelineContainer = new CssLayout();
    timelineContainer.setWidth("100%");
    this.addComponent(timelineContainer);
    timelineContainer.addStyleName("tm-wrapper");
    displayTimelines(false, false);
}

From source file:com.esspl.datagen.ui.SelectableResultSetTable.java

License:Open Source License

protected Table createResultsTable(ResultSet rs, List<String> columns) throws SQLException {
    ResultSetMetaData md = rs.getMetaData();
    Container c = new IndexedContainer();
    c.addContainerProperty(" ", CheckBox.class, null);
    for (int i = 0; i < md.getColumnCount(); ++i) {
        String label = md.getColumnLabel(i + 1);
        if (null == columns || columns.contains(label)) {
            Class<?> clazz = getClassForSqlType(md.getColumnClassName(i + 1));
            c.addContainerProperty(label, clazz, null);
        }/*w w  w .j  a  v  a2 s . c  o  m*/
    }

    int i = 0;
    while (rs.next()) {
        Item item = c.addItem(i++);
        int j = 0;
        for (Object propertyId : c.getContainerPropertyIds()) {
            if (j == 0) {
                CheckBox cb = new CheckBox();
                cb.setValue(true);
                item.getItemProperty(propertyId).setValue(cb);
            } else {
                item.getItemProperty(propertyId).setValue(rs.getObject(propertyId.toString()));
            }
            j++;
        }
    }

    final Table t = new Table(null, c);
    t.setSizeFull();
    t.setPageLength(50);
    t.setColumnReorderingAllowed(true);
    t.setColumnCollapsingAllowed(true);
    t.setSelectable(true);
    t.setColumnIcon(" ", DataGenConstant.CHECK_ALL);
    t.addListener(new HeaderClickListener() {

        @SuppressWarnings("rawtypes")
        @Override
        public void headerClick(HeaderClickEvent event) {
            String column = (String) event.getPropertyId();
            if (column.equals(" ")) {
                log.debug("SelectableResultSetTable - createResultsTable() checkbox states-" + isChecked);
                isChecked = (isChecked) ? false : true;
                Iterator iter = t.getItemIds().iterator();
                while (iter.hasNext()) {
                    int row = (Integer) iter.next();
                    Item item = t.getItem(row);
                    CheckBox cbx = (CheckBox) (item.getItemProperty(" ").getValue());
                    cbx.setValue(isChecked);
                }
            }
        }
    });
    return t;
}

From source file:com.github.lsiu.MyVaadinApplication.java

private void initTopBar(HorizontalLayout topBar) {
    topBar.setWidth("100%");
    final CheckBox editableCheckBox = new CheckBox("Editable");
    topBar.addComponent(editableCheckBox);
    topBar.setComponentAlignment(editableCheckBox, Alignment.BOTTOM_RIGHT);
    editableCheckBox.setValue(table.isEditable());
    editableCheckBox.setImmediate(true);
    editableCheckBox.addListener(new ValueChangeListener() {
        @Override/*from w  w w.  j  av  a 2 s  .  c om*/
        public void valueChange(ValueChangeEvent event) {
            table.setEditable((Boolean) editableCheckBox.getValue());
        }
    });
}

From source file:com.klwork.explorer.ui.form.BooleanFormPropertyRenderer.java

License:Apache License

@Override
public Field getPropertyField(FormProperty formProperty) {

    CheckBox checkBox = new CheckBox(getPropertyLabel(formProperty));
    checkBox.setRequired(formProperty.isRequired());
    checkBox.setEnabled(formProperty.isWritable());

    if (formProperty.getValue() != null) {
        Boolean value = new Boolean(Boolean.parseBoolean(formProperty.getValue()));
        checkBox.setValue(value);
    }/*from w  ww .  j av  a  2s  .c  o m*/

    return checkBox;
}

From source file:com.mycollab.module.project.ui.components.ProjectSubscribersComp.java

License:Open Source License

@Override
protected Component initContent() {
    ProjectMemberService projectMemberService = AppContextUtil.getSpringBean(ProjectMemberService.class);
    List<SimpleUser> members = projectMemberService.getActiveUsersInProject(projectId,
            MyCollabUI.getAccountId());/*  w w w  .  j  a  v  a  2s  . c o m*/
    CssLayout container = new CssLayout();
    container.setStyleName("followers-container");
    final CheckBox selectAllCheckbox = new CheckBox("All", defaultSelectAll);
    selectAllCheckbox.addValueChangeListener(valueChangeEvent -> {
        boolean val = selectAllCheckbox.getValue();
        for (FollowerCheckbox followerCheckbox : memberSelections) {
            followerCheckbox.setValue(val);
        }
    });
    container.addComponent(selectAllCheckbox);
    for (SimpleUser user : members) {
        final FollowerCheckbox memberCheckbox = new FollowerCheckbox(user);
        memberCheckbox.addValueChangeListener(valueChangeEvent -> {
            if (!memberCheckbox.getValue()) {
                selectAllCheckbox.setValue(false);
            }
        });
        if (defaultSelectAll || selectedUsers.contains(user.getUsername())) {
            memberCheckbox.setValue(true);
        }
        memberSelections.add(memberCheckbox);
        container.addComponent(memberCheckbox);
    }
    return container;
}

From source file:com.mycollab.module.project.view.milestone.AllMilestoneTimelineWidget.java

License:Open Source License

public void display() {
    this.withMargin(new MarginInfo(false, false, true, false)).withStyleName("tm-container").withFullWidth();

    MHorizontalLayout headerLayout = new MHorizontalLayout()
            .withMargin(new MarginInfo(false, true, false, true)).withStyleName(WebThemes.PANEL_HEADER);
    headerLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    ELabel titleLbl = ELabel.h3(UserUIContext.getMessage(MilestoneI18nEnum.OPT_TIMELINE));

    final CheckBox includeNoDateSet = new CheckBox(UserUIContext.getMessage(DayI18nEnum.OPT_NO_DATE_SET));
    includeNoDateSet.setValue(false);

    final CheckBox includeClosedMilestone = new CheckBox(UserUIContext.getMessage(MilestoneStatus.Closed));
    includeClosedMilestone.setValue(false);

    includeNoDateSet.addValueChangeListener(valueChangeEvent -> displayTimelines(includeNoDateSet.getValue(),
            includeClosedMilestone.getValue()));
    includeClosedMilestone//  ww w  . j  ava2  s.c om
            .addValueChangeListener(valueChangeEvent -> displayTimelines(includeNoDateSet.getValue(),
                    includeClosedMilestone.getValue()));
    headerLayout.with(titleLbl, includeNoDateSet, includeClosedMilestone).expand(titleLbl)
            .withAlign(includeNoDateSet, Alignment.MIDDLE_RIGHT)
            .withAlign(includeClosedMilestone, Alignment.MIDDLE_RIGHT);

    MilestoneSearchCriteria searchCriteria = new MilestoneSearchCriteria();
    UserDashboardView userDashboardView = UIUtils.getRoot(this, UserDashboardView.class);
    searchCriteria.setProjectIds(new SetSearchField<>(userDashboardView.getInvolvedProjectKeys()));
    searchCriteria.setOrderFields(
            Collections.singletonList(new SearchCriteria.OrderField(Milestone.Field.enddate.name(), "ASC")));
    MilestoneService milestoneService = AppContextUtil.getSpringBean(MilestoneService.class);
    milestones = milestoneService.findPageableListByCriteria(new BasicSearchRequest<>(searchCriteria));

    this.addComponent(headerLayout);
    timelineContainer = new CssLayout();
    timelineContainer.setWidth("100%");
    this.addComponent(timelineContainer);
    timelineContainer.addStyleName("tm-wrapper");
    displayTimelines(false, false);
}