use of de.symeda.sormas.app.component.controls.ControlPropertyField in project SORMAS-Project by hzi-braunschweig.
the class ConfirmationInputDialog method initializeContentView.
@Override
protected void initializeContentView(ViewDataBinding rootBinding, ViewDataBinding buttonPanelBinding) {
getPositiveButton().setEnabled(false);
((ControlTextEditField) getRoot().findViewById(R.id.confirmation_input)).addValueChangedListener(new ValueChangeListener() {
@Override
public void onChange(ControlPropertyField field) {
if (field.getValue() != null) {
getPositiveButton().setEnabled(wordToType.compareToIgnoreCase(field.getValue().toString()) == 0);
} else {
getPositiveButton().setEnabled(false);
}
}
});
}
use of de.symeda.sormas.app.component.controls.ControlPropertyField in project SORMAS-Project by hzi-braunschweig.
the class BaseActivity method extendHelpString.
private void extendHelpString(StringBuilder sb, ViewGroup parent) {
if (parent == null)
return;
for (int i = 0; i < parent.getChildCount(); i++) {
View child = parent.getChildAt(i);
if (child instanceof ControlPropertyField && child.getVisibility() == View.VISIBLE) {
ControlPropertyField propertyField = (ControlPropertyField) child;
if (propertyField.getCaption() != null) {
sb.append("<b>").append(Html.escapeHtml(propertyField.getCaption())).append("</b>").append("<br>");
if (!StringUtils.isEmpty(propertyField.getDescription())) {
sb.append(Html.escapeHtml(propertyField.getDescription()));
} else {
sb.append(Html.escapeHtml("-"));
}
sb.append("<br><br>");
}
} else if (child instanceof ViewGroup) {
extendHelpString(sb, (ViewGroup) child);
}
}
}
use of de.symeda.sormas.app.component.controls.ControlPropertyField in project SORMAS-Project by hzi-braunschweig.
the class SymptomsEditFragment method initOnsetSymptomField.
private void initOnsetSymptomField(FragmentSymptomsEditLayoutBinding contentBinding) {
final ControlSpinnerField onsetSymptomField = contentBinding.symptomsOnsetSymptom;
final ControlDateField onsetDateField = contentBinding.symptomsOnsetDate;
List<Item> initialSpinnerItems = new ArrayList<>();
for (ControlSwitchField symptomField : symptomFields) {
symptomField.addValueChangedListener(new ValueChangeListener() {
@Override
public void onChange(ControlPropertyField field) {
Item item = new Item(field.getCaption(), field.getCaption());
int position = onsetSymptomField.getPositionOf(item);
if (SymptomState.YES.equals(field.getValue())) {
if (position == -1) {
onsetSymptomField.getAdapter().add(item);
}
onsetDateField.setEnabled(true);
} else {
if (position != -1) {
onsetSymptomField.getAdapter().remove(onsetSymptomField.getAdapter().getItem(position));
}
onsetDateField.setEnabled(isAnySymptomSetToYes());
}
// first is "empty item"
onsetSymptomField.setEnabled(onsetSymptomField.getAdapter().getCount() > 1);
}
});
if (SymptomState.YES.equals(symptomField.getValue())) {
initialSpinnerItems.add(new Item(symptomField.getCaption(), symptomField.getCaption()));
}
}
onsetSymptomField.initializeSpinner(DataUtils.addEmptyItem(initialSpinnerItems));
// first is "empty item"
onsetSymptomField.setEnabled(onsetSymptomField.getAdapter().getCount() > 1);
onsetDateField.setEnabled(isAnySymptomSetToYes());
}
use of de.symeda.sormas.app.component.controls.ControlPropertyField in project SORMAS-Project by hzi-braunschweig.
the class CampaignFormDataFragmentUtils method handleDependingOn.
public static void handleDependingOn(Map<String, ControlPropertyField> fieldMap, CampaignFormElement campaignFormElement, ControlPropertyField dynamicField) {
final String dependingOn = campaignFormElement.getDependingOn();
final String[] dependingOnValues = campaignFormElement.getDependingOnValues();
if (dependingOn != null && dependingOnValues != null) {
ControlPropertyField controlPropertyField = fieldMap.get(dependingOn);
setVisibilityDependency(dynamicField, dependingOnValues, controlPropertyField.getValue());
final ControlPropertyField finalDynamicField = dynamicField;
controlPropertyField.addValueChangedListener(field -> setVisibilityDependency(finalDynamicField, dependingOnValues, field.getValue()));
}
}
use of de.symeda.sormas.app.component.controls.ControlPropertyField in project SORMAS-Project by hzi-braunschweig.
the class FieldVisibilityAndAccessHelper method setFieldVisibilitiesAndAccesses.
public static void setFieldVisibilitiesAndAccesses(Class<?> dtoClass, ViewGroup viewGroup, FieldVisibilityCheckers visibilityCheckers, UiFieldAccessCheckers accessCheckers) {
for (int i = 0; i < viewGroup.getChildCount(); i++) {
View child = viewGroup.getChildAt(i);
if (child instanceof ControlPropertyField) {
String propertyId = ((ControlPropertyField) child).getSubPropertyId();
boolean visibleAllowed = isVisibleAllowed(dtoClass, propertyId, visibilityCheckers);
child.setVisibility(visibleAllowed && child.getVisibility() == VISIBLE ? VISIBLE : GONE);
if (child.isEnabled() && !isFieldAccessible(dtoClass, propertyId, accessCheckers)) {
setFieldInaccessibleValue(child);
}
} else if (child instanceof ViewGroup) {
setFieldVisibilitiesAndAccesses(dtoClass, (ViewGroup) child, visibilityCheckers, accessCheckers);
}
}
}
Aggregations