directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r519067 - in /directory/ldapstudio/trunk/ldapstudio-schemas-plugin: ressources/icons/ src/main/java/org/apache/directory/ldapstudio/schemas/ src/main/java/org/apache/directory/ldapstudio/schemas/controller/ src/main/java/org/apache/director...
Date Fri, 16 Mar 2007 17:13:23 GMT
Author: pamarcelot
Date: Fri Mar 16 10:13:21 2007
New Revision: 519067

URL: http://svn.apache.org/viewvc?view=rev&rev=519067
Log:
Added correct behavior for Hierarchy View.
Added two types of display : supertypes display and subtypes displays.
Added a Link With Editor Action.

Added:
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/ressources/icons/hierarchy_subtype.png   (with props)
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/ressources/icons/hierarchy_supertype.png   (with props)
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/HierarchyViewController.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/ShowSubtypeHierarchyAction.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/ShowSupertypeHierarchyAction.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyViewContentProvider.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyViewLabelProvider.java
Modified:
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/PluginConstants.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyView.java

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

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

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

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

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/PluginConstants.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/PluginConstants.java?view=diff&rev=519067&r1=519066&r2=519067
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/PluginConstants.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/PluginConstants.java Fri Mar 16 10:13:21 2007
@@ -152,10 +152,20 @@
     public static final int PREFS_SCHEMAS_VIEW_SORTING_ORDER_DESCENDING = 1;
 
     // Preferences - Search View
-
     /** The preference ID for Search History of the Search View */
     public static final String PREFS_SEARCH_VIEW_SEARCH_HISTORY = Activator.PLUGIN_ID
-        + ".preferences.SearchView.searchHistory";;
+        + ".preferences.SearchView.searchHistory";
+    
+    // Preferences - Hierarchy View
+    /** The preference ID for Mode of the Hierarchy View */
+    public static final String PREFS_HIERARCHY_VIEW_MODE = Activator.PLUGIN_ID
+        + ".preferences.HierarchyView.mode";
+    
+    /** The preference value for Schemas View Mode 'Supertype' */
+    public static final int PREFS_HIERARCHY_VIEW_MODE_SUPERTYPE = 0;
+    
+    /** The preference value for Schemas View Mode 'Subtype' */
+    public static final int PREFS_HIERARCHY_VIEW_MODE_SUBTYPE = 1;
 
     // Images - Actions
     public static final String IMG_ABOUT = "ressources/icons/flag_blue.png"; //$NON-NLS-1$
@@ -175,6 +185,8 @@
     public static final String IMG_SAVE_AS = "ressources/icons/save_as.png"; //$NON-NLS-1$
     public static final String IMG_SAVE_ALL = "ressources/icons/save_all.png"; //$NON-NLS-1$
     public static final String IMG_SHOW_PREFERENCES = "ressources/icons/preferences.png"; //$NON-NLS-1$
+    public static final String IMG_SHOW_SUBTYPE_HIERARCHY = "ressources/icons/hierarchy_subtype.png"; //$NON-NLS-1$
+    public static final String IMG_SHOW_SUPERTYPE_HIERARCHY = "ressources/icons/hierarchy_supertype.png"; //$NON-NLS-1$
     public static final String IMG_SORT = "ressources/icons/sort.gif"; //$NON-NLS-1$
 
     // Images - Views
@@ -219,4 +231,6 @@
     public static final String CMD_SAVE = Activator.PLUGIN_ID + ".cmd.Save"; //$NON-NLS-1$
     public static final String CMD_SAVE_AS = Activator.PLUGIN_ID + ".cmd.SaveAs"; //$NON-NLS-1$
     public static final String CMD_SAVE_ALL = Activator.PLUGIN_ID + ".cmd.SaveAll"; //$NON-NLS-1$
+    public static final String CMD_SHOW_SUBTYPE_HIERARCHY = Activator.PLUGIN_ID + ".cmd.ShowSubtypeHierarchy"; //$NON-NLS-1$
+    public static final String CMD_SHOW_SUPERTYPE_HIERARCHY = Activator.PLUGIN_ID + ".cmd.ShowSupertypeHierarchy"; //$NON-NLS-1$
 }

