Search in sources :

Example 36 with Customer

use of ui.ex1.entity.Customer in project jmix-docs by Haulmont.

the class KeyValueTest method test.

@Test
void test() {
    // tag::load[]
    List<KeyValueEntity> entities = dataManager.loadValues("select e.customer, sum(e.amount) from sample_Order e group by e.customer").properties("customer", "total").list();
    // end::load[]
    assertEquals(2, entities.size());
    // tag::get-value[]
    for (KeyValueEntity entity : entities) {
        Customer customer = entity.getValue("customer");
        BigDecimal totalAmount = entity.getValue("total");
    // ...
    }
// end::get-value[]
}
Also used : Customer(datamodel.ex1.entity.Customer) KeyValueEntity(io.jmix.core.entity.KeyValueEntity) BigDecimal(java.math.BigDecimal) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 37 with Customer

use of ui.ex1.entity.Customer in project jmix-docs by Haulmont.

the class ActionScreen method custTableCreateNewEntitySupplier.

// end::screen-configurer[]
// tag::new-entity-supplier[]
@Install(to = "custTable.create", subject = "newEntitySupplier")
private Customer custTableCreateNewEntitySupplier() {
    Customer customer = metadata.create(Customer.class);
    customer.setFirstName("Sean");
    customer.setLastName("White");
    return customer;
}
Also used : Customer(ui.ex1.entity.Customer)

Example 38 with Customer

use of ui.ex1.entity.Customer in project jmix-docs by Haulmont.

the class ActionScreen method onCustomersTableCreate.

// end::action-performed-event[]
// tag::action-performed-event-2[]
@Subscribe("customersTable.create")
public void onCustomersTableCreate(Action.ActionPerformedEvent event) {
    screenBuilders.editor(customersTable).newEntity().withOpenMode(OpenMode.DIALOG).withScreenClass(CustomerEdit.class).withAfterCloseListener(afterScreenCloseEvent -> {
        if (afterScreenCloseEvent.closedWith(StandardOutcome.COMMIT)) {
            Customer committedCustomer = (afterScreenCloseEvent.getSource()).getEditedEntity();
            System.out.println("Created " + committedCustomer);
        }
    }).build().show();
}
Also used : Customer(ui.ex1.entity.Customer) CustomerEdit(ui.ex1.screen.entity.customer.CustomerEdit)

Example 39 with Customer

use of ui.ex1.entity.Customer in project jmix-docs by Haulmont.

the class ActionScreen method onCustTableView.

// end::view-after-close-handler[]
// tag::view-action-performed-event[]
@Subscribe("custTable.view")
public void onCustTableView(Action.ActionPerformedEvent event) {
    CustomerEdit customerEdit = screenBuilders.editor(custTable).withOpenMode(OpenMode.DIALOG).withScreenClass(CustomerEdit.class).withAfterCloseListener(afterScreenCloseEvent -> {
        if (afterScreenCloseEvent.closedWith(StandardOutcome.COMMIT)) {
            Customer committedCustomer = (afterScreenCloseEvent.getSource()).getEditedEntity();
            System.out.println("Updated " + committedCustomer);
        }
    }).build();
    customerEdit.setReadOnly(true);
    customerEdit.show();
}
Also used : CollectionLoader(io.jmix.ui.model.CollectionLoader) java.util(java.util) Customer(ui.ex1.entity.Customer) BulkEditors(io.jmix.ui.bulk.BulkEditors) Dialogs(io.jmix.ui.Dialogs) io.jmix.ui.action.list(io.jmix.ui.action.list) TagLookupAction(io.jmix.ui.action.tagpicker.TagLookupAction) Autowired(org.springframework.beans.factory.annotation.Autowired) Metadata(io.jmix.core.Metadata) ParamsMap(io.jmix.core.common.util.ParamsMap) CustomerEdit(ui.ex1.screen.entity.customer.CustomerEdit) ColumnsMode(io.jmix.ui.app.bulk.ColumnsMode) Notifications(io.jmix.ui.Notifications) io.jmix.ui.screen(io.jmix.ui.screen) ScreenBuilders(io.jmix.ui.ScreenBuilders) CustomerBrowse(ui.ex1.screen.entity.customer.CustomerBrowse) RemoveOperation(io.jmix.ui.RemoveOperation) Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) Named(javax.inject.Named) MetaProperty(io.jmix.core.metamodel.model.MetaProperty) DialogAction(io.jmix.ui.action.DialogAction) io.jmix.ui.component(io.jmix.ui.component) Customer(ui.ex1.entity.Customer) CustomerEdit(ui.ex1.screen.entity.customer.CustomerEdit)

Example 40 with Customer

use of ui.ex1.entity.Customer in project jmix-docs by Haulmont.

the class ActionScreen method onCustomersTableEdit.

// end::edit-action-performed-event[]
// tag::edit-action-performed-event-2[]
@Subscribe("customersTable.edit")
public void onCustomersTableEdit(Action.ActionPerformedEvent event) {
    screenBuilders.editor(customersTable).withOpenMode(OpenMode.DIALOG).withScreenClass(CustomerEdit.class).withAfterCloseListener(afterScreenCloseEvent -> {
        if (afterScreenCloseEvent.closedWith(StandardOutcome.COMMIT)) {
            Customer committedCustomer = (afterScreenCloseEvent.getSource()).getEditedEntity();
            System.out.println("Updated " + committedCustomer);
        }
    }).build().show();
}
Also used : Customer(ui.ex1.entity.Customer) CustomerEdit(ui.ex1.screen.entity.customer.CustomerEdit)

Aggregations

Customer (ui.ex1.entity.Customer)34 Customer (dataaccess.ex1.entity.Customer)25 Autowired (org.springframework.beans.factory.annotation.Autowired)12 BaseAction (io.jmix.ui.action.BaseAction)10 io.jmix.ui.screen (io.jmix.ui.screen)10 Named (javax.inject.Named)10 BeforeEach (org.junit.jupiter.api.BeforeEach)10 CustomerEdit (ui.ex1.screen.entity.customer.CustomerEdit)10 Test (org.junit.jupiter.api.Test)9 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)9 Notifications (io.jmix.ui.Notifications)8 Action (io.jmix.ui.action.Action)8 io.jmix.ui.component (io.jmix.ui.component)8 Order (dataaccess.ex1.entity.Order)7 Metadata (io.jmix.core.Metadata)6 ParamsMap (io.jmix.core.common.util.ParamsMap)6 ScreenBuilders (io.jmix.ui.ScreenBuilders)6 DialogAction (io.jmix.ui.action.DialogAction)6 JmixIcon (io.jmix.ui.icon.JmixIcon)6 BigDecimal (java.math.BigDecimal)6