directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r518704 - in /directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas: controller/ controller/actions/ view/viewers/ view/viewers/wrappers/
Date Thu, 15 Mar 2007 17:44:24 GMT
Author: pamarcelot
Date: Thu Mar 15 10:44:23 2007
New Revision: 518704

URL: http://svn.apache.org/viewvc?view=rev&rev=518704
Log:
Changed the behavior of the Schema Elements View. It now displays all loaded Schema Elements
(AT and OC).

Removed:
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemasElementsSortDialog.java
Modified:
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/SchemaElementsController.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/OpenSchemaElementsViewSortDialogAction.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemaElementsContentProvider.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemaElementsView.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/SchemaElementsViewRoot.java

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/SchemaElementsController.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/SchemaElementsController.java?view=diff&rev=518704&r1=518703&r2=518704
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/SchemaElementsController.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/SchemaElementsController.java
Thu Mar 15 10:44:23 2007
@@ -26,12 +26,11 @@
 
 import org.apache.directory.ldapstudio.schemas.Activator;
 import org.apache.directory.ldapstudio.schemas.PluginConstants;
-import org.apache.directory.ldapstudio.schemas.controller.actions.CollapseAllAction;
 import org.apache.directory.ldapstudio.schemas.controller.actions.HideAttributeTypesAction;
 import org.apache.directory.ldapstudio.schemas.controller.actions.HideObjectClassesAction;
 import org.apache.directory.ldapstudio.schemas.controller.actions.LinkWithEditorSchemaElementsView;
-import org.apache.directory.ldapstudio.schemas.controller.actions.OpencSchemaElementsViewPreferencesAction;
 import org.apache.directory.ldapstudio.schemas.controller.actions.OpenSchemaElementsViewSortDialogAction;
+import org.apache.directory.ldapstudio.schemas.controller.actions.OpencSchemaElementsViewPreferencesAction;
 import org.apache.directory.ldapstudio.schemas.view.editors.AttributeTypeFormEditor;
 import org.apache.directory.ldapstudio.schemas.view.editors.AttributeTypeFormEditorInput;
 import org.apache.directory.ldapstudio.schemas.view.editors.ObjectClassFormEditor;
@@ -76,7 +75,6 @@
     // The Actions
     private HideObjectClassesAction hideObjectClasses;
     private HideAttributeTypesAction hideAttributeTypes;
-    private CollapseAllAction collapseAll;
     private LinkWithEditorSchemaElementsView linkWithEditor;
     private OpenSchemaElementsViewSortDialogAction openSortDialog;
     private OpencSchemaElementsViewPreferencesAction openPreferencePage;
@@ -121,7 +119,6 @@
     {
         hideObjectClasses = new HideObjectClassesAction( view.getViewer() );
         hideAttributeTypes = new HideAttributeTypesAction( view.getViewer() );
-        collapseAll = new CollapseAllAction( view.getViewer() );
         linkWithEditor = new LinkWithEditorSchemaElementsView( view );
         openSortDialog = new OpenSchemaElementsViewSortDialogAction();
         openPreferencePage = new OpencSchemaElementsViewPreferencesAction();
@@ -137,7 +134,6 @@
         toolbar.add( hideObjectClasses );
         toolbar.add( hideAttributeTypes );
         toolbar.add( new Separator() );
-        toolbar.add( collapseAll );
         toolbar.add( linkWithEditor );
     }
 
@@ -231,11 +227,11 @@
                 {
                     if ( PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_GROUPING == event.getProperty()
)
                     {
-                        view.completeRefresh();
+                        view.refresh();
                     }
                     else
                     {
-                        view.refresh();
+                        view.update();
                     }
                 }
             }

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/OpenSchemaElementsViewSortDialogAction.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/OpenSchemaElementsViewSortDialogAction.java?view=diff&rev=518704&r1=518703&r2=518704
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/OpenSchemaElementsViewSortDialogAction.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/OpenSchemaElementsViewSortDialogAction.java
Thu Mar 15 10:44:23 2007
@@ -23,7 +23,7 @@
 
 import org.apache.directory.ldapstudio.schemas.Activator;
 import org.apache.directory.ldapstudio.schemas.PluginConstants;
