directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r518658 [2/3] - in /directory/ldapstudio/trunk/ldapstudio-schemas-plugin: ./ META-INF/ ressources/icons/ src/main/java/org/apache/directory/ldapstudio/schemas/ src/main/java/org/apache/directory/ldapstudio/schemas/controller/ src/main/java/...
Date Thu, 15 Mar 2007 15:14:44 GMT
Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaPool.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaPool.java?view=diff&rev=518658&r1=518657&r2=518658
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaPool.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaPool.java Thu Mar 15 08:14:41 2007
@@ -25,9 +25,9 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Set;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 import org.apache.directory.ldapstudio.schemas.Activator;
 import org.apache.directory.ldapstudio.schemas.view.preferences.SchemasEditorPreferencePage;
@@ -61,8 +61,14 @@
     private static SchemaPool instance_;
     private static Object syncObject_ = new Object();
 
-    private ArrayList<Schema> schemaList;
-    private ArrayList<PoolListener> listeners;
+    private List<Schema> schemaList;
+    private List<PoolListener> listeners;
+
+    private List<AttributeType> attributeTypes = new ArrayList<AttributeType>();
+    private List<ObjectClass> objectClasses = new ArrayList<ObjectClass>();
+
+    private Map<String, AttributeType> attributeTypesMap = new HashMap<String, AttributeType>();
+    private Map<String, ObjectClass> objectClassesMap = new HashMap<String, ObjectClass>();
 
 
     /**
@@ -169,8 +175,8 @@
     private static void initializeWithSpecified( SchemaPool pool )
     {
         IEclipsePreferences prefs = new ConfigurationScope().getNode( Activator.PLUGIN_ID );
-        String specificPath = prefs
-            .get( SchemasEditorPreferencePage.SPECIFIC_CORE_DIRECTORY, System.getProperty( "user.home" ) ); //$NON-NLS-1$
+        String specificPath = prefs.get( SchemasEditorPreferencePage.SPECIFIC_CORE_DIRECTORY, System
+            .getProperty( "user.home" ) ); //$NON-NLS-1$
 
         File dir = new File( specificPath );
         String sCurPath = dir.getAbsolutePath() + File.separator;
@@ -227,7 +233,8 @@
                     IEclipsePreferences prefs = new ConfigurationScope().getNode( Activator.PLUGIN_ID );
 
                     //2) initialize the pool
-                    boolean initialize_with_specified = prefs.getBoolean( SchemasEditorPreferencePage.SPECIFIC_CORE, false );
+                    boolean initialize_with_specified = prefs.getBoolean( SchemasEditorPreferencePage.SPECIFIC_CORE,
+                        false );
                     if ( initialize_with_specified )
                     {
                         //2a) with user-specified core schemas
@@ -283,8 +290,7 @@
      */
     public Schema[] getSchemas()
     {
-        return schemaList.toArray( new Schema[]
-            {} );
+        return schemaList.toArray( new Schema[0] );
     }
 
 
@@ -335,7 +341,7 @@
      */
     public boolean containsObjectClass( String name )
     {
-        return getObjectClass( name ) != null;
+        return objectClassesMap.containsKey( name );
     }
 
 
@@ -346,7 +352,7 @@
      */
     public boolean containsAttributeType( String name )
     {
-        return getAttributeType( name ) != null;
+        return attributeTypesMap.containsKey( name );
     }
 
 
@@ -358,13 +364,7 @@
      */
     public boolean containsObjectClass( ObjectClass objectClass )
     {
-        String[] names = objectClass.getNames();
-        for ( String name : names )
-        {
-            if ( getObjectClass( name ) != null )
-                return true;
-        }
-        return false;
+        return objectClassesMap.containsKey( objectClass.getOid() );
     }
 
 
@@ -376,13 +376,7 @@
      */
     public boolean containsAttributeType( AttributeType attributeType )
     {
-        String[] names = attributeType.getNames();
-        for ( String name : names )
-        {
-            if ( getAttributeType( name ) != null )
-                return true;
-        }
-        return false;
+        return attributeTypesMap.containsKey( attributeType.getOid() );
     }
 
 
@@ -393,9 +387,7 @@
      */
     public ObjectClass getObjectClass( String name )
     {
-        Hashtable<String, ObjectClass> objectClassTable = getObjectClassesAsHashTableByName();
-
-        return objectClassTable.get( name );
+        return objectClassesMap.get( name );
     }
 
 
@@ -406,81 +398,19 @@
      */
     public AttributeType getAttributeType( String name )
     {
-        Hashtable<String, AttributeType> attributeTypeTable = getAttributeTypesAsHashTableByName();
-
-        return attributeTypeTable.get( name );
+        return attributeTypesMap.get( name );
     }
 
 
-    /**
-     * Accessor to all the objectClasses defined by the schemas stored in the pool
-     * @return as an (name, objectClass) hashtable 
-     */
-    public Hashtable<String, ObjectClass> getObjectClassesAsHashTableByName()
+    public Map<String, ObjectClass> getObjectClassesAsMap()
     {
-        Hashtable<String, ObjectClass> objectClassTable = new Hashtable<String, ObjectClass>();
-
-        for ( Schema schema : schemaList )
-        {
-            Hashtable<String, ObjectClass> temp = schema.getObjectClassesAsHashTable();
-            if ( temp != null )
-                objectClassTable.putAll( temp );
-        }
-        return objectClassTable;
-    }
-
-
-    /**
-     * Accessor to all the objectClasses defined by the schemas stored in the pool
-     * @return as an (oid, ObjectClass) hashtable
-     */
-    public Hashtable<String, ObjectClass> getObjectClassesAsHashTableByOID()
-    {
-        Hashtable<String, ObjectClass> classesTable = new Hashtable<String, ObjectClass>();
-
-        ObjectClass[] ObjectClasses = getObjectClassesAsArray();
-        for ( ObjectClass class1 : ObjectClasses )
-        {
-            classesTable.put( class1.getOid(), class1 );
-        }
-
-        return classesTable;
-    }
-
-
-    /**
-     * Accessor to all the attributeType defined by the schemas stored in the pool
-     * @return as an (name, attributeType) hashtable
-     */
-    public Hashtable<String, AttributeType> getAttributeTypesAsHashTableByName()
-    {
-        Hashtable<String, AttributeType> attributeTypeTable = new Hashtable<String, AttributeType>();
-
-        for ( Schema schema : schemaList )
-        {
-            Hashtable<String, AttributeType> temp = schema.getAttributeTypesAsHashTable();
-            if ( temp != null )
-                attributeTypeTable.putAll( temp );
-        }
-        return attributeTypeTable;
+        return objectClassesMap;
     }
 
 
-    /**
-     * Accessor to all the attributeType defined by the schemas stored in the pool
-     * @return as an (oid, attributeType) hashtable
-     */
-    public Hashtable<String, AttributeType> getAttributeTypesAsHashTableByOID()
+    public Map<String, AttributeType> getAttributeTypesAsMap()
     {
-        Hashtable<String, AttributeType> attributeTypeTable = new Hashtable<String, AttributeType>();
-
-        AttributeType[] attributeTypes = getAttributeTypesAsArray();
-        for ( AttributeType type : attributeTypes )
-        {
-            attributeTypeTable.put( type.getOid(), type );
-        }
-
-        return attributeTypeTable;
+        return attributeTypesMap;
     }
 
 
@@ -489,22 +419,12 @@
      * the schemas stored in the pool
      * @return as an (oid, SchemaElement) hashtable
      */
-    public Hashtable<String, SchemaElement> getSchemaElementsAsHashTableByOID()
+    public Map<String, SchemaElement> getSchemaElements()
     {
-        Hashtable<String, SchemaElement> elementsTable = new Hashtable<String, SchemaElement>();
-
-        AttributeType[] attributeTypes = getAttributeTypesAsArray();
-        ObjectClass[] objectClasses = getObjectClassesAsArray();
+        Map<String, SchemaElement> elementsTable = new HashMap<String, SchemaElement>();
 
-        for ( ObjectClass class1 : objectClasses )
-        {
-            elementsTable.put( class1.getOid(), class1 );
-        }
-
-        for ( AttributeType type : attributeTypes )
-        {
-            elementsTable.put( type.getOid(), type );
-        }
+        elementsTable.putAll( attributeTypesMap );
+        elementsTable.putAll( objectClassesMap );
 
         return elementsTable;
     }
