directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r509199 [1/2] - in /directory/ldapstudio/trunk/ldapstudio-schemas-plugin: ./ ressources/icons/ src/main/java/org/apache/directory/ldapstudio/schemas/controller/ src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/ src/m...
Date Mon, 19 Feb 2007 13:41:27 GMT
Author: pamarcelot
Date: Mon Feb 19 05:41:26 2007
New Revision: 509199

URL: http://svn.apache.org/viewvc?view=rev&rev=509199
Log:
Fixed DIRSTUDIO-7 (OID View).
Refactored Hierarchy View and Schemas View.
Removed Sort Actions for both Views.
Added to Hierarchy View :
	o A Sorting Dialog
	o A preference page for label preferences.

Hierarchy View can now be sorted by First Name or by OID (ascending and descending) and grouped by OC first, AT first or mixed.

Labels for AT and OC can now be First Name, All aliases or OID. A secondary label can be added to display another information.

The icon of the Hierarchy View has been changed.

Added:
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/ressources/icons/hierarchy_view.png   (with props)
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/ressources/icons/sort.gif   (with props)
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/OpenHierarchyViewPreferencesAction.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/OpenSortDialogAction.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/preferences/HierarchyViewPreferencePage.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyViewSorterDialog.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/HierarchyViewFirstNameSorter.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/HierarchyViewOidSorter.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/SchemasViewSorter.java
Removed:
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/ressources/icons/Thumbs.db
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/ressources/icons/chart_organisation.png
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/SortHierarchicalViewAction.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/SortPoolManagerAction.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/AlphabeticalOrderComparator.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/PoolManagerAttributeTypeWrapper.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/PoolManagerObjectClassWrapper.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/UnAlphabeticalOrderComparator.java
Modified:
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/plugin.xml
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/HierarchicalViewerController.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/PoolManagerController.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/PreferenceInitializer.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/LinkWithEditorHierarchyView.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/LinkWithEditorSchemasView.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/IImageKeys.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchicalContentProvider.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchicalLabelProvider.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchicalViewer.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/PoolManager.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/PoolManagerContentProvider.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/PoolManagerLabelProvider.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/AttributeTypeWrapper.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/DisplayableTreeElement.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/IntermediateNode.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/ObjectClassWrapper.java

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/plugin.xml
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/plugin.xml?view=diff&rev=509199&r1=509198&r2=509199
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/plugin.xml (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/plugin.xml Mon Feb 19 05:41:26 2007
@@ -43,7 +43,7 @@
             allowMultiple="false"
             category="org.apache.directory.ldapstudio.schemas.view.category"
             class="org.apache.directory.ldapstudio.schemas.view.viewers.HierarchicalViewer"
-            icon="ressources/icons/chart_organisation.png"
+            icon="ressources/icons/hierarchy_view.png"
             id="org.apache.directory.ldapstudio.schemas.view.HierarchicalViewer"
             name="%ldapstudio-schemas-plugin.views.hierarchy.name"/>
       <view
@@ -194,6 +194,10 @@
             class="org.apache.directory.ldapstudio.schemas.view.preferences.SchemaPreferencePage"
             id="org.apache.directory.ldapstudio.schemas.preferences.schema"
             name="%ldapstudio-schemas-plugin.preferencepages.schema.name"/>
+      <page
+            class="org.apache.directory.ldapstudio.schemas.view.preferences.HierarchyViewPreferencePage"
+            id="org.apache.directory.ldapstudio.schemas.preferences.hierarchyView"
+            name="Hierarchy View"/>
    </extension>
    <extension
          point="org.eclipse.core.runtime.preferences">

Added: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/ressources/icons/hierarchy_view.png
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/ressources/icons/hierarchy_view.png?view=auto&rev=509199
==============================================================================
Binary file - no diff available.

Propchange: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/ressources/icons/hierarchy_view.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/ressources/icons/sort.gif
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/ressources/icons/sort.gif?view=auto&rev=509199
==============================================================================
Binary file - no diff available.

Propchange: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/ressources/icons/sort.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/HierarchicalViewerController.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/HierarchicalViewerController.java?view=diff&rev=509199&r1=509198&r2=509199
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/HierarchicalViewerController.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/HierarchicalViewerController.java Mon Feb 19 05:41:26 2007
@@ -21,23 +21,27 @@
 package org.apache.directory.ldapstudio.schemas.controller;
 
 
+import org.apache.directory.ldapstudio.schemas.Activator;
 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.LinkWithEditorHierarchyView;
-import org.apache.directory.ldapstudio.schemas.controller.actions.SortHierarchicalViewAction;
+import org.apache.directory.ldapstudio.schemas.controller.actions.OpenHierarchyViewPreferencesAction;
+import org.apache.directory.ldapstudio.schemas.controller.actions.OpenSortDialogAction;
 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;
 import org.apache.directory.ldapstudio.schemas.view.editors.ObjectClassFormEditorInput;
 import org.apache.directory.ldapstudio.schemas.view.viewers.HierarchicalViewer;
-import org.apache.directory.ldapstudio.schemas.view.viewers.Messages;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.AttributeTypeWrapper;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.IntermediateNode;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.ObjectClassWrapper;
 import org.apache.log4j.Logger;
+import org.eclipse.jface.action.IMenuManager;
 import org.eclipse.jface.action.IToolBarManager;
 import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
 import org.eclipse.jface.viewers.DoubleClickEvent;
 import org.eclipse.jface.viewers.IDoubleClickListener;
 import org.eclipse.jface.viewers.StructuredSelection;
@@ -61,14 +65,15 @@
 
     /** The associated view */
     private HierarchicalViewer view;
-    
+
     // The Actions
     private HideObjectClassesAction hideObjectClasses;
     private HideAttributeTypesAction hideAttributeTypes;
-    private SortHierarchicalViewAction sortAlphabetical;
-    private SortHierarchicalViewAction sortUnAlphabetical;
     private CollapseAllAction collapseAll;
     private LinkWithEditorHierarchyView linkWithEditor;
+    private OpenSortDialogAction openSortDialog;
+    private OpenHierarchyViewPreferencesAction openPreferencePage;
+
 
     /**
      * Creates a new instance of HierarchicalViewerController.
@@ -80,8 +85,9 @@
 
         initActions();
         initToolbar();
-
+        initMenu();
         initDoubleClickListener();
+        initPreferencesListener();
     }
 
 
@@ -92,14 +98,10 @@
     {
         hideObjectClasses = new HideObjectClassesAction( view );
         hideAttributeTypes = new HideAttributeTypesAction( view );
-        sortAlphabetical = new SortHierarchicalViewAction( PlatformUI.getWorkbench().getActiveWorkbenchWindow(),
-            SortHierarchicalViewAction.SortType.alphabetical, Messages
-                .getString( "HierarchicalViewer.Sort_alphabetically" ) ); //$NON-NLS-1$
-        sortUnAlphabetical = new SortHierarchicalViewAction( PlatformUI.getWorkbench().getActiveWorkbenchWindow(),
-            SortHierarchicalViewAction.SortType.unalphabetical, Messages
-                .getString( "HierarchicalViewer.Sort_unalphabetically" ) ); //$NON-NLS-1$
         collapseAll = new CollapseAllAction( view.getViewer() );
         linkWithEditor = new LinkWithEditorHierarchyView( view );
+        openSortDialog = new OpenSortDialogAction();
+        openPreferencePage = new OpenHierarchyViewPreferencesAction();
     }
 
 
@@ -112,15 +114,26 @@
         toolbar.add( hideObjectClasses );
         toolbar.add( hideAttributeTypes );
         toolbar.add( new Separator() );
-        toolbar.add( sortAlphabetical );
-        toolbar.add( sortUnAlphabetical );
-        toolbar.add( new Separator() );
         toolbar.add( collapseAll );
         toolbar.add( linkWithEditor );
     }
 
 
     /**
+     * Initializes the Menu.
+     */
+    private void initMenu()
+    {
+        IMenuManager menu = view.getViewSite().getActionBars().getMenuManager();
+        menu.add( openSortDialog );
+        menu.add( new Separator() );
+        menu.add( linkWithEditor );
+        menu.add( new Separator() );
+        menu.add( openPreferencePage );
+    }
+
+
+    /**
      * Initializes the DoubleClickListener
      */
     private void initDoubleClickListener()
@@ -176,5 +189,24 @@
                 }
             }
         } );
