Commit 0e90e09f authored by Jay Jay Billings's avatar Jay Jay Billings
Browse files

Updated the Renderer and VaadinRendererClient.



They now work with the new IDataElement interface and annotations.
Signed-off-by: default avatarJay Jay Billings <billingsjj@ornl.gov>
parent 6fc8e490
......@@ -20,16 +20,16 @@
<configuration>
<release>11</release>
<annotationProcessorPaths>
<path>
<groupId>com.google.dagger</groupId>
<artifactId>dagger-compiler</artifactId>
<version>2.16</version>
</path>
<path>
<groupId>org.eclipse.ice.dev</groupId>
<artifactId>org.eclipse.ice.dev.annotations</artifactId>
<version>3.0.0-SNAPSHOT</version>
</path>
<path>
<groupId>com.google.dagger</groupId>
<artifactId>dagger-compiler</artifactId>
<version>2.16</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
......
......@@ -15,6 +15,8 @@ import java.io.Serializable;
import java.util.function.BiConsumer;
import javax.inject.Inject;
import org.eclipse.ice.dev.annotations.IDataElement;
/**
* This class is a basic controller that connects data and UI classes in a
* simple, pre-determined way. Data can be provided through the DataElement<V>
......@@ -35,7 +37,7 @@ import javax.inject.Inject;
* @author Jay Jay Billings
*
*/
public class Renderer<T, V extends Serializable> implements Serializable {
public class Renderer<T, V extends IDataElement> implements Serializable {
/**
* Serial version id
......@@ -43,9 +45,9 @@ public class Renderer<T, V extends Serializable> implements Serializable {
private static final long serialVersionUID = -8514680453430699108L;
private T viewer;
private DataElement<V> dataElement;
private V dataElement;
private BiConsumer<T, DataElement<V>> drawMethod;
private BiConsumer<T, V> drawMethod;
@Inject
public void setViewer(T view) {
......@@ -53,11 +55,11 @@ public class Renderer<T, V extends Serializable> implements Serializable {
}
@Inject
public void setDataElement(DataElement<V> data) {
public void setDataElement(V data) {
dataElement = data;
}
public void setDrawMethod(BiConsumer<T, DataElement<V>> drawFunction) {
public void setDrawMethod(BiConsumer<T, V> drawFunction) {
drawMethod = drawFunction;
}
......
......@@ -11,7 +11,6 @@
*******************************************************************************/
package org.eclipse.ice.tests.renderer;
import org.eclipse.ice.renderer.DaggerRendererComponent;
import org.eclipse.ice.renderer.DataElement;
import org.eclipse.ice.renderer.RendererComponent;
......@@ -19,16 +18,16 @@ public class Launcher {
public static void main(String[] args) throws Exception {
RendererComponent rendererComponent = DaggerRendererComponent.create();
DataElement<String> element = (DataElement<String>) rendererComponent.buildDataElement();
element.setName("Enemy");
System.out.println(element.getName());
DataElementTestComponent component = DaggerDataElementTestComponent.create();
RendererRunner runner = component.buildRendererRunner();
// RendererComponent rendererComponent = DaggerRendererComponent.create();
// DataElement<String> element = (DataElement<String>) rendererComponent.buildDataElement();
// element.setName("Enemy");
// System.out.println(element.getName());
//
// DataElementTestComponent component = DaggerDataElementTestComponent.create();
// RendererRunner runner = component.buildRendererRunner();
try {
runner.run();
// runner.run();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
......
......@@ -36,11 +36,11 @@ public class RendererRunner {
//@Inject
//DataElement<Offset> sampleOffset;
@Inject
Renderer<HTMLView, Boolean> renderer;
@Inject
Renderer<HTMLView, String> stringRenderer;
// @Inject
// Renderer<HTMLView, Boolean> renderer;
//
// @Inject
// Renderer<HTMLView, String> stringRenderer;
//@Inject
//Renderer<HTMLView, Offset> osRenderer;
......@@ -65,18 +65,18 @@ public class RendererRunner {
testSomeStuff();
// Setup the renderer
renderer.setDataElement(data);
renderer.setDrawMethod(drawViewFunc);
// renderer.setDataElement(data);
// renderer.setDrawMethod(drawViewFunc);
// Draw the render
renderer.render();
// renderer.render();
// Configure another basic data element with a string value that is the same as
// the last
dataString.setData("true");
stringRenderer.setDataElement(dataString);
stringRenderer.setDrawMethod(stringViewFunc);
stringRenderer.render();
// stringRenderer.setDataElement(dataString);
// stringRenderer.setDrawMethod(stringViewFunc);
// stringRenderer.render();
// Configure one with Pojo data
//osRenderer.setDrawMethod(offsetViewFunc);
......
......@@ -10,10 +10,10 @@
<packaging>jar</packaging>
<properties>
<java.version>11</java.version>
<java.version>11</java.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>11</maven.compiler.release>
<maven.compiler.release>11</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
......@@ -142,6 +142,12 @@
<artifactId>org.eclipse.ice.renderer</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.eclipse.ice.dev</groupId>
<artifactId>org.eclipse.ice.dev.annotations</artifactId>
<version>3.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
......
package gov.ornl.rse.renderer.client.test;
import org.eclipse.ice.renderer.Renderer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class AppConfig {
@Bean
public VaadinRendererClient<String> vaadinRendererClient() {
return new VaadinRendererClient<String>();
}
@Bean
public Renderer<VaadinRendererClient<String>,String> renderer() {
return new Renderer<VaadinRendererClient<String>,String>();
}
@Bean
public Object object() {
return new Object();
}
}
......@@ -12,9 +12,11 @@
package gov.ornl.rse.renderer.client.test;
import java.io.Serializable;
import org.eclipse.ice.dev.annotations.IDataElement;
import org.eclipse.ice.renderer.DataElement;
public interface IRendererClient<T extends Serializable> {
public interface IRendererClient<T extends IDataElement> {
/**
* This operation sets the data that should be rendered.
......@@ -22,7 +24,7 @@ public interface IRendererClient<T extends Serializable> {
* @param otherData The data element that should be rendered. This function
* overwrites the existing data on the client and server.
*/
public void setData(DataElement<T> otherData);
public void setData(T otherData);
/**
* This function returns the present version of the DataElement
......@@ -31,6 +33,6 @@ public interface IRendererClient<T extends Serializable> {
* there is a chance that the most recent updates from the client have
* not been committed due to latency.
*/
public DataElement<T> getData();
public T getData();
}
\ No newline at end of file
......@@ -16,8 +16,12 @@ import java.util.function.BiConsumer;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.eclipse.ice.dev.annotations.IDataElement;
import org.eclipse.ice.renderer.DataElement;
import org.eclipse.ice.renderer.JavascriptValidator;
import org.eclipse.ice.renderer.Renderer;
import org.eclipse.ice.renderer.Person;
import org.eclipse.ice.renderer.PersonImplementation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -27,8 +31,7 @@ import com.vaadin.flow.router.Route;
@Route
public class MainView extends VerticalLayout {
@Autowired
private Renderer<VaadinRendererClient<String>, String> renderer;
private Renderer<VaadinRendererClient<Person>, Person> renderer;
/**
* Constructor
......@@ -44,21 +47,23 @@ public class MainView extends VerticalLayout {
public void render() {
// Nothing to do here - just sample setup
DataElement<String> nameElem = new DataElement<String>();
Person ross = new PersonImplementation();
try {
nameElem.setName("Ross' name");
nameElem.setDescription("Ross' name described by a data element");
nameElem.setData("Ross Whitfield");
ross.setName("Ross Whitfield");
ross.setDescription("Ross' name described by a generated IDataElement");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(ross.toJson());
BiConsumer<VaadinRendererClient<String>, DataElement<String>> drawViewFunc = (v, w) -> {
renderer = new Renderer<VaadinRendererClient<Person>, Person>();
renderer.setViewer(new VaadinRendererClient<Person>());
BiConsumer<VaadinRendererClient<Person>, Person> drawViewFunc = (v, w) -> {
v.setData(w);
add(v);
};
renderer.setDataElement(nameElem);
renderer.setDataElement(ross);
renderer.setDrawMethod(drawViewFunc);
renderer.render();
......
......@@ -16,12 +16,18 @@ package gov.ornl.rse.renderer.client.test;
import java.io.Serializable;
import org.eclipse.ice.dev.annotations.IDataElement;
import org.eclipse.ice.renderer.DataElement;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.mongodb.util.JSON;
import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.Tag;
import com.vaadin.flow.component.dependency.JsModule;
import elemental.json.JsonObject;
/**
* This is a base class for renderer clients tailored to Vaadin. It provides
* the basic accessors for the data member.
......@@ -30,7 +36,7 @@ import com.vaadin.flow.component.dependency.JsModule;
*/
@Tag("renderer-template")
@JsModule("./src/renderer.ts")
public class VaadinRendererClient<T extends Serializable> extends Component implements IRendererClient<T> {
public class VaadinRendererClient<T extends IDataElement> extends Component implements IRendererClient<T> {
/**
* version UID
......@@ -40,7 +46,7 @@ public class VaadinRendererClient<T extends Serializable> extends Component impl
/**
* The local reference to the data element
*/
DataElement<T> data;
T data;
/**
* Constructor
......@@ -49,7 +55,7 @@ public class VaadinRendererClient<T extends Serializable> extends Component impl
// This function updates the data every time the client posts and update.
getElement().addPropertyChangeListener("dataElementJSON", "data-changed", e -> {
String value = getElement().getProperty("dataElementJSON");
data.fromString(value);
data.fromJson(value);
});
}
......@@ -60,9 +66,9 @@ public class VaadinRendererClient<T extends Serializable> extends Component impl
* overwrites the existing data on the client and server.
*/
@Override
public void setData(DataElement<T> otherData) {
public void setData(T otherData) {
data = otherData;
getElement().setProperty("dataElementJSON", data.toString());
getElement().setProperty("dataElementJSON", data.toJson());
}
/**
......@@ -73,7 +79,7 @@ public class VaadinRendererClient<T extends Serializable> extends Component impl
* not been committed due to latency.
*/
@Override
public DataElement<T> getData() {
public T getData() {
return data;
}
......
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