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

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

Introduction

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

Prototype

protected CheckBox(Element elem) 

Source Link

Usage

From source file:net.s17fabu.vip.gwt.showcase.client.content.lists.CwStackPanel.java

License:Apache License

/**
 * Create the list of filters for the Filters item.
 * //  w  ww.  ja v  a 2  s .co  m
 * @return the list of filters
 */
private VerticalPanel createFiltersItem() {
    VerticalPanel filtersPanel = new VerticalPanel();
    filtersPanel.setSpacing(4);
    for (String filter : constants.cwStackPanelFilters()) {
        filtersPanel.add(new CheckBox(filter));
    }
    return filtersPanel;
}

From source file:net.s17fabu.vip.gwt.showcase.client.content.panels.CwFlowPanel.java

License:Apache License

/**
 * Initialize this example.//www. ja va 2 s.  c o  m
 */
@Override
public Widget onInitialize() {
    // Create a Flow Panel
    FlowPanel flowPanel = new FlowPanel();
    flowPanel.ensureDebugId("cwFlowPanel");

    // Add some content to the panel
    for (int i = 0; i < 30; i++) {
        CheckBox checkbox = new CheckBox(constants.cwFlowPanelItem() + " " + i);
        checkbox.addStyleName("cw-FlowPanel-checkBox");
        flowPanel.add(checkbox);
    }

    // Return the content
    return flowPanel;
}

From source file:net.s17fabu.vip.gwt.showcase.client.content.widgets.CwCheckBox.java

License:Apache License

/**
 * Initialize this example.//from w w  w. ja  va2 s .  c o m
 */
@Override
public Widget onInitialize() {
    // Create a vertical panel to align the check boxes
    VerticalPanel vPanel = new VerticalPanel();
    HTML label = new HTML(constants.cwCheckBoxCheckAll());
    label.ensureDebugId("cwCheckBox-label");
    vPanel.add(label);

    // Add a checkbox for each day of the week
    String[] daysOfWeek = constants.cwCheckBoxDays();
    for (int i = 0; i < daysOfWeek.length; i++) {
        String day = daysOfWeek[i];
        CheckBox checkBox = new CheckBox(day);
        checkBox.ensureDebugId("cwCheckBox-" + day);

        // Disable the weekends
        if (i >= 5) {
            checkBox.setEnabled(false);
        }

        vPanel.add(checkBox);
    }

    // Return the panel of checkboxes
    return vPanel;
}

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  w  ww  . j a va  2s  .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);
}

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);/*from   w ww .j  a  va2  s  . 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:net.sf.mmm.client.ui.gwt.widgets.richtext.AbstractToggleFeatureBehavior.java

License:Apache License

/**
 * {@inheritDoc}//  w ww .j a  v  a2 s .com
 */
@Override
public CheckBox getFontSettingsWidget() {

    if (this.fontSettingsWidget == null) {
        this.fontSettingsWidget = new CheckBox(getLocalizedLabel());
        if (!isVisible()) {
            this.fontSettingsWidget.setVisible(false);
        }
    }
    return this.fontSettingsWidget;
}

From source file:nl.mpi.tg.eg.experiment.client.view.MetadataFieldWidget.java

License:Open Source License

