Search in sources :

Example 6 with RadioButton

use of com.google.gwt.user.client.ui.RadioButton in project data-access by pentaho.

the class MetadataImportDialogController method promptImportMetadata.

/**
 * Shows a promt dialog
 *
 * @param title
 * @param message
 * @param radioDSWLabel
 * @param radioMetaLabel
 * @param onResulthandler
 */
private void promptImportMetadata(final String title, final String message, final String radioDSWLabel, final String radioMetaLabel, final AsyncCallback<Boolean> onResulthandler) {
    final VerticalPanel panel = new VerticalPanel();
    // $NON-NLS-1$
    panel.add(new Label(message));
    VerticalPanel vp = new VerticalPanel();
    HorizontalPanel hp = new HorizontalPanel();
    hp.getElement().getStyle().setMarginBottom(10, Style.Unit.PX);
    hp.getElement().getStyle().setMarginTop(10, Style.Unit.PX);
    final RadioButton dswRadio = new RadioButton("importMetadata");
    RadioButton metadataRadio = new RadioButton("importMetadata");
    dswRadio.setEnabled(true);
    dswRadio.setValue(true);
    hp.add(dswRadio);
    hp.add(new Label(radioDSWLabel));
    vp.add(hp);
    HorizontalPanel hp2 = new HorizontalPanel();
    hp2.add(metadataRadio);
    hp2.add(new Label(radioMetaLabel));
    vp.add(hp2);
    panel.add(vp);
    XulPromptBox promptBox = new GwtPromptBox() {

        @Override
        public Panel getDialogContents() {
            return panel;
        }

        @Override
        public int open() {
            super.show();
            dswRadio.setFocus(true);
            return 0;
        }

        @Override
        public Panel getButtonPanel() {
            Panel button = super.getButtonPanel();
            return button;
        }
    };
    promptBox.setTitle(title);
    promptBox.setAcceptLabel(resBundle.getString("importDialog.DIALOG_OK", "OK"));
    promptBox.setCancelLabel(resBundle.getString("importDialog.DIALOG_Cancel", "Cancel"));
    promptBox.addDialogCallback(new XulDialogCallback<String>() {

        @Override
        public void onClose(XulComponent component, Status status, String value) {
            if (status == Status.CANCEL) {
                onImportCancel();
                reShowDialog();
                return;
            }
            if (onResulthandler != null) {
                onResulthandler.onSuccess(dswRadio.getValue());
            }
        }

        @Override
        public void onError(XulComponent xulComponent, Throwable throwable) {
            onResulthandler.onFailure(throwable);
        }
    });
    promptBox.setWidth(460);
    promptBox.setHeight(140);
    promptBox.open();
}
Also used : HttpStatus(org.apache.http.HttpStatus) Label(com.google.gwt.user.client.ui.Label) XulLabel(org.pentaho.ui.xul.components.XulLabel) RadioButton(com.google.gwt.user.client.ui.RadioButton) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) RootPanel(com.google.gwt.user.client.ui.RootPanel) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) FormPanel(com.google.gwt.user.client.ui.FormPanel) Panel(com.google.gwt.user.client.ui.Panel) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) GwtPromptBox(org.pentaho.ui.xul.gwt.tags.GwtPromptBox) XulPromptBox(org.pentaho.ui.xul.components.XulPromptBox) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) XulComponent(org.pentaho.ui.xul.XulComponent)

Example 7 with RadioButton

use of com.google.gwt.user.client.ui.RadioButton in project ovirt-engine by oVirt.

the class HostPopupView method createSpmControls.

private void createSpmControls(final HostModel object) {
    Row labelRow = (Row) spmContainer.getWidget(0);
    spmContainer.clear();
    spmContainer.add(labelRow);
    Iterable<?> items = object.getSpmPriority().getItems();
    if (items == null) {
        return;
    }
    // Recreate SPM related controls.
    for (Object item : items) {
        @SuppressWarnings("unchecked") final EntityModel<Integer> model = (EntityModel<Integer>) item;
        // $//$NON-NLS-1$
        RadioButton rb = new RadioButton("spm");
        rb.setText(model.getTitle());
        Element labelElement = (Element) rb.getElement().getChild(1);
        labelElement.addClassName(style.patternFlyRadio());
        rb.setValue(object.getSpmPriority().getSelectedItem() == model);
        rb.addValueChangeHandler(e -> object.getSpmPriority().setSelectedItem(model));
        Row row = new Row();
        Column column = new Column(ColumnSize.SM_12, rb);
        row.add(column);
        spmContainer.add(row);
    }
}
Also used : Column(org.gwtbootstrap3.client.ui.Column) Element(com.google.gwt.dom.client.Element) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) Row(org.gwtbootstrap3.client.ui.Row) RadioButton(com.google.gwt.user.client.ui.RadioButton)

Example 8 with RadioButton

use of com.google.gwt.user.client.ui.RadioButton in project ovirt-engine by oVirt.

the class RadioGroup method addValue.

