Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Commit

Permalink
Migrate to Vaadin 8 (v7 compatibility mode)
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-baiborodine committed Jan 24, 2018
1 parent 3fc94d3 commit b8dcad0
Show file tree
Hide file tree
Showing 26 changed files with 2,706 additions and 813 deletions.
185 changes: 123 additions & 62 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,62 +5,110 @@

<groupId>com.kiroule</groupId>
<artifactId>jpetstore-6-vaadin-spring-boot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.0.2-SNAPSHOT</version>
<packaging>jar</packaging>

<name>jpetstore-6-vaadin-spring-boot</name>
<description>JPetStore Vaadin 7 with Spring Boot Demo</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
<version>1.5.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<name>jpetstore-6-vaadin-spring-boot</name>
<description>JPetStore Vaadin 8 with Spring Boot</description>

<properties>
<vaadin.version>8.1.5</vaadin.version>
<vaadin-spring.version>2.1.0.beta2</vaadin-spring.version>
<vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version>
<org.vaadin.spring.version>0.0.7.RELEASE</org.vaadin.spring.version>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<vaadin.version>7.7.7</vaadin.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<vaadin.widgetset.mode>cdn</vaadin.widgetset.mode>
</properties>

<repositories>
<repository>
<id>vaadin-addons</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
<repository>
<id>vaadin-pre</id>
<url>http://maven.vaadin.com/vaadin-prereleases</url>
</repository>
<repository>
<id>vaadin-snapshot</id>
<url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
</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>
<!--SPRING-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-compatibility-server</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.2.0</version>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-compatibility-client-compiled</artifactId>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-compatibility-themes</artifactId>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot-starter</artifactId>
<version>${vaadin-spring.version}</version><!--$NO-MVN-MAN-VER$ -->
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot</artifactId>
<version>${vaadin-spring.version}</version><!--$NO-MVN-MAN-VER$ -->
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring</artifactId>
<version>1.2.0</version>
<version>${vaadin-spring.version}</version><!--$NO-MVN-MAN-VER$ -->
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-security</artifactId>
<version>${vaadin-spring.version}</version>
</dependency>
<dependency>
<groupId>org.vaadin.addon</groupId>
<artifactId>confirmdialog</artifactId>
<version>3.1.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<!--VAADIN-->
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot-starter</artifactId>
<version>1.2.0</version>
<artifactId>webcomponents-helper</artifactId>
<version>0.2.0</version>
</dependency>
<dependency>
<groupId>org.vaadin</groupId>
<artifactId>viritin</artifactId>
<version>1.61</version>
</dependency>
<dependency>
<groupId>org.vaadin.addons</groupId>
<artifactId>loginform</artifactId>
<version>0.6.2</version>
<artifactId>viritin-v7-compatibility</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.vaadin.addons</groupId>
Expand All @@ -70,14 +118,50 @@
<dependency>
<groupId>org.vaadin.addons</groupId>
<artifactId>stepper</artifactId>
<version>2.3.0</version>
<version>2.4.0</version>
</dependency>

<!-- Spring -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--LOGGING-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.vaadin.spring.addons</groupId>
<artifactId>vaadin-spring-addon-eventbus</artifactId>
<version>${org.vaadin.spring.version}</version>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>runtime</scope>
</dependency>

<!-- Testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
</dependency>

<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand All @@ -90,32 +174,15 @@
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<!--PERSISTENCE-->
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>runtime</scope>
</dependency>
<!--MISC-->

<!-- Misc -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
<version>23.0</version>
</dependency>
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>${vaadin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -144,19 +211,19 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<version>3.7.0</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
<source>${java.version}</source>
<target>${java.version}</target>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.source}</target>
</configuration>
</plugin>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>${vaadin.version}</version>
<configuration>
<widgetsetMode>cdn</widgetsetMode>
<widgetsetMode>${vaadin.widgetset.mode}</widgetsetMode>
<extraJvmArgs>-Xmx2g -Xss1024k</extraJvmArgs>
<webappDirectory>
${basedir}/src/main/resources/VAADIN/widgetsets
Expand Down Expand Up @@ -220,10 +287,4 @@
</plugins>
</build>

<repositories>
<repository>
<id>vaadin-addons</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
</repositories>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
import org.springframework.context.annotation.Import;

