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:fr.aliasource.webmail.client.conversations.DataGrid.java

License:GNU General Public License

public ClickHandler getCheckListener(final ConversationId convId, final CheckBox cb) {
    ClickHandler cl = new ClickHandler() {
        public void onClick(ClickEvent sender) {
            if (cb.getValue()) {
                selectedIds.add(convId);
            } else {
                selectedIds.remove(convId);
                clp.destroySelectAllPanel();
            }//from   w ww.  j a v a  2 s . c  om
            notifySelectionListeners();
        }
    };
    return cl;
}

From source file:fr.aliasource.webmail.client.conversations.DataGrid.java

License:GNU General Public License

private void switchSelected(int row) {
    CheckBox cb = (CheckBox) getWidget(row, 1);
    setSelected(row, !cb.getValue());
    notifySelectionListeners();/*from  ww  w.jav  a  2 s  .c  om*/
}

From source file:ilarkesto.gwt.client.desktop.fields.AEditableMultiSelectionField.java

License:Open Source License

private List<String> getSelectedKeysFromCheckboxes() {
    List<String> selectedKeys = new ArrayList<String>();
    for (Map.Entry<String, CheckBox> entry : checkboxes.entrySet()) {
        String key = entry.getKey();
        CheckBox checkBox = entry.getValue();
        if (checkBox.getValue().booleanValue())
            selectedKeys.add(key);/*from  www  . ja va  2 s. c  om*/
    }
    return selectedKeys;
}

From source file:ilarkesto.gwt.client.desktop.fields.AEditableMultiSelectionField.java

License:Open Source License

private void updateStyle(CheckBox checkBox) {
    Style style = checkBox.getElement().getStyle();
    if (checkBox.getValue().booleanValue()) {
        style.setColor("#000");
    } else {// ww w  .j ava  2  s.co  m
        style.setColor("#666");
    }
}

From source file:main.client.ui.RowLayoutPortlet.java

License:Open Source License

public RowLayoutPortlet() {
    LayoutPanel panel = new LayoutPanel();
    initWidget(panel);//from  www.  j a  va  2  s. c  om

    final CheckBox column = new CheckBox("Column");
    column.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            getTargetLayout().setColumn(column.getValue());
            target.layout();
        }
    });

    final TextBox spacing = new TextBox();
    spacing.setVisibleLength(4);
    spacing.addChangeHandler(new ChangeHandler() {
        public void onChange(ChangeEvent event) {
            try {
                getTargetLayout().setSpacing(Integer.parseInt(spacing.getText()));
            } catch (NumberFormatException e) {
                // ignore
            }
            target.layout();
        }
    });

    final Label bounds = new Label();
    target.addLayoutHandler(new LayoutHandler() {
        public void onLayoutUpdated(LayoutEvent layoutEvent) {
            bounds.setText(LDOM.getBounds(target).toString());
            column.setValue(getTargetLayout().isColumn());
            spacing.setText(Integer.toString(getTargetLayout().getSpacing()));
        }
    });

    demoList.addItem("Buttons & Body");
    demoList.addItem("Sidebar & Margin");
    demoList.addItem("Border Layout");
    demoList.setSelectedIndex(0);

    Button add = new CssButton("Add Widget", new ClickHandler() {
        public void onClick(ClickEvent event) {
            target.add(new Thing("Widget-" + (target.getWidgetCount() + 1)));
            target.layout();
        }
    }, "Add a new widget to the layout");

    final Button go = new CssButton("Go", new ClickHandler() {
        public void onClick(ClickEvent event) {
            go();
        }
    }, "Reset the layout to the selected state");

    demoList.addChangeHandler(new ChangeHandler() {
        public void onChange(ChangeEvent event) {
            go.click();
        }
    });

    FormBuilder b = new FormBuilder();
    b.add(add).label("Spacing").field(spacing).field(column).add("").field(bounds).wrap().width("100%")
            .add(demoList).add(go).endRow();

    panel.add(b.getForm(), 22);
    panel.add(target, LayoutConstraints.HIDDEN);

    go();
}

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

/**
 * Gets the selected options of the field.
 *
 * @return map the map of selected key-option(s).
 *//*  w w w .j  a v a2 s. c o  m*/
public HashMap<String, ArrayList<String>> getValue() {
    ArrayList<String> item = null;
    HashMap<String, ArrayList<String>> value = new HashMap<String, ArrayList<String>>();
    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("StackField getValue " + row);
            }
            String id = cb.getFormValue();
            if (cb.getValue()) {
                if (!value.containsKey(key)) {
                    item = new ArrayList<String>();
                    value.put(key, item);
                }
                item.add(id);
            }
        }
    }
    return value;
}

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);//from w  ww.  j  a v a  2 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.easysmarthouse.ui.webui.client.view.handler.SignalingEnableHandler.java