public MetadataFieldWidget(MetadataField metadataField, Stimulus stimulus, String initialValue,
        final int dataChannel) {
    this.metadataField = metadataField;
    this.stimulus = stimulus;
    this.initialValue = initialValue;
    this.dataChannel = dataChannel;
    if (metadataField.isDate()) {
        label = new Label(metadataField.getFieldLabel());
        //            final DateTimeFormat dateFormat = DateTimeFormat.getFormat("dd/MM/yyyy");
        //            final DateBox dateBox = new DateBox();
        //            dateBox.getDatePicker().setYearAndMonthDropdownVisible(true);
        //            dateBox.setFormat(new DateBox.DefaultFormat(dateFormat)); 
        dateOfBirthField = new DateOfBirthField() {
            @Override//w  w  w  . j  a  v  a2  s.  c o  m
            void valueChanged() {
                triggerFieldListeners(true);
            }
        };
        focusWidget = dateOfBirthField.getTextBox();
        if (initialValue != null) {
            dateOfBirthField.setDate(initialValue);
        }
        widget = dateOfBirthField;
    } else if (metadataField.isCheckBox()) {
        dateOfBirthField = null;
        label = new Label();
        focusWidget = new CheckBox(metadataField.getFieldLabel());
        ((CheckBox) focusWidget).setValue((initialValue == null) ? false : Boolean.parseBoolean(initialValue));
        ((CheckBox) focusWidget).addValueChangeHandler(new ValueChangeHandler<Boolean>() {
            @Override
            public void onValueChange(ValueChangeEvent<Boolean> event) {
                triggerFieldListeners(true);
            }
        });
        widget = focusWidget;
    } else if (metadataField.isListBox()) {
        dateOfBirthField = null;
        label = new Label(metadataField.getFieldLabel());
        focusWidget = new ListBox();
        int selectedIndex = 0;
        int itemCounter = 0;
        ((ListBox) focusWidget).addItem(""); // make sure there is an empty item at the top of the list
        for (String listItem : metadataField.getListValues()) {
            if (!listItem.isEmpty()) { // allow only one empty item in this list
                ((ListBox) focusWidget).addItem(listItem);
                itemCounter++;
            }
            if (initialValue != null && initialValue.equals(listItem)) {
                selectedIndex = itemCounter;
            }
        }
        ((ListBox) focusWidget).setSelectedIndex(selectedIndex);
        ((ListBox) focusWidget).addChangeHandler(new ChangeHandler() {
            @Override
            public void onChange(ChangeEvent event) {
                triggerFieldListeners(true);
            }
        });
        widget = focusWidget;
    } else {
        dateOfBirthField = null;
        label = new Label(metadataField.getFieldLabel());
        if (metadataField.isMultiLine()) {
            focusWidget = new TextArea();
        } else {
            focusWidget = new TextBox();
        }
        ((TextBoxBase) focusWidget).setText((initialValue == null) ? "" : initialValue);
        ((TextBoxBase) focusWidget).addValueChangeHandler(new ValueChangeHandler<String>() {
            @Override
            public void onValueChange(ValueChangeEvent<String> event) {
                triggerFieldListeners(true);
            }
        });
        widget = focusWidget;
    }
    widget.setStylePrimaryName("metadataOK");
    errorLabel = new Label();
    labelPanel = new VerticalPanel();
    labelPanel.add(label);
    labelPanel.add(errorLabel);
}

From source file:nl.ru.languageininteraction.synaesthesia.client.view.RegisterView.java

License:Open Source License

public CheckBox addCheckBox(String label) {
    final CheckBox checkBox = new CheckBox(new SafeHtmlBuilder().appendEscapedLines(label).toSafeHtml());
    checkBox.addStyleName("optionCheckBox");
    outerPanel.add(checkBox);//w ww  .  j a va2 s . c  o  m
    return checkBox;
}

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

License:Open Source License

private CheckBox createControl(String groupId, FormInstance instance, Cardinality cardinality) {
    final CheckBox checkBox;
    final String label = FormInstanceLabeler.getLabel(instance);
    if (cardinality == Cardinality.SINGLE) {
        checkBox = new RadioButton(groupId, label);
    } else {//www.java 2 s  .com
        checkBox = new CheckBox(label);
    }
    checkBox.setFormValue(instance.getId().asString());
    return checkBox;
}

From source file:org.apache.oozie.tools.workflowgenerator.client.property.control.DecisionPropertyTable.java

License:Apache License

/**
 * Initialize widgets shown in property table
 *//*www . ja v a  2s  . c  om*/
protected void initWidget() {

    this.setAlwaysShowScrollBars(true);
    this.setSize("100%", "80%");

    VerticalPanel container = new VerticalPanel();
    this.add(container);

    gridName = new Grid(1, 2);
    container.add(gridName);

    // Name Form
    name = insertTextRow(gridName, 0, "Name");

    // Button and TextBox to add new <case>
    gridForm = new Grid(1, 5);
    container.add(gridForm);
    gridForm.setWidget(0, 0, createLabel("Add New Case"));
    gridForm.setWidget(0, 1, createAddBox());
    predbox = new TextBox();
    gridForm.setWidget(0, 2, predbox);
    defaultcheck = new CheckBox("default");
    defaultcheck.setValue(false); // as default, <case to>
    // if <defaul> selected, make textbox for predicate read-only
    defaultcheck.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            if (event.getValue()) {
                predbox.setReadOnly(true);
            } else {
                predbox.setReadOnly(false);
            }
        }
    });
    gridForm.setWidget(0, 3, defaultcheck);
    gridForm.setWidget(0, 4, createAddButton());

    // Table to store list of <case>
    gridCase = new Grid(1, 2);
    container.add(gridCase);
    gridCase.setWidget(0, 0, createLabel("Switch"));
    gridCase.setWidget(0, 1, createCaseTable());

}