Commit 8632ff63 authored by Nico Mack's avatar Nico Mack

Added verbose property to VariableScript class

parent 50e50848
......@@ -31,4 +31,5 @@ UPPER_BOUND_RADIUS_NODE=upperBoundRadius
UPPER_BOUND_VARIABLE_NODE=upperBoundVariable
UPPER_STOP_ANGLE_NODE=upperStopAngle
VARIABLE_NODE=variable
VARIABLES_NODE=variables
\ No newline at end of file
VARIABLES_NODE=variables
VERBOSE_NODE=verbose
\ No newline at end of file
......@@ -53,6 +53,7 @@ public class VariableScript extends Script implements VariableBased, InputChange
private Equation equation;
private HashMap<String, Variable<?>> parameters;
private Variable<?> result;
private boolean verbose;
// ***************************************************************************
// * Constants *
......@@ -87,6 +88,7 @@ public class VariableScript extends Script implements VariableBased, InputChange
this.property = builder.property;
this.parameters = builder.parameters;
this.expression = builder.expression;
this.verbose = builder.verbose;
}
// ---------------------------------------------------------------------------
......@@ -107,7 +109,7 @@ public class VariableScript extends Script implements VariableBased, InputChange
this.equation = new Equation(ScriptableCondition.class.getName(), new Mapping(inputs, outputs), expression);
JavascriptExecutor executor = new JavascriptExecutor();
executor.setVerbosity(false);
executor.setVerbosity(this.verbose);
this.equation.setExecutor(executor);
}
......
......@@ -22,6 +22,7 @@ import lu.list.itis.dkd.tui.cps.variable.NumericalVariable;
import lu.list.itis.dkd.tui.cps.variable.Variable;
import lu.list.itis.dkd.tui.exception.BuildException;
import lu.list.itis.dkd.tui.scripting.VariableScript;
import lu.list.itis.dkd.tui.utility.CpsNamespace;
import lu.list.itis.dkd.tui.utility.Externalization;
import org.jdom2.Element;
......@@ -42,6 +43,7 @@ import java.util.HashMap;
public abstract class BaseVariableScriptBuilder<B extends BaseVariableScriptBuilder<B>> extends BaseScriptBuilder<B> {
public HashMap<String, Variable<?>> parameters;
public boolean verbose;
// ***************************************************************************
// * Constants *
......@@ -93,6 +95,7 @@ public abstract class BaseVariableScriptBuilder<B extends BaseVariableScriptBuil
double initial = BootstrappingUtils.getAttributeAsDouble(parameterNode, EquationSystemBundle.INITIAL_ATTRIBUTE, BootstrappingUtils.OPTIONAL, 0d);
parameters.put(identifier, new NumericalVariable(identifier, Externalization.EMPTY_STRING, initial));
}
verbose = BootstrappingUtils.getAttributeAsBoolean(rootElement, CpsNamespace.VERBOSE_NODE, BootstrappingUtils.OPTIONAL, Boolean.FALSE);
}
// ---------------------------------------------------------------------------
......
......@@ -75,6 +75,8 @@ public class CpsNamespace extends NLS {
public static String VARIABLE_NODE;
public static String VARIABLES_NODE;
public static String VERBOSE_NODE;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, CpsNamespace.class);
......
package lu.list.itis.dkd.tui.widget.corona;
import lu.list.itis.dkd.tui.content.InformationReceiver;
import lu.list.itis.dkd.tui.cps.InputChangeListener;
import lu.list.itis.dkd.tui.cps.InputEvent;
import lu.list.itis.dkd.tui.cps.system.VariableBased;
import lu.list.itis.dkd.tui.cps.variable.NumericalVariable;
import lu.list.itis.dkd.tui.cps.variable.Variable;
......@@ -26,7 +27,7 @@ import java.util.Map;
// * Class Definition and Members *
// ***************************************************************************
public class SectorDisplay extends Sector implements InformationReceiver<Object>, VariableBased {
public class SectorDisplay extends Sector implements VariableBased, InputChangeListener {
protected NumericalVariable variable;
// ***************************************************************************
......@@ -46,7 +47,7 @@ public class SectorDisplay extends Sector implements InformationReceiver<Object>
public SectorDisplay(BaseSectorDisplayBuilder<?> builder) {
super(builder);
this.variable = builder.variable;
this.setInformation(this.variable.getValue());
this.renderLabel(this.variable.toString(false));
}
// ---------------------------------------------------------------------------
......@@ -87,16 +88,6 @@ public class SectorDisplay extends Sector implements InformationReceiver<Object>
// ---------------------------------------------------------------------------
@Override
public void setInformation(Object information) {
if (information != null) {
this.variable.setValue(this.variable.valueFromString(information.toString()));
this.renderLabel(this.variable.toString(false));
}
}
// ---------------------------------------------------------------------------
@Override
public SectorDisplay clone() {
return new SectorDisplay(this);
......@@ -111,8 +102,6 @@ public class SectorDisplay extends Sector implements InformationReceiver<Object>
Preconditions.checkArgument(systemVariables != null, "Set of variables can't be null!"); //$NON-NLS-1$
assert systemVariables != null;
Variable<?> systemVariable;
NumericalVariable numerical;
......@@ -121,6 +110,7 @@ public class SectorDisplay extends Sector implements InformationReceiver<Object>
numerical = Variable.castTo(systemVariable, NumericalVariable.class);
if (numerical != null) {
this.variable = numerical;
this.variable.addListener(this);
connected.add(this.variable);
}
}
......@@ -133,8 +123,6 @@ public class SectorDisplay extends Sector implements InformationReceiver<Object>
}
}
return connected;
}
......@@ -149,6 +137,14 @@ public class SectorDisplay extends Sector implements InformationReceiver<Object>
return declared;
}
// ---------------------------------------------------------------------------
/** {@inheritDoc} */
@Override
public void inputChanged(InputEvent input) {
this.renderLabel(this.variable.toString(false));
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * End of Class *
......
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