@Override
public void onClick(ClickEvent event) {
    CheckBox checkBox = (CheckBox) event.getSource();
    boolean enabled = checkBox.getValue();

    String address = null;//from w w  w.  j ava2s  .c  o  m
    if (signaligElement instanceof Device) {
        Device signaligDevice = (Device) signaligElement;
        address = signaligDevice.getAddress();
    }

    if (address == null) {
        return;
    }

    AsyncCallback<Void> idleCallback = new BaseCallback<Void>() {
        @Override
        public void onSuccess(Void result) {
        }
    };

    this.serviceLocator.getSignalings().setEnabled(address, enabled, idleCallback);

}

From source file:net.scran24.admin.client.NewSurvey.java

License:Apache License

public NewSurvey() {
    contents = new FlowPanel();

    final Grid surveyParametersGrid = new Grid(7, 2);
    surveyParametersGrid.setCellPadding(5);

    contents.add(surveyParametersGrid);/*from  www .  j a  v  a 2 s . c  o  m*/

    final Label idLabel = new Label("Survey identifier: ");
    final TextBox idTextBox = new TextBox();

    surveyParametersGrid.setWidget(0, 0, idLabel);
    surveyParametersGrid.setWidget(0, 1, idTextBox);

    final Label schemeBoxLabel = new Label("Survey scheme: ");
    final ListBox schemeBox = new ListBox();
    schemeBox.setMultipleSelect(false);

    final Label localeLabel = new Label("Locale: ");
    final ListBox localeBox = new ListBox();
    localeBox.setMultipleSelect(false);

    localeBox.addItem("English (UK)", "en_GB");
    localeBox.addItem("English (New Zealand)", "en_NZ");
    localeBox.addItem("Portuguese (Portugal)", "pt_PT");
    localeBox.addItem("Danish (Denmark)", "da_DK");
    localeBox.addItem("Arabic (UAE)", "ar_AE");

    for (SurveySchemeReference s : SurveySchemes.allSchemes)
        schemeBox.addItem(s.description(), s.id());

    schemeBox.setSelectedIndex(0);

    surveyParametersGrid.setWidget(1, 0, schemeBoxLabel);
    surveyParametersGrid.setWidget(1, 1, schemeBox);

    surveyParametersGrid.setWidget(2, 0, localeLabel);
    surveyParametersGrid.setWidget(2, 1, localeBox);

    final Label genUserLabel = new Label("Allow auto login: ");
    final CheckBox genCheckBox = new CheckBox();

    surveyParametersGrid.setWidget(3, 0, genUserLabel);
    surveyParametersGrid.setWidget(3, 1, genCheckBox);

    final Label forwardToSurveyMonkey = new Label("SurveyMonkey support:");
    final CheckBox smCheckBox = new CheckBox();

    surveyParametersGrid.setWidget(4, 0, forwardToSurveyMonkey);
    surveyParametersGrid.setWidget(4, 1, smCheckBox);

    final Label surveyMonkeyUrl = new Label("SurveyMonkey link:");
    final TextBox smUrlTextBox = new TextBox();

    surveyParametersGrid.setWidget(5, 0, surveyMonkeyUrl);
    surveyParametersGrid.setWidget(5, 1, smUrlTextBox);

    smUrlTextBox.setEnabled(false);

    final Label supportEmailLabel = new Label("Support e-mail:");
    final TextBox supportEmailTextBox = new TextBox();

    surveyParametersGrid.setWidget(6, 0, supportEmailLabel);
    surveyParametersGrid.setWidget(6, 1, supportEmailTextBox);

    smCheckBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override
        public void onValueChange(ValueChangeEvent<Boolean> valueChangeEvent) {
            smUrlTextBox.setEnabled(valueChangeEvent.getValue());
        }
    });

    final FlowPanel errorDiv = new FlowPanel();
    errorDiv.getElement().addClassName("scran24-admin-survey-id-error-message");

    contents.add(errorDiv);

    final Button createButton = WidgetFactory.createButton("Create survey");

    createButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            createButton.setEnabled(false);
            final String id = idTextBox.getText();
            errorDiv.clear();

            String smUrlText = smUrlTextBox.getText();

            Option<String> smUrl;

            if (smCheckBox.getValue())
                smUrl = smUrlText.isEmpty() ? Option.<String>none() : Option.some(smUrlText);
            else
                smUrl = Option.<String>none();

            if (smCheckBox.getValue() && smUrlText.isEmpty()) {
                errorDiv.add(new Label("Please paste the SurveyMonkey link!"));
                createButton.setEnabled(true);
                return;
            } else if (smCheckBox.getValue()
                    && !smUrlText.contains("intake24_username=[intake24_username_value]")) {
                errorDiv.add(new Label("Invalid SurveyMonkey link: intake24_username variable missing!"));
                createButton.setEnabled(true);
                return;
            }

            service.createSurvey(id, schemeBox.getValue(schemeBox.getSelectedIndex()),
                    localeBox.getValue(localeBox.getSelectedIndex()), genCheckBox.getValue(), smUrl,
                    supportEmailTextBox.getValue(), new AsyncCallback<Option<String>>() {
                        @Override
                        public void onSuccess(Option<String> result) {
                            result.accept(new Option.SideEffectVisitor<String>() {
                                @Override
                                public void visitSome(String error) {
                                    errorDiv.add(new Label(error));
                                    createButton.setEnabled(true);
                                }

                                @Override
                                public void visitNone() {
                                    contents.clear();
                                    contents.add(new HTMLPanel(SafeHtmlUtils.fromSafeConstant(
                                            "<h2>Survey created!</h2><p>Please go to <strong>Survey management</strong> and upload the staff accounts for the new survey.</p>")));
                                }
                            });
                        }

                        @Override
                        public void onFailure(Throwable caught) {
                            createButton.setEnabled(true);
                            errorDiv.add(
                                    new Label("Server error (" + SafeHtmlUtils.htmlEscape(caught.getMessage())
                                            + "), please check server logs"));
                        }
                    });
        }
    });
    createButton.getElement().addClassName("scran24-admin-button");

    VerticalPanel buttonsPanel = new VerticalPanel();
    buttonsPanel.add(createButton);

    contents.add(buttonsPanel);

    initWidget(contents);
}

