diff --git a/.classpath b/.classpath new file mode 100644 index 000000000..73accf64d --- /dev/null +++ b/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 000000000..77b04f7d6 --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + owlcms4top + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000..4824b8026 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..f494d1de0 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000..14b697b7b --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/doc/.classpath b/doc/.classpath new file mode 100644 index 000000000..6f3a3b1d6 --- /dev/null +++ b/doc/.classpath @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/.project b/doc/.project new file mode 100644 index 000000000..5659649a3 --- /dev/null +++ b/doc/.project @@ -0,0 +1,23 @@ + + + doc + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/doc/.settings/org.eclipse.core.resources.prefs b/doc/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000..4824b8026 --- /dev/null +++ b/doc/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/doc/.settings/org.eclipse.jdt.core.prefs b/doc/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..f494d1de0 --- /dev/null +++ b/doc/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/doc/.settings/org.eclipse.m2e.core.prefs b/doc/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000..14b697b7b --- /dev/null +++ b/doc/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/doc/pom.xml b/doc/pom.xml new file mode 100644 index 000000000..ea64f8c03 --- /dev/null +++ b/doc/pom.xml @@ -0,0 +1,9 @@ + + 4.0.0 + + org.ledocte + owlcms4top + 0.0.1-SNAPSHOT + + doc + \ No newline at end of file diff --git a/doc/src/site/documents/MockupNEC.pptx b/doc/src/site/documents/MockupNEC.pptx new file mode 100644 index 000000000..9a9917889 Binary files /dev/null and b/doc/src/site/documents/MockupNEC.pptx differ diff --git a/doc/src/site/markdown/design.md b/doc/src/site/markdown/design.md new file mode 100644 index 000000000..6c7836cbc --- /dev/null +++ b/doc/src/site/markdown/design.md @@ -0,0 +1,25 @@ +# Design Notes + +## Browser-side Behaviour +### Referee Decisions +1. Use a "referee-decisions" web-component polymer template that contains both the divs that show the results and listens to inputs. + + Use a [polymer-keydown component](https://github.com/dmytroyarmak/polymer-keydown) to listen to keys + + Include the referee divs and the code that changes their color based on key presses in the template + + Include the code that updates the colors based on remote inputs (e.g. phones or tablets) -- *Synchronize with flow* + + Include a variation with a single div for situations where announcer enters the decision (e.g. no refs, jury override) ++ Need to figure out how to stop countdown timer on keypress. Is there a global js scope -- we need to avoid round-trip. + +### Countdown Timer +1. Use a "slave-countdown-timer" web-component polymer template except when connected to refereeing devices (pressing will stop timer) or acting as time keeper + + Timer is started from server-side + + Timer is stopped from server-side ++ Refereeing and marshall use a "stop-countdown-timer" + + timer is stopped client-side -- referee down signal while timer still running and stop is sent to server + + server stops all other counters ++ Timekeeper (or announcer acting as timekeeper) uses a "master-countdown-timer" + + timekeeper (or announcer acting as timekeeper) can stop and start + + Timer is stopped from server-side by refereeing and marshall + + + + \ No newline at end of file diff --git a/pocCurrentAttempt/.classpath b/pocCurrentAttempt/.classpath new file mode 100644 index 000000000..d2bc4e02a --- /dev/null +++ b/pocCurrentAttempt/.classpath @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pocCurrentAttempt/.project b/pocCurrentAttempt/.project new file mode 100644 index 000000000..1ccda8eec --- /dev/null +++ b/pocCurrentAttempt/.project @@ -0,0 +1,23 @@ + + + pocTodoGrid + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/pocCurrentAttempt/.settings/org.eclipse.core.resources.prefs b/pocCurrentAttempt/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000..04cfa2c1a --- /dev/null +++ b/pocCurrentAttempt/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 +encoding//src/test/java=UTF-8 +encoding//src/test/resources=UTF-8 +encoding/=UTF-8 diff --git a/pocCurrentAttempt/.settings/org.eclipse.jdt.core.prefs b/pocCurrentAttempt/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..f494d1de0 --- /dev/null +++ b/pocCurrentAttempt/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/pocCurrentAttempt/.settings/org.eclipse.m2e.core.prefs b/pocCurrentAttempt/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000..14b697b7b --- /dev/null +++ b/pocCurrentAttempt/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/pocCurrentAttempt/pom.xml b/pocCurrentAttempt/pom.xml new file mode 100644 index 000000000..1782288fa --- /dev/null +++ b/pocCurrentAttempt/pom.xml @@ -0,0 +1,177 @@ + + 4.0.0 + + org.ledocte + owlcms4top + 0.0.1-SNAPSHOT + + + Polymer Proof-of-Concept + pocTodoGrid + war + + + + + org.webjars.bowergithub.polymerelements + paper-styles + 2.0.0 + + + org.webjars.bowergithub.polymerelements + font-roboto + 1.0.3 + + + org.webjars.bowergithub.polymerelements + iron-autogrow-textarea + 2.1.0 + + + org.webjars.bowergithub.polymerelements + iron-validatable-behavior + 2.0.0 + + + org.webjars.bowergithub.polymerelements + iron-input + 2.0.1 + + + org.webjars.bowergithub.polymerelements + iron-form-element-behavior + 2.0.0 + + + org.webjars.bowergithub.polymerelements + paper-behaviors + 2.0.1 + + + org.webjars.bowergithub.polymerelements + iron-checked-element-behavior + 2.0.0 + + + org.webjars.bowergithub.polymerelements + paper-ripple + 2.0.1 + + + org.webjars.bowergithub.webcomponents + shadycss + 1.2.0-0 + + + + + + + + + org.webjars.bowergithub.polymer + polymer + + + org.webjars.bowergithub.polymerelements + paper-input + 2.1.1 + + + org.webjars.bowergithub.polymerelements + paper-fab + 2.0.0 + + + org.webjars.bowergithub.polymerelements + iron-icons + 2.0.1 + + + org.webjars.bowergithub.polymerelements + paper-checkbox + 2.0.2 + + + org.webjars.bowergithub.polymerelements + paper-item + 2.0.0 + + + + + + productionMode + + + vaadin.productionMode + + + + + ${project.build.directory}/build + + + + + com.vaadin + flow-server-production-mode + ${flow.version} + + + + + + + com.vaadin + flow-maven-plugin + ${flow.plugin.version} + + + + copy-production-files + package-for-production + + + ${transpilation.output} + + + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven.war.plugin.version} + + + + ${transpilation.output} + + + + + + + org.eclipse.jetty + jetty-maven-plugin + ${jetty.version} + + + ^$ + + ${transpilation.output} + + + + + + + + + \ No newline at end of file diff --git a/pocCurrentAttempt/src/main/java/com/vaadin/flow/demo/helloworld/template/Todo.java b/pocCurrentAttempt/src/main/java/com/vaadin/flow/demo/helloworld/template/Todo.java new file mode 100644 index 000000000..8e75d258e --- /dev/null +++ b/pocCurrentAttempt/src/main/java/com/vaadin/flow/demo/helloworld/template/Todo.java @@ -0,0 +1,84 @@ +/* + * Copyright 2000-2017 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.flow.demo.helloworld.template; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + * Todo item. + */ +public class Todo implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 1L; + private String task; + private String user; + private int rid; + + private LocalDateTime time; + + private boolean completed = false; + + + public String getTask() { + return task; + } + + public void setTask(String task) { + this.task = task; + } + + public String getUser() { + return user; + } + + public void setUser(String user) { + this.user = user; + } + + public int getRid() { + return rid; + } + + public void setRid(int rid) { + this.rid = rid; + } + + public LocalDateTime getTime() { + return time; + } + + public void setTime(LocalDateTime time) { + this.time = time; + } + + public boolean isCompleted() { + return completed; + } + + public void setCompleted(boolean completed) { + this.completed = completed; + } + + @Override + public String toString() { + return String.format("Task: %s, User: %s, Id: %s", task, + user, rid); + } +} diff --git a/pocCurrentAttempt/src/main/java/com/vaadin/flow/demo/helloworld/template/TodoCreator.java b/pocCurrentAttempt/src/main/java/com/vaadin/flow/demo/helloworld/template/TodoCreator.java new file mode 100644 index 000000000..dd6b2604f --- /dev/null +++ b/pocCurrentAttempt/src/main/java/com/vaadin/flow/demo/helloworld/template/TodoCreator.java @@ -0,0 +1,80 @@ +/* + * Copyright 2000-2017 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.flow.demo.helloworld.template; + +import java.io.Serializable; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import com.vaadin.flow.component.ClientCallable; +import com.vaadin.flow.component.Tag; +import com.vaadin.flow.component.dependency.HtmlImport; +import com.vaadin.flow.component.polymertemplate.PolymerTemplate; +import com.vaadin.flow.templatemodel.TemplateModel; + +/** + * Creator layout for creating todo items. + */ +@Tag("todo-creator") +@HtmlImport("frontend://components/TodoCreator.html") +public class TodoCreator extends PolymerTemplate { + + /** + * + */ + private static final long serialVersionUID = 1L; + private Random rand = new Random(System.currentTimeMillis()); + private List callbacks = new ArrayList<>(0); + + /** + * Add a creation callback to listen to for newly created todo items. + * + * @param callback + * creation callback + */ + public void addCreateCallback(CreateCallback callback) { + callbacks.add(callback); + } + + @ClientCallable + private void createTodo(String task, String user) { + Todo todo = new Todo(); + todo.setTask(task); + todo.setUser(user); + todo.setTime(LocalDateTime.now()); + todo.setCompleted(false); + todo.setRid(rand.nextInt()); + + callbacks.forEach(callback -> callback.createdNewTodo(todo)); + } + + /** + * Creation callback interface. + */ + @FunctionalInterface + public interface CreateCallback extends Serializable { + /** + * Method called when a new {@link Todo} item is created. + * + * @param todo + * the created {@link Todo} item + */ + void createdNewTodo(Todo todo); + } + +} diff --git a/pocCurrentAttempt/src/main/java/com/vaadin/flow/demo/helloworld/template/TodoElement.java b/pocCurrentAttempt/src/main/java/com/vaadin/flow/demo/helloworld/template/TodoElement.java new file mode 100644 index 000000000..fce883810 --- /dev/null +++ b/pocCurrentAttempt/src/main/java/com/vaadin/flow/demo/helloworld/template/TodoElement.java @@ -0,0 +1,185 @@ +/* + * Copyright 2000-2017 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.flow.demo.helloworld.template; + +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.List; + +import com.vaadin.flow.component.Tag; +import com.vaadin.flow.component.dependency.HtmlImport; +import com.vaadin.flow.component.polymertemplate.PolymerTemplate; +import com.vaadin.flow.templatemodel.TemplateModel; + +/** + * An element for displaying the Todo item. Task can be edited and completion of + * task can be set in the element. + */ +@Tag("todo-element") +@HtmlImport("frontend://components/TodoElement.html") +public class TodoElement extends PolymerTemplate { + + /** + * + */ + private static final long serialVersionUID = 1L; + private List changeListeners = new ArrayList<>(0); + + /** + * The TodoModel. + */ + public interface TodoModel extends TemplateModel { + /** + * Get task text. + * + * @return task + */ + String getTask(); + + /** + * Set task. + * + * @param task + * task + */ + void setTask(String task); + + /** + * Get user. + * + * @return user + */ + String getUser(); + + /** + * Set user. + * + * @param user + * user + */ + void setUser(String user); + + /** + * Get Id. + * + * @return id + */ + int getRid(); + + /** + * Set id. + * + * @param rid + * id + */ + void setRid(int rid); + + /** + * Get the stored time string. + * + * @return time + */ + String getTime(); + + /** + * Set the time string. + * + * @param time + * time + */ + void setTime(String time); + + /** + * Get task completion. + * + * @return task completion + */ + boolean isCompleted(); + + /** + * Set task completion. + * + * @param completed + * task completion. + */ + void setCompleted(boolean completed); + } + + private Todo todo; + + /** + * Todo element constructor. + * + * @param todo + * todo item for this element + */ + public TodoElement(Todo todo) { + this.todo = todo; + + populateModel(todo); + addChangeListeners(todo); + } + + private void populateModel(Todo todo) { + getModel().setTask(todo.getTask()); + getModel().setUser(todo.getUser()); + getModel().setRid(todo.getRid()); + getModel().setTime(todo.getTime() + .format(DateTimeFormatter.ofPattern("dd.MM.yyyy - HH:mm"))); + } + + private void addChangeListeners(Todo todo) { + getElement().addPropertyChangeListener("completed", + event -> taskCompleted()); + getElement().addPropertyChangeListener("task", + event -> todo.setTask(getModel().getTask())); + } + + private void taskCompleted() { + todo.setCompleted(getModel().isCompleted()); + + changeListeners.forEach(Runnable::run); + } + + /** + * Get the {@link Todo} item for this TodoElement. + * + * @return todo item + */ + public Todo getTodo() { + return todo; + } + + /** + * Returns completion state of this {@link Todo} item. + * + * @return todo item completion status + */ + public boolean isCompleted() { + return getModel().isCompleted(); + } + + /** + * Add a state change listener that is informed when the completed state + * changes. + * + * @param listener + * runnable method to be used as a listener + */ + public void addStateChangeListener(Runnable listener) { + changeListeners.add(listener); + } +} diff --git a/pocCurrentAttempt/src/main/java/com/vaadin/flow/demo/helloworld/template/TodoList.java b/pocCurrentAttempt/src/main/java/com/vaadin/flow/demo/helloworld/template/TodoList.java new file mode 100644 index 000000000..dea91d010 --- /dev/null +++ b/pocCurrentAttempt/src/main/java/com/vaadin/flow/demo/helloworld/template/TodoList.java @@ -0,0 +1,76 @@ +/* + * Copyright 2000-2017 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.flow.demo.helloworld.template; + +import java.util.stream.Collectors; + +import com.vaadin.flow.component.Tag; +import com.vaadin.flow.component.dependency.HtmlImport; +import com.vaadin.flow.component.polymertemplate.Id; +import com.vaadin.flow.component.polymertemplate.PolymerTemplate; +import com.vaadin.flow.dom.Element; +import com.vaadin.flow.router.Route; +import com.vaadin.flow.templatemodel.TemplateModel; + +/** + * The main application view of the todo application. + */ +@Tag("todo-template") +@HtmlImport("frontend://components/TodoTemplate.html") +@Route("") +public class TodoList extends PolymerTemplate { + + /** + * + */ + private static final long serialVersionUID = 1L; + @Id("creator") + private TodoCreator creator; + + /** + * Creates the todo list applicaton base. + */ + public TodoList() { + setId("todo-template"); + + creator.addCreateCallback(todo -> addNewTodoItem(todo)); + } + + private void addNewTodoItem(Todo todo) { + TodoElement todoElement = new TodoElement(todo); + + todoElement.getElement().addEventListener("remove", + e -> getElement().removeChild(todoElement.getElement())); + + todoElement.addStateChangeListener(() -> { + if (todoElement.isCompleted()) { + // ensure that DOM element will show on the left hand side + Element element = todoElement.getElement(); + //dumpElement(element); + // the parent renders the elements with slot="done" in its "done" slot + element.setAttribute("slot", "done"); + } + }); + + getElement().appendChild(todoElement.getElement()); + } + + void dumpElement(Element element) { + System.err.println(" attributes: "+element.getAttributeNames().collect(Collectors.joining(", "))); + System.err.print(" properties: "+element.getPropertyNames().collect(Collectors.joining(", "))); + } + +} diff --git a/pocCurrentAttempt/src/main/webapp/frontend/components/TodoCreator.html b/pocCurrentAttempt/src/main/webapp/frontend/components/TodoCreator.html new file mode 100644 index 000000000..557d4e6b8 --- /dev/null +++ b/pocCurrentAttempt/src/main/webapp/frontend/components/TodoCreator.html @@ -0,0 +1,83 @@ + + + + + + + + + + + diff --git a/pocCurrentAttempt/src/main/webapp/frontend/components/TodoElement.html b/pocCurrentAttempt/src/main/webapp/frontend/components/TodoElement.html new file mode 100644 index 000000000..702810532 --- /dev/null +++ b/pocCurrentAttempt/src/main/webapp/frontend/components/TodoElement.html @@ -0,0 +1,114 @@ + + + + + + + + + + + + diff --git a/pocCurrentAttempt/src/main/webapp/frontend/components/TodoTemplate.html b/pocCurrentAttempt/src/main/webapp/frontend/components/TodoTemplate.html new file mode 100644 index 000000000..b4db5824e --- /dev/null +++ b/pocCurrentAttempt/src/main/webapp/frontend/components/TodoTemplate.html @@ -0,0 +1,71 @@ + + + + + diff --git a/pocCurrentAttempt/src/test/java/com/vaadin/flow/demo/helloworld/template/TodoIT.jav b/pocCurrentAttempt/src/test/java/com/vaadin/flow/demo/helloworld/template/TodoIT.jav new file mode 100644 index 000000000..9d8f424a7 --- /dev/null +++ b/pocCurrentAttempt/src/test/java/com/vaadin/flow/demo/helloworld/template/TodoIT.jav @@ -0,0 +1,59 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.flow.demo.helloworld.template; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.flow.demo.testutil.AbstractChromeTest; + +public class TodoIT extends AbstractChromeTest { + + @Test + public void basicFunctionality() { + open(); + + WebElement template = findElement(By.id("template")); + + WebElement createTemplate = getInShadowRoot(template, + By.id("creator")); + + WebElement todo = getInShadowRoot(createTemplate, By.id("task-input")); + todo.sendKeys("Important task"); + + WebElement user = getInShadowRoot(createTemplate, + By.id("user-name-input")); + user.sendKeys("Teuvo testi"); + + WebElement createButton = getInShadowRoot(createTemplate, + By.id("create-button")); + createButton.click(); + + WebElement todoElement = template + .findElement(By.tagName("todo-element")); + Assert.assertEquals("Important task", + getInShadowRoot(todoElement, By.id("task")) + .getText()); + + getInShadowRoot(todoElement, By.id("checkbox")).click(); + + todoElement = template + .findElement(By.tagName("todo-element")); + Assert.assertEquals("done", todoElement.getAttribute("slot")); + } +} diff --git a/pocCurrentAttempt/target/classes/com/vaadin/flow/demo/helloworld/template/Todo.class b/pocCurrentAttempt/target/classes/com/vaadin/flow/demo/helloworld/template/Todo.class new file mode 100644 index 000000000..e7ce5aa0d Binary files /dev/null and b/pocCurrentAttempt/target/classes/com/vaadin/flow/demo/helloworld/template/Todo.class differ diff --git a/pocCurrentAttempt/target/classes/com/vaadin/flow/demo/helloworld/template/TodoCreator$CreateCallback.class b/pocCurrentAttempt/target/classes/com/vaadin/flow/demo/helloworld/template/TodoCreator$CreateCallback.class new file mode 100644 index 000000000..27a763cc8 Binary files /dev/null and b/pocCurrentAttempt/target/classes/com/vaadin/flow/demo/helloworld/template/TodoCreator$CreateCallback.class differ diff --git a/pocCurrentAttempt/target/classes/com/vaadin/flow/demo/helloworld/template/TodoCreator.class b/pocCurrentAttempt/target/classes/com/vaadin/flow/demo/helloworld/template/TodoCreator.class new file mode 100644 index 000000000..691ee8ccf Binary files /dev/null and b/pocCurrentAttempt/target/classes/com/vaadin/flow/demo/helloworld/template/TodoCreator.class differ diff --git a/pocCurrentAttempt/target/classes/com/vaadin/flow/demo/helloworld/template/TodoElement$TodoModel.class b/pocCurrentAttempt/target/classes/com/vaadin/flow/demo/helloworld/template/TodoElement$TodoModel.class new file mode 100644 index 000000000..555d2777f Binary files /dev/null and b/pocCurrentAttempt/target/classes/com/vaadin/flow/demo/helloworld/template/TodoElement$TodoModel.class differ diff --git a/pocCurrentAttempt/target/classes/com/vaadin/flow/demo/helloworld/template/TodoElement.class b/pocCurrentAttempt/target/classes/com/vaadin/flow/demo/helloworld/template/TodoElement.class new file mode 100644 index 000000000..df8e8c876 Binary files /dev/null and b/pocCurrentAttempt/target/classes/com/vaadin/flow/demo/helloworld/template/TodoElement.class differ diff --git a/pocCurrentAttempt/target/classes/com/vaadin/flow/demo/helloworld/template/TodoList.class b/pocCurrentAttempt/target/classes/com/vaadin/flow/demo/helloworld/template/TodoList.class new file mode 100644 index 000000000..6d9a87bea Binary files /dev/null and b/pocCurrentAttempt/target/classes/com/vaadin/flow/demo/helloworld/template/TodoList.class differ diff --git a/pocCurrentAttempt/target/driver/windows/googlechrome/64bit/chromedriver.exe b/pocCurrentAttempt/target/driver/windows/googlechrome/64bit/chromedriver.exe new file mode 100644 index 000000000..3ec72f461 Binary files /dev/null and b/pocCurrentAttempt/target/driver/windows/googlechrome/64bit/chromedriver.exe differ diff --git a/pocCurrentAttempt/target/driver_zips/chromedriver_win32.zip b/pocCurrentAttempt/target/driver_zips/chromedriver_win32.zip new file mode 100644 index 000000000..332d13df6 Binary files /dev/null and b/pocCurrentAttempt/target/driver_zips/chromedriver_win32.zip differ diff --git a/pocCurrentAttempt/target/drivers.xml b/pocCurrentAttempt/target/drivers.xml new file mode 100644 index 000000000..99bac2bdb --- /dev/null +++ b/pocCurrentAttempt/target/drivers.xml @@ -0,0 +1,36 @@ + + + + + + + https://chromedriver.storage.googleapis.com/2.43/chromedriver_win32.zip + 00c7133d8caadabcb51623dc8c5e11842087bd3a + sha1 + + + + + + + + + https://chromedriver.storage.googleapis.com/2.43/chromedriver_linux64.zip + 63bce01580d6bc488aa185d572500f342f10eeef + sha1 + + + + + + + + + https://chromedriver.storage.googleapis.com/2.43/chromedriver_mac64.zip + 1c19c0ea6b92fc7010033563bdd8d95f52ba3340 + sha1 + + + + + diff --git a/pocCurrentAttempt/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/pocCurrentAttempt/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 000000000..10fb0ea27 --- /dev/null +++ b/pocCurrentAttempt/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,6 @@ +com\vaadin\flow\demo\helloworld\template\Todo.class +com\vaadin\flow\demo\helloworld\template\TodoElement$TodoModel.class +com\vaadin\flow\demo\helloworld\template\TodoElement.class +com\vaadin\flow\demo\helloworld\template\TodoList.class +com\vaadin\flow\demo\helloworld\template\TodoCreator$CreateCallback.class +com\vaadin\flow\demo\helloworld\template\TodoCreator.class diff --git a/pocCurrentAttempt/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/pocCurrentAttempt/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 000000000..6de820a85 --- /dev/null +++ b/pocCurrentAttempt/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,4 @@ +C:\Users\owlcms\git\owlcms4\pocPolymer\src\main\java\com\vaadin\flow\demo\helloworld\template\TodoCreator.java +C:\Users\owlcms\git\owlcms4\pocPolymer\src\main\java\com\vaadin\flow\demo\helloworld\template\TodoElement.java +C:\Users\owlcms\git\owlcms4\pocPolymer\src\main\java\com\vaadin\flow\demo\helloworld\template\TodoList.java +C:\Users\owlcms\git\owlcms4\pocPolymer\src\main\java\com\vaadin\flow\demo\helloworld\template\Todo.java diff --git a/pocCurrentAttempt/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/pocCurrentAttempt/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 000000000..e69de29bb diff --git a/pocCurrentAttempt/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/pocCurrentAttempt/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 000000000..e69de29bb diff --git a/pocCurrentAttempt/target/test-classes/com/vaadin/flow/demo/helloworld/template/TodoIT.jav b/pocCurrentAttempt/target/test-classes/com/vaadin/flow/demo/helloworld/template/TodoIT.jav new file mode 100644 index 000000000..9d8f424a7 --- /dev/null +++ b/pocCurrentAttempt/target/test-classes/com/vaadin/flow/demo/helloworld/template/TodoIT.jav @@ -0,0 +1,59 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.flow.demo.helloworld.template; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.flow.demo.testutil.AbstractChromeTest; + +public class TodoIT extends AbstractChromeTest { + + @Test + public void basicFunctionality() { + open(); + + WebElement template = findElement(By.id("template")); + + WebElement createTemplate = getInShadowRoot(template, + By.id("creator")); + + WebElement todo = getInShadowRoot(createTemplate, By.id("task-input")); + todo.sendKeys("Important task"); + + WebElement user = getInShadowRoot(createTemplate, + By.id("user-name-input")); + user.sendKeys("Teuvo testi"); + + WebElement createButton = getInShadowRoot(createTemplate, + By.id("create-button")); + createButton.click(); + + WebElement todoElement = template + .findElement(By.tagName("todo-element")); + Assert.assertEquals("Important task", + getInShadowRoot(todoElement, By.id("task")) + .getText()); + + getInShadowRoot(todoElement, By.id("checkbox")).click(); + + todoElement = template + .findElement(By.tagName("todo-element")); + Assert.assertEquals("done", todoElement.getAttribute("slot")); + } +} diff --git a/pocPolymer/.classpath b/pocPolymer/.classpath new file mode 100644 index 000000000..d2bc4e02a --- /dev/null +++ b/pocPolymer/.classpath @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pocPolymer/.project b/pocPolymer/.project new file mode 100644 index 000000000..1ccda8eec --- /dev/null +++ b/pocPolymer/.project @@ -0,0 +1,23 @@ + + + pocTodoGrid + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/pocPolymer/.settings/org.eclipse.core.resources.prefs b/pocPolymer/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000..04cfa2c1a --- /dev/null +++ b/pocPolymer/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 +encoding//src/test/java=UTF-8 +encoding//src/test/resources=UTF-8 +encoding/=UTF-8 diff --git a/pocPolymer/.settings/org.eclipse.jdt.core.prefs b/pocPolymer/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..f494d1de0 --- /dev/null +++ b/pocPolymer/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/pocPolymer/.settings/org.eclipse.m2e.core.prefs b/pocPolymer/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000..14b697b7b --- /dev/null +++ b/pocPolymer/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/pocPolymer/pom.xml b/pocPolymer/pom.xml new file mode 100644 index 000000000..1782288fa --- /dev/null +++ b/pocPolymer/pom.xml @@ -0,0 +1,177 @@ + + 4.0.0 + + org.ledocte + owlcms4top + 0.0.1-SNAPSHOT + + + Polymer Proof-of-Concept + pocTodoGrid + war + + + + + org.webjars.bowergithub.polymerelements + paper-styles + 2.0.0 + + + org.webjars.bowergithub.polymerelements + font-roboto + 1.0.3 + + + org.webjars.bowergithub.polymerelements + iron-autogrow-textarea + 2.1.0 + + + org.webjars.bowergithub.polymerelements + iron-validatable-behavior + 2.0.0 + + + org.webjars.bowergithub.polymerelements + iron-input + 2.0.1 + + + org.webjars.bowergithub.polymerelements + iron-form-element-behavior + 2.0.0 + + + org.webjars.bowergithub.polymerelements + paper-behaviors + 2.0.1 + + + org.webjars.bowergithub.polymerelements + iron-checked-element-behavior + 2.0.0 + + + org.webjars.bowergithub.polymerelements + paper-ripple + 2.0.1 + + + org.webjars.bowergithub.webcomponents + shadycss + 1.2.0-0 + + + + + + + + + org.webjars.bowergithub.polymer + polymer + + + org.webjars.bowergithub.polymerelements + paper-input + 2.1.1 + + + org.webjars.bowergithub.polymerelements + paper-fab + 2.0.0 + + + org.webjars.bowergithub.polymerelements + iron-icons + 2.0.1 + + + org.webjars.bowergithub.polymerelements + paper-checkbox + 2.0.2 + + + org.webjars.bowergithub.polymerelements + paper-item + 2.0.0 + + + + + + productionMode + + + vaadin.productionMode + + + + + ${project.build.directory}/build + + + + + com.vaadin + flow-server-production-mode + ${flow.version} + + + + + + + com.vaadin + flow-maven-plugin + ${flow.plugin.version} + + + + copy-production-files + package-for-production + + + ${transpilation.output} + + + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven.war.plugin.version} + + + + ${transpilation.output} + + + + + + + org.eclipse.jetty + jetty-maven-plugin + ${jetty.version} + + + ^$ + + ${transpilation.output} + + + + + + + + + \ No newline at end of file diff --git a/pocPolymer/src/main/java/com/vaadin/flow/demo/helloworld/template/Todo.java b/pocPolymer/src/main/java/com/vaadin/flow/demo/helloworld/template/Todo.java new file mode 100644 index 000000000..8e75d258e --- /dev/null +++ b/pocPolymer/src/main/java/com/vaadin/flow/demo/helloworld/template/Todo.java @@ -0,0 +1,84 @@ +/* + * Copyright 2000-2017 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.flow.demo.helloworld.template; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + * Todo item. + */ +public class Todo implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 1L; + private String task; + private String user; + private int rid; + + private LocalDateTime time; + + private boolean completed = false; + + + public String getTask() { + return task; + } + + public void setTask(String task) { + this.task = task; + } + + public String getUser() { + return user; + } + + public void setUser(String user) { + this.user = user; + } + + public int getRid() { + return rid; + } + + public void setRid(int rid) { + this.rid = rid; + } + + public LocalDateTime getTime() { + return time; + } + + public void setTime(LocalDateTime time) { + this.time = time; + } + + public boolean isCompleted() { + return completed; + } + + public void setCompleted(boolean completed) { + this.completed = completed; + } + + @Override + public String toString() { + return String.format("Task: %s, User: %s, Id: %s", task, + user, rid); + } +} diff --git a/pocPolymer/src/main/java/com/vaadin/flow/demo/helloworld/template/TodoCreator.java b/pocPolymer/src/main/java/com/vaadin/flow/demo/helloworld/template/TodoCreator.java new file mode 100644 index 000000000..dd6b2604f --- /dev/null +++ b/pocPolymer/src/main/java/com/vaadin/flow/demo/helloworld/template/TodoCreator.java @@ -0,0 +1,80 @@ +/* + * Copyright 2000-2017 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.flow.demo.helloworld.template; + +import java.io.Serializable; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import com.vaadin.flow.component.ClientCallable; +import com.vaadin.flow.component.Tag; +import com.vaadin.flow.component.dependency.HtmlImport; +import com.vaadin.flow.component.polymertemplate.PolymerTemplate; +import com.vaadin.flow.templatemodel.TemplateModel; + +/** + * Creator layout for creating todo items. + */ +@Tag("todo-creator") +@HtmlImport("frontend://components/TodoCreator.html") +public class TodoCreator extends PolymerTemplate { + + /** + * + */ + private static final long serialVersionUID = 1L; + private Random rand = new Random(System.currentTimeMillis()); + private List callbacks = new ArrayList<>(0); + + /** + * Add a creation callback to listen to for newly created todo items. + * + * @param callback + * creation callback + */ + public void addCreateCallback(CreateCallback callback) { + callbacks.add(callback); + } + + @ClientCallable + private void createTodo(String task, String user) { + Todo todo = new Todo(); + todo.setTask(task); + todo.setUser(user); + todo.setTime(LocalDateTime.now()); + todo.setCompleted(false); + todo.setRid(rand.nextInt()); + + callbacks.forEach(callback -> callback.createdNewTodo(todo)); + } + + /** + * Creation callback interface. + */ + @FunctionalInterface + public interface CreateCallback extends Serializable { + /** + * Method called when a new {@link Todo} item is created. + * + * @param todo + * the created {@link Todo} item + */ + void createdNewTodo(Todo todo); + } + +} diff --git a/pocPolymer/src/main/java/com/vaadin/flow/demo/helloworld/template/TodoElement.java b/pocPolymer/src/main/java/com/vaadin/flow/demo/helloworld/template/TodoElement.java new file mode 100644 index 000000000..fce883810 --- /dev/null +++ b/pocPolymer/src/main/java/com/vaadin/flow/demo/helloworld/template/TodoElement.java @@ -0,0 +1,185 @@ +/* + * Copyright 2000-2017 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.flow.demo.helloworld.template; + +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.List; + +import com.vaadin.flow.component.Tag; +import com.vaadin.flow.component.dependency.HtmlImport; +import com.vaadin.flow.component.polymertemplate.PolymerTemplate; +import com.vaadin.flow.templatemodel.TemplateModel; + +/** + * An element for displaying the Todo item. Task can be edited and completion of + * task can be set in the element. + */ +@Tag("todo-element") +@HtmlImport("frontend://components/TodoElement.html") +public class TodoElement extends PolymerTemplate { + + /** + * + */ + private static final long serialVersionUID = 1L; + private List changeListeners = new ArrayList<>(0); + + /** + * The TodoModel. + */ + public interface TodoModel extends TemplateModel { + /** + * Get task text. + * + * @return task + */ + String getTask(); + + /** + * Set task. + * + * @param task + * task + */ + void setTask(String task); + + /** + * Get user. + * + * @return user + */ + String getUser(); + + /** + * Set user. + * + * @param user + * user + */ + void setUser(String user); + + /** + * Get Id. + * + * @return id + */ + int getRid(); + + /** + * Set id. + * + * @param rid + * id + */ + void setRid(int rid); + + /** + * Get the stored time string. + * + * @return time + */ + String getTime(); + + /** + * Set the time string. + * + * @param time + * time + */ + void setTime(String time); + + /** + * Get task completion. + * + * @return task completion + */ + boolean isCompleted(); + + /** + * Set task completion. + * + * @param completed + * task completion. + */ + void setCompleted(boolean completed); + } + + private Todo todo; + + /** + * Todo element constructor. + * + * @param todo + * todo item for this element + */ + public TodoElement(Todo todo) { + this.todo = todo; + + populateModel(todo); + addChangeListeners(todo); + } + + private void populateModel(Todo todo) { + getModel().setTask(todo.getTask()); + getModel().setUser(todo.getUser()); + getModel().setRid(todo.getRid()); + getModel().setTime(todo.getTime() + .format(DateTimeFormatter.ofPattern("dd.MM.yyyy - HH:mm"))); + } + + private void addChangeListeners(Todo todo) { + getElement().addPropertyChangeListener("completed", + event -> taskCompleted()); + getElement().addPropertyChangeListener("task", + event -> todo.setTask(getModel().getTask())); + } + + private void taskCompleted() { + todo.setCompleted(getModel().isCompleted()); + + changeListeners.forEach(Runnable::run); + } + + /** + * Get the {@link Todo} item for this TodoElement. + * + * @return todo item + */ + public Todo getTodo() { + return todo; + } + + /** + * Returns completion state of this {@link Todo} item. + * + * @return todo item completion status + */ + public boolean isCompleted() { + return getModel().isCompleted(); + } + + /** + * Add a state change listener that is informed when the completed state + * changes. + * + * @param listener + * runnable method to be used as a listener + */ + public void addStateChangeListener(Runnable listener) { + changeListeners.add(listener); + } +} diff --git a/pocPolymer/src/main/java/com/vaadin/flow/demo/helloworld/template/TodoList.java b/pocPolymer/src/main/java/com/vaadin/flow/demo/helloworld/template/TodoList.java new file mode 100644 index 000000000..dea91d010 --- /dev/null +++ b/pocPolymer/src/main/java/com/vaadin/flow/demo/helloworld/template/TodoList.java @@ -0,0 +1,76 @@ +/* + * Copyright 2000-2017 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.flow.demo.helloworld.template; + +import java.util.stream.Collectors; + +import com.vaadin.flow.component.Tag; +import com.vaadin.flow.component.dependency.HtmlImport; +import com.vaadin.flow.component.polymertemplate.Id; +import com.vaadin.flow.component.polymertemplate.PolymerTemplate; +import com.vaadin.flow.dom.Element; +import com.vaadin.flow.router.Route; +import com.vaadin.flow.templatemodel.TemplateModel; + +/** + * The main application view of the todo application. + */ +@Tag("todo-template") +@HtmlImport("frontend://components/TodoTemplate.html") +@Route("") +public class TodoList extends PolymerTemplate { + + /** + * + */ + private static final long serialVersionUID = 1L; + @Id("creator") + private TodoCreator creator; + + /** + * Creates the todo list applicaton base. + */ + public TodoList() { + setId("todo-template"); + + creator.addCreateCallback(todo -> addNewTodoItem(todo)); + } + + private void addNewTodoItem(Todo todo) { + TodoElement todoElement = new TodoElement(todo); + + todoElement.getElement().addEventListener("remove", + e -> getElement().removeChild(todoElement.getElement())); + + todoElement.addStateChangeListener(() -> { + if (todoElement.isCompleted()) { + // ensure that DOM element will show on the left hand side + Element element = todoElement.getElement(); + //dumpElement(element); + // the parent renders the elements with slot="done" in its "done" slot + element.setAttribute("slot", "done"); + } + }); + + getElement().appendChild(todoElement.getElement()); + } + + void dumpElement(Element element) { + System.err.println(" attributes: "+element.getAttributeNames().collect(Collectors.joining(", "))); + System.err.print(" properties: "+element.getPropertyNames().collect(Collectors.joining(", "))); + } + +} diff --git a/pocPolymer/src/main/webapp/frontend/components/TodoCreator.html b/pocPolymer/src/main/webapp/frontend/components/TodoCreator.html new file mode 100644 index 000000000..557d4e6b8 --- /dev/null +++ b/pocPolymer/src/main/webapp/frontend/components/TodoCreator.html @@ -0,0 +1,83 @@ + + + + + + + + + + + diff --git a/pocPolymer/src/main/webapp/frontend/components/TodoElement.html b/pocPolymer/src/main/webapp/frontend/components/TodoElement.html new file mode 100644 index 000000000..702810532 --- /dev/null +++ b/pocPolymer/src/main/webapp/frontend/components/TodoElement.html @@ -0,0 +1,114 @@ + + + + + + + + + + + + diff --git a/pocPolymer/src/main/webapp/frontend/components/TodoTemplate.html b/pocPolymer/src/main/webapp/frontend/components/TodoTemplate.html new file mode 100644 index 000000000..b4db5824e --- /dev/null +++ b/pocPolymer/src/main/webapp/frontend/components/TodoTemplate.html @@ -0,0 +1,71 @@ + + + + + diff --git a/pocPolymer/src/test/java/com/vaadin/flow/demo/helloworld/template/TodoIT.jav b/pocPolymer/src/test/java/com/vaadin/flow/demo/helloworld/template/TodoIT.jav new file mode 100644 index 000000000..9d8f424a7 --- /dev/null +++ b/pocPolymer/src/test/java/com/vaadin/flow/demo/helloworld/template/TodoIT.jav @@ -0,0 +1,59 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.flow.demo.helloworld.template; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.flow.demo.testutil.AbstractChromeTest; + +public class TodoIT extends AbstractChromeTest { + + @Test + public void basicFunctionality() { + open(); + + WebElement template = findElement(By.id("template")); + + WebElement createTemplate = getInShadowRoot(template, + By.id("creator")); + + WebElement todo = getInShadowRoot(createTemplate, By.id("task-input")); + todo.sendKeys("Important task"); + + WebElement user = getInShadowRoot(createTemplate, + By.id("user-name-input")); + user.sendKeys("Teuvo testi"); + + WebElement createButton = getInShadowRoot(createTemplate, + By.id("create-button")); + createButton.click(); + + WebElement todoElement = template + .findElement(By.tagName("todo-element")); + Assert.assertEquals("Important task", + getInShadowRoot(todoElement, By.id("task")) + .getText()); + + getInShadowRoot(todoElement, By.id("checkbox")).click(); + + todoElement = template + .findElement(By.tagName("todo-element")); + Assert.assertEquals("done", todoElement.getAttribute("slot")); + } +} diff --git a/pocPolymer/target/classes/com/vaadin/flow/demo/helloworld/template/Todo.class b/pocPolymer/target/classes/com/vaadin/flow/demo/helloworld/template/Todo.class new file mode 100644 index 000000000..e7ce5aa0d Binary files /dev/null and b/pocPolymer/target/classes/com/vaadin/flow/demo/helloworld/template/Todo.class differ diff --git a/pocPolymer/target/classes/com/vaadin/flow/demo/helloworld/template/TodoCreator$CreateCallback.class b/pocPolymer/target/classes/com/vaadin/flow/demo/helloworld/template/TodoCreator$CreateCallback.class new file mode 100644 index 000000000..27a763cc8 Binary files /dev/null and b/pocPolymer/target/classes/com/vaadin/flow/demo/helloworld/template/TodoCreator$CreateCallback.class differ diff --git a/pocPolymer/target/classes/com/vaadin/flow/demo/helloworld/template/TodoCreator.class b/pocPolymer/target/classes/com/vaadin/flow/demo/helloworld/template/TodoCreator.class new file mode 100644 index 000000000..691ee8ccf Binary files /dev/null and b/pocPolymer/target/classes/com/vaadin/flow/demo/helloworld/template/TodoCreator.class differ diff --git a/pocPolymer/target/classes/com/vaadin/flow/demo/helloworld/template/TodoElement$TodoModel.class b/pocPolymer/target/classes/com/vaadin/flow/demo/helloworld/template/TodoElement$TodoModel.class new file mode 100644 index 000000000..555d2777f Binary files /dev/null and b/pocPolymer/target/classes/com/vaadin/flow/demo/helloworld/template/TodoElement$TodoModel.class differ diff --git a/pocPolymer/target/classes/com/vaadin/flow/demo/helloworld/template/TodoElement.class b/pocPolymer/target/classes/com/vaadin/flow/demo/helloworld/template/TodoElement.class new file mode 100644 index 000000000..df8e8c876 Binary files /dev/null and b/pocPolymer/target/classes/com/vaadin/flow/demo/helloworld/template/TodoElement.class differ diff --git a/pocPolymer/target/classes/com/vaadin/flow/demo/helloworld/template/TodoList.class b/pocPolymer/target/classes/com/vaadin/flow/demo/helloworld/template/TodoList.class new file mode 100644 index 000000000..6d9a87bea Binary files /dev/null and b/pocPolymer/target/classes/com/vaadin/flow/demo/helloworld/template/TodoList.class differ diff --git a/pocPolymer/target/driver/windows/googlechrome/64bit/chromedriver.exe b/pocPolymer/target/driver/windows/googlechrome/64bit/chromedriver.exe new file mode 100644 index 000000000..3ec72f461 Binary files /dev/null and b/pocPolymer/target/driver/windows/googlechrome/64bit/chromedriver.exe differ diff --git a/pocPolymer/target/driver_zips/chromedriver_win32.zip b/pocPolymer/target/driver_zips/chromedriver_win32.zip new file mode 100644 index 000000000..332d13df6 Binary files /dev/null and b/pocPolymer/target/driver_zips/chromedriver_win32.zip differ diff --git a/pocPolymer/target/drivers.xml b/pocPolymer/target/drivers.xml new file mode 100644 index 000000000..99bac2bdb --- /dev/null +++ b/pocPolymer/target/drivers.xml @@ -0,0 +1,36 @@ + + + + + + + https://chromedriver.storage.googleapis.com/2.43/chromedriver_win32.zip + 00c7133d8caadabcb51623dc8c5e11842087bd3a + sha1 + + + + + + + + + https://chromedriver.storage.googleapis.com/2.43/chromedriver_linux64.zip + 63bce01580d6bc488aa185d572500f342f10eeef + sha1 + + + + + + + + + https://chromedriver.storage.googleapis.com/2.43/chromedriver_mac64.zip + 1c19c0ea6b92fc7010033563bdd8d95f52ba3340 + sha1 + + + + + diff --git a/pocPolymer/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/pocPolymer/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 000000000..10fb0ea27 --- /dev/null +++ b/pocPolymer/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,6 @@ +com\vaadin\flow\demo\helloworld\template\Todo.class +com\vaadin\flow\demo\helloworld\template\TodoElement$TodoModel.class +com\vaadin\flow\demo\helloworld\template\TodoElement.class +com\vaadin\flow\demo\helloworld\template\TodoList.class +com\vaadin\flow\demo\helloworld\template\TodoCreator$CreateCallback.class +com\vaadin\flow\demo\helloworld\template\TodoCreator.class diff --git a/pocPolymer/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/pocPolymer/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 000000000..6de820a85 --- /dev/null +++ b/pocPolymer/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,4 @@ +C:\Users\owlcms\git\owlcms4\pocPolymer\src\main\java\com\vaadin\flow\demo\helloworld\template\TodoCreator.java +C:\Users\owlcms\git\owlcms4\pocPolymer\src\main\java\com\vaadin\flow\demo\helloworld\template\TodoElement.java +C:\Users\owlcms\git\owlcms4\pocPolymer\src\main\java\com\vaadin\flow\demo\helloworld\template\TodoList.java +C:\Users\owlcms\git\owlcms4\pocPolymer\src\main\java\com\vaadin\flow\demo\helloworld\template\Todo.java diff --git a/pocPolymer/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/pocPolymer/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 000000000..e69de29bb diff --git a/pocPolymer/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/pocPolymer/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 000000000..e69de29bb diff --git a/pocPolymer/target/test-classes/com/vaadin/flow/demo/helloworld/template/TodoIT.jav b/pocPolymer/target/test-classes/com/vaadin/flow/demo/helloworld/template/TodoIT.jav new file mode 100644 index 000000000..9d8f424a7 --- /dev/null +++ b/pocPolymer/target/test-classes/com/vaadin/flow/demo/helloworld/template/TodoIT.jav @@ -0,0 +1,59 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.flow.demo.helloworld.template; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.flow.demo.testutil.AbstractChromeTest; + +public class TodoIT extends AbstractChromeTest { + + @Test + public void basicFunctionality() { + open(); + + WebElement template = findElement(By.id("template")); + + WebElement createTemplate = getInShadowRoot(template, + By.id("creator")); + + WebElement todo = getInShadowRoot(createTemplate, By.id("task-input")); + todo.sendKeys("Important task"); + + WebElement user = getInShadowRoot(createTemplate, + By.id("user-name-input")); + user.sendKeys("Teuvo testi"); + + WebElement createButton = getInShadowRoot(createTemplate, + By.id("create-button")); + createButton.click(); + + WebElement todoElement = template + .findElement(By.tagName("todo-element")); + Assert.assertEquals("Important task", + getInShadowRoot(todoElement, By.id("task")) + .getText()); + + getInShadowRoot(todoElement, By.id("checkbox")).click(); + + todoElement = template + .findElement(By.tagName("todo-element")); + Assert.assertEquals("done", todoElement.getAttribute("slot")); + } +} diff --git a/pom.xml b/pom.xml new file mode 100644 index 000000000..51018a2e5 --- /dev/null +++ b/pom.xml @@ -0,0 +1,431 @@ + + 4.0.0 + org.ledocte + owlcms4top + 0.0.1-SNAPSHOT + pom + + doc + pocTodoGrid + + + 1.8 + 1.8 + UTF-8 + UTF-8 + false + + 8 + preview + true + true + + + 1.3-SNAPSHOT + 1.9.3 + + + 9.4.11.v20180605 + 1.4 + 3.0.0 + 2.20 + 1.0.14 + 3.1.0 + ${flow.version} + 22.0 + + **/node_modules/,**/node/,**/build/,**/etc/ + + ${project.build.directory} + + + + vaadin-snapshots + https://oss.sonatype.org/content/repositories/vaadin-snapshots/ + + true + + + + flow-prerelease + https://maven.vaadin.com/vaadin-prereleases + + + binary-downloader-repo + https://oss.sonatype.org + + + + + + flow-internal-release + https://maven.vaadin.com/vaadin-prereleases + + + vaadin-snapshots + https://oss.sonatype.org/content/repositories/vaadin-snapshots/ + + true + + + + + + + + javax.servlet + javax.servlet-api + 3.1.0 + provided + + + com.vaadin + flow-server + ${flow.version} + + + com.vaadin + flow-client + ${flow.version} + + + com.vaadin + flow-push + ${flow.version} + + + com.vaadin + flow-html-components + ${flow.version} + + + com.vaadin.flow.demo + demo-utils + ${project.version} + + + com.vaadin.flow.demo + demo-test-util + ${project.version} + + + + + com.google.collections + google-collections + + + test + + + + com.google.guava + guava + ${guava.version} + + + + org.webjars.bowergithub.polymer + polymer + 2.6.0 + + + + org.webjars.bowergithub.webcomponents + webcomponentsjs + 1.2.2 + + + + + + + javax.servlet + javax.servlet-api + + + com.vaadin + flow-server + + + com.vaadin + flow-client + + + com.vaadin + flow-push + + + com.vaadin + flow-html-components + + + org.slf4j + slf4j-simple + 1.7.25 + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.1 + + + + org.apache.maven.plugins + maven-source-plugin + 3.0.1 + + + attach-sources + verify + + jar-no-fork + + + + + + + maven-failsafe-plugin + ${maven.failsafe.plugin.version} + + + + integration-test + verify + + + + + false + + ${webdriver.chrome.driver} + + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven.war.plugin.version} + + + + ${project.name} + ${project.version} + + + ${war.source.excludes} + + + + + org.eclipse.jetty + jetty-maven-plugin + ${jetty.version} + + 2 + 8081 + 5 + foo + + ^$ + + + + + start-jetty + pre-integration-test + + start + + + + stop-jetty + post-integration-test + + stop + + + + + + + org.commonjava.maven.plugins + directory-maven-plugin + 0.1 + + + set-root-dir-for-common-lifecycle + + highest-basedir + + initialize + + project.rootdir + + + + set-root-dir-for-clean-lifecycle + + highest-basedir + + pre-clean + + project.rootdir + + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + com.lazerycode.selenium + + + driver-binary-downloader-maven-plugin + + + [${driver.binary.downloader.maven.plugin.version},) + + + selenium + + + + + + + + + + org.commonjava.maven.plugins + + + directory-maven-plugin + + + [0.1,) + + + highest-basedir + + + + + + + + + + + + + + + + eclipse + + + + org.eclipse.jetty + jetty-maven-plugin + ${jetty.version} + + + ^$ + + + + + ${project.basedir}/../../flow/flow-server/src/main/resources/META-INF/resources + + + ${project.basedir}/../../flow/flow-client/target/classes/META-INF/resources + + + ${project.basedir}/../../flow/flow-push/src/main/resources/META-INF/resources + + ${project.basedir}/src/main/webapp + + + + + + + + + + local-run + + + !test.use.hub + + + + + + com.googlecode.maven-download-plugin + download-maven-plugin + 1.3.0 + + + process-resources + + wget + + + https://raw.githubusercontent.com/vaadin/flow/master/drivers.xml + drivers.xml + ${rootOutputDir} + + + + + + com.lazerycode.selenium + driver-binary-downloader-maven-plugin + ${driver.binary.downloader.maven.plugin.version} + + + true + ${rootOutputDir}/driver + ${rootOutputDir}/driver_zips + ${rootOutputDir}/drivers.xml + + + + + selenium + + + + + + + + + +