monitor.beginTask( " ", searches.length + 1 ); //$NON-NLS-1$
monitor.reportProgress( " " ); //$NON-NLS-1$
for ( int pi = 0; pi < searches.length; pi++ )
{
ISearch search = searches[pi];
ISearch searchToPerform = searchesToPerform[pi];
monitor.setTaskName( BrowserCoreMessages.bind( BrowserCoreMessages.jobs__search_task, new String[]
{ search.getName() } ) );
monitor.worked( 1 );
if ( search.getBrowserConnection() != null )
{
// reset search results
search.setSearchResults( new ISearchResult[0] );
search.getResponseControls().clear();
search.setNextPageSearchRunnable( null );
search.setTopPageSearchRunnable( null );
searchToPerform.setSearchResults( new ISearchResult[0] );
searchToPerform.setNextPageSearchRunnable( null );
searchToPerform.setTopPageSearchRunnable( null );
searchToPerform.getResponseControls().clear();
do
{
// perform search
searchAndUpdateModel( searchToPerform.getBrowserConnection(), searchToPerform, monitor );
if ( search != searchToPerform )
{
// merge search results
ISearchResult[] sr1 = search.getSearchResults();
ISearchResult[] sr2 = searchToPerform.getSearchResults();
ISearchResult[] sr = new ISearchResult[sr1.length + sr2.length];
System.arraycopy( sr1, 0, sr, 0, sr1.length );
System.arraycopy( sr2, 0, sr, sr1.length, sr2.length );
search.setSearchResults( sr );
}
else
{
// set search results
search.setSearchResults( searchToPerform.getSearchResults() );
}
// check response controls
ISearch clonedSearch = ( ISearch ) searchToPerform.clone();
clonedSearch.getResponseControls().clear();
StudioPagedResultsControl sprResponseControl = null;
StudioPagedResultsControl sprRequestControl = null;
for ( StudioControl responseControl : searchToPerform.getResponseControls() )
{
if ( responseControl instanceof StudioPagedResultsControl )
{
sprResponseControl = ( StudioPagedResultsControl ) responseControl;
}
}
for ( Iterator<StudioControl> it = clonedSearch.getControls().iterator(); it.hasNext(); )
{
StudioControl requestControl = it.next();
if ( requestControl instanceof StudioPagedResultsControl )
{
sprRequestControl = ( StudioPagedResultsControl ) requestControl;
it.remove();
}
}
searchToPerform = null;
// paged search
if ( sprResponseControl != null && sprRequestControl != null )
{
StudioPagedResultsControl nextSpsc = new StudioPagedResultsControl(
sprRequestControl.getSize(), sprResponseControl.getCookie(),
sprRequestControl.isCritical(), sprRequestControl.isScrollMode() );
ISearch nextPageSearch = ( ISearch ) clonedSearch.clone();
nextPageSearch.getResponseControls().clear();
nextPageSearch.getControls().add( nextSpsc );
if ( sprRequestControl.isScrollMode() )
{
if ( sprRequestControl.getCookie() != null )
{
// create top page search runnable, same as original search
ISearch topPageSearch = ( ISearch ) search.clone();
topPageSearch.getResponseControls().clear();
SearchRunnable topPageSearchRunnable = new SearchRunnable( search, topPageSearch );
search.setTopPageSearchRunnable( topPageSearchRunnable );
}
if ( sprResponseControl.getCookie() != null )
{