Search in sources :

Example 26 with Customer

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

the class RelatedEntitiesScreen method onRelatedClick.

// tag::related-click[]
@Subscribe("related")
protected void onRelatedClick(Button.ClickEvent event) {
    RelatedEntitiesBuilder builder = relatedEntitiesSupport.builder(this);
    Screen customerBrowser = builder.withEntityClass(Order.class).withProperty("customer").withSelectedEntities(ordersTable.getSelected()).build();
    customerBrowser.show();
}
Also used : Order(ui.ex1.entity.Order) RelatedEntitiesBuilder(io.jmix.ui.relatedentities.RelatedEntitiesBuilder)

Example 27 with Customer

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

the class TableScreen method onTableSelectEventSelection.

@Subscribe("tableSelectEvent")
public void onTableSelectEventSelection(Table.SelectionEvent<Customer> event) {
    Customer customer = tableSelectEvent.getSingleSelected();
    notifications.create().withCaption("You selected " + customer.getFirstName() + " " + customer.getLastName() + " customer").show();
}
Also used : Customer(ui.ex1.entity.Customer)

Example 28 with Customer

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

the class DataGridScreen method createCloseButton.

// end::details-generator[]
// tag::create-close-button[]
protected Component createCloseButton(Customer entity) {
    Button closeButton = uiComponents.create(Button.class);
    closeButton.setIcon("font-icon:TIMES");
    BaseAction closeAction = new BaseAction("closeAction").withHandler(actionPerformedEvent -> detailsGrid.setDetailsVisible(entity, false)).withCaption("");
    closeButton.setAction(closeAction);
    return closeButton;
}
Also used : CollectionLoader(io.jmix.ui.model.CollectionLoader) ValueSource(io.jmix.ui.component.data.ValueSource) ThemeClassNames(io.jmix.ui.theme.ThemeClassNames) CollectionContainer(io.jmix.ui.model.CollectionContainer) Date(java.util.Date) Collection(java.util.Collection) Autowired(org.springframework.beans.factory.annotation.Autowired) ContainerDataGridItems(io.jmix.ui.component.data.datagrid.ContainerDataGridItems) ExcelExportAction(io.jmix.uiexport.action.ExcelExportAction) Notifications(io.jmix.ui.Notifications) JmixIcon(io.jmix.ui.icon.JmixIcon) DateUtils(org.apache.commons.lang3.time.DateUtils) UiComponents(io.jmix.ui.UiComponents) Icons(io.jmix.ui.icon.Icons) io.jmix.ui.screen(io.jmix.ui.screen) ui.ex1.entity(ui.ex1.entity) Map(java.util.Map) BaseAction(io.jmix.ui.action.BaseAction) Named(javax.inject.Named) io.jmix.ui.component(io.jmix.ui.component) BaseAction(io.jmix.ui.action.BaseAction)

Example 29 with Customer

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

the class CustomerBrowseData method createCustomer.

// end::find-by-name[]
// tag::create-customer[]
private void createCustomer() {
    Customer customer = metadata.create(Customer.class);
    customer.setFirstName("John");
    customer.setLastName("Doe");
    customersDc.getMutableItems().add(customer);
}
Also used : Customer(ui.ex1.entity.Customer)

Example 30 with Customer

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

the class TableScreen method onInit.

