diff --git a/README.md b/README.md new file mode 100644 index 0000000..456c5b5 --- /dev/null +++ b/README.md @@ -0,0 +1,52 @@ +contacts +============== + +Template for a simple Vaadin application that only requires a Servlet 3.0 container to run. + + +Workflow +======== + +To compile the entire project, run "mvn install". + +To run the application, run "mvn jetty:run" and open http://localhost:8080/ . + +To produce a deployable production mode WAR: +- change productionMode to true in the servlet class configuration (nested in the UI class) +- run "mvn clean package" +- test the war file with "mvn jetty:run-war" + +Client-Side compilation +------------------------- + +The generated maven project is using an automatically generated widgetset by default. +When you add a dependency that needs client-side compilation, the maven plugin will +automatically generate it for you. Your own client-side customisations can be added into +package "client". + +Debugging client side code + - run "mvn vaadin:run-codeserver" on a separate console while the application is running + - activate Super Dev Mode in the debug window of the application + +Developing a theme using the runtime compiler +------------------------- + +When developing the theme, Vaadin can be configured to compile the SASS based +theme at runtime in the server. This way you can just modify the scss files in +your IDE and reload the browser to see changes. + +To use the runtime compilation, open pom.xml and comment out the compile-theme +goal from vaadin-maven-plugin configuration. To remove a possibly existing +pre-compiled theme, run "mvn clean package" once. + +When using the runtime compiler, running the application in the "run" mode +(rather than in "debug" mode) can speed up consecutive theme compilations +significantly. + +It is highly recommended to disable runtime compilation for production WAR files. + +Using Vaadin pre-releases +------------------------- + +If Vaadin pre-releases are not enabled by default, use the Maven parameter +"-P vaadin-prerelease" or change the activation default value of the profile in pom.xml . diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..675ca95 --- /dev/null +++ b/pom.xml @@ -0,0 +1,173 @@ + + + 4.0.0 + + org.vaadin.stepbystep + contacts + war + 1.0-SNAPSHOT + contacts + + + 3 + + + + 8.0.0 + 8.0.0 + 9.3.9.v20160517 + UTF-8 + 1.8 + 1.8 + + local + + + + + vaadin-addons + http://maven.vaadin.com/vaadin-addons + + + + + + + com.vaadin + vaadin-bom + ${vaadin.version} + pom + import + + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + com.vaadin + vaadin-server + + + com.vaadin + vaadin-push + + + com.vaadin + vaadin-client-compiled + + + com.vaadin + vaadin-themes + + + + + + + org.apache.maven.plugins + maven-war-plugin + 3.0.0 + + false + + WEB-INF/classes/VAADIN/widgetsets/WEB-INF/** + + + + com.vaadin + vaadin-maven-plugin + ${vaadin.plugin.version} + + + + update-theme + update-widgetset + compile + + compile-theme + + + + + + org.apache.maven.plugins + maven-clean-plugin + 3.0.0 + + + + + src/main/webapp/VAADIN/themes + + **/styles.css + **/styles.scss.cache + + + + + + + + + org.eclipse.jetty + jetty-maven-plugin + ${jetty.plugin.version} + + 2 + + + + + + + + + vaadin-prerelease + + false + + + + + vaadin-prereleases + http://maven.vaadin.com/vaadin-prereleases + + + vaadin-snapshots + https://oss.sonatype.org/content/repositories/vaadin-snapshots/ + + false + + + true + + + + + + vaadin-prereleases + http://maven.vaadin.com/vaadin-prereleases + + + vaadin-snapshots + https://oss.sonatype.org/content/repositories/vaadin-snapshots/ + + false + + + true + + + + + + + diff --git a/src/main/java/org/vaadin/stepbystep/MyUI.java b/src/main/java/org/vaadin/stepbystep/MyUI.java new file mode 100644 index 0000000..6dc1bf6 --- /dev/null +++ b/src/main/java/org/vaadin/stepbystep/MyUI.java @@ -0,0 +1,47 @@ +package org.vaadin.stepbystep; + +import javax.servlet.annotation.WebServlet; + +import com.vaadin.annotations.Theme; +import com.vaadin.annotations.VaadinServletConfiguration; +import com.vaadin.server.VaadinRequest; +import com.vaadin.server.VaadinServlet; +import com.vaadin.ui.Button; +import com.vaadin.ui.Label; +import com.vaadin.ui.TextField; +import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; + +/** + * This UI is the application entry point. A UI may either represent a browser window + * (or tab) or some part of a html page where a Vaadin application is embedded. + *