From source file:net.scran24.user.client.survey.prompts.ReadyMealsPrompt.java

@Override
public SurveyStageInterface getInterface(final Callback1<MealOperation> onComplete,
        final Callback1<Function1<Meal, Meal>> onIntermediateStateChange) {

    FlowPanel content = new FlowPanel();

    FlowPanel promptPanel = WidgetFactory.createPromptPanel(
            SafeHtmlUtils.fromSafeConstant(
                    messages.readyMeals_promptText(SafeHtmlUtils.htmlEscape(meal.name.toLowerCase()))),
            ShepherdTour.createTourButton(tour, ReadyMealsPrompt.class.getSimpleName()));
    ShepherdTour.makeShepherdTarget(promptPanel);

    content.add(promptPanel);//from   ww  w  .j a  va2 s . co m

    PVector<WithIndex<FoodEntry>> potentialReadyMeals = filter(zipWithIndex(meal.foods),
            new Function1<WithIndex<FoodEntry>, Boolean>() {
                @Override
                public Boolean apply(WithIndex<FoodEntry> argument) {
                    return argument.value.accept(new FoodEntry.Visitor<Boolean>() {

                        @Override
                        public Boolean visitRaw(RawFood food) {
                            return false;
                        }

                        @Override
                        public Boolean visitEncoded(EncodedFood food) {
                            return !food.isDrink() && !food.link.isLinked() && food.data.askIfReadyMeal;
                        }

                        @Override
                        public Boolean visitTemplate(TemplateFood food) {
                            return false;
                        }

                        @Override
                        public Boolean visitMissing(MissingFood food) {
                            return false;
                        }

                        @Override
                        public Boolean visitCompound(CompoundFood food) {
                            return false;
                        }
                    });
                }
            });

    final Map<CheckBox, Integer> checkBoxToIndex = new HashMap<CheckBox, Integer>();

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

    for (WithIndex<FoodEntry> f : potentialReadyMeals) {
        FlowPanel rowDiv = new FlowPanel();

        CheckBox readyMealCheck = new CheckBox(SafeHtmlUtils.htmlEscape(f.value.description()));
        readyMealCheck.addStyleName("scran24-ready-meals-checkbox");

        checkBoxToIndex.put(readyMealCheck, f.index);

        rowDiv.add(readyMealCheck);

        checkboxesDiv.add(rowDiv);
    }

    content.add(checkboxesDiv);

    Button finishedButton = WidgetFactory.createButton(messages.editMeal_finishButtonLabel(),
            new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    onComplete.call(MealOperation.update(new Function1<Meal, Meal>() {
                        @Override
                        public Meal apply(Meal argument) {
                            Meal result = argument;

                            for (CheckBox check : checkBoxToIndex.keySet()) {
                                int index = checkBoxToIndex.get(check);
                                result = (check.getValue())
                                        ? result.updateFood(index, result.foods.get(index).markReadyMeal())
                                        : result;
                            }

                            return result.markReadyMealsComplete();
                        }
                    }));
                }
            });

    finishedButton.getElement().setId("intake24-ready-meals-finished-button");

    ShepherdTour.makeShepherdTarget(checkboxesDiv, finishedButton);

    content.add(WidgetFactory.createButtonsPanel(finishedButton));

    return new SurveyStageInterface.Aligned(content, HasHorizontalAlignment.ALIGN_LEFT,
            HasVerticalAlignment.ALIGN_TOP, SurveyStageInterface.DEFAULT_OPTIONS);
}