// end::inject-tableClick[]
// tag::onInit-start[]
@Subscribe
public void onInit(InitEvent event) {
    // end::onInit-start[]
    customersTable.addGeneratedColumn("aaa", entity -> null);
    // tag::add-base-action[]
    customersTable.addAction(new AboutSingleAction());
    // end::add-base-action[]
    // tag::add-ItemTrackingAction[]
    customersTable.addAction(new ItemTrackingAction("about") {

        @Nullable
        @Override
        public String getCaption() {
            return "About";
        }

        @Override
        public void actionPerform(Component component) {
            notifications.create().withCaption("Hello " + customersTable.getSelected().iterator().next()).withType(Notifications.NotificationType.TRAY).show();
        }
    });
    // end::add-ItemTrackingAction[]
    // tag::table-set-style-name[]
    tableBorderless.setStyleName(ThemeClassNames.TABLE_BORDERLESS);
    // end::table-set-style-name[]
    // tag::column-value-provider[]
    printableTableExcelExport.addColumnValueProvider("firstName", context -> {
        // <1>
        Customer customer = context.getEntity();
        return "Name: " + customer.getFirstName();
    });
    // end::column-value-provider[]
    printableTableExcelExport.addColumnValueProvider("fullName", context -> {
        Customer customer = context.getEntity();
        return customer.getFirstName() + " " + customer.getLastName();
    });
    // tag::table-add-printable[]
    /*printableTable.addPrintable("firstName", new Table.Printable<Customer, String>() {
            @Override
            public String getValue(Customer item) {
                return "Name: " + item.getFirstName();
            }
        });*/
    // end::table-add-printable[]
    // tag::printable-column-generator[]
    /*printableTable.addGeneratedColumn("fullName", new Table.PrintableColumnGenerator<Customer, String>() {
            @Override
            public String getValue(Customer item) {
                return item.getFirstName() + " " + item.getLastName();
            }

            @Override
            public Component generateCell(Customer entity) {
                Label label = uiComponents.create(Label.NAME);
                label.setValue(entity.getFirstName() + " " + entity.getLastName());
                return label;
            }
        });*/
    // end::printable-column-generator[]
    // tag::item-click-action[]
    tableClick.setItemClickAction(new BaseAction("itemClickAction").withHandler(actionPerformedEvent -> {
        Customer customer = tableClick.getSingleSelected();
        if (customer != null) {
            notifications.create().withCaption("Item clicked for: " + customer.getFirstName() + "" + customer.getLastName()).show();
        }
    }));
    // end::item-click-action[]
    // tag::enter-press-action[]
    tableClick.setEnterPressAction(new BaseAction("enterPressAction").withHandler(actionPerformedEvent -> {
        Customer customer = tableClick.getSingleSelected();
        if (customer != null) {
            notifications.create().withCaption("Enter pressed for: " + customer.getFirstName() + "" + customer.getLastName()).show();
        }
    }));
    // end::enter-press-action[]
    // tag::programmatic-binding[]
    customersTable1.setItems(new ContainerTableItems<>(customersDc));
// end::programmatic-binding[]
// tag::onInit-end[]
}
Also used : ItemTrackingAction(io.jmix.ui.action.ItemTrackingAction) Customer(ui.ex1.entity.Customer) ThemeClassNames(io.jmix.ui.theme.ThemeClassNames) CollectionContainer(io.jmix.ui.model.CollectionContainer) Collection(java.util.Collection) Autowired(org.springframework.beans.factory.annotation.Autowired) ExcelExportAction(io.jmix.uiexport.action.ExcelExportAction) Notifications(io.jmix.ui.Notifications) JmixIcon(io.jmix.ui.icon.JmixIcon) List(java.util.List) UiComponents(io.jmix.ui.UiComponents) io.jmix.ui.screen(io.jmix.ui.screen) ScreenBuilders(io.jmix.ui.ScreenBuilders) SendByEmailAction(ui.ex1.screen.actions.SendByEmailAction) EmailAttachment(io.jmix.email.EmailAttachment) BudgetItem(ui.ex1.entity.BudgetItem) Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) Named(javax.inject.Named) ContainerTableItems(io.jmix.ui.component.data.table.ContainerTableItems) Collections(java.util.Collections) City(ui.ex1.entity.City) Nullable(javax.annotation.Nullable) io.jmix.ui.component(io.jmix.ui.component) Customer(ui.ex1.entity.Customer) ItemTrackingAction(io.jmix.ui.action.ItemTrackingAction) BaseAction(io.jmix.ui.action.BaseAction) Nullable(javax.annotation.Nullable)

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