Java Code Examples for com.vaadin.ui.CheckBox#setValue()

The following examples show how to use com.vaadin.ui.CheckBox#setValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MilestoneTimelineWidget.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
public void display() {
    final CheckBox noDateSetMilestone = new CheckBox(UserUIContext.getMessage(DayI18nEnum.OPT_NO_DATE_SET));
    noDateSetMilestone.setValue(false);

    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()));

    addHeaderElement(noDateSetMilestone);
    addHeaderElement(includeClosedMilestone);

    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 = (List<SimpleMilestone>) milestoneService.findPageableListByCriteria(new BasicSearchRequest<>(searchCriteria));

    bodyContent.addStyleName("tm-wrapper");
    displayTimelines(false, false);
}
 
Example 2
Source File: AllMilestoneTimelineWidget.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
public void display(List<Integer> projectIds) {
    CheckBox includeNoDateSet = new CheckBox(UserUIContext.getMessage(DayI18nEnum.OPT_NO_DATE_SET));
    includeNoDateSet.setValue(false);

    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()));

    addHeaderElement(includeNoDateSet);
    addHeaderElement(includeClosedMilestone);

    MilestoneSearchCriteria searchCriteria = new MilestoneSearchCriteria();
    searchCriteria.setProjectIds(new SetSearchField<>(projectIds));
    searchCriteria.setOrderFields(Collections.singletonList(new SearchCriteria.OrderField(Milestone.Field.enddate.name(), "ASC")));
    MilestoneService milestoneService = AppContextUtil.getSpringBean(MilestoneService.class);
    milestones = (List<SimpleMilestone>) milestoneService.findPageableListByCriteria(new BasicSearchRequest<>(searchCriteria));

    bodyContent.addStyleName("tm-wrapper");
    displayTimelines(false, false);
}
 
Example 3
Source File: WinServerAttachService.java    From primecloud-controller with GNU General Public License v2.0 4 votes vote down vote up
public void show(List<ComponentDto> components) {
    this.components = components;

    removeAllItems();

    if (components == null) {
        return;
    }

    for (ComponentDto component : components) {
        // チェックボックス
        CheckBox checkBox = new CheckBox();
        checkBox.setImmediate(true);
        checkBox.setEnabled(false);
        if (selectedComponentNos.contains(component.getComponent().getComponentNo())) {
            checkBox.setValue(true);
        } else {
            checkBox.setValue(false);
        }

        checkBox.addListener(new Property.ValueChangeListener() {
            @Override
            public void valueChange(Property.ValueChangeEvent event) {
                // チェックボックスの有効/無効を制御
                changeCheckEnabled();

                // テーブル再描画
                requestRepaint();
            }
        });

        // サービス名
        String serviceName = component.getComponent().getComponentName();
        if (StringUtils.isNotEmpty(component.getComponent().getComment())) {
            serviceName = component.getComponent().getComment() + "\n[" + serviceName + "]";
        }
        Label serviceNameLabel = new Label(serviceName, Label.CONTENT_PREFORMATTED);
        serviceNameLabel.setHeight(COLUMN_HEIGHT);

        // ステータス
        String status = null;
        if (instance != null) {
            for (ComponentInstanceDto componentInstance : instance.getComponentInstances()) {
                if (componentInstance.getComponentInstance().getComponentNo()
                        .equals(component.getComponent().getComponentNo())) {
                    status = componentInstance.getComponentInstance().getStatus();
                    break;
                }
            }
        }
        if (StringUtils.isEmpty(status)) {
            status = "Stopped";
        } else {
            status = StringUtils.capitalize(StringUtils.lowerCase(status));
        }

        Icons statusIcon = Icons.fromName(status);
        Label statusLabel = new Label(IconUtils.createImageTag(getApplication(), statusIcon, status),
                Label.CONTENT_XHTML);
        statusLabel.setHeight(COLUMN_HEIGHT);

        addItem(new Object[] { checkBox, serviceNameLabel, statusLabel },
                component.getComponent().getComponentNo());
    }

    changeCheckEnabled();
}
 
