use of com.vaadin.v7.ui.TextArea in project SORMAS-Project by hzi-braunschweig.
the class ImmunizationDataForm method addFields.
@SuppressWarnings("deprecation")
@Override
protected void addFields() {
TextField immunizationUuuidField = addField(ImmunizationDto.UUID, TextField.class);
immunizationUuuidField.setReadOnly(true);
TextField externalIdField = addField(ImmunizationDto.EXTERNAL_ID, TextField.class);
style(externalIdField, ERROR_COLOR_PRIMARY);
addField(ImmunizationDto.REPORT_DATE, DateField.class);
addField(ImmunizationDto.REPORTING_USER, ComboBox.class);
ComboBox cbDisease = addDiseaseField(ImmunizationDto.DISEASE, false);
addField(ImmunizationDto.DISEASE_DETAILS, TextField.class);
ComboBox meansOfImmunizationField = addField(ImmunizationDto.MEANS_OF_IMMUNIZATION, ComboBox.class);
addField(ImmunizationDto.MEANS_OF_IMMUNIZATION_DETAILS, TextField.class);
overwriteImmunizationManagementStatus = addCustomField(OVERWRITE_IMMUNIZATION_MANAGEMENT_STATUS, Boolean.class, CheckBox.class);
overwriteImmunizationManagementStatus.addStyleName(VSPACE_3);
ComboBox managementStatusField = addField(ImmunizationDto.IMMUNIZATION_MANAGEMENT_STATUS, ComboBox.class);
managementStatusField.setNullSelectionAllowed(false);
managementStatusField.setEnabled(false);
ComboBox immunizationStatusField = addField(ImmunizationDto.IMMUNIZATION_STATUS, ComboBox.class);
immunizationStatusField.setEnabled(false);
addField(ImmunizationDto.PREVIOUS_INFECTION, NullableOptionGroup.class);
addField(ImmunizationDto.LAST_INFECTION_DATE, DateField.class);
ComboBox country = addInfrastructureField(ImmunizationDto.COUNTRY);
country.addItems(FacadeProvider.getCountryFacade().getAllActiveAsReference());
TextArea descriptionField = addField(ImmunizationDto.ADDITIONAL_DETAILS, TextArea.class, new ResizableTextAreaWrapper<>());
descriptionField.setRows(2);
descriptionField.setDescription(I18nProperties.getPrefixDescription(ImmunizationDto.I18N_PREFIX, ImmunizationDto.ADDITIONAL_DETAILS, "") + "\n" + I18nProperties.getDescription(Descriptions.descGdpr));
Label jurisdictionHeadingLabel = new Label(I18nProperties.getString(Strings.headingResponsibleJurisdiction));
jurisdictionHeadingLabel.addStyleName(H3);
getContent().addComponent(jurisdictionHeadingLabel, RESPONSIBLE_JURISDICTION_HEADING_LOC);
ComboBox responsibleRegion = addInfrastructureField(ImmunizationDto.RESPONSIBLE_REGION);
responsibleRegion.setRequired(true);
ComboBox responsibleDistrictCombo = addInfrastructureField(ImmunizationDto.RESPONSIBLE_DISTRICT);
responsibleDistrictCombo.setRequired(true);
ComboBox responsibleCommunityCombo = addInfrastructureField(ImmunizationDto.RESPONSIBLE_COMMUNITY);
responsibleCommunityCombo.setNullSelectionAllowed(true);
responsibleCommunityCombo.addStyleName(SOFT_REQUIRED);
InfrastructureFieldsHelper.initInfrastructureFields(responsibleRegion, responsibleDistrictCombo, responsibleCommunityCombo);
facilityTypeGroup = ComboBoxHelper.createComboBoxV7();
facilityTypeGroup.setId("typeGroup");
facilityTypeGroup.setCaption(I18nProperties.getCaption(Captions.Facility_typeGroup));
facilityTypeGroup.setWidth(100, Unit.PERCENTAGE);
facilityTypeGroup.addItems(FacilityTypeGroup.values());
getContent().addComponent(facilityTypeGroup, FACILITY_TYPE_GROUP_LOC);
ComboBox facilityType = addField(ImmunizationDto.FACILITY_TYPE);
ComboBox facilityCombo = addInfrastructureField(ImmunizationDto.HEALTH_FACILITY);
facilityCombo.setImmediate(true);
TextField facilityDetails = addField(ImmunizationDto.HEALTH_FACILITY_DETAILS, TextField.class);
facilityDetails.setVisible(false);
DateField startDate = addField(ImmunizationDto.START_DATE, DateField.class);
DateField endDate = addDateField(ImmunizationDto.END_DATE, DateField.class, -1);
DateComparisonValidator.addStartEndValidators(startDate, endDate);
DateField validFrom = addDateField(ImmunizationDto.VALID_FROM, DateField.class, -1);
DateField validUntil = addDateField(ImmunizationDto.VALID_UNTIL, DateField.class, -1);
DateComparisonValidator.addStartEndValidators(validFrom, validUntil);
MeansOfImmunization meansOfImmunizationValue = (MeansOfImmunization) meansOfImmunizationField.getValue();
boolean isVaccinationVisibleInitial = shouldShowVaccinationFields(meansOfImmunizationValue);
Label vaccinationHeadingLabel = new Label(I18nProperties.getString(Strings.headingVaccination));
vaccinationHeadingLabel.addStyleName(H3);
getContent().addComponent(vaccinationHeadingLabel, VACCINATION_HEADING_LOC);
vaccinationHeadingLabel.setVisible(isVaccinationVisibleInitial);
Field numberOfDosesField = addField(ImmunizationDto.NUMBER_OF_DOSES);
numberOfDosesField.addValidator(new NumberValidator(I18nProperties.getValidationError(Validations.vaccineDosesFormat), 1, 10, false));
numberOfDosesField.setVisible(isVaccinationVisibleInitial);
Field numberOfDosesDetailsField = addField(ImmunizationDto.NUMBER_OF_DOSES_DETAILS);
numberOfDosesDetailsField.setReadOnly(true);
numberOfDosesDetailsField.setVisible(isVaccinationVisibleInitial && getValue().getNumberOfDosesDetails() != null);
VaccinationsField vaccinationsField = addField(ImmunizationDto.VACCINATIONS, VaccinationsField.class);
FieldHelper.setVisibleWhen(getFieldGroup(), ImmunizationDto.VACCINATIONS, ImmunizationDto.MEANS_OF_IMMUNIZATION, Arrays.asList(MeansOfImmunization.VACCINATION, MeansOfImmunization.VACCINATION_RECOVERY), false);
cbDisease.addValueChangeListener(e -> vaccinationsField.setDisease((Disease) cbDisease.getValue()));
Label recoveryHeadingLabel = new Label(I18nProperties.getString(Strings.headingRecovery));
recoveryHeadingLabel.addStyleName(H3);
getContent().addComponent(recoveryHeadingLabel, RECOVERY_HEADING_LOC);
recoveryHeadingLabel.setVisible(shouldShowRecoveryFields(meansOfImmunizationValue));
DateField positiveTestResultDate = addField(ImmunizationDto.POSITIVE_TEST_RESULT_DATE, DateField.class);
DateField recoveryDate = addField(ImmunizationDto.RECOVERY_DATE, DateField.class);
addField(ImmunizationDto.DELETION_REASON);
addField(ImmunizationDto.OTHER_DELETION_REASON, TextArea.class).setRows(3);
setVisible(false, ImmunizationDto.DELETION_REASON, ImmunizationDto.OTHER_DELETION_REASON);
Button linkImmunizationToCaseButton;
if (relatedCase != null) {
linkImmunizationToCaseButton = ButtonHelper.createButton(Captions.openLinkedCaseToImmunizationButton, e -> ControllerProvider.getCaseController().navigateToCase(relatedCase.getUuid()), ValoTheme.BUTTON_PRIMARY, FORCE_CAPTION);
} else {
linkImmunizationToCaseButton = ButtonHelper.createButton(Captions.linkImmunizationToCaseButton, e -> buildAndOpenSearchSpecificCaseWindow(), ValoTheme.BUTTON_PRIMARY, FORCE_CAPTION);
}
getContent().addComponent(linkImmunizationToCaseButton, LINK_IMMUNIZATION_TO_CASE_BTN_LOC);
linkImmunizationToCaseButton.setVisible(shouldShowRecoveryFields(meansOfImmunizationValue));
// Set initial visibilities & accesses
initializeVisibilitiesAndAllowedVisibilities();
setRequired(true, ImmunizationDto.REPORT_DATE, ImmunizationDto.DISEASE, ImmunizationDto.MEANS_OF_IMMUNIZATION);
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(ImmunizationDto.DISEASE_DETAILS), ImmunizationDto.DISEASE, Arrays.asList(Disease.OTHER), true);
FieldHelper.setRequiredWhen(getFieldGroup(), ImmunizationDto.DISEASE, Arrays.asList(ImmunizationDto.DISEASE_DETAILS), Arrays.asList(Disease.OTHER));
FieldHelper.setVisibleWhen(getFieldGroup(), Collections.singletonList(ImmunizationDto.MEANS_OF_IMMUNIZATION_DETAILS), ImmunizationDto.MEANS_OF_IMMUNIZATION, Collections.singletonList(MeansOfImmunization.OTHER), true);
overwriteImmunizationManagementStatus.addValueChangeListener(valueChangeEvent -> {
boolean selectedValue = (boolean) valueChangeEvent.getProperty().getValue();
if (!selectedValue) {
ImmunizationManagementStatus value = getValue().getImmunizationManagementStatus();
managementStatusField.setValue(value);
}
managementStatusField.setEnabled(selectedValue);
ignoreMeansOfImmunizationChange = selectedValue;
});
meansOfImmunizationField.addValueChangeListener(valueChangeEvent -> {
MeansOfImmunization meansOfImmunization = (MeansOfImmunization) valueChangeEvent.getProperty().getValue();
boolean isVaccinationVisible = shouldShowVaccinationFields(meansOfImmunization);
boolean isRecoveryVisible = shouldShowRecoveryFields(meansOfImmunization);
if (!ignoreMeansOfImmunizationChange) {
if (MeansOfImmunization.RECOVERY.equals(meansOfImmunization) || MeansOfImmunization.OTHER.equals(meansOfImmunization)) {
managementStatusField.setValue(ImmunizationManagementStatus.COMPLETED);
if (CollectionUtils.isNotEmpty(vaccinationsField.getValue())) {
VaadinUiUtil.showConfirmationPopup(I18nProperties.getString(Strings.headingDeleteVaccinations), new Label(I18nProperties.getString(Strings.messageDeleteImmunizationVaccinations)), questionWindow -> {
ConfirmationComponent confirmationComponent = new ConfirmationComponent(false) {
private static final long serialVersionUID = 1L;
@Override
protected void onConfirm() {
vaccinationsField.clear();
previousMeansOfImmunization = meansOfImmunization;
if (!isVaccinationVisible) {
numberOfDosesField.setValue(null);
}
questionWindow.close();
}
@Override
protected void onCancel() {
ignoreMeansOfImmunizationChange = true;
meansOfImmunizationField.setValue(previousMeansOfImmunization);
ignoreMeansOfImmunizationChange = false;
questionWindow.close();
}
};
confirmationComponent.getConfirmButton().setCaption(I18nProperties.getCaption(Captions.actionConfirm));
confirmationComponent.getCancelButton().setCaption(I18nProperties.getCaption(Captions.actionCancel));
return confirmationComponent;
}, null);
} else {
previousMeansOfImmunization = meansOfImmunization;
}
} else {
previousMeansOfImmunization = meansOfImmunization;
}
}
vaccinationHeadingLabel.setVisible(isVaccinationVisible);
numberOfDosesField.setVisible(isVaccinationVisible);
numberOfDosesDetailsField.setVisible(isVaccinationVisible && getValue().getNumberOfDosesDetails() != null);
recoveryHeadingLabel.setVisible(isRecoveryVisible);
positiveTestResultDate.setVisible(isRecoveryVisible);
recoveryDate.setVisible(isRecoveryVisible);
});
managementStatusField.addValueChangeListener(valueChangeEvent -> {
ImmunizationManagementStatus managementStatusValue = (ImmunizationManagementStatus) valueChangeEvent.getProperty().getValue();
switch(managementStatusValue) {
case SCHEDULED:
case ONGOING:
immunizationStatusField.setValue(ImmunizationStatus.PENDING);
break;
case COMPLETED:
immunizationStatusField.setValue(ImmunizationStatus.ACQUIRED);
break;
case CANCELED:
immunizationStatusField.setValue(ImmunizationStatus.NOT_ACQUIRED);
break;
default:
break;
}
});
setReadOnly(true, ImmunizationDto.REPORTING_USER);
FieldHelper.setVisibleWhen(getFieldGroup(), ImmunizationDto.LAST_INFECTION_DATE, ImmunizationDto.PREVIOUS_INFECTION, Collections.singletonList(YesNoUnknown.YES), true);
meansOfImmunizationField.addValueChangeListener(e -> {
if (shouldShowRecoveryFields((MeansOfImmunization) e.getProperty().getValue())) {
positiveTestResultDate.setVisible(true);
recoveryDate.setVisible(true);
linkImmunizationToCaseButton.setVisible(true);
} else {
positiveTestResultDate.setVisible(false);
recoveryDate.setVisible(false);
linkImmunizationToCaseButton.setVisible(false);
}
});
responsibleDistrictCombo.addValueChangeListener(e -> {
FieldHelper.removeItems(facilityCombo);
DistrictReferenceDto districtDto = (DistrictReferenceDto) e.getProperty().getValue();
if (districtDto != null && facilityType.getValue() != null) {
FieldHelper.updateItems(facilityCombo, FacadeProvider.getFacilityFacade().getActiveFacilitiesByDistrictAndType(districtDto, (FacilityType) facilityType.getValue(), true, false));
}
});
responsibleCommunityCombo.addValueChangeListener(e -> {
FieldHelper.removeItems(facilityCombo);
CommunityReferenceDto communityDto = (CommunityReferenceDto) e.getProperty().getValue();
if (facilityType.getValue() != null) {
FieldHelper.updateItems(facilityCombo, communityDto != null ? FacadeProvider.getFacilityFacade().getActiveFacilitiesByCommunityAndType(communityDto, (FacilityType) facilityType.getValue(), true, false) : responsibleDistrictCombo.getValue() != null ? FacadeProvider.getFacilityFacade().getActiveFacilitiesByDistrictAndType((DistrictReferenceDto) responsibleDistrictCombo.getValue(), (FacilityType) facilityType.getValue(), true, false) : null);
}
});
facilityTypeGroup.addValueChangeListener(e -> {
if (facilityTypeGroup.getValue() == null) {
facilityType.clear();
}
FieldHelper.updateEnumData(facilityType, facilityTypeGroup.getValue() != null ? FacilityType.getTypes((FacilityTypeGroup) facilityTypeGroup.getValue()) : Arrays.stream(FacilityType.values()).collect(Collectors.toList()));
});
facilityType.addValueChangeListener(e -> {
FieldHelper.removeItems(facilityCombo);
if (facilityType.getValue() != null && responsibleDistrictCombo.getValue() != null) {
if (responsibleCommunityCombo.getValue() != null) {
FieldHelper.updateItems(facilityCombo, FacadeProvider.getFacilityFacade().getActiveFacilitiesByCommunityAndType((CommunityReferenceDto) responsibleCommunityCombo.getValue(), (FacilityType) facilityType.getValue(), true, false));
} else {
FieldHelper.updateItems(facilityCombo, FacadeProvider.getFacilityFacade().getActiveFacilitiesByDistrictAndType((DistrictReferenceDto) responsibleDistrictCombo.getValue(), (FacilityType) facilityType.getValue(), true, false));
}
}
});
facilityCombo.addValueChangeListener(e -> {
updateFacilityFields(facilityCombo, facilityDetails);
});
addValueChangeListener(e -> {
FacilityType facilityTypeValue = getValue().getFacilityType();
if (facilityTypeValue != null) {
facilityTypeGroup.setValue(facilityTypeValue.getFacilityTypeGroup());
facilityCombo.setValue(getValue().getHealthFacility());
facilityDetails.setValue(getValue().getHealthFacilityDetails());
}
});
}
use of com.vaadin.v7.ui.TextArea in project SORMAS-Project by hzi-braunschweig.
the class HospitalizationForm method addFields.
@SuppressWarnings("deprecation")
@Override
protected void addFields() {
if (caze == null || viewMode == null) {
return;
}
Label hospitalizationHeadingLabel = new Label(I18nProperties.getString(Strings.headingHospitalization));
hospitalizationHeadingLabel.addStyleName(H3);
getContent().addComponent(hospitalizationHeadingLabel, HOSPITALIZATION_HEADING_LOC);
Label previousHospitalizationsHeadingLabel = new Label(I18nProperties.getString(Strings.headingPreviousHospitalizations));
previousHospitalizationsHeadingLabel.addStyleName(H3);
getContent().addComponent(previousHospitalizationsHeadingLabel, PREVIOUS_HOSPITALIZATIONS_HEADING_LOC);
TextField facilityField = addCustomField(HEALTH_FACILITY, FacilityReferenceDto.class, TextField.class);
FacilityReferenceDto healthFacility = caze.getHealthFacility();
final boolean noneFacility = healthFacility == null || healthFacility.getUuid().equalsIgnoreCase(FacilityDto.NONE_FACILITY_UUID);
facilityField.setValue(noneFacility || !FacilityType.HOSPITAL.equals(caze.getFacilityType()) ? null : healthFacility.toString());
facilityField.setReadOnly(true);
final NullableOptionGroup admittedToHealthFacilityField = addField(HospitalizationDto.ADMITTED_TO_HEALTH_FACILITY, NullableOptionGroup.class);
final DateField admissionDateField = addField(HospitalizationDto.ADMISSION_DATE, DateField.class);
final DateField dischargeDateField = addDateField(HospitalizationDto.DISCHARGE_DATE, DateField.class, 7);
intensiveCareUnit = addField(HospitalizationDto.INTENSIVE_CARE_UNIT, NullableOptionGroup.class);
intensiveCareUnitStart = addField(HospitalizationDto.INTENSIVE_CARE_UNIT_START, DateField.class);
intensiveCareUnitStart.setVisible(false);
intensiveCareUnitEnd = addField(HospitalizationDto.INTENSIVE_CARE_UNIT_END, DateField.class);
intensiveCareUnitEnd.setVisible(false);
FieldHelper.setVisibleWhen(intensiveCareUnit, Arrays.asList(intensiveCareUnitStart, intensiveCareUnitEnd), Arrays.asList(YesNoUnknown.YES), true);
final Field isolationDateField = addField(HospitalizationDto.ISOLATION_DATE);
final TextArea descriptionField = addField(HospitalizationDto.DESCRIPTION, TextArea.class);
descriptionField.setRows(4);
final NullableOptionGroup isolatedField = addField(HospitalizationDto.ISOLATED, NullableOptionGroup.class);
final NullableOptionGroup leftAgainstAdviceField = addField(HospitalizationDto.LEFT_AGAINST_ADVICE, NullableOptionGroup.class);
final ComboBox hospitalizationReason = addField(HospitalizationDto.HOSPITALIZATION_REASON);
final TextField otherHospitalizationReason = addField(HospitalizationDto.OTHER_HOSPITALIZATION_REASON, TextField.class);
NullableOptionGroup hospitalizedPreviouslyField = addField(HospitalizationDto.HOSPITALIZED_PREVIOUSLY, NullableOptionGroup.class);
CssStyles.style(hospitalizedPreviouslyField, CssStyles.ERROR_COLOR_PRIMARY);
PreviousHospitalizationsField previousHospitalizationsField = addField(HospitalizationDto.PREVIOUS_HOSPITALIZATIONS, PreviousHospitalizationsField.class);
FieldHelper.setEnabledWhen(admittedToHealthFacilityField, Arrays.asList(YesNoUnknown.YES, YesNoUnknown.NO, YesNoUnknown.UNKNOWN), Arrays.asList(facilityField, admissionDateField, dischargeDateField, intensiveCareUnit, intensiveCareUnitStart, intensiveCareUnitEnd, isolationDateField, descriptionField, isolatedField, leftAgainstAdviceField, hospitalizationReason, otherHospitalizationReason), false);
initializeVisibilitiesAndAllowedVisibilities();
initializeAccessAndAllowedAccesses();
if (isVisibleAllowed(HospitalizationDto.ISOLATION_DATE)) {
FieldHelper.setVisibleWhen(getFieldGroup(), HospitalizationDto.ISOLATION_DATE, HospitalizationDto.ISOLATED, Arrays.asList(YesNoUnknown.YES), true);
}
if (isVisibleAllowed(HospitalizationDto.PREVIOUS_HOSPITALIZATIONS)) {
FieldHelper.setVisibleWhen(getFieldGroup(), HospitalizationDto.PREVIOUS_HOSPITALIZATIONS, HospitalizationDto.HOSPITALIZED_PREVIOUSLY, Arrays.asList(YesNoUnknown.YES), true);
}
FieldHelper.setVisibleWhen(getFieldGroup(), HospitalizationDto.OTHER_HOSPITALIZATION_REASON, HospitalizationDto.HOSPITALIZATION_REASON, Collections.singletonList(HospitalizationReasonType.OTHER), true);
// Validations
// Add a visual-only validator to check if symptomonsetdate<admissiondate, as saving should be possible either way
admissionDateField.addValueChangeListener(event -> {
if (caze.getSymptoms().getOnsetDate() != null && DateTimeComparator.getDateOnlyInstance().compare(admissionDateField.getValue(), caze.getSymptoms().getOnsetDate()) < 0) {
admissionDateField.setComponentError(new ErrorMessage() {
@Override
public ErrorLevel getErrorLevel() {
return ErrorLevel.INFO;
}
@Override
public String getFormattedHtmlMessage() {
return I18nProperties.getValidationError(Validations.afterDateSoft, admissionDateField.getCaption(), I18nProperties.getPrefixCaption(SymptomsDto.I18N_PREFIX, SymptomsDto.ONSET_DATE));
}
});
} else {
// remove all invalidity-indicators and re-evaluate field
admissionDateField.setComponentError(null);
admissionDateField.markAsDirty();
}
// re-evaluate validity of dischargeDate (necessary because discharge has to be after admission)
dischargeDateField.markAsDirty();
});
admissionDateField.addValidator(new DateComparisonValidator(admissionDateField, dischargeDateField, true, false, I18nProperties.getValidationError(Validations.beforeDate, admissionDateField.getCaption(), dischargeDateField.getCaption())));
dischargeDateField.addValidator(new DateComparisonValidator(dischargeDateField, admissionDateField, false, false, I18nProperties.getValidationError(Validations.afterDate, dischargeDateField.getCaption(), admissionDateField.getCaption())));
// re-evaluate admission date for consistent validation of all fields
dischargeDateField.addValueChangeListener(event -> admissionDateField.markAsDirty());
intensiveCareUnitStart.addValidator(new DateComparisonValidator(intensiveCareUnitStart, admissionDateField, false, false, I18nProperties.getValidationError(Validations.afterDate, intensiveCareUnitStart.getCaption(), admissionDateField.getCaption())));
intensiveCareUnitStart.addValidator(new DateComparisonValidator(intensiveCareUnitStart, intensiveCareUnitEnd, true, false, I18nProperties.getValidationError(Validations.beforeDate, intensiveCareUnitStart.getCaption(), intensiveCareUnitEnd.getCaption())));
intensiveCareUnitEnd.addValidator(new DateComparisonValidator(intensiveCareUnitEnd, intensiveCareUnitStart, false, false, I18nProperties.getValidationError(Validations.afterDate, intensiveCareUnitEnd.getCaption(), intensiveCareUnitStart.getCaption())));
intensiveCareUnitEnd.addValidator(new DateComparisonValidator(intensiveCareUnitEnd, dischargeDateField, true, false, I18nProperties.getValidationError(Validations.beforeDate, intensiveCareUnitEnd.getCaption(), dischargeDateField.getCaption())));
intensiveCareUnitStart.addValueChangeListener(event -> intensiveCareUnitEnd.markAsDirty());
intensiveCareUnitEnd.addValueChangeListener(event -> intensiveCareUnitStart.markAsDirty());
hospitalizedPreviouslyField.addValueChangeListener(e -> updatePrevHospHint(hospitalizedPreviouslyField, previousHospitalizationsField));
previousHospitalizationsField.addValueChangeListener(e -> updatePrevHospHint(hospitalizedPreviouslyField, previousHospitalizationsField));
}
use of com.vaadin.v7.ui.TextArea in project CodenameOne by codenameone.
the class IOSImplementation method updateNativeTextEditorFrame.
private static void updateNativeTextEditorFrame() {
if (instance.currentEditing != null) {
TextArea cmp = instance.currentEditing;
final Style stl = cmp.getStyle();
final boolean rtl = UIManager.getInstance().getLookAndFeel().isRTL();
instance.doNotHideTextEditorSemaphore++;
try {
instance.currentEditing.requestFocus();
} finally {
instance.doNotHideTextEditorSemaphore--;
}
int x = cmp.getAbsoluteX() + cmp.getScrollX();
int y = cmp.getAbsoluteY() + cmp.getScrollY();
int w = cmp.getWidth();
int h = cmp.getHeight();
int pt = stl.getPaddingTop();
int pb = stl.getPaddingBottom();
int pl = stl.getPaddingLeft(rtl);
int pr = stl.getPaddingRight(rtl);
/*
if(cmp.isSingleLineTextArea()) {
switch(cmp.getVerticalAlignment()) {
case TextArea.CENTER:
if(h > cmp.getPreferredH()) {
y += (h / 2 - cmp.getPreferredH() / 2);
}
break;
case TextArea.BOTTOM:
if(h > cmp.getPreferredH()) {
y += (h - cmp.getPreferredH());
}
break;
}
}
*/
int maxH = Display.getInstance().getDisplayHeight() - nativeInstance.getVKBHeight();
if (h > maxH) {
// For text areas, we don't want the keyboard to cover part of the
// typing region. So we will try to size the component to
// to only go up to the top edge of the keyboard
// that should allow the OS to enable scrolling properly.... at least
// in theory.
h = maxH;
}
nativeInstance.resizeNativeTextView(x, y, w, h, pt, pr, pb, pl);
}
}
use of com.vaadin.v7.ui.TextArea in project CodenameOne by codenameone.
the class TestUtils method setText.
/**
* Sets the text for the given component
* @param path the path to the component
* @param text the text to set
*/
public static void setText(int[] path, String text) {
if (verbose) {
log("setText(" + toString(path) + ", " + text + ")");
}
Component c = getComponentByPath(path);
if (c instanceof Label) {
((Label) c).setText(text);
return;
}
((TextArea) c).setText(text);
}
use of com.vaadin.v7.ui.TextArea in project CodenameOne by codenameone.
the class TestUtils method assertTextAreaContaining.
/**
* Asserts that we have a TextArea with the a text contains the given text and with the given name
* @param name the name of the TextArea
* @param text the sequence to search for in the TextArea
*/
public static void assertTextAreaContaining(String name, String text) {
if (verbose) {
log("assertTextAreaContaining(" + name + ", " + text + ")");
}
TextArea l = (TextArea) findByName(name);
assertBool(l != null, "Null area " + text);
assertBool(l.getText().indexOf(text) > -1, "assertTextArea: \"" + l.getText() + "\" is not containing: \"" + text + "\"");
}
Aggregations