X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=swt%2Forg.argeo.cms.swt%2Fsrc%2Forg%2Fargeo%2Fcms%2Fswt%2Facr%2FSwtUiProvider.java;fp=swt%2Forg.argeo.cms.swt%2Fsrc%2Forg%2Fargeo%2Fcms%2Fswt%2Facr%2FSwtUiProvider.java;h=403bc8e871efcd646c7afe12c36df2ea4fdce032;hb=c69946007916a000fe88524f4e927bb612741c6e;hp=4988fc6b897b6300fcc601c87918200fe71ddd46;hpb=9fd6762a7ac6bb5102dcd2c5a3bc876aa5c942c4;p=lgpl%2Fargeo-commons.git diff --git a/swt/org.argeo.cms.swt/src/org/argeo/cms/swt/acr/SwtUiProvider.java b/swt/org.argeo.cms.swt/src/org/argeo/cms/swt/acr/SwtUiProvider.java index 4988fc6b8..403bc8e87 100644 --- a/swt/org.argeo.cms.swt/src/org/argeo/cms/swt/acr/SwtUiProvider.java +++ b/swt/org.argeo.cms.swt/src/org/argeo/cms/swt/acr/SwtUiProvider.java @@ -3,8 +3,31 @@ package org.argeo.cms.swt.acr; import org.argeo.api.acr.Content; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Layout; +/** + * Creates SWT UI parts based on a given view/model context. For simple UIs, the + * view and controller can usually be implemented directly in the method, while + * more complex UI components may require a dedicated object (either an internal + * or external class). The main purpose of this factory pattern is to ease the + * dependency injection of other services used. + */ @FunctionalInterface public interface SwtUiProvider { + /** + * Populates the provided {@link Composite} with SWT UI components (view) and + * listeners (controller), based on the provided {@link Content}. For a typical + * view or editor, the context will be the data to display/edit, but it can also + * just be used to access the underlying data session. + * + * @param parent the SWT {@link Composite} to use as parent for the widgets. + * Implementations should not assume that a {@link Layout} has + * been set on it, and should therefore set the appropriate + * layout themselves. + * @param context the data to display or a generic data context (typically a + * user home area). + * @return a {@link Control} within the parent on which to focus if needed, Can + * be null, so client should always check. + */ Control createUiPart(Composite parent, Content context); }