Search in sources :

Example 1 with Company

use of com.dala.data.company.Company in project DoodleVerse by davidemarcoli.

the class CompanyManagementView method createEditor.

/**
 * Create the Company CRUD-Editor
 * @return the created Crud-Editor
 */
private CrudEditor<Company> createEditor() {
    TextField companyName = new TextField("Company");
    FormLayout form = new FormLayout(companyName);
    form.setMaxWidth("480px");
    form.setResponsiveSteps(new FormLayout.ResponsiveStep("0", 1), new FormLayout.ResponsiveStep("30em", 2));
    Binder<Company> binder = new Binder<>(Company.class);
    binder.forField(companyName).asRequired().bind(Company::getCompanyName, Company::setCompanyName);
    return new BinderCrudEditor<>(binder, form);
}
Also used : FormLayout(com.vaadin.flow.component.formlayout.FormLayout) Binder(com.vaadin.flow.data.binder.Binder) Company(com.dala.data.company.Company) TextField(com.vaadin.flow.component.textfield.TextField) BinderCrudEditor(com.vaadin.flow.component.crud.BinderCrudEditor)

Example 2 with Company

use of com.dala.data.company.Company in project DoodleVerse by davidemarcoli.

the class CompanyManagementView method setupToolbar.

/**
 * Setup the toolbar
 */
private void setupToolbar() {
    Html total = new Html("<span>Total: <b>" + companyRepository.count() + "</b> companies</span>");
    Button button = new Button("New company", VaadinIcon.PLUS.create());
    button.addClickListener(event -> {
        Company newCompany = new Company();
        crud.edit(newCompany, Crud.EditMode.NEW_ITEM);
    });
    button.addThemeVariants(ButtonVariant.LUMO_TERTIARY);
    HorizontalLayout toolbar = new HorizontalLayout(total, button);
    toolbar.setAlignItems(FlexComponent.Alignment.CENTER);
    toolbar.setFlexGrow(1, toolbar);
    toolbar.setJustifyContentMode(FlexComponent.JustifyContentMode.BETWEEN);
    toolbar.setSpacing(false);
    crud.setToolbar(toolbar);
}
Also used : Company(com.dala.data.company.Company) Button(com.vaadin.flow.component.button.Button) Html(com.vaadin.flow.component.Html) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 3 with Company

use of com.dala.data.company.Company in project DoodleVerse by davidemarcoli.

the class FakeGenerator method generateCompanies.

/**
 * Generate random companys
 * @param count the number of randomly generated companys
 * @return the generated companys
 */
public ArrayList<Company> generateCompanies(int count) {
    ArrayList<Company> companies = new ArrayList<>();
    for (int i = 0; i < count; i++) {
        ArrayList<Department> departments = generateDepartment(10);
        companies.add(new Company(0L, faker.company().name(), departments));
    }
    return companies;
}
Also used : Company(com.dala.data.company.Company) Department(com.dala.data.department.Department) ArrayList(java.util.ArrayList)

Aggregations

Company (com.dala.data.company.Company)3 Department (com.dala.data.department.Department)1 Html (com.vaadin.flow.component.Html)1 Button (com.vaadin.flow.component.button.Button)1 BinderCrudEditor (com.vaadin.flow.component.crud.BinderCrudEditor)1 FormLayout (com.vaadin.flow.component.formlayout.FormLayout)1 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)1 TextField (com.vaadin.flow.component.textfield.TextField)1 Binder (com.vaadin.flow.data.binder.Binder)1 ArrayList (java.util.ArrayList)1