{
final IRootDSE rootDSE = ( IRootDSE ) parent;
if ( !rootDSE.isChildrenInitialized() )
{
new StudioBrowserJob( new InitializeChildrenRunnable( false, rootDSE ) ).execute();
return new String[]
{ Messages.getString( "BrowserContentProvider.FetchingEntries" ) }; //$NON-NLS-1$
}
// get base entries
List<IEntry> entryList = new ArrayList<IEntry>();
entryList.addAll( Arrays.asList( rootDSE.getChildren() ) );
// remove non-visible entries
for ( Iterator<IEntry> it = entryList.iterator(); it.hasNext(); )
{
Object o = it.next();
if ( !preferences.isShowDirectoryMetaEntries() && ( o instanceof DirectoryMetadataEntry ) )
{
it.remove();
}
}
return entryList.toArray();
}
else if ( parent instanceof IEntry )
{
final IEntry parentEntry = ( IEntry ) parent;
if ( parentEntry instanceof IContinuation )
{
IContinuation continuation = ( IContinuation ) parentEntry;
if ( continuation.getState() == State.UNRESOLVED )
{
continuation.resolve();
}
if ( continuation.getState() == State.CANCELED )
{
return new Object[0];
}
}
if ( !parentEntry.isChildrenInitialized() )
{
new StudioBrowserJob( new InitializeChildrenRunnable( false, parentEntry ) ).execute();
return new String[]
{ Messages.getString( "BrowserContentProvider.FetchingEntries" ) }; //$NON-NLS-1$
}
else if ( parentEntry.getChildrenCount() <= preferences.getFoldingSize() || !preferences.isUseFolding() )
{
if ( entryToEntryPagesMap.containsKey( parentEntry ) )
{
entryToEntryPagesMap.remove( parentEntry );
}
IEntry[] results = parentEntry.getChildren();
List<Object> objects = new ArrayList<Object>();
if ( widget.getQuickSearch() != null
&& parentEntry.getDn().equals( widget.getQuickSearch().getSearchBase() ) )
{
objects.add( widget.getQuickSearch() );
}
if ( parentEntry.getTopPageChildrenRunnable() != null )
{
objects.add( parentEntry.getTopPageChildrenRunnable() );
}
objects.addAll( Arrays.asList( results ) );
if ( parentEntry.getNextPageChildrenRunnable() != null )
{
objects.add( parentEntry.getNextPageChildrenRunnable() );
}
return objects.toArray();
}
else
{
BrowserEntryPage[] entryPages = getEntryPages( parentEntry );
List<Object> objects = new ArrayList<Object>();
if ( widget.getQuickSearch() != null
&& parentEntry.getDn().equals( widget.getQuickSearch().getSearchBase() ) )
{
objects.add( widget.getQuickSearch() );
}
objects.addAll( Arrays.asList( entryPages ) );
return objects.toArray();
}
}
else if ( parent instanceof BrowserSearchResultPage )
{
BrowserSearchResultPage srPage = ( BrowserSearchResultPage ) parent;
Object[] objects = srPage.getChildren();
if ( objects == null )
{
return new String[]
{ Messages.getString( "BrowserContentProvider.FetchingSearchResults" ) }; //$NON-NLS-1$
}
else if ( objects instanceof ISearchResult[] )
{
ISearchResult[] srs = ( ISearchResult[] ) objects;
return srs;
}
else
{
return objects;
}
}
else if ( parent instanceof ISearch )
{
ISearch search = ( ISearch ) parent;
if ( search instanceof IContinuation )
{
IContinuation continuation = ( IContinuation ) search;
if ( continuation.getState() == State.UNRESOLVED )
{
continuation.resolve();
}
if ( continuation.getState() == State.CANCELED )
{
return new Object[0];
}
}
if ( search.getSearchResults() == null || search.getSearchContinuations() == null )
{
new StudioBrowserJob( new SearchRunnable( new ISearch[]
{ search } ) ).execute();
return new String[]
{ Messages.getString( "BrowserContentProvider.PerformingSearch" ) }; //$NON-NLS-1$
}
else if ( search.getSearchResults().length + search.getSearchContinuations().length == 0 )
{
return new String[]
{ Messages.getString( "BrowserContentProvider.NoResults" ) }; //$NON-NLS-1$
}
else if ( search.getSearchResults().length <= preferences.getFoldingSize() || !preferences.isUseFolding() )
{
if ( searchToSearchResultPagesMap.containsKey( search ) )
{
searchToSearchResultPagesMap.remove( search );
}
ISearchResult[] results = search.getSearchResults();
SearchContinuation[] scs = search.getSearchContinuations();
List<Object> objects = new ArrayList<Object>();
if ( search.getTopSearchRunnable() != null )
{
objects.add( search.getTopSearchRunnable() );
}
objects.addAll( Arrays.asList( results ) );
if ( scs != null )
{
objects.addAll( Arrays.asList( scs ) );
}
if ( search.getNextSearchRunnable() != null )
{
objects.add( search.getNextSearchRunnable() );
}
return objects.toArray();
}
else
{
BrowserSearchResultPage[] srPages = getSearchResultPages( search );
return srPages;
}
}
else if ( parent instanceof BrowserCategory )
{
BrowserCategory category = ( BrowserCategory ) parent;
IBrowserConnection browserConnection = category.getParent();
switch ( category.getType() )
{
case BrowserCategory.TYPE_DIT:
{
// open connection when expanding DIT
if ( browserConnection.getConnection() != null
&& !browserConnection.getConnection().getConnectionWrapper().isConnected() )
{
new StudioBrowserJob( new OpenConnectionsRunnable( browserConnection.getConnection() ) )
.execute();
return new String[]
{ Messages.getString( "BrowserContentProvider.OpeningConnection" ) }; //$NON-NLS-1$
}