Example usage for com.vaadin.ui CheckBox getValue

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

Introduction

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

Prototype

@Override
    public Boolean getValue() 

Source Link

Usage

From source file:com.mycollab.module.crm.view.lead.LeadConvertInfoWindow.java

License:Open Source License

private ComponentContainer createBody() {
    final CssLayout layout = new CssLayout();
    layout.setSizeFull();/*  w  ww.j av  a  2s .  c  o  m*/

    Label shortDescription = ELabel.html(
            "<p>&nbsp;&nbsp;&nbsp;By clicking the \"Convert\" button, the following tasks will be done:</p>");
    layout.addComponent(shortDescription);

    MVerticalLayout infoLayout = new MVerticalLayout().withMargin(new MarginInfo(false, true, true, true));

    String createAccountTxt = FontAwesome.CHECK.getHtml() + " Create Account: " + lead.getAccountname();
    Label createAccountLbl = new Label(createAccountTxt, ContentMode.HTML);
    infoLayout.addComponent(createAccountLbl);

    String createContactTxt = FontAwesome.CHECK.getHtml() + " Create Contact: " + lead.getLastname()
            + (lead.getFirstname() != null ? " " + lead.getFirstname() : "");
    Label createContactLbl = new Label(createContactTxt, ContentMode.HTML);
    infoLayout.addComponent(createContactLbl);

    final CheckBox isCreateOpportunityChk = new CheckBox("Create a new opportunity for this account");
    isCreateOpportunityChk.addValueChangeListener(valueChangeEvent -> {
        Boolean isSelected = isCreateOpportunityChk.getValue();
        if (isSelected) {
            opportunityForm = new LeadOpportunityForm();
            Opportunity opportunity = new Opportunity();

            // this is a trick to pass validation
            opportunity.setAccountid(0);
            opportunityForm.setBean(opportunity);
            layout.addComponent(opportunityForm);
        } else {
            layout.removeComponent(opportunityForm);
        }
    });

    infoLayout.addComponent(isCreateOpportunityChk);
    layout.addComponent(infoLayout);
    return layout;
}

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  . jav a  2s. c  om
    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.kanban.AddNewColumnWindow.java

License:Open Source License

public AddNewColumnWindow(final IKanbanView kanbanView, final String type, final String fieldGroup) {
    super(UserUIContext.getMessage(TaskI18nEnum.ACTION_NEW_COLUMN));
    this.withModal(true).withResizable(false).withWidth("800px").withCenter();
    MVerticalLayout layout = new MVerticalLayout().withMargin(new MarginInfo(false, false, true, false));
    GridFormLayoutHelper gridFormLayoutHelper = GridFormLayoutHelper.defaultFormLayoutHelper(1, 4);
    this.setContent(layout);

    final TextField stageField = new TextField();
    final CheckBox defaultProject = new CheckBox();
    defaultProject.setVisible(UserUIContext.canBeYes(RolePermissionCollections.GLOBAL_PROJECT_SETTINGS));
    final ColorPicker colorPicker = new ColorPicker("", new com.vaadin.shared.ui.colorpicker.Color(
            DEFAULT_COLOR.getRed(), DEFAULT_COLOR.getGreen(), DEFAULT_COLOR.getBlue()));
    final TextArea description = new TextArea();

    gridFormLayoutHelper.addComponent(stageField, UserUIContext.getMessage(GenericI18Enum.FORM_NAME), 0, 0);
    gridFormLayoutHelper.addComponent(defaultProject,
            UserUIContext.getMessage(TaskI18nEnum.FORM_COLUMN_DEFAULT_FOR_NEW_PROJECT), 0, 1);
    gridFormLayoutHelper.addComponent(colorPicker, UserUIContext.getMessage(TaskI18nEnum.FORM_COLUMN_COLOR), 0,
            2);// w ww .j  a  va  2  s  . com
    gridFormLayoutHelper.addComponent(description, UserUIContext.getMessage(GenericI18Enum.FORM_DESCRIPTION), 0,
            3);

    MButton saveBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SAVE), clickEvent -> {
        OptionVal optionVal = new OptionVal();
        optionVal.setCreatedtime(new GregorianCalendar().getTime());
        optionVal.setCreateduser(UserUIContext.getUsername());
        optionVal.setDescription(description.getValue());
        com.vaadin.shared.ui.colorpicker.Color color = colorPicker.getColor();
        String cssColor = color.getCSS();
        if (cssColor.startsWith("#")) {
            cssColor = cssColor.substring(1);
        }
        optionVal.setColor(cssColor);
        if (defaultProject.getValue()) {
            optionVal.setIsdefault(true);
        } else {
            optionVal.setIsdefault(false);
            optionVal.setExtraid(CurrentProjectVariables.getProjectId());
        }
        optionVal.setSaccountid(MyCollabUI.getAccountId());
        optionVal.setType(type);
        optionVal.setTypeval(stageField.getValue());
        optionVal.setFieldgroup(fieldGroup);
        OptionValService optionService = AppContextUtil.getSpringBean(OptionValService.class);
        int optionValId = optionService.saveWithSession(optionVal, UserUIContext.getUsername());

        if (optionVal.getIsdefault()) {
            optionVal.setId(null);
            optionVal.setIsdefault(false);
            optionVal.setRefoption(optionValId);
            optionVal.setExtraid(CurrentProjectVariables.getProjectId());
            optionService.saveWithSession(optionVal, UserUIContext.getUsername());
        }
        kanbanView.addColumn(optionVal);
        close();
    }).withIcon(FontAwesome.SAVE).withStyleName(WebThemes.BUTTON_ACTION);

    MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            clickEvent -> close()).withStyleName(WebThemes.BUTTON_OPTION);

    MHorizontalLayout controls = new MHorizontalLayout().with(cancelBtn, saveBtn)
            .withMargin(new MarginInfo(false, true, false, false));
    layout.with(gridFormLayoutHelper.getLayout(), controls).withAlign(controls, Alignment.BOTTOM_RIGHT);
}

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);//  w  w  w.  j  a v  a  2  s  .c  o  m

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

    includeNoDateSet.addValueChangeListener(valueChangeEvent -> displayTimelines(includeNoDateSet.getValue(),
            includeClosedMilestone.getValue()));
    includeClosedMilestone
            .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);
}

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

