Cleanup MaxFieldLength for UI text fields. (#676)

* Cleanup MaxFieldLength for Ui text fields.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Cleanup builder usage.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Code cleanup.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2018-04-27 09:21:22 +02:00
committed by GitHub
parent 63cf4598c2
commit fcc15a0484
23 changed files with 162 additions and 198 deletions

View File

@@ -20,7 +20,6 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.common.CommonDialogWindow; import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener; import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener;
import org.eclipse.hawkbit.ui.common.EmptyStringValidator;
import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery; import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery;
import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder; import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder; import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
@@ -211,20 +210,19 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
private void createRequiredComponents() { private void createRequiredComponents() {
nameTextField = createTextField("textfield.name", UIComponentIdProvider.SOFT_MODULE_NAME); nameTextField = createTextField("textfield.name", UIComponentIdProvider.SOFT_MODULE_NAME,
nameTextField.addValidator(new EmptyStringValidator(i18n)); SoftwareModule.NAME_MAX_SIZE);
versionTextField = createTextField("textfield.version", UIComponentIdProvider.SOFT_MODULE_VERSION); versionTextField = createTextField("textfield.version", UIComponentIdProvider.SOFT_MODULE_VERSION,
versionTextField.addValidator(new EmptyStringValidator(i18n)); SoftwareModule.VERSION_MAX_SIZE);
vendorTextField = createTextField("textfield.vendor", UIComponentIdProvider.SOFT_MODULE_VENDOR); vendorTextField = new TextFieldBuilder(SoftwareModule.VENDOR_MAX_SIZE)
vendorTextField.setRequired(false); .caption(i18n.getMessage("textfield.vendor")).id(UIComponentIdProvider.SOFT_MODULE_VENDOR)
vendorTextField.setNullRepresentation("");
descTextArea = new TextAreaBuilder().caption(i18n.getMessage("textfield.description")).style("text-area-style")
.prompt(i18n.getMessage("textfield.description")).id(UIComponentIdProvider.ADD_SW_MODULE_DESCRIPTION)
.buildTextComponent(); .buildTextComponent();
descTextArea.setNullRepresentation("");
descTextArea = new TextAreaBuilder(SoftwareModule.DESCRIPTION_MAX_SIZE)
.caption(i18n.getMessage("textfield.description")).style("text-area-style")
.id(UIComponentIdProvider.ADD_SW_MODULE_DESCRIPTION).buildTextComponent();
typeComboBox = SPUIComponentProvider.getComboBox(i18n.getMessage("upload.swmodule.type"), "", null, null, true, typeComboBox = SPUIComponentProvider.getComboBox(i18n.getMessage("upload.swmodule.type"), "", null, null, true,
null, i18n.getMessage("upload.swmodule.type")); null, i18n.getMessage("upload.swmodule.type"));
@@ -234,9 +232,9 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
typeComboBox.setImmediate(Boolean.TRUE); typeComboBox.setImmediate(Boolean.TRUE);
} }
private TextField createTextField(final String in18Key, final String id) { private TextField createTextField(final String in18Key, final String id, final int maxLength) {
return new TextFieldBuilder().caption(i18n.getMessage(in18Key)).required(true).prompt(i18n.getMessage(in18Key)) return new TextFieldBuilder(maxLength).caption(i18n.getMessage(in18Key)).required(true, i18n).id(id)
.immediate(true).id(id).buildTextComponent(); .buildTextComponent();
} }
private void populateTypeNameCombo() { private void populateTypeNameCombo() {

View File

@@ -20,7 +20,6 @@ import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent.SoftwareModuleTypeEnum; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent.SoftwareModuleTypeEnum;
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerConstants; import org.eclipse.hawkbit.ui.colorpicker.ColorPickerConstants;
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper; import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper;
import org.eclipse.hawkbit.ui.common.EmptyStringValidator;
import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery; import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder; import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
@@ -101,15 +100,16 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTypeLayout<Softw
multiAssign = new LabelBuilder().name(multiAssignStr).buildLabel(); multiAssign = new LabelBuilder().name(multiAssignStr).buildLabel();
tagName = createTextField("textfield.name", SPUIDefinitions.TYPE_NAME, SPUIDefinitions.NEW_SOFTWARE_TYPE_NAME); tagName = createTextField("textfield.name", SPUIDefinitions.TYPE_NAME, SPUIDefinitions.NEW_SOFTWARE_TYPE_NAME,
SoftwareModuleType.NAME_MAX_SIZE);
typeKey = createTextField("textfield.key", SPUIDefinitions.TYPE_KEY, SPUIDefinitions.NEW_SOFTWARE_TYPE_KEY); typeKey = createTextField("textfield.key", SPUIDefinitions.TYPE_KEY, SPUIDefinitions.NEW_SOFTWARE_TYPE_KEY,
SoftwareModuleType.KEY_MAX_SIZE);
tagDesc = new TextAreaBuilder().caption(i18n.getMessage("textfield.description")) tagDesc = new TextAreaBuilder(SoftwareModuleType.DESCRIPTION_MAX_SIZE)
.caption(i18n.getMessage("textfield.description"))
.styleName(ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TYPE_DESC) .styleName(ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TYPE_DESC)
.prompt(i18n.getMessage("textfield.description")).immediate(true)
.id(SPUIDefinitions.NEW_SOFTWARE_TYPE_DESC).buildTextComponent(); .id(SPUIDefinitions.NEW_SOFTWARE_TYPE_DESC).buildTextComponent();
tagDesc.setNullRepresentation("");
singleMultiOptionGroup(); singleMultiOptionGroup();
} }
@@ -127,10 +127,10 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTypeLayout<Softw
return ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR); return ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR);
} }
private TextField createTextField(final String in18Key, final String styleName, final String id) { private TextField createTextField(final String in18Key, final String styleName, final String id,
return new TextFieldBuilder().caption(i18n.getMessage(in18Key)) final int maxLength) {
.styleName(ValoTheme.TEXTFIELD_TINY + " " + styleName).required(true).prompt(i18n.getMessage(in18Key)) return new TextFieldBuilder(maxLength).caption(i18n.getMessage(in18Key))
.validator(new EmptyStringValidator(i18n)).immediate(true).id(id).buildTextComponent(); .styleName(ValoTheme.TEXTFIELD_TINY + " " + styleName).required(true, i18n).id(id).buildTextComponent();
} }
@Override @Override

