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

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

Introduction

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

Prototype

@Override
public void setValue(Boolean value) 

Source Link

Document

Checks or unchecks the check box.

Usage

From source file:net.cbtltd.client.field.StackField.java

/**
 * Renders the field from the specified map of available key-option(s) into the field.
 *
 * @param map the map of available key-option(s).
 *///from ww  w. ja  v  a2s.  co m
private void setItems(HashMap<NameId, ArrayList<NameId>> map) {
    if (map == null) {
        return;
    }
    field.clear();
    ArrayList<NameId> keys = new ArrayList<NameId>(map.keySet());
    Collections.sort(keys);
    for (NameId key : keys) {
        ArrayList<NameId> values = map.get(key);
        VerticalPanel options = new VerticalPanel();
        options.setTitle(key.getId());
        field.add(options,
                "<img src='" + BUNDLE.open().getURL() + "' style='padding: 1px;'</img>" + key.getName(), true);
        //         field.add(options, key.getName());
        for (NameId value : values) {
            CheckBox cb = new CheckBox(value.getName());
            cb.setFormValue(value.getId());
            cb.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    CheckBox cb = (CheckBox) event.getSource();
                    if (isUniquekey(cb.getFormValue())) {
                        deselect(cb.getFormValue());
                        cb.setValue(true);
                    }
                }
            });
            options.add(cb);
        }
    }
}

From source file:net.cbtltd.client.field.StackField.java

/**
 * Sets the selected options in the field from the specified map of selected key-option(s).
 *
 * @param value the map of selected key-option(s).
 *///from ww  w . ja  v a 2  s .c  om
public void setValue(HashMap<String, ArrayList<String>> value) {
    for (int index = 0; index < field.getWidgetCount(); index++) {
        VerticalPanel options = (VerticalPanel) field.getWidget(index);
        String key = options.getTitle();
        for (int row = 0; row < options.getWidgetCount(); row++) {
            CheckBox cb = (CheckBox) options.getWidget(row);
            if (cb == null) {
                Window.alert("setValue " + row);
            }
            String id = cb.getFormValue();
            if (value == null) {
                cb.setValue(false);
            } else if (value.containsKey(key)) {
                cb.setValue(value.get(key).contains(id));
            }
        }
    }
    super.setChanged();
}

From source file:net.cbtltd.client.form.OrganizationForm.java

License:Open Source License

private FlowPanel createWorkflow() {
    final FlowPanel panel = new FlowPanel();
    final HTML workflowText = new HTML(CONSTANTS.workflowText());
    panel.add(workflowText);/*  ww  w .jav a2  s.c  o m*/
    final String[] WORKFLOW_DATES = { Reservation.FROMDATE, Reservation.DATE, Reservation.TODATE };
    final ArrayList<NameId> DATENAMES = NameId.getList(CONSTANTS.workflowDates(), WORKFLOW_DATES);

    workflowGrid = new GridField<Workflow>(this, null, CONSTANTS.workflowHeaders(),
            Reservation.WORKFLOW_STATES.length, tab++) {

        @Override
        public void setRowValue(int row, Workflow value) {

            CheckBox enabledField = new CheckBox(getStatename(value.getState()));
            enabledField.setFormValue(value.getState());
            enabledField.setValue(value.getEnabled());
            enabledField.addStyleName(OrganizationForm.CSS.workflowState());
            workflowGrid.setWidget(row, 0, enabledField);

            IntegerField durationField = new IntegerField(this, null, null, 0);
            durationField.setValue(value.getDuration());
            durationField.setFieldStyle(OrganizationForm.CSS.workflowDuration());
            workflowGrid.setWidget(row, 1, durationField);

            workflowGrid.setText(row, 2, value.getUnit().toString());

            ToggleButton priorField = new ToggleButton(OrganizationForm.CONSTANTS.workflowLabelAfter(),
                    OrganizationForm.CONSTANTS.workflowLabelBefore());
            priorField.setDown(value.getPrior());
            priorField.addStyleName(OrganizationForm.CSS.workflowWhen());
            workflowGrid.setWidget(row, 3, priorField);

            ListField datenameField = new ListField(this, null, DATENAMES, null, false, 0);
            datenameField.setValue(value.getDatename());
            datenameField.setFieldStyle(OrganizationForm.CSS.workflowDatename());
            workflowGrid.setWidget(row, 4, datenameField);
        }

        @Override
        public Workflow getRowValue(int row) {
            CheckBox enabledField = (CheckBox) workflowGrid.getWidget(row, 0);
            IntegerField durationField = (IntegerField) workflowGrid.getWidget(row, 1);
            ToggleButton priorField = (ToggleButton) workflowGrid.getWidget(row, 3);
            ListField datenameField = (ListField) workflowGrid.getWidget(row, 4);
            Workflow value = new Workflow(organizationField.getId(), NameId.Type.Reservation.name(),
                    enabledField.getFormValue(), enabledField.getValue(), priorField.isDown(),
                    datenameField.getValue(), Time.DAY.name(), durationField.getValue());
            //Window.alert("getRowValue " + value);
            return value;
        }
    };

    ArrayList<Workflow> defaultValue = new ArrayList<Workflow>();
    defaultValue.add(new Workflow(organizationField.getId(), NameId.Type.Reservation.name(),
            Reservation.WORKFLOW_STATES[0], true, false, Reservation.DATE, Time.DAY.name(), 2));//RESERVED
    defaultValue.add(new Workflow(organizationField.getId(), NameId.Type.Reservation.name(),
            Reservation.WORKFLOW_STATES[1], true, false, Reservation.DATE, Time.DAY.name(), 3));//CONFIRMED
    defaultValue.add(new Workflow(organizationField.getId(), NameId.Type.Reservation.name(),
            Reservation.WORKFLOW_STATES[2], true, true, Reservation.FROMDATE, Time.DAY.name(), 35));//FULLYPAID
    defaultValue.add(new Workflow(organizationField.getId(), NameId.Type.Reservation.name(),
            Reservation.WORKFLOW_STATES[3], true, true, Reservation.FROMDATE, Time.DAY.name(), 7));//BRIEFED
    defaultValue.add(new Workflow(organizationField.getId(), NameId.Type.Reservation.name(),
            Reservation.WORKFLOW_STATES[4], true, true, Reservation.FROMDATE, Time.DAY.name(), 1));//ARRIVED
    defaultValue.add(new Workflow(organizationField.getId(), NameId.Type.Reservation.name(),
            Reservation.WORKFLOW_STATES[5], true, true, Reservation.TODATE, Time.DAY.name(), 2));//PREDEPARTED
    defaultValue.add(new Workflow(organizationField.getId(), NameId.Type.Reservation.name(),
            Reservation.WORKFLOW_STATES[6], true, true, Reservation.TODATE, Time.DAY.name(), 7));//DEPARTED
    //      defaultValue.add(new Workflow(organizationField.getId(), NameId.Type.Reservation.name(), Reservation.WORKFLOW_STATES[7], true, false, Reservation.TODATE, Time.DAY.name(), 7));//DEPARTED
    workflowGrid.setDefaultValue(defaultValue);

    panel.add(workflowGrid);
    return panel;
}

