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();
}
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);
}
}
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);
}
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();
}
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);
}
Aggregations