diff --git a/Doc/Sda1/Ref/Video/sortedinteger.txt b/Doc/Sda1/Ref/Video/sortedinteger.txt new file mode 100644 index 0000000000000000000000000000000000000000..89ca741c935f6f2e97b44ca72dfb273e3bdcf850 --- /dev/null +++ b/Doc/Sda1/Ref/Video/sortedinteger.txt @@ -0,0 +1,5 @@ +Our application allows for adding values + +We may as well delete existing values + + diff --git a/Doc/Sda1/Ref/Video/sortedinteger.webm b/Doc/Sda1/Ref/Video/sortedinteger.webm new file mode 100644 index 0000000000000000000000000000000000000000..8d0250e3f116dbd4976b0301ad7ff2d740731a7e Binary files /dev/null and b/Doc/Sda1/Ref/Video/sortedinteger.webm differ diff --git a/Doc/Sda1/vaadin.xml b/Doc/Sda1/vaadin.xml index 95f8e6c507379bd9a3c23c2384194e7f9cbbff93..e370c4aa020339aae6dd9a2d7f7590536ba36e97 100644 --- a/Doc/Sda1/vaadin.xml +++ b/Doc/Sda1/vaadin.xml @@ -43,16 +43,21 @@ <glossdef> <para>The jetty plugin searches for source code changes. You may - want to adjust its scan interval in - <filename>pom.xml</filename>:</para> + want to adjust its scan interval for automatic application + redeployment in <filename>pom.xml</filename>:</para> <programlisting language="none"><plugin> - <groupId>org.mortbay.jetty</groupId> + <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> + <version>9.3.0.v20150612</version> <configuration> - <emphasis role="bold"><scanIntervalSeconds>2</scanIntervalSeconds></emphasis> + <scanIntervalSeconds>1</scanIntervalSeconds> </configuration> - </plugin></programlisting> +</plugin></programlisting> + + <para>The above plugin is safe with respect to Java 8 lambda + expressions. Some Jetty plugins exhibit lambda expression related + NPEs.</para> </glossdef> </glossentry> </glosslist> @@ -71,4 +76,17 @@ </listitem> </orderedlist> </section> + + <section xml:id="sda1VaadinProperty"> + <title>Properties, editors and listeners</title> + + <para>Implement an application which allows for adding and removing + integer values to an ordered set like:</para> + + <mediaobject> + <videoobject> + <videodata fileref="Ref/Video/sortedinteger.webm"/> + </videoobject> + </mediaobject> + </section> </chapter> diff --git a/P/Sda1/Vaadin/IntegerSet/.gitignore b/P/Sda1/Vaadin/IntegerSet/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..660be2a5fdb9e3019ef8fc737d47fba56fc32ff3 --- /dev/null +++ b/P/Sda1/Vaadin/IntegerSet/.gitignore @@ -0,0 +1,5 @@ +.project +.classpath +/.settings/ +/target/ +A1.log \ No newline at end of file diff --git a/P/Sda1/Vaadin/IntegerSet/pom.xml b/P/Sda1/Vaadin/IntegerSet/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..ff0252fd65d3820ca6900d426a12d13524f84c61 --- /dev/null +++ b/P/Sda1/Vaadin/IntegerSet/pom.xml @@ -0,0 +1,113 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>de.hdm-stuttgart.mi</groupId> + <artifactId>integerset</artifactId> + <version>1.0</version> + <packaging>jar</packaging> + + <name>Integerset</name> + <url>http://www.mi.hdm-stuttgart.de/freedocs</url> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <vaadin.version>7.5.0</vaadin.version> + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.2</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + </configuration> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <version>2.10.1</version> + <configuration> + <linksource>true</linksource> + </configuration> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>2.5</version> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-install-plugin</artifactId> + <version>2.5.2</version> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-resources-plugin</artifactId> + <version>2.5</version> + </plugin> + + <plugin> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-maven-plugin</artifactId> + <version>9.3.0.v20150612</version> + <configuration> + <scanIntervalSeconds>1</scanIntervalSeconds> + </configuration> + </plugin> + + </plugins> + + </build> + <repositories> + <repository> + <id>vaadin-addons</id> + <url>http://maven.vaadin.com/vaadin-addons</url> + </repository> + <repository> + <id>vaadin-snapshots</id> + <name>Vaadin snapshot repository</name> + <url>http://oss.sonatype.org/content/repositories/vaadin-snapshots/</url> + </repository> + </repositories> + + <dependencies> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-server</artifactId> + <version>${vaadin.version}</version> + </dependency> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-client-compiled</artifactId> + <version>${vaadin.version}</version> + </dependency> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-themes</artifactId> + <version>${vaadin.version}</version> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <version>3.1.0</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.12</version> + <scope>test</scope> + </dependency> + + </dependencies> + +</project> \ No newline at end of file diff --git a/P/Sda1/Vaadin/IntegerSet/src/main/java/de/hdm_stuttgart/mi/integerset/ui/HelloUi.java b/P/Sda1/Vaadin/IntegerSet/src/main/java/de/hdm_stuttgart/mi/integerset/ui/HelloUi.java new file mode 100644 index 0000000000000000000000000000000000000000..401cec4a50f854d95da5b893d1ee81da6527aec3 --- /dev/null +++ b/P/Sda1/Vaadin/IntegerSet/src/main/java/de/hdm_stuttgart/mi/integerset/ui/HelloUi.java @@ -0,0 +1,90 @@ +package de.hdm_stuttgart.mi.integerset.ui; + +import java.util.SortedSet; +import java.util.TreeSet; + +import javax.servlet.annotation.WebServlet; + +import com.vaadin.annotations.Theme; +import com.vaadin.annotations.Title; +import com.vaadin.annotations.VaadinServletConfiguration; +import com.vaadin.data.util.ObjectProperty; +import com.vaadin.server.VaadinRequest; +import com.vaadin.server.VaadinServlet; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.TextField; +import com.vaadin.ui.UI; + +/** + * A Set of integer values. + * + */ +@Title("Intro") +@Theme("valo") +public class HelloUi extends UI { + + private static final long serialVersionUID = -307591917714387247L; + + static String convert(final SortedSet<Integer> values) { + if (0 == values.size()) { + return ""; + } else { + final Integer v[] = values.toArray(new Integer[values.size()]); + final StringBuffer ret = new StringBuffer(v[0].toString()); + for (int i = 1; i < v.length; i++) { + ret.append(", " + v[i]); + } + return ret.toString(); + } + } + + final SortedSet<Integer> values = new TreeSet<Integer>(); + + @Override + protected void init(VaadinRequest request) { + + final GridLayout grid = new GridLayout(2, 3); + + setContent(grid); // Attach to the UI + + // Add or remove value + final ObjectProperty<Integer> + addNewInteger = new ObjectProperty<Integer>(0), + removeExistingInteger = new ObjectProperty<Integer>(0); + + final TextField + addEditor = new TextField(addNewInteger), + removeEditor = new TextField(removeExistingInteger); + + final Label output = new Label(); + + grid.addComponents( + new Label("Add value:"), addEditor, + new Label("Remove value:"), removeEditor, + new Label("Numbers:"), output); + + addEditor.addValueChangeListener(event -> { + final Integer i = addNewInteger.getValue(); + if (null != i && values.add(i)) { + output.setValue(convert(values)); + } + }); + + removeEditor.addValueChangeListener(event -> { + final Integer i = removeExistingInteger.getValue(); + if (null != i && values.remove(i)) { + output.setValue(convert(values)); + } + }); + } + + /** Deployment description . + * + */ + @WebServlet(urlPatterns = "/*") + @VaadinServletConfiguration(ui = HelloUi.class, productionMode = false) + public static class MyUIServlet extends VaadinServlet { + private static final long serialVersionUID = -2771410633323765889L; + } +} diff --git a/P/Sda1/Vaadin/IntegerSet/src/main/resources/log4j2.xml b/P/Sda1/Vaadin/IntegerSet/src/main/resources/log4j2.xml new file mode 100644 index 0000000000000000000000000000000000000000..eda4f3b0d781b09217fb4218285c39adf8d3c9c0 --- /dev/null +++ b/P/Sda1/Vaadin/IntegerSet/src/main/resources/log4j2.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Configuration> + <Appenders> + <File name="A1" fileName="A1.log" append="false"> + <PatternLayout pattern="%t %-5p %c{2} - %m%n"/> + </File> + <Console name="STDOUT" target="SYSTEM_OUT"> + <PatternLayout pattern="%C{2} (%F:%L) - %m%n"/> + </Console> + </Appenders> + <Loggers> + + <!-- You my want to define class or package level per-logger rules --> + <Logger name="de.hdm_stuttgart.mi.sda1.catalog2sax.App" level="debug"> + <AppenderRef ref="A1"/> + </Logger> + <Root level="debug"> + <AppenderRef ref="STDOUT"/> + </Root> + </Loggers> +</Configuration> \ No newline at end of file diff --git a/P/Sda1/Vaadin/IntegerSet/src/test/java/.gitignore b/P/Sda1/Vaadin/IntegerSet/src/test/java/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391