+    }
+
+
+    /**
+     * Initializes the listener on the preferences store
+     */
+    private void initPreferencesListener()
+    {
+        Activator.getDefault().getPreferenceStore().addPropertyChangeListener( new IPropertyChangeListener()
+        {
+            /* (non-Javadoc)
+             * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+             */
+            public void propertyChange( PropertyChangeEvent event )
+            {
+                view.getViewer().refresh();
+            }
+        } );
+
     }
 }

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/PoolManagerController.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/PoolManagerController.java?view=diff&rev=509199&r1=509198&r2=509199
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/PoolManagerController.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/PoolManagerController.java Mon Feb 19 05:41:26 2007
@@ -32,7 +32,6 @@
 import org.apache.directory.ldapstudio.schemas.controller.actions.RemoveSchemaAction;
 import org.apache.directory.ldapstudio.schemas.controller.actions.SaveAction;
 import org.apache.directory.ldapstudio.schemas.controller.actions.SaveAsAction;
-import org.apache.directory.ldapstudio.schemas.controller.actions.SortPoolManagerAction;
 import org.apache.directory.ldapstudio.schemas.model.Schema;
 import org.apache.directory.ldapstudio.schemas.model.SchemaCreationException;
 import org.apache.directory.ldapstudio.schemas.model.SchemaPool;
@@ -41,7 +40,6 @@
 import org.apache.directory.ldapstudio.schemas.view.editors.AttributeTypeFormEditorInput;
 import org.apache.directory.ldapstudio.schemas.view.editors.ObjectClassFormEditor;
 import org.apache.directory.ldapstudio.schemas.view.editors.ObjectClassFormEditorInput;
-import org.apache.directory.ldapstudio.schemas.view.viewers.Messages;
 import org.apache.directory.ldapstudio.schemas.view.viewers.PoolManager;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.AttributeTypeWrapper;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.IntermediateNode;
@@ -103,8 +101,6 @@
     private Action createANewObjectClass;
     private Action createANewAttributeType;
     private Action deleteAction;
-    private Action sortAlphabetical;
-    private Action sortUnAlphabetical;
     private Action collapseAll;
     private Action linkWithEditor;
     private Action openSchemaSourceCode;
@@ -142,10 +138,6 @@
         createANewObjectClass = new CreateANewObjectClassAction();
         createANewAttributeType = new CreateANewAttributeTypeAction();
         deleteAction = new DeleteAction();
-        sortAlphabetical = new SortPoolManagerAction( PlatformUI.getWorkbench().getActiveWorkbenchWindow(),
-            SortPoolManagerAction.SortType.alphabetical, Messages.getString( "PoolManager.Sort_alphabetically" ) ); //$NON-NLS-1$
-        sortUnAlphabetical = new SortPoolManagerAction( PlatformUI.getWorkbench().getActiveWorkbenchWindow(),
-            SortPoolManagerAction.SortType.unalphabetical, Messages.getString( "PoolManager.Sort_unalphabetically" ) ); //$NON-NLS-1$
         collapseAll = new CollapseAllAction( view.getViewer() );
         linkWithEditor = new LinkWithEditorSchemasView( view );
         openSchemaSourceCode = new OpenSchemaSourceCode( PlatformUI.getWorkbench().getActiveWorkbenchWindow(),
@@ -169,9 +161,6 @@
         toolbar.add( createANewAttributeType );
         toolbar.add( ( IAction ) deleteAction );
         toolbar.add( new Separator() );
-        toolbar.add( sortAlphabetical );
-        toolbar.add( sortUnAlphabetical );
-        toolbar.add( new Separator() );
         toolbar.add( collapseAll );
         toolbar.add( linkWithEditor );
     }
@@ -295,6 +284,7 @@
                 }
             }
 
+
             /**
              * {@inheritDoc}
              */
@@ -302,6 +292,7 @@
             {
             }
 
+
             /**
              * {@inheritDoc}
              */
@@ -309,6 +300,7 @@
             {
             }
 
+
             /**
              * {@inheritDoc}
              */
@@ -316,6 +308,7 @@
             {
             }
 
+
             /**
              * {@inheritDoc}
              */
@@ -323,6 +316,7 @@
             {
             }
 
+
             /**
              * {@inheritDoc}
              */
@@ -463,7 +457,8 @@
                 else if ( selectedObject instanceof AttributeTypeWrapper )
                 {
                     AttributeTypeWrapper attributeTypeWrapper = ( AttributeTypeWrapper ) selectedObject;
-                    deleteAction.setText( "Delete Attribute Type" + " '" + attributeTypeWrapper.getName() + "'" );
+                    deleteAction.setText( "Delete Attribute Type" + " '"
+                        + attributeTypeWrapper.getMyAttributeType().getNames()[0] + "'" );
 
                     if ( attributeTypeWrapper.getMyAttributeType().getOriginatingSchema().type == SchemaType.coreSchema )
                     {
@@ -481,7 +476,8 @@
                 else if ( selectedObject instanceof ObjectClassWrapper )
                 {
                     ObjectClassWrapper objectClassWrapper = ( ObjectClassWrapper ) selectedObject;
-                    deleteAction.setText( "Delete Object Class" + " '" + objectClassWrapper.getNames()[0] + "'" );
+                    deleteAction.setText( "Delete Object Class" + " '"
+                        + objectClassWrapper.getMyObjectClass().getNames()[0] + "'" );
 
                     if ( objectClassWrapper.getMyObjectClass().getOriginatingSchema().type == SchemaType.coreSchema )
                     {

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/PreferenceInitializer.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/PreferenceInitializer.java?view=diff&rev=509199&r1=509198&r2=509199
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/PreferenceInitializer.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/PreferenceInitializer.java Mon Feb 19 05:41:26 2007
@@ -21,11 +21,15 @@
 package org.apache.directory.ldapstudio.schemas.controller;
 
 
+import org.apache.directory.ldapstudio.schemas.Activator;
 import org.apache.directory.ldapstudio.schemas.view.preferences.GeneralPreferencePage;
+import org.apache.directory.ldapstudio.schemas.view.preferences.HierarchyViewPreferencePage;
 import org.apache.directory.ldapstudio.schemas.view.preferences.SchemaPreferencePage;
+import org.apache.directory.ldapstudio.schemas.view.viewers.HierarchyViewSorterDialog;
 import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
 import org.eclipse.core.runtime.preferences.DefaultScope;
 import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.jface.preference.IPreferenceStore;
 
 
 public class PreferenceInitializer extends AbstractPreferenceInitializer
@@ -47,6 +51,26 @@
         defaults.putBoolean( SchemaPreferencePage.SAVE_WORKSPACE, true );
         defaults.putBoolean( SchemaPreferencePage.SPECIFIC_CORE, false );
         defaults.put( SchemaPreferencePage.SPECIFIC_CORE_DIRECTORY, System.getProperty( "user.home" ) ); //$NON-NLS-1$
-    }
 
+        IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+
+        // Hierarchy View Preference Page
+        store.setDefault( HierarchyViewPreferencePage.PREFS_HIERARCHY_VIEW_LABEL,
+            HierarchyViewPreferencePage.PREFS_HIERARCHY_VIEW_LABEL_FIRST_NAME );
+        store.setDefault( HierarchyViewPreferencePage.PREFS_HIERARCHY_VIEW_ABBREVIATE, true );
+        store.setDefault( HierarchyViewPreferencePage.PREFS_HIERARCHY_VIEW_ABBREVIATE_MAX_LENGTH, "50" );
+        store.setDefault( HierarchyViewPreferencePage.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_DISPLAY, true );
+        store.setDefault( HierarchyViewPreferencePage.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL,
+            HierarchyViewPreferencePage.PREFS_HIERARCHY_VIEW_LABEL_OID );
+        store.setDefault( HierarchyViewPreferencePage.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_ABBREVIATE, false );
+        store.setDefault( HierarchyViewPreferencePage.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH, "50" );
+
+        // Hierarchy View Sorting
+        store.setDefault( HierarchyViewSorterDialog.PREFS_HIERARCHY_VIEW_GROUPING,
+            HierarchyViewSorterDialog.PREFS_HIERARCHY_VIEW_GROUPING_ATFIRST );
+        store.setDefault( HierarchyViewSorterDialog.PREFS_HIERARCHY_VIEW_SORTING_BY,
+            HierarchyViewSorterDialog.PREFS_HIERARCHY_VIEW_SORTING_BY_FIRSTNAME );
+        store.setDefault( HierarchyViewSorterDialog.PREFS_HIERARCHY_VIEW_SORTING_ORDER,
+            HierarchyViewSorterDialog.PREFS_HIERARCHY_VIEW_SORTING_ORDER_ASCENDING );
+    }
 }

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/LinkWithEditorHierarchyView.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/LinkWithEditorHierarchyView.java?view=diff&rev=509199&r1=509198&r2=509199
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/LinkWithEditorHierarchyView.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/LinkWithEditorHierarchyView.java Mon Feb 19 05:41:26 2007
@@ -77,7 +77,9 @@
 
             if ( ( id.equals( ObjectClassFormEditor.ID ) || ( id.equals( AttributeTypeFormEditor.ID ) ) ) )
             {
+                hierarchyView.getSite().getPage().removePostSelectionListener( HierarchicalViewer.ID, viewListener );
                 linkViewWithEditor( partRef.getPartName(), id );
+                hierarchyView.getSite().getPage().addPostSelectionListener( HierarchicalViewer.ID, viewListener );
             }
         }
 
