X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=swt%2Forg.argeo.cms.swt%2Fsrc%2Forg%2Fargeo%2Fcms%2Fswt%2Fwidgets%2FStyledControl.java;h=9370b52c58fe859b8b719baceb3de925d5b7ec0d;hb=HEAD;hp=82c04a26cde06121c7f7756c075cf3d3c7ee4dfd;hpb=3b45f571938e0eb6803084aac3f2bd298e6026ba;p=lgpl%2Fargeo-commons.git diff --git a/swt/org.argeo.cms.swt/src/org/argeo/cms/swt/widgets/StyledControl.java b/swt/org.argeo.cms.swt/src/org/argeo/cms/swt/widgets/StyledControl.java index 82c04a26c..9370b52c5 100644 --- a/swt/org.argeo.cms.swt/src/org/argeo/cms/swt/widgets/StyledControl.java +++ b/swt/org.argeo.cms.swt/src/org/argeo/cms/swt/widgets/StyledControl.java @@ -91,6 +91,10 @@ public abstract class StyledControl extends Composite implements SwtEditablePart setStyle(style.style()); } + /** + * Set the style, creating all related controls and composites. It should be + * called after all properties have been set. + */ public void setStyle(String style) { Object currentStyle = null; if (control != null) @@ -107,6 +111,18 @@ public abstract class StyledControl extends Composite implements SwtEditablePart } } + /** + * Convenience method when no style is explicitly set, so that the control can + * effectively be created. Does nothing if a control already exists, otherwise + * it is equivalent to {@link #setStyle(String)} with a null + * argument. + */ + public void initControl() { + if (control != null) + return; + setStyle((String) null); + } + /** To be overridden */ protected void setControlLayoutData(Control control) { control.setLayoutData(CmsSwtUtils.fillWidth());