License:Open Source License

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

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

    final CheckBox noDateSetMilestone = new CheckBox(UserUIContext.getMessage(DayI18nEnum.OPT_NO_DATE_SET));
    noDateSetMilestone.setValue(false);/*from   ww  w .  j  a  va 2s. c om*/

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

    noDateSetMilestone
            .addValueChangeListener(valueChangeEvent -> displayTimelines(noDateSetMilestone.getValue(),
                    includeClosedMilestone.getValue()));
    includeClosedMilestone
            .addValueChangeListener(valueChangeEvent -> 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.findPageableListByCriteria(new BasicSearchRequest<>(searchCriteria));

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

From source file:com.mycollab.module.project.view.ticket.TicketOverdueWidget.java

License:Open Source License

public TicketOverdueWidget() {
    super(UserUIContext.getMessage(TicketI18nEnum.VAL_OVERDUE_TICKETS) + " (0)", new CssLayout());

    final CheckBox myItemsOnly = new CheckBox(UserUIContext.getMessage(GenericI18Enum.OPT_MY_ITEMS));
    myItemsOnly.addValueChangeListener(valueChangeEvent -> {
        if (searchCriteria != null) {
            boolean selectMyItemsOnly = myItemsOnly.getValue();
            if (selectMyItemsOnly) {
                searchCriteria.setAssignUser(StringSearchField.and(UserUIContext.getUsername()));
            } else {
                searchCriteria.setAssignUser(null);
            }/*from  w  w  w.  j ava 2 s .c o  m*/
            ticketOverdueComponent.setSearchCriteria(searchCriteria);
        }
    });

    this.addHeaderElement(myItemsOnly);

    ticketOverdueComponent = new TicketOverduePagedList();
    bodyContent.addComponent(ticketOverdueComponent);
}

From source file:com.mycollab.module.project.view.user.ProjectOverdueTicketsWidget.java

License:Open Source License

public ProjectOverdueTicketsWidget() {
    super(String.format("%s (0)", UserUIContext.getMessage(TicketI18nEnum.VAL_OVERDUE_TICKETS)),
            new CssLayout());
    this.setWidth("100%");

    final CheckBox myItemsSelection = new CheckBox(UserUIContext.getMessage(GenericI18Enum.OPT_MY_ITEMS));
    myItemsSelection.addValueChangeListener(valueChangeEvent -> {
        boolean isMyItemsOption = myItemsSelection.getValue();
        if (isMyItemsOption) {
            searchCriteria.setAssignUser(StringSearchField.and(UserUIContext.getUsername()));
        } else {//from ww w. j av a 2  s.  com
            searchCriteria.setAssignUser(null);
        }
        updateSearchResult();
    });

    ticketList = new DefaultBeanPagedList(AppContextUtil.getSpringBean(ProjectTicketService.class),
            new TicketRowDisplayHandler(), 10) {
        @Override
        protected String stringWhenEmptyList() {
            return UserUIContext.getMessage(ProjectI18nEnum.OPT_NO_OVERDUE_TICKET);
        }
    };
    this.addHeaderElement(myItemsSelection);
    bodyContent.addComponent(ticketList);
}

From source file:com.mycollab.module.project.view.user.ProjectUnresolvedTicketsWidget.java

License:Open Source License

public ProjectUnresolvedTicketsWidget() {
    super("", new CssLayout());
    this.setWidth("100%");
    final CheckBox myItemsSelection = new CheckBox(UserUIContext.getMessage(GenericI18Enum.OPT_MY_ITEMS));
    myItemsSelection.addValueChangeListener(valueChangeEvent -> {
        boolean isMyItemsOption = myItemsSelection.getValue();
        if (isMyItemsOption) {
            searchCriteria.setAssignUser(StringSearchField.and(UserUIContext.getUsername()));
        } else {// w  w  w.  ja  v a 2 s.co  m
            searchCriteria.setAssignUser(null);
        }
        updateSearchResult();
    });
    taskList = new DefaultBeanPagedList(AppContextUtil.getSpringBean(ProjectTicketService.class),
            new TicketRowDisplayHandler(), 10) {
        @Override
        protected String stringWhenEmptyList() {
            return UserUIContext.getMessage(ProjectI18nEnum.OPT_NO_TICKET);
        }
    };
    addHeaderElement(myItemsSelection);
    bodyContent.addComponent(taskList);
}

From source file:com.mycollab.module.project.view.user.TaskStatusComponent.java

License:Open Source License

public TaskStatusComponent() {
    super(AppContext.getMessage(ProjectCommonI18nEnum.WIDGET_OVERDUE_ASSIGNMENTS_TITLE, 0), new CssLayout());

    final CheckBox myItemsOnly = new CheckBox(AppContext.getMessage(GenericI18Enum.OPT_MY_ITEMS));
    myItemsOnly.addValueChangeListener(new Property.ValueChangeListener() {
        @Override/*from w  w  w  . ja  va 2  s.c o m*/
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            if (searchCriteria != null) {
                boolean selectMyItemsOnly = myItemsOnly.getValue();
                if (selectMyItemsOnly) {
                    searchCriteria.setAssignUser(StringSearchField.and(AppContext.getUsername()));
                } else {
                    searchCriteria.setAssignUser(null);
                }
                taskComponents.setSearchCriteria(searchCriteria);
            }
        }
    });

    this.addHeaderElement(myItemsOnly);

    taskComponents = new TaskStatusPagedList();
    bodyContent.addComponent(taskComponents);
}

