@Override
public void render()
{
final WithPart part = part();
final WithDef def = part.definition();
final ElementHandle<?> property = part.property();
final Composite composite = new Composite( composite(), SWT.NONE );
composite.setLayoutData( gdhspan( ( part.getScaleVertically() ? gdfill() : gdhfill() ), 2 ) );
composite.setLayout( glayout( 1, 0, 0 ) );
register( composite );
final PossibleTypesService possibleTypesService = property.service( PossibleTypesService.class );
final Composite typeSelectorComposite = new Composite( composite, SWT.NONE );
typeSelectorComposite.setLayoutData( gdhfill() );
final Runnable renderTypeSelectorOp = new Runnable()
{
public void run()
{
for( Control control : typeSelectorComposite.getChildren() )
{
control.dispose();
}
final SortedSet<ElementType> allPossibleTypes = possibleTypesService.types();
final int allPossibleTypesCount = allPossibleTypes.size();
final Runnable updateUserInterfaceOp;
final Style defaultStyle;
if( allPossibleTypesCount == 1 )
{
defaultStyle = Style.CHECKBOX;
}
else if( allPossibleTypesCount <= 3 )
{
defaultStyle = Style.RADIO_BUTTONS;
}
else
{
defaultStyle = Style.DROP_DOWN_LIST;
}
Style style = Style.decode( def.getHint( WithDef.HINT_STYLE ) );
if( style == null || ( style == Style.CHECKBOX && allPossibleTypesCount != 1 ) )
{
style = defaultStyle;
}