@@ -139,7 +141,9 @@
 
             if ( ( id.equals( ObjectClassFormEditor.ID ) || ( id.equals( AttributeTypeFormEditor.ID ) ) ) )
             {
+                hierarchyView.getSite().getPage().removePostSelectionListener( HierarchicalViewer.ID, viewListener );
                 linkViewWithEditor( partRef.getPartName(), id );
+                hierarchyView.getSite().getPage().addPostSelectionListener( HierarchicalViewer.ID, viewListener );
             }
         }
     };
@@ -341,12 +345,10 @@
             IEditorReference reference = editorReferences[i];
             IWorkbenchPart workbenchPart = reference.getPart( true );
 
-            if ( ( 
-                    ( ( workbenchPart instanceof ObjectClassFormEditor ) && ( wrapper instanceof ObjectClassWrapper ) )
-                    || ( ( workbenchPart instanceof AttributeTypeFormEditor ) && ( wrapper instanceof AttributeTypeWrapper ) ) 
-                    || ( ( workbenchPart instanceof SchemaFormEditor ) && ( wrapper instanceof SchemaWrapper ) ) 
-                )
-                && ( reference.getPartName().equals( wrapper.getDisplayName() ) ) )
+            if ( ( ( workbenchPart instanceof ObjectClassFormEditor ) && ( wrapper instanceof ObjectClassWrapper ) && ( reference.getPartName().equals( ( ( ObjectClassWrapper ) wrapper).getMyObjectClass().getNames()[0] ) ) )
+              || ( ( workbenchPart instanceof AttributeTypeFormEditor ) && ( wrapper instanceof AttributeTypeWrapper ) && ( reference.getPartName().equals( ( ( AttributeTypeWrapper ) wrapper).getMyAttributeType().getNames()[0] ) ) ) 
+              || ( ( workbenchPart instanceof SchemaFormEditor ) && ( wrapper instanceof SchemaWrapper ) && ( reference.getPartName().equals( ( ( SchemaWrapper ) wrapper).getMySchema().getName() ) ) ) 
+               )
             {
                 PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().bringToTop( workbenchPart );
                 return;

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/LinkWithEditorSchemasView.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/LinkWithEditorSchemasView.java?view=diff&rev=509199&r1=509198&r2=509199
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/LinkWithEditorSchemasView.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/LinkWithEditorSchemasView.java Mon Feb 19 05:41:26 2007
@@ -76,7 +76,9 @@
 
             if ( ( id.equals( ObjectClassFormEditor.ID ) || ( id.equals( AttributeTypeFormEditor.ID ) ) ) )
             {
+                schemasView.getSite().getPage().removePostSelectionListener( PoolManager.ID, viewListener );
                 linkViewWithEditor( partRef.getPartName(), id );
+                schemasView.getSite().getPage().addPostSelectionListener( PoolManager.ID, viewListener );
             }
         }
 
@@ -90,7 +92,9 @@
 
             if ( ( id.equals( ObjectClassFormEditor.ID ) || ( id.equals( AttributeTypeFormEditor.ID ) ) ) )
             {
+                schemasView.getSite().getPage().removePostSelectionListener( PoolManager.ID, viewListener );
                 linkViewWithEditor( partRef.getPartName(), id );
+                schemasView.getSite().getPage().addPostSelectionListener( PoolManager.ID, viewListener );
             }
         }
 
@@ -340,12 +344,10 @@
             IEditorReference reference = editorReferences[i];
             IWorkbenchPart workbenchPart = reference.getPart( true );
 
-            if ( ( 
-                    ( ( workbenchPart instanceof ObjectClassFormEditor ) && ( wrapper instanceof ObjectClassWrapper ) )
-                    || ( ( workbenchPart instanceof AttributeTypeFormEditor ) && ( wrapper instanceof AttributeTypeWrapper ) ) 
-                    || ( ( workbenchPart instanceof SchemaFormEditor ) && ( wrapper instanceof SchemaWrapper ) ) 
-                )
-                && ( reference.getPartName().equals( wrapper.getDisplayName() ) ) )
+            if ( ( ( workbenchPart instanceof ObjectClassFormEditor ) && ( wrapper instanceof ObjectClassWrapper ) && ( reference.getPartName().equals( ( ( ObjectClassWrapper ) wrapper).getMyObjectClass().getNames()[0] ) ) )
+              || ( ( workbenchPart instanceof AttributeTypeFormEditor ) && ( wrapper instanceof AttributeTypeWrapper ) && ( reference.getPartName().equals( ( ( AttributeTypeWrapper ) wrapper).getMyAttributeType().getNames()[0] ) ) ) 
+              || ( ( workbenchPart instanceof SchemaFormEditor ) && ( wrapper instanceof SchemaWrapper ) && ( reference.getPartName().equals( ( ( SchemaWrapper ) wrapper).getMySchema().getName() ) ) ) 
+               )
             {
                 PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().bringToTop( workbenchPart );
                 return;

Added: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/OpenHierarchyViewPreferencesAction.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/OpenHierarchyViewPreferencesAction.java?view=auto&rev=509199
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/OpenHierarchyViewPreferencesAction.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/OpenHierarchyViewPreferencesAction.java Mon Feb 19 05:41:26 2007
@@ -0,0 +1,56 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.schemas.controller.actions;
+
+import org.apache.directory.ldapstudio.schemas.view.preferences.HierarchyViewPreferencePage;
+import org.eclipse.jface.action.Action;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+
+/**
+ * This action opens the Sort Dialog of the Hierchy View.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class OpenHierarchyViewPreferencesAction extends Action
+{
+    /**
+     * Creates a new instance of OpenHierarchyViewPreferencesAction.
+     */
+    public OpenHierarchyViewPreferencesAction()
+    {
+        super( "Preferences..." );
+        setEnabled( true );
+    }
+    
+    
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.action.Action#run()
+     */
+    public void run()
+    {
+        Shell shell = Display.getCurrent().getActiveShell();
+        PreferencesUtil.createPreferenceDialogOn( shell, HierarchyViewPreferencePage.ID, new String[] { HierarchyViewPreferencePage.ID }, null ).open();
+    }
+}

