Search in sources :

Example 1 with RadioButton

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());
            }
        }
    }
}
Also used : ColumnAction(org.activityinfo.ui.client.component.importDialog.model.ColumnAction) ImportTarget(org.activityinfo.ui.client.component.importDialog.model.strategy.ImportTarget) FieldTypeClass(org.activityinfo.model.type.FieldTypeClass) MapExistingAction(org.activityinfo.ui.client.component.importDialog.model.MapExistingAction) RadioButton(org.activityinfo.ui.client.widget.RadioButton) Map(java.util.Map)

Example 2 with RadioButton

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;
}
Also used : RadioButton(org.activityinfo.ui.client.widget.RadioButton)

Example 3 with RadioButton

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);
        }
    }
}
Also used : RadioButton(org.activityinfo.ui.client.widget.RadioButton)

Example 4 with RadioButton

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());
            }
        }
    }
}
Also used : ColumnAction(org.activityinfo.ui.client.component.importDialog.model.ColumnAction) ImportTarget(org.activityinfo.ui.client.component.importDialog.model.strategy.ImportTarget) MapExistingAction(org.activityinfo.ui.client.component.importDialog.model.MapExistingAction) RadioButton(org.activityinfo.ui.client.widget.RadioButton) Map(java.util.Map)

Example 5 with RadioButton

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;
}
Also used : CheckBox(com.google.gwt.user.client.ui.CheckBox) RadioButton(org.activityinfo.ui.client.widget.RadioButton)

Aggregations

RadioButton (org.activityinfo.ui.client.widget.RadioButton)5 Map (java.util.Map)2 ColumnAction (org.activityinfo.ui.client.component.importDialog.model.ColumnAction)2 MapExistingAction (org.activityinfo.ui.client.component.importDialog.model.MapExistingAction)2 ImportTarget (org.activityinfo.ui.client.component.importDialog.model.strategy.ImportTarget)2 CheckBox (com.google.gwt.user.client.ui.CheckBox)1 FieldTypeClass (org.activityinfo.model.type.FieldTypeClass)1