use of com.haulmont.cuba.web.toolkit.ui.CubaFieldWrapper in project cuba by cuba-platform.
the class WebFieldGroup method applyFieldDefaults.
protected void applyFieldDefaults(FieldConfigImpl fci) {
Component fieldComponent = fci.getComponentNN();
if (fieldComponent instanceof Field) {
Field cubaField = (Field) fieldComponent;
if (fci.getTargetCaption() != null) {
cubaField.setCaption(fci.getTargetCaption());
}
if (fci.getTargetDescription() != null) {
// we check empty for description since Vaadin components have "" description by default
cubaField.setDescription(fci.getTargetDescription());
}
if (cubaField instanceof HasInputPrompt && fci.getTargetInputPrompt() != null) {
((HasInputPrompt) cubaField).setInputPrompt(fci.getTargetInputPrompt());
}
if (fci.getTargetRequired() != null) {
cubaField.setRequired(fci.getTargetRequired());
}
if (fci.getTargetRequiredMessage() != null) {
cubaField.setRequiredMessage(fci.getTargetRequiredMessage());
}
if (fci.getTargetContextHelpText() != null) {
cubaField.setContextHelpText(fci.getTargetContextHelpText());
}
if (fci.getTargetContextHelpTextHtmlEnabled() != null) {
cubaField.setContextHelpTextHtmlEnabled(fci.getTargetContextHelpTextHtmlEnabled());
}
if (fci.getTargetContextHelpIconClickHandler() != null) {
cubaField.setContextHelpIconClickHandler(fci.getTargetContextHelpIconClickHandler());
}
if (fci.getTargetEditable() != null) {
cubaField.setEditable(fci.getTargetEditable());
}
if (fci.getTargetVisible() != null) {
cubaField.setVisible(fci.getTargetVisible());
}
if (cubaField instanceof Component.Focusable && fci.getTargetTabIndex() != null) {
((Component.Focusable) cubaField).setTabIndex(fci.getTargetTabIndex());
}
for (Field.Validator validator : fci.getTargetValidators()) {
cubaField.addValidator(validator);
}
if (fci.getTargetWidth() != null) {
fieldComponent.setWidth(fci.getTargetWidth());
} else {
if (App.isBound()) {
ThemeConstants theme = App.getInstance().getThemeConstants();
fieldComponent.setWidth(theme.get("cuba.web.WebFieldGroup.defaultFieldWidth"));
}
}
} else {
com.vaadin.ui.Field composition = fci.getCompositionNN();
if (fci.getTargetCaption() != null) {
composition.setCaption(fci.getTargetCaption());
}
if (fci.getTargetDescription() != null) {
((CubaFieldWrapper) composition).setDescription(fci.getTargetDescription());
}
if (fci.getTargetRequired() != null) {
composition.setRequired(fci.getTargetRequired());
}
if (fci.getTargetRequiredMessage() != null) {
composition.setRequiredError(fci.getTargetRequiredMessage());
}
if (fci.getTargetEditable() != null) {
composition.setReadOnly(!fci.getTargetEditable());
}
if (fci.getTargetVisible() != null) {
composition.setVisible(fci.getTargetVisible());
}
if (fci.getTargetWidth() != null) {
composition.setWidth(fci.getTargetWidth());
} else {
if (App.isBound()) {
ThemeConstants theme = App.getInstance().getThemeConstants();
composition.setWidth(theme.get("cuba.web.WebFieldGroup.defaultFieldWidth"));
}
}
}
if (fieldComponent instanceof Component.HasFormatter && fci.getTargetFormatter() != null) {
((Component.HasFormatter) fieldComponent).setFormatter(fci.getTargetFormatter());
}
if (StringUtils.isNotEmpty(fci.getTargetStylename())) {
fieldComponent.setStyleName(fci.getTargetStylename());
}
}
Aggregations