Example 4
Source File: SignInViewImpl.java    From Vaadin4Spring-MVP-Sample-SpringSecurity with Apache License 2.0 4 votes vote down vote up
@Override
public void postConstruct() {	
	super.postConstruct();		
	setSizeFull();
	layout = new VerticalLayout();
	layout.setSizeFull();
	layout.setSpacing(true);
	setCompositionRoot(layout);
	
	caption = new Label("Sign in to Vaadin4Spring Security Demo");
	caption.addStyleName(ValoTheme.LABEL_H2);
	caption.setSizeUndefined();		
	layout.addComponent(caption);
	layout.setComponentAlignment(caption, Alignment.MIDDLE_CENTER);
	
	loginPanel = new VerticalLayout();
	loginPanel.setSizeUndefined();
	loginPanel.setSpacing(true);
	loginPanel.setMargin(true);
	layout.addComponent(loginPanel);
	layout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
	layout.setExpandRatio(loginPanel, 1);
	
	errorMessage = new Label();
	errorMessage.setWidth("300px");
	errorMessage.addStyleName(ValoTheme.LABEL_FAILURE);		
	errorMessage.setVisible(false);
	loginPanel.addComponent(errorMessage);
	
	username = new TextField("Username");
	username.setImmediate(true);
	username.setWidth("300px");
	username.setNullRepresentation("");
	username.setInputPrompt("Enter your username");
	loginPanel.addComponent(username);
	
	password = new PasswordField("Password");
	password.setImmediate(true);
	password.setWidth("300px");
	password.setNullRepresentation("");
	loginPanel.addComponent(password);
	
	rememberMe = new CheckBox("Remember me");
	rememberMe.setValue(false);
	rememberMe.addStyleName(ValoTheme.CHECKBOX_LARGE);
	loginPanel.addComponent(rememberMe);
	
	btnLogin = new Button("Signin", FontAwesome.UNLOCK);
	btnLogin.addStyleName(ValoTheme.BUTTON_PRIMARY);
	btnLogin.addClickListener(this);
	btnLogin.setWidth("100%");
	loginPanel.addComponent(btnLogin);							
	
	final Label infoLabel = new Label(FontAwesome.INFO_CIRCLE.getHtml() + " You can sign in as: <br/>\"user\" with password \"user\" <br/>\"admin\" with password \"admin\".", ContentMode.HTML);
	infoLabel.setWidth("300px");
	loginPanel.addComponent(infoLabel);
}
 
