Example usage for com.google.gwt.user.client.ui RadioButton addValueChangeHandler

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

Introduction

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

Prototype

@Override
    public HandlerRegistration addValueChangeHandler(ValueChangeHandler<Boolean> handler) 

Source Link

Usage

From source file:com.controlj.addon.gwttree.client.TreeOptions.java

License:Open Source License

private RadioButton createTreeChoice(String groupId, String label, final boolean isStatic) {
    RadioButton dynamicChoice = new RadioButton(groupId, label);
    dynamicChoice.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override/* w ww.  j  ava2s.co  m*/
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            if (event.getValue())
                state.isStaticTree = isStatic;
        }
    });
    return dynamicChoice;
}

From source file:com.gwtm.ui.client.widgets.RadioButtonGroup.java

License:Apache License

@Override
public void add(Widget w) {
    // no assertions for gwtdesigner reasons
    //       assert w instanceof RadioButton 
    //          : "Can only contain RadioButton widgets in RadioButtonGroup";
    if (Beans.isDesignTime() && !(w instanceof RadioButton))
        return;//w w w  . j a v  a 2s . c  o m

    RadioButton radio = (RadioButton) w;
    if (name != null) {
        radio.setName(name);
    }
    super.addWidgetToPanel(radio);
    radio.addValueChangeHandler(this);
}

From source file:com.gwtmobile.ui.client.widgets.RadioButtonGroup.java

License:Apache License

@Override
public void add(Widget w) {
    // no assertions for gwtdesigner reasons
    //       assert w instanceof RadioButton 
    //          : "Can only contain RadioButton widgets in RadioButtonGroup";
    if (Beans.isDesignTime() && !(w instanceof RadioButton))
        return;//from w  w  w.ja  va2s.c o  m

    RadioButton radio = (RadioButton) w;
    if (_name != null) {
        radio.setName(_name);
    }
    super.addWidgetToPanel(radio);
    radio.addValueChangeHandler(this);
}

From source file:com.jwh.gwt.fasttable.sample.client.FastTableSample.java

License:Open Source License

private void buildRowCountButtons(FlexTable flexTable) {
    flexTable.setWidget(0, 0, new Label());
    flexTable.getFlexCellFormatter().setColSpan(0, 0, 2);
    final String rows10 = "10 sample rows";
    final String rows100 = "100 sample rows";
    final String rows500 = "500 sample rows";
    final String rows1000 = "1000 sample rows";
    final String rowsToBuild = "rowsToBuild";
    final ValueChangeHandler<Boolean> handler = new ValueChangeHandler<Boolean>() {
        @Override//from w  w  w .j av  a 2  s. c o  m
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            RadioButton selected = (RadioButton) event.getSource();
            if (rows10.equals(selected.getFormValue())) {
                sampleRowCount = 10;
            } else if (rows100.equals(selected.getFormValue())) {
                sampleRowCount = 100;
            } else if (rows500.equals(selected.getFormValue())) {
                sampleRowCount = 500;
            } else {
                sampleRowCount = 1000;
            }
        }
    };
    {
        final RadioButton radio = new RadioButton(rowsToBuild);
        radio.setHTML(rows10);
        radio.setValue(false, false);
        radio.setFormValue(rows10);
        radio.addValueChangeHandler(handler);
        flexTable.setWidget(1, 0, radio);
        flexTable.getFlexCellFormatter().setColSpan(1, 0, 2);
        radio.getElement().getParentElement().addClassName(BORDER_NONE);
    }
    {
        final RadioButton radio = new RadioButton(rowsToBuild);
        radio.setHTML(rows100);
        radio.setValue(true, false);
        radio.setFormValue(rows100);
        radio.addValueChangeHandler(handler);
        flexTable.setWidget(2, 0, radio);
        flexTable.getFlexCellFormatter().setColSpan(2, 0, 2);
        radio.getElement().getParentElement().addClassName(BORDER_NONE);
    }
    {
        final RadioButton radio = new RadioButton(rowsToBuild);
        radio.setHTML(rows500);
        radio.setValue(false, false);
        radio.setFormValue(rows500);
        radio.addValueChangeHandler(handler);
        flexTable.setWidget(3, 0, radio);
        flexTable.getFlexCellFormatter().setColSpan(3, 0, 2);
        radio.getElement().getParentElement().addClassName(BORDER_NONE);
    }
    {
        final RadioButton radio = new RadioButton(rowsToBuild);
        radio.setHTML(rows1000);
        radio.setValue(false, false);
        radio.setFormValue(rows1000);
        radio.addValueChangeHandler(handler);
        flexTable.setWidget(4, 0, radio);
        flexTable.getFlexCellFormatter().setColSpan(4, 0, 2);
        radio.getElement().getParentElement().addClassName(BORDER_NONE);
    }
}

