Commit 08517080 authored by Cristina Cocho's avatar Cristina Cocho
Browse files

Modifications in both NomadGUI and NomadCommandSystem related to multiplot management

parent 6c799374
......@@ -27,6 +27,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
......@@ -48,8 +49,6 @@ import fr.ill.ics.nscclient.dataprovider.PropertyDatabase;
import fr.ill.ics.nscclient.dataprovider.ServantDatabase;
import fr.ill.ics.nscclient.servant.DynamicPropertyDescriptor;
public class PropertyFactory {
private static final Logger LOGGER = Logger.getLogger(PropertyFactory.class.getName());
......@@ -64,15 +63,15 @@ public class PropertyFactory {
}
public Property createProperty(int containerId, int id, String type, boolean isCommandBox) {
Property property = null;
//String type = propertyDescriptor.getPropertyType().toLowerCase();
// String type = propertyDescriptor.getPropertyType().toLowerCase();
if (type.equals("unknown")) {
// Get property type directly from the controller
type = PropertyDatabase.getInstance().getPropertyType(id);
}
if (type == null) {
type = "string";
LOGGER.log(Level.WARNING, "Unable to find type for property " + id);
......@@ -103,10 +102,10 @@ public class PropertyFactory {
} else if (type.equals("string") || type.equals("String")) {
property = new StringProperty(containerId, id, isCommandBox);
} else if (type.equals("int8array") ) {
} else if (type.equals("int8array")) {
property = new Int8ArrayProperty(containerId, id, isCommandBox);
} else if (type.equals("int16array") ) {
} else if (type.equals("int16array")) {
property = new Int16ArrayProperty(containerId, id, isCommandBox);
} else if (type.equals("int32array") || type.equals("longarray")) {
......@@ -125,25 +124,24 @@ public class PropertyFactory {
property = new StringProperty(containerId, id, isCommandBox);
LOGGER.log(Level.WARNING, "Unable to manage type " + type + " for property " + id);
}
return property;
}
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
// add format
if (propertyDescriptor.getFormat().equals(PropertyParser.TAG_DECIMAL_FORMAT)) {
property.setPropertyFormat(new DecimalFormat(propertyDescriptor, id, false));
......@@ -198,10 +196,10 @@ public class PropertyFactory {
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;
}
......@@ -217,7 +215,6 @@ public class PropertyFactory {
return new DynamicProperty(containerId, id, isCommandBox);
}
/**
* <p>Walks through the propertyDescriptors map to create Property instances for the given controller id from PropertyDescriptor ones.<br/>
* Property instances are stored as values as the returned map (property names as keys).</p>
......@@ -240,7 +237,6 @@ public class PropertyFactory {
return properties;
}
/**
*
* @param databaseId
......@@ -271,10 +267,29 @@ public class PropertyFactory {
} else {
// trying with "double" dynamic properties
String genericPropertyName = xmlDynamicPropertyDescriptor.getPropertyName();
int index = 0;
boolean hasNext = true;
while (hasNext) {
String genericPropertyName = xmlDynamicPropertyDescriptor.getPropertyName();
Set<DynamicPropertyDescriptor> doubleDynamicPropertyDescriptors = PropertyDatabase.getInstance().getDoubleDynamicPropertyDescriptor(servantId, genericPropertyName);
if (doubleDynamicPropertyDescriptors != null) {
Iterator<DynamicPropertyDescriptor> iter = doubleDynamicPropertyDescriptors.iterator();
while (iter.hasNext()) {
DynamicPropertyDescriptor descriptor = iter.next();
String dynamicPropertyName = descriptor.getName();
LinkedHashSet<Property> childProperties = new LinkedHashSet<Property>();
DynamicProperty dynamicProperty = new DynamicProperty(databaseId, descriptor.getId(), false);
List<Integer> ids = descriptor.getIds();
for (int i = 0; i < ids.size(); i++) {
childProperties.add(createProperty(databaseId, ids.get(i), xmlDynamicPropertyDescriptor, false));
}
dynamicProperty.setProperties(childProperties);
dynamicProperties.put(dynamicPropertyName, dynamicProperty);
}
}
/*
String genericPropertyName = xmlDynamicPropertyDescriptor.getPropertyName();
int index = 0;
boolean hasNext = true;
while (hasNext) {
String indexPropertyName = genericPropertyName + "." + index;
dynamicPropertyDescriptor = PropertyDatabase.getInstance().getDynamicPropertyDescriptor(servantId, indexPropertyName);
......@@ -297,14 +312,14 @@ public class PropertyFactory {
} else {
hasNext = false;
/*
if (index == 0) {
System.err.println("Dynamic property " + genericPropertyName + " from " + servantId + " not found in server");
} else {
//System.out.println("Dynamic property " + indexPropertyName + " added from " + servantId);
}*/
}
}
}
}*/
}
}
......@@ -313,7 +328,6 @@ public class PropertyFactory {
return null;
}
/**
* Clones given property.
* @param property
......@@ -327,7 +341,7 @@ public class PropertyFactory {
int id = property.getPropertyID();
int databaseId = property.getContainerID();
boolean isCommandBox = property.isCommandBox;
if (type.equals("int8")) {
clone = new Int8Property(databaseId, id, isCommandBox);
} else if (type.equals("int16")) {
......@@ -378,7 +392,6 @@ public class PropertyFactory {
return clone;
}
/**
*
* @param property
......@@ -390,9 +403,9 @@ public class PropertyFactory {
clone.setMaxLength(property.getMaxLength());
clone.setMaxLengthOnlyForTextFieldSize(true);
// what is this for ?!
//if (!isTrueString) { // ???
// clone.setValue(property.getValue());
//}
// if (!isTrueString) { // ???
// clone.setValue(property.getValue());
// }
if (property.getPropertyFormat() != null) {
if (property.getPropertyFormat() instanceof UnitFormat) {
......@@ -401,7 +414,7 @@ public class PropertyFactory {
}
return clone;
}
/**
*
* @param property
......@@ -412,7 +425,7 @@ public class PropertyFactory {
clone.setUndoable();
clone.setMaxLength(property.getMaxLength());
clone.setMaxLengthOnlyForTextFieldSize(true);
clone.setValue(property.getValue());
if (property.getPropertyFormat() != null) {
......
......@@ -369,6 +369,29 @@ public class PropertyDatabase {
return null;
}
/**
* Get all "double dynamic" properties that have the same "genericPropertyName"
* Important detail: for a double dynamic property, the name of the propertyDescriptor contains the father index, that is, it is sth like: nameOfDoubleDynamicProperty.i
* @param servantId
* @param genericPropertyName
* @return
*/
public Set<DynamicPropertyDescriptor> getDoubleDynamicPropertyDescriptor(int servantId, String genericPropertyName) {
//Iterate through dynamicPropertiesbyServant to find all the properties that has the same genericPropertyName
Set<DynamicPropertyDescriptor> descriptors = dynamicPropertiesByServant.get(servantId);
Set<DynamicPropertyDescriptor> doubleDynamicDescriptors = new HashSet<DynamicPropertyDescriptor>();
if (descriptors != null) {
Iterator<DynamicPropertyDescriptor> it = descriptors.iterator();
while (it.hasNext()) {
DynamicPropertyDescriptor descriptor = it.next();
if (descriptor.getName().contains(".") && descriptor.getName().contains(genericPropertyName)) {
doubleDynamicDescriptors.add(descriptor);
}
}
}
return doubleDynamicDescriptors;
}
/**
*
......
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