Example usage for com.google.gwt.user.client.ui CheckBox getValue

List of usage examples for com.google.gwt.user.client.ui CheckBox getValue

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui CheckBox getValue.

Prototype

@Override
public Boolean getValue() 

Source Link

Document

Determines whether this check box is currently checked.

Usage

From source file:net.scran24.user.client.surveyscheme.MultipleChoiceCheckboxQuestion.java

@Override
public SimpleSurveyStageInterface getInterface(final Callback1<Survey> onComplete,
        Callback2<Survey, Boolean> onIntermediateStateChange) {
    final FlowPanel content = new FlowPanel();
    content.addStyleName("intake24-multiple-choice-question");
    content.addStyleName("intake24-survey-content-container");

    content.add(WidgetFactory.createPromptPanel(questionText));

    FlowPanel checkboxesDiv = new FlowPanel();
    checkboxesDiv.addStyleName("scran24-ready-meals-checkboxes-block");

    final ArrayList<CheckBox> checkBoxes = new ArrayList<CheckBox>();

    for (String option : options) {
        FlowPanel rowDiv = new FlowPanel();
        CheckBox checkBox = new CheckBox(SafeHtmlUtils.htmlEscape(option));
        checkBox.setFormValue(option);/*  w  w w.ja  va 2s.  com*/
        checkBox.addStyleName("scran24-ready-meals-checkbox");
        checkBoxes.add(checkBox);
        rowDiv.add(checkBox);
        checkboxesDiv.add(rowDiv);
    }

    if (!otherOptionName.isEmpty()) {
        FlowPanel otherPanel = new FlowPanel();
        otherOption = new CheckBox(otherOptionName.getOrDie() + ": ");
        otherPanel.add(otherOption);
        otherBox = new TextBox();
        otherPanel.add(otherBox);
        checkboxesDiv.add(otherPanel);

        otherBox.addFocusHandler(new FocusHandler() {
            @Override
            public void onFocus(FocusEvent event) {
                otherOption.setValue(true);
            }
        });
    }

    content.add(checkboxesDiv);

    Button accept = WidgetFactory.createGreenButton(acceptText, new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {

            StringBuilder value = new StringBuilder();
            boolean first = true;

            for (CheckBox checkBox : checkBoxes)
                if (checkBox.getValue()) {
                    if (first)
                        first = false;
                    else
                        value.append(", ");

                    value.append(checkBox.getFormValue());
                }

            if (!otherOptionName.isEmpty()) {
                if (otherOption.getValue()) {
                    if (!first)
                        value.append(", ");
                    value.append(otherBox.getText());
                }
            }

            onComplete.call(state.withData(dataField, value.toString()));
        }
    });

    content.add(checkboxesDiv);
    content.add(accept);

    return new SimpleSurveyStageInterface(content);
}

From source file:next.i.view.widgets.XCheckboxGroup.java

License:Apache License

@Override
public void onClick(ClickEvent e) {
    final EventTarget target = e.getNativeEvent().getEventTarget();
    String targetTagName = ((Element) target.cast()).getTagName().toUpperCase();
    //XLog.warn("onClick target=" + target + " targetTagName=" + targetTagName);
    if (targetTagName.equals("LABEL")) {
        return; // if check box label is click, another (simulated) click event
        // with/* w w w  .ja v  a  2 s .  c  o  m*/
        // check box INPUT as target will fire after this one. So this click event
        // can be safely ignored.
    }
    Element div = Element.as(target);
    while (!div.getNodeName().toUpperCase().equals("SPAN") || div.getParentElement() != this.getElement()) {
        div = div.getParentElement();
        if (div == null) {
            // XLog.info("XCheckboxGroup onClick: span not found");
            return;
        }
    }
    final int index = DOM.getChildIndex(this.getElement(), (com.google.gwt.user.client.Element) div);
    CheckBox checkbox = (CheckBox) _panel.getWidget(index);
    // XLog.info("onClick " + checkbox.getValue());
    if (targetTagName.equals("INPUT")) {
        // XLog.info("onClick value changed");
        checkbox.setValue(checkbox.getValue()); // if target is check box INPUT,
        // check box value is
        // already changed when click event is fired.
        // just need to set its current value back to the check box
        // to update style.
    } else {
        checkbox.setValue(!checkbox.getValue());
    }

    Scheduler.get().scheduleDeferred(new ScheduledCommand() {
        @Override
        public void execute() {
            SelectionChangedEvent selectionChangedEvent = new SelectionChangedEvent(index, target);
            fireEvent(selectionChangedEvent);
        }
    });
}

From source file:nl.ru.languageininteraction.synaesthesia.client.presenter.RegisterPresenter.java

License:Open Source License