From source file:com.murrayc.murraycgwtpexample.client.application.thing.ThingView.java

License:Open Source License

@Override
public void setThing(final Thing thing) {
    Window.setTitle("murrayc GWTP AppEngine Example" + ": " + "Thing" + ": " + thing.getText());

    choicesPanel.clear();//from   w  ww .j  a  v  a2s . com

    if (thing == null) {
        thingLabel.setText("");
        return;
    }

    thingLabel.setText(thing.getText());

    List<String> choices = new ArrayList<>();
    choices.add("Yes");
    choices.add("No");
    final String groupName = "choices";
    for (final String choice : choices) {
        final RadioButton radioButton = new RadioButton(groupName, choice);
        radioButton.addStyleName("thing-radio-button");
        radioButton.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
            @Override
            public void onValueChange(final ValueChangeEvent<Boolean> event) {
                if (event.getValue()) {
                    submitAnswer(choice);
                }
            }
        });

        choicesPanel.add(radioButton);
    }

    updateResultPanelUi(State.WAITING_FOR_ANSWER);
    resultLabel.setText("");
}

From source file:com.ponysdk.ui.terminal.ui.PTRadioButton.java

License:Apache License

@Override
protected void addValueChangeHandler(final PTInstruction addHandler, final UIService uiService) {
    final RadioButton radioButton = cast();

    radioButton.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override/*from   ww  w .  java  2  s  . c o  m*/
        public void onValueChange(final ValueChangeEvent<Boolean> event) {
            fireInstruction(addHandler.getObjectID(), uiService, event.getValue());

            if (cast().getName() != null) {
                final PTRadioButton previouslySelected = lastSelectedRadioButtonByGroup.get(cast().getName());
                if (previouslySelected != null && !previouslySelected.equals(radioButton)) {
                    fireInstruction(previouslySelected.getObjectID(), uiService,
                            previouslySelected.cast().getValue());
                }
                lastSelectedRadioButtonByGroup.put(radioButton.getName(), PTRadioButton.this);
            }
        }
    });
}

From source file:com.sensia.tools.client.swetools.editors.sensorml.panels.CenterPanel.java

License:Open Source License

private Panel getXMLViewPanel() {
    final HorizontalPanel panel = new HorizontalPanel();
    panel.setSpacing(20);/*from  ww w. ja v a 2s.  co  m*/
    panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

    HTML title = new HTML("<b>SensorML XML:</b>");
    final Button load = new Button("Load");

    //init radio buttons choices
    final RadioButton fromLocalFileSystem = new RadioButton("myRadioGroup", "from local");
    final RadioButton fromUrl = new RadioButton("myRadioGroup", "from url");

    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.add(fromLocalFileSystem);
    hPanel.add(fromUrl);

    //container for either local file system input panel or url valueBox
    final SimplePanel fromPanel = new SimplePanel();

    //init file upload panel
    final ISourcePanel fileUploadPanel = new LocalFileSourcePanel(smlEditorProcessor, editCheckbox);

    //init url load
    final ISourcePanel urlDownloadPanel = new UrlSourcePanel(smlEditorProcessor, editCheckbox);

    //add to xml panel
    panel.add(title);
    panel.add(hPanel);
    panel.add(fromPanel);
    panel.add(load);

    //set from local file system panel as default choice
    fromLocalFileSystem.setChecked(true);
    fromPanel.add(fileUploadPanel.getPanel());

    //add listener to handle event
    load.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            if (fromLocalFileSystem.getValue()) {
                fileUploadPanel.parseContent();
            } else if (fromUrl.getValue()) {
                urlDownloadPanel.parseContent();
            }
        }
    });

    //add listener to handle from local file system handler
    fromLocalFileSystem.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            if (event.getValue()) {
                fromPanel.clear();
                fromPanel.add(fileUploadPanel.getPanel());
            }
        }
    });

    //add listener to handle from local file system handler
    fromUrl.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            if (event.getValue()) {
                fromPanel.clear();
                fromPanel.add(urlDownloadPanel.getPanel());
            }
        }
    });

    return panel;
}

