{
final IRootDSE rootDSE = ( IRootDSE ) parent;
if ( !rootDSE.isChildrenInitialized() && rootDSE.isDirectoryEntry() )
{
new StudioBrowserJob( new InitializeChildrenRunnable( new IEntry[]
{ rootDSE } ) ).execute();
return new String[]
{ "Fetching Entries..." };
}
// 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.isChildrenInitialized() && parentEntry.isDirectoryEntry() )
{
new StudioBrowserJob( new InitializeChildrenRunnable( new IEntry[]
{ parentEntry } ) ).execute();
return new String[]
{ "Fetching Entries..." };
}
int childrenCount = parentEntry.getChildrenCount();
if ( childrenCount <= preferences.getFoldingSize() || !preferences.isUseFolding() )
{
if ( entryToEntryPagesMap.containsKey( parentEntry ) )
{
entryToEntryPagesMap.remove( parentEntry );
}
Object[] results = parentEntry.getChildren();
List<Object> objects = new ArrayList<Object>();
if ( parentEntry.getTopPageChildrenRunnable() != null )
{
objects.add( parentEntry.getTopPageChildrenRunnable() );
}
objects.addAll( Arrays.asList( results ) );
if ( parentEntry.getNextPageChildrenRunnable() != null )
{
objects.add( parentEntry.getNextPageChildrenRunnable() );
}
results = objects.toArray();
if ( results == null )
{
return new String[]
{ "Fetching Entries..." };
}
else
{
return results;
}
}
else
{
BrowserEntryPage[] entryPages = null;
if ( !entryToEntryPagesMap.containsKey( parentEntry ) )
{
entryPages = getEntryPages( parentEntry, 0, childrenCount - 1 );
entryToEntryPagesMap.put( parentEntry, entryPages );
}
else
{
entryPages = entryToEntryPagesMap.get( parentEntry );
if ( childrenCount - 1 != entryPages[entryPages.length - 1].getLast() )
{
entryPages = getEntryPages( parentEntry, 0, childrenCount - 1 );
entryToEntryPagesMap.put( parentEntry, entryPages );
}
}
return entryPages;
}
}
else if ( parent instanceof BrowserSearchResultPage )
{
BrowserSearchResultPage srPage = ( BrowserSearchResultPage ) parent;
Object[] objects = srPage.getChildren();
if ( objects == null )
{
return new String[]
{ "Fetching Search Results..." };
}
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.getSearchResults() == null )
{
new StudioBrowserJob( new SearchRunnable( new ISearch[]
{ search } ) ).execute();
return new String[]
{ "Performing Search..." };
}
else if ( search.getSearchResults().length == 0 )
{
return new String[]
{ "No Results" };
}
else if ( search.getSearchResults().length <= preferences.getFoldingSize() || !preferences.isUseFolding() )
{
Object[] results = search.getSearchResults();
List<Object> objects = new ArrayList<Object>();
if ( search.getTopSearchRunnable() != null )
{
objects.add( search.getTopSearchRunnable() );
}
objects.addAll( Arrays.asList( results ) );
if ( search.getNextSearchRunnable() != null )
{
objects.add( search.getNextSearchRunnable() );
}
results = objects.toArray();
return results;
}
else
{
BrowserSearchResultPage[] srPages = null;
if ( !searchToSearchResultPagesMap.containsKey( search ) )
{
srPages = getSearchResultPages( search, 0, search.getSearchResults().length - 1 );
searchToSearchResultPagesMap.put( search, srPages );
}
else
{
srPages = searchToSearchResultPagesMap.get( search );
if ( search.getSearchResults().length - 1 != srPages[srPages.length - 1].getLast() )
{
srPages = getSearchResultPages( search, 0, search.getSearchResults().length - 1 );
searchToSearchResultPagesMap.put( search, srPages );
}
}
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().getJNDIConnectionWrapper().isConnected() )
{
new StudioBrowserJob( new OpenConnectionsRunnable( browserConnection.getConnection() ) )
.execute();
return new String[]
{ "Opening Connection..." };
}