Search in sources :

Example 1 with RadioGroup

use of com.extjs.gxt.ui.client.widget.form.RadioGroup in project activityinfo by bedatadriven.

the class ClusteringOptionsWidget method buildForm.

private void buildForm(Collection<AdminLevelDTO> adminLevels) {
    radios = Lists.newArrayList();
    radios.add(new ClusteringRadio(I18N.CONSTANTS.none(), new NoClustering()));
    radios.add(new ClusteringRadio(I18N.CONSTANTS.automatic(), new AutomaticClustering()));
    for (AdminLevelDTO level : adminLevels) {
        AdministrativeLevelClustering clustering = new AdministrativeLevelClustering();
        clustering.getAdminLevels().add(level.getId());
        radios.add(new ClusteringRadio(level.getName(), clustering));
    }
    radioGroup = new RadioGroup();
    radioGroup.setOrientation(Orientation.VERTICAL);
    radioGroup.setStyleAttribute("padding", "5px");
    for (ClusteringRadio radio : radios) {
        radioGroup.add(radio);
        if (radio.getClustering().equals(value)) {
            radioGroup.setValue(radio);
        }
    }
    add(radioGroup);
    radioGroup.addListener(Events.Change, new Listener<FieldEvent>() {

        @Override
        public void handleEvent(FieldEvent be) {
            ClusteringRadio radio = (ClusteringRadio) radioGroup.getValue();
            setValue(radio.getClustering(), true);
        }
    });
    layout();
// unmask();
}
Also used : AdministrativeLevelClustering(org.activityinfo.legacy.shared.reports.model.clustering.AdministrativeLevelClustering) RadioGroup(com.extjs.gxt.ui.client.widget.form.RadioGroup) AdminLevelDTO(org.activityinfo.legacy.shared.model.AdminLevelDTO) FieldEvent(com.extjs.gxt.ui.client.event.FieldEvent) NoClustering(org.activityinfo.legacy.shared.reports.model.clustering.NoClustering) AutomaticClustering(org.activityinfo.legacy.shared.reports.model.clustering.AutomaticClustering)

Example 2 with RadioGroup

use of com.extjs.gxt.ui.client.widget.form.RadioGroup in project activityinfo by bedatadriven.

the class OnlyValidFieldBinding method updateField.

@Override
public void updateField(boolean updateOriginalValue) {
    if (field instanceof RadioGroup) {
        // special handling for radio group
        RadioGroup radioGroup = (RadioGroup) field;
        Object val = onConvertModelValue(model.get(property));
        // hack : boolean represented with radio buttons : order is important - true is first button, false is second button
        if (val instanceof Boolean) {
            Field nestedField = radioGroup.get((Boolean) val ? 0 : 1);
            nestedField.setValue(Boolean.TRUE);
            return;
        }
    // we do not support other cases right now, fallback to default implementation
    }
    super.updateField(updateOriginalValue);
}
Also used : Field(com.extjs.gxt.ui.client.widget.form.Field) RadioGroup(com.extjs.gxt.ui.client.widget.form.RadioGroup)

Example 3 with RadioGroup

use of com.extjs.gxt.ui.client.widget.form.RadioGroup in project activityinfo by bedatadriven.

the class EmailDialog method createLayout.

public void createLayout() {
    FormPanel form = new FormPanel();
    form.setHeaderVisible(false);
    form.setLabelWidth(100);
    setLayout(new FitLayout());
    add(form);
    none = new Radio();
    none.setBoxLabel(I18N.CONSTANTS.none());
    weekly = new Radio();
    weekly.setBoxLabel(I18N.CONSTANTS.weekly());
    weekly.setValue(true);
    monthly = new Radio();
    monthly.setBoxLabel(I18N.CONSTANTS.monthly());
    emailFrequency = new RadioGroup();
    emailFrequency.setFieldLabel(I18N.CONSTANTS.emailFrequency());
    emailFrequency.setOrientation(Orientation.VERTICAL);
    emailFrequency.add(none);
    emailFrequency.add(weekly);
    emailFrequency.add(monthly);
    form.add(emailFrequency);
    dayOfWeek = new MappingComboBox<Integer>();
    dayOfWeek.setAllowBlank(false);
    dayOfWeek.setEditable(false);
    dayOfWeek.setFieldLabel(I18N.CONSTANTS.dayOfWeek());
    String[] weekDays = LocaleInfo.getCurrentLocale().getDateTimeConstants().weekdays();
    for (int i = 0; i != weekDays.length; ++i) {
        dayOfWeek.add(i + 1, weekDays[i]);
    }
    form.add(dayOfWeek);
    dayOfMonth = new MappingComboBox<Integer>();
    dayOfMonth.setEditable(false);
    dayOfMonth.hide();
    dayOfMonth.setFieldLabel(I18N.CONSTANTS.dayOfMonth());
    for (int i = 1; i <= 31; i++) {
        dayOfMonth.add(i, String.valueOf(i));
    }
    form.add(dayOfMonth);
    emailFrequency.addListener(Events.Change, new Listener<BaseEvent>() {

        @Override
        public void handleEvent(BaseEvent be) {
            if (weekly.getValue()) {
                showWeek();
            } else if (monthly.getValue()) {
                showMonth();
            }
        }
    });
}
Also used : FormPanel(com.extjs.gxt.ui.client.widget.form.FormPanel) RadioGroup(com.extjs.gxt.ui.client.widget.form.RadioGroup) BaseEvent(com.extjs.gxt.ui.client.event.BaseEvent) Radio(com.extjs.gxt.ui.client.widget.form.Radio) FitLayout(com.extjs.gxt.ui.client.widget.layout.FitLayout)

