}
@Override
protected Composite renderOuterComposite( final GridData gd )
{
final SectionPart part = part();
final SectionDef def = part.definition();
final FormToolkit toolkit = new FormToolkit( composite().getDisplay() );
final Composite outerComposite = new Composite( composite(), SWT.NONE );
outerComposite.setLayoutData( gdhspan( ( part().getScaleVertically() ? gdfill() : gdhfill() ), 2 ) );
outerComposite.setLayout( glayout( 1, 10, 10, 10, 20 ) );
register( outerComposite );
final boolean collapsible = def.getCollapsible().content();
final int style = Section.TITLE_BAR | ( collapsible ? Section.TWISTIE : SWT.NONE );
this.section = toolkit.createSection( outerComposite, style );
this.section.setLayoutData( gdfill() );
if( collapsible )
{
this.section.setExpanded( ! part.folded() );
this.section.addExpansionListener
(
new ExpansionAdapter()
{
public void expansionStateChanged( final ExpansionEvent event )
{
if( event.getState() == true )
{
part.unfold();
}
else
{
part.fold();
}
}
}
);
}
this.sectionContentOuterComposite = new Composite( this.section, SWT.NONE );
this.sectionContentOuterComposite.setLayout( glayout( 1, 0, 0 ) );
final Color bgcolor = resources().color( part.getBackgroundColor(), org.eclipse.sapphire.Color.WHITE );
this.sectionContentOuterComposite.setBackground( bgcolor );
this.sectionContentOuterComposite.setBackgroundMode( SWT.INHERIT_DEFAULT );
attachPartListener
(
new Listener()
{
@Override
public void handle( final Event event )
{
if( event instanceof TitleEvent )
{
refreshTitle();
}
else if( event instanceof DescriptionEvent )
{
refreshDescription();
}
}
}
);
refreshTitle();
refreshDescription();
this.sectionContentInnerComposite = new Composite( this.sectionContentOuterComposite, SWT.NONE );
this.sectionContentInnerComposite.setLayoutData( gdfill() );
this.sectionContentInnerComposite.setLayout( glayout( 2, 0, 0 ) );
final SapphireActionGroup actions = part.getActions();
this.actionPresentationManager = new SapphireActionPresentationManager( this, actions );
final SapphireToolBarActionPresentation toolBarActionsPresentation = new SapphireToolBarActionPresentation( actionPresentationManager );
final ToolBar toolbar = new ToolBar( this.section, SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT );
toolBarActionsPresentation.setToolBar( toolbar );