Commit a91b8acb authored by Nico Mack's avatar Nico Mack

Added ExecutorScope Annotation

parent 6a5a0730
......@@ -15,6 +15,7 @@ package lu.list.itis.dkd.tui.bootstrapping;
import lu.list.itis.dkd.tui.cps.utility.Externalization;
import lu.list.itis.dkd.tui.cps.variable.BooleanVariable;
import lu.list.itis.dkd.tui.cps.variable.TextVariable;
import lu.list.itis.dkd.tui.cps.variable.Variable;
import lu.list.itis.dkd.tui.cps.variable.tangible.TangibleNumericalVariable;
import lu.list.itis.dkd.tui.exception.BuildException;
......@@ -55,6 +56,12 @@ public class VariableBootstrapper {
variable = booleanVariable;
break;
case Externalization.TEXT_TYPE:
String textValue = BootstrappingUtils.getContentAsString(variableNode, Externalization.INITIAL_ATTRIBUTE, BootstrappingUtils.OPTIONAL, Externalization.EMPTY_STRING, context);
TextVariable textVariable = new TextVariable(name, textValue);
variable = textVariable;
break;
default:
throw new BuildException("Don't know how to build a Variable of type " + type); //$NON-NLS-1$
}
......
......@@ -31,6 +31,9 @@ public class JavascriptExecutor extends Executor {
@Override
public void set(Variable<?> variable) {
// TODO Rely on ExecutorScope annotations to generalize setting of multi-value variables
engine.put(variable.getName(), variable.getValue());
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Parameter {} = {}", variable.getName(), variable.getValue()); //$NON-NLS-1$
......
/**
* Copyright Luxembourg Institute of Science and Technology, 2017. All rights reserved. If you wish
* to use this code for any purpose, please contact the author(s).
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package lu.list.itis.dkd.tui.cps.utility;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@Retention(RUNTIME)
@Target(METHOD)
/**
* @author mack
* @since [major].[minor]
* @version [major].[minor].[micro]
*/
public @interface ExecutorScope {
String identifier() default "";
}
......@@ -14,6 +14,7 @@
package lu.list.itis.dkd.tui.cps.variable;
import lu.list.itis.dkd.dbc.annotation.Nullable;
import lu.list.itis.dkd.tui.cps.utility.ExecutorScope;
import lu.list.itis.dkd.tui.cps.utility.Externalization;
import lu.list.itis.dkd.tui.utility.Point;
......@@ -133,5 +134,43 @@ public class SpatialVariable extends Variable<Point> {
return converted;
}
@ExecutorScope(identifier = "x")
public double getX() {
return (this.value != null) ? this.value.getX() : 0;
}
@ExecutorScope(identifier = "x")
public void setX(double value) {
if (this.value == null) {
this.value = new Point();
}
this.value.x = (float) value;
}
@ExecutorScope(identifier = "y")
public double getY() {
return (this.value != null) ? this.value.getY() : 0;
}
@ExecutorScope(identifier = "y")
public void setY(double value) {
if (this.value == null) {
this.value = new Point();
}
this.value.y = (float) value;
}
@ExecutorScope(identifier = "a")
public double getA() {
return (this.value != null) ? this.value.getAngle() : 0;
}
@ExecutorScope(identifier = "a")
public void setAngle(double value) {
if (this.value == null) {
this.value = new Point();
}
this.value.setAngle((float) value);
}
}
......@@ -32,7 +32,7 @@ import lu.list.itis.dkd.tui.utility.Point;
import lu.list.itis.dkd.tui.widget.builder.BaseValueWidgetBuilder;
import lu.list.itis.dkd.tui.widget.corona.ConditionalCorona;
import lu.list.itis.dkd.tui.widget.corona.Corona;
import lu.list.itis.dkd.tui.widget.tether.DataFeed;
import lu.list.itis.dkd.tui.widget.tether.InformationFeed;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -125,8 +125,8 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
@SuppressWarnings("unchecked")
protected void updateTethers(Double value) {
@SuppressWarnings("rawtypes")
List<DataFeed> dataFeeds = this.getTethers(DataFeed.class);
for (DataFeed<Double> tether : dataFeeds) {
List<InformationFeed> dataFeeds = this.getTethers(InformationFeed.class);
for (InformationFeed<Double> tether : dataFeeds) {
tether.setInformation(value);
}
}
......
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