--- /dev/null
+vaadin01
+==============
+
+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 develop the theme, simply update the relevant theme files and reload the application.
+Pre-compiling a theme eliminates automatic theme updates at runtime - see below for more information.
+
+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
+
+To produce a deployable production mode WAR:
+- change productionMode to true in the servlet class configuration (nested in the UI class)
+- run "mvn clean vaadin:compile-theme package"
+ - See below for more information. Running "mvn clean" removes the pre-compiled theme.
+- test with "mvn jetty:run-war
+
+Using a precompiled theme
+-------------------------
+
+When developing the application, Vaadin can compile the theme on the fly when needed,
+or the theme can be precompiled to speed up page loads.
+
+To precompile the theme run "mvn vaadin:compile-theme". Note, though, that once
+the theme has been precompiled, any theme changes will not be visible until the
+next theme compilation or running the "mvn clean" target.
+
+When developing the theme, running the application in the "run" mode (rather than
+in "debug") in the IDE can speed up consecutive on-the-fly theme compilations
+significantly.
+
+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 .
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project-shared-configuration>
+ <!--
+This file contains additional configuration written by modules in the NetBeans IDE.
+The configuration is intended to be shared among all the users of project and
+therefore it is assumed to be part of version control checkout.
+Without this configuration present, some functionality in the IDE may be limited or fail altogether.
+-->
+ <libraries xmlns="http://www.netbeans.org/ns/cdnjs-libraries/1"/>
+ <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
+ <!--
+Properties that influence various parts of the IDE, especially code formatting and the like.
+You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
+That way multiple projects can share the same settings (useful for formatting rules for example).
+Any value defined here will override the pom.xml file value but is only applicable to the current project.
+-->
+ <org-netbeans-modules-css-prep.less_2e_mappings>/less:/css</org-netbeans-modules-css-prep.less_2e_mappings>
+ <org-netbeans-modules-css-prep.less_2e_enabled>false</org-netbeans-modules-css-prep.less_2e_enabled>
+ <org-netbeans-modules-css-prep.sass_2e_enabled>false</org-netbeans-modules-css-prep.sass_2e_enabled>
+ <org-netbeans-modules-css-prep.sass_2e_compiler_2e_options/>
+ <org-netbeans-modules-css-prep.less_2e_compiler_2e_options/>
+ <org-netbeans-modules-css-prep.sass_2e_mappings>/scss:/css</org-netbeans-modules-css-prep.sass_2e_mappings>
+ <org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>Tomcat</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
+ <org-netbeans-modules-whitelist.whitelist-oracle>false</org-netbeans-modules-whitelist.whitelist-oracle>
+ <org-netbeans-modules-web-clientproject-api.js_2e_libs_2e_folder>js/libs</org-netbeans-modules-web-clientproject-api.js_2e_libs_2e_folder>
+ <org-netbeans-modules-javascript2-requirejs.enabled>true</org-netbeans-modules-javascript2-requirejs.enabled>
+ <org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>1.7-web</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>
+ </properties>
+</project-shared-configuration>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<actions>
+ <action>
+ <actionName>run</actionName>
+ <packagings>
+ <packaging>war</packaging>
+ <packaging>ear</packaging>
+ <packaging>ejb</packaging>
+ </packagings>
+ <goals>
+ <goal>package</goal>
+ </goals>
+ <properties>
+ <netbeans.deploy>true</netbeans.deploy>
+ <netbeans.deploy.clientUrlPart>/vaadin01</netbeans.deploy.clientUrlPart>
+ </properties>
+ </action>
+ <action>
+ <actionName>debug</actionName>
+ <packagings>
+ <packaging>war</packaging>
+ <packaging>ear</packaging>
+ <packaging>ejb</packaging>
+ </packagings>
+ <goals>
+ <goal>package</goal>
+ </goals>
+ <properties>
+ <netbeans.deploy.debugmode>true</netbeans.deploy.debugmode>
+ <netbeans.deploy>true</netbeans.deploy>
+ <netbeans.deploy.clientUrlPart>/vaadin01</netbeans.deploy.clientUrlPart>
+ </properties>
+ </action>
+ <action>
+ <actionName>profile</actionName>
+ <packagings>
+ <packaging>ejb</packaging>
+ <packaging>ear</packaging>
+ <packaging>war</packaging>
+ </packagings>
+ <goals>
+ <goal>package</goal>
+ </goals>
+ <properties>
+ <netbeans.deploy>true</netbeans.deploy>
+ <netbeans.deploy.profilemode>true</netbeans.deploy.profilemode>
+ <netbeans.deploy.clientUrlPart>/vaadin01</netbeans.deploy.clientUrlPart>
+ </properties>
+ </action>
+ </actions>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<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>net.korabo.app</groupId>
+ <artifactId>vaadin01</artifactId>
+ <packaging>war</packaging>
+ <version>1.0-SNAPSHOT</version>
+ <name>vaadin01</name>
+
+ <properties>
+ <vaadin.version>7.6.3</vaadin.version>
+ <vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version>
+ <jetty.plugin.version>9.2.3.v20140905</jetty.plugin.version>
+ <project.encoding>UTF-8</project.encoding>
+ </properties>
+
+ <repositories>
+ <repository>
+ <id>vaadin-addons</id>
+ <url>http://maven.vaadin.com/vaadin-addons</url>
+ </repository>
+ <repository>
+ <id>vaadin-snapshots</id>
+ <url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>com.vaadin</groupId>
+ <artifactId>vaadin-bom</artifactId>
+ <version>${vaadin.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.0.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.vaadin</groupId>
+ <artifactId>vaadin-server</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.vaadin</groupId>
+ <artifactId>vaadin-push</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.vaadin</groupId>
+ <artifactId>vaadin-client</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <!--
+ Needed when using the widgetset optimizer (custom ConnectorBundleLoaderFactory).
+
+ For widgetset compilation, vaadin-client-compiler is automatically added on the
+ compilation classpath by vaadin-maven-plugin so normally there is no need for an
+ explicit dependency.
+ -->
+ <!--
+ <dependency>
+ <groupId>com.vaadin</groupId>
+ <artifactId>vaadin-client-compiler</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ -->
+ <dependency>
+ <groupId>com.vaadin</groupId>
+ <artifactId>vaadin-themes</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.orientechnologies</groupId>
+ <artifactId>orientdb-server</artifactId>
+ <version>2.1.7</version>
+ </dependency>
+ <dependency>
+ <groupId>com.orientechnologies</groupId>
+ <artifactId>orientdb-enterprise</artifactId>
+ <version>2.1.7</version>
+ </dependency>
+ <dependency>
+ <groupId>net.korabo.lib</groupId>
+ <artifactId>korabolib</artifactId>
+ <version>1.2.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.vaadin.addons</groupId>
+ <artifactId>dcharts-widget</artifactId>
+ <version>1.7.0</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.vaadin.addons.lazyquerycontainer</groupId>
+ <artifactId>vaadin-lazyquerycontainer</artifactId>
+ <version>7.6.1.3</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.3</version>
+ <configuration>
+ <encoding>${project.encoding}</encoding>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.6</version>
+ <configuration>
+ <encoding>${project.encoding}</encoding>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.3</version>
+ <configuration>
+ <failOnMissingWebXml>false</failOnMissingWebXml>
+ <!-- Exclude some unnecessary files generated by the GWT compiler. -->
+ <packagingExcludes>WEB-INF/classes/VAADIN/gwt-unitCache/**,
+ WEB-INF/classes/VAADIN/widgetsets/WEB-INF/**</packagingExcludes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>com.vaadin</groupId>
+ <artifactId>vaadin-maven-plugin</artifactId>
+ <version>${vaadin.plugin.version}</version>
+ <configuration>
+ <extraJvmArgs>-Xmx512M -Xss1024k</extraJvmArgs>
+ <webappDirectory>${basedir}/target/classes/VAADIN/widgetsets</webappDirectory>
+ <draftCompile>false</draftCompile>
+ <compileReport>false</compileReport>
+ <style>OBF</style>
+ <strict>true</strict>
+ <runTarget>http://localhost:8080/vaadin01</runTarget>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>update-theme</goal>
+ <goal>update-widgetset</goal>
+ <goal>compile</goal>
+ <!-- disabled by default to use on-the-fly theme compilation -->
+ <!-- <goal>compile-theme</goal> -->
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.4</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-clean-plugin</artifactId>
+ <version>2.6.1</version>
+ <!-- Clean up also any pre-compiled themes -->
+ <configuration>
+ <filesets>
+ <fileset>
+ <directory>src/main/webapp/VAADIN/themes</directory>
+ <includes>
+ <include>**/styles.css</include>
+ <include>**/styles.scss.cache</include>
+ </includes>
+ </fileset>
+ </filesets>
+ </configuration>
+ </plugin>
+
+ <!-- The Jetty plugin allows us to easily test the development build by
+ running jetty:run on the command line. -->
+ <plugin>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-maven-plugin</artifactId>
+ <version>${jetty.plugin.version}</version>
+ <configuration>
+ <scanIntervalSeconds>2</scanIntervalSeconds>
+ </configuration>
+ </plugin>
+ </plugins>
+
+ <pluginManagement>
+ <plugins>
+ <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
+ <!-- TODO Remove when http://dev.vaadin.com/ticket/14924 is resolved -->
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>com.vaadin</groupId>
+ <artifactId>
+ vaadin-maven-plugin
+ </artifactId>
+ <versionRange>[7.1.11,)</versionRange>
+ <goals>
+ <goal>resources</goal>
+ <goal>update-widgetset</goal>
+ <goal>compile</goal>
+ <goal>compile-theme</goal>
+ <goal>update-theme</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore></ignore>
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
+ </build>
+
+ <profiles>
+ <profile>
+ <!-- Vaadin pre-release repositories -->
+ <id>vaadin-prerelease</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+
+ <repositories>
+ <repository>
+ <id>vaadin-prereleases</id>
+ <url>http://maven.vaadin.com/vaadin-prereleases</url>
+ </repository>
+ <repository>
+ <id>vaadin-addons</id>
+ <url>http://maven.vaadin.com/vaadin-addons</url>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>vaadin-prereleases</id>
+ <url>http://maven.vaadin.com/vaadin-prereleases</url>
+ </pluginRepository>
+ </pluginRepositories>
+ </profile>
+ </profiles>
+
+</project>
--- /dev/null
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package net.korabo.app.orientdb;
+
+import com.orientechnologies.orient.server.OServer;
+import com.orientechnologies.orient.server.OServerMain;
+import java.io.File;
+import java.util.Properties;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.annotation.WebListener;
+import net.korabo.lib.UriUtil;
+import net.korabo.lib.file.FileUriUtil;
+import net.korabo.lib.file.SysFilesUtil;
+import net.korabo.lib.settings.KSettingsUtil;
+
+/**
+ *
+ * @author cintake
+ */
+@WebListener()
+public class AppServletContextListener implements ServletContextListener{
+
+ @Override
+ public void contextDestroyed(ServletContextEvent sce) {
+// throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ System.out.println("ServletContextListener destroyed");
+ }
+
+ @Override
+ public void contextInitialized(ServletContextEvent sce) {
+// throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ SysFilesUtil.getVarMap().replace(SysFilesUtil.V_CFGBASE, "VAADIN01");
+ String home = SysFilesUtil.findDataUriPath();
+ String orientDB = UriUtil.concatPath(home, "OrientDB");
+ String orientDBcfg = UriUtil.concatPath(orientDB, "config", "orientdb-server-config.xml");
+ String orientDBwww = UriUtil.concatPath(orientDB, "www");
+ Properties props = System.getProperties();
+ props.setProperty("ORIENTDB_HOME", orientDB);
+ props.setProperty("orientdb.www.path", orientDBwww);
+
+ try {
+ OServer server = OServerMain.create();
+ server.startup(FileUriUtil.getFileFor(orientDBcfg));
+ server.activate();
+ } catch (Exception e) {
+ System.out.println(e.getMessage() + e.getStackTrace());
+ }
+
+ System.out.println("ServletContextListener started.");
+ }
+
+}
--- /dev/null
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package net.korabo.app.vaadin01;
+
+import com.vaadin.annotations.Theme;
+import com.vaadin.annotations.Title;
+import com.vaadin.annotations.VaadinServletConfiguration;
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.data.util.BeanItemContainer;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.server.VaadinServlet;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+import javax.servlet.annotation.WebServlet;
+import net.korabo.app.vaadin01.ent.Contact;
+import net.korabo.app.vaadin01.srv.ContactService;
+
+
+/**
+ *
+ * @author cintake
+ */
+@Title("Addressbook")
+@Theme("valo")
+@Widgetset("net.korabo.app.vaadin01.MyAppWidgetset")
+public class AddressbookUI extends UI{
+
+
+ TextField filter = new TextField();
+ Grid contactList = new Grid();
+ Button newContact = new Button("New contact");
+
+ // ContactForm is an example of a custom component class
+ ContactForm contactForm = new ContactForm();
+
+ // ContactService is a in-memory mock DAO that mimics
+ // a real-world datasource. Typically implemented for
+ // example as EJB or Spring Data based service.
+ ContactService service = ContactService.createDemoService();
+
+
+ @Override
+ protected void init(VaadinRequest request) {
+ configureComponents();
+ buildLayout();
+ }
+
+
+ private void configureComponents() {
+
+ newContact.addClickListener(e -> contactForm.edit(new Contact()));
+
+ filter.setInputPrompt("Filter contacts...");
+ filter.addTextChangeListener(e -> refreshContacts(e.getText()));
+
+ contactList.setContainerDataSource(new BeanItemContainer<>(Contact.class));
+ contactList.setColumnOrder("firstName", "lastName", "email");
+ contactList.removeColumn("id");
+ contactList.removeColumn("birthDate");
+ contactList.removeColumn("phone");
+ contactList.setSelectionMode(Grid.SelectionMode.SINGLE);
+ contactList.addSelectionListener(e
+ -> contactForm.edit((Contact) contactList.getSelectedRow()));
+ refreshContacts();
+ }
+
+ private void buildLayout() {
+ HorizontalLayout actions = new HorizontalLayout(filter, newContact);
+ actions.setWidth("100%");
+ filter.setWidth("100%");
+ actions.setExpandRatio(filter, 1);
+
+ VerticalLayout left = new VerticalLayout(actions, contactList);
+ left.setSizeFull();
+ contactList.setSizeFull();
+ left.setExpandRatio(contactList, 1);
+
+ HorizontalLayout mainLayout = new HorizontalLayout(left, contactForm);
+ mainLayout.setSizeFull();
+ mainLayout.setExpandRatio(left, 1);
+
+ // Split and allow resizing
+ setContent(mainLayout);
+ }
+
+ void refreshContacts() {
+ refreshContacts(filter.getValue());
+ }
+
+ private void refreshContacts(String stringFilter) {
+ contactList.setContainerDataSource(new BeanItemContainer<>(
+ Contact.class, service.findAll(stringFilter)));
+ contactForm.setVisible(false);
+ }
+
+
+
+
+ @WebServlet(urlPatterns = "/*")
+ @VaadinServletConfiguration(ui = AddressbookUI.class, productionMode = false)
+ public static class MyUIServlet extends VaadinServlet {
+
+ }
+
+
+}
--- /dev/null
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package net.korabo.app.vaadin01;
+
+import com.vaadin.data.fieldgroup.BeanFieldGroup;
+import com.vaadin.data.fieldgroup.FieldGroup;
+import com.vaadin.event.ShortcutAction;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.DateField;
+import com.vaadin.ui.FormLayout;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Notification;
+import com.vaadin.ui.Notification.Type;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.themes.ValoTheme;
+import net.korabo.app.vaadin01.ent.Contact;
+
+/**
+ *
+ * @author cintake
+ */
+public class ContactForm extends FormLayout {
+
+ Button save = new Button("Save", this::save);
+ Button cancel = new Button("Cancel", this::cancel);
+ TextField firstName = new TextField("First name");
+ TextField lastName = new TextField("Last name");
+ TextField phone = new TextField("Phone");
+ TextField email = new TextField("Email");
+ DateField birthDate = new DateField("Birth date");
+
+ Contact contact;
+
+ // Easily bind forms to beans and manage validation and buffering
+ BeanFieldGroup<Contact> formFieldBindings;
+
+ public ContactForm() {
+ configureComponents();
+ buildLayout();
+ }
+
+ private void configureComponents() {
+
+ save.setStyleName(ValoTheme.BUTTON_PRIMARY);
+ save.setClickShortcut(ShortcutAction.KeyCode.ENTER);
+ setVisible(false);
+ }
+
+ private void buildLayout() {
+ setSizeUndefined();
+ setMargin(true);
+
+ HorizontalLayout actions = new HorizontalLayout(save, cancel);
+ actions.setSpacing(true);
+
+ addComponents(actions, firstName, lastName, phone, email, birthDate);
+ }
+
+ public void save(Button.ClickEvent event) {
+ try {
+ // Commit the fields from UI to DAO
+ formFieldBindings.commit();
+
+ // Save DAO to backend with direct synchronous service API
+ ((AddressbookUI)getUI()).service.save(contact);
+
+ String msg = String.format("Saved '%s %s'.",
+ contact.getFirstName(),
+ contact.getLastName());
+ Notification.show(msg,Type.TRAY_NOTIFICATION);
+ ((AddressbookUI)getUI()).refreshContacts();
+ } catch (FieldGroup.CommitException e) {
+ // Validation exceptions could be shown here
+ }
+ }
+
+ public void cancel(Button.ClickEvent event) {
+ // Place to call business logic.
+ Notification.show("Cancelled", Type.TRAY_NOTIFICATION);
+ ((AddressbookUI)getUI()).contactList.select(null);
+ }
+
+ void edit(Contact contact) {
+ this.contact = contact;
+ if(contact != null) {
+ // Bind the properties of the contact POJO to fiels in this form
+ formFieldBindings = BeanFieldGroup.bindFieldsBuffered(contact, this);
+ firstName.focus();
+ }
+ setVisible(contact != null);
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package net.korabo.app.vaadin01;
+
+import javax.servlet.annotation.WebServlet;
+
+import com.vaadin.annotations.Theme;
+import com.vaadin.annotations.VaadinServletConfiguration;
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.server.VaadinServlet;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+
+/**
+ *
+ */
+@Theme("mytheme")
+@Widgetset("net.korabo.app.vaadin01.MyAppWidgetset")
+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);
+ layout.setMargin(true);
+ layout.setSpacing(true);
+
+ setContent(layout);
+ }
+
+ @WebServlet(urlPatterns = "/MyUI/*", name = "MyUIServlet", asyncSupported = true)
+ @VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
+ public static class MyUIServlet extends VaadinServlet {
+ }
+}
--- /dev/null
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package net.korabo.app.vaadin01.ent;
+
+import java.io.Serializable;
+import java.util.Date;
+import net.korabo.lib.beans.InstanceUtil;
+
+/**
+ *
+ * @author cintake
+ */
+public class Contact implements Serializable, Cloneable {
+
+ private Long id;
+
+ private String firstName = "";
+ private String lastName = "";
+ private String phone = "";
+ private String email = "";
+ private Date birthDate;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public Date getBirthDate() {
+ return birthDate;
+ }
+
+ public void setBirthDate(Date birthDate) {
+ this.birthDate = birthDate;
+ }
+
+ @Override
+ public Contact clone() throws CloneNotSupportedException {
+ try {
+ return (Contact) InstanceUtil.dupObj(this);
+ } catch (Exception ex) {
+ throw new CloneNotSupportedException();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "Contact{" + "id=" + id + ", firstName=" + firstName
+ + ", lastName=" + lastName + ", phone=" + phone + ", email="
+ + email + ", birthDate=" + birthDate + '}';
+ }
+
+}
+
+
--- /dev/null
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package net.korabo.app.vaadin01.srv;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Random;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import net.korabo.app.vaadin01.ent.Contact;
+import net.korabo.lib.beans.InstanceUtil;
+
+/**
+ *
+ * @author cintake
+ */
+public class ContactService {
+
+ // Create dummy data by randomly combining first and last names
+ static String[] fnames = { "Peter", "Alice", "John", "Mike", "Olivia",
+ "Nina", "Alex", "Rita", "Dan", "Umberto", "Henrik", "Rene", "Lisa",
+ "Linda", "Timothy", "Daniel", "Brian", "George", "Scott",
+ "Jennifer" };
+ static String[] lnames = { "Smith", "Johnson", "Williams", "Jones",
+ "Brown", "Davis", "Miller", "Wilson", "Moore", "Taylor",
+ "Anderson", "Thomas", "Jackson", "White", "Harris", "Martin",
+ "Thompson", "Young", "King", "Robinson" };
+
+ private static ContactService instance;
+
+ public static ContactService createDemoService() {
+ if (instance == null) {
+
+ final ContactService contactService = new ContactService();
+
+ Random r = new Random(0);
+ Calendar cal = Calendar.getInstance();
+ for (int i = 0; i < 100; i++) {
+ Contact contact = new Contact();
+ contact.setFirstName(fnames[r.nextInt(fnames.length)]);
+ contact.setLastName(lnames[r.nextInt(fnames.length)]);
+ contact.setEmail(contact.getFirstName().toLowerCase() + "@"
+ + contact.getLastName().toLowerCase() + ".com");
+ contact.setPhone("+ 358 555 " + (100 + r.nextInt(900)));
+ cal.set(1930 + r.nextInt(70),
+ r.nextInt(11), r.nextInt(28));
+ contact.setBirthDate(cal.getTime());
+ contactService.save(contact);
+ }
+ instance = contactService;
+ }
+
+ return instance;
+ }
+
+ private HashMap<Long, Contact> contacts = new HashMap<>();
+ private long nextId = 0;
+
+ public synchronized List<Contact> findAll(String stringFilter) {
+ ArrayList arrayList = new ArrayList();
+ for (Contact contact : contacts.values()) {
+ try {
+ boolean passesFilter = (stringFilter == null || stringFilter.isEmpty())
+ || contact.toString().toLowerCase()
+ .contains(stringFilter.toLowerCase());
+ if (passesFilter) {
+ arrayList.add(contact.clone());
+ }
+ } catch (CloneNotSupportedException ex) {
+ Logger.getLogger(ContactService.class.getName()).log(
+ Level.SEVERE, null, ex);
+ }
+ }
+ Collections.sort(arrayList, new Comparator<Contact>() {
+
+ @Override
+ public int compare(Contact o1, Contact o2) {
+ return (int) (o2.getId() - o1.getId());
+ }
+ });
+ return arrayList;
+ }
+
+ public synchronized long count() {
+ return contacts.size();
+ }
+
+ public synchronized void delete(Contact value) {
+ contacts.remove(value.getId());
+ }
+
+ public synchronized void save(Contact entry) {
+ if (entry.getId() == null) {
+ entry.setId(nextId++);
+ }
+ try {
+ entry = (Contact) InstanceUtil.dupObj(entry);
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ contacts.put(entry.getId(), entry);
+ }
+
+
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.1//EN"
+ "http://google-web-toolkit.googlecode.com/svn/tags/2.5.1/distro-source/core/src/gwt-module.dtd">
+<module>
+ <inherits name="com.vaadin.DefaultWidgetSet"/>
+
+ <inherits name="org.dussan.vaadin.dcharts.DchartsWidgetset" />
+</module>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<Context antiJARLocking="true" path="/vaadin01"/>
--- /dev/null
+/* 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 {
+}
+
--- /dev/null
+// 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
+}
--- /dev/null
+@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;
+
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
+ <context-param>
+ <description>OrientDB initial password</description>
+ <param-name>ORIENTDB_ROOT_PASSWORD</param-name>
+ <param-value>korabo</param-value>
+ </context-param>
+ <session-config>
+ <session-timeout>
+ 30
+ </session-timeout>
+ </session-config>
+</web-app>