Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

injected #619

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "interactive"
}
4 changes: 3 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 78 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,99 @@
<groupId>com.vaadin</groupId>
<!-- Replace artifactId with vaadin-core to use only free components -->
<artifactId>vaadin</artifactId>
<exclusions>
<!-- Webjars are only needed when running in Vaadin 13 compatibility mode -->
<exclusion>
<groupId>com.vaadin.webjar</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.webjars.bowergithub.insites</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.webjars.bowergithub.polymer</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.webjars.bowergithub.polymerelements</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.webjars.bowergithub.vaadin</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.webjars.bowergithub.webcomponents</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot-starter</artifactId>
<exclusions>
<!-- Excluding so that webjars are not included. -->
<exclusion>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.vaadin.artur</groupId>
<artifactId>a-vaadin-helper</artifactId>
<version>1.7.1</version>
</dependency>

<dependency>
<groupId>com.vaadin</groupId>
<artifactId>exampledata</artifactId>
<version>4.0.0</version>
</dependency>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-testbench</artifactId>
<scope>test</scope>
</dependency>
<!-- Include JUnit 4 support for TestBench and others -->
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
Expand Down
42 changes: 42 additions & 0 deletions src/main/java/org/vaadin/example/AbstractEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.vaadin.example;

import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

@MappedSuperclass
public abstract class AbstractEntity {

@Id
@GeneratedValue
private Integer id;

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

@Override
public int hashCode() {
if (id != null) {
return id.hashCode();
}
return super.hashCode();
}

@Override
public boolean equals(Object obj) {
if (!(obj instanceof AbstractEntity)) {
return false; // null or other class
}
AbstractEntity other = (AbstractEntity) obj;

if (id != null) {
return id.equals(other.id);
}
return super.equals(other);
}
}
1 change: 0 additions & 1 deletion src/main/java/org/vaadin/example/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

/**
* The entry point of the Spring Boot application.
*
Expand Down
46 changes: 46 additions & 0 deletions src/main/java/org/vaadin/example/DataGenerator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.vaadin.example;
import com.vaadin.flow.spring.annotation.SpringComponent;


import java.time.LocalDateTime;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import com.vaadin.exampledata.DataType;
import com.vaadin.exampledata.ExampleDataGenerator;

@SpringComponent
public class DataGenerator {

@Bean
public CommandLineRunner loadData(SamplePersonRepository samplePersonRepository) {
return args -> {
Logger logger = LoggerFactory.getLogger(getClass());
if (samplePersonRepository.count() != 0L) {
logger.info("Using existing database");
return;
}
int seed = 123;

logger.info("Generating demo data");

logger.info("... generating 100 Sample Person entities...");
ExampleDataGenerator<SamplePerson> samplePersonRepositoryGenerator = new ExampleDataGenerator<>(
SamplePerson.class, LocalDateTime.of(2021, 10, 2, 0, 0, 0));
samplePersonRepositoryGenerator.setData(SamplePerson::setId, DataType.ID);
samplePersonRepositoryGenerator.setData(SamplePerson::setFirstName, DataType.FIRST_NAME);
samplePersonRepositoryGenerator.setData(SamplePerson::setLastName, DataType.LAST_NAME);
samplePersonRepositoryGenerator.setData(SamplePerson::setEmail, DataType.EMAIL);
samplePersonRepositoryGenerator.setData(SamplePerson::setPhone, DataType.PHONE_NUMBER);
samplePersonRepositoryGenerator.setData(SamplePerson::setDateOfBirth, DataType.DATE_OF_BIRTH);
samplePersonRepositoryGenerator.setData(SamplePerson::setOccupation, DataType.OCCUPATION);
samplePersonRepositoryGenerator.setData(SamplePerson::setImportant, DataType.BOOLEAN_10_90);
samplePersonRepository.saveAll(samplePersonRepositoryGenerator.create(100, seed));

logger.info("Generated demo data");
};
}

}
11 changes: 10 additions & 1 deletion src/main/java/org/vaadin/example/MainView.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import com.vaadin.flow.component.Key;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.button.ButtonVariant;
import com.vaadin.flow.component.charts.model.Navigator;
import com.vaadin.flow.component.dependency.CssImport;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.textfield.TextField;
Expand All @@ -28,6 +30,7 @@
@CssImport(value = "./styles/vaadin-text-field-styles.css", themeFor = "vaadin-text-field")
public class MainView extends VerticalLayout {


/**
* Construct a new Vaadin view.
* <p>
Expand All @@ -37,7 +40,8 @@ public class MainView extends VerticalLayout {
* The message service. Automatically injected Spring managed
* bean.
*/
public MainView(@Autowired GreetService service) {

public MainView(@Autowired GreetService service, @Autowired MasterDetailView masterDetailView) {

// Use TextField for standard text input
TextField textField = new TextField("Your name");
Expand All @@ -60,6 +64,11 @@ public MainView(@Autowired GreetService service) {
addClassName("centered-content");

add(textField, button);
//MasterDetailView masterDetailView = new MasterDetailView(null);
//add( masterDetailView );

add(masterDetailView);

}

}
Loading