From source file:com.mycollab.module.project.view.user.UserUnresolvedAssignmentWidget.java

License:Open Source License

public UserUnresolvedAssignmentWidget() {
    super("", new CssLayout());
    this.setWidth("100%");
    final CheckBox myItemsSelection = new CheckBox(UserUIContext.getMessage(GenericI18Enum.OPT_MY_ITEMS));
    myItemsSelection.addValueChangeListener(valueChangeEvent -> {
        boolean isMyItemsOption = myItemsSelection.getValue();
        if (searchCriteria != null) {
            if (isMyItemsOption) {
                searchCriteria.setAssignUser(StringSearchField.and(UserUIContext.getUsername()));
            } else {
                searchCriteria.setAssignUser(null);
            }/* w  w  w . j a va  2 s.  c om*/
            updateSearchResult();
        }
    });
    taskList = new DefaultBeanPagedList<ProjectTicketService, ProjectTicketSearchCriteria, ProjectTicket>(
            AppContextUtil.getSpringBean(ProjectTicketService.class), new TicketRowDisplayHandler(), 10) {
        @Override
        protected String stringWhenEmptyList() {
            return UserUIContext.getMessage(ProjectI18nEnum.OPT_NO_TICKET);
        }
    };
    this.addHeaderElement(myItemsSelection);
    this.bodyContent.addComponent(taskList);
}