Commit 9157f698 authored by Nico Mack's avatar Nico Mack

Added displayName property to variables

parent 5860ff6c
......@@ -252,6 +252,11 @@ public class EquationSystemBuilder {
attribute = element.getAttributeValue(Externalization.NAME_ATTRIBUTE);
attributes.put(Externalization.NAME_ATTRIBUTE, attribute);
attribute = element.getChildText(Externalization.DISPLAY_NAME_ATTRIBUTE);
if (Strings.isNullOrEmpty(attribute))
attribute = element.getAttributeValue(Externalization.DISPLAY_NAME_ATTRIBUTE);
attributes.put(Externalization.DISPLAY_NAME_ATTRIBUTE, attribute);
attribute = element.getChildText(Externalization.TYPE_ATTRIBUTE);
if (Strings.isNullOrEmpty(attribute))
attribute = element.getAttributeValue(Externalization.TYPE_ATTRIBUTE);
......@@ -315,6 +320,9 @@ public class EquationSystemBuilder {
attributes.get(Externalization.UNIT_ATTRIBUTE),
attributes.get(Externalization.INITIAL_ATTRIBUTE));
if (!Strings.isNullOrEmpty(attributes.get(Externalization.DISPLAY_NAME_ATTRIBUTE)))
variable.setDisplayName(attributes.get(Externalization.DISPLAY_NAME_ATTRIBUTE));
if (Externalization.NUMERIC_TYPE.equals(attributes.get(Externalization.TYPE_ATTRIBUTE))) {
NumericalVariable numericVariable = (NumericalVariable) variable;
......
......@@ -61,6 +61,7 @@ public class Externalization extends NLS {
public static String FROM_ATTRIBUTE;
public static String IMPORTS_ELEMENT;
public static String SYSTEM_ELEMENT;
public static String DISPLAY_NAME_ATTRIBUTE;
public static String TYPE_ATTRIBUTE;
public static String UNIT_ATTRIBUTE;
public static String MINIMUM_ATTRIBUTE;
......
......@@ -18,6 +18,7 @@ NAME_ATTRIBUTE=name
OUTPUTS_ELEMENT=outputs
OUTPUT_ELEMENT=output
PARAMETER_ELEMENT=parameter
DISPLAY_NAME_ATTRIBUTE=displayName
TYPE_ATTRIBUTE=type
INITIAL_ATTRIBUTE=initial
MINIMUM_ATTRIBUTE=minimum
......
......@@ -45,6 +45,8 @@ public abstract class Variable<V> implements Cloneable {
protected String type;
/** The name of the variable. */
protected String name;
/** The name of the variable to be used for display */
protected String displayName;
/** The unit the variable is given in. */
protected String unit;
/** An alternative source to get value of variable from */
......@@ -102,11 +104,37 @@ public abstract class Variable<V> implements Cloneable {
return unit;
}
/**
* Simple getter to identify the class of this variable's content (value)
*
* @return
*/
@SuppressWarnings("unchecked")
public V getContentClass() {
return (V) value.getClass();
}
/**
* Returns the display name of this variable. If display name is not defined the name of the
* variable is returned.
*/
public String getDisplayName() {
return ((displayName != null) && (displayName.length() > 0)) ? displayName : name;
}
/**
* Simple setter for setting the display name for this variable
*
* @param name
* specifies the new display name to be used
*/
public void setDisplayName(String name) {
displayName = name;
}
/**
* Simple getter method for the value held by the {@link Variable} instance.
*
......
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