entity panel diagram

The EntityPanel is the base UI class for working with entity instances. It usually consists of an EntityTablePanel, an EntityEditPanel, and a set of detail panels representing the entities having a master/detail relationship with the underlying entity.

1. Basics

You can either extend the EntityPanel class or instantiate one directly, depending on your needs.

public class AddressPanel extends EntityPanel {

  public AddressPanel(SwingEntityModel addressModel) {
    super(addressModel, new AddressEditPanel(addressModel.editModel()));
  }
}
SwingEntityModel addressModel =
        new SwingEntityModel(Address.TYPE, connectionProvider);

EntityPanel addressPanel =
        new EntityPanel(addressModel,
                new AddressEditPanel(addressModel.editModel()));

2. Detail panels

Adding a detail panel is done with a single method call, but note that the underlying EntityModel must contain the correct detail model for the detail panel, in this case a CustomerModel instance, see detail models. See EntityApplicationPanel.

public class CustomerPanel extends EntityPanel {

  public CustomerPanel(SwingEntityModel entityModel) {
    super(entityModel);
    SwingEntityModel addressModel =
            entityModel.detailModels().get(Address.TYPE);
    detailPanels().add(new AddressPanel(addressModel));
  }
}