From source file:net.officefloor.plugin.gwt.comet.client.OfficeFloorCometEntryPoint.java

License:Open Source License

@Override
public void onModuleLoad() {

    // Create the publishers
    final MockCometNotificationListener notificationPublisher = OfficeFloorComet
            .createPublisher(MockCometNotificationListener.class);
    final MockCometEventListener eventPublisher = OfficeFloorComet
            .createPublisher(MockCometEventListener.class);
    final MockCometMatchKeyListener matchKeyPublisher = OfficeFloorComet
            .createPublisher(MockCometMatchKeyListener.class);
    final MockCometNullFilterKeyListener nullFilterKeyPublisher = OfficeFloorComet
            .createPublisher(MockCometNullFilterKeyListener.class);

    // Provide the widgets
    Panel root = RootPanel.get("comet");
    root.clear();/* w  w w  .j  a  va  2s. com*/
    VerticalPanel panel = new VerticalPanel();
    root.add(panel);

    // Provide event text widget
    HorizontalPanel eventPanel = new HorizontalPanel();
    panel.add(eventPanel);
    eventPanel.add(new Label("Event text: "));
    final TextBox eventText = new TextBox();
    eventText.setText("TEST");
    eventPanel.add(eventText);

    // Provide match key widget
    HorizontalPanel matchKeyPanel = new HorizontalPanel();
    panel.add(matchKeyPanel);
    matchKeyPanel.add(new Label("Match key: "));
    final TextBox matchKeyText = new TextBox();
    matchKeyText.setText("MATCH");
    matchKeyPanel.add(matchKeyText);
    matchKeyPanel.add(new Label("Additional: "));
    final TextBox additionalText = new TextBox();
    additionalText.setText("additional");
    matchKeyPanel.add(additionalText);

    // Multiple subscriptions
    OfficeFloorComet.setMultipleSubscriptions(true);

    // Provide notification subscription
    HorizontalPanel notificationSubscribePanel = new HorizontalPanel();
    panel.add(notificationSubscribePanel);
    notificationSubscribePanel.add(new Label("Subscribe notification: "));
    final CheckBox notificationCheckBox = new CheckBox();
    notificationSubscribePanel.add(notificationCheckBox);
    OfficeFloorComet.subscribe(MockCometNotificationListener.class, new MockCometNotificationListener() {
        @Override
        public void handleNotification() {
            OfficeFloorCometEntryPoint.this.notificationToggle = !OfficeFloorCometEntryPoint.this.notificationToggle;
            notificationCheckBox.setValue(Boolean.valueOf(OfficeFloorCometEntryPoint.this.notificationToggle));
        }
    }, null);

    // Provide event subscription
    HorizontalPanel eventSubscribePanel = new HorizontalPanel();
    panel.add(eventSubscribePanel);
    eventSubscribePanel.add(new Label("Subscribed event: "));
    final Label eventSubscribeLabel = new Label("[no event]");
    eventSubscribePanel.add(eventSubscribeLabel);
    OfficeFloorComet.subscribe(MockCometEventListener.class, new MockCometEventListener() {
        @Override
        public void handleEvent(String event) {
            eventSubscribeLabel.setText(event + " (" + (++OfficeFloorCometEntryPoint.this.eventCount) + ")");
        }
    }, null);

    // Provide filter key subscription
    HorizontalPanel filterKeySubscribePanel = new HorizontalPanel();
    panel.add(filterKeySubscribePanel);
    filterKeySubscribePanel.add(new Label("Filter Key: "));
    final TextBox filterKeyText = new TextBox();
    filterKeyText.setText(matchKeyText.getText());
    filterKeySubscribePanel.add(filterKeyText);
    filterKeySubscribePanel.add(new Label("Subscribe filter key: "));
    final Label matchKeySubscribeLabel = new Label("[no event]");
    filterKeySubscribePanel.add(matchKeySubscribeLabel);
    OfficeFloorComet.subscribe(MockCometMatchKeyListener.class, new MockCometMatchKeyListener() {
        @Override
        public void handleEvent(String event, MockFilterKey matchKey) {
            matchKeySubscribeLabel.setText(event + "(" + (++OfficeFloorCometEntryPoint.this.filterKeyCount)
                    + ") - " + (matchKey == null ? "NONE" : matchKey.getAdditionalText()));
        }
    }, this.filterKey);

    // Provide null filter key subscription
    HorizontalPanel nullFilterKeySubscribePanel = new HorizontalPanel();
    panel.add(nullFilterKeySubscribePanel);
    nullFilterKeySubscribePanel.add(new Label("Subscribe null filter key: "));
    final Label nullMatchKeySubscribeLabel = new Label("[no event]");
    nullFilterKeySubscribePanel.add(nullMatchKeySubscribeLabel);
    OfficeFloorComet.subscribe(MockCometNullFilterKeyListener.class, new MockCometNullFilterKeyListener() {
        @Override
        public void handleEvent(String event, MockFilterKey matchKey) {
            nullMatchKeySubscribeLabel
                    .setText(event + "(" + (++OfficeFloorCometEntryPoint.this.nullFilterKeyCount) + ") - "
                            + (matchKey == null ? "NONE" : matchKey.getAdditionalText()));
        }
    }, null);

    // Subscribe
    OfficeFloorComet.subscribe();

    // Provide button to trigger publishing
    Button publishButton = new Button("Publish");
    panel.add(publishButton);
    publishButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent clickEvent) {

            // Specify the filter key (may take two events to update)
            String filterKey = filterKeyText.getText();
            OfficeFloorCometEntryPoint.this.filterKey.setFilterText(filterKey);

            // Create the match key
            MockFilterKey matchKey;
            String matchKeyValue = matchKeyText.getText();
            if ((matchKeyValue == null) || (matchKeyValue.trim().length() == 0)) {
                // No match key
                matchKey = null;
            } else {
                // Provide the match key
                matchKey = new MockFilterKey(additionalText.getText());
                matchKey.setFilterText(matchKeyValue);
            }

            // Publish events
            String event = eventText.getText();
            notificationPublisher.handleNotification();
            eventPublisher.handleEvent(event);
            matchKeyPublisher.handleEvent(event, matchKey);
            nullFilterKeyPublisher.handleEvent(event, matchKey);
        }
    });
}

