if ( root.getChildren().isEmpty() )
{
Schema[] schemas = schemaPool.getSchemas();
for ( Schema schema : schemas )
{
root.addChild( new SchemaWrapper( schema, root ) );
}
}
children = root.getChildren();
Collections.sort( children, schemaSorter );
}
if ( parentElement instanceof IntermediateNode )
{
IntermediateNode intermediate = ( IntermediateNode ) parentElement;
if ( intermediate.getChildren().isEmpty() )
{
if ( intermediate.getType().equals( IntermediateNodeType.ATTRIBUTE_TYPE_FOLDER ) )
{
Schema schema = ( ( SchemaWrapper ) intermediate.getParent() ).getMySchema();
AttributeType[] ats = schema.getAttributeTypesAsArray();
for ( AttributeType at : ats )
{
intermediate.addChild( new AttributeTypeWrapper( at, intermediate ) );
}
}
else if ( intermediate.getType().equals( IntermediateNodeType.OBJECT_CLASS_FOLDER ) )
{
Schema schema = ( ( SchemaWrapper ) intermediate.getParent() ).getMySchema();
ObjectClass[] ocs = schema.getObjectClassesAsArray();
for ( ObjectClass oc : ocs )
{
intermediate.addChild( new ObjectClassWrapper( oc, intermediate ) );
}
}
}
children = intermediate.getChildren();
// Sort by
if ( sortBy == PluginConstants.PREFS_SCHEMAS_VIEW_SORTING_BY_FIRSTNAME )
{
Collections.sort( children, firstNameSorter );
}
else if ( sortBy == PluginConstants.PREFS_SCHEMAS_VIEW_SORTING_BY_OID )
{
Collections.sort( children, oidSorter );
}
// Sort order
if ( sortOrder == PluginConstants.PREFS_SCHEMAS_VIEW_SORTING_ORDER_DESCENDING )
{
Collections.reverse( children );
}
}
else if ( parentElement instanceof SchemaWrapper )
{
SchemaWrapper schemaWrapper = ( SchemaWrapper ) parentElement;
if ( group == PluginConstants.PREFS_SCHEMAS_VIEW_GROUPING_FOLDERS )
{
if ( schemaWrapper.getChildren().isEmpty() )
{
IntermediateNode attributeTypes = new IntermediateNode(
"Attribute Types", ( SchemaWrapper ) parentElement, IntermediateNodeType.ATTRIBUTE_TYPE_FOLDER ); //$NON-NLS-1$
IntermediateNode objectClasses = new IntermediateNode(
"Object Classes", ( SchemaWrapper ) parentElement, IntermediateNodeType.OBJECT_CLASS_FOLDER ); //$NON-NLS-1$
schemaWrapper.addChild( attributeTypes );
schemaWrapper.addChild( objectClasses );
}
children = schemaWrapper.getChildren();
}
else if ( group == PluginConstants.PREFS_SCHEMAS_VIEW_GROUPING_MIXED )
{
if ( schemaWrapper.getChildren().isEmpty() )
{
Schema schema = schemaWrapper.getMySchema();
AttributeType[] ats = schema.getAttributeTypesAsArray();
for ( AttributeType at : ats )
{
schemaWrapper.addChild( new AttributeTypeWrapper( at, schemaWrapper ) );
}
ObjectClass[] ocs = schema.getObjectClassesAsArray();
for ( ObjectClass oc : ocs )
{
schemaWrapper.addChild( new ObjectClassWrapper( oc, schemaWrapper ) );
}
}
children = schemaWrapper.getChildren();
// Sort by
if ( sortBy == PluginConstants.PREFS_SCHEMAS_VIEW_SORTING_BY_FIRSTNAME )
{
Collections.sort( children, firstNameSorter );