Commit 3b79fbe1 authored by yannick legoc's avatar yannick legoc
Browse files

separated property object creation from configuration before adding automatically the properties

parent efb99575
......@@ -63,12 +63,10 @@ public class PropertyFactory {
return instance;
}
public Property createProperty(int containerId, int id, XMLPropertyDescriptor propertyDescriptor, boolean isCommandBox) {
public Property createProperty(int containerId, int id, String type, boolean isCommandBox) {
// Create basic property
Property property = null;
String type = propertyDescriptor.getPropertyType().toLowerCase();
//String type = propertyDescriptor.getPropertyType().toLowerCase();
if (type.equals("unknown")) {
// Get property type directly from the controller
......@@ -95,11 +93,9 @@ public class PropertyFactory {
} else if (type.equals("float32")) {
property = new Float32Property(containerId, id, isCommandBox);
property.setPropertyFormat(new DecimalFormat(propertyDescriptor, id, false));
} else if (type.equals("float64") || type.equals("double")) {
property = new Float64Property(containerId, id, isCommandBox);
property.setPropertyFormat(new DecimalFormat(propertyDescriptor, id, false));
} else if (type.equals("boolean") || type.equals("Boolean")) {
property = new BooleanProperty(containerId, id, isCommandBox);
......@@ -129,8 +125,25 @@ public class PropertyFactory {
property = new StringProperty(containerId, id, isCommandBox);
LOGGER.log(Level.WARNING, "Unable to manage type " + type + " for property " + id);
}
return property;
}
// add format
public Property configureProperty(Property property, XMLPropertyDescriptor propertyDescriptor) {
// Create basic property
String type = propertyDescriptor.getPropertyType().toLowerCase();
int id = property.getPropertyID();
if (type.equals("float32")) {
property.setPropertyFormat(new DecimalFormat(propertyDescriptor, id, false));
} else if (type.equals("float64") || type.equals("double")) {
property.setPropertyFormat(new DecimalFormat(propertyDescriptor, id, false));
}
// add format
if (propertyDescriptor.getFormat().equals(PropertyParser.TAG_DECIMAL_FORMAT)) {
property.setPropertyFormat(new DecimalFormat(propertyDescriptor, id, false));
......@@ -182,6 +195,15 @@ public class PropertyFactory {
return property;
}
public Property createProperty(int containerId, int id, XMLPropertyDescriptor propertyDescriptor, boolean isCommandBox) {
// Create basic property
String type = propertyDescriptor.getPropertyType().toLowerCase();
Property property = createProperty(containerId, id, type, isCommandBox);
configureProperty(property, propertyDescriptor);
return property;
}
/**
*
......
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