Search in sources :

Example 1 with ContainerPmo

use of org.linkki.core.ui.table.ContainerPmo in project linkki by linkki-framework.

the class PmoBasedDialogFactory method newOkCancelDialog.

/**
 * Creates a new {@link OkCancelDialog}.
 *
 * @param title The dialog title.
 * @param okHandler The called when OK is clicked.
 * @param pmos The presentation model objects providing the data and the layout information.
 * @return A dialog with the content defined by the given PMO.
 */
public OkCancelDialog newOkCancelDialog(String title, Handler okHandler, Object... pmos) {
    OkCancelDialog dialog = new OkCancelDialog(title, okHandler, ButtonOption.OK_CANCEL);
    DialogBindingManager bindingManager = new DialogBindingManager(dialog, validationService, propertyBehaviorProvider);
    BindingContext bindingContext = bindingManager.startNewContext(dialog.getClass());
    for (Object pmo : pmos) {
        AbstractSection content;
        if (pmo instanceof ContainerPmo) {
            content = pmoBasedSectionFactory.createTableSection((ContainerPmo<?>) pmo, bindingContext);
        } else {
            content = pmoBasedSectionFactory.createSection(pmo, bindingContext);
        }
        float expRatio = 0f;
        if (pmo == pmos[pmos.length - 1]) {
            expRatio = 1f;
        }
        dialog.addContent(content, expRatio);
    }
    bindingContext.updateUI();
    return dialog;
}
Also used : ContainerPmo(org.linkki.core.ui.table.ContainerPmo) AbstractSection(org.linkki.core.ui.section.AbstractSection) PresentationModelObject(org.linkki.core.PresentationModelObject) BindingContext(org.linkki.core.binding.BindingContext)

Aggregations

PresentationModelObject (org.linkki.core.PresentationModelObject)1 BindingContext (org.linkki.core.binding.BindingContext)1 AbstractSection (org.linkki.core.ui.section.AbstractSection)1 ContainerPmo (org.linkki.core.ui.table.ContainerPmo)1