+ * The UI is initialized using {@link #init(VaadinRequest)}. This method is intended to be + * overridden to add component to the user interface and initialize non-component functionality. + */ +@Theme("mytheme") +public class MyUI extends UI { + + @Override + protected void init(VaadinRequest vaadinRequest) { + final VerticalLayout layout = new VerticalLayout(); + + final TextField name = new TextField(); + name.setCaption("Type your name here:"); + + Button button = new Button("Click Me"); + button.addClickListener( e -> { + layout.addComponent(new Label("Thanks " + name.getValue() + + ", it works!")); + }); + + layout.addComponents(name, button); + + setContent(layout); + } + + @WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true) + @VaadinServletConfiguration(ui = MyUI.class, productionMode = false) + public static class MyUIServlet extends VaadinServlet { + } +} diff --git a/src/main/resources/README b/src/main/resources/README new file mode 100644 index 0000000..faabc74 --- /dev/null +++ b/src/main/resources/README @@ -0,0 +1 @@ +Please add your static resources here diff --git a/src/main/webapp/VAADIN/themes/mytheme/addons.scss b/src/main/webapp/VAADIN/themes/mytheme/addons.scss new file mode 100644 index 0000000..a5670b7 --- /dev/null +++ b/src/main/webapp/VAADIN/themes/mytheme/addons.scss @@ -0,0 +1,7 @@ +/* This file is automatically managed and will be overwritten from time to time. */ +/* Do not manually edit this file. */ + +/* Import and include this mixin into your project theme to include the addon themes */ +@mixin addons { +} + diff --git a/src/main/webapp/VAADIN/themes/mytheme/favicon.ico b/src/main/webapp/VAADIN/themes/mytheme/favicon.ico new file mode 100644 index 0000000..ffb34a6 Binary files /dev/null and b/src/main/webapp/VAADIN/themes/mytheme/favicon.ico differ diff --git a/src/main/webapp/VAADIN/themes/mytheme/mytheme.scss b/src/main/webapp/VAADIN/themes/mytheme/mytheme.scss new file mode 100644 index 0000000..2c5fb8b --- /dev/null +++ b/src/main/webapp/VAADIN/themes/mytheme/mytheme.scss @@ -0,0 +1,38 @@ +// If you edit this file you need to compile the theme. See README.md for details. + +// Global variable overrides. Must be declared before importing Valo. + +// Defines the plaintext font size, weight and family. Font size affects general component sizing. +//$v-font-size: 16px; +//$v-font-weight: 300; +//$v-font-family: "Open Sans", sans-serif; + +// Defines the border used by all components. +//$v-border: 1px solid (v-shade 0.7); +//$v-border-radius: 4px; + +// Affects the color of some component elements, e.g Button, Panel title, etc +//$v-background-color: hsl(210, 0%, 98%); +// Affects the color of content areas, e.g Panel and Window content, TextField input etc +//$v-app-background-color: $v-background-color; + +// Affects the visual appearance of all components +//$v-gradient: v-linear 8%; +//$v-bevel-depth: 30%; +//$v-shadow-opacity: 5%; + +// Defines colors for indicating status (focus, success, failure) +//$v-focus-color: valo-focus-color(); // Calculates a suitable color automatically +//$v-friendly-color: #2c9720; +//$v-error-indicator-color: #ed473b; + +// For more information, see: https://vaadin.com/book/-/page/themes.valo.html +// Example variants can be copy/pasted from https://vaadin.com/wiki/-/wiki/Main/Valo+Examples + +@import "../valo/valo.scss"; + +@mixin mytheme { + @include valo; + + // Insert your own theme rules here +} diff --git a/src/main/webapp/VAADIN/themes/mytheme/styles.scss b/src/main/webapp/VAADIN/themes/mytheme/styles.scss new file mode 100644 index 0000000..bba1d49 --- /dev/null +++ b/src/main/webapp/VAADIN/themes/mytheme/styles.scss @@ -0,0 +1,11 @@ +@import "mytheme.scss"; +@import "addons.scss"; + +// This file prefixes all rules with the theme name to avoid causing conflicts with other themes. +// The actual styles should be defined in mytheme.scss + +.mytheme { + @include addons; + @include mytheme; + +}