protected String layoutBeforeChild( Control control, String labelText, String elementName, Map<String, String> attributes, Control container, SwtMetawidget metawidget ) { State state = getState( (Composite) container ); // Add label if ( SimpleLayoutUtils.needsLabel( labelText, elementName ) ) { Label label = new Label( (Composite) container, SWT.None ); // Required if ( attributes != null && TRUE.equals( attributes.get( REQUIRED ) ) && !WidgetBuilderUtils.isReadOnly( attributes ) && !metawidget.isReadOnly() ) { label.setText( labelText + "*" + StringUtils.SEPARATOR_COLON ); } else { label.setText( labelText + StringUtils.SEPARATOR_COLON ); } CC labelConstraints = new CC(); labelConstraints.cell( state.currentColumn * 2, state.currentRow ); labelConstraints.growX(); // Top align all labels, not just those belonging to 'tall' controls, // so that tall controls, regular controls and nested Metawidget // controls all line up labelConstraints.alignY( "top" ); // Apply some vertical padding so the label lines up with the control nicely labelConstraints.pad( state.defaultLabelVerticalPadding, 0, state.defaultLabelVerticalPadding, 0 ); // Add it label.setLayoutData( labelConstraints ); label.moveAbove( control ); } return labelText; }
labelConstraints.cell( state.currentColumn * 2, state.currentRow ); labelConstraints.growX();
public void onEndBuild( SwingMetawidget metawidget ) { // Buttons Facet buttonsFacet = metawidget.getFacet( "buttons" ); if ( buttonsFacet != null ) { State state = getState( metawidget ); if ( state.currentColumn > 0 ) { state.currentColumn = 0; state.currentRow++; } metawidget.add( buttonsFacet, new CC().cell( 0, state.currentRow ).spanX().growX() ); } }
public void onEndBuild( SwtMetawidget metawidget ) { // Buttons Facet buttonsFacet = metawidget.getFacet( "buttons" ); if ( buttonsFacet != null ) { State state = getState( metawidget ); if ( state.currentColumn > 0 ) { state.currentColumn = 0; state.currentRow++; } buttonsFacet.setLayoutData( new CC().cell( 0, state.currentRow ).spanX().growX() ); buttonsFacet.moveBelow( null ); } }