Added: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/OpenSortDialogAction.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/OpenSortDialogAction.java?view=auto&rev=509199
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/OpenSortDialogAction.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/OpenSortDialogAction.java Mon Feb 19 05:41:26 2007
@@ -0,0 +1,61 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.schemas.controller.actions;
+
+import org.apache.directory.ldapstudio.schemas.controller.Application;
+import org.apache.directory.ldapstudio.schemas.view.IImageKeys;
+import org.apache.directory.ldapstudio.schemas.view.viewers.HierarchyViewSorterDialog;
+import org.eclipse.jface.action.Action;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This action opens the Sort Dialog of the Hierchy View.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class OpenSortDialogAction extends Action
+{
+    
+    /**
+     * Creates a new instance of OpenSortDialogAction.
+     *
+     * @param view
+     *      the associated view
+     */
+    public OpenSortDialogAction()
+    {
+        super( "Sorting..." );
+        setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Application.PLUGIN_ID, IImageKeys.SORT )  );
+        setEnabled( true );
+    }
+    
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.action.Action#run()
+     */
+    public void run()
+    {
+        HierarchyViewSorterDialog hvsd = new HierarchyViewSorterDialog( PlatformUI.getWorkbench().getDisplay().getActiveShell() );
+        hvsd.open();
+    }
+}

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/IImageKeys.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/IImageKeys.java?view=diff&rev=509199&r1=509198&r2=509199
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/IImageKeys.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/IImageKeys.java Mon Feb 19 05:41:26 2007
@@ -38,13 +38,12 @@
     public static final String SAVE = "ressources/icons/save.gif"; //$NON-NLS-1$
     public static final String SAVE_AS = "ressources/icons/save_as.png"; //$NON-NLS-1$
     public static final String SAVE_ALL = "ressources/icons/save_all.png"; //$NON-NLS-1$
-    public static final String SORT_ALPHABETICAL = "ressources/icons/sort_alphabetical.gif"; //$NON-NLS-1$
-    public static final String SORT_UNALPHABETICAL = "ressources/icons/sort_unalphabetical.gif"; //$NON-NLS-1$
     public static final String SHOW_PREFERENCES = "ressources/icons/preferences.png"; //$NON-NLS-1$
     public static final String LINK_WITH_EDITOR = "ressources/icons/link_with_editor.gif"; //$NON-NLS-1$
     public static final String COLLAPSE_ALL = "ressources/icons/collapse_all.gif"; //$NON-NLS-1$
     public static final String HIDE_OBJECT_CLASSES = "ressources/icons/hide_object_classes.png"; //$NON-NLS-1$
     public static final String HIDE_ATTRIBUTE_TYPES = "ressources/icons/hide_attribute_types.png"; //$NON-NLS-1$
+    public static final String SORT = "ressources/icons/sort.gif"; //$NON-NLS-1$
 
     // Images for Views
     public static final String FOLDER_ATTRIBUTE_TYPE = "ressources/icons/folder_at.gif"; //$NON-NLS-1$