Example 4 with RadioGroup

use of com.extjs.gxt.ui.client.widget.form.RadioGroup in project activityinfo by bedatadriven.

the class AdminLevelPanel method showOptions.

protected void showOptions(List<AdminLevelDTO> levels) {
    removeAll();
    if (radioGroup != null) {
        radioGroup.removeAllListeners();
    }
    radioGroup = new RadioGroup();
    boolean missingPolygons = false;
    for (AdminLevelDTO level : levels) {
        Radio radio = new Radio();
        radio.setBoxLabel(level.getName());
        radio.setEnabled(level.getPolygons());
        radio.setData("adminLevelId", level.getId());
        radioGroup.add(radio);
        add(radio);
        if (!level.getPolygons()) {
            missingPolygons = true;
        }
    }
    if (missingPolygons) {
        addMissingPolygonMessage();
    }
    radioGroup.addListener(Events.Change, new Listener<BaseEvent>() {

        @Override
        public void handleEvent(BaseEvent be) {
            AdminLevelPanel.this.fireEvent(Events.Change, new BaseEvent(Events.Change));
        }
    });
    layout();
}
Also used : RadioGroup(com.extjs.gxt.ui.client.widget.form.RadioGroup) AdminLevelDTO(org.activityinfo.legacy.shared.model.AdminLevelDTO) BaseEvent(com.extjs.gxt.ui.client.event.BaseEvent) Radio(com.extjs.gxt.ui.client.widget.form.Radio)

Example 5 with RadioGroup

use of com.extjs.gxt.ui.client.widget.form.RadioGroup in project activityinfo by bedatadriven.

the class OnlyValidFieldBinding method updateModel.

@Override
public void updateModel() {
    if (field.isValid()) {
        if (field instanceof RadioGroup) {
            // special handing for radio group
            RadioGroup radioGroup = (RadioGroup) field;
            // hack : boolean represented with radio buttons : order is important - true is first button, false is second button
            if ("classicView".equals(property)) {
                Field nestedField = radioGroup.getValue();
                int selectedIndex = radioGroup.getAll().indexOf(nestedField);
                boolean val = selectedIndex == 0;
                if (store != null) {
                    Record r = store.getRecord(model);
                    if (r != null) {
                        r.setValid(property, field.isValid());
                        r.set(property, val);
                    }
                } else {
                    model.set(property, val);
                }
                return;
            }
        }
        super.updateModel();
    }
}
Also used : Field(com.extjs.gxt.ui.client.widget.form.Field) RadioGroup(com.extjs.gxt.ui.client.widget.form.RadioGroup) Record(com.extjs.gxt.ui.client.store.Record)

Aggregations

RadioGroup (com.extjs.gxt.ui.client.widget.form.RadioGroup)5 BaseEvent (com.extjs.gxt.ui.client.event.BaseEvent)2 Field (com.extjs.gxt.ui.client.widget.form.Field)2 Radio (com.extjs.gxt.ui.client.widget.form.Radio)2 AdminLevelDTO (org.activityinfo.legacy.shared.model.AdminLevelDTO)2 FieldEvent (com.extjs.gxt.ui.client.event.FieldEvent)1 Record (com.extjs.gxt.ui.client.store.Record)1 FormPanel (com.extjs.gxt.ui.client.widget.form.FormPanel)1 FitLayout (com.extjs.gxt.ui.client.widget.layout.FitLayout)1 AdministrativeLevelClustering (org.activityinfo.legacy.shared.reports.model.clustering.AdministrativeLevelClustering)1 AutomaticClustering (org.activityinfo.legacy.shared.reports.model.clustering.AutomaticClustering)1 NoClustering (org.activityinfo.legacy.shared.reports.model.clustering.NoClustering)1