private void addValue(final K value) {
    if (value == null) {
        // $NON-NLS-1$
        throw new IllegalArgumentException("null value is not permited");
    }
    if (buttons.containsKey(value)) {
        // $NON-NLS-1$
        throw new IllegalArgumentException("Duplicate value: " + value);
    }
    RadioButton radioButton = new RadioButton(groupString, SafeHtmlUtils.fromTrustedString(renderer.render(value))) {

        @Override
        public void onBrowserEvent(Event event) {
            super.onBrowserEvent(event);
            boolean value = getValue();
            // and it causes the event not to be fired although it should be.
            if (Event.ONCLICK == DOM.eventGetType(event) && value && this != buttons.get(selectedValue)) {
                ValueChangeEvent.fire(this, value);
            }
        }
    };
    radioButton.addValueChangeHandler(event -> {
        if (event.getValue()) {
            setValue(value, true);
        }
    });
    radioButton.getElement().getStyle().setMarginRight(20, Unit.PX);
    buttons.put(value, radioButton);
    FlowPanel panel = new FlowPanel();
    panels.put(value, panel);
    panel.add(radioButton);
    wrapperPanel.add(panel);
}
Also used : FlowPanel(com.google.gwt.user.client.ui.FlowPanel) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) KeyUpEvent(com.google.gwt.event.dom.client.KeyUpEvent) Event(com.google.gwt.user.client.Event) KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) KeyPressEvent(com.google.gwt.event.dom.client.KeyPressEvent) RadioButton(com.google.gwt.user.client.ui.RadioButton)

Example 9 with RadioButton

use of com.google.gwt.user.client.ui.RadioButton in project webprotege by protegeproject.

the class ChoiceFieldRadioButtonEditor method setChoices.

@Override
public void setChoices(List<ChoiceDescriptor> choices) {
    container.clear();
    choiceButtons.clear();
    nameCounter++;
    for (ChoiceDescriptor descriptor : choices) {
        RadioButton radioButton = new RadioButton("Choice" + nameCounter, new SafeHtmlBuilder().appendHtmlConstant(descriptor.getLabel()).toSafeHtml());
        radioButton.addStyleName(WebProtegeClientBundle.BUNDLE.style().noFocusBorder());
        radioButton.addValueChangeHandler(radioButtonValueChangedHandler);
        radioButton.addFocusHandler(event -> {
            radioButton.addStyleName(WebProtegeClientBundle.BUNDLE.style().focusBorder());
            radioButton.removeStyleName(WebProtegeClientBundle.BUNDLE.style().noFocusBorder());
        });
        radioButton.addBlurHandler(event -> {
            radioButton.addStyleName(WebProtegeClientBundle.BUNDLE.style().noFocusBorder());
            radioButton.removeStyleName(WebProtegeClientBundle.BUNDLE.style().focusBorder());
        });
        container.add(radioButton);
        choiceButtons.put(radioButton, descriptor);
    }
    selectDefaultChoice();
}
Also used : RadioButton(com.google.gwt.user.client.ui.RadioButton) ChoiceDescriptor(edu.stanford.bmir.protege.web.shared.form.field.ChoiceDescriptor) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder)

Example 10 with RadioButton

use of com.google.gwt.user.client.ui.RadioButton in project gwt-test-utils by gwt-test-utils.

the class RadioButtonTest method click_ClickHandler.

@Test
public void click_ClickHandler() {
    // Given
    tested = false;
    RadioButton r = new RadioButton("myRadioGroup", "foo");
    r.addClickHandler(event -> tested = !tested);
    // Preconditions
    assertThat(tested).isEqualTo(false);
    // When
    Browser.click(r);
    // Then
    assertThat(tested).isEqualTo(true);
    assertThat(r.getValue()).isEqualTo(true);
}
Also used : RadioButton(com.google.gwt.user.client.ui.RadioButton) Test(org.junit.Test)

Aggregations

RadioButton (com.google.gwt.user.client.ui.RadioButton)31 Test (org.junit.Test)11 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)4 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)4 Label (com.google.gwt.user.client.ui.Label)4 Widget (com.google.gwt.user.client.ui.Widget)4 MockValueChangeHandler (com.googlecode.gwt.MockValueChangeHandler)4 InputElement (com.google.gwt.dom.client.InputElement)3 Element (com.google.gwt.dom.client.Element)2 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)2 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)2 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)2 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)2 EntityModelCheckBoxEditor (org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor)2 EntityModelRadioButtonEditor (org.ovirt.engine.ui.common.widget.editor.generic.EntityModelRadioButtonEditor)2 StringEntityModelTextAreaLabelEditor (org.ovirt.engine.ui.common.widget.editor.generic.StringEntityModelTextAreaLabelEditor)2 AgreementInfo (com.google.gerrit.client.info.AgreementInfo)1 SmallHeading (com.google.gerrit.client.ui.SmallHeading)1 HeadingElement (com.google.gwt.dom.client.HeadingElement)1 Node (com.google.gwt.dom.client.Node)1