Commit 1cf4b590 authored by Nico Mack's avatar Nico Mack

Added VariableValue property to VariableBasedCallback

Adds VariableBased Coronas as Listeners of ValueWidget
parent 0ce9998f
...@@ -127,6 +127,7 @@ public class VariableBasedCallback implements BootstrapCallback { ...@@ -127,6 +127,7 @@ public class VariableBasedCallback implements BootstrapCallback {
context.setProperty(Templating.VARIABLE_NAME_PROPERTY, variable.getName()); context.setProperty(Templating.VARIABLE_NAME_PROPERTY, variable.getName());
context.setProperty(Templating.VARIABLE_DISPLAY_NAME_PROPERTY, variable.getDisplayName()); context.setProperty(Templating.VARIABLE_DISPLAY_NAME_PROPERTY, variable.getDisplayName());
context.setProperty(Templating.VARIABLE_UNIT_PROPERTY, variable.getUnit()); context.setProperty(Templating.VARIABLE_UNIT_PROPERTY, variable.getUnit());
context.setProperty(Templating.VARIABLE_VALUE_PROPERTY, variable.getValue());
if (variable instanceof NumericalVariable) { if (variable instanceof NumericalVariable) {
NumericalVariable numerical = (NumericalVariable) variable; NumericalVariable numerical = (NumericalVariable) variable;
......
...@@ -36,6 +36,7 @@ public class VariableBootstrapper { ...@@ -36,6 +36,7 @@ public class VariableBootstrapper {
String name = BootstrappingUtils.getContentAsString(variableNode, EquationSystemBundle.NAME_ATTRIBUTE, BootstrappingUtils.MANDATORY, null, context); String name = BootstrappingUtils.getContentAsString(variableNode, EquationSystemBundle.NAME_ATTRIBUTE, BootstrappingUtils.MANDATORY, null, context);
String type = BootstrappingUtils.getContentAsString(variableNode, EquationSystemBundle.TYPE_NODE, BootstrappingUtils.MANDATORY, null, context); String type = BootstrappingUtils.getContentAsString(variableNode, EquationSystemBundle.TYPE_NODE, BootstrappingUtils.MANDATORY, null, context);
switch (type) { switch (type) {
case EquationSystemBundle.NUMERIC_TYPE: case EquationSystemBundle.NUMERIC_TYPE:
String unit = BootstrappingUtils.getContentAsString(variableNode, EquationSystemBundle.UNIT_ATTRIBUTE, BootstrappingUtils.OPTIONAL, EquationSystemBundle.EMPTY_STRING, context); String unit = BootstrappingUtils.getContentAsString(variableNode, EquationSystemBundle.UNIT_ATTRIBUTE, BootstrappingUtils.OPTIONAL, EquationSystemBundle.EMPTY_STRING, context);
......
...@@ -174,8 +174,8 @@ public class EquationSystemBuilder { ...@@ -174,8 +174,8 @@ public class EquationSystemBuilder {
variableClass = properties.getProperty(EquationSystemBundle.LOGIC_VARIABLE_CLASS); variableClass = properties.getProperty(EquationSystemBundle.LOGIC_VARIABLE_CLASS);
variable = (Variable<T>) Class.forName(variableClass) variable = (Variable<T>) Class.forName(variableClass)
.getConstructor(String.class, String.class, boolean.class) .getConstructor(String.class, boolean.class)
.newInstance(name, unit, false); .newInstance(name, false);
if (!Strings.isNullOrEmpty(value)) if (!Strings.isNullOrEmpty(value))
variable.setValue(variable.valueFromString(value)); variable.setValue(variable.valueFromString(value));
...@@ -326,9 +326,9 @@ public class EquationSystemBuilder { ...@@ -326,9 +326,9 @@ public class EquationSystemBuilder {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/** /**
* Checks whether the specified equation creates a dependency cycle. Dependency cycles occur * Checks whether the specified equation creates a dependency cycle. Dependency cycles occur when
* when two equations are mutually dependent, i.e. equation 1 has an input parameter being the * two equations are mutually dependent, i.e. equation 1 has an input parameter being the result of
* result of equation 2 and vice versa. * equation 2 and vice versa.
* *
* @param equation * @param equation
* specifies the XML node representing the equation * specifies the XML node representing the equation
...@@ -360,8 +360,8 @@ public class EquationSystemBuilder { ...@@ -360,8 +360,8 @@ public class EquationSystemBuilder {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/** /**
* Checks whether all defined output variables are connected to a corresponding equation to get * Checks whether all defined output variables are connected to a corresponding equation to get the
* the values from. * values from.
* *
* @return <code>true</code> if all output variables are assigned to an equation. * @return <code>true</code> if all output variables are assigned to an equation.
*/ */
...@@ -677,8 +677,8 @@ public class EquationSystemBuilder { ...@@ -677,8 +677,8 @@ public class EquationSystemBuilder {
* @param equationFile * @param equationFile
* The file containing the XML representation of the equation system. * The file containing the XML representation of the equation system.
* @throws EquationSystemException * @throws EquationSystemException
* Thrown when the file is <code>null</code>, does not exist, or if a required tag to * Thrown when the file is <code>null</code>, does not exist, or if a required tag to parse
* parse the file correctly is missing. * the file correctly is missing.
*/ */
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -706,11 +706,10 @@ public class EquationSystemBuilder { ...@@ -706,11 +706,10 @@ public class EquationSystemBuilder {
* Method used to build an equation system from a provided element. * Method used to build an equation system from a provided element.
* *
* @param element * @param element
* The element holding, as child elements, the required data to build the equation * The element holding, as child elements, the required data to build the equation system.
* system.
* @throws EquationSystemException * @throws EquationSystemException
* Thrown when an error in the equation system specification prevented the equation * Thrown when an error in the equation system specification prevented the equation system
* system from being built. * from being built.
*/ */
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
......
...@@ -35,6 +35,7 @@ IMPORTS_ELEMENT=imports ...@@ -35,6 +35,7 @@ IMPORTS_ELEMENT=imports
IMPORT_ELEMENT=import IMPORT_ELEMENT=import
FUNCTION_ATTRIBUTE=function FUNCTION_ATTRIBUTE=function
FROM_ATTRIBUTE=from FROM_ATTRIBUTE=from
SCOPE_ATTRIBUTE=scope
SYSTEM_ELEMENT=system SYSTEM_ELEMENT=system
UNIT_ATTRIBUTE=unit UNIT_ATTRIBUTE=unit
TYPE_NODE=type TYPE_NODE=type
\ No newline at end of file
...@@ -146,8 +146,8 @@ public abstract class Variable<V> implements Cloneable { ...@@ -146,8 +146,8 @@ public abstract class Variable<V> implements Cloneable {
/** /**
* Simple getter method for the value held by the {@link Variable} instance. Reading the value * Simple getter method for the value held by the {@link Variable} instance. Reading the value will
* will reset the modified flag. * reset the modified flag.
* *
* @return The value held by the {@link Variable} instance. * @return The value held by the {@link Variable} instance.
*/ */
...@@ -159,8 +159,7 @@ public abstract class Variable<V> implements Cloneable { ...@@ -159,8 +159,7 @@ public abstract class Variable<V> implements Cloneable {
/** /**
* checks whether this variable was modified since it was read for the last time. * * checks whether this variable was modified since it was read for the last time. *
* *
* @return <code>true</code> if variable was modified since last read, <code>false</code> * @return <code>true</code> if variable was modified since last read, <code>false</code> otherwise.
* otherwise.
*/ */
public boolean wasModified() { public boolean wasModified() {
...@@ -312,8 +311,8 @@ public abstract class Variable<V> implements Cloneable { ...@@ -312,8 +311,8 @@ public abstract class Variable<V> implements Cloneable {
/** /**
* Method invoked to add a {@link InputChangeListener} to the {@link Vector} of listeners to * Method invoked to add a {@link InputChangeListener} to the {@link Vector} of listeners to notify
* notify on tick. * on tick.
* *
* @param listener * @param listener
* The {@link InputChangeListener} to add. * The {@link InputChangeListener} to add.
...@@ -325,12 +324,12 @@ public abstract class Variable<V> implements Cloneable { ...@@ -325,12 +324,12 @@ public abstract class Variable<V> implements Cloneable {
} }
/** /**
* Sets the suspendNotification flag for InputChangeListeners. When suspend, * Sets the suspendNotification flag for InputChangeListeners. When suspend, InputChangeListeners
* InputChangeListeners will not be notified on value changes. * will not be notified on value changes.
* *
* @param suspend * @param suspend
* specify <code>true</true> to suspend listener notification, <code>false</code> to * specify <code>true</true> to suspend listener notification, <code>false</code> to enable
* enable notification of InputChangeListerners on value change. * notification of InputChangeListerners on value change.
* @see #consolidateListeners * @see #consolidateListeners
*/ */
public synchronized void suspendListenerNotification(boolean suspend) { public synchronized void suspendListenerNotification(boolean suspend) {
...@@ -346,12 +345,12 @@ public abstract class Variable<V> implements Cloneable { ...@@ -346,12 +345,12 @@ public abstract class Variable<V> implements Cloneable {
} }
/** /**
* Causes this variable to add its InputChangeListeners to the specified HashMap. HashMap * Causes this variable to add its InputChangeListeners to the specified HashMap. HashMap ensures
* ensures that no duplicate listeners will be added to consolidated list. * that no duplicate listeners will be added to consolidated list.
* *
* @param consolidated * @param consolidated
* specifies the HashMap to add this variables' listeners to. Note that key-value pair * specifies the HashMap to add this variables' listeners to. Note that key-value pair with
* with identical listener key will be replaced by entry inserted by this call. * identical listener key will be replaced by entry inserted by this call.
* @return specified HashMap enriched by this variables' listeners. * @return specified HashMap enriched by this variables' listeners.
*/ */
...@@ -363,8 +362,8 @@ public abstract class Variable<V> implements Cloneable { ...@@ -363,8 +362,8 @@ public abstract class Variable<V> implements Cloneable {
} }
/** /**
* Invokes inputChanged method of each registered InputChangeListener unless consolidated flag * Invokes inputChanged method of each registered InputChangeListener unless consolidated flag is
* is raised * raised
* *
* @param event * @param event
* specifies the event to be passed to each listeners inputChanged method. * specifies the event to be passed to each listeners inputChanged method.
......
...@@ -366,6 +366,12 @@ public class ValueWidget extends TetherableWidget implements InformationProvider ...@@ -366,6 +366,12 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
} }
} }
List<VariableBased> displays = this.getCoronas(VariableBased.class);
for (VariableBased display : displays) {
connected.addAll(display.connectWithSystemVariables(systemVariables));
}
return connected; return connected;
} }
......
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