use of org.activityinfo.ui.client.widget.RadioButton in project activityinfo by bedatadriven.
the class ColumnActionSelector method updateTypeStyles.
public void updateTypeStyles(FieldTypeClass sourceType) {
for (Map.Entry<ColumnAction, RadioButton> entry : buttons.entrySet()) {
final ColumnAction columnAction = entry.getKey();
if (columnAction instanceof MapExistingAction) {
final ImportTarget target = ((MapExistingAction) columnAction).getTarget();
final FieldTypeClass targetType = target.getFormField().getType().getTypeClass();
final RadioButton button = entry.getValue();
button.removeStyleName(ColumnMappingStyles.INSTANCE.typeNotMatched());
button.removeStyleName(ColumnMappingStyles.INSTANCE.typeMatched());
if (targetType == sourceType || (sourceType == FieldTypeClass.FREE_TEXT && targetType == FieldTypeClass.REFERENCE)) {
button.addStyleName(ColumnMappingStyles.INSTANCE.typeMatched());
} else {
button.addStyleName(ColumnMappingStyles.INSTANCE.typeNotMatched());
}
}
}
}
use of org.activityinfo.ui.client.widget.RadioButton in project activityinfo by bedatadriven.
the class ColumnActionSelector method createRadioButton.
private RadioButton createRadioButton(SafeHtml label, final ColumnAction action) {
RadioButton button = new RadioButton(group, label);
button.setTabIndex(buttons.size() + 1);
if (action == IgnoreAction.INSTANCE) {
button.addStyleName(ColumnMappingStyles.INSTANCE.stateIgnored());
}
button.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
if (!Objects.equal(action, value)) {
value = action;
ValueChangeEvent.fire(ColumnActionSelector.this, value);
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
public void execute() {
updateStyles();
}
});
}
}
});
buttons.put(action, button);
return button;
}
use of org.activityinfo.ui.client.widget.RadioButton in project activityinfo by bedatadriven.
the class ColumnActionSelector method setValue.
@Override
public void setValue(ColumnAction newValue, boolean fireEvents) {
if (!Objects.equal(this.value, newValue)) {
if (newValue == null) {
// clear the old selection
buttons.get(value).setValue(false);
this.value = newValue;
} else {
this.value = newValue;
// update the UI
RadioButton button = buttons.get(newValue);
assert button != null : "No button for " + newValue;
button.setValue(true);
// update our internal value
buttons.get(newValue).setValue(true);
}
// notify listeners
if (fireEvents) {
ValueChangeEvent.fire(this, value);
}
}
}
use of org.activityinfo.ui.client.widget.RadioButton in project activityinfo by bedatadriven.
the class ColumnActionSelector method updateStyles.
public void updateStyles() {
for (Map.Entry<ColumnAction, RadioButton> entry : buttons.entrySet()) {
final ColumnAction columnAction = entry.getKey();
if (columnAction instanceof MapExistingAction) {
final ImportTarget target = ((MapExistingAction) columnAction).getTarget();
final RadioButton button = entry.getValue();
button.removeStyleName(ColumnMappingStyles.INSTANCE.stateBound());
button.removeStyleName(ColumnMappingStyles.INSTANCE.stateUnset());
if (!importModel.getMappedColumns(target.getFormField().getId()).isEmpty()) {
button.addStyleName(ColumnMappingStyles.INSTANCE.stateBound());
} else if (target.getFormField().isRequired()) {
button.addStyleName(ColumnMappingStyles.INSTANCE.stateUnset());
}
}
}
}
use of org.activityinfo.ui.client.widget.RadioButton in project activityinfo by bedatadriven.
the class CheckBoxFieldWidget method createControl.
private CheckBox createControl(String groupId, String choiceId, String label, Cardinality cardinality) {
final CheckBox checkBox;
if (cardinality == Cardinality.SINGLE) {
checkBox = new RadioButton(groupId, label);
} else {
checkBox = new CheckBox(label);
}
checkBox.setFormValue(choiceId);
return checkBox;
}
Aggregations