@Override
protected void setContent(final AppEventListner appEventListner) {
    ((RegisterView) simpleView).addText(messages.registerScreenText());
    for (MetadataField metadataField : metadataFieldProvider.metadataFieldArray) {
        ((RegisterView) simpleView).addField(metadataField.getFieldLabel(),
                userResults.getMetadataValue(metadataField.getPostName()));
    }/* ww  w.  j  a  v  a2 s. com*/
    ((RegisterView) simpleView).addOptionButton(new PresenterEventListner() {

        @Override
        public String getLabel() {
            return messages.editMetadataLabel();
        }

        @Override
        public void eventFired(Button button) {
            appEventListner.requestApplicationState(AppEventListner.ApplicationState.metadata);
        }
    });

    ((RegisterView) simpleView).addOptionButton(new PresenterEventListner() {

        @Override
        public String getLabel() {
            return messages.informationSheetLink();
        }

        @Override
        public void eventFired(Button button) {
            appEventListner.requestApplicationState(AppEventListner.ApplicationState.moreinfo);
        }
    });
    ((RegisterView) simpleView).addText(messages.informationSheetCheckBox());
    final CheckBox agreementCheckBox = ((RegisterView) simpleView).addCheckBox("");
    final Button registerButton = addRegisterButton(appEventListner);
    agreementCheckBox.setValue(false);
    registerButton.setEnabled(false);
    agreementCheckBox.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            //                event.preventDefault();
            //                event.stopPropagation();
            // on chrome the check box is changed before this code is reached
            //                agreementCheckBox.setValue(!registerButton.isEnabled());
            registerButton.setEnabled(agreementCheckBox.getValue());
        }
    });
    agreementCheckBox.addTouchEndHandler(new TouchEndHandler() {

        @Override
        public void onTouchEnd(TouchEndEvent event) {
            event.preventDefault();
            agreementCheckBox.setValue(!agreementCheckBox.getValue());
            registerButton.setEnabled(agreementCheckBox.getValue());
        }
    });
}

From source file:org.activityinfo.ui.client.component.form.field.CheckBoxFieldWidget.java

License:Open Source License

private ReferenceValue updatedValue() {
    final Set<ResourceId> value = Sets.newHashSet();
    for (CheckBox control : controls) {
        if (control.getValue()) {
            value.add(ResourceId.valueOf(control.getFormValue()));
        }//from w  ww . ja  v  a  2 s  . c o m
    }
    return new ReferenceValue(value);
}

From source file:org.artificer.ui.client.local.pages.ArtifactsPage.java

License:Apache License

/**
 * Updates the table of artifacts with the given data.
 * @param data//from   w  w  w  . j a v a 2 s .com
 */
protected void updateArtifactTable(ArtifactResultSetBean data) {
    this.artifactsTable.clear();
    this.searchInProgressMessage.setVisible(false);
    if (data.getArtifacts().size() > 0) {
        for (final ArtifactSummaryBean artifactSummaryBean : data.getArtifacts()) {
            // If in "new relationship" mode, add checkboxes to the last column.  Maintain the target list
            // based on the clicks.
            if (stateService.inNewRelationshipMode()) {
                final CheckBox checkbox = new CheckBox();
                boolean checked = addRelationshipTargets.contains(artifactSummaryBean.getUuid());
                checkbox.setValue(checked);

                checkbox.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        boolean checked = checkbox.getValue();
                        if (checked) {
                            addRelationshipTargets.add(artifactSummaryBean.getUuid());
                        } else {
                            addRelationshipTargets.remove(artifactSummaryBean.getUuid());
                        }
                    }
                });

                this.artifactsTable.addRow(artifactSummaryBean, checkbox);
            } else {
                this.artifactsTable.addRow(artifactSummaryBean);
            }
        }
        this.artifactsTable.setVisible(true);
        // Important to set this here.  If you click on a search suggestion, filtersPanel's ValueChangeHandler
        // gets kicked off twice -- once due to the click on the suggestion popup and again when that replaces
        // the value in the field.  The first one sets noDataMessage.setVisible(true), below.  See SRAMP-557
        this.noDataMessage.setVisible(false);
    } else {
        this.noDataMessage.setVisible(true);
    }
}

From source file:org.bonitasoft.console.client.view.cases.AdminCaseMenuBarWidget.java

License:Open Source License

