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