@@ -514,11 +434,9 @@
      * Accessor to all the objectClasses defined by the schemas stored in the pool
      * @return as an array
      */
-    public ObjectClass[] getObjectClassesAsArray()
+    public List<ObjectClass> getObjectClasses()
     {
-        Set<ObjectClass> set = new HashSet<ObjectClass>();
-        set.addAll(getObjectClassesAsHashTableByName().values());
-        return set.toArray(new ObjectClass[0]);
+        return objectClasses;
     }
 
 
@@ -526,11 +444,9 @@
      * Accessor to all the attributeType defined by the schemas stored in the pool
      * @return as an array
      */
-    public AttributeType[] getAttributeTypesAsArray()
+    public List<AttributeType> getAttributeTypes()
     {
-        Set<AttributeType> set = new HashSet<AttributeType>();
-        set.addAll(getAttributeTypesAsHashTableByName().values());
-        return set.toArray(new AttributeType[0]);
+        return attributeTypes;
     }
 
 
@@ -560,9 +476,20 @@
             if ( !containsSchema( s.getName() ) )
             {
                 schemaList.add( s );
-                //we register as a listener of the schema
                 s.addListener( this );
-                //we notify our listeners that a schema has been added
+
+                AttributeType[] ats = s.getAttributeTypesAsArray();
+                for ( int i = 0; i < ats.length; i++ )
+                {
+                    addAttributeType( ats[i] );
+                }
+
+                ObjectClass[] ocs = s.getObjectClassesAsArray();
+                for ( int i = 0; i < ocs.length; i++ )
+                {
+                    addObjectClass( ocs[i] );
+                }
+
                 notifyChanged( LDAPModelEvent.Reason.SchemaAdded, s );
                 return true;
             }
@@ -660,7 +587,19 @@
             schemaList.remove( s );
             s.removeListener( this );
             s.closeAssociatedEditors();
-            //notify of the changement
+
+            AttributeType[] ats = s.getAttributeTypesAsArray();
+            for ( int i = 0; i < ats.length; i++ )
+            {
+                removeAttributeType( ats[i] );
+            }
+
+            ObjectClass[] ocs = s.getObjectClassesAsArray();
+            for ( int i = 0; i < ocs.length; i++ )
+            {
+                removeObjectClass( ocs[i] );
+            }
+
             notifyChanged( LDAPModelEvent.Reason.SchemaRemoved, s );
         }
     }
@@ -774,12 +713,35 @@
     }
 
 
-    /******************************************
-     *           Schema Listener Impl         *
-     ******************************************/
-
+    /* (non-Javadoc)
+     * @see org.apache.directory.ldapstudio.schemas.model.SchemaListener#schemaChanged(org.apache.directory.ldapstudio.schemas.model.Schema, org.apache.directory.ldapstudio.schemas.model.LDAPModelEvent)
+     */
     public void schemaChanged( Schema originatingSchema, LDAPModelEvent e )
     {
+        switch ( e.getReason() )
+        {
+            case ATAdded:
+            case OCAdded:
+                elementAdded( e );
+                break;
+
+            case ATModified:
+                attributeTypeModified( e );
+                break;
+
+            case OCModified:
+                objectClassModified( e );
+                break;
+
+            case ATRemoved:
+            case OCRemoved:
+                elementRemoved( e );
+                break;
+
+            default:
+                break;
+        }
+
         for ( PoolListener listener : listeners )
         {
             try
@@ -789,7 +751,176 @@
             catch ( Exception e1 )
             {
                 logger.debug( "error when notifying " + listener + " of pool modification" ); //$NON-NLS-1$ //$NON-NLS-2$
+                e1.printStackTrace(); // TODO remove this
             }
         }
+    }
+
+
+    /**
+     * Updates the SchemaPool after an event of type ATAdded or case OCAdded.
+     *
+     * @param e
+     *      the associated event
+     */
+    private void elementAdded( LDAPModelEvent e )
+    {
+        SchemaElement schemaElement = ( SchemaElement ) e.getNewValue();
+
+        if ( schemaElement instanceof AttributeType )
+        {
+            addAttributeType( ( AttributeType ) schemaElement );
+        }
+        else if ( schemaElement instanceof ObjectClass )
+        {
+            addObjectClass( ( ObjectClass ) schemaElement );
+        }
+    }
+
+
+    /**
+     * Updates the SchemaPool after an event of type ATModified.
+     *
+     * @param e
+     *      the associated event
+     */
+    private void attributeTypeModified( LDAPModelEvent e )
+    {
+        AttributeType oldAttributeType = ( AttributeType ) e.getOldValue();
+        AttributeType newAttributeType = ( AttributeType ) e.getNewValue();
+
+        String[] names = oldAttributeType.getNames();
+        for ( int j = 0; j < names.length; j++ )
+        {
+            attributeTypesMap.remove( names[j] );
+        }
+        attributeTypesMap.remove( oldAttributeType.getOid() );
+
+        names = newAttributeType.getNames();
+        for ( int j = 0; j < names.length; j++ )
+        {
+            attributeTypesMap.put( names[j], newAttributeType );
+        }
+        attributeTypesMap.put( newAttributeType.getOid(), newAttributeType );
+    }
+
+
+    /**
+     * Updates the SchemaPool after an event of type OCModified.
+     *
+     * @param e
+     *      the associated event
+     */
+    private void objectClassModified( LDAPModelEvent e )
+    {
+        ObjectClass oldObjectClass = ( ObjectClass ) e.getOldValue();
+        ObjectClass newObjectClass = ( ObjectClass ) e.getNewValue();
+
+        String[] names = oldObjectClass.getNames();
+        for ( int j = 0; j < names.length; j++ )
+        {
+            objectClassesMap.remove( names[j] );
+        }
+        objectClassesMap.remove( oldObjectClass.getOid() );
+
+        names = newObjectClass.getNames();
+        for ( int j = 0; j < names.length; j++ )
+        {
+            objectClassesMap.put( names[j], newObjectClass );
+        }
+        objectClassesMap.put( newObjectClass.getOid(), newObjectClass );
+    }
+
+
+    /**
+     * Updates the SchemaPool after an event of type ATRemoved or case OCRemoved.
+     *
+     * @param e
+     *      the associated event
+     */
+    private void elementRemoved( LDAPModelEvent e )
+    {
+        SchemaElement schemaElement = ( SchemaElement ) e.getOldValue();
+
+        if ( schemaElement instanceof AttributeType )
+        {
+            removeAttributeType( ( AttributeType ) schemaElement );
+        }
+        else if ( schemaElement instanceof ObjectClass )
+        {
+            removeObjectClass( ( ObjectClass ) schemaElement );
+        }
+    }
+
+
+    /**
+     * Adds an attribute type.
+     *
+     * @param at
+     *      the attribute type to add
+     */
+    private void addAttributeType( AttributeType at )
+    {
+        String[] names = at.getNames();
+        for ( int j = 0; j < names.length; j++ )
+        {
+            attributeTypesMap.put( names[j], at );
+        }
+        attributeTypesMap.put( at.getOid(), at );
+        attributeTypes.add( at );
+    }
+
+
+    /**
+     * Removes an attribute type.
+     *
+     * @param at
+     *      the attribute type to remove
+     */
+    private void removeAttributeType( AttributeType at )
+    {
+        String[] names = at.getNames();
+        for ( int j = 0; j < names.length; j++ )
+        {
+            attributeTypesMap.remove( names[j] );
+        }
+        attributeTypesMap.remove( at.getOid() );
+        attributeTypes.remove( at );
+    }
+
+
+    /**
+     * Adds an object class.
+     *
+     * @param oc
+     *      the object class to add
+     */
+    private void addObjectClass( ObjectClass oc )
+    {
+        String[] names = oc.getNames();
+        for ( int j = 0; j < names.length; j++ )
+        {
+            objectClassesMap.put( names[j], oc );
+        }
+        objectClassesMap.put( oc.getOid(), oc );
+        objectClasses.add( oc );
+    }
+
+
+    /**
+     * Removes an object class
+     *
+     * @param oc
+     *      the object class to remove
+     */
+    private void removeObjectClass( ObjectClass oc )
+    {
+        String[] names = oc.getNames();
+        for ( int j = 0; j < names.length; j++ )
+        {
+            objectClassesMap.remove( names[j] );
+        }
+        objectClassesMap.remove( oc.getOid() );
+        objectClasses.remove( oc );
     }
 }

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeFormEditor.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeFormEditor.java?view=diff&rev=518658&r1=518657&r2=518658
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeFormEditor.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeFormEditor.java Thu Mar 15 08:14:41 2007
@@ -118,8 +118,14 @@
         originalAttributeType = ( ( AttributeTypeFormEditorInput ) getEditorInput() ).getAttributeType();
         originalAttributeType.setEditor( this );
 