From source file:net.randomhacks.wave.voting.approval.client.ChoicesTable.java

License:Apache License

private void updateChoiceRow(int i, Choice choice, boolean isWritable) {
    Log.debug("Updating row " + Integer.toString(i) + ": " + choice.key);
    CheckBox checkBox = (CheckBox) getWidget(rowForChoiceIndex(i), 0);
    checkBox.setValue(choice.wasChosenByMe);
    String label = choice.name;/* w w  w .  j a va 2  s . com*/
    if (choice.votes > 0)
        label += " (" + Integer.toString(choice.votes) + ")";
    checkBox.setText(label);
    if (choice.isWinner)
        checkBox.addStyleName("winningChoice");
    else
        checkBox.removeStyleName("winningChoice");
    checkBox.setEnabled(isWritable);
}

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//  ww w  .  j  a  va2 s  . com
        // 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  . c  o  m
    ((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

@Override
public Promise<Void> setValue(ReferenceValue value) {
    Set<ResourceId> ids = value.getResourceIds();
    for (CheckBox entry : controls) {
        ResourceId resourceId = ResourceId.valueOf(entry.getFormValue());
        entry.setValue(ids.contains(resourceId));
    }/* w  ww  .j  a va2  s  .  c  o m*/
    return Promise.done();
}

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 .c  o m*/
 */
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.forms.client.view.widget.CheckboxGroupWidget.java

License:Open Source License

private void setInitialValue(final CheckBox checkBox, final Collection<String> initialValues,
        final ReducedFormFieldAvailableValue availableValue) {
    if (initialValues != null && initialValues.contains(availableValue.getValue())) {
        checkBox.setValue(true);
    }/*  w w w.  j a  v  a2 s. c o m*/
}