Example 5
Source File: ToggleMilestoneSummaryField.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
ToggleMilestoneSummaryField(final SimpleMilestone milestone, int maxLength, boolean toggleStatusSupport, boolean isDeleteSupport) {
    this.milestone = milestone;
    this.maxLength = maxLength;
    this.setWidth("100%");
    this.addStyleName("editable-field");
    if (toggleStatusSupport && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MILESTONES)) {
        toggleStatusSelect = new CheckBox();
        toggleStatusSelect.setValue(milestone.isCompleted());
        this.addComponent(toggleStatusSelect);
        this.addComponent(ELabel.EMPTY_SPACE());
        displayTooltip();

        toggleStatusSelect.addValueChangeListener(valueChangeEvent -> {
            if (milestone.isCompleted()) {
                milestone.setStatus(MilestoneStatus.InProgress.name());
                titleLinkLbl.removeStyleName(WebThemes.LINK_COMPLETED);
            } else {
                milestone.setStatus(MilestoneStatus.Closed.name());
                titleLinkLbl.addStyleName(WebThemes.LINK_COMPLETED);
            }
            displayTooltip();
            MilestoneService milestoneService = AppContextUtil.getSpringBean(MilestoneService.class);
            milestoneService.updateSelectiveWithSession(milestone, UserUIContext.getUsername());
            ProjectTicketSearchCriteria searchCriteria = new ProjectTicketSearchCriteria();
            searchCriteria.setProjectIds(new SetSearchField<>(CurrentProjectVariables.getProjectId()));
            searchCriteria.setTypes(new SetSearchField<>(ProjectTypeConstants.BUG, ProjectTypeConstants.RISK,
                    ProjectTypeConstants.TASK));
            searchCriteria.setMilestoneId(NumberSearchField.equal(milestone.getId()));
            searchCriteria.setOpen(new SearchField());
            ProjectTicketService genericTaskService = AppContextUtil.getSpringBean(ProjectTicketService.class);
            int openAssignmentsCount = genericTaskService.getTotalCount(searchCriteria);
            if (openAssignmentsCount > 0) {
                ConfirmDialogExt.show(UI.getCurrent(),
                        UserUIContext.getMessage(GenericI18Enum.OPT_QUESTION, AppUI.getSiteName()),
                        UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_CLOSE_SUB_ASSIGNMENTS),
                        UserUIContext.getMessage(GenericI18Enum.ACTION_YES),
                        UserUIContext.getMessage(GenericI18Enum.ACTION_NO),
                        confirmDialog -> {
                            if (confirmDialog.isConfirmed()) {
                                genericTaskService.closeSubAssignmentOfMilestone(milestone.getId());
                            }
                        });
            }
        });
    }

    titleLinkLbl = ELabel.h3(buildMilestoneLink()).withStyleName(WebThemes.LABEL_WORD_WRAP).withUndefinedWidth();
    this.addComponent(titleLinkLbl);
    buttonControls = new MHorizontalLayout().withMargin(new MarginInfo(false, false, false, true)).withStyleName("toggle");
    if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MILESTONES)) {
        MButton instantEditBtn = new MButton("", clickEvent -> {
            if (isRead) {
                ToggleMilestoneSummaryField.this.removeComponent(titleLinkLbl);
                ToggleMilestoneSummaryField.this.removeComponent(buttonControls);
                final MTextField editField = new MTextField(milestone.getName()).withFullWidth();
                editField.focus();
                ToggleMilestoneSummaryField.this.addComponent(editField);
                ToggleMilestoneSummaryField.this.removeStyleName("editable-field");
                editField.addShortcutListener(new ShortcutListener("enter", ShortcutAction.KeyCode.ENTER, (int[]) null) {
                    @Override
                    public void handleAction(Object sender, Object target) {
                        updateFieldValue(editField);
                    }
                });
                editField.addBlurListener(blurEvent -> updateFieldValue(editField));
                isRead = !isRead;
            }
        }).withDescription(UserUIContext.getMessage(MilestoneI18nEnum.OPT_EDIT_PHASE_NAME))
                .withIcon(VaadinIcons.EDIT).withStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP);
        buttonControls.with(instantEditBtn);
    }
    if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.MILESTONES)) {
        MButton removeBtn = new MButton("", clickEvent -> {
            ConfirmDialogExt.show(UI.getCurrent(),
                    UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, AppUI.getSiteName()),
                    UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                    UserUIContext.getMessage(GenericI18Enum.ACTION_YES),
                    UserUIContext.getMessage(GenericI18Enum.ACTION_NO),
                    confirmDialog -> {
                        if (confirmDialog.isConfirmed()) {
                            AppContextUtil.getSpringBean(MilestoneService.class).removeWithSession(milestone,
                                    UserUIContext.getUsername(), AppUI.getAccountId());
                            TicketRowRender rowRenderer = UIUtils.getRoot(ToggleMilestoneSummaryField.this, TicketRowRender.class);
                            if (rowRenderer != null) {
                                rowRenderer.selfRemoved();
                            }
                            EventBusFactory.getInstance().post(new MilestoneEvent.MilestoneDeleted(this, milestone.getId()));
                        }
                    });
        }).withIcon(VaadinIcons.TRASH).withStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP);
        buttonControls.with(removeBtn);
    }
    if (buttonControls.getComponentCount() > 0) {
        this.addComponent(buttonControls);
    }
}
 