View File

@@ -264,7 +264,7 @@ public class UploadConfirmationWindow implements Button.ClickListener {
} }
private static TextField createTextField(final String id) { private static TextField createTextField(final String id) {
return new TextFieldBuilder().immediate(true).id(id).buildTextComponent(); return new TextFieldBuilder(64).id(id).buildTextComponent();
} }
private void addFileNameLayout(final Item newItem, final String baseSoftwareModuleNameVersion, private void addFileNameLayout(final Item newItem, final String baseSoftwareModuleNameVersion,

View File

@@ -236,10 +236,8 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
} }
private TextField createKeyTextField() { private TextField createKeyTextField() {
final TextField keyField = new TextFieldBuilder().caption(i18n.getMessage("textfield.key")).required(true) final TextField keyField = new TextFieldBuilder(MetaData.KEY_MAX_SIZE).caption(i18n.getMessage("textfield.key"))
.prompt(i18n.getMessage("textfield.key")).immediate(true) .required(true, i18n).id(UIComponentIdProvider.METADATA_KEY_FIELD_ID).buildTextComponent();
.id(UIComponentIdProvider.METADATA_KEY_FIELD_ID).maxLengthAllowed(MetaData.KEY_MAX_SIZE)
.validator(new EmptyStringValidator(i18n)).buildTextComponent();
keyField.addTextChangeListener(this::onKeyChange); keyField.addTextChangeListener(this::onKeyChange);
keyField.setTextChangeEventMode(TextChangeEventMode.EAGER); keyField.setTextChangeEventMode(TextChangeEventMode.EAGER);
keyField.setWidth("100%"); keyField.setWidth("100%");
@@ -247,11 +245,8 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
} }
private TextArea createValueTextField() { private TextArea createValueTextField() {
valueTextArea = new TextAreaBuilder().caption(i18n.getMessage("textfield.value")).required(true) valueTextArea = new TextAreaBuilder(MetaData.VALUE_MAX_SIZE).caption(i18n.getMessage("textfield.value"))
.validator(new EmptyStringValidator(i18n)).prompt(i18n.getMessage("textfield.value")).immediate(true) .required(true, i18n).id(UIComponentIdProvider.METADATA_VALUE_ID).buildTextComponent();
.id(UIComponentIdProvider.METADATA_VALUE_ID).maxLengthAllowed(MetaData.VALUE_MAX_SIZE)
.buildTextComponent();
valueTextArea.setNullRepresentation("");
valueTextArea.setSizeFull(); valueTextArea.setSizeFull();
valueTextArea.setHeight(100, Unit.PERCENTAGE); valueTextArea.setHeight(100, Unit.PERCENTAGE);
valueTextArea.addTextChangeListener(this::onValueChange); valueTextArea.addTextChangeListener(this::onValueChange);

View File

@@ -23,18 +23,6 @@ public class EmptyStringValidator extends StringLengthValidator {
private static final String MESSAGE_KEY = "validator.textfield.min.length"; private static final String MESSAGE_KEY = "validator.textfield.min.length";
private static final int TEXT_FIELD_DEFAULT_MAX_LENGTH = 64;
/**
* Constructor for EmptyStringValidator
*
* @param i18n
* {@link VaadinMessageSource}
*/
public EmptyStringValidator(final VaadinMessageSource i18n) {
super(i18n.getMessage(MESSAGE_KEY), 1, TEXT_FIELD_DEFAULT_MAX_LENGTH, false);
}
/** /**
* Constructor for EmptyStringValidator * Constructor for EmptyStringValidator
* *
@@ -44,12 +32,12 @@ public class EmptyStringValidator extends StringLengthValidator {
* max length of the textfield * max length of the textfield
*/ */
public EmptyStringValidator(final VaadinMessageSource i18n, final int maxLength) { public EmptyStringValidator(final VaadinMessageSource i18n, final int maxLength) {
super(i18n.getMessage(MESSAGE_KEY), 1, maxLength, false); super(i18n.getMessage(MESSAGE_KEY, maxLength), 1, maxLength, false);
} }
@Override @Override
public boolean isValid(final Object value) { public boolean isValidValue(final String value) {
return super.isValid(value != null ? value.toString().trim() : null); return super.isValidValue(value != null ? value.trim() : null);
} }
} }

View File

@@ -11,6 +11,8 @@ package org.eclipse.hawkbit.ui.common.builder;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.eclipse.hawkbit.ui.common.EmptyStringValidator;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import com.vaadin.data.Validator; import com.vaadin.data.Validator;
@@ -19,31 +21,39 @@ import com.vaadin.ui.AbstractTextField;
/** /**
* Abstract Text field builder. * Abstract Text field builder.
* *
* @param <T>
* type of the builder
* @param <E> * @param <E>
* the concrete text component * the text component
*
*/ */
public abstract class AbstractTextFieldBuilder<E extends AbstractTextField> { public abstract class AbstractTextFieldBuilder<T, E extends AbstractTextField> {
private String caption; private String caption;
private String style; private String style;
private String styleName; private String styleName;
private String prompt; private String prompt;
private String id; private String id;
private boolean immediate; private boolean immediate = true;
private boolean required; private boolean required;
private boolean readOnly; private boolean readOnly;
private boolean enabled = true; private boolean enabled = true;
private int maxLengthAllowed; private final int maxLengthAllowed;
private final List<Validator> validators = new LinkedList<>(); private final List<Validator> validators = new LinkedList<>();
protected AbstractTextFieldBuilder(final int maxLengthAllowed) {
this.maxLengthAllowed = maxLengthAllowed;
}
/** /**
* @param caption * @param caption
* the caption to set * the caption to set
* @return the builder * @return the builder
*/ */
public AbstractTextFieldBuilder<E> caption(final String caption) { public T caption(final String caption) {
this.caption = caption; this.caption = caption;
return this; this.prompt = caption;
return (T) this;
} }
/** /**
@@ -51,9 +61,9 @@ public abstract class AbstractTextFieldBuilder<E extends AbstractTextField> {
* the style to set * @return the builder * the style to set * @return the builder
* @return the builder * @return the builder
*/ */
public AbstractTextFieldBuilder<E> style(final String style) { public T style(final String style) {
this.style = style; this.style = style;
return this; return (T) this;
} }
/** /**
@@ -61,19 +71,24 @@ public abstract class AbstractTextFieldBuilder<E extends AbstractTextField> {
* the styleName to set * the styleName to set
* @return the builder * @return the builder
*/ */
public AbstractTextFieldBuilder<E> styleName(final String styleName) { public T styleName(final String styleName) {
this.styleName = styleName; this.styleName = styleName;
return this; return (T) this;
} }
/** /**
* @param required * @param required
* the required to set * the required to set
* @param i18n
* to translate error message
* @return the builder * @return the builder
*/ */
public AbstractTextFieldBuilder<E> required(final boolean required) { public T required(final boolean required, final VaadinMessageSource i18n) {
this.required = required; this.required = required;
return this; if (required) {
validators.add(new EmptyStringValidator(i18n, maxLengthAllowed));
}
return (T) this;
} }
/** /**
@@ -81,9 +96,9 @@ public abstract class AbstractTextFieldBuilder<E extends AbstractTextField> {
* the readOnly to set * the readOnly to set
* @return the builder * @return the builder
*/ */
public AbstractTextFieldBuilder<E> readOnly(final boolean readOnly) { public T readOnly(final boolean readOnly) {
this.readOnly = readOnly; this.readOnly = readOnly;
return this; return (T) this;
} }
/** /**
@@ -91,9 +106,9 @@ public abstract class AbstractTextFieldBuilder<E extends AbstractTextField> {
* the enabled to set * the enabled to set
* @return the builder * @return the builder
*/ */
public AbstractTextFieldBuilder<E> enabled(final boolean enabled) { public T enabled(final boolean enabled) {
this.enabled = enabled; this.enabled = enabled;
return this; return (T) this;
} }
/** /**
@@ -101,9 +116,9 @@ public abstract class AbstractTextFieldBuilder<E extends AbstractTextField> {
* the prompt to set * the prompt to set
* @return the builder * @return the builder
*/ */
public AbstractTextFieldBuilder<E> prompt(final String prompt) { public T prompt(final String prompt) {
this.prompt = prompt; this.prompt = prompt;
return this; return (T) this;
} }
/** /**
@@ -111,19 +126,9 @@ public abstract class AbstractTextFieldBuilder<E extends AbstractTextField> {
* the immediate to set * the immediate to set
* @return the builder * @return the builder
*/ */
public AbstractTextFieldBuilder<E> immediate(final boolean immediate) { public T immediate(final boolean immediate) {
this.immediate = immediate; this.immediate = immediate;
return this; return (T) this;
}
/**
* @param maxLengthAllowed
* the maxLengthAllowed to set
* @return the builder
*/
public AbstractTextFieldBuilder<E> maxLengthAllowed(final int maxLengthAllowed) {
this.maxLengthAllowed = maxLengthAllowed;
return this;
} }
/** /**
@@ -131,9 +136,9 @@ public abstract class AbstractTextFieldBuilder<E extends AbstractTextField> {
* the id to set * the id to set
* @return the builder * @return the builder
*/ */
public AbstractTextFieldBuilder<E> id(final String id) { public T id(final String id) {
this.id = id; this.id = id;
return this; return (T) this;
} }
/** /**
@@ -142,9 +147,9 @@ public abstract class AbstractTextFieldBuilder<E extends AbstractTextField> {
* the validator to set for this field * the validator to set for this field
* @return the builder * @return the builder
*/ */
public AbstractTextFieldBuilder<E> validator(final Validator validator) { public T validator(final Validator validator) {
validators.add(validator); validators.add(validator);
return this; return (T) this;
} }
/** /**
@@ -187,6 +192,8 @@ public abstract class AbstractTextFieldBuilder<E extends AbstractTextField> {
validators.forEach(textComponent::addValidator); validators.forEach(textComponent::addValidator);
} }
textComponent.setNullRepresentation("");
return textComponent; return textComponent;
} }

View File

@@ -15,15 +15,16 @@ import com.vaadin.ui.themes.ValoTheme;
* TextArea builder. * TextArea builder.
* *
*/ */
public class TextAreaBuilder extends AbstractTextFieldBuilder<TextArea> { public class TextAreaBuilder extends AbstractTextFieldBuilder<TextAreaBuilder, TextArea> {
private static final int TEXT_AREA_DEFAULT_MAX_LENGTH = 512;
/** /**
* Constructor. * Constructor.
*
* @param maxLengthAllowed
* for the text area
*/ */
public TextAreaBuilder() { public TextAreaBuilder(final int maxLengthAllowed) {
maxLengthAllowed(TEXT_AREA_DEFAULT_MAX_LENGTH); super(maxLengthAllowed);
styleName(ValoTheme.TEXTAREA_SMALL); styleName(ValoTheme.TEXTAREA_SMALL);
} }

View File

@@ -18,24 +18,17 @@ import com.vaadin.ui.themes.ValoTheme;
* Textfield builder. * Textfield builder.
* *
*/ */
public class TextFieldBuilder extends AbstractTextFieldBuilder<TextField> { public class TextFieldBuilder extends AbstractTextFieldBuilder<TextFieldBuilder, TextField> {
/**
* Constructor.
*/
public TextFieldBuilder() {
this(null);
}
/** /**
* Constructor. * Constructor.
* *
* @param id * @param maxLengthAllowed
* the id * as mandatory field
*/ */
public TextFieldBuilder(final String id) { public TextFieldBuilder(final int maxLengthAllowed) {
super(maxLengthAllowed);
styleName(ValoTheme.TEXTAREA_TINY); styleName(ValoTheme.TEXTAREA_TINY);
id(id);
} }
/** /**

View File

@@ -73,7 +73,8 @@ public abstract class AbstractGridHeader extends VerticalLayout {
private void createComponents() { private void createComponents() {
headerCaptionLayout = getHeaderCaptionLayout(); headerCaptionLayout = getHeaderCaptionLayout();
if (isRollout()) { if (isRollout()) {
searchField = new TextFieldBuilder(getSearchBoxId()).createSearchField(event -> searchBy(event.getText())); searchField = new TextFieldBuilder(64).id(getSearchBoxId())
.createSearchField(event -> searchBy(event.getText()));
searchResetIcon = createSearchResetIcon(); searchResetIcon = createSearchResetIcon();
addButton = createAddButton(); addButton = createAddButton();
} }

View File

@@ -87,7 +87,8 @@ public abstract class AbstractTableHeader extends VerticalLayout {
private void createComponents() { private void createComponents() {
headerCaption = createHeaderCaption(); headerCaption = createHeaderCaption();
searchField = new TextFieldBuilder(getSearchBoxId()).createSearchField(event -> searchBy(event.getText())); searchField = new TextFieldBuilder(64).id(getSearchBoxId())
.createSearchField(event -> searchBy(event.getText()));
searchResetIcon = createSearchResetIcon(); searchResetIcon = createSearchResetIcon();

View File

@@ -24,7 +24,6 @@ import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerConstants; import org.eclipse.hawkbit.ui.colorpicker.ColorPickerConstants;
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper; import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper;
import org.eclipse.hawkbit.ui.common.DistributionSetTypeBeanQuery; import org.eclipse.hawkbit.ui.common.DistributionSetTypeBeanQuery;
import org.eclipse.hawkbit.ui.common.EmptyStringValidator;
import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder; import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder; import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
@@ -124,22 +123,21 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTypeLayout<Distri
super.createRequiredComponents(); super.createRequiredComponents();
tagName = createTextField("textfield.name", SPUIDefinitions.DIST_SET_TYPE_NAME, tagName = createTextField("textfield.name", SPUIDefinitions.DIST_SET_TYPE_NAME,
SPUIDefinitions.NEW_DISTRIBUTION_TYPE_NAME); SPUIDefinitions.NEW_DISTRIBUTION_TYPE_NAME, DistributionSetType.NAME_MAX_SIZE);
typeKey = createTextField("textfield.key", SPUIDefinitions.DIST_SET_TYPE_KEY, typeKey = createTextField("textfield.key", SPUIDefinitions.DIST_SET_TYPE_KEY,
SPUIDefinitions.NEW_DISTRIBUTION_TYPE_KEY); SPUIDefinitions.NEW_DISTRIBUTION_TYPE_KEY, DistributionSetType.KEY_MAX_SIZE);
tagDesc = new TextAreaBuilder().caption(i18n.getMessage("textfield.description")) tagDesc = new TextAreaBuilder(DistributionSetType.DESCRIPTION_MAX_SIZE)
.caption(i18n.getMessage("textfield.description"))
.styleName(ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.DIST_SET_TYPE_DESC) .styleName(ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.DIST_SET_TYPE_DESC)
.prompt(i18n.getMessage("textfield.description")).immediate(true)
.id(SPUIDefinitions.NEW_DISTRIBUTION_TYPE_DESC).buildTextComponent(); .id(SPUIDefinitions.NEW_DISTRIBUTION_TYPE_DESC).buildTextComponent();
tagDesc.setNullRepresentation("");
} }
private TextField createTextField(final String in18Key, final String styleName, final String id) { private TextField createTextField(final String in18Key, final String styleName, final String id,
return new TextFieldBuilder().caption(i18n.getMessage(in18Key)) final int maxSize) {
.styleName(ValoTheme.TEXTFIELD_TINY + " " + styleName).required(true).prompt(i18n.getMessage(in18Key)) return new TextFieldBuilder(maxSize).caption(i18n.getMessage(in18Key))
.validator(new EmptyStringValidator(i18n)).immediate(true).id(id).buildTextComponent(); .styleName(ValoTheme.TEXTFIELD_TINY + " " + styleName).required(true, i18n).id(id).buildTextComponent();
} }
@Override @Override

View File

@@ -15,11 +15,11 @@ import java.util.concurrent.Executor;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy; import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.eclipse.hawkbit.repository.rsql.RsqlValidationOracle; import org.eclipse.hawkbit.repository.rsql.RsqlValidationOracle;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder; import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent; import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState; import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -195,12 +195,11 @@ public class AutoCompleteTextFieldComponent extends HorizontalLayout {
} }
private TextField createSearchField() { private TextField createSearchField() {
final TextField textField = new TextFieldBuilder().immediate(true).id(UIComponentIdProvider.CUSTOM_FILTER_QUERY) final TextField textField = new TextFieldBuilder(TargetFilterQuery.QUERY_MAX_SIZE)
.maxLengthAllowed(SPUILabelDefinitions.TARGET_FILTER_QUERY_TEXT_FIELD_LENGTH).buildTextComponent(); .id(UIComponentIdProvider.CUSTOM_FILTER_QUERY).buildTextComponent();
textField.addStyleName("target-filter-textfield"); textField.addStyleName("target-filter-textfield");
textField.setWidth(900.0F, Unit.PIXELS); textField.setWidth(900.0F, Unit.PIXELS);
textField.setTextChangeEventMode(TextChangeEventMode.EAGER); textField.setTextChangeEventMode(TextChangeEventMode.EAGER);
textField.setImmediate(true);
textField.setTextChangeTimeout(100); textField.setTextChangeTimeout(100);
return textField; return textField;
} }

View File

@@ -12,6 +12,7 @@ import java.util.Optional;
import org.eclipse.hawkbit.repository.EntityFactory; import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement; import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery; import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.eclipse.hawkbit.ui.SpPermissionChecker; import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.UiProperties; import org.eclipse.hawkbit.ui.UiProperties;
@@ -201,8 +202,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
} }
private TextField createNameTextField() { private TextField createNameTextField() {
final TextField nameField = new TextFieldBuilder().caption(i18n.getMessage("textfield.customfiltername")) final TextField nameField = new TextFieldBuilder(NamedEntity.NAME_MAX_SIZE)
.prompt(i18n.getMessage("textfield.customfiltername")).immediate(true) .caption(i18n.getMessage("textfield.customfiltername")).required(true, i18n)
.id(UIComponentIdProvider.CUSTOM_FILTER_ADD_NAME).buildTextComponent(); .id(UIComponentIdProvider.CUSTOM_FILTER_ADD_NAME).buildTextComponent();
nameField.setPropertyDataSource(nameLabel); nameField.setPropertyDataSource(nameLabel);
nameField.addTextChangeListener(this::onFilterNameChange); nameField.addTextChangeListener(this::onFilterNameChange);
@@ -368,8 +369,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
} }
private void createTargetFilterQuery() { private void createTargetFilterQuery() {
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.create(entityFactory final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.create(entityFactory.targetFilterQuery()
.targetFilterQuery().create().name(nameTextField.getValue()).query(queryTextField.getValue())); .create().name(nameTextField.getValue()).query(queryTextField.getValue()));
notification.displaySuccess( notification.displaySuccess(
i18n.getMessage("message.create.filter.success", new Object[] { targetFilterQuery.getName() })); i18n.getMessage("message.create.filter.success", new Object[] { targetFilterQuery.getName() }));
eventBus.publish(this, CustomFilterUIEvent.CREATE_TARGET_FILTER_QUERY); eventBus.publish(this, CustomFilterUIEvent.CREATE_TARGET_FILTER_QUERY);

View File

@@ -122,7 +122,8 @@ public class TargetFilterHeader extends VerticalLayout {
} }
private TextField createSearchField() { private TextField createSearchField() {
final TextField campSearchTextField = new TextFieldBuilder(UIComponentIdProvider.TARGET_FILTER_SEARCH_TEXT) final TextField campSearchTextField = new TextFieldBuilder(64)
.id(UIComponentIdProvider.TARGET_FILTER_SEARCH_TEXT)
.createSearchField(event -> searchBy(event.getText())); .createSearchField(event -> searchBy(event.getText()));
campSearchTextField.setWidth(500.0F, Unit.PIXELS); campSearchTextField.setWidth(500.0F, Unit.PIXELS);
return campSearchTextField; return campSearchTextField;

View File

@@ -18,7 +18,6 @@ import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper;
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerLayout; import org.eclipse.hawkbit.ui.colorpicker.ColorPickerLayout;
import org.eclipse.hawkbit.ui.common.CommonDialogWindow; import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener; import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener;
import org.eclipse.hawkbit.ui.common.EmptyStringValidator;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder; import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder; import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
@@ -191,18 +190,15 @@ public abstract class AbstractCreateUpdateTagLayout<E extends NamedEntity> exten
colorLabel = new LabelBuilder().name(i18n.getMessage("label.choose.tag.color")).buildLabel(); colorLabel = new LabelBuilder().name(i18n.getMessage("label.choose.tag.color")).buildLabel();
colorLabel.addStyleName(SPUIDefinitions.COLOR_LABEL_STYLE); colorLabel.addStyleName(SPUIDefinitions.COLOR_LABEL_STYLE);
tagName = new TextFieldBuilder().caption(i18n.getMessage("textfield.name")) tagName = new TextFieldBuilder(NamedEntity.NAME_MAX_SIZE).caption(i18n.getMessage("textfield.name"))
.styleName(ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_NAME).required(true) .styleName(ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_NAME).required(true, i18n)
.prompt(i18n.getMessage("textfield.name")).immediate(true).id(SPUIDefinitions.NEW_TARGET_TAG_NAME) .id(SPUIDefinitions.NEW_TARGET_TAG_NAME).buildTextComponent();
.validator(new EmptyStringValidator(i18n)).buildTextComponent();
tagDesc = new TextAreaBuilder().caption(i18n.getMessage("textfield.description")) tagDesc = new TextAreaBuilder(NamedEntity.DESCRIPTION_MAX_SIZE)
.caption(i18n.getMessage("textfield.description"))
.styleName(ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_DESC) .styleName(ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_DESC)
.prompt(i18n.getMessage("textfield.description")).immediate(true)
.id(SPUIDefinitions.NEW_TARGET_TAG_DESC).buildTextComponent(); .id(SPUIDefinitions.NEW_TARGET_TAG_DESC).buildTextComponent();
tagDesc.setNullRepresentation("");
tagNameComboBox = SPUIComponentProvider.getComboBox(null, "", null, null, false, "", tagNameComboBox = SPUIComponentProvider.getComboBox(null, "", null, null, false, "",
i18n.getMessage("label.combobox.tag")); i18n.getMessage("label.combobox.tag"));
tagNameComboBox.addStyleName(SPUIDefinitions.FILTER_TYPE_COMBO_STYLE); tagNameComboBox.addStyleName(SPUIDefinitions.FILTER_TYPE_COMBO_STYLE);

View File

@@ -22,7 +22,6 @@ import org.eclipse.hawkbit.repository.model.TenantMetaData;
import org.eclipse.hawkbit.ui.common.CommonDialogWindow; import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener; import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener;
import org.eclipse.hawkbit.ui.common.DistributionSetTypeBeanQuery; import org.eclipse.hawkbit.ui.common.DistributionSetTypeBeanQuery;
import org.eclipse.hawkbit.ui.common.EmptyStringValidator;
import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder; import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder; import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
import org.eclipse.hawkbit.ui.common.builder.WindowBuilder; import org.eclipse.hawkbit.ui.common.builder.WindowBuilder;
@@ -222,8 +221,10 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
* Create required UI components. * Create required UI components.
*/ */
private void createRequiredComponents() { private void createRequiredComponents() {
distNameTextField = createTextField("textfield.name", UIComponentIdProvider.DIST_ADD_NAME); distNameTextField = createTextField("textfield.name", UIComponentIdProvider.DIST_ADD_NAME,
distVersionTextField = createTextField("textfield.version", UIComponentIdProvider.DIST_ADD_VERSION); DistributionSet.NAME_MAX_SIZE);
distVersionTextField = createTextField("textfield.version", UIComponentIdProvider.DIST_ADD_VERSION,
DistributionSet.VERSION_MAX_SIZE);
distsetTypeNameComboBox = SPUIComponentProvider.getComboBox(i18n.getMessage("label.combobox.type"), "", null, distsetTypeNameComboBox = SPUIComponentProvider.getComboBox(i18n.getMessage("label.combobox.type"), "", null,
"", false, "", i18n.getMessage("label.combobox.type")); "", false, "", i18n.getMessage("label.combobox.type"));
@@ -231,10 +232,9 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
distsetTypeNameComboBox.setNullSelectionAllowed(false); distsetTypeNameComboBox.setNullSelectionAllowed(false);
distsetTypeNameComboBox.setId(UIComponentIdProvider.DIST_ADD_DISTSETTYPE); distsetTypeNameComboBox.setId(UIComponentIdProvider.DIST_ADD_DISTSETTYPE);
descTextArea = new TextAreaBuilder().caption(i18n.getMessage("textfield.description")).style("text-area-style") descTextArea = new TextAreaBuilder(DistributionSet.DESCRIPTION_MAX_SIZE)
.prompt(i18n.getMessage("textfield.description")).immediate(true) .caption(i18n.getMessage("textfield.description")).style("text-area-style")
.id(UIComponentIdProvider.DIST_ADD_DESC).buildTextComponent(); .id(UIComponentIdProvider.DIST_ADD_DESC).buildTextComponent();
descTextArea.setNullRepresentation("");
reqMigStepCheckbox = SPUIComponentProvider.getCheckBox(i18n.getMessage("checkbox.dist.required.migration.step"), reqMigStepCheckbox = SPUIComponentProvider.getCheckBox(i18n.getMessage("checkbox.dist.required.migration.step"),
"dist-checkbox-style", null, false, ""); "dist-checkbox-style", null, false, "");
@@ -242,12 +242,9 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
reqMigStepCheckbox.setId(UIComponentIdProvider.DIST_ADD_MIGRATION_CHECK); reqMigStepCheckbox.setId(UIComponentIdProvider.DIST_ADD_MIGRATION_CHECK);
} }
private TextField createTextField(final String in18Key, final String id) { private TextField createTextField(final String in18Key, final String id, final int maxLength) {
final TextField buildTextField = new TextFieldBuilder().caption(i18n.getMessage(in18Key)).required(true) return new TextFieldBuilder(maxLength).caption(i18n.getMessage(in18Key)).required(true, i18n).id(id)
.validator(new EmptyStringValidator(i18n)).prompt(i18n.getMessage(in18Key)).immediate(true).id(id)
.buildTextComponent(); .buildTextComponent();
buildTextField.setNullRepresentation("");
return buildTextField;
} }
/** /**

View File

@@ -17,6 +17,7 @@ import java.util.stream.Collectors;
import org.eclipse.hawkbit.repository.MaintenanceScheduleHelper; import org.eclipse.hawkbit.repository.MaintenanceScheduleHelper;
import org.eclipse.hawkbit.repository.exception.InvalidMaintenanceScheduleException; import org.eclipse.hawkbit.repository.exception.InvalidMaintenanceScheduleException;
import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder; import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
@@ -83,9 +84,10 @@ public class MaintenanceWindowLayout extends VerticalLayout {
* Text field to specify the schedule. * Text field to specify the schedule.
*/ */
private void createMaintenanceScheduleControl() { private void createMaintenanceScheduleControl() {
schedule = new TextFieldBuilder().id(UIComponentIdProvider.MAINTENANCE_WINDOW_SCHEDULE_ID) schedule = new TextFieldBuilder(Action.MAINTENANCE_SCHEDULE_CRON_LENGTH)
.caption(i18n.getMessage("caption.maintenancewindow.schedule")).immediate(true) .id(UIComponentIdProvider.MAINTENANCE_WINDOW_SCHEDULE_ID)
.validator(new CronValidator()).prompt("0 0 3 ? * 6").required(true).buildTextComponent(); .caption(i18n.getMessage("caption.maintenancewindow.schedule")).validator(new CronValidator())
.prompt("0 0 3 ? * 6").required(true, i18n).buildTextComponent();
schedule.addTextChangeListener(new CronTranslationListener()); schedule.addTextChangeListener(new CronTranslationListener());
} }
@@ -148,9 +150,10 @@ public class MaintenanceWindowLayout extends VerticalLayout {
* Text field to specify the duration. * Text field to specify the duration.
*/ */
private void createMaintenanceDurationControl() { private void createMaintenanceDurationControl() {
duration = new TextFieldBuilder().id(UIComponentIdProvider.MAINTENANCE_WINDOW_DURATION_ID) duration = new TextFieldBuilder(Action.MAINTENANCE_WINDOW_DURATION_LENGTH)
.caption(i18n.getMessage("caption.maintenancewindow.duration")).immediate(true) .id(UIComponentIdProvider.MAINTENANCE_WINDOW_DURATION_ID)
.validator(new DurationValidator()).prompt("hh:mm:ss").required(true).buildTextComponent(); .caption(i18n.getMessage("caption.maintenancewindow.duration")).validator(new DurationValidator())
.prompt("hh:mm:ss").required(true, i18n).buildTextComponent();
} }
/** /**

View File

@@ -98,21 +98,18 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
} }
private void createRequiredComponents() { private void createRequiredComponents() {
controllerIDTextField = createTextField("prompt.target.id", UIComponentIdProvider.TARGET_ADD_CONTROLLER_ID); controllerIDTextField = new TextFieldBuilder(Target.CONTROLLER_ID_MAX_SIZE)
.caption(i18n.getMessage("prompt.target.id")).required(true, i18n)
.id(UIComponentIdProvider.TARGET_ADD_CONTROLLER_ID).buildTextComponent();
controllerIDTextField controllerIDTextField
.addValidator(new RegexpValidator("[.\\S]*", i18n.getMessage("message.target.whitespace.check"))); .addValidator(new RegexpValidator("[.\\S]*", i18n.getMessage("message.target.whitespace.check")));
nameTextField = createTextField("textfield.name", UIComponentIdProvider.TARGET_ADD_NAME); nameTextField = new TextFieldBuilder(Target.NAME_MAX_SIZE).caption(i18n.getMessage("textfield.name"))
.id(UIComponentIdProvider.TARGET_ADD_NAME).buildTextComponent();
nameTextField.setRequired(false); nameTextField.setRequired(false);
descTextArea = new TextAreaBuilder().caption(i18n.getMessage("textfield.description")).style("text-area-style") descTextArea = new TextAreaBuilder(Target.DESCRIPTION_MAX_SIZE)
.prompt(i18n.getMessage("textfield.description")).immediate(true) .caption(i18n.getMessage("textfield.description")).style("text-area-style")
.id(UIComponentIdProvider.TARGET_ADD_DESC).buildTextComponent(); .id(UIComponentIdProvider.TARGET_ADD_DESC).buildTextComponent();
descTextArea.setNullRepresentation("");
}
private TextField createTextField(final String in18Key, final String id) {
return new TextFieldBuilder().caption(i18n.getMessage(in18Key)).required(true).prompt(i18n.getMessage(in18Key))
.immediate(true).id(id).buildTextComponent();
} }
private void buildLayout() { private void buildLayout() {

View File

@@ -16,6 +16,7 @@ import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.EntityFactory; import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.TargetTagManagement; import org.eclipse.hawkbit.repository.TargetTagManagement;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.ui.SpPermissionChecker; import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.UiProperties; import org.eclipse.hawkbit.ui.UiProperties;
import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder; import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
@@ -98,9 +99,9 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent {
TargetBulkUpdateWindowLayout(final VaadinMessageSource i18n, final TargetManagement targetManagement, TargetBulkUpdateWindowLayout(final VaadinMessageSource i18n, final TargetManagement targetManagement,
final UIEventBus eventBus, final ManagementUIState managementUIState, final UIEventBus eventBus, final ManagementUIState managementUIState,
final DeploymentManagement deploymentManagement, final UiProperties uiproperties, final DeploymentManagement deploymentManagement, final UiProperties uiproperties,
final SpPermissionChecker checker, final UINotification uinotification, final TargetTagManagement tagManagement, final SpPermissionChecker checker, final UINotification uinotification,
final DistributionSetManagement distributionSetManagement, final EntityFactory entityFactory, final TargetTagManagement tagManagement, final DistributionSetManagement distributionSetManagement,
final Executor uiExecutor) { final EntityFactory entityFactory, final Executor uiExecutor) {
this.i18n = i18n; this.i18n = i18n;
this.targetManagement = targetManagement; this.targetManagement = targetManagement;
this.eventBus = eventBus; this.eventBus = eventBus;
@@ -194,10 +195,9 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent {
} }
private TextArea getDescriptionTextArea() { private TextArea getDescriptionTextArea() {
final TextArea description = new TextAreaBuilder().caption(i18n.getMessage("textfield.description")) final TextArea description = new TextAreaBuilder(Target.DESCRIPTION_MAX_SIZE)
.style("text-area-style").prompt(i18n.getMessage("textfield.description")).immediate(true) .caption(i18n.getMessage("textfield.description")).style("text-area-style")
.id(UIComponentIdProvider.BULK_UPLOAD_DESC).buildTextComponent(); .id(UIComponentIdProvider.BULK_UPLOAD_DESC).buildTextComponent();
description.setNullRepresentation("");
description.setWidth("100%"); description.setWidth("100%");
return description; return description;
} }

View File

@@ -333,7 +333,8 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
private Long getScheduledStartTime() { private Long getScheduledStartTime() {
return AutoStartOptionGroupLayout.AutoStartOption.SCHEDULED.equals(getAutoStartOption()) return AutoStartOptionGroupLayout.AutoStartOption.SCHEDULED.equals(getAutoStartOption())
? autoStartOptionGroupLayout.getStartAtDateField().getValue().getTime() : null; ? autoStartOptionGroupLayout.getStartAtDateField().getValue().getTime()
: null;
} }
private int getErrorThresholdPercentage(final int amountGroup) { private int getErrorThresholdPercentage(final int amountGroup) {
@@ -486,13 +487,12 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
return new LabelBuilder().name(i18n.getMessage(key)).buildLabel(); return new LabelBuilder().name(i18n.getMessage(key)).buildLabel();
} }
private TextField createTextField(final String in18Key, final String id) { private TextField createTextField(final String in18Key, final String id, final int maxLength) {
return new TextFieldBuilder().prompt(i18n.getMessage(in18Key)).immediate(true).id(id).buildTextComponent(); return new TextFieldBuilder(maxLength).prompt(i18n.getMessage(in18Key)).id(id).buildTextComponent();
} }
private TextField createIntegerTextField(final String in18Key, final String id) { private TextField createIntegerTextField(final String in18Key, final String id) {
final TextField textField = createTextField(in18Key, id); final TextField textField = createTextField(in18Key, id, 32);
textField.setNullRepresentation("");
textField.setConverter(new StringToIntegerConverter()); textField.setConverter(new StringToIntegerConverter());
textField.setConversionError(i18n.getMessage(MESSAGE_ENTER_NUMBER)); textField.setConversionError(i18n.getMessage(MESSAGE_ENTER_NUMBER));
textField.setSizeUndefined(); textField.setSizeUndefined();
@@ -615,12 +615,10 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
} }
private static TextArea createTargetFilterQuery() { private static TextArea createTargetFilterQuery() {
final TextArea filterField = new TextAreaBuilder().style("text-area-style") final TextArea filterField = new TextAreaBuilder(TargetFilterQuery.QUERY_MAX_SIZE).style("text-area-style")
.id(UIComponentIdProvider.ROLLOUT_TARGET_FILTER_QUERY_FIELD) .id(UIComponentIdProvider.ROLLOUT_TARGET_FILTER_QUERY_FIELD).buildTextComponent();
.maxLengthAllowed(SPUILabelDefinitions.TARGET_FILTER_QUERY_TEXT_FIELD_LENGTH).buildTextComponent();
filterField.setId(UIComponentIdProvider.ROLLOUT_TARGET_FILTER_QUERY_FIELD); filterField.setId(UIComponentIdProvider.ROLLOUT_TARGET_FILTER_QUERY_FIELD);
filterField.setNullRepresentation("");
filterField.setEnabled(false); filterField.setEnabled(false);
filterField.setSizeUndefined(); filterField.setSizeUndefined();
return filterField; return filterField;
@@ -776,11 +774,9 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
errorThresholdOptionGroup.setValue(ERRORTHRESOLDOPTIONS.PERCENT.getValue()); errorThresholdOptionGroup.setValue(ERRORTHRESOLDOPTIONS.PERCENT.getValue());
} }
private TextArea createDescription() { private static TextArea createDescription() {
final TextArea descriptionField = new TextAreaBuilder().style("text-area-style") final TextArea descriptionField = new TextAreaBuilder(Rollout.DESCRIPTION_MAX_SIZE).style("text-area-style")
.prompt(i18n.getMessage("textfield.description")).id(UIComponentIdProvider.ROLLOUT_DESCRIPTION_ID) .id(UIComponentIdProvider.ROLLOUT_DESCRIPTION_ID).buildTextComponent();
.buildTextComponent();
descriptionField.setNullRepresentation("");
descriptionField.setSizeUndefined(); descriptionField.setSizeUndefined();
return descriptionField; return descriptionField;
} }
@@ -846,8 +842,10 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
} }
private TextField createRolloutNameField() { private TextField createRolloutNameField() {
final TextField rolloutNameField = createTextField("textfield.name", final TextField rolloutNameField = new TextFieldBuilder(Rollout.NAME_MAX_SIZE)
UIComponentIdProvider.ROLLOUT_NAME_FIELD_ID); .prompt(i18n.getMessage("textfield.name")).id(UIComponentIdProvider.ROLLOUT_NAME_FIELD_ID)
.required(true, i18n).buildTextComponent();
rolloutNameField.setSizeUndefined(); rolloutNameField.setSizeUndefined();
return rolloutNameField; return rolloutNameField;
} }

View File

@@ -50,7 +50,6 @@ import com.vaadin.data.util.converter.StringToFloatConverter;
import com.vaadin.data.util.converter.StringToIntegerConverter; import com.vaadin.data.util.converter.StringToIntegerConverter;
import com.vaadin.data.validator.FloatRangeValidator; import com.vaadin.data.validator.FloatRangeValidator;
import com.vaadin.data.validator.IntegerRangeValidator; import com.vaadin.data.validator.IntegerRangeValidator;
import com.vaadin.data.validator.StringLengthValidator;
import com.vaadin.server.FontAwesome; import com.vaadin.server.FontAwesome;
import com.vaadin.server.UserError; import com.vaadin.server.UserError;
import com.vaadin.ui.Button; import com.vaadin.ui.Button;
@@ -419,19 +418,17 @@ public class DefineGroupsLayout extends GridLayout {
} }
private TextField createTextField(final String in18Key, final String id) { private TextField createTextField(final String in18Key, final String id) {
final TextField textField = new TextFieldBuilder().prompt(i18n.getMessage(in18Key)).immediate(true).id(id) final TextField textField = new TextFieldBuilder(RolloutGroup.NAME_MAX_SIZE).required(true, i18n)
.buildTextComponent(); .prompt(i18n.getMessage(in18Key)).id(id).buildTextComponent();
textField.setSizeUndefined(); textField.setSizeUndefined();
textField.addValidator(
new StringLengthValidator(i18n.getMessage("message.rollout.group.name.invalid"), 1, 64, false));
return textField; return textField;
} }
private TextField createPercentageField(final String in18Key, final String id) { private TextField createPercentageField(final String in18Key, final String id) {
final TextField textField = new TextFieldBuilder().prompt(i18n.getMessage(in18Key)).immediate(true).id(id) final TextField textField = new TextFieldBuilder(32).prompt(i18n.getMessage(in18Key)).id(id)
.buildTextComponent(); .buildTextComponent();
textField.setWidth(80, Unit.PIXELS); textField.setWidth(80, Unit.PIXELS);
textField.setNullRepresentation("");
textField.setConverter(new StringToIntegerConverter()); textField.setConverter(new StringToIntegerConverter());
textField.addValidator(this::validateMandatoryPercentage); textField.addValidator(this::validateMandatoryPercentage);
return textField; return textField;
@@ -474,11 +471,9 @@ public class DefineGroupsLayout extends GridLayout {
} }
private TextArea createTargetFilterQuery() { private TextArea createTargetFilterQuery() {
final TextArea filterField = new TextAreaBuilder().style("text-area-style") final TextArea filterField = new TextAreaBuilder(TargetFilterQuery.QUERY_MAX_SIZE).style("text-area-style")
.id(UIComponentIdProvider.ROLLOUT_TARGET_FILTER_QUERY_FIELD) .id(UIComponentIdProvider.ROLLOUT_TARGET_FILTER_QUERY_FIELD).buildTextComponent();
.maxLengthAllowed(SPUILabelDefinitions.TARGET_FILTER_QUERY_TEXT_FIELD_LENGTH).buildTextComponent();
filterField.setNullRepresentation("");
filterField.setEnabled(false); filterField.setEnabled(false);
filterField.setSizeUndefined(); filterField.setSizeUndefined();
return filterField; return filterField;

View File

@@ -53,7 +53,7 @@ public class CertificateAuthenticationConfigurationItem extends AbstractBooleanT
"The SSL Issuer iRules.X509 hash, to validate against the controller request certifcate."); "The SSL Issuer iRules.X509 hash, to validate against the controller request certifcate.");
caRootAuthorityLabel.setWidthUndefined(); caRootAuthorityLabel.setWidthUndefined();
caRootAuthorityTextField = new TextFieldBuilder().immediate(true).maxLengthAllowed(160).buildTextComponent(); caRootAuthorityTextField = new TextFieldBuilder(160).buildTextComponent();
caRootAuthorityTextField.setWidth("100%"); caRootAuthorityTextField.setWidth("100%");
caRootAuthorityTextField.addTextChangeListener(event -> caRootAuthorityChanged()); caRootAuthorityTextField.addTextChangeListener(event -> caRootAuthorityChanged());

View File

@@ -272,11 +272,6 @@ public final class SPUILabelDefinitions {
*/ */
public static final String STATUS_ICON = "statusIcon"; public static final String STATUS_ICON = "statusIcon";
/**
* Create custom target filter header - query text field length.
*/
public static final int TARGET_FILTER_QUERY_TEXT_FIELD_LENGTH = 1024;
/** /**
* Status - column property. * Status - column property.
*/ */