Added: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/preferences/HierarchyViewPreferencePage.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/preferences/HierarchyViewPreferencePage.java?view=auto&rev=509199
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/preferences/HierarchyViewPreferencePage.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/preferences/HierarchyViewPreferencePage.java Mon Feb 19 05:41:26 2007
@@ -0,0 +1,460 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.schemas.view.preferences;
+
+
+import org.apache.directory.ldapstudio.schemas.Activator;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+
+/**
+ * This class implements the Preference page for the Hierarchy View
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class HierarchyViewPreferencePage extends PreferencePage implements IWorkbenchPreferencePage
+{
+    /** The preference page ID */
+    public static final String ID = Activator.PLUGIN_ID + ".preferences.hierarchyView";
+
+    /** The First Name category */
+    private static final String FIRST_NAME = "First Name";
+
+    /** The All Aliases category */
+    private static final String ALL_ALIASES = "All Aliases";
+
+    /** The OID category */
+    private static final String OID = "OID";
+
+    /** The preference ID for Label */
+    public static final String PREFS_HIERARCHY_VIEW_LABEL = HierarchyViewPreferencePage.ID + ".label.labelValue";
+
+    /** The preference value for First Name label */
+    public static final int PREFS_HIERARCHY_VIEW_LABEL_FIRST_NAME = 0;
+
+    /** The preference value for All Aliases label */
+    public static final int PREFS_HIERARCHY_VIEW_LABEL_ALL_ALIASES = 1;
+
+    /** The preference value for OID label */
+    public static final int PREFS_HIERARCHY_VIEW_LABEL_OID = 2;
+
+    /** The preference ID for Abbreviate */
+    public static final String PREFS_HIERARCHY_VIEW_ABBREVIATE = HierarchyViewPreferencePage.ID + ".label.abbreviate";
+
+    /** The preference ID for Abbreviate Max Length*/
+    public static final String PREFS_HIERARCHY_VIEW_ABBREVIATE_MAX_LENGTH = HierarchyViewPreferencePage.ID
+        + ".label.abbreviate.maxLength";
+
+    /** The preference ID for Display Secondary Label */
+    public static final String PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_DISPLAY = HierarchyViewPreferencePage.ID
+        + ".secondaryLabel.display";
+
+    /** The preference ID for Secondary Label */
+    public static final String PREFS_HIERARCHY_VIEW_SECONDARY_LABEL = HierarchyViewPreferencePage.ID
+        + ".secondaryLabel.labelValue";
+
+    /** The preference ID for Abbreviate Secondary Label */
+    public static final String PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_ABBREVIATE = HierarchyViewPreferencePage.ID
+        + ".secondaryLabel.abbreviate";
+
+    /** The preference ID for Abbreviate Secondary Label Max Length*/
+    public static final String PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH = HierarchyViewPreferencePage.ID
+        + ".secondaryLabel.abbreviate.maxLength";
+
+    // UI fields
+    private Combo labelCombo;
+    private Button limitButton;
+    private Text lengthText;
+    private Button secondaryLabelButtonDisplay;
+    private Combo secondaryLabelCombo;
+    private Button secondaryLabelLimitButton;
+    private Text secondaryLabelLengthText;
+
+
+    /**
+     * Creates a new instance of HierarchyViewPreferencePage.
+     */
+    public HierarchyViewPreferencePage()
+    {
+        super();
+        super.setPreferenceStore( Activator.getDefault().getPreferenceStore() );
+        super.setDescription( "General settings for the Schemas Editor Hierarchy View" );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
+     */
+    protected Control createContents( Composite parent )
+    {
+        Composite composite = new Composite( parent, SWT.NONE );
+        GridLayout gl = new GridLayout( 1, false );
+        gl.marginHeight = gl.marginWidth = 0;
+        composite.setLayout( gl );
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = 1;
+        composite.setLayoutData( gd );
+
+        // Label Group
+        Group labelGroup = new Group( composite, SWT.NONE );
+        labelGroup.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+        labelGroup.setText( "Label" );
+        labelGroup.setLayout( new GridLayout() );
+        Composite labelGroupComposite = new Composite( labelGroup, SWT.NONE );
+        gl = new GridLayout( 1, false );
+        gl.marginHeight = gl.marginWidth = 0;
+        labelGroupComposite.setLayout( gl );
+        labelGroupComposite.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+
+        // Label row composite
+        Composite labelComposite = new Composite( labelGroupComposite, SWT.NONE );
+        gl = new GridLayout( 3, false );
+        gl.marginHeight = gl.marginWidth = 0;
+        labelComposite.setLayout( gl );
+        gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = 1;
+        labelComposite.setLayoutData( gd );
+
+        // Use Label
+        Label useLabel = new Label( labelComposite, SWT.NONE );
+        useLabel.setText( "Use" );
+
+        // Label Combo
+        labelCombo = new Combo( labelComposite, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER );
+        labelCombo.setLayoutData( new GridData() );
+        labelCombo.setItems( new String[]
+            { FIRST_NAME, ALL_ALIASES, OID } );
+        labelCombo.setEnabled( true );
+
+        // As label Label
+        Label asLabel = new Label( labelComposite, SWT.NONE );
+        asLabel.setText( "as label." );
+
+        // Abbreviate row composite
+        Composite abbreviateComposite = new Composite( labelGroupComposite, SWT.NONE );
+        gl = new GridLayout( 3, false );
+        gl.marginHeight = gl.marginWidth = 0;
+        abbreviateComposite.setLayout( gl );
+        gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = 1;
+        abbreviateComposite.setLayoutData( gd );
+
+        // Limit label lenght to Label
+        limitButton = new Button( abbreviateComposite, SWT.CHECK );
+        limitButton.setText( "Limit label length to" );
+        gd = new GridData();
+        gd.horizontalSpan = 1;
+        limitButton.setLayoutData( gd );
+
+        // Lenght Text
+        lengthText = new Text( abbreviateComposite, SWT.NONE | SWT.BORDER );
+        GridData gridData = new GridData();
+        gridData.horizontalSpan = 1;
+        gridData.widthHint = 9 * 3;
+        lengthText.setLayoutData( gridData );
+        lengthText.setTextLimit( 3 );
+        lengthText.addVerifyListener( new VerifyListener()
+        {
+            public void verifyText( VerifyEvent e )
+            {
+                if ( !e.text.matches( "[0-9]*" ) )
+                {
+                    e.doit = false;
+                }
+                if ( "".equals( lengthText.getText() ) && e.text.matches( "[0]" ) )
+                {
+                    e.doit = false;
+                }
+            }
+        } );
+
+        // Characters Label
+        Label charactersLabel = new Label( abbreviateComposite, SWT.NONE );
+        charactersLabel.setText( "characters." );
+
+        // Secondary Label Group
+        Group secondaryLabelGroup = new Group( composite, SWT.NONE );
+        secondaryLabelGroup.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+        secondaryLabelGroup.setText( "Secondary label" );
+        secondaryLabelGroup.setLayout( new GridLayout() );
+        Composite secondaryLabelGroupComposite = new Composite( secondaryLabelGroup, SWT.NONE );
+        gl = new GridLayout( 1, false );
+        gl.marginHeight = gl.marginWidth = 0;
+        secondaryLabelGroupComposite.setLayout( gl );
+        secondaryLabelGroupComposite.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+
+        secondaryLabelButtonDisplay = new Button( secondaryLabelGroupComposite, SWT.CHECK );
+        secondaryLabelButtonDisplay.setText( "Display secondary label." );
+
+        // Label row composite
+        Composite secondaryLabelComposite = new Composite( secondaryLabelGroupComposite, SWT.NONE );
+        gl = new GridLayout( 3, false );
+        gl.marginHeight = gl.marginWidth = 0;
+        secondaryLabelComposite.setLayout( gl );
+        gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = 1;
+        secondaryLabelComposite.setLayoutData( gd );
+
+        // Use Label
+        Label useLabel2 = new Label( secondaryLabelComposite, SWT.NONE );
+        useLabel2.setText( "Use" );
+
+        // Label Combo
+        secondaryLabelCombo = new Combo( secondaryLabelComposite, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER );
+        secondaryLabelCombo.setLayoutData( new GridData() );
+        secondaryLabelCombo.setItems( new String[]
+            { FIRST_NAME, ALL_ALIASES, OID } );
+        secondaryLabelCombo.setEnabled( true );
+
+        // As label Label
+        Label asLabel2 = new Label( secondaryLabelComposite, SWT.NONE );
+        asLabel2.setText( "as secondary label." );
+
+        // Abbreviate row composite
+        Composite abbreviateComposite2 = new Composite( secondaryLabelGroup, SWT.NONE );
+        gl = new GridLayout( 3, false );
+        gl.marginHeight = gl.marginWidth = 0;
+        abbreviateComposite2.setLayout( gl );
+        gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = 1;
+        abbreviateComposite2.setLayoutData( gd );
+
+        // Limit label lenght to Label
+        secondaryLabelLimitButton = new Button( abbreviateComposite2, SWT.CHECK );
+        secondaryLabelLimitButton.setText( "Limit secondary label length to" );
+        gd = new GridData();
+        gd.horizontalSpan = 1;
+        secondaryLabelLimitButton.setLayoutData( gd );
+
+        // Lenght Text
+        secondaryLabelLengthText = new Text( abbreviateComposite2, SWT.NONE | SWT.BORDER );
+        gridData = new GridData();
+        gridData.horizontalSpan = 1;
+        gridData.widthHint = 9 * 3;
+        secondaryLabelLengthText.setLayoutData( gridData );
+        secondaryLabelLengthText.setTextLimit( 3 );
+        secondaryLabelLengthText.addVerifyListener( new VerifyListener()
+        {
+            public void verifyText( VerifyEvent e )
+            {
+                if ( !e.text.matches( "[0-9]*" ) )
+                {
+                    e.doit = false;
+                }
+                if ( "".equals( secondaryLabelLengthText.getText() ) && e.text.matches( "[0]" ) )
+                {
+                    e.doit = false;
+                }
+            }
+        } );
+
+        // Characters Label
+        Label secondaryLabelcharactersLabel = new Label( abbreviateComposite2, SWT.NONE );
+        secondaryLabelcharactersLabel.setText( "characters." );
+
+        initFieldsFromPreferences();
+
+        initListeners();
+
+        applyDialogFont( parent );
+
+        return parent;
+    }
+
+
+    /**
+     * Initializes the fields from the preferences store.
+     */
+    private void initFieldsFromPreferences()
+    {
+        IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+
+        labelCombo.select( store.getInt( PREFS_HIERARCHY_VIEW_LABEL ) );
+        limitButton.setSelection( store.getBoolean( PREFS_HIERARCHY_VIEW_ABBREVIATE ) );
+        lengthText.setEnabled( limitButton.getSelection() );
+        lengthText.setText( store.getString( PREFS_HIERARCHY_VIEW_ABBREVIATE_MAX_LENGTH ) );
+
+        secondaryLabelButtonDisplay.setSelection( store.getBoolean( PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_DISPLAY ) );
+        secondaryLabelCombo.select( store.getInt( PREFS_HIERARCHY_VIEW_SECONDARY_LABEL ) );
+        secondaryLabelLimitButton.setSelection( store.getBoolean( PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_ABBREVIATE ) );
+        secondaryLabelLengthText
+            .setText( store.getString( PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH ) );
+        if ( store.getBoolean( PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_DISPLAY ) )
+        {
+            secondaryLabelCombo.setEnabled( true );
+            secondaryLabelLimitButton.setEnabled( true );
+            secondaryLabelLengthText.setEnabled( secondaryLabelLimitButton.getSelection() );
+        }
+        else
+        {
+            secondaryLabelCombo.setEnabled( false );
+            secondaryLabelLimitButton.setEnabled( false );
+            secondaryLabelLengthText.setEnabled( false );
+        }
+    }
+
+
+    /**
+     * Initializes the listeners.
+     */
+    private void initListeners()
+    {
+        limitButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                lengthText.setEnabled( limitButton.getSelection() );
+            }
+        } );
+
+        secondaryLabelButtonDisplay.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                if ( secondaryLabelButtonDisplay.getSelection() )
+                {
+                    secondaryLabelCombo.setEnabled( true );
+                    secondaryLabelLimitButton.setEnabled( true );
+                    secondaryLabelLengthText.setEnabled( secondaryLabelLimitButton.getSelection() );
+                }
+                else
+                {
+                    secondaryLabelCombo.setEnabled( false );
+                    secondaryLabelLimitButton.setEnabled( false );
+                    secondaryLabelLengthText.setEnabled( false );
+                }
+            }
+        } );
+
+        secondaryLabelLimitButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                secondaryLabelLengthText.setEnabled( secondaryLabelLimitButton.getSelection() );
+            }
+        } );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
+     */
+    protected void performDefaults()
+    {
+        IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+
+        labelCombo.select( store.getDefaultInt( PREFS_HIERARCHY_VIEW_LABEL ) );
+        limitButton.setSelection( store.getDefaultBoolean( PREFS_HIERARCHY_VIEW_ABBREVIATE ) );
+        lengthText.setEnabled( limitButton.getSelection() );
+        lengthText.setText( store.getDefaultString( PREFS_HIERARCHY_VIEW_ABBREVIATE_MAX_LENGTH ) );
+
+        secondaryLabelButtonDisplay.setSelection( store
+            .getDefaultBoolean( PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_DISPLAY ) );
+        secondaryLabelCombo.select( store.getDefaultInt( PREFS_HIERARCHY_VIEW_SECONDARY_LABEL ) );
+        secondaryLabelLimitButton.setSelection( store
+            .getDefaultBoolean( PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_ABBREVIATE ) );
+        secondaryLabelLengthText.setText( store
+            .getDefaultString( PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH ) );
+
+        if ( secondaryLabelButtonDisplay.getSelection() )
+        {
+            secondaryLabelCombo.setEnabled( true );
+            secondaryLabelLimitButton.setEnabled( true );
+            secondaryLabelLengthText.setEnabled( secondaryLabelLimitButton.getSelection() );
+        }
+        else
+        {
+            secondaryLabelCombo.setEnabled( false );
+            secondaryLabelLimitButton.setEnabled( false );
+            secondaryLabelLengthText.setEnabled( false );
+        }
+
+        super.performDefaults();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.preference.PreferencePage#performOk()
+     */
+    public boolean performOk()
+    {
+        IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+
+        if ( labelCombo.getItem( labelCombo.getSelectionIndex() ).equals( FIRST_NAME ) )
+        {
+            store.setValue( PREFS_HIERARCHY_VIEW_LABEL, PREFS_HIERARCHY_VIEW_LABEL_FIRST_NAME );
+        }
+        else if ( labelCombo.getItem( labelCombo.getSelectionIndex() ).equals( ALL_ALIASES ) )
+        {
+            store.setValue( PREFS_HIERARCHY_VIEW_LABEL, PREFS_HIERARCHY_VIEW_LABEL_ALL_ALIASES );
+        }
+        else if ( labelCombo.getItem( labelCombo.getSelectionIndex() ).equals( OID ) )
+        {
+            store.setValue( PREFS_HIERARCHY_VIEW_LABEL, PREFS_HIERARCHY_VIEW_LABEL_OID );
+        }
+        store.setValue( PREFS_HIERARCHY_VIEW_ABBREVIATE, limitButton.getSelection() );
+        store.setValue( PREFS_HIERARCHY_VIEW_ABBREVIATE_MAX_LENGTH, lengthText.getText() );
+
+        store.setValue( PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_DISPLAY, secondaryLabelButtonDisplay.getSelection() );
+        if ( secondaryLabelCombo.getItem( secondaryLabelCombo.getSelectionIndex() ).equals( FIRST_NAME ) )
+        {
+            store.setValue( PREFS_HIERARCHY_VIEW_SECONDARY_LABEL, PREFS_HIERARCHY_VIEW_LABEL_FIRST_NAME );
+        }
+        else if ( secondaryLabelCombo.getItem( secondaryLabelCombo.getSelectionIndex() ).equals( ALL_ALIASES ) )
+        {
+            store.setValue( PREFS_HIERARCHY_VIEW_SECONDARY_LABEL, PREFS_HIERARCHY_VIEW_LABEL_ALL_ALIASES );
+        }
+        else if ( secondaryLabelCombo.getItem( secondaryLabelCombo.getSelectionIndex() ).equals( OID ) )
+        {
+            store.setValue( PREFS_HIERARCHY_VIEW_SECONDARY_LABEL, PREFS_HIERARCHY_VIEW_LABEL_OID );
+        }
+        store.setValue( PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_ABBREVIATE, secondaryLabelLimitButton.getSelection() );
+        store.setValue( PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH, secondaryLabelLengthText.getText() );
+
+        return true;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+     */
+    public void init( IWorkbench workbench )
+    {
+    }
+}

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchicalContentProvider.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchicalContentProvider.java?view=diff&rev=509199&r1=509198&r2=509199
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchicalContentProvider.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchicalContentProvider.java Mon Feb 19 05:41:26 2007
@@ -23,7 +23,7 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Comparator;
+import java.util.Collections;
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
@@ -34,11 +34,13 @@
 import org.apache.directory.ldapstudio.schemas.model.AttributeType;
 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.AlphabeticalOrderComparator;
 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.HierarchyViewFirstNameSorter;
+import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.HierarchyViewOidSorter;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.IntermediateNode;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.ObjectClassWrapper;
+import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.viewers.IStructuredContentProvider;
 import org.eclipse.jface.viewers.ITreeContentProvider;
 import org.eclipse.jface.viewers.TreeViewer;
@@ -51,8 +53,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class HierarchicalContentProvider implements SortableContentProvider, IStructuredContentProvider,
-    ITreeContentProvider
+public class HierarchicalContentProvider implements IStructuredContentProvider, ITreeContentProvider
 {
     /** The Schema Pool holding all schemas */
     private SchemaPool schemaPool;
@@ -63,8 +64,11 @@
     /** The HashTable containing all the attribute types */
     private Hashtable<String, AttributeType> attributeTypeTable;
 
-    /** The Order Comparator */
-    private Comparator order = new AlphabeticalOrderComparator();
+    /** The FirstName Sorter */
+    private HierarchyViewFirstNameSorter firstNameSorter;
+
+    /** The OID Sorter */
+    private HierarchyViewOidSorter oidSorter;
 
 
     /**
@@ -79,6 +83,9 @@
 
         objectClassTable = schemaPool.getObjectClassesAsHashTableByName();
         attributeTypeTable = schemaPool.getAttributeTypesAsHashTableByName();
+
+        firstNameSorter = new HierarchyViewFirstNameSorter();
+        oidSorter = new HierarchyViewOidSorter();
     }
 
 
@@ -96,16 +103,20 @@
      */
     public Object[] getChildren( Object parentElement )
     {
+        List<DisplayableTreeElement> children = new ArrayList<DisplayableTreeElement>();
+
+        IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+        int group = store.getInt( HierarchyViewSorterDialog.PREFS_HIERARCHY_VIEW_GROUPING );
+        int sortBy = store.getInt( HierarchyViewSorterDialog.PREFS_HIERARCHY_VIEW_SORTING_BY );
+        int sortOrder = store.getInt( HierarchyViewSorterDialog.PREFS_HIERARCHY_VIEW_SORTING_ORDER );
+
         if ( parentElement instanceof ObjectClassWrapper )
         {
             //we are looking for the childrens of the contained objectClass
             ObjectClass objectClass = ( ( ObjectClassWrapper ) parentElement ).getMyObjectClass();
 
-            List<ObjectClassWrapper> subTypes = new ArrayList<ObjectClassWrapper>();
-
             //-> we need to compare each and every other objectClass's sup against them 
             //-> we also need to find a better way to do this (complexity wise)
-
             Collection<ObjectClass> objectClasses = objectClassTable.values();
             for ( Iterator iter = objectClasses.iterator(); iter.hasNext(); )
             {
@@ -124,7 +135,7 @@
                             if ( oClassSup.equals( objectClass ) )
                             {
                                 //we use an objectClass wrapper
-                                subTypes
+                                children
                                     .add( new ObjectClassWrapper( oClass, ( DisplayableTreeElement ) parentElement ) );
                                 break; //break only the inner for
                             }
@@ -133,19 +144,31 @@
                 }
             }
 
-            return subTypes.toArray();
-        }
+            // Sort by
+            if ( sortBy == HierarchyViewSorterDialog.PREFS_HIERARCHY_VIEW_SORTING_BY_FIRSTNAME )
+            {
+
+                Collections.sort( children, firstNameSorter );
+            }
+            else if ( sortBy == HierarchyViewSorterDialog.PREFS_HIERARCHY_VIEW_SORTING_BY_OID )
+            {
+
+                Collections.sort( children, oidSorter );
+            }
 
+            // Sort order
+            if ( sortOrder == HierarchyViewSorterDialog.PREFS_HIERARCHY_VIEW_SORTING_ORDER_DESCENDING )
+            {
+                Collections.reverse( children );
+            }
+        }
         if ( parentElement instanceof AttributeTypeWrapper )
         {
             //we are looking for the childrens of the contained attribute type
             AttributeType attributeType = ( ( AttributeTypeWrapper ) parentElement ).getMyAttributeType();
 
-            List<AttributeTypeWrapper> subTypes = new ArrayList<AttributeTypeWrapper>();
-
             //-> we need to compare each and every other attribute type sup against them 
             //-> we also need to find a better way to do this (complexity wise)
-
             Collection<AttributeType> attributeTypes = attributeTypeTable.values();
             for ( Iterator iter = attributeTypes.iterator(); iter.hasNext(); )
             {
@@ -164,7 +187,7 @@
                             if ( aTypeSup.equals( attributeType ) )
                             {
                                 //we use an objectClass wrapper
-                                subTypes
+                                children
                                     .add( new AttributeTypeWrapper( aType, ( DisplayableTreeElement ) parentElement ) );
                                 break; //break only the inner for
                             }
@@ -173,23 +196,33 @@
                 }
             }
 
-            return subTypes.toArray();
-        }
+            // Sort by
+            if ( sortBy == HierarchyViewSorterDialog.PREFS_HIERARCHY_VIEW_SORTING_BY_FIRSTNAME )
+            {
 
+                Collections.sort( children, firstNameSorter );
+            }
+            else if ( sortBy == HierarchyViewSorterDialog.PREFS_HIERARCHY_VIEW_SORTING_BY_OID )
+            {
+
+                Collections.sort( children, oidSorter );
+            }
+
+            // Sort order
+            if ( sortOrder == HierarchyViewSorterDialog.PREFS_HIERARCHY_VIEW_SORTING_ORDER_DESCENDING )
+            {
+                Collections.reverse( children );
+            }
+        }
         else if ( parentElement instanceof IntermediateNode )
         {
             IntermediateNode intermediate = ( IntermediateNode ) parentElement;
 
-            if ( intermediate.getName().equals( "**Primary Node**" ) ) { //$NON-NLS-1$
-                //if we are asked for the primary node it's because the whole viewer
-                //is beeing refreshed 
-                // -> the pool has been modified or it's the first display
-                // -> we need to regenerate the hashmaps containing the schemas elements
+            if ( intermediate.getName().equals( "**Primary Node**" ) ) //$NON-NLS-1$
+            {
                 refreshOcsAndAts();
 
-                //clear the primary node (because it's always the same instance we need to
-                //refresh it manually)
-                intermediate.clearChildrens();
+                List<ObjectClassWrapper> ocList = new ArrayList<ObjectClassWrapper>();
                 if ( !Activator.getDefault().getDialogSettings().getBoolean(
                     HideObjectClassesAction.HIDE_OBJECT_CLASSES_DS_KEY ) )
                 {
@@ -198,7 +231,7 @@
                     if ( top != null )
                     {
                         ObjectClassWrapper topWrapper = new ObjectClassWrapper( top, intermediate );
-                        intermediate.addElement( topWrapper );
+                        ocList.add( topWrapper );
                     }
 
                     //add the unresolved object-classes to the top of the hierarchy
@@ -212,7 +245,7 @@
                         {
                             ObjectClassWrapper wrapper = new ObjectClassWrapper( oClass, intermediate );
                             wrapper.setState( ObjectClassWrapper.State.unResolved );
-                            intermediate.addElement( wrapper );
+                            ocList.add( wrapper );
                             this.hasChildren( wrapper );
                         }
                         else
@@ -224,13 +257,14 @@
                                 {
                                     ObjectClassWrapper wrapper = new ObjectClassWrapper( oClass, intermediate );
                                     wrapper.setState( ObjectClassWrapper.State.unResolved );
-                                    intermediate.addElement( wrapper );
+                                    ocList.add( wrapper );
                                 }
                             }
                         }
                     }
                 }
 