Example 6
Source File: ToggleTaskSummaryField.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
public ToggleTaskSummaryField(SimpleTask task, int maxLength, boolean toggleStatusSupport, boolean canRemove) {
    this.setWidth("100%");
    this.maxLength = maxLength;
    this.task = task;
    titleLinkLbl = ELabel.html(buildTaskLink()).withUndefinedWidth().withStyleName(WebThemes.LABEL_WORD_WRAP);

    if (toggleStatusSupport && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) {
        toggleStatusSelect = new CheckBox();
        toggleStatusSelect.setValue(task.isCompleted());
        displayTooltip();
        toggleStatusSelect.addValueChangeListener(valueChangeEvent -> {
            if (task.isCompleted()) {
                task.setStatus(StatusI18nEnum.Open.name());
                task.setPercentagecomplete(0d);
                titleLinkLbl.removeStyleName(WebThemes.LINK_COMPLETED);
            } else {
                task.setStatus(StatusI18nEnum.Closed.name());
                task.setPercentagecomplete(100d);
                titleLinkLbl.addStyleName(WebThemes.LINK_COMPLETED);
            }
            displayTooltip();
            TaskService taskService = AppContextUtil.getSpringBean(TaskService.class);
            taskService.updateWithSession(task, UserUIContext.getUsername());

            if (StatusI18nEnum.Closed.name().equals(task.getStatus())) {
                Integer countOfOpenSubTasks = taskService.getCountOfOpenSubTasks(task.getId());
                if (countOfOpenSubTasks > 0) {
                    ConfirmDialogExt.show(UI.getCurrent(),
                            UserUIContext.getMessage(GenericI18Enum.OPT_QUESTION, AppUI.getSiteName()),
                            UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_CLOSE_SUB_ASSIGNMENTS),
                            UserUIContext.getMessage(GenericI18Enum.ACTION_YES),
                            UserUIContext.getMessage(GenericI18Enum.ACTION_NO),
                            confirmDialog -> {
                                if (confirmDialog.isConfirmed()) {
                                    taskService.massUpdateTaskStatuses(task.getId(), StatusI18nEnum.Closed.name(),
                                            AppUI.getAccountId());
                                }
                            });
                }
            }
        });
        this.withComponents(toggleStatusSelect, ELabel.EMPTY_SPACE());
    }

    this.addComponent(titleLinkLbl);
    buttonControls = new MHorizontalLayout().withMargin(new MarginInfo(false, false, false, true)).withStyleName("toggle");
    if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) {
        this.addStyleName("editable-field");

        MButton instantEditBtn = new MButton("", clickEvent -> {
            if (isRead) {
                ToggleTaskSummaryField.this.removeComponent(titleLinkLbl);
                ToggleTaskSummaryField.this.removeComponent(buttonControls);
                final TextField editField = new TextField();
                editField.setValue(task.getName());
                editField.setWidth("100%");
                editField.focus();
                ToggleTaskSummaryField.this.addComponent(editField);
                ToggleTaskSummaryField.this.removeStyleName("editable-field");
                editField.addShortcutListener(new ShortcutListener("enter", ShortcutAction.KeyCode.ENTER, (int[]) null) {
                    @Override
                    public void handleAction(Object sender, Object target) {
                        updateFieldValue(editField);
                    }
                });
                editField.addBlurListener(blurEvent -> updateFieldValue(editField));
                isRead = !isRead;
            }
        }).withIcon(VaadinIcons.EDIT).withStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP);
        instantEditBtn.setDescription(UserUIContext.getMessage(TaskI18nEnum.OPT_EDIT_TASK_NAME));
        buttonControls.with(instantEditBtn);
    }

    if (canRemove && CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.TASKS)) {
        MButton removeBtn = new MButton("", clickEvent -> {
            ConfirmDialogExt.show(UI.getCurrent(),
                    UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, AppUI.getSiteName()),
                    UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                    UserUIContext.getMessage(GenericI18Enum.ACTION_YES),
                    UserUIContext.getMessage(GenericI18Enum.ACTION_NO),
                    confirmDialog -> {
                        if (confirmDialog.isConfirmed()) {
                            AppContextUtil.getSpringBean(TaskService.class).removeWithSession(task,
                                    UserUIContext.getUsername(), AppUI.getAccountId());
                            TicketRowRender rowRenderer = UIUtils.getRoot(ToggleTaskSummaryField.this, TicketRowRender.class);
                            if (rowRenderer != null) {
                                rowRenderer.selfRemoved();
                            }
                            EventBusFactory.getInstance().post(new TaskEvent.TaskDeleted(this, task.getId()));
                        }
                    });
        }).withIcon(VaadinIcons.TRASH).withStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP);
        buttonControls.with(removeBtn);
    }
    if (buttonControls.getComponentCount() > 0) {
        this.addComponent(buttonControls);
    }
}