-        modifiedAttributeType = new AttributeType( originalAttributeType.getLiteral(), originalAttributeType
-            .getOriginatingSchema() );
+        try
+        {
+            modifiedAttributeType = ( AttributeType ) originalAttributeType.clone();
+        }
+        catch ( CloneNotSupportedException e )
+        {
+            // Will never occurr.
+        }
 
         addPageChangedListener( pageChangedListener );
     }
@@ -177,7 +183,7 @@
             return;
         }
 
-        updateAttributeType( modifiedAttributeType, originalAttributeType );
+        originalAttributeType.update( modifiedAttributeType );
 
         setPartName( getEditorInput().getName() );
         if ( !monitor.isCanceled() )
@@ -256,32 +262,6 @@
     public void setModifiedAttributeType( AttributeType modifiedAttributeType )
     {
         this.modifiedAttributeType = modifiedAttributeType;
-    }
-
-
-    /**
-     * Updates the values of an attribute type to another one
-     *
-     * @param at1
-     *      the attribute type literal to clone from
-     * @param at2
-     *      the attribute type literal to clone to
-     */
-    private void updateAttributeType( AttributeType at1, AttributeType at2 )
-    {
-        at2.setCollective( at1.isCollective() );
-        at2.setDescription( at1.getDescription() );
-        at2.setEquality( at1.getEquality() );
-        at2.setNames( at1.getNames() );
-        at2.setNoUserModification( at1.isNoUserModification() );
-        at2.setObsolete( at1.isObsolete() );
-        at2.setOid( at1.getOid() );
-        at2.setOrdering( at1.getOrdering() );
-        at2.setSingleValue( at1.isSingleValue() );
-        at2.setSubstr( at1.getSubstr() );
-        at2.setSuperior( at1.getSuperior() );
-        at2.setSyntax( at1.getSyntax() );
-        at2.setUsage( at1.getUsage() );
     }
 
 

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeFormEditorOverviewPage.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeFormEditorOverviewPage.java?view=diff&rev=518658&r1=518657&r2=518658
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeFormEditorOverviewPage.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeFormEditorOverviewPage.java Thu Mar 15 08:14:41 2007
@@ -25,6 +25,7 @@
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashSet;
+import java.util.List;
 
 import org.apache.directory.ldapstudio.schemas.model.AttributeType;
 import org.apache.directory.ldapstudio.schemas.model.MatchingRule;
