}
@Override
protected Function initVisibleWhenFunction()
{
final Function function = new Function()
{
@Override
public String name()
{
return "VisibleIfChildrenVisible";
}
@Override
public FunctionResult evaluate( final FunctionContext context )
{
return new FunctionResult( this, context )
{
@Override
protected void init()
{
final Listener pageVisibilityListener = new FilteredListener<PartVisibilityEvent>()
{
@Override
protected void handleTypedEvent( final PartVisibilityEvent event )
{
refresh();
}
};
PageBookPart.this.attach
(
new FilteredListener<PageChangedEvent>()
{
@Override
protected void handleTypedEvent( final PageChangedEvent event )
{
final FormPart page = getCurrentPage();
if( page != null )
{
page.attach( pageVisibilityListener );
}
refresh();
}
}
);
final FormPart page = getCurrentPage();
if( page != null )
{
page.attach( pageVisibilityListener );
}
}
@Override
protected Object evaluate()
{
boolean visible = false;
final FormPart page = getCurrentPage();
if( page != null )
{
visible = page.visible();
}
return visible;
}
};
}
};
function.init();
final Function base = super.initVisibleWhenFunction();
if( base == null )
{
return function;
}