Commit cb8ebadd authored by helene ortiz's avatar helene ortiz
Browse files

Systematically allocate maximum width for label widgets

parent 079bff09
......@@ -120,4 +120,9 @@ public abstract class FloatProperty extends Property {
public boolean acceptsNegativeValue() {
return acceptNegativeValue;
}
protected int getDefaultMaxLength() {
return XMLPropertyDescriptor.DEFAULT_NUMERIC_MAX_LENGTH;
}
}
\ No newline at end of file
......@@ -24,6 +24,7 @@ import fr.ill.ics.core.property.condition.IPropertyCondition;
import fr.ill.ics.core.property.condition.PositivePropertyCondition;
import fr.ill.ics.core.property.condition.StrictlyPositivePropertyCondition;
import fr.ill.ics.core.property.event.VerifyIntegerValueListener;
import fr.ill.ics.core.property.parser.descriptor.XMLPropertyDescriptor;
public abstract class IntegerProperty extends Property {
......@@ -112,4 +113,9 @@ public abstract class IntegerProperty extends Property {
public boolean acceptsNegativeValue() {
return acceptNegativeValue;
}
protected int getDefaultMaxLength() {
return XMLPropertyDescriptor.DEFAULT_NUMERIC_MAX_LENGTH;
}
}
\ No newline at end of file
......@@ -64,7 +64,7 @@ public abstract class Property implements ServerPropertyChangeListener, ICommand
private boolean isArray = false;
private boolean isCheckable = true;
private int maxLength = XMLPropertyDescriptor.DEFAULT_MAX_LENGTH;
private int maxLength;
private boolean maxLengthOnlyForTextFieldSize = false;
// private long lastPropertyChangedTime;
private String errorMessage;
......@@ -83,6 +83,9 @@ public abstract class Property implements ServerPropertyChangeListener, ICommand
this.containerId = containerId;
this.isCommandBox = isCommandBox;
maxLength = getDefaultMaxLength();
// Set property change listeners initial size to 2
this.propertyChangeListeners = new HashSet<IPropertyChangeListener>(1);
this.propertyErrorListeners = new ArrayList(2);
......@@ -619,8 +622,6 @@ public abstract class Property implements ServerPropertyChangeListener, ICommand
this.undoState.setAutoApply();
}
public abstract boolean isNumeric();
public boolean isCheckable() {
return isCheckable;
}
......@@ -680,20 +681,7 @@ public abstract class Property implements ServerPropertyChangeListener, ICommand
return ServantDatabase.getInstance().getControllerName(PropertyDatabase.getInstance().getServantIdForDynamicProperty(id));
}
public abstract String getType();
/**
* <p>
* Has to be implemented in the concret Property classe to set the pVerifyListener. Thus, the hasVerifyListener() method will return true.
* </p>
*
* <p>
* Implement nothing if the concret Property class does not need a pVerifyListener. Thus, the hasVerifyListener() method will return false.
* </p>
*
*/
public abstract void setPVerifyListener();
public void removeFromPropertyNotification() {
DataNotificationClient.getInstance().removePropertyChangeListener(this);
}
......@@ -709,5 +697,27 @@ public abstract class Property implements ServerPropertyChangeListener, ICommand
public void setShowSettingPropertyMessage(boolean showSettingPropertyMessage) {
this.showSettingPropertyMessage = showSettingPropertyMessage;
}
protected int getDefaultMaxLength() {
return XMLPropertyDescriptor.DEFAULT_STRING_MAX_LENGTH;
}
public abstract String getType();
/**
* <p>
* Has to be implemented in the concret Property classe to set the pVerifyListener. Thus, the hasVerifyListener() method will return true.
* </p>
*
* <p>
* Implement nothing if the concret Property class does not need a pVerifyListener. Thus, the hasVerifyListener() method will return false.
* </p>
*
*/
public abstract void setPVerifyListener();
public abstract boolean isNumeric();
}
\ No newline at end of file
......@@ -189,7 +189,7 @@ public class PropertyManager {
LinkedHashMap<String, XMLPropertyDescriptor> propertiesFromFile = new LinkedHashMap<String, XMLPropertyDescriptor>(propertyParser.getProperties().size());
propertiesFromFile.putAll(propertyParser.getProperties());
propertiesByControllerType.put(propertyParser.getControllerType(), propertiesFromFile);
if (!propertyParser.getDynamicProperties().isEmpty()) {
......
......@@ -37,11 +37,23 @@ public class DecimalFormat extends PropertyFormat {
private int propertyId;
private static java.text.DecimalFormat scientificFormat = new java.text.DecimalFormat("0.###E0");
private static java.text.DecimalFormat scientificFormat = new java.text.DecimalFormat("0.000E00");
private java.text.DecimalFormat df;
private static String[] decimalFormats = new String[] {"0",
"0.#",
private static String[] decimalFormats = new String[] {
"0",
"0.0",
"0.00",
"0.000",
"0.0000",
"0.00000",
"0.000000",
"0.0000000",
"0.00000000",
"0.000000000"};
/*
"0.#",
"0.##",
"0.###",
"0.####",
......@@ -51,7 +63,8 @@ public class DecimalFormat extends PropertyFormat {
"0.########",
"0.#########"};
*/
public DecimalFormat(int numberOfDecimalPlaces, boolean isScientific) {
this.nbOfDecimalPlaces = numberOfDecimalPlaces;
this.isScientific = isScientific;
......
......@@ -26,12 +26,13 @@ import fr.ill.ics.core.property.parser.PropertyParser;
public class XMLPropertyDescriptor {
public static final int DEFAULT_MAX_LENGTH = 15;
public static final int DEFAULT_STRING_MAX_LENGTH = 15;
public static final int DEFAULT_NUMERIC_MAX_LENGTH = 10;
public static final int DEFAULT_NB_PLACES = 2;
protected String propertyName;
protected String propertyType;
private int maxLength = DEFAULT_MAX_LENGTH;
private int maxLength = DEFAULT_STRING_MAX_LENGTH;
private boolean isUndoable = false;
private String format = PropertyParser.TAG_NO_FORMAT;
private int nbDecimalPlaces = DEFAULT_NB_PLACES;
......@@ -63,6 +64,17 @@ public class XMLPropertyDescriptor {
this.propertyType.toLowerCase().equals("unknown") ||
this.propertyType.toLowerCase().equals("longarray"))) {
System.err.println("Warning: unknown property type " + type + " for property " + name);
} else {
if (this.propertyType.toLowerCase().equals("double") ||
this.propertyType.toLowerCase().equals("float32") ||
this.propertyType.toLowerCase().equals("float64") ||
this.propertyType.toLowerCase().equals("int8") ||
this.propertyType.toLowerCase().equals("int16") ||
this.propertyType.toLowerCase().equals("int32") ||
this.propertyType.toLowerCase().equals("int64") ||
this.propertyType.toLowerCase().equals("long")) {
maxLength = DEFAULT_NUMERIC_MAX_LENGTH;
}
}
}
......
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