+                List<AttributeTypeWrapper> atList = new ArrayList<AttributeTypeWrapper>();
                 if ( !Activator.getDefault().getDialogSettings().getBoolean(
                     HideAttributeTypesAction.HIDE_ATTRIBUTE_TYPES_DS_KEY ) )
                 {
@@ -244,15 +278,89 @@
                         if ( sup == null )
                         {
                             AttributeTypeWrapper wrapper = new AttributeTypeWrapper( aType, intermediate );
-                            intermediate.addElement( wrapper );
+                            atList.add( wrapper );
                         }
                     }
                 }
-            }
 
-            return intermediate.getChildren();
+                if ( group == HierarchyViewSorterDialog.PREFS_HIERARCHY_VIEW_GROUPING_ATFIRST )
+                {
+                    // Sort by
+                    if ( sortBy == HierarchyViewSorterDialog.PREFS_HIERARCHY_VIEW_SORTING_BY_FIRSTNAME )
+                    {
+                        Collections.sort( atList, firstNameSorter );
+                        Collections.sort( ocList, firstNameSorter );
+                    }
+                    else if ( sortBy == HierarchyViewSorterDialog.PREFS_HIERARCHY_VIEW_SORTING_BY_OID )
+                    {
+                        Collections.sort( atList, oidSorter );
+                        Collections.sort( ocList, oidSorter );
+                    }
+
+                    // Sort Order
+                    if ( sortOrder == HierarchyViewSorterDialog.PREFS_HIERARCHY_VIEW_SORTING_ORDER_DESCENDING )
+                    {
+                        Collections.reverse( atList );
+                        Collections.reverse( ocList );
+                    }
+
+                    // Group
+                    children.addAll( atList );
+                    children.addAll( ocList );
+                }
+                else if ( group == HierarchyViewSorterDialog.PREFS_HIERARCHY_VIEW_GROUPING_OCFIRST )
+                {
+                    // Sort by
+                    if ( sortBy == HierarchyViewSorterDialog.PREFS_HIERARCHY_VIEW_SORTING_BY_FIRSTNAME )
+                    {
+                        Collections.sort( atList, firstNameSorter );
+                        Collections.sort( ocList, firstNameSorter );
+                    }
+                    else if ( sortBy == HierarchyViewSorterDialog.PREFS_HIERARCHY_VIEW_SORTING_BY_OID )
+                    {
+                        Collections.sort( atList, oidSorter );
+                        Collections.sort( ocList, oidSorter );
+                    }
+
+                    // Sort Order
+                    if ( sortOrder == HierarchyViewSorterDialog.PREFS_HIERARCHY_VIEW_SORTING_ORDER_DESCENDING )
+                    {
+                        Collections.reverse( atList );
+                        Collections.reverse( ocList );
+                    }
+
+                    // Group
+                    children.addAll( ocList );
+                    children.addAll( atList );
+                }
+                else if ( group == HierarchyViewSorterDialog.PREFS_HIERARCHY_VIEW_GROUPING_MIXED )
+                {
+                    // Group
+                    children.addAll( atList );
+                    children.addAll( ocList );
+
+                    // Sort by
+                    if ( sortBy == HierarchyViewSorterDialog.PREFS_HIERARCHY_VIEW_SORTING_BY_FIRSTNAME )
+                    {
+
+                        Collections.sort( children, firstNameSorter );
+                    }
+                    else if ( sortBy == HierarchyViewSorterDialog.PREFS_HIERARCHY_VIEW_SORTING_BY_OID )
+                    {
+
+                        Collections.sort( children, oidSorter );
+                    }
+
+                    // Sort order
+                    if ( sortOrder == HierarchyViewSorterDialog.PREFS_HIERARCHY_VIEW_SORTING_ORDER_DESCENDING )
+                    {
+                        Collections.reverse( children );
+                    }
+                }
+            }
         }