-import org.apache.directory.ldapstudio.schemas.view.viewers.SchemasElementsSortDialog;
+import org.apache.directory.ldapstudio.schemas.view.viewers.SchemaElementsSortDialog;
 import org.eclipse.jface.action.Action;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
@@ -59,7 +59,7 @@
      */
     public void run()
     {
-        SchemasElementsSortDialog hvsd = new SchemasElementsSortDialog( PlatformUI.getWorkbench().getDisplay()
+        SchemaElementsSortDialog hvsd = new SchemaElementsSortDialog( PlatformUI.getWorkbench().getDisplay()
             .getActiveShell() );
         hvsd.open();
     }

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemaElementsContentProvider.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemaElementsContentProvider.java?view=diff&rev=518704&r1=518703&r2=518704
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemaElementsContentProvider.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemaElementsContentProvider.java
Thu Mar 15 10:44:23 2007
@@ -30,19 +30,19 @@
 import org.apache.directory.ldapstudio.schemas.controller.actions.HideAttributeTypesAction;
 import org.apache.directory.ldapstudio.schemas.controller.actions.HideObjectClassesAction;
 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.SchemaPool;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.AttributeTypeWrapper;
 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.SchemaElementsViewRoot;
 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.TreeViewer;
 import org.eclipse.jface.viewers.Viewer;
 
 
@@ -52,7 +52,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class SchemaElementsContentProvider implements IStructuredContentProvider, ITreeContentProvider
+public class SchemaElementsContentProvider implements IStructuredContentProvider, ITreeContentProvider,
PoolListener
 {
     /** The Schema Pool holding all schemas */
     private SchemaPool schemaPool;
@@ -60,12 +60,6 @@
     /** The preferences store */
     IPreferenceStore store;
 
-    /** The HashTable containing all the object classes */
-    private List<ObjectClass> objectClasses;
-
-    /** The HashTable containing all the attribute types */
-    private List<AttributeType> attributeTypes;
-
     /** The FirstName Sorter */
     private FirstNameSorter firstNameSorter;
 
@@ -81,12 +75,10 @@
      */
     public SchemaElementsContentProvider()
     {
-        this.schemaPool = SchemaPool.getInstance();
+        schemaPool = SchemaPool.getInstance();
+        schemaPool.addListener( this );
         store = Activator.getDefault().getPreferenceStore();
 
-        objectClasses = schemaPool.getObjectClasses();
-        attributeTypes = schemaPool.getAttributeTypes();
-
         firstNameSorter = new FirstNameSorter();
         oidSorter = new OidSorter();
     }
@@ -106,235 +98,126 @@
      */
     public Object[] getChildren( Object parentElement )
     {
-        List<ITreeNode> children = new ArrayList<ITreeNode>();
+        if ( parentElement instanceof SchemaElementsViewRoot )
+        {
+            SchemaElementsViewRoot root = ( SchemaElementsViewRoot ) parentElement;
 
-        int group = store.getInt( PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_GROUPING );
-        int sortBy = store.getInt( PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_SORTING_BY
);
-        int sortOrder = store.getInt( PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_SORTING_ORDER
);
+            List<ITreeNode> children = new ArrayList<ITreeNode>();
 
-        if ( parentElement instanceof ObjectClassWrapper )
-        {
-            //we are looking for the childrens of the contained objectClass
-            ObjectClass objectClass = ( ( ObjectClassWrapper ) parentElement ).getMyObjectClass();
+            int group = store.getInt( PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_GROUPING
);
+            int sortBy = store.getInt( PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_SORTING_BY
);
+            int sortOrder = store.getInt( PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_SORTING_ORDER
);
+            boolean hideAttributeTypes = Activator.getDefault().getDialogSettings().getBoolean(
+                HideAttributeTypesAction.HIDE_ATTRIBUTE_TYPES_DS_KEY );
+            boolean hideObjectClasses = Activator.getDefault().getDialogSettings().getBoolean(
+                HideObjectClassesAction.HIDE_OBJECT_CLASSES_DS_KEY );
 
-            for ( ObjectClass oClass : objectClasses )
+            if ( root.getChildren().isEmpty() )
             {
-                //not this object class
-                if ( oClass.getOid() != objectClass.getOid() )
+                // ATTRIBUTE TYPES
+                List<AttributeType> attributeTypes = schemaPool.getAttributeTypes();
+                for ( AttributeType attributeType : attributeTypes )
+                {
+                    root.addChild( new AttributeTypeWrapper( attributeType, root ) );
+                }
+
+                // OBJECT CLASSES
+                List<ObjectClass> objectClasses = schemaPool.getObjectClasses();
+                for ( ObjectClass objectClass : objectClasses )
                 {
-                    String[] sups = oClass.getSuperiors();
-                    for ( String sup : sups )
-                    {
-                        ObjectClass oClassSup = schemaPool.getObjectClass( sup );
-                        if ( oClassSup != null )
-                        {
-                            //the current object class is a sup of oClass
-                            if ( oClassSup.equals( objectClass ) )
-                            {
-                                //we use an objectClass wrapper
-                                children
-                                    .add( new ObjectClassWrapper( oClass, ( ITreeNode ) parentElement
) );
-                                break; //break only the inner for
-                            }
-                        }
-                    }
+                    root.addChild( new ObjectClassWrapper( objectClass, root ) );
                 }
             }
 
-            // Sort by
-            if ( sortBy == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_SORTING_BY_FIRSTNAME
)
+            List<AttributeTypeWrapper> atList = new ArrayList<AttributeTypeWrapper>();
+            List<ObjectClassWrapper> ocList = new ArrayList<ObjectClassWrapper>();
+
+            if ( !hideAttributeTypes )
             {
-                Collections.sort( children, firstNameSorter );
+                atList = root.getAttributeTypes();
             }
-            else if ( sortBy == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_SORTING_BY_OID
)
+            if ( !hideObjectClasses )
             {
-                Collections.sort( children, oidSorter );
+                ocList = root.getObjectClasses();
             }
 
-            // Sort order
-            if ( sortOrder == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_SORTING_ORDER_DESCENDING
)
+            if ( group == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_GROUPING_ATFIRST )
             {
-                Collections.reverse( children );
-            }
-        }
-        if ( parentElement instanceof AttributeTypeWrapper )
-        {
-            //we are looking for the childrens of the contained attribute type
-            AttributeType attributeType = ( ( AttributeTypeWrapper ) parentElement ).getMyAttributeType();
+                // Sort by
+                if ( sortBy == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_SORTING_BY_FIRSTNAME
)
+                {
+                    Collections.sort( atList, firstNameSorter );
+                    Collections.sort( ocList, firstNameSorter );
+                }
+                else if ( sortBy == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_SORTING_BY_OID
)
+                {
+                    Collections.sort( atList, oidSorter );
+                    Collections.sort( ocList, oidSorter );
+                }
 
-            for (AttributeType aType : attributeTypes)
-            {
-                //not this attribute type
-                if ( aType.getOid() != attributeType.getOid() )
+                // Sort Order
+                if ( sortOrder == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_SORTING_ORDER_DESCENDING
)
                 {
-                    String aTypeSupName = aType.getSuperior();
-                    if ( aTypeSupName != null )
-                    {
-                        AttributeType aTypeSup = schemaPool.getAttributeType( aType.getSuperior()
);
-                        if ( aTypeSup != null )
-                        {
-                            //the current object class is a sup of oClass
-                            if ( aTypeSup.equals( attributeType ) )
-                            {
-                                //we use an objectClass wrapper
-                                children
-                                    .add( new AttributeTypeWrapper( aType, ( ITreeNode )
parentElement ) );
-                                break; //break only the inner for
-                            }
-                        }
-                    }
+                    Collections.reverse( atList );
+                    Collections.reverse( ocList );
                 }
-            }
 
-            // Sort by
-            if ( sortBy == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_SORTING_BY_FIRSTNAME
)
-            {
-                Collections.sort( children, firstNameSorter );
+                // Group
+                children.addAll( atList );
+                children.addAll( ocList );
             }
-            else if ( sortBy == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_SORTING_BY_OID
)
+            else if ( group == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_GROUPING_OCFIRST
)
             {
-                Collections.sort( children, oidSorter );
-            }
+                // Sort by
+                if ( sortBy == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_SORTING_BY_FIRSTNAME
)
+                {
+                    Collections.sort( atList, firstNameSorter );
+                    Collections.sort( ocList, firstNameSorter );
+                }
+                else if ( sortBy == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_SORTING_BY_OID
)
+                {
+                    Collections.sort( atList, oidSorter );
+                    Collections.sort( ocList, oidSorter );
+                }
 
-            // Sort order
-            if ( sortOrder == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_SORTING_ORDER_DESCENDING
)
-            {
-                Collections.reverse( children );
-            }
-        }
-        else if ( parentElement instanceof IntermediateNode )
-        {
-            IntermediateNode intermediate = ( IntermediateNode ) parentElement;
+                // Sort Order
+                if ( sortOrder == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_SORTING_ORDER_DESCENDING
)
+                {
+                    Collections.reverse( atList );
+                    Collections.reverse( ocList );
+                }
 
-            if ( intermediate.getName().equals( "**Primary Node**" ) ) //$NON-NLS-1$
+                // Group
+                children.addAll( ocList );
+                children.addAll( atList );
+            }
+            else if ( group == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_GROUPING_MIXED
)
             {
-                List<ObjectClassWrapper> ocList = new ArrayList<ObjectClassWrapper>();
-                if ( !Activator.getDefault().getDialogSettings().getBoolean(
-                    HideObjectClassesAction.HIDE_OBJECT_CLASSES_DS_KEY ) )
-                {
-                    for (ObjectClass oClass : objectClasses)
-                    {
-                        String[] sups = oClass.getSuperiors();
-                        //if no supperiors had been set
-                        if ( sups.length == 0 )
-                        {
-                            ObjectClassWrapper wrapper = new ObjectClassWrapper( oClass,
intermediate );
-                            if ( !"2.5.6.0".equals( oClass.getOid() ) )
-                            {
-                                wrapper.setState( ObjectClassWrapper.State.unResolved );
-                            }
-                            ocList.add( wrapper );
-                            this.hasChildren( wrapper );
-                        }
-                        else
-                        {
-                            for ( String sup : sups )
-                            {
-                                ObjectClass oClassSup = schemaPool.getObjectClass( sup );
-                                if ( oClassSup == null )
-                                {
-                                    ObjectClassWrapper wrapper = new ObjectClassWrapper(
oClass, intermediate );
-                                    wrapper.setState( ObjectClassWrapper.State.unResolved
);
-                                    ocList.add( wrapper );
-                                }
-                            }
-                        }
-                    }
-                }
-
-                List<AttributeTypeWrapper> atList = new ArrayList<AttributeTypeWrapper>();
-                if ( !Activator.getDefault().getDialogSettings().getBoolean(
-                    HideAttributeTypesAction.HIDE_ATTRIBUTE_TYPES_DS_KEY ) )
-                {
-
-                    for (AttributeType aType : attributeTypes )
-                    {
-                        String sup = aType.getSuperior();
-                        //if no superior had been set
-                        if ( sup == null )
-                        {
-                            AttributeTypeWrapper wrapper = new AttributeTypeWrapper( aType,
intermediate );
-                            atList.add( wrapper );
-                        }
-                    }
-                }
-
-                if ( group == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_GROUPING_ATFIRST
)
-                {
-                    // Sort by
-                    if ( sortBy == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_SORTING_BY_FIRSTNAME
)
-                    {
-                        Collections.sort( atList, firstNameSorter );
-                        Collections.sort( ocList, firstNameSorter );
-                    }
-                    else if ( sortBy == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_SORTING_BY_OID
)
-                    {
-                        Collections.sort( atList, oidSorter );
-                        Collections.sort( ocList, oidSorter );
-                    }
-
-                    // Sort Order
-                    if ( sortOrder == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_SORTING_ORDER_DESCENDING
)
-                    {
-                        Collections.reverse( atList );
-                        Collections.reverse( ocList );
-                    }
-
-                    // Group
-                    children.addAll( atList );
-                    children.addAll( ocList );
-                }
-                else if ( group == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_GROUPING_OCFIRST
)
-                {
-                    // Sort by
-                    if ( sortBy == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_SORTING_BY_FIRSTNAME
)
-                    {
-                        Collections.sort( atList, firstNameSorter );
-                        Collections.sort( ocList, firstNameSorter );
-                    }
-                    else if ( sortBy == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_SORTING_BY_OID
)
-                    {
-                        Collections.sort( atList, oidSorter );
-                        Collections.sort( ocList, oidSorter );
-                    }
-
-                    // Sort Order
-                    if ( sortOrder == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_SORTING_ORDER_DESCENDING
)
-                    {
-                        Collections.reverse( atList );
-                        Collections.reverse( ocList );
-                    }
-
-                    // Group
-                    children.addAll( ocList );
-                    children.addAll( atList );
-                }
-                else if ( group == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_GROUPING_MIXED
)
-                {
-                    // Group
-                    children.addAll( atList );
-                    children.addAll( ocList );
-
-                    // Sort by
-                    if ( sortBy == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_SORTING_BY_FIRSTNAME
)
-                    {
-                        Collections.sort( children, firstNameSorter );
-                    }
-                    else if ( sortBy == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_SORTING_BY_OID
)
-                    {
-                        Collections.sort( children, oidSorter );
-                    }
-
-                    // Sort order
-                    if ( sortOrder == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_SORTING_ORDER_DESCENDING
)
-                    {
-                        Collections.reverse( children );
-                    }
+                // Group
+                children.addAll( atList );
+                children.addAll( ocList );
+
+                // Sort by
+                if ( sortBy == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_SORTING_BY_FIRSTNAME
)
+                {
+                    Collections.sort( children, firstNameSorter );
+                }
+                else if ( sortBy == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_SORTING_BY_OID
)
+                {
+                    Collections.sort( children, oidSorter );
+                }
+
+                // Sort order
+                if ( sortOrder == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_SORTING_ORDER_DESCENDING
)
+                {
+                    Collections.reverse( children );
                 }
             }
+            return children.toArray();
         }
 
-        return children.toArray();
+        // Default
+        return new Object[0];
     }
 
 
@@ -343,17 +226,9 @@
      */
     public Object getParent( Object element )
     {
-        if ( element instanceof ObjectClassWrapper )
-        {
-            return ( ( ObjectClassWrapper ) element ).getParent();
-        }
-        else if ( element instanceof AttributeTypeWrapper )
-        {
-            return ( ( AttributeTypeWrapper ) element ).getParent();
-        }
-        else if ( element instanceof IntermediateNode )
+        if ( element instanceof ITreeNode )
         {
-            return ( ( IntermediateNode ) element ).getParent();
+            return ( ( ITreeNode ) element ).getParent();
         }
 
         return null;
@@ -365,38 +240,22 @@
      */
     public boolean hasChildren( Object element )
     {
-        if ( element instanceof ObjectClassWrapper )
+        if ( element instanceof SchemaElementsViewRoot )
         {
-            return getChildren( ( ObjectClassWrapper ) element ).length > 0;
-        }
-        else if ( element instanceof AttributeTypeWrapper )
-        {
-            return getChildren( ( AttributeTypeWrapper ) element ).length > 0;
-        }
-        else if ( element instanceof IntermediateNode )
-        {
-            return getChildren( ( IntermediateNode ) element ).length > 0;
+            return true;
         }
 
         return false;
     }
 
 
-    /**
-     * Initialize a tree viewer to display the information provided by the specified content
-     * provider.
-     * 
-     * @param viewer
-     *      the tree viewer
+    /* (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 bindToTreeViewer( TreeViewer viewer )
+    public void poolChanged( SchemaPool p, LDAPModelEvent e )
     {
-        viewer.setContentProvider( this );
-        viewer.setLabelProvider( new DecoratingLabelProvider( new SchemaElementsViewLabelProvider(),
Activator.getDefault()
-            .getWorkbench().getDecoratorManager().getLabelDecorator() ) );
+        // TODO Auto-generated method stub
 
-        IntermediateNode invisibleNode = new IntermediateNode( "**Primary Node**", null );
//$NON-NLS-1$
-        viewer.setInput( invisibleNode );
     }
 
 

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemaElementsView.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemaElementsView.java?view=diff&rev=518704&r1=518703&r2=518704
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemaElementsView.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemaElementsView.java
Thu Mar 15 10:44:23 2007
@@ -23,11 +23,9 @@
 
 import org.apache.directory.ldapstudio.schemas.Activator;
 import org.apache.directory.ldapstudio.schemas.controller.SchemaElementsController;
-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.ITreeNode;
-import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.SchemasViewRoot;
+import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.SchemaElementsViewRoot;
+import org.eclipse.jface.viewers.DecoratingLabelProvider;
 import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Composite;
@@ -40,7 +38,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class SchemaElementsView extends ViewPart implements PoolListener
+public class SchemaElementsView extends ViewPart
 {
     /** The view's ID */
     public static final String ID = Activator.PLUGIN_ID + ".view.SchemaElementsView"; //$NON-NLS-1$
@@ -62,10 +60,6 @@
         // 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 SchemaElementsController( this );
     }
@@ -81,7 +75,10 @@
     {
         viewer = new TreeViewer( parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER
);
         contentProvider = new SchemaElementsContentProvider();
-        contentProvider.bindToTreeViewer( viewer );
+        viewer.setContentProvider( contentProvider );
+        viewer.setLabelProvider( new DecoratingLabelProvider( new SchemaElementsViewLabelProvider(),
Activator
+            .getDefault().getWorkbench().getDecoratorManager().getLabelDecorator() ) );
+        viewer.setInput( new SchemaElementsViewRoot() );
     }
 
 
@@ -93,51 +90,22 @@
         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
      */
     public void refresh()
     {
-        Object[] exp = viewer.getExpandedElements();
-
-        // Refresh the tree viewer
         viewer.refresh();
-
-        // Expand all the previsouly expanded elements
-        for ( Object object : exp )
-        {
-            viewer.setExpandedState( object, true );
-        }
     }
 
 
     /**
-     * refresh the view if the pool has been modified
+     * Updates the viewer
      */
-    public void poolChanged( SchemaPool p, LDAPModelEvent e )
+    public void update()
     {
-        refresh();
+        viewer.update( viewer.getInput(), null );
     }
 
 
@@ -151,41 +119,17 @@
      */
     public ITreeNode findElementInTree( ITreeNode element )
     {
-        ITreeNode input = ( ITreeNode ) getViewer().getInput();
-
-        return findElementInTree( element, input );
-    }
-
+        Object[] children = contentProvider.getChildren( ( ITreeNode ) getViewer().getInput()
);
 
-    /**
-     * Search for the given element in the Tree and returns it if it has been found.
-     *
-     * @param element
-     *      the element to find
-     * @param current
-     *      the current element
-     * @return
-     */
-    private ITreeNode findElementInTree( ITreeNode element, ITreeNode current )
-    {
-        if ( element.equals( current ) )
+        for ( Object child : children )
         {
-            return current;
-        }
-        else
-        {
-            Object[] children = contentProvider.getChildren( current );
-
-            for ( int i = 0; i < children.length; i++ )
+            ITreeNode item = ( ITreeNode ) child;
+            if ( item.equals( element ) )
             {
-                ITreeNode item = ( ITreeNode ) children[i];
-                ITreeNode foundElement = findElementInTree( element, item );
-                if ( foundElement != null )
-                {
-                    return foundElement;
-                }
+                return item;
             }
         }
+
         return null;
     }
 

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/SchemaElementsViewRoot.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/SchemaElementsViewRoot.java?view=diff&rev=518704&r1=518703&r2=518704
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/SchemaElementsViewRoot.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/SchemaElementsViewRoot.java
Thu Mar 15 10:44:23 2007
@@ -179,9 +179,10 @@
 
 
     /**
-     * TODO removeAttributeType.
+     * Removes an Attribute Type Wrapper.
      *
      * @param wrapper
+     *      the Attribute Type Wrapper to remove
      */
     private void removeAttributeType( AttributeTypeWrapper wrapper )
     {
@@ -193,9 +194,10 @@
 
 
     /**
-     * TODO removeObjectClass.
+     * Removes an Object Class Wrapper.
      *
      * @param wrapper
+     *      the Object Class Wrapper to remove
      */
     private void removeObjectClass( ObjectClassWrapper wrapper )
     {
@@ -204,13 +206,16 @@
             ocChildren.remove( wrapper );
         }
     }
-    
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.TreeNode#getChildren()
+     */
     public List<ITreeNode> getChildren()
     {
         List<ITreeNode> children = new ArrayList<ITreeNode>();
-        children.addAll( aTChildren );
-        children.addAll( ocChildren );
-        
+        children.addAll( getAttributeTypes() );
+        children.addAll( getObjectClasses() );
         return children;
     }
 }



Mime
View raw message