@SpringBootApplication
@SpringBootApplication(exclude = {SecurityAutoConfiguration.class })
@Import({DataSourceConfig.class, ServiceConfig.class})
public class JPetStore6Application {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@
import com.kiroule.jpetstore.vaadinspring.ui.view.ItemListView;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.Title;
import com.vaadin.annotations.Widgetset;
import com.vaadin.navigator.Navigator;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinSession;
import com.vaadin.spring.annotation.SpringUI;
import com.vaadin.spring.navigator.SpringViewProvider;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.v7.ui.HorizontalLayout;
import com.vaadin.v7.ui.VerticalLayout;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -46,8 +47,9 @@
/**
* @author Igor Baiborodine
*/
@Title("JPetStore Vaadin 7 Spring Demo")
@Title("JPetStore Vaadin 8 Spring Demo")
@Theme("jpetstoretheme")
@Widgetset("com.vaadin.v7.Vaadin7WidgetSet")
@SpringUI
public class MainUI extends UI {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button;
import com.vaadin.ui.Component;
import com.vaadin.ui.Notification;
import com.vaadin.ui.UI;
import com.vaadin.v7.data.Validator;
import com.vaadin.v7.data.validator.RegexpValidator;
import com.vaadin.v7.ui.TextField;

import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.risto.stepper.IntStepper;
import org.vaadin.viritin.fields.MTable;
import org.vaadin.viritinv7.fields.MTable;
import org.vaadin.viritinv7.fields.MTextField;

import java.math.BigDecimal;

Expand Down Expand Up @@ -61,7 +65,7 @@ public CartItemListTable() {
withGeneratedColumn("productId", cartItem -> cartItem.getItem().getProductId());
withGeneratedColumn("description",
cartItem -> cartItem.getItem().getAttribute1() + " " + cartItem.getItem().getProduct().getName());
withGeneratedColumn("quantity", this::createQuantityStepper);
withGeneratedColumn("quantity", this::createQuantityField);
withGeneratedColumn("removeFromCart",
cartItem -> new Button("Remove", event -> {
if (CurrentCart.isEmpty()) {
Expand All @@ -76,23 +80,50 @@ public CartItemListTable() {
withFullWidth();
}

private IntStepper createQuantityStepper(CartItem cartItem) {

IntStepper quantityStepper = new IntStepper();
quantityStepper.setMinValue(1);
quantityStepper.setMaxValue(99);
quantityStepper.setWidth(60f, Unit.PIXELS);
quantityStepper.setManualInputAllowed(false);
quantityStepper.setValue(cartItem.getQuantity());
quantityStepper.addValueChangeListener(event -> {
if (CartItemListTable.this.isReadOnly()) {
event.getProperty().setValue(cartItem.getQuantity());
return;
}
Integer newQuantity = (Integer) event.getProperty().getValue();
UIEventBus.post(new UIChangeCartItemQuantityEvent(cartItem.getItem(), newQuantity - cartItem.getQuantity()));
private TextField createQuantityField(CartItem cartItem) {
final TextField quantityField = new MTextField();
quantityField.setNullSettingAllowed(false);
quantityField.setWidth(60f, Unit.PIXELS);
quantityField.addStyleName("align-right");
quantityField.setValue(String.valueOf(cartItem.getQuantity()));
final RegexpValidator regexpValidator = new RegexpValidator("\\d+", "Numeric values only");

quantityField.addValueChangeListener((ValueChangeListener) event -> {
if (((String) event.getProperty().getValue()).isEmpty()) {
Notification.show("Must not be empty", Notification.Type.ERROR_MESSAGE);
return;
}
boolean valid = true;
try {
regexpValidator.validate(event.getProperty().getValue());
} catch (Validator.InvalidValueException e) {
valid = false;
}
if (valid) {
Integer newQuantity = Integer.valueOf((String) event.getProperty().getValue());
UIEventBus.post(new UIChangeCartItemQuantityEvent(
cartItem.getItem(), newQuantity - cartItem.getQuantity()));
} else {
Notification.show("Numeric values only", Notification.Type.ERROR_MESSAGE);
}
});
return quantityStepper;
return quantityField;
// TODO: use stepper after migrating to v8 without v7 compatibility mode
// IntStepper quantityStepper = new IntStepper();
// quantityStepper.setMinValue(1);
// quantityStepper.setMaxValue(99);
// quantityStepper.setWidth(60f, Unit.PIXELS);
// quantityStepper.setManualInputAllowed(false);
// quantityStepper.setValue(cartItem.getQuantity());
// quantityStepper.addValueChangeListener(event -> {
// if (CartItemListTable.this.isReadOnly()) {
// event.getSource().setValue(cartItem.getQuantity());
// return;
// }
// Integer newQuantity = event.getSource().getValue();
// UIEventBus.post(new UIChangeCartItemQuantityEvent(cartItem.getItem(), newQuantity - cartItem.getQuantity()));
// });
// return quantityStepper;
}

private void viewDetails(Button.ClickEvent event) {
Expand Down
Loading

0 comments on commit b8dcad0

Please sign in to comment.