public static < T > AsyncCallback < T > disabler ( AsyncCallback < T > callback , final HasEnabled ... disablees ) { for ( HasEnabled widget : disablees ) { widget . setEnabled ( false ) ; } return new ChainedCallback < T , T > ( callback ) { @ Override public void onSuccess ( T result ) { for ( HasEnabled widget : disablees ) { widget . setEnabled ( true ) ; } forwardSuccess ( result ) ; } @ Override public void onFailure ( Throwable cause ) { for ( HasEnabled widget : disablees ) { widget . setEnabled ( true ) ; } super . onFailure ( cause ) ; } } ; }
Immediately disables the specified widgets and wraps the supplied callback in one that will reenable those widgets when the callback returns successfully or with failure .