Skip to content

Instantly share code, notes, and snippets.

@eiswind
Created August 11, 2012 05:22
Show Gist options
  • Save eiswind/3321417 to your computer and use it in GitHub Desktop.
Save eiswind/3321417 to your computer and use it in GitHub Desktop.
Hack to render contribution ids in for RAP UI Tests (Snippet from Widget.java)
public void setData( Object data ) {
checkWidget();
if( ( state & KEYED_DATA ) != 0 ) {
( ( Object[] )this.data )[ 0 ] = data;
} else {
this.data = data;
}
if( UITestUtil.isEnabled() && data != null ) {
Class<? extends Object> clazz = data.getClass();
while( clazz != Object.class ) {
for( Class<?> type : clazz.getInterfaces() ) {
if( type.getSimpleName().equals( "IContributionItem" ) ) {
try {
Method getter = clazz.getMethod( "getId", new Class<?>[]{} );
String id = ( String )getter.invoke( data, new Object[]{} );
handleCustomId( WidgetUtil.CUSTOM_WIDGET_ID, id );
} catch( Exception e ) {
e.printStackTrace();
}
}
}
clazz = clazz.getSuperclass();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment