public Object[] getChildren( Object parentElement )
{
if ( parentElement instanceof ObjectClassWrapper )
{
//we are looking for the childrens of the contained objectClass
ObjectClass objectClass = ( ( ObjectClassWrapper ) parentElement ).getMyObjectClass();
IntermediateNode sub = new IntermediateNode( "Sub-types", ( ObjectClassWrapper ) parentElement, this, IntermediateNodeType.OBJECT_CLASS_FOLDER ); //$NON-NLS-1$
IntermediateNode may = new IntermediateNode(
"Optionnal Attributes", ( ObjectClassWrapper ) parentElement, this, IntermediateNodeType.ATTRIBUTE_TYPE_FOLDER ); //$NON-NLS-1$
IntermediateNode must = new IntermediateNode(
"Mandatory Attributes", ( ObjectClassWrapper ) parentElement, this, IntermediateNodeType.ATTRIBUTE_TYPE_FOLDER ); //$NON-NLS-1$
//-> we need to compare each and every other objectClass's sup against them
//-> we also need to find a better way to do this (complexity wise)
Collection<ObjectClass> objectClasses = objectClassTable.values();
for ( Iterator iter = objectClasses.iterator(); iter.hasNext(); )
{
ObjectClass oClass = ( ObjectClass ) iter.next();
//not this object class
if ( oClass.getOid() != objectClass.getOid() )
{
String[] sups = oClass.getSuperiors();
for ( String sup : sups )
{
ObjectClass oClassSup = objectClassTable.get( sup );
if ( oClassSup != null )
{
//the current object class is a sup of oClass
if ( oClassSup.equals( objectClass ) )
{
//we use an objectClass wrapper
sub.addElement( new ObjectClassWrapper( oClass, sub ) );
break; //break only the inner for
}
}
}
}
}
//complete optional attributes
String[] optAttributes = objectClass.getMay();
for ( String name : optAttributes )
{
AttributeType attr = attributeTypeTable.get( name );
//A CHANGER, ON FAIT SAUTER LES ATTR QUI NE SONT PAS DEFINIS
//DANS LE SCHEMA COURANT (ATTRS PAR DEFAUT)
if ( attr == null )
continue;
//we use an attribute-type wrapper
may.addElement( new AttributeTypeWrapper( attr, may ) );
}
//complete mandatory attributes
String[] mandAttributes = objectClass.getMust();
for ( String name : mandAttributes )
{
AttributeType attr = attributeTypeTable.get( name );
//A CHANGER, ON FAIT SAUTER LES ATTR QUI NE SONT PAS DEFINIS
//DANS LE SCHEMA COURANT (ATTRS PAR DEFAUT)
if ( attr == null )
continue;
//we use an attribute-type wrapper
must.addElement( new AttributeTypeWrapper( attr, must ) );
}
return new Object[]
{ sub, may, must };
}
else if ( parentElement instanceof IntermediateNode )
{
IntermediateNode intermediate = ( IntermediateNode ) parentElement;
if ( intermediate.getName().equals( "**Primary Node**" ) ) { //$NON-NLS-1$
//if we are asked for the primary node it's because the whole viewer
//is beeing refreshed
// -> the pool has been modified or it's the first display
// -> we need to regenerate the hashmaps containing the schemas elements
refresh();
//clear the primary node (because it's always the same instance we need to
//refresh it manually)
intermediate.clearChildrens();
//bootstrap the tree exploring process by adding the top node into the tree
ObjectClass top = schemaPool.getObjectClass( "top" ); //$NON-NLS-1$
if ( top != null )
{
ObjectClassWrapper topWrapper = new ObjectClassWrapper( top, intermediate );
intermediate.addElement( topWrapper );
}
//add the unresolved object-classes to the top of the hierarchy
Collection<ObjectClass> objectClasses = objectClassTable.values();
for ( Iterator iter = objectClasses.iterator(); iter.hasNext(); )
{
ObjectClass oClass = ( ObjectClass ) iter.next();
String[] sups = oClass.getSuperiors();
//if no supperiors had been set
if ( sups.length == 0 )
{
ObjectClassWrapper wrapper = new ObjectClassWrapper( oClass, intermediate );
wrapper.setState( ObjectClassWrapper.State.unResolved );
intermediate.addElement( wrapper );
}
else
{
for ( String sup : sups )
{
ObjectClass oClassSup = objectClassTable.get( sup );
if ( oClassSup == null )
{
ObjectClassWrapper wrapper = new ObjectClassWrapper( oClass, intermediate );
wrapper.setState( ObjectClassWrapper.State.unResolved );
intermediate.addElement( wrapper );