@@ -595,8 +596,7 @@
     private void initSupCombo()
     {
         SchemaPool pool = SchemaPool.getInstance();
-        ArrayList<AttributeType> atList = new ArrayList<AttributeType>( pool.getAttributeTypesAsHashTableByName()
-            .values() );
+        List<AttributeType> atList = pool.getAttributeTypes();
 
         // Remove duplicate entries
         HashSet<AttributeType> set = new HashSet<AttributeType>( atList );

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeFormEditorUsedByPage.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeFormEditorUsedByPage.java?view=diff&rev=518658&r1=518657&r2=518658
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeFormEditorUsedByPage.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeFormEditorUsedByPage.java Thu Mar 15 08:14:41 2007
@@ -255,14 +255,15 @@
     {
         List<String> ocList = new ArrayList<String>();
 
-        ObjectClass[] objectClasses = schemaPool.getObjectClassesAsArray();
-        for ( int i = 0; i < objectClasses.length; i++ )
+        List<ObjectClass> objectClasses = schemaPool.getObjectClasses();
+        for ( int i = 0; i < objectClasses.size(); i++ )
         {
-            ObjectClass oc = objectClasses[i];
+            ObjectClass oc = objectClasses.get( i );
 
             String[] musts = oc.getMust();
             for ( int j = 0; j < musts.length; j++ )
             {
+                // TODO Match all aliases
                 if ( modifiedAttributeType.getNames()[0].equals( musts[j] ) )
                 {
                     ocList.add( oc.getNames()[0] );
@@ -299,10 +300,10 @@
     {
         List<String> ocList = new ArrayList<String>();
 
-        ObjectClass[] objectClasses = schemaPool.getObjectClassesAsArray();
-        for ( int i = 0; i < objectClasses.length; i++ )
+        List<ObjectClass> objectClasses = schemaPool.getObjectClasses();
+        for ( int i = 0; i < objectClasses.size(); i++ )
         {
-            ObjectClass oc = objectClasses[i];
+            ObjectClass oc = objectClasses.get( i );
 
             String[] mays = oc.getMay();
             for ( int j = 0; j < mays.length; j++ )

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeSelectionDialogContentProvider.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeSelectionDialogContentProvider.java?view=diff&rev=518658&r1=518657&r2=518658
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeSelectionDialogContentProvider.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeSelectionDialogContentProvider.java Thu Mar 15 08:14:41 2007
@@ -24,6 +24,7 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
+import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -57,8 +58,7 @@
 
             SchemaPool schemaPool = SchemaPool.getInstance();
 
-            ArrayList<AttributeType> atList = new ArrayList<AttributeType>( schemaPool
-                .getAttributeTypesAsHashTableByName().values() );
+            List<AttributeType> atList = schemaPool.getAttributeTypes();
 
             // Sorting the list
             Collections.sort( atList, new Comparator<AttributeType>()

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditor.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditor.java?view=diff&rev=518658&r1=518657&r2=518658
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditor.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditor.java Thu Mar 15 08:14:41 2007
@@ -112,8 +112,14 @@
         originalObjectClass = ( ( ObjectClassFormEditorInput ) getEditorInput() ).getObjectClass();
         originalObjectClass.setEditor( this );
 
-        modifiedObjectClass = new ObjectClass( originalObjectClass.getLiteral(), originalObjectClass
-            .getOriginatingSchema() );
+        try
+        {
+            modifiedObjectClass = ( ObjectClass ) originalObjectClass.clone();
+        }
+        catch ( CloneNotSupportedException e )
+        {
+            // Will never occurr.
+        }
 
         addPageChangedListener( pageChangedListener );
     }
@@ -163,7 +169,7 @@
             return;
         }
 
-        updateObjectClass( modifiedObjectClass, originalObjectClass );
+        originalObjectClass.update( modifiedObjectClass );
 
         setPartName( getEditorInput().getName() );
         if ( !monitor.isCanceled() )
@@ -236,27 +242,6 @@
     public void setModifiedObjectClass( ObjectClass modifiedObjectClass )
     {
         this.modifiedObjectClass = modifiedObjectClass;
-    }
-
-
-    /**
-     * Updates the values of an object class to another one
-     *
-     * @param oc1
-     *      the object class literal to clone from
-     * @param oc2
-     *      the object class literal to clone to
-     */
-    private void updateObjectClass( ObjectClass oc1, ObjectClass oc2 )
-    {
-        oc2.setClassType( oc1.getClassType() );
-        oc2.setDescription( oc1.getDescription() );
-        oc2.setMay( oc1.getMay() );
-        oc2.setMust( oc1.getMust() );
-        oc2.setNames( oc1.getNames() );
-        oc2.setObsolete( oc1.isObsolete() );
-        oc2.setOid( oc2.getOid() );
-        oc2.setSuperiors( oc1.getSuperiors() );
     }
 
 

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditorOverviewPage.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditorOverviewPage.java?view=diff&rev=518658&r1=518657&r2=518658
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditorOverviewPage.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditorOverviewPage.java Thu Mar 15 08:14:41 2007
@@ -26,6 +26,7 @@
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashSet;
+import java.util.List;
 
 import org.apache.directory.ldapstudio.schemas.Activator;
 import org.apache.directory.ldapstudio.schemas.PluginConstants;
@@ -789,7 +790,7 @@
     private void initSupCombo()
     {
         SchemaPool pool = SchemaPool.getInstance();
-        ArrayList<ObjectClass> ocList = new ArrayList<ObjectClass>( pool.getObjectClassesAsHashTableByName().values() );
+        List<ObjectClass> ocList =  pool.getObjectClasses();
 
         //remove duplicate entries
         HashSet<ObjectClass> set = new HashSet<ObjectClass>( ocList );

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditorSourceCodePage.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditorSourceCodePage.java?view=diff&rev=518658&r1=518657&r2=518658
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditorSourceCodePage.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditorSourceCodePage.java Thu Mar 15 08:14:41 2007
@@ -94,6 +94,7 @@
             }
             catch ( ParseException exception )
             {
+                exception.printStackTrace();
                 canLeaveThePage = false;
             }
         }

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyView.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyView.java?view=diff&rev=518658&r1=518657&r2=518658
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyView.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyView.java Thu Mar 15 08:14:41 2007
@@ -26,7 +26,8 @@
 import org.apache.directory.ldapstudio.schemas.model.LDAPModelEvent;
 import org.apache.directory.ldapstudio.schemas.model.PoolListener;
 import org.apache.directory.ldapstudio.schemas.model.SchemaPool;
-import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.DisplayableTreeElement;
+import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.ITreeNode;
+import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.SchemasViewRoot;
 import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Composite;
@@ -92,6 +93,26 @@
         viewer.getControl().setFocus();
     }
 
+    
+    /**
+     * Refreshes completely the view (reload model and re-display).
+     * 
+     * @see refresh() for refreshing only the display.
+     */
+    public void completeRefresh()
+    {
+        Object[] exp = viewer.getExpandedElements();
+
+        // Refresh the tree viewer
+        viewer.setInput( new SchemasViewRoot() );
+
+        // Expand all the previsouly expanded elements
+        for ( Object object : exp )
+        {
+            viewer.setExpandedState( object, true );
+        }
+    }
+    
 
     /**
      * Refresh the viewer
@@ -128,9 +149,9 @@
      * @return
      *      the element if it has been found, null if has not been found
      */
-    public DisplayableTreeElement findElementInTree( DisplayableTreeElement element )
+    public ITreeNode findElementInTree( ITreeNode element )
     {
-        DisplayableTreeElement input = ( DisplayableTreeElement ) getViewer().getInput();
+        ITreeNode input = ( ITreeNode ) getViewer().getInput();
 
         return findElementInTree( element, input );
     }
@@ -145,7 +166,7 @@
      *      the current element
      * @return
      */
-    private DisplayableTreeElement findElementInTree( DisplayableTreeElement element, DisplayableTreeElement current )
+    private ITreeNode findElementInTree( ITreeNode element, ITreeNode current )
     {
         if ( element.equals( current ) )
         {
@@ -157,8 +178,8 @@
 
             for ( int i = 0; i < children.length; i++ )
             {
-                DisplayableTreeElement item = ( DisplayableTreeElement ) children[i];
-                DisplayableTreeElement foundElement = findElementInTree( element, item );
+                ITreeNode item = ( ITreeNode ) children[i];
+                ITreeNode foundElement = findElementInTree( element, item );
                 if ( foundElement != null )
                 {
                     return foundElement;

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyViewContentProvider.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyViewContentProvider.java?view=diff&rev=518658&r1=518657&r2=518658
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyViewContentProvider.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyViewContentProvider.java Thu Mar 15 08:14:41 2007
@@ -33,8 +33,8 @@
 import org.apache.directory.ldapstudio.schemas.model.ObjectClass;
 import org.apache.directory.ldapstudio.schemas.model.SchemaPool;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.AttributeTypeWrapper;
-import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.DisplayableTreeElement;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.FirstNameSorter;
+import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.ITreeNode;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.IntermediateNode;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.ObjectClassWrapper;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.OidSorter;
@@ -61,10 +61,10 @@
     IPreferenceStore store;
 
     /** The HashTable containing all the object classes */
-    private ObjectClass[] objectClasses;
+    private List<ObjectClass> objectClasses;
 
     /** The HashTable containing all the attribute types */
-    private AttributeType[] attributeTypes;
+    private List<AttributeType> attributeTypes;
 
     /** The FirstName Sorter */
     private FirstNameSorter firstNameSorter;
@@ -84,8 +84,8 @@
         this.schemaPool = SchemaPool.getInstance();
         store = Activator.getDefault().getPreferenceStore();
 
-        objectClasses = schemaPool.getObjectClassesAsArray();
-        attributeTypes = schemaPool.getAttributeTypesAsArray();
+        objectClasses = schemaPool.getObjectClasses();
+        attributeTypes = schemaPool.getAttributeTypes();
 
         firstNameSorter = new FirstNameSorter();
         oidSorter = new OidSorter();
@@ -106,7 +106,7 @@
      */
     public Object[] getChildren( Object parentElement )
     {
-        List<DisplayableTreeElement> children = new ArrayList<DisplayableTreeElement>();
+        List<ITreeNode> children = new ArrayList<ITreeNode>();
 
         int group = store.getInt( PluginConstants.PREFS_HIERARCHY_VIEW_GROUPING );
         int sortBy = store.getInt( PluginConstants.PREFS_HIERARCHY_VIEW_SORTING_BY );
@@ -117,10 +117,8 @@
             //we are looking for the childrens of the contained objectClass
             ObjectClass objectClass = ( ( ObjectClassWrapper ) parentElement ).getMyObjectClass();
 
-            for ( int i = 0; i < objectClasses.length; i++ )
+            for ( ObjectClass oClass : objectClasses )
             {
-                ObjectClass oClass = objectClasses[i];
-
                 //not this object class
                 if ( oClass.getOid() != objectClass.getOid() )
                 {
@@ -135,7 +133,7 @@
                             {
                                 //we use an objectClass wrapper
                                 children
-                                    .add( new ObjectClassWrapper( oClass, ( DisplayableTreeElement ) parentElement ) );
+                                    .add( new ObjectClassWrapper( oClass, ( ITreeNode ) parentElement ) );
                                 break; //break only the inner for
                             }
                         }
@@ -164,10 +162,8 @@
             //we are looking for the childrens of the contained attribute type
             AttributeType attributeType = ( ( AttributeTypeWrapper ) parentElement ).getMyAttributeType();
 
-            for ( int i = 0; i < attributeTypes.length; i++ )
+            for (AttributeType aType : attributeTypes)
             {
-                AttributeType aType = attributeTypes[i];
-
                 //not this attribute type
                 if ( aType.getOid() != attributeType.getOid() )
                 {
@@ -182,7 +178,7 @@
                             {
                                 //we use an objectClass wrapper
                                 children
-                                    .add( new AttributeTypeWrapper( aType, ( DisplayableTreeElement ) parentElement ) );
+                                    .add( new AttributeTypeWrapper( aType, ( ITreeNode ) parentElement ) );
                                 break; //break only the inner for
                             }
                         }
@@ -212,15 +208,12 @@
 
             if ( intermediate.getName().equals( "**Primary Node**" ) ) //$NON-NLS-1$
             {
-                refreshOcsAndAts();
-
                 List<ObjectClassWrapper> ocList = new ArrayList<ObjectClassWrapper>();
                 if ( !Activator.getDefault().getDialogSettings().getBoolean(
                     HideObjectClassesAction.HIDE_OBJECT_CLASSES_DS_KEY ) )
                 {
-                    for ( int i = 0; i < objectClasses.length; i++ )
+                    for (ObjectClass oClass : objectClasses)
                     {
-                        ObjectClass oClass = objectClasses[i];
                         String[] sups = oClass.getSuperiors();
                         //if no supperiors had been set
                         if ( sups.length == 0 )
@@ -254,9 +247,8 @@
                     HideAttributeTypesAction.HIDE_ATTRIBUTE_TYPES_DS_KEY ) )
                 {
 
-                    for ( int i = 0; i < attributeTypes.length; i++ )
+                    for (AttributeType aType : attributeTypes )
                     {
-                        AttributeType aType = attributeTypes[i];
                         String sup = aType.getSuperior();
                         //if no superior had been set
                         if ( sup == null )
@@ -387,16 +379,6 @@
         }
 
         return false;
-    }
-
-
-    /**
-     * Refreshes the object classes and attribute types HahshTables.
-     */
-    private void refreshOcsAndAts()
-    {
-        objectClasses = schemaPool.getObjectClassesAsArray();
-        attributeTypes = schemaPool.getAttributeTypesAsArray();
     }
 
 

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyViewLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyViewLabelProvider.java?view=diff&rev=518658&r1=518657&r2=518658
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyViewLabelProvider.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyViewLabelProvider.java Thu Mar 15 08:14:41 2007
@@ -24,7 +24,7 @@
 import org.apache.directory.ldapstudio.schemas.Activator;
 import org.apache.directory.ldapstudio.schemas.PluginConstants;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.AttributeTypeWrapper;
-import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.DisplayableTreeElement;
+import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.ITreeNode;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.ObjectClassWrapper;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.viewers.LabelProvider;
@@ -198,8 +198,8 @@
      */
     public Image getImage( Object obj )
     {
-        if ( obj instanceof DisplayableTreeElement )
-            return ( ( DisplayableTreeElement ) obj ).getDisplayImage();
+        if ( obj instanceof ITreeNode )
+            return ( ( ITreeNode ) obj ).getImage();
 
         // Default
         return PlatformUI.getWorkbench().getSharedImages().getImage( ISharedImages.IMG_OBJS_WARN_TSK );

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemasView.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemasView.java?view=diff&rev=518658&r1=518657&r2=518658
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemasView.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemasView.java Thu Mar 15 08:14:41 2007
@@ -23,13 +23,13 @@
 
 import org.apache.directory.ldapstudio.schemas.Activator;
 import org.apache.directory.ldapstudio.schemas.controller.SchemasViewController;
-import org.apache.directory.ldapstudio.schemas.model.LDAPModelEvent;
-import org.apache.directory.ldapstudio.schemas.model.PoolListener;
 import org.apache.directory.ldapstudio.schemas.model.Schema;
 import org.apache.directory.ldapstudio.schemas.model.SchemaPool;
-import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.DisplayableTreeElement;
+import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.ITreeNode;
+import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.SchemasViewRoot;
 import org.apache.log4j.Logger;
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.viewers.DecoratingLabelProvider;
 import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Composite;
@@ -43,13 +43,18 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class SchemasView extends ViewPart implements PoolListener, ISaveablePart2
+public class SchemasView extends ViewPart implements ISaveablePart2
 {
+    /** The ID of the View */
     public static final String ID = Activator.PLUGIN_ID + ".view.SchemasView"; //$NON-NLS-1$
 
+    /** The logger*/
     private static Logger logger = Logger.getLogger( SchemasView.class );
+
+    /** The viewer */
     private TreeViewer viewer;
-    private Composite parent;
+
+    /** The content provider of the viewer */
     private SchemasViewContentProvider contentProvider;
 
 
@@ -58,16 +63,11 @@
      */
     public void createPartControl( Composite parent )
     {
-        this.parent = parent;
-        initViewer();
+        initViewer( parent );
 
         // Registering the Viewer, so other views can be notified when the viewer selection changes
         getSite().setSelectionProvider( viewer );
 
-        SchemaPool pool = SchemaPool.getInstance();
-        //we want to be notified if the pool has been modified
-        pool.addListener( this );
-
         // Adding the controller
         new SchemasViewController( this );
     }
@@ -76,11 +76,14 @@
     /**
      * Initializes the Viewer
      */
-    private void initViewer()
+    private void initViewer( Composite parent )
     {
         viewer = new TreeViewer( parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER );
-        contentProvider = new SchemasViewContentProvider();
-        contentProvider.bindToTreeViewer( viewer );
+        contentProvider = new SchemasViewContentProvider( viewer );
+        viewer.setContentProvider( contentProvider );
+        viewer.setLabelProvider( new DecoratingLabelProvider( new SchemasViewLabelProvider(), Activator.getDefault()
+            .getWorkbench().getDecoratorManager().getLabelDecorator() ) );
+        viewer.setInput( new SchemasViewRoot() );
     }
 
 
@@ -94,14 +97,16 @@
 
 
     /**
-     * Refresh the viewer
+     * Refreshes completely the view (reload model and re-display).
+     * 
+     * @see refresh() for refreshing only the display.
      */
-    public void refresh()
+    public void completeRefresh()
     {
         Object[] exp = viewer.getExpandedElements();
 
         // Refresh the tree viewer
-        viewer.refresh();
+        viewer.setInput( new SchemasViewRoot() );
 
         // Expand all the previsouly expanded elements
         for ( Object object : exp )
@@ -112,11 +117,13 @@
 
 
     /**
-     * We refresh the view only if the pool has been modified
+     * Refreshes the view (re-display only).
+     * 
+     * @see completeRefresh() for a complete refresh.
      */
-    public void poolChanged( SchemaPool p, LDAPModelEvent e )
+    public void refresh()
     {
-        refresh();
+        viewer.refresh();
     }
 
 
@@ -215,9 +222,14 @@
      * @return
      *      the element if it has been found, null if has not been found
      */
-    public DisplayableTreeElement findElementInTree( DisplayableTreeElement element )
+    public ITreeNode findElementInTree( ITreeNode element )
     {
-        DisplayableTreeElement input = ( DisplayableTreeElement ) getViewer().getInput();
+        if ( element == null )
+        {
+            return null;
+        }
+
+        ITreeNode input = ( ITreeNode ) getViewer().getInput();
 
         return findElementInTree( element, input );
     }
@@ -228,24 +240,24 @@
      *
      * @param element
      *      the element to find
-     * @param current
+     * @param node
      *      the current element
      * @return
      */
-    private DisplayableTreeElement findElementInTree( DisplayableTreeElement element, DisplayableTreeElement current )
+    public ITreeNode findElementInTree( ITreeNode element, ITreeNode node )
     {
-        if ( element.equals( current ) )
+        if ( element.equals( node ) )
         {
-            return current;
+            return node;
         }
         else
         {
-            Object[] children = contentProvider.getChildren( current );
+            Object[] children = contentProvider.getChildren( node );
 
             for ( int i = 0; i < children.length; i++ )
             {
-                DisplayableTreeElement item = ( DisplayableTreeElement ) children[i];
-                DisplayableTreeElement foundElement = findElementInTree( element, item );
+                ITreeNode item = ( ITreeNode ) children[i];
+                ITreeNode foundElement = findElementInTree( element, item );
                 if ( foundElement != null )
                 {
                     return foundElement;

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemasViewContentProvider.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemasViewContentProvider.java?view=diff&rev=518658&r1=518657&r2=518658
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemasViewContentProvider.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemasViewContentProvider.java Thu Mar 15 08:14:41 2007
@@ -21,29 +21,33 @@
 package org.apache.directory.ldapstudio.schemas.view.viewers;
 
 
-import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
 
 import org.apache.directory.ldapstudio.schemas.Activator;
 import org.apache.directory.ldapstudio.schemas.PluginConstants;
 import org.apache.directory.ldapstudio.schemas.model.AttributeType;
+import org.apache.directory.ldapstudio.schemas.model.LDAPModelEvent;
 import org.apache.directory.ldapstudio.schemas.model.ObjectClass;
+import org.apache.directory.ldapstudio.schemas.model.PoolListener;
 import org.apache.directory.ldapstudio.schemas.model.Schema;
+import org.apache.directory.ldapstudio.schemas.model.SchemaElement;
 import org.apache.directory.ldapstudio.schemas.model.SchemaPool;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.AttributeTypeWrapper;
-import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.DisplayableTreeElement;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.FirstNameSorter;
+import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.ITreeNode;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.IntermediateNode;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.ObjectClassWrapper;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.OidSorter;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.SchemaSorter;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.SchemaWrapper;
+import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.SchemasViewRoot;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.IntermediateNode.IntermediateNodeType;
 import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.viewers.DecoratingLabelProvider;
 import org.eclipse.jface.viewers.IStructuredContentProvider;
 import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.jface.viewers.Viewer;
 
@@ -54,13 +58,16 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class SchemasViewContentProvider implements IStructuredContentProvider, ITreeContentProvider
+public class SchemasViewContentProvider implements IStructuredContentProvider, ITreeContentProvider, PoolListener
 {
     /** The Schema Pool */
     private SchemaPool schemaPool;
 
+    /** The associated viewer */
+    private TreeViewer viewer;
+
     /** The preferences store */
-    IPreferenceStore store;
+    private IPreferenceStore store;
 
     /** The FirstName Sorter */
     private FirstNameSorter firstNameSorter;
@@ -75,14 +82,17 @@
     /**
      * Default constructor
      */
-    public SchemasViewContentProvider()
+    public SchemasViewContentProvider( TreeViewer viewer )
     {
+        this.viewer = viewer;
         schemaPool = SchemaPool.getInstance();
         store = Activator.getDefault().getPreferenceStore();
 
         firstNameSorter = new FirstNameSorter();
         oidSorter = new OidSorter();
         schemaSorter = new SchemaSorter();
+
+        SchemaPool.getInstance().addListener( this );
     }
 
 
@@ -100,106 +110,113 @@
      */
     public Object[] getChildren( Object parentElement )
     {
-        List<DisplayableTreeElement> children = new ArrayList<DisplayableTreeElement>();
-
         int group = store.getInt( PluginConstants.PREFS_SCHEMAS_VIEW_GROUPING );
         int sortBy = store.getInt( PluginConstants.PREFS_SCHEMAS_VIEW_SORTING_BY );
         int sortOrder = store.getInt( PluginConstants.PREFS_SCHEMAS_VIEW_SORTING_ORDER );
+        List<ITreeNode> children = null;
 
-        if ( parentElement instanceof IntermediateNode )
+        if ( parentElement instanceof SchemasViewRoot )
         {
-            IntermediateNode intermediate = ( IntermediateNode ) parentElement;
-            if ( intermediate.getName().equals( "**Primary Node**" ) ) //$NON-NLS-1$
+            SchemasViewRoot root = ( SchemasViewRoot ) parentElement;
+
+            if ( root.getChildren().isEmpty() )
             {
                 Schema[] schemas = this.schemaPool.getSchemas();
                 for ( int i = 0; i < schemas.length; i++ )
                 {
-                    children.add( new SchemaWrapper( schemas[i], ( IntermediateNode ) parentElement ) );
+                    root.addChild( new SchemaWrapper( schemas[i], root ) );
                 }
-
-                Collections.sort( children, schemaSorter );
             }
-            else if ( intermediate.getType().equals( IntermediateNodeType.ATTRIBUTE_TYPE_FOLDER ) )
-            {
-                Schema schema = ( ( SchemaWrapper ) intermediate.getParent() ).getMySchema();
 
-                AttributeType[] attributeTypeList = schema.getAttributeTypesAsArray();
-                for ( int i = 0; i < attributeTypeList.length; i++ )
-                {
-                    children.add( new AttributeTypeWrapper( attributeTypeList[i], intermediate ) );
-                }
+            children = root.getChildren();
 
-                // Sort by
-                if ( sortBy == PluginConstants.PREFS_SCHEMAS_VIEW_SORTING_BY_FIRSTNAME )
+            Collections.sort( children, schemaSorter );
+        }
+        if ( parentElement instanceof IntermediateNode )
+        {
+            IntermediateNode intermediate = ( IntermediateNode ) parentElement;
+
+            if ( intermediate.getChildren().isEmpty() )
+            {
+                if ( intermediate.getType().equals( IntermediateNodeType.ATTRIBUTE_TYPE_FOLDER ) )
                 {
-                    Collections.sort( children, firstNameSorter );
+                    Schema schema = ( ( SchemaWrapper ) intermediate.getParent() ).getMySchema();
+
+                    AttributeType[] attributeTypeList = schema.getAttributeTypesAsArray();
+                    for ( int i = 0; i < attributeTypeList.length; i++ )
+                    {
+                        intermediate.addChild( new AttributeTypeWrapper( attributeTypeList[i], intermediate ) );
+                    }
                 }
-                else if ( sortBy == PluginConstants.PREFS_SCHEMAS_VIEW_SORTING_BY_OID )
+                else if ( intermediate.getType().equals( IntermediateNodeType.OBJECT_CLASS_FOLDER ) )
                 {
-                    Collections.sort( children, oidSorter );
-                }
+                    Schema schema = ( ( SchemaWrapper ) intermediate.getParent() ).getMySchema();
 
-                // Sort order
-                if ( sortOrder == PluginConstants.PREFS_SCHEMAS_VIEW_SORTING_ORDER_DESCENDING )
-                {
-                    Collections.reverse( children );
+                    ObjectClass[] objectClassList = schema.getObjectClassesAsArray();
+                    for ( int i = 0; i < objectClassList.length; i++ )
+                    {
+                        intermediate.addChild( new ObjectClassWrapper( objectClassList[i], intermediate ) );
+                    }
                 }
             }
-            else if ( intermediate.getType().equals( IntermediateNodeType.OBJECT_CLASS_FOLDER ) )
-            {
-                Schema schema = ( ( SchemaWrapper ) intermediate.getParent() ).getMySchema();
 
-                ObjectClass[] objectClassList = schema.getObjectClassesAsArray();
-                for ( int i = 0; i < objectClassList.length; i++ )
-                {
-                    children.add( new ObjectClassWrapper( objectClassList[i], 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 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 );
-                }
+            // 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 )
             {
-                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$
+                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.add( attributeTypes );
-                children.add( objectClasses );
+                children = schemaWrapper.getChildren();
             }
             else if ( group == PluginConstants.PREFS_SCHEMAS_VIEW_GROUPING_MIXED )
             {
-                Schema schema = ( ( SchemaWrapper ) parentElement ).getMySchema();
-
-                AttributeType[] attributeTypeList = schema.getAttributeTypesAsArray();
-                for ( int i = 0; i < attributeTypeList.length; i++ )
+                if ( schemaWrapper.getChildren().isEmpty() )
                 {
-                    children.add( new AttributeTypeWrapper( attributeTypeList[i], ( SchemaWrapper ) parentElement ) );
-                }
+                    Schema schema = schemaWrapper.getMySchema();
 
-                ObjectClass[] objectClassList = schema.getObjectClassesAsArray();
-                for ( int i = 0; i < objectClassList.length; i++ )
-                {
-                    children.add( new ObjectClassWrapper( objectClassList[i], ( SchemaWrapper ) parentElement ) );
+                    AttributeType[] attributeTypeList = schema.getAttributeTypesAsArray();
+                    for ( int i = 0; i < attributeTypeList.length; i++ )
+                    {
+                        schemaWrapper.addChild( new AttributeTypeWrapper( attributeTypeList[i], schemaWrapper ) );
+                    }
+
+                    ObjectClass[] objectClassList = schema.getObjectClassesAsArray();
+                    for ( int i = 0; i < objectClassList.length; i++ )
+                    {
+                        schemaWrapper.addChild( new ObjectClassWrapper( objectClassList[i], schemaWrapper ) );
+                    }
                 }
 
+                children = schemaWrapper.getChildren();
+
                 // Sort by
                 if ( sortBy == PluginConstants.PREFS_SCHEMAS_VIEW_SORTING_BY_FIRSTNAME )
                 {
@@ -218,7 +235,14 @@
             }
         }
 
-        return children.toArray();
+        if ( children == null )
+        {
+            return new Object[0];
+        }
+        else
+        {
+            return children.toArray();
+        }
     }
 
 
@@ -227,11 +251,12 @@
      */
     public Object getParent( Object element )
     {
-        if ( element instanceof DisplayableTreeElement )
+        if ( element instanceof ITreeNode )
         {
-            return ( ( DisplayableTreeElement ) element ).getParent();
+            return ( ( ITreeNode ) element ).getParent();
         }
 
+        // Default
         return null;
     }
 
@@ -241,28 +266,312 @@
      */
     public boolean hasChildren( Object element )
     {
-        if ( element instanceof DisplayableTreeElement )
+        if ( element instanceof SchemaWrapper )
+        {
+            return true;
+        }
+        else if ( element instanceof IntermediateNode )
         {
-            return getChildren( element ).length > 0;
+            return true;
         }
 
+        // Default
         return false;
     }
 
 
+    /* (non-Javadoc)
+     * @see org.apache.directory.ldapstudio.schemas.model.PoolListener#poolChanged(org.apache.directory.ldapstudio.schemas.model.SchemaPool, org.apache.directory.ldapstudio.schemas.model.LDAPModelEvent)
+     */
+    public void poolChanged( SchemaPool p, LDAPModelEvent e )
+    {
+        switch ( e.getReason() )
+        {
+            case SchemaAdded:
+                schemaAdded( p, e );
+                break;
+
+            case SchemaRemoved:
+                schemaRemoved( p, e );
+                break;
+
+            case ATAdded:
+            case OCAdded:
+                aTOrOCAdded( p, e );
+                break;
+
+            case ATModified:
+            case OCModified:
+                aTOrOCModified( p, e );
+                break;
+
+            case ATRemoved:
+            case OCRemoved:
+                aTOrOCRemoved( p, e );
+                break;
+
+            default:
+                break;
+        }
+    }
+
+
+    /**
+     * Refreshes the viewer when a SchemaAdded event is fired.
+     *
+     * @param p
+     *      the schema pool
+     * @param e
+     *      the event
+     */
+    private void schemaAdded( SchemaPool p, LDAPModelEvent e )
+    {
+        ITreeNode rootNode = ( ITreeNode ) viewer.getInput();
+        SchemaWrapper schemaWrapper = new SchemaWrapper( ( Schema ) e.getNewValue(), rootNode );
+        rootNode.addChild( schemaWrapper );
+
+        Collections.sort( rootNode.getChildren(), new SchemaSorter() );
+
+        viewer.refresh( rootNode );
+        viewer.setSelection( new StructuredSelection( schemaWrapper ) );
+    }
+
+
     /**
-     * Initialize a tree viewer to display the information provided by the specified content
-     * provider
-     * @param viewer the tree viewer
-     */
-    public void bindToTreeViewer( TreeViewer viewer )
-    {
-        viewer.setContentProvider( this );
-        viewer.setLabelProvider( new DecoratingLabelProvider( new SchemasViewLabelProvider(), Activator.getDefault()
-            .getWorkbench().getDecoratorManager().getLabelDecorator() ) );
+     * Refreshes the viewer when a SchemaRemoved event is fired.
+     *
+     * @param p
+     *      the schema pool
+     * @param e
+     *      the event
+     */
+    private void schemaRemoved( SchemaPool p, LDAPModelEvent e )
+    {
+        ITreeNode rootNode = ( ITreeNode ) viewer.getInput();
+
+        List<ITreeNode> schemaWrapperList = rootNode.getChildren();
+        for ( Iterator iter = schemaWrapperList.iterator(); iter.hasNext(); )
+        {
+            SchemaWrapper schemaWrapper = ( SchemaWrapper ) iter.next();
+            if ( schemaWrapper.getMySchema().equals( ( Schema ) e.getNewValue() ) )
+            {
+                rootNode.removeChild( schemaWrapper );
+                viewer.refresh( rootNode );
+                break;
+            }
+        }
+    }
+
+
+    /**
+     * Refreshes the viewer when a ATAdded or OCAdded event is fired.
+     *
+     * @param p
+     *      the schema pool
+     * @param e
+     *      the event
+     */
+    private void aTOrOCAdded( SchemaPool p, LDAPModelEvent e )
+    {
+        SchemaElement element = ( SchemaElement ) e.getNewValue();
+
+        ITreeNode parentNode = findParentElement( element );
+        if ( parentNode == null )
+        {
+            return;
+        }
+
+        // Forcing the load of the children
+        getChildren( parentNode );
+        
+        // Creating and adding the new element
+        ITreeNode newElement = null;
+        if ( element instanceof AttributeType )
+        {
+            newElement = new AttributeTypeWrapper( ( AttributeType ) element, parentNode );
+        }
+        else if ( element instanceof ObjectClass )
+        {
+            newElement = new ObjectClassWrapper( ( ObjectClass ) element, parentNode );
+        }
+        parentNode.addChild( newElement );
+
+        // Refreshing the UI and selecting the newly created element
+        viewer.refresh( parentNode );
+        viewer.setSelection( new StructuredSelection( newElement ) );
+    }
+
+
+    /**
+     * Refreshes the viewer when a ATModified or OCModified event is fired.
+     *
+     * @param p
+     *      the schema pool
+     * @param e
+     *      the event
+     */
+    private void aTOrOCModified( SchemaPool p, LDAPModelEvent e )
+    {
+        SchemaElement element = ( SchemaElement ) e.getNewValue();
+
+        ITreeNode parentNode = findParentElement( element );
+        if ( parentNode == null )
+        {
+            return;
+        }
+
+        ITreeNode fakeNode = null;
+        if ( element instanceof ObjectClass )
+        {
+            fakeNode = new ObjectClassWrapper( ( ObjectClass ) element, null );
+        }
+        else if ( element instanceof AttributeType )
+        {
+            fakeNode = new AttributeTypeWrapper( ( AttributeType ) element, null );
+        }
+
+        ITreeNode realNode = null;
+        Object[] children = getChildren( parentNode );
+        for ( int i = 0; i < children.length; i++ )
+        {
+            if ( children[i].equals( fakeNode ) )
+            {
+                realNode = ( ITreeNode ) children[i];
+                break;
+            }
+        }
+
+        if ( realNode != null )
+        {
+            viewer.update( realNode, null );
+        }
+    }
+
+
+    /**
+     * Refreshes the viewer when a ATRemoved or OCRemoved event is fired.
+     *
+     * @param p
+     *      the schema pool
+     * @param e
+     *      the event
+     */
+    private void aTOrOCRemoved( SchemaPool p, LDAPModelEvent e )
+    {
+        SchemaElement element = ( SchemaElement ) e.getOldValue();
+
+        ITreeNode parentNode = findParentElement( element );
+        if ( parentNode == null )
+        {
+            return;
+        }
+
+        ITreeNode fakeNode = null;
+        if ( element instanceof ObjectClass )
+        {
+            ( ( ObjectClass ) element ).closeAssociatedEditor();
+            fakeNode = new ObjectClassWrapper( ( ObjectClass ) element, null );
+        }
+        else if ( element instanceof AttributeType )
+        {
+            ( ( AttributeType ) element ).closeAssociatedEditor();
+            fakeNode = new AttributeTypeWrapper( ( AttributeType ) element, null );
+        }
+
+        ITreeNode realNode = null;
+        Object[] children = getChildren( parentNode );
+        for ( int i = 0; i < children.length; i++ )
+        {
+            if ( children[i].equals( fakeNode ) )
+            {
+                realNode = ( ITreeNode ) children[i];
+                break;
+            }
+        }
+
+        if ( realNode != null )
+        {
+            realNode.getParent().removeChild( realNode );
+            viewer.refresh( realNode.getParent() );
+        }
+    }
+
+
+    /**
+     * Finds the corresponding Schema Wrapper in the Tree.
+     *
+     * @param schemaWrapper
+     *      the Schema Wrapper to search
+     * @return
+     *      the corresponding Schema Wrapper in the Tree
+     */
+    private ITreeNode findSchemaWrapperInTree( SchemaWrapper schemaWrapper )
+    {
+        Object[] schemaWrappers = getChildren( ( ITreeNode ) viewer.getInput() );
+        for ( int i = 0; i < schemaWrappers.length; i++ )
+        {
+            SchemaWrapper sw = ( SchemaWrapper ) schemaWrappers[i];
+            if ( sw.equals( schemaWrapper ) )
+            {
+                return sw;
+            }
+        }
+
+        return null;
+    }
+
+
+    /**
+     * Finds the parent node of a given element (AT or OT).
+     *
+     * @param element
+     *      the element
+     * @return
+     *      the parent node of a given element (AT or OT)
+     */
+    private ITreeNode findParentElement( SchemaElement element )
+    {
+        int group = Activator.getDefault().getPreferenceStore().getInt( PluginConstants.PREFS_SCHEMAS_VIEW_GROUPING );
+
+        // Finding the associated SchemaWrapper
+        SchemaWrapper fakeSchemaWrapper = new SchemaWrapper( element.getOriginatingSchema(), null );
+        ITreeNode realSchemaWrapper = findSchemaWrapperInTree( fakeSchemaWrapper );
+        if ( realSchemaWrapper == null )
+        {
+            return null;
+        }
+
+        // Finding the correct node
+        ITreeNode parentNode = null;
+        if ( group == PluginConstants.PREFS_SCHEMAS_VIEW_GROUPING_FOLDERS )
+        {
+            Object[] children = getChildren( realSchemaWrapper );
+            for ( int i = 0; i < children.length; i++ )
+            {
+                IntermediateNode intermediateNode = ( IntermediateNode ) children[i];
+
+                if ( element instanceof AttributeType )
+                {
+                    if ( intermediateNode.getType() == IntermediateNodeType.ATTRIBUTE_TYPE_FOLDER )
+                    {
+                        parentNode = intermediateNode;
+                    }
+                }
+                else if ( element instanceof ObjectClass )
+                {
+                    if ( intermediateNode.getType() == IntermediateNodeType.OBJECT_CLASS_FOLDER )
+                    {
+                        parentNode = intermediateNode;
+                    }
+                }
+            }
+        }
+        else if ( group == PluginConstants.PREFS_SCHEMAS_VIEW_GROUPING_MIXED )
+        {
+            parentNode = realSchemaWrapper;
+        }
 
-        IntermediateNode invisibleNode = new IntermediateNode( "**Primary Node**", null ); //$NON-NLS-1$
-        viewer.setInput( invisibleNode );
+        return parentNode;
     }
 
 

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemasViewLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemasViewLabelProvider.java?view=diff&rev=518658&r1=518657&r2=518658
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemasViewLabelProvider.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemasViewLabelProvider.java Thu Mar 15 08:14:41 2007
@@ -24,7 +24,7 @@
 import org.apache.directory.ldapstudio.schemas.Activator;
 import org.apache.directory.ldapstudio.schemas.PluginConstants;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.AttributeTypeWrapper;
-import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.DisplayableTreeElement;
+import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.ITreeNode;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.ObjectClassWrapper;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.SchemaWrapper;
 import org.eclipse.jface.preference.IPreferenceStore;
@@ -131,9 +131,9 @@
      */
     public Image getImage( Object obj )
     {
-        if ( obj instanceof DisplayableTreeElement )
+        if ( obj instanceof ITreeNode )
         {
-            return ( ( DisplayableTreeElement ) obj ).getDisplayImage();
+            return ( ( ITreeNode ) obj ).getImage();
         }
 
         // Default

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SearchView.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SearchView.java?view=diff&rev=518658&r1=518657&r2=518658
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SearchView.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SearchView.java Thu Mar 15 08:14:41 2007
@@ -68,6 +68,9 @@
 
 /**
  * This class represents the Search View.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
  */
 public class SearchView extends ViewPart implements PoolListener
 {
@@ -366,7 +369,6 @@
      */
     public void poolChanged( SchemaPool p, LDAPModelEvent e )
     {
-        searchContentProvider.refresh();
         resultsTableViewer.refresh();
     }
 

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SearchViewContentProvider.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SearchViewContentProvider.java?view=diff&rev=518658&r1=518657&r2=518658
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SearchViewContentProvider.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SearchViewContentProvider.java Thu Mar 15 08:14:41 2007
@@ -23,14 +23,13 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.apache.directory.ldapstudio.schemas.model.AttributeType;
-import org.apache.directory.ldapstudio.schemas.model.LDAPModelEvent;
 import org.apache.directory.ldapstudio.schemas.model.ObjectClass;
-import org.apache.directory.ldapstudio.schemas.model.PoolListener;
 import org.apache.directory.ldapstudio.schemas.model.SchemaElement;
 import org.apache.directory.ldapstudio.schemas.model.SchemaPool;
 import org.eclipse.jface.viewers.IStructuredContentProvider;
@@ -39,36 +38,34 @@
 
 
 /**
- * Content provider for the search view
+ * Content provider for the search view.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class SearchViewContentProvider implements IStructuredContentProvider, PoolListener
+public class SearchViewContentProvider implements IStructuredContentProvider/*, PoolListener*/
 {
-    private SchemaPool schemaPool;
-    private Hashtable<String, ObjectClass> objectClassTable;
-    private Hashtable<String, AttributeType> attributeTypeTable;
+    /** The object classes Map */
+    private Map<String, ObjectClass> objectClassTable;
+
+    /** The attribute types Map*/
+    private Map<String, AttributeType> attributeTypeTable;
 
 
     /**
-     * Default constructor
+     * Creates a new instance of SearchViewContentProvider.
      */
     public SearchViewContentProvider()
     {
-        this.schemaPool = SchemaPool.getInstance();
-        schemaPool.addListener( this );
-
-        objectClassTable = schemaPool.getObjectClassesAsHashTableByName();
-
-        attributeTypeTable = schemaPool.getAttributeTypesAsHashTableByName();
+        SchemaPool schemaPool = SchemaPool.getInstance();
+        objectClassTable = schemaPool.getObjectClassesAsMap();
+        attributeTypeTable = schemaPool.getAttributeTypesAsMap();
     }
 
 
-    /**
-     * returns the matched elements as an array of objects
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
      */
-    @SuppressWarnings("unchecked")//$NON-NLS-1$
     public Object[] getElements( Object parent )
     {
         if ( parent instanceof String )
@@ -84,12 +81,12 @@
             {
                 String searchRegexp = searchText + ".*"; //$NON-NLS-1$
                 Pattern pattern = Pattern.compile( searchRegexp, Pattern.CASE_INSENSITIVE );
-                ArrayList resultsList = new ArrayList();
+                List<SchemaElement> resultsList = new ArrayList<SchemaElement>();
 
                 Collection<ObjectClass> OCs = objectClassTable.values();
                 Collection<AttributeType> ATs = attributeTypeTable.values();
 
-                ArrayList<SchemaElement> allList = new ArrayList<SchemaElement>();
+                List<SchemaElement> allList = new ArrayList<SchemaElement>();
                 allList.addAll( OCs );
                 allList.addAll( ATs );
 
@@ -173,28 +170,5 @@
      */
     public void dispose()
     {
-        schemaPool.removeListener( this );
     }
-
-
-    /**
-     * Pool listener method
-     */
-    public void poolChanged( SchemaPool p, LDAPModelEvent e )
-    {
-        refresh();
-    }
-
-
-    /**
-     * Refresh the content of the provider
-     * (you can trigger it manually or it will be called when the pool has changed)
-     */
-    public void refresh()
-    {
-        objectClassTable = schemaPool.getObjectClassesAsHashTableByName();
-
-        attributeTypeTable = schemaPool.getAttributeTypesAsHashTableByName();
-    }
-
 }

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/AttributeTypeWrapper.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/AttributeTypeWrapper.java?view=diff&rev=518658&r1=518657&r2=518658
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/AttributeTypeWrapper.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/AttributeTypeWrapper.java Thu Mar 15 08:14:41 2007
@@ -34,14 +34,17 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class AttributeTypeWrapper implements DisplayableTreeElement
+public class AttributeTypeWrapper extends TreeNode
 {
-    /** The parent element */
-    private DisplayableTreeElement parent;
-
     /** The associated attribute type */
     private AttributeType myAttributeType;
+    private State state;
 
+    
+    public enum State
+    {
+        resolved, unResolved
+    }
 
     /**
      * Creates a new instance of AttributeTypeWrapper.
@@ -51,10 +54,12 @@
      * @param parent
      *      the parent element
      */
-    public AttributeTypeWrapper( AttributeType myAttributeType, DisplayableTreeElement parent )
+    public AttributeTypeWrapper( AttributeType myAttributeType, ITreeNode parent )
     {
+        super( parent );
+
         this.myAttributeType = myAttributeType;
-        this.parent = parent;
+        this.state = State.resolved;
     }
 
 
@@ -70,22 +75,10 @@
     }
 
 
-    /**
-     * Gets the parent element.
-     * 
-     * @return
-     *      the parent element
-     */
-    public DisplayableTreeElement getParent()
-    {
-        return parent;
-    }
-
-
     /* (non-Javadoc)
-     * @see org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.DisplayableTreeElement#getDisplayImage()
+     * @see org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.TreeNode#getImage()
      */
-    public Image getDisplayImage()
+    public Image getImage()
     {
         return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, PluginConstants.IMG_ATTRIBUTE_TYPE )
             .createImage();
@@ -113,5 +106,28 @@
     public String toString()
     {
         return myAttributeType + " wrapper"; //$NON-NLS-1$
+    }
+    
+    /**
+     * Gets the state of the object class wrapper.
+     * 
+     * @return
+     *      the state of the object class wrapper
+     */
+    public State getState()
+    {
+        return state;
+    }
+
+
+    /**
+     * Sets the state of the object class wrapper.
+     * 
+     * @param state
+     *      the state of the object class wrapper
+     */
+    public void setState( State state )
+    {
+        this.state = state;
     }
 }

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/FirstNameSorter.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/FirstNameSorter.java?view=diff&rev=518658&r1=518657&r2=518658
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/FirstNameSorter.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/FirstNameSorter.java Thu Mar 15 08:14:41 2007
@@ -30,12 +30,12 @@
 /**
  * This class is used to compare and sort ascending two DisplayableTreeElement
  */
-public class FirstNameSorter implements Comparator<DisplayableTreeElement>
+public class FirstNameSorter implements Comparator<ITreeNode>
 {
     /* (non-Javadoc)
      * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
      */
-    public int compare( DisplayableTreeElement o1, DisplayableTreeElement o2 )
+    public int compare( ITreeNode o1, ITreeNode o2 )
     {
         if ( ( o1 instanceof AttributeTypeWrapper ) && ( o2 instanceof AttributeTypeWrapper ) )
         {



Mime
View raw message