{
// check cache
if ( referralUrlToReferralConnectionCache.containsKey( referralUrl ) )
{
IConnection referralConnection = ( IConnection ) referralUrlToReferralConnectionCache.get( referralUrl );
if ( referralConnection != null )
{
IConnection[] connections = BrowserCorePlugin.getDefault().getConnectionManager().getConnections();
for ( int i = 0; i < connections.length; i++ )
{
IConnection connection = connections[i];
if ( referralConnection == connection )
{
return referralConnection;
}
}
}
}
referralUrlToReferralConnectionCache.remove( referralUrl );
// open dialog
final IConnection[] referralConnection = new IConnection[1];
PlatformUI.getWorkbench().getDisplay().syncExec( new Runnable()
{
public void run()
{
SelectReferralConnectionDialog dialog = new SelectReferralConnectionDialog( PlatformUI.getWorkbench()
.getDisplay().getActiveShell(), referralUrl );
if ( dialog.open() == SelectReferralConnectionDialog.OK )
{
IConnection connection = dialog.getReferralConnection();
referralUrlToReferralConnectionCache.put( referralUrl, connection );
referralConnection[0] = connection;
}
}
} );