protected void buildMyDirectActionMenu(boolean isBackEnabled) {
    if (isBackEnabled) {
        myDirectActionMenu.addItem(MODIFY_INSTANCE_BUTTON_TITLE, new Command() {
            public void execute() {
                modifySelectedCases();/*from   w ww.j ava2  s.c om*/
            }
        });
    }

    myDirectActionMenu.addItem(CANCEL_INSTANCE_TITLE, new Command() {
        public void execute() {
            //add a ConfirmationDialogbox when you cancel a Case.
            if (myCaseSelection.getSize() > 0) {
                confirmationDialogbox = new ConfirmationDialogbox(constants.cancelCasesDialogbox(),
                        patterns.cancelCasesWarn(myCaseSelection.getSelectedItems().size()),
                        constants.okButton(), constants.cancelButton());
                confirmationDialogbox.addCloseHandler(new CloseHandler<PopupPanel>() {
                    public void onClose(CloseEvent<PopupPanel> event) {
                        if (confirmationDialogbox.getConfirmation()) {
                            cancelSelectedCases();
                        }
                    }
                });
            } else {
                if (myMessageDataSource != null) {
                    myMessageDataSource.addWarningMessage(messages.noCaseSelectedWarn());
                }
            }
        }

    });

    myDirectActionMenu.addItem(DELETE_INSTANCE_BUTTON_TITLE, new Command() {
        public void execute() {
            //add a ConfirmationDialogbox when you delete a Case.
            if (myCaseSelection.getSize() > 0) {
                confirmationDialogbox = new ConfirmationDialogbox(constants.deleteCasesDialogbox(),
                        patterns.deleteCasesWarn(myCaseSelection.getSelectedItems().size()),
                        constants.okButton(), constants.cancelButton());
                final CheckBox deleteAttachmentsCheckBox = new CheckBox(constants.deleteAttachmentsCheckBox());
                confirmationDialogbox.addWidgetToDialogboxBody(deleteAttachmentsCheckBox);

                confirmationDialogbox.addCloseHandler(new CloseHandler<PopupPanel>() {
                    public void onClose(CloseEvent<PopupPanel> event) {
                        if (confirmationDialogbox.getConfirmation()) {
                            deleteSelectedCases(deleteAttachmentsCheckBox.getValue());
                        }
                    }
                });
            } else {
                if (myMessageDataSource != null) {
                    myMessageDataSource.addWarningMessage(messages.noCaseSelectedWarn());
                }
            }
        }

    });

    if (isBackEnabled) {
        buildMoreActionSubMenu();
    }

}

From source file:org.bonitasoft.console.client.view.categories.CategoriesListEditorView.java

License:Open Source License

private Widget buildSelectAllSelector() {
    final FlowPanel theWrapper = new FlowPanel();
    final CheckBox theSelectAllCheckBox = new CheckBox();
    theWrapper.add(theSelectAllCheckBox);
    theSelectAllCheckBox.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent aEvent) {
            if (aEvent.getSource() instanceof CheckBox) {
                CheckBox theCheckBox = (CheckBox) aEvent.getSource();
                selectAllRows(theCheckBox.getValue());
                aEvent.stopPropagation();
            }/*from ww w  .j  av  a 2 s . c om*/
        }
    });
    final CustomMenuBar theSelector = new CustomMenuBar();
    theSelector.addItem(theWrapper, new Command() {
        public void execute() {
            boolean theNewValue = !theSelectAllCheckBox.getValue();
            theSelectAllCheckBox.setValue(theNewValue, true);
            selectAllRows(theNewValue);
        }
    });
    return theSelector;
}

From source file:org.bonitasoft.console.client.view.categories.CategoriesListEditorView.java

License:Open Source License

private Widget buildItemSelector(final int row) {
    final CheckBox theSelectItemCheckBox = new CheckBox();
    theSelectItemCheckBox.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent aEvent) {
            if (aEvent.getSource() instanceof CheckBox) {
                CheckBox theCheckBox = (CheckBox) aEvent.getSource();
                if (theCheckBox.getValue()) {
                    myItemRowSelection.add(row);
                } else {
                    myItemRowSelection.remove(row);
                }/*from  w w w  .j a  v  a  2 s.c  om*/
            }
        }
    });
    return theSelectItemCheckBox;
}

From source file:org.bonitasoft.console.client.view.identity.GroupsListEditorView.java

License:Open Source License

private Widget buildSelectAllSelector() {
    final FlowPanel theWrapper = new FlowPanel();
    final CheckBox theSelectAllCheckBox = new CheckBox();
    theWrapper.add(theSelectAllCheckBox);
    theSelectAllCheckBox.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent aEvent) {
            if (aEvent.getSource() instanceof CheckBox) {
                CheckBox theCheckBox = (CheckBox) aEvent.getSource();
                selectAllRows(theCheckBox.getValue());
                aEvent.stopPropagation();
            }// w w w. jav  a  2  s .  com
        }
    });

    final CustomMenuBar theSelector = new CustomMenuBar();
    theSelector.addItem(theWrapper, new Command() {
        public void execute() {
            boolean theNewValue = !theSelectAllCheckBox.getValue();
            theSelectAllCheckBox.setValue(theNewValue, true);
            selectAllRows(theNewValue);
        }
    });
    return theSelector;
}

From source file:org.bonitasoft.console.client.view.identity.MembershipsListEditorView.java

License:Open Source License

private Widget buildItemSelector(final int row) {
    final CheckBox theSelectItemCheckBox = new CheckBox();
    theSelectItemCheckBox.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent aEvent) {
            if (aEvent.getSource() instanceof CheckBox) {
                CheckBox theCheckBox = (CheckBox) aEvent.getSource();
                if (theCheckBox.getValue()) {
                    myMembershipRowSelection.add(row);
                } else {
                    myMembershipRowSelection.remove(row);
                }/*from  w w w .  j  a  v  a2s.c om*/
            }
        }
    });
    return theSelectItemCheckBox;
}