-        return new Object[0];
+
+        return children.toArray();
     }
 
 
@@ -293,7 +401,7 @@
         }
         else if ( element instanceof IntermediateNode )
         {
-            return ( ( IntermediateNode ) element ).getChildren().length > 0;
+            return getChildren( ( IntermediateNode ) element ).length > 0;
         }
 
         return false;
@@ -312,29 +420,6 @@
 
 
     /**
-     * Specify the comparator that will be used to sort the elements in the view.
-     * 
-     * @param order
-     *      the comparator
-     */
-    public void setOrder( Comparator order )
-    {
-        this.order = order;
-    }
-
-
-    /**
-     * Returns the comparator used to sort the elements in the view.
-     * 
-     * @return
-     */
-    public Comparator getOrder()
-    {
-        return order;
-    }
-
-
-    /**
      * Initialize a tree viewer to display the information provided by the specified content
      * provider.
      * 
@@ -346,7 +431,7 @@
         viewer.setContentProvider( this );
         viewer.setLabelProvider( new HierarchicalLabelProvider() );
 
-        IntermediateNode invisibleNode = new IntermediateNode( "**Primary Node**", null, this ); //$NON-NLS-1$
+        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/HierarchicalLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchicalLabelProvider.java?view=diff&rev=509199&r1=509198&r2=509199
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchicalLabelProvider.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchicalLabelProvider.java Mon Feb 19 05:41:26 2007
@@ -21,7 +21,12 @@
 package org.apache.directory.ldapstudio.schemas.view.viewers;
 
 
+import org.apache.directory.ldapstudio.schemas.Activator;
+import org.apache.directory.ldapstudio.schemas.view.preferences.HierarchyViewPreferencePage;
+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.ObjectClassWrapper;
+import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.ui.ISharedImages;
@@ -36,16 +41,155 @@
  */
 public class HierarchicalLabelProvider extends LabelProvider
 {
+    /** The preferences store */
+    private IPreferenceStore store;
+
+
+    /**
+     * Creates a new instance of HierarchicalLabelProvider.
+     */
+    public HierarchicalLabelProvider()
+    {
+        store = Activator.getDefault().getPreferenceStore();
+    }
+
+
     /* (non-Javadoc)
      * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
      */
     public String getText( Object obj )
     {
-        if ( obj instanceof DisplayableTreeElement )
-            return ( ( DisplayableTreeElement ) obj ).getDisplayName();
+        String label = "";
+
+        int labelValue = store.getInt( HierarchyViewPreferencePage.PREFS_HIERARCHY_VIEW_LABEL );
+        boolean abbreviate = store.getBoolean( HierarchyViewPreferencePage.PREFS_HIERARCHY_VIEW_ABBREVIATE );
+        int abbreviateMaxLength = store.getInt( HierarchyViewPreferencePage.PREFS_HIERARCHY_VIEW_ABBREVIATE_MAX_LENGTH );
+        boolean secondaryLabelDisplay = store
+            .getBoolean( HierarchyViewPreferencePage.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_DISPLAY );
+        int secondaryLabelValue = store.getInt( HierarchyViewPreferencePage.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL );
+        boolean secondaryLabelAbbreviate = store
+            .getBoolean( HierarchyViewPreferencePage.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_ABBREVIATE );
+        int secondaryLabelAbbreviateMaxLength = store
+            .getInt( HierarchyViewPreferencePage.PREFS_HIERARCHY_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH );
 
+        if ( obj instanceof AttributeTypeWrapper )
+        {
+            if ( labelValue == HierarchyViewPreferencePage.PREFS_HIERARCHY_VIEW_LABEL_FIRST_NAME )
+            {
+                label = ( ( AttributeTypeWrapper ) obj ).getMyAttributeType().getNames()[0];
+            }
+            else if ( labelValue == HierarchyViewPreferencePage.PREFS_HIERARCHY_VIEW_LABEL_ALL_ALIASES )
+            {
+                label = concateNames( ( ( AttributeTypeWrapper ) obj ).getMyAttributeType().getNames() );
+            }
+            else if ( labelValue == HierarchyViewPreferencePage.PREFS_HIERARCHY_VIEW_LABEL_OID )
+            {
+                label = ( ( AttributeTypeWrapper ) obj ).getMyAttributeType().getOid();
+            }
+            else
+            // Default
+            {
+                label = ( ( AttributeTypeWrapper ) obj ).getMyAttributeType().getNames()[0];
+            }
+        }
+        else if ( obj instanceof ObjectClassWrapper )
+        {
+            if ( labelValue == HierarchyViewPreferencePage.PREFS_HIERARCHY_VIEW_LABEL_FIRST_NAME )
+            {
+                label = ( ( ObjectClassWrapper ) obj ).getMyObjectClass().getNames()[0];
+            }
+            else if ( labelValue == HierarchyViewPreferencePage.PREFS_HIERARCHY_VIEW_LABEL_ALL_ALIASES )
+            {
+                label = concateNames( ( ( ObjectClassWrapper ) obj ).getMyObjectClass().getNames() );
+            }
+            else if ( labelValue == HierarchyViewPreferencePage.PREFS_HIERARCHY_VIEW_LABEL_OID )
+            {
+                label = ( ( ObjectClassWrapper ) obj ).getMyObjectClass().getOid();
+            }
+            else
+            // Default
+            {
+                label = ( ( ObjectClassWrapper ) obj ).getMyObjectClass().getNames()[0];
+            }
+        }
+        else
         // Default
-        return obj.toString();
+        {
+            label = obj.toString();
+        }
+
+        if ( abbreviate && ( abbreviateMaxLength < label.length() ) )
+        {
+            label = label.substring( 0, abbreviateMaxLength ) + "...";
+        }
+
+        if ( secondaryLabelDisplay )
+        {
+            String secondaryLabel = "";
+            if ( obj instanceof AttributeTypeWrapper )
+            {
+                if ( secondaryLabelValue == HierarchyViewPreferencePage.PREFS_HIERARCHY_VIEW_LABEL_FIRST_NAME )
+                {
+                    secondaryLabel = ( ( AttributeTypeWrapper ) obj ).getMyAttributeType().getNames()[0];
+                }
+                else if ( secondaryLabelValue == HierarchyViewPreferencePage.PREFS_HIERARCHY_VIEW_LABEL_ALL_ALIASES )
+                {
+                    secondaryLabel = concateNames( ( ( AttributeTypeWrapper ) obj ).getMyAttributeType().getNames() );
+                }
+                else if ( secondaryLabelValue == HierarchyViewPreferencePage.PREFS_HIERARCHY_VIEW_LABEL_OID )
+                {
+                    secondaryLabel = ( ( AttributeTypeWrapper ) obj ).getMyAttributeType().getOid();
+                }
+            }
+            else if ( obj instanceof ObjectClassWrapper )
+            {
+                if ( secondaryLabelValue == HierarchyViewPreferencePage.PREFS_HIERARCHY_VIEW_LABEL_FIRST_NAME )
+                {
+                    secondaryLabel = ( ( ObjectClassWrapper ) obj ).getMyObjectClass().getNames()[0];
+                }
+                else if ( secondaryLabelValue == HierarchyViewPreferencePage.PREFS_HIERARCHY_VIEW_LABEL_ALL_ALIASES )
+                {
+                    secondaryLabel = concateNames( ( ( ObjectClassWrapper ) obj ).getMyObjectClass().getNames() );
+                }
+                else if ( secondaryLabelValue == HierarchyViewPreferencePage.PREFS_HIERARCHY_VIEW_LABEL_OID )
+                {
+                    secondaryLabel = ( ( ObjectClassWrapper ) obj ).getMyObjectClass().getOid();
+                }
+            }
+
+            if ( secondaryLabelAbbreviate && ( secondaryLabelAbbreviateMaxLength < secondaryLabel.length() ) )
+            {
+                secondaryLabel = secondaryLabel.substring( 0, secondaryLabelAbbreviateMaxLength ) + "...";
+            }
+
+            label += "   [" + secondaryLabel + "]";
+        }
+
+        return label;
+    }
+
+
+    /**
+     * Concatenates all aliases in a String format
+     *
+     * @param aliases
+     *      the aliases to concatenate
+     * @return
+     *      a String representing all aliases
+     */
+    private String concateNames( String[] aliases )
+    {
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( aliases[0] );
+
+        for ( int i = 1; i < aliases.length; i++ )
+        {
+            sb.append( ", " );
+            sb.append( aliases[i] );
+        }
+
+        return sb.toString();
     }
 
 

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchicalViewer.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchicalViewer.java?view=diff&rev=509199&r1=509198&r2=509199
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchicalViewer.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchicalViewer.java Mon Feb 19 05:41:26 2007
@@ -21,8 +21,6 @@
 package org.apache.directory.ldapstudio.schemas.view.viewers;
 
 
-import java.util.Comparator;
-
 import org.apache.directory.ldapstudio.schemas.controller.Application;
 import org.apache.directory.ldapstudio.schemas.controller.HierarchicalViewerController;
 import org.apache.directory.ldapstudio.schemas.model.LDAPModelEvent;
@@ -57,16 +55,16 @@
      * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
      */
     public void createPartControl( Composite parent )
-    { 
+    {
         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 HierarchicalViewerController( this );
     }
@@ -111,17 +109,6 @@
         {
             viewer.setExpandedState( object, true );
         }
-    }
-
-
-    /**
-     * Specify the comparator that will be used to sort the elements in that viewer
-     * @param order the comparator
-     */
-    public void setOrder( Comparator order )
-    {
-        contentProvider.setOrder( order );
-        refresh();
     }
 
 



Mime
View raw message