From source file:de.swm.commons.mobile.client.widgets.GenericRadioButtonGroup.java

License:Apache License

@Override
public void add(Widget w) {
    assert w instanceof RadioButton : "Can only contain RadioButton widgets in RadioButtonGroup";
    RadioButton radio = (RadioButton) w;

    if (keyValueProvider != null) {
        if (this.keyValueProvider.getValue(radio.getFormValue()) != null) {
            T enumValue = this.keyValueProvider.getValue(radio.getFormValue());
            this.keyIndexMap.put(radio.getFormValue(), lastIndex);
            this.indexKeyMap.put(lastIndex, radio.getFormValue());
            radio.setText(renderer.render(enumValue));
            myFlowPanel.add(radio);/*from w w  w .  jav  a2s.com*/
            lastIndex++;
        }
    } else {
        myFlowPanel.add(radio);
    }
    if (myName != null) {
        radio.setName(myName);
    }
    radio.addValueChangeHandler(this);
}

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

License:Open Source License

private RadioButton createRadioButton(boolean horizontal, String key, String label) {
    RadioButton radioButton = new RadioButton(getId(), label);
    radioButton.getElement().setId(getId() + "_radiobutton_");

    radioButton.setValue(isSelectedOptionKey(key));

    if (getEditVetoMessage() != null) {
        radioButton.setEnabled(false);/*from www .ja  v a2s .  c  o m*/
        radioButton.setTitle(getEditVetoMessage());
    }

    Style style = radioButton.getElement().getStyle();
    style.setProperty("minWidth", "100px");
    style.setProperty("minHeight", "32px");
    style.setDisplay(Display.BLOCK);
    style.setFloat(com.google.gwt.dom.client.Style.Float.LEFT);
    style.setWidth(horizontal ? getTextBoxWidth() / 2 : getTextBoxWidth(), Unit.PX);
    style.setMarginRight(Widgets.defaultSpacing, Unit.PX);
    if (NULL_KEY.equals(key)) {
        style.setColor(Colors.greyedText);
    }

    if (!isParentMultiField()) {
        radioButton.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

            @Override
            public void onValueChange(ValueChangeEvent<Boolean> event) {
                if (fieldEditorDialogBox == null)
                    return;
                fieldEditorDialogBox.submit();
            }
        });
    }
    radioButtons.put(key, radioButton);
    return radioButton;
}

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

public SurveyStageInterface getInterface(final Callback1<FoodOperation> onComplete,
        final Callback1<Function1<FoodEntry, FoodEntry>> onIntermediateStateChange) {

    final FlowPanel content = new FlowPanel();

    FlowPanel promptPanel = WidgetFactory.createPromptPanel(
            SafeHtmlUtils.fromSafeConstant(
                    messages.brandName_promptText(SafeHtmlUtils.htmlEscape(description.toLowerCase()))),
            ShepherdTour.createTourButton(tour, BrandNamePrompt.class.getSimpleName()));
    ShepherdTour.makeShepherdTarget(promptPanel);

    content.add(promptPanel);/*from  www . ja v  a2s  .  c  o  m*/

    final Button contButton = WidgetFactory.createGreenButton(messages.brandName_continueButtonLabel(),
            new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    onComplete.call(FoodOperation.updateEncoded(new Function1<EncodedFood, EncodedFood>() {
                        @Override
                        public EncodedFood apply(EncodedFood argument) {
                            return argument.withBrand(choice);
                        }
                    }));
                }
            });

    contButton.setEnabled(false);
    contButton.getElement().setId("intake24-brand-continue-button");
    ShepherdTour.makeShepherdTarget(contButton);

    VerticalPanel panel = new VerticalPanel();

    for (final String name : brandNames) {
        RadioButton btn = new RadioButton("brand", name);
        btn.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
            @Override
            public void onValueChange(ValueChangeEvent<Boolean> event) {
                if (event.getValue())
                    choice = name;
                contButton.setEnabled(true);
            }
        });
        panel.add(btn);
    }

    panel.setSpacing(4);
    panel.addStyleName("scran24-brand-name-choice-panel");
    panel.getElement().setId("intake24-brand-choice-panel");
    ShepherdTour.makeShepherdTarget(panel);

    content.add(panel);
    content.add(WidgetFactory.createButtonsPanel(contButton));

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