Added: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/HierarchyViewController.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/HierarchyViewController.java?view=auto&rev=519067
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/HierarchyViewController.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/HierarchyViewController.java Fri Mar 16 10:13:21 2007
@@ -0,0 +1,224 @@
+/*
+ *  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;
+
+
+import java.util.List;
+
+import org.apache.directory.ldapstudio.schemas.Activator;
+import org.apache.directory.ldapstudio.schemas.PluginConstants;
+import org.apache.directory.ldapstudio.schemas.controller.actions.LinkWithEditorHierarchyView;
+import org.apache.directory.ldapstudio.schemas.controller.actions.ShowSubtypeHierarchyAction;
+import org.apache.directory.ldapstudio.schemas.controller.actions.ShowSupertypeHierarchyAction;
+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.HierarchyView;
+import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.AttributeTypeWrapper;
+import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.ObjectClassWrapper;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * This class implements the Controller for the Hierarchy View
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class HierarchyViewController
+{
+    /** The associated view */
+    private HierarchyView view;
+
+    /** The authorized Preferences keys*/
+    List<String> authorizedPrefs;
+
+    // The Actions
+    private Action showSupertypeHierarchy;
+    private Action showSubtypeHierarchy;
+    private Action linkWithEditor;
+
+
+    /**
+     * Creates a new instance of SchemasViewController.
+     *
+     * @param view
+     *      the associated view
+     */
+    public HierarchyViewController( HierarchyView view )
+    {
+        this.view = view;
+
+        initAuthorizedPrefs();
+        initActions();
+        initToolbar();
+        initMenu();
+        initDoubleClickListener();
+        initPreferencesListener();
+    }
+
+
+    /**
+     * Initializes the values for the authorized preferences.
+     */
+    private void initAuthorizedPrefs()
+    {
+        //        authorizedPrefs = new ArrayList<String>();
+        //        authorizedPrefs.add( PluginConstants.PREFS_SCHEMAS_VIEW_LABEL );
+        //        authorizedPrefs.add( PluginConstants.PREFS_SCHEMAS_VIEW_ABBREVIATE );
+        //        authorizedPrefs.add( PluginConstants.PREFS_SCHEMAS_VIEW_ABBREVIATE_MAX_LENGTH );
+        //        authorizedPrefs.add( PluginConstants.PREFS_SCHEMAS_VIEW_GROUPING );
+        //        authorizedPrefs.add( PluginConstants.PREFS_SCHEMAS_VIEW_SORTING_BY );
+        //        authorizedPrefs.add( PluginConstants.PREFS_SCHEMAS_VIEW_SORTING_ORDER );
+    }
+
+
+    /**
+     * Initializes the Actions.
+     */
+    private void initActions()
+    {
+        // Setting up the default key value (if needed)
+        if ( Activator.getDefault().getDialogSettings().get( PluginConstants.PREFS_HIERARCHY_VIEW_MODE ) == null )
+        {
+            Activator.getDefault().getDialogSettings().put( PluginConstants.PREFS_HIERARCHY_VIEW_MODE,
+                PluginConstants.PREFS_HIERARCHY_VIEW_MODE_SUPERTYPE );
+        }
+        showSupertypeHierarchy = new ShowSupertypeHierarchyAction( view );
+        showSubtypeHierarchy = new ShowSubtypeHierarchyAction( view );
+        linkWithEditor = new LinkWithEditorHierarchyView( view );
+    }
+
+
+    /**
+     * Initializes the Toolbar.
+     */
+    private void initToolbar()
+    {
+        IToolBarManager toolbar = view.getViewSite().getActionBars().getToolBarManager();
+        toolbar.add( showSupertypeHierarchy );
+        toolbar.add( showSubtypeHierarchy );
+    }
+
+
+    /**
+     * Initializes the Menu.
+     */
+    private void initMenu()
+    {
+        IMenuManager menu = view.getViewSite().getActionBars().getMenuManager();
+        menu.add( showSupertypeHierarchy );
+        menu.add( showSubtypeHierarchy );
+        menu.add( new Separator() );
+        menu.add( linkWithEditor );
+    }
+
+
+    /**
+     * Initializes the DoubleClickListener.
+     */
+    private void initDoubleClickListener()
+    {
+        view.getViewer().addDoubleClickListener( new IDoubleClickListener()
+        {
+            /**
+             * {@inheritDoc}
+             */
+            public void doubleClick( DoubleClickEvent event )
+            {
+                // What we get from the treeViewer is a StructuredSelection
+                StructuredSelection selection = ( StructuredSelection ) event.getSelection();
+
+                // Here's the real object (an AttributeTypeWrapper, ObjectClassWrapper or IntermediateNode)
+                Object objectSelection = selection.getFirstElement();
+                IEditorInput input = null;
+                String editorId = null;
+
+                // Selecting the right editor and input
+                if ( objectSelection instanceof AttributeTypeWrapper )
+                {
+                    input = new AttributeTypeFormEditorInput( ( ( AttributeTypeWrapper ) objectSelection )
+                        .getMyAttributeType() );
+                    editorId = AttributeTypeFormEditor.ID;
+                }
+                else if ( objectSelection instanceof ObjectClassWrapper )
+                {
+                    input = new ObjectClassFormEditorInput( ( ( ObjectClassWrapper ) objectSelection )
+                        .getMyObjectClass() );
+                    editorId = ObjectClassFormEditor.ID;
+                }
+
+                // Let's open the editor
+                if ( input != null )
+                {
+                    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+                    try
+                    {
+                        page.openEditor( input, editorId );
+                    }
+                    catch ( PartInitException e )
+                    {
+                        // TODO ADD A LOGGER
+                    }
+                }
+            }
+        } );
+    }
+
+
+    /**
+     * 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 )
+        //            {
+        //                if ( authorizedPrefs.contains( event.getProperty() ) )
+        //                {
+        //                    if ( PluginConstants.PREFS_SCHEMAS_VIEW_GROUPING == event.getProperty() )
+        //                    {
+        //                        view.completeRefresh();
+        //                    }
+        //                    else
+        //                    {
+        //                        view.refresh();
+        //                    }
+        //                }
+        //            }
+        //        } );
+    }
+}

Added: 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=auto&rev=519067
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/LinkWithEditorHierarchyView.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/LinkWithEditorHierarchyView.java Fri Mar 16 10:13:21 2007
@@ -0,0 +1,218 @@
+/*
+ *  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.Activator;
+import org.apache.directory.ldapstudio.schemas.PluginConstants;
+import org.apache.directory.ldapstudio.schemas.model.SchemaPool;
+import org.apache.directory.ldapstudio.schemas.view.editors.AttributeTypeFormEditor;
+import org.apache.directory.ldapstudio.schemas.view.editors.ObjectClassFormEditor;
+import org.apache.directory.ldapstudio.schemas.view.editors.SchemaFormEditor;
+import org.apache.directory.ldapstudio.schemas.view.viewers.HierarchyView;
+import org.eclipse.jface.action.Action;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IPartListener2;
+import org.eclipse.ui.IWorkbenchPartReference;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class implements the Link With Editor Action for the Hierarchy View
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class LinkWithEditorHierarchyView extends Action
+{
+    /** The String for storing the checked state of the action */
+    private static final String LINK_WITH_EDITOR_HIERARCHY_VIEW_DS_KEY = LinkWithEditorHierarchyView.class.getName()
+        + ".dialogsettingkey";
+
+    /** The associated view */
+    private HierarchyView view;
+
+    /** The Schema Pool */
+    private SchemaPool schemaPool;
+
+    /** The listener listening on changes on editors */
+    private IPartListener2 editorListener = new IPartListener2()
+    {
+        /* (non-Javadoc)
+         * @see org.eclipse.ui.IPartListener2#partVisible(org.eclipse.ui.IWorkbenchPartReference)
+         */
+        public void partVisible( IWorkbenchPartReference partRef )
+        {
+            String id = partRef.getId();
+
+            if ( id.equals( ObjectClassFormEditor.ID ) || id.equals( AttributeTypeFormEditor.ID )
+                || id.equals( SchemaFormEditor.ID ) )
+            {
+                linkViewWithEditor( partRef.getPartName(), id );
+            }
+        }
+
+
+        /* (non-Javadoc)
+         * @see org.eclipse.ui.IPartListener2#partActivated(org.eclipse.ui.IWorkbenchPartReference)
+         */
+        public void partActivated( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /* (non-Javadoc)
+         * @see org.eclipse.ui.IPartListener2#partClosed(org.eclipse.ui.IWorkbenchPartReference)
+         */
+        public void partClosed( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /* (non-Javadoc)
+         * @see org.eclipse.ui.IPartListener2#partDeactivated(org.eclipse.ui.IWorkbenchPartReference)
+         */
+        public void partDeactivated( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /* (non-Javadoc)
+         * @see org.eclipse.ui.IPartListener2#partHidden(org.eclipse.ui.IWorkbenchPartReference)
+         */
+        public void partHidden( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /* (non-Javadoc)
+         * @see org.eclipse.ui.IPartListener2#partInputChanged(org.eclipse.ui.IWorkbenchPartReference)
+         */
+        public void partInputChanged( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /* (non-Javadoc)
+         * @see org.eclipse.ui.IPartListener2#partOpened(org.eclipse.ui.IWorkbenchPartReference)
+         */
+        public void partOpened( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /* (non-Javadoc)
+         * @see org.eclipse.ui.IPartListener2#partBroughtToTop(org.eclipse.ui.IWorkbenchPartReference)
+         */
+        public void partBroughtToTop( IWorkbenchPartReference partRef )
+        {
+        }
+    };
+
+
+    /**
+     * Creates a new instance of LinkWithEditorSchemasView.
+     *
+     * @param view
+     *      the associated view
+     */
+    public LinkWithEditorHierarchyView( HierarchyView view )
+    {
+        super( "Link with Editor", AS_CHECK_BOX );
+        setToolTipText( getText() );
+        setId( PluginConstants.CMD_LINK_WITH_EDITOR_SCHEMA_VIEW );
+        setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+            PluginConstants.IMG_LINK_WITH_EDITOR ) );
+        setEnabled( true );
+        this.view = view;
+        schemaPool = SchemaPool.getInstance();
+
+        // Setting up the default key value (if needed)
+        if ( Activator.getDefault().getDialogSettings().get( LINK_WITH_EDITOR_HIERARCHY_VIEW_DS_KEY ) == null )
+        {
+            Activator.getDefault().getDialogSettings().put( LINK_WITH_EDITOR_HIERARCHY_VIEW_DS_KEY, false );
+        }
+
+        // Setting state from the dialog settings
+        setChecked( Activator.getDefault().getDialogSettings().getBoolean( LINK_WITH_EDITOR_HIERARCHY_VIEW_DS_KEY ) );
+
+        // Enabling the listeners
+        if ( isChecked() )
+        {
+            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().addPartListener( editorListener );
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.action.Action#run()
+     */
+    public void run()
+    {
+        setChecked( isChecked() );
+        Activator.getDefault().getDialogSettings().put( LINK_WITH_EDITOR_HIERARCHY_VIEW_DS_KEY, isChecked() );
+
+        if ( isChecked() ) // Enabling the listeners
+        {
+            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().addPartListener( editorListener );
+
+            IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
+                .getActiveEditor();
+            if ( activeEditor instanceof ObjectClassFormEditor )
+            {
+                ObjectClassFormEditor editor = ( ObjectClassFormEditor ) activeEditor;
+                linkViewWithEditor( editor.getPartName(), ObjectClassFormEditor.ID );
+            }
+            else if ( activeEditor instanceof AttributeTypeFormEditor )
+            {
+                AttributeTypeFormEditor editor = ( AttributeTypeFormEditor ) activeEditor;
+                linkViewWithEditor( editor.getPartName(), AttributeTypeFormEditor.ID );
+            }
+        }
+        else
+        // Disabling the listeners
+        {
+            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().removePartListener( editorListener );
+        }
+    }
+
+
+    /**
+     * Links the view with the right editor
+     *
+     * @param editorName
+     *      the name of the editor
+     * @param editorID
+     *      the id of the editor
+     */
+    private void linkViewWithEditor( String editorName, String editorID )
+    {
+        // Only editors for attribute types and object class are accepted
+        if ( editorID.equals( AttributeTypeFormEditor.ID ) )
+        {
+            view.setInput( schemaPool.getAttributeType( editorName ) );
+        }
+        else if ( editorID.equals( ObjectClassFormEditor.ID ) )
+        {
+            view.setInput( schemaPool.getObjectClass( editorName ) );
+        }
+    }
+}

Added: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/ShowSubtypeHierarchyAction.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/ShowSubtypeHierarchyAction.java?view=auto&rev=519067
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/ShowSubtypeHierarchyAction.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/ShowSubtypeHierarchyAction.java Fri Mar 16 10:13:21 2007
@@ -0,0 +1,73 @@
+/*
+ *  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.Activator;
+import org.apache.directory.ldapstudio.schemas.PluginConstants;
+import org.apache.directory.ldapstudio.schemas.view.viewers.HierarchyView;
+import org.eclipse.jface.action.Action;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class implements the Show Subtype Hierachy Action for the Hierarchy View.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ShowSubtypeHierarchyAction extends Action
+{
+    /** The associated view */
+    private HierarchyView view;
+
+
+    /**
+     * Creates a new instance of ShowSubtypeHierarchyAction.
+     *
+     * @param view
+     *      the associated view
+     */
+    public ShowSubtypeHierarchyAction( HierarchyView view )
+    {
+        super( "Subtype Hierarchy", AS_RADIO_BUTTON );
+        setToolTipText( "Show the Subtype Hierarchy" );
+        setId( PluginConstants.CMD_SHOW_SUBTYPE_HIERARCHY );
+        setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+            PluginConstants.IMG_SHOW_SUBTYPE_HIERARCHY ) );
+        setEnabled( true );
+        this.view = view;
+
+        // Setting state from the dialog settings
+        setChecked( Activator.getDefault().getDialogSettings().getInt( PluginConstants.PREFS_HIERARCHY_VIEW_MODE ) == PluginConstants.PREFS_HIERARCHY_VIEW_MODE_SUBTYPE );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.action.Action#run()
+     */
+    public void run()
+    {
+        Activator.getDefault().getDialogSettings().put( PluginConstants.PREFS_HIERARCHY_VIEW_MODE,
+            PluginConstants.PREFS_HIERARCHY_VIEW_MODE_SUBTYPE );
+        
+        view.refresh();
+    }
+}

Added: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/ShowSupertypeHierarchyAction.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/ShowSupertypeHierarchyAction.java?view=auto&rev=519067
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/ShowSupertypeHierarchyAction.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/controller/actions/ShowSupertypeHierarchyAction.java Fri Mar 16 10:13:21 2007
@@ -0,0 +1,73 @@
+/*
+ *  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.Activator;
+import org.apache.directory.ldapstudio.schemas.PluginConstants;
+import org.apache.directory.ldapstudio.schemas.view.viewers.HierarchyView;
+import org.eclipse.jface.action.Action;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class implements the Show Supertype Hierachy Action for the Hierarchy View.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ShowSupertypeHierarchyAction extends Action
+{
+    /** The associated view */
+    private HierarchyView view;
+
+
+    /**
+     * Creates a new instance of ShowSubtypeHierarchyAction.
+     *
+     * @param view
+     *      the associated view
+     */
+    public ShowSupertypeHierarchyAction( HierarchyView view )
+    {
+        super( "Supertype Hierarchy", AS_RADIO_BUTTON );
+        setToolTipText( "Show the Supertype Hierarchy" );
+        setId( PluginConstants.CMD_SHOW_SUPERTYPE_HIERARCHY );
+        setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+            PluginConstants.IMG_SHOW_SUPERTYPE_HIERARCHY ) );
+        setEnabled( true );
+        this.view = view;
+
+        // Setting state from the dialog settings
+        setChecked( Activator.getDefault().getDialogSettings().getInt( PluginConstants.PREFS_HIERARCHY_VIEW_MODE ) == PluginConstants.PREFS_HIERARCHY_VIEW_MODE_SUPERTYPE );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.action.Action#run()
+     */
+    public void run()
+    {
+        Activator.getDefault().getDialogSettings().put( PluginConstants.PREFS_HIERARCHY_VIEW_MODE,
+            PluginConstants.PREFS_HIERARCHY_VIEW_MODE_SUPERTYPE );
+        
+        view.refresh();
+    }
+}

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyView.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyView.java?view=diff&rev=519067&r1=519066&r2=519067
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyView.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyView.java Fri Mar 16 10:13:21 2007
@@ -21,6 +21,11 @@
 
 
 import org.apache.directory.ldapstudio.schemas.Activator;
+import org.apache.directory.ldapstudio.schemas.controller.HierarchyViewController;
+import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.ITreeNode;
+import org.eclipse.jface.viewers.DecoratingLabelProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.ui.part.ViewPart;
 
@@ -36,14 +41,37 @@
     /** The view's ID */
     public static final String ID = Activator.PLUGIN_ID + ".view.HierarchyView"; //$NON-NLS-1$
 
+    /** The tree viewer */
+    private TreeViewer viewer;
+
+    /** The content provider */
+    private HierarchyViewContentProvider contentProvider;
+
 
     /* (non-Javadoc)
      * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
      */
     public void createPartControl( Composite parent )
     {
-        // TODO Auto-generated method stub
+        initViewer( parent );
+
+        new HierarchyViewController( this );
+    }
 
+
+    /**
+     * Initializes the Viewer
+     *
+     * @param parent
+     *      the parent Composite
+     */
+    private void initViewer( Composite parent )
+    {
+        viewer = new TreeViewer( parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER );
+        contentProvider = new HierarchyViewContentProvider( viewer );
+        viewer.setContentProvider( contentProvider );
+        viewer.setLabelProvider( new DecoratingLabelProvider( new HierarchyViewLabelProvider(), Activator.getDefault()
+            .getWorkbench().getDecoratorManager().getLabelDecorator() ) );
     }
 
 
@@ -52,7 +80,89 @@
      */
     public void setFocus()
     {
-        // TODO Auto-generated method stub
+        viewer.getControl().setFocus();
+    }
+
+
+    /**
+     * Gets the TreeViewer
+     *
+     * @return
+     *      the TreeViewer
+     */
+    public TreeViewer getViewer()
+    {
+        return viewer;
+    }
+
+
+    /**
+     * Refreshes the viewer.
+     */
+    public void refresh()
+    {
+        viewer.refresh();
+        viewer.expandAll();
+    }
+
+
+    public void setInput( Object input )
+    {
+        viewer.setInput( input );
+        viewer.expandAll();
+    }
+
+
+    /**
+     * Search for the given element in the Tree and returns it if it has been found.
+     *
+     * @param element
+     *      the element to find
+     * @return
+     *      the element if it has been found, null if has not been found
+     */
+    public ITreeNode findElementInTree( ITreeNode element )
+    {
+        if ( element == null )
+        {
+            return null;
+        }
+
+        ITreeNode input = ( ITreeNode ) getViewer().getInput();
+
+        return findElementInTree( element, input );
+    }
+
 
+    /**
+     * Search for the given element in the Tree and returns it if it has been found.
+     *
+     * @param element
+     *      the element to find
+     * @param node
+     *      the current element
+     * @return
+     */
+    public ITreeNode findElementInTree( ITreeNode element, ITreeNode node )
+    {
+        if ( element.equals( node ) )
+        {
+            return node;
+        }
+        else
+        {
+            Object[] children = contentProvider.getChildren( node );
+
+            for ( int i = 0; i < children.length; i++ )
+            {
+                ITreeNode item = ( ITreeNode ) children[i];
+                ITreeNode foundElement = findElementInTree( element, item );
+                if ( foundElement != null )
+                {
+                    return foundElement;
+                }
+            }
+        }
+        return null;
     }
 }

Added: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyViewContentProvider.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyViewContentProvider.java?view=auto&rev=519067
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyViewContentProvider.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyViewContentProvider.java Fri Mar 16 10:13:21 2007
@@ -0,0 +1,253 @@
+/*
+ *  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.viewers;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.schemas.Activator;
+import org.apache.directory.ldapstudio.schemas.PluginConstants;
+import org.apache.directory.ldapstudio.schemas.model.AttributeType;
+import org.apache.directory.ldapstudio.schemas.model.LDAPModelEvent;
+import org.apache.directory.ldapstudio.schemas.model.ObjectClass;
+import org.apache.directory.ldapstudio.schemas.model.PoolListener;
+import org.apache.directory.ldapstudio.schemas.model.SchemaPool;
+import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.AttributeTypeWrapper;
+import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.ITreeNode;
+import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.ObjectClassWrapper;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+
+
+/**
+ * This class implements the Content Provider for the Schemas View.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class HierarchyViewContentProvider implements IStructuredContentProvider, ITreeContentProvider, PoolListener
+{
+    /** The Schema Pool */
+    private SchemaPool schemaPool;
+
+    /** The associated viewer */
+    private TreeViewer viewer;
+
+    List<AttributeType> attributeTypes;
+    List<ObjectClass> objectClasses;
+
+
+    /**
+     * Default constructor
+     */
+    public HierarchyViewContentProvider( TreeViewer viewer )
+    {
+        this.viewer = viewer;
+        schemaPool = SchemaPool.getInstance();
+        schemaPool.addListener( this );
+        attributeTypes = schemaPool.getAttributeTypes();
+        objectClasses = schemaPool.getObjectClasses();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+     */
+    public Object[] getElements( Object inputElement )
+    {
+        return getChildren( inputElement );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
+     */
+    public Object[] getChildren( Object parentElement )
+    {
+        int mode = Activator.getDefault().getDialogSettings().getInt( PluginConstants.PREFS_HIERARCHY_VIEW_MODE );
+        List<ITreeNode> children = null;
+
+        if ( parentElement instanceof ObjectClass )
+        {
+            ObjectClass oc = ( ObjectClass ) parentElement;
+
+            ObjectClassWrapper ocw = new ObjectClassWrapper( oc, null );
+            children = new ArrayList<ITreeNode>();
+            children.add( ocw );
+        }
+        else if ( parentElement instanceof AttributeType )
+        {
+            AttributeType at = ( AttributeType ) parentElement;
+
+            AttributeTypeWrapper atw = new AttributeTypeWrapper( at, null );
+            children = new ArrayList<ITreeNode>();
+            children.add( atw );
+        }
+        else if ( parentElement instanceof ObjectClassWrapper )
+        {
+            ObjectClassWrapper ocw = ( ObjectClassWrapper ) parentElement;
+            ObjectClass oc = ocw.getMyObjectClass();
+
+            if ( mode == PluginConstants.PREFS_HIERARCHY_VIEW_MODE_SUPERTYPE )
+            {
+                String[] superiors = oc.getSuperiors();
+                for ( String superior : superiors )
+                {
+                    if ( superior != null || "".equals( superior ) )
+                    {
+                        ObjectClass supOC = schemaPool.getObjectClass( superior );
+                        if ( supOC != null )
+                        {
+                            ObjectClassWrapper supOCW = new ObjectClassWrapper( supOC, ocw );
+                            ocw.addChild( supOCW );
+                        }
+                    }
+                }
+            }
+            else if ( mode == PluginConstants.PREFS_HIERARCHY_VIEW_MODE_SUBTYPE )
+            {
+                for ( ObjectClass objectClass : objectClasses )
+                {
+                    String[] superiors = objectClass.getSuperiors();
+                    for ( String superior : superiors )
+                    {
+                        if ( superior != null || "".equals( superior ) )
+                        {
+                            ObjectClass supOC = schemaPool.getObjectClass( superior );
+                            if ( supOC != null && oc.equals( supOC ) )
+                            {
+                                ObjectClassWrapper supOCW = new ObjectClassWrapper( objectClass, ocw );
+                                ocw.addChild( supOCW );
+                            }
+                        }
+                    }
+                }
+            }
+
+            children = ocw.getChildren();
+        }
+        else if ( parentElement instanceof AttributeTypeWrapper )
+        {
+            AttributeTypeWrapper atw = ( AttributeTypeWrapper ) parentElement;
+            AttributeType at = atw.getMyAttributeType();
+
+            if ( mode == PluginConstants.PREFS_HIERARCHY_VIEW_MODE_SUPERTYPE )
+            {
+                String superior = at.getSuperior();
+                if ( superior != null || "".equals( superior ) )
+                {
+                    AttributeType supAT = schemaPool.getAttributeType( superior );
+                    if ( supAT != null )
+                    {
+                        AttributeTypeWrapper supATW = new AttributeTypeWrapper( supAT, atw );
+                        atw.addChild( supATW );
+                    }
+                }
+            }
+            else if ( mode == PluginConstants.PREFS_HIERARCHY_VIEW_MODE_SUBTYPE )
+            {
+                for ( AttributeType attributeType : attributeTypes )
+                {
+                    String superior = attributeType.getSuperior();
+                    if ( superior != null && !"".equals( superior ) )
+                    {
+                        AttributeType supAT = schemaPool.getAttributeType( superior );
+                        if ( supAT != null && at.equals( supAT ) )
+                        {
+                            AttributeTypeWrapper supATW = new AttributeTypeWrapper( attributeType, atw );
+                            atw.addChild( supATW );
+                        }
+                    }
+                }
+            }
+
+            children = atw.getChildren();
+        }
+
+        if ( children == null )
+        {
+            return new Object[0];
+        }
+        else
+        {
+            return children.toArray();
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
+     */
+    public Object getParent( Object element )
+    {
+        if ( element instanceof ITreeNode )
+        {
+            return ( ( ITreeNode ) element ).getParent();
+        }
+
+        // Default
+        return null;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
+     */
+    public boolean hasChildren( Object element )
+    {
+        if ( element instanceof ITreeNode )
+        {
+            return getChildren( element ).length > 0;
+        }
+
+        // Default
+        return false;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+     */
+    public void dispose()
+    {
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+     */
+    public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
+    {
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.ldapstudio.schemas.model.PoolListener#poolChanged(org.apache.directory.ldapstudio.schemas.model.SchemaPool, org.apache.directory.ldapstudio.schemas.model.LDAPModelEvent)
+     */
+    public void poolChanged( SchemaPool p, LDAPModelEvent e )
+    {
+        viewer.refresh();
+        viewer.expandAll();
+    }
+}

Added: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyViewLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyViewLabelProvider.java?view=auto&rev=519067
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyViewLabelProvider.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyViewLabelProvider.java Fri Mar 16 10:13:21 2007
@@ -0,0 +1,166 @@
+/*
+ *  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.viewers;
+
+
+import org.apache.directory.ldapstudio.schemas.Activator;
+import org.apache.directory.ldapstudio.schemas.PluginConstants;
+import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.AttributeTypeWrapper;
+import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.ITreeNode;
+import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.ObjectClassWrapper;
+import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.SchemaWrapper;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * This class implements the LabelProvider for the Hierarchy View.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class HierarchyViewLabelProvider extends LabelProvider
+{
+    /** The preferences store */
+    private IPreferenceStore store;
+
+
+    /**
+     * Creates a new instance of SchemasViewLabelProvider.
+     */
+    public HierarchyViewLabelProvider()
+    {
+        store = Activator.getDefault().getPreferenceStore();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
+     */
+    public String getText( Object obj )
+    {
+        String label = "";
+
+        int labelValue = store.getInt( PluginConstants.PREFS_SCHEMAS_VIEW_LABEL );
+        boolean abbreviate = store.getBoolean( PluginConstants.PREFS_SCHEMAS_VIEW_ABBREVIATE );
+        int abbreviateMaxLength = store.getInt( PluginConstants.PREFS_SCHEMAS_VIEW_ABBREVIATE_MAX_LENGTH );
+
+        if ( obj instanceof AttributeTypeWrapper )
+        {
+            if ( labelValue == PluginConstants.PREFS_SCHEMAS_VIEW_LABEL_FIRST_NAME )
+            {
+                label = ( ( AttributeTypeWrapper ) obj ).getMyAttributeType().getNames()[0];
+            }
+            else if ( labelValue == PluginConstants.PREFS_SCHEMAS_VIEW_LABEL_ALL_ALIASES )
+            {
+                label = concateNames( ( ( AttributeTypeWrapper ) obj ).getMyAttributeType().getNames() );
+            }
+            else if ( labelValue == PluginConstants.PREFS_SCHEMAS_VIEW_LABEL_OID )
+            {
+                label = ( ( AttributeTypeWrapper ) obj ).getMyAttributeType().getOid();
+            }
+            else
+            // Default
+            {
+                label = ( ( AttributeTypeWrapper ) obj ).getMyAttributeType().getNames()[0];
+            }
+        }
+        else if ( obj instanceof ObjectClassWrapper )
+        {
+            if ( labelValue == PluginConstants.PREFS_SCHEMAS_VIEW_LABEL_FIRST_NAME )
+            {
+                label = ( ( ObjectClassWrapper ) obj ).getMyObjectClass().getNames()[0];
+            }
+            else if ( labelValue == PluginConstants.PREFS_SCHEMAS_VIEW_LABEL_ALL_ALIASES )
+            {
+                label = concateNames( ( ( ObjectClassWrapper ) obj ).getMyObjectClass().getNames() );
+            }
+            else if ( labelValue == PluginConstants.PREFS_SCHEMAS_VIEW_LABEL_OID )
+            {
+                label = ( ( ObjectClassWrapper ) obj ).getMyObjectClass().getOid();
+            }
+            else
+            // Default
+            {
+                label = ( ( ObjectClassWrapper ) obj ).getMyObjectClass().getNames()[0];
+            }
+        }
+        else if ( obj instanceof SchemaWrapper )
+        {
+            label = ( ( SchemaWrapper ) obj ).getMySchema().getName();
+        }
+        else
+        // Default
+        {
+            label = obj.toString();
+        }
+
+        if ( abbreviate && ( abbreviateMaxLength < label.length() )
+            && ( ( obj instanceof ObjectClassWrapper ) || ( obj instanceof AttributeTypeWrapper ) ) )
+        {
+            label = label.substring( 0, abbreviateMaxLength ) + "...";
+        }
+
+        return label;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
+     */
+    public Image getImage( Object obj )
+    {
+        if ( obj instanceof ITreeNode )
+        {
+            return ( ( ITreeNode ) obj ).getImage();
+        }
+
+        // Default
+        return PlatformUI.getWorkbench().getSharedImages().getImage( ISharedImages.IMG_OBJS_WARN_TSK );
+    }
+
+
+    /**
+     * 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();
+    }
+}



Mime
View raw message