-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5547660
commit cc243a9
Showing
7 changed files
with
65 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 45 additions & 41 deletions
86
crud-ui-demo/src/main/java/org/vaadin/crudui/demo/ui/view/SimpleTreeCrudView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,75 @@ | ||
package org.vaadin.crudui.demo.ui.view; | ||
|
||
import javax.annotation.PostConstruct; | ||
|
||
import com.vaadin.flow.component.HasValueAndElement; | ||
import com.vaadin.flow.component.combobox.ComboBox; | ||
import com.vaadin.flow.component.orderedlayout.VerticalLayout; | ||
import com.vaadin.flow.component.textfield.TextArea; | ||
import com.vaadin.flow.component.textfield.TextField; | ||
import com.vaadin.flow.router.Route; | ||
import javax.annotation.PostConstruct; | ||
|
||
import org.vaadin.crudui.crud.impl.TreeGridCrud; | ||
import org.vaadin.crudui.demo.entity.Category; | ||
import org.vaadin.crudui.demo.service.CategoryService; | ||
import org.vaadin.crudui.demo.ui.MainLayout; | ||
import org.vaadin.crudui.layout.impl.VerticalSplitCrudLayout; | ||
|
||
/** | ||
* @author XakepSDK | ||
*/ | ||
@Route(value = "simple-tree", layout = MainLayout.class) | ||
public class SimpleTreeCrudView extends VerticalLayout { | ||
|
||
protected final CategoryService categoryService; | ||
protected final CategoryService categoryService; | ||
|
||
public SimpleTreeCrudView(CategoryService categoryService) { | ||
this.categoryService = categoryService; | ||
} | ||
public SimpleTreeCrudView(CategoryService categoryService) { | ||
this.categoryService = categoryService; | ||
} | ||
|
||
@PostConstruct | ||
private void build() { | ||
TreeGridCrud<Category> crud = new TreeGridCrud<Category>(Category.class); | ||
crud.getGrid().removeAllColumns(); | ||
crud.getGrid().addHierarchyColumn(Category::getName) | ||
.setHeader("Name"); | ||
@PostConstruct | ||
private void build() { | ||
TreeGridCrud<Category> crud = new TreeGridCrud<Category>(Category.class); | ||
crud.getGrid().removeAllColumns(); | ||
crud.getGrid().addHierarchyColumn(Category::getName) | ||
.setHeader("Name"); | ||
|
||
crud.setChildItemProvider(category -> categoryService.findChildren(category)); | ||
crud.setChildItemProvider(category -> categoryService.findChildren(category)); | ||
|
||
crud.getCrudFormFactory().setVisibleProperties("name", "parent", "description"); | ||
crud.getCrudFormFactory().setVisibleProperties("name", "parent", "description"); | ||
|
||
crud.getCrudFormFactory().setFieldProvider("name", () -> createNameField()); | ||
crud.getCrudFormFactory().setFieldProvider("parent", () -> createParentSelector()); | ||
crud.getCrudFormFactory().setFieldProvider("description", () -> createDescriptionField()); | ||
crud.getCrudFormFactory().setFieldProvider("name", category -> createNameField()); | ||
crud.getCrudFormFactory().setFieldProvider("parent", category -> createParentSelector()); | ||
crud.getCrudFormFactory().setFieldProvider("description", category -> createDescriptionField()); | ||
|
||
crud.setFindAllOperation(() -> categoryService.findRoots()); | ||
crud.setFindAllOperation(() -> categoryService.findRoots()); | ||
|
||
crud.setAddOperation(category -> categoryService.save(category)); | ||
crud.setUpdateOperation(category -> categoryService.save(category)); | ||
crud.setDeleteOperation(category -> categoryService.delete(category)); | ||
crud.setAddOperation(category -> categoryService.save(category)); | ||
crud.setUpdateOperation(category -> categoryService.save(category)); | ||
crud.setDeleteOperation(category -> categoryService.delete(category)); | ||
|
||
crud.setChildItemProvider(category -> categoryService.findChildren(category)); | ||
crud.setChildItemProvider(category -> categoryService.findChildren(category)); | ||
|
||
crud.setShowNotifications(false); | ||
addAndExpand(crud); | ||
setSizeFull(); | ||
} | ||
crud.setShowNotifications(false); | ||
addAndExpand(crud); | ||
setSizeFull(); | ||
} | ||
|
||
private HasValueAndElement createNameField() { | ||
TextField nameField = new TextField("Name"); | ||
nameField.setWidth("300px"); | ||
return nameField; | ||
} | ||
private HasValueAndElement createNameField() { | ||
TextField nameField = new TextField("Name"); | ||
nameField.setWidth("300px"); | ||
return nameField; | ||
} | ||
|
||
private HasValueAndElement createDescriptionField() { | ||
TextArea descriptionField = new TextArea("Description"); | ||
descriptionField.setWidth("300px"); | ||
return descriptionField; | ||
} | ||
private HasValueAndElement createDescriptionField() { | ||
TextArea descriptionField = new TextArea("Description"); | ||
descriptionField.setWidth("300px"); | ||
return descriptionField; | ||
} | ||
|
||
private HasValueAndElement createParentSelector() { | ||
ComboBox<Category> selector = new ComboBox<Category>("Parent", categoryService.findAll()); | ||
selector.setWidth("300px"); | ||
return selector; | ||
} | ||
private HasValueAndElement createParentSelector() { | ||
ComboBox<Category> selector = new ComboBox<Category>("Parent", categoryService.findAll()); | ||
selector.setWidth("300px"); | ||
return selector; | ||
} | ||
|
||
} |