Commit d6764c72 authored by Cristina Cocho's avatar Cristina Cocho

Added attribute view_max_length for text widgets

parent a83a9a61
3.2.1 29/04/2019
------
* Overwritten equals method in Property class.
* Added attribute "view_max_length" used in text widgets.
3.2.0 11/02/2019
------
......
......@@ -147,6 +147,7 @@ public abstract class Property implements ServerPropertyChangeListener, ICommand
private boolean isCheckable = true;
private int maxLength;
private int viewMaxLength;
private boolean maxLengthOnlyForTextFieldSize = false;
// private long lastPropertyChangedTime;
private String errorMessage;
......@@ -169,7 +170,7 @@ public abstract class Property implements ServerPropertyChangeListener, ICommand
this.name = PropertyDatabase.getInstance().getPropertyName(id);
maxLength = getDefaultMaxLength();
viewMaxLength = getDefaultMaxLength();
// Set property change listeners initial size to 2
this.propertyChangeListeners = new HashSet<IPropertyChangeListener>(1);
......@@ -738,6 +739,10 @@ public abstract class Property implements ServerPropertyChangeListener, ICommand
public int getMaxLength() {
return maxLength;
}
public int getViewMaxLength() {
return viewMaxLength;
}
public boolean maxLengthOnlyForTextFieldSize() {
return maxLengthOnlyForTextFieldSize;
......@@ -751,6 +756,10 @@ public abstract class Property implements ServerPropertyChangeListener, ICommand
this.maxLength = maxlength;
}
public void setViewMaxLength(int viewMaxLength) {
this.viewMaxLength = viewMaxLength;
}
public final boolean acceptsValue(String value, boolean isFinalValue) {
if (propertyFormat.verifiesValue()) {
// the propertyFormat is in charge of the control
......
......@@ -138,6 +138,9 @@ public class PropertyFactory {
// max length
property.setMaxLength(propertyDescriptor.getMaxLength());
// max view length
property.setViewMaxLength(propertyDescriptor.getViewMaxLength());
// add conditions
Iterator<ConditionDescriptor> it = propertyDescriptor.getConditionsIterator();
......
......@@ -77,6 +77,7 @@ public class PropertyParser extends GenericParser {
private final static String ATTRIBUTE_MAX_EXCLUDED = "max_excluded";
private final static String ATTRIBUTE_DECIMAL_FORMAT_PROPERTY_NAME = "property_name";
protected final static String ATTRIBUTE_SIZE_PROPERTY = "size_property";
protected final static String ATTRIBUTE_VIEW_MAX_LENGTH = "view_max_length";
protected String controllerType;
private Map properties; // KEY=property name VALUE=PropertyDescriptor instance
......@@ -102,6 +103,7 @@ public class PropertyParser extends GenericParser {
propertyDescriptor = new XMLPropertyDescriptor(getAttribute(attributes, ATTRIBUTE_PROPERTY_NAME), getAttribute(attributes, ATTRIBUTE_PROPERTY_TYPE));
propertyDescriptor.setMaxLength(getAttribute(attributes, ATTRIBUTE_MAX_LENGTH));
propertyDescriptor.setUndoable(getAttribute(attributes, ATTRIBUTE_IS_UNDOABLE));
propertyDescriptor.setViewMaxLength(getAttribute(attributes, ATTRIBUTE_VIEW_MAX_LENGTH));
// Store it in the map
properties.put(propertyDescriptor.getPropertyName(), propertyDescriptor);
......
......@@ -37,6 +37,7 @@ public class XMLPropertyDescriptor {
private String format = PropertyParser.TAG_NO_FORMAT;
private int nbDecimalPlaces = DEFAULT_NB_PLACES;
private String decimalFormatPropertyName;
private int viewMaxLength = DEFAULT_STRING_MAX_LENGTH;
private Set<ConditionDescriptor> conditions = new HashSet<ConditionDescriptor>(); // set of ConditionDescriptor instances
......@@ -109,6 +110,17 @@ public class XMLPropertyDescriptor {
} catch (NumberFormatException nbe) {
}
}
public int getViewMaxLength() {
return viewMaxLength;
}
public void setViewMaxLength(String viewMaxLength) {
try {
this.viewMaxLength = Integer.parseInt(viewMaxLength);
} catch (NumberFormatException nbe) {
}
}
public int getNbDecimalPlaces() {
return nbDecimalPlaces;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment