directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r581956 - in /directory/studio/trunk/studio-schemaeditor: resources/icons/ src/main/java/org/apache/directory/studio/schemaeditor/ src/main/java/org/apache/directory/studio/schemaeditor/controller/ src/main/java/org/apache/directory/studio/...
Date Thu, 04 Oct 2007 16:04:15 GMT
Author: pamarcelot
Date: Thu Oct  4 09:04:11 2007
New Revision: 581956

URL: http://svn.apache.org/viewvc?rev=581956&view=rev
Log:
Fix for DIRSTUDIO-216 (Improve Type Hierarchy View).

Added:
    directory/studio/trunk/studio-schemaeditor/resources/icons/attribute_type_hierarchy_selected.gif
  (with props)
    directory/studio/trunk/studio-schemaeditor/resources/icons/hierarchy_type.gif   (with
props)
    directory/studio/trunk/studio-schemaeditor/resources/icons/object_class_hierarchy_selected.gif
  (with props)
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ShowTypeHierarchyAction.java
Modified:
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginConstants.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/HierarchyViewController.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/HierarchyView.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/HierarchyViewContentProvider.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/HierarchyViewLabelProvider.java

Added: directory/studio/trunk/studio-schemaeditor/resources/icons/attribute_type_hierarchy_selected.gif
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/resources/icons/attribute_type_hierarchy_selected.gif?rev=581956&view=auto
==============================================================================
Binary file - no diff available.

Propchange: directory/studio/trunk/studio-schemaeditor/resources/icons/attribute_type_hierarchy_selected.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: directory/studio/trunk/studio-schemaeditor/resources/icons/hierarchy_type.gif
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/resources/icons/hierarchy_type.gif?rev=581956&view=auto
==============================================================================
Binary file - no diff available.

Propchange: directory/studio/trunk/studio-schemaeditor/resources/icons/hierarchy_type.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: directory/studio/trunk/studio-schemaeditor/resources/icons/object_class_hierarchy_selected.gif
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/resources/icons/object_class_hierarchy_selected.gif?rev=581956&view=auto
==============================================================================
Binary file - no diff available.

Propchange: directory/studio/trunk/studio-schemaeditor/resources/icons/object_class_hierarchy_selected.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginConstants.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginConstants.java?rev=581956&r1=581955&r2=581956&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginConstants.java
(original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginConstants.java
Thu Oct  4 09:04:11 2007
@@ -35,6 +35,7 @@
 {
     // Images
     public static final String IMG_ATTRIBUTE_TYPE = "resources/icons/attribute_type.gif";
+    public static final String IMG_ATTRIBUTE_TYPE_HIERARCHY_SELECTED = "resources/icons/attribute_type_hierarchy_selected.gif";
     public static final String IMG_ATTRIBUTE_TYPE_NEW = "resources/icons/attribute_type_new.gif";
     public static final String IMG_ATTRIBUTE_TYPE_NEW_WIZARD = "resources/icons/attribute_type_new_wizard.png";
     public static final String IMG_ATTRIBUTE_TYPE_OVERLAY_OPERATION = "resources/icons/attribute_type_overlay_operation.gif";
@@ -62,6 +63,7 @@
     public static final String IMG_FOLDER_OC = "resources/icons/folder_oc.gif";
     public static final String IMG_LINK_WITH_EDITOR = "resources/icons/link_with_editor.gif";
     public static final String IMG_OBJECT_CLASS = "resources/icons/object_class.gif";
+    public static final String IMG_OBJECT_CLASS_HIERARCHY_SELECTED = "resources/icons/object_class_hierarchy_selected.gif";
     public static final String IMG_OBJECT_CLASS_NEW = "resources/icons/object_class_new.gif";
     public static final String IMG_OBJECT_CLASS_NEW_WIZARD = "resources/icons/object_class_new_wizard.png";
     public static final String IMG_OBJECT_CLASS_OVERLAY_ABSTRACT = "resources/icons/object_class_overlay_abstract.gif";
@@ -101,6 +103,7 @@
     public static final String IMG_SHOW_SEARCH_HISTORY = "resources/icons/show_search_history.gif";
     public static final String IMG_SHOW_SUBTYPE_HIERARCHY = "resources/icons/hierarchy_subtype.gif";
     public static final String IMG_SHOW_SUPERTYPE_HIERARCHY = "resources/icons/hierarchy_supertype.gif";
+    public static final String IMG_SHOW_TYPE_HIERARCHY = "resources/icons/hierarchy_type.gif";
     public static final String IMG_SORTING = "resources/icons/sorting.gif";
     public static final String IMG_TOOLBAR_MENU = "resources/icons/toolbar_menu.gif";
     public static final String IMG_TRANSPARENT_16X16 = "resources/icons/transparent_16x16.gif";
@@ -149,8 +152,11 @@
     public static final String CMD_SHOW_SEARCH_HISTORY = Activator.PLUGIN_ID + ".commands.showSearchHistory";
     public static final String CMD_SHOW_SUBTYPE_HIERARCHY = Activator.PLUGIN_ID + ".commands.showSubTypeHierarchy";
     public static final String CMD_SHOW_SUPERTYPE_HIERARCHY = Activator.PLUGIN_ID + ".commands.showSuperTypeHierarchy";
-    public static final String CMD_SWITCH_SCHEMA_PRESENTATION_TO_FLAT = Activator.PLUGIN_ID
+ ".commands.switchSchemaPresentationToFlat";
-    public static final String CMD_SWITCH_SCHEMA_PRESENTATION_TO_HIERARCHICAL = Activator.PLUGIN_ID
+ ".commands.switchSchemaPresentationToHierarchical";
+    public static final String CMD_SHOW_TYPE_HIERARCHY = Activator.PLUGIN_ID + ".commands.showSubTypeHierarchy";
+    public static final String CMD_SWITCH_SCHEMA_PRESENTATION_TO_FLAT = Activator.PLUGIN_ID
+        + ".commands.switchSchemaPresentationToFlat";
+    public static final String CMD_SWITCH_SCHEMA_PRESENTATION_TO_HIERARCHICAL = Activator.PLUGIN_ID
+        + ".commands.switchSchemaPresentationToHierarchical";
 
     // Preferences - DifferencesWidget
     /** The preferences ID for DifferencesWidget Grouping */
@@ -163,7 +169,8 @@
 
     // Preferences - SchemaView
     /** The preference ID for Schema View Schema Presentation */
-    public static final String PREFS_SCHEMA_VIEW_SCHEMA_PRESENTATION = SchemaViewPreferencePage.ID
+ ".schemaPresentation"; //$NON-NLS-1$
+    public static final String PREFS_SCHEMA_VIEW_SCHEMA_PRESENTATION = SchemaViewPreferencePage.ID
+        + ".schemaPresentation"; //$NON-NLS-1$
     /** The preference value for Schema View Schema Presentation 'Flat' */
     public static final int PREFS_SCHEMA_VIEW_SCHEMA_PRESENTATION_FLAT = 0;
     /** The preference value for Schema View Schema Presentation 'Hierarchical' */
@@ -194,7 +201,7 @@
     public static final String PREFS_SCHEMA_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH =
SchemaViewPreferencePage.ID
         + ".secondaryLabel.abbreviate.maxLength"; //$NON-NLS-1$
     public static final String PREFS_SCHEMA_VIEW_SCHEMA_LABEL_DISPLAY = SchemaViewPreferencePage.ID
-    + ".schemaLabel.display"; //$NON-NLS-1$
+        + ".schemaLabel.display"; //$NON-NLS-1$
     /** The preference ID for Schema View Grouping */
     public static final String PREFS_SCHEMA_VIEW_GROUPING = Activator.PLUGIN_ID + ".preferences.SchemaView.grouping";
//$NON-NLS-1$
     /** The preference value for Schema View Grouping 'group ATs and OCs in folders' */
@@ -222,6 +229,8 @@
     public static final int PREFS_HIERARCHY_VIEW_MODE_SUPERTYPE = 0;
     /** The preference value for Hierarchy View Mode 'Subtype' */
     public static final int PREFS_HIERARCHY_VIEW_MODE_SUBTYPE = 1;
+    /** The preference value for Hierarchy View Mode 'Type' */
+    public static final int PREFS_HIERARCHY_VIEW_MODE_TYPE = 2;
     /** The preference ID for Hierarchy View Label */
     public static final String PREFS_HIERARCHY_VIEW_LABEL = HierarchyViewPreferencePage.ID
+ ".label.labelValue"; //$NON-NLS-1$
     /** The preference value for Hierarchy View First Name label */

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/HierarchyViewController.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/HierarchyViewController.java?rev=581956&r1=581955&r2=581956&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/HierarchyViewController.java
(original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/HierarchyViewController.java
Thu Oct  4 09:04:11 2007
@@ -31,6 +31,7 @@
 import org.apache.directory.studio.schemaeditor.controller.actions.OpenHierarchyViewPreferencesAction;
 import org.apache.directory.studio.schemaeditor.controller.actions.ShowSubtypeHierarchyAction;
 import org.apache.directory.studio.schemaeditor.controller.actions.ShowSupertypeHierarchyAction;
+import org.apache.directory.studio.schemaeditor.controller.actions.ShowTypeHierarchyAction;
 import org.apache.directory.studio.schemaeditor.model.Project;
 import org.apache.directory.studio.schemaeditor.view.ViewUtils;
 import org.apache.directory.studio.schemaeditor.view.editors.attributetype.AttributeTypeEditor;
@@ -80,6 +81,7 @@
             if ( newProject != null )
             {
                 view.getViewer().getTree().setEnabled( true );
+                showTypeHierarchy.setEnabled( true );
                 showSupertypeHierarchy.setEnabled( true );
                 showSubtypeHierarchy.setEnabled( true );
                 linkWithEditor.setEnabled( true );
@@ -88,6 +90,7 @@
             else
             {
                 view.getViewer().getTree().setEnabled( false );
+                showTypeHierarchy.setEnabled( false );
                 showSupertypeHierarchy.setEnabled( false );
                 showSubtypeHierarchy.setEnabled( false );
                 linkWithEditor.setEnabled( false );
@@ -151,6 +154,7 @@
     };
 
     // The Actions
+    private Action showTypeHierarchy;
     private Action showSupertypeHierarchy;
     private Action showSubtypeHierarchy;
     private Action linkWithEditor;
@@ -203,8 +207,9 @@
         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 );
+                PluginConstants.PREFS_HIERARCHY_VIEW_MODE_TYPE );
         }
+        showTypeHierarchy = new ShowTypeHierarchyAction( view );
         showSupertypeHierarchy = new ShowSupertypeHierarchyAction( view );
         showSubtypeHierarchy = new ShowSubtypeHierarchyAction( view );
         linkWithEditor = new LinkWithEditorHierarchyViewAction( view );
@@ -218,6 +223,7 @@
     private void initToolbar()
     {
         IToolBarManager toolbar = view.getViewSite().getActionBars().getToolBarManager();
+        toolbar.add( showTypeHierarchy );
         toolbar.add( showSupertypeHierarchy );
         toolbar.add( showSubtypeHierarchy );
         toolbar.add( new Separator() );
@@ -231,6 +237,7 @@
     private void initMenu()
     {
         IMenuManager menu = view.getViewSite().getActionBars().getMenuManager();
+        menu.add( showTypeHierarchy );
         menu.add( showSupertypeHierarchy );
         menu.add( showSubtypeHierarchy );
         menu.add( new Separator() );
@@ -275,6 +282,7 @@
         if ( Activator.getDefault().getProjectsHandler().getOpenProject() != null )
         {
             view.getViewer().getTree().setEnabled( true );
+            showTypeHierarchy.setEnabled( true );
             showSupertypeHierarchy.setEnabled( true );
             showSubtypeHierarchy.setEnabled( true );
             linkWithEditor.setEnabled( true );
@@ -283,6 +291,7 @@
         else
         {
             view.getViewer().getTree().setEnabled( false );
+            showTypeHierarchy.setEnabled( false );
             showSupertypeHierarchy.setEnabled( false );
             showSubtypeHierarchy.setEnabled( false );
             linkWithEditor.setEnabled( false );

Added: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ShowTypeHierarchyAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ShowTypeHierarchyAction.java?rev=581956&view=auto
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ShowTypeHierarchyAction.java
(added)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ShowTypeHierarchyAction.java
Thu Oct  4 09:04:11 2007
@@ -0,0 +1,70 @@
+/*
+ *  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.studio.schemaeditor.controller.actions;
+
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.apache.directory.studio.schemaeditor.view.views.HierarchyView;
+import org.eclipse.jface.action.Action;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class implements the Show Type Hierachy Action for the Hierarchy View.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ShowTypeHierarchyAction extends Action
+{
+    /** The associated view */
+    private HierarchyView view;
+
+
+    /**
+     * Creates a new instance of ShowSubtypeHierarchyAction.
+     */
+    public ShowTypeHierarchyAction( HierarchyView view )
+    {
+        super( "&Type Hierarchy", AS_RADIO_BUTTON );
+        setToolTipText( "Show the Type Hierarchy" );
+        setId( PluginConstants.CMD_SHOW_TYPE_HIERARCHY );
+        setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+            PluginConstants.IMG_SHOW_TYPE_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_TYPE );
+    }
+
+
+    /* (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_TYPE );
+
+        view.refresh();
+    }
+}

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/HierarchyView.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/HierarchyView.java?rev=581956&r1=581955&r2=581956&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/HierarchyView.java
(original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/HierarchyView.java
Thu Oct  4 09:04:11 2007
@@ -102,8 +102,8 @@
     {
         viewer = new TreeViewer( parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL );
         viewer.setContentProvider( new HierarchyViewContentProvider() );
-        viewer.setLabelProvider( new DecoratingLabelProvider( new HierarchyViewLabelProvider(),
Activator.getDefault()
-            .getWorkbench().getDecoratorManager().getLabelDecorator() ) );
+        viewer.setLabelProvider( new DecoratingLabelProvider( new HierarchyViewLabelProvider(
viewer ), Activator
+            .getDefault().getWorkbench().getDecoratorManager().getLabelDecorator() ) );
         viewer.getTree().setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
         viewer.getTree().setEnabled( false );
     }

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/HierarchyViewContentProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/HierarchyViewContentProvider.java?rev=581956&r1=581955&r2=581956&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/HierarchyViewContentProvider.java
(original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/HierarchyViewContentProvider.java
Thu Oct  4 09:04:11 2007
@@ -26,9 +26,9 @@
 
 import org.apache.directory.studio.schemaeditor.Activator;
 import org.apache.directory.studio.schemaeditor.PluginConstants;
-import org.apache.directory.studio.schemaeditor.controller.SchemaHandler;
 import org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl;
 import org.apache.directory.studio.schemaeditor.model.ObjectClassImpl;
+import org.apache.directory.studio.schemaeditor.model.hierarchy.HierarchyManager;
 import org.apache.directory.studio.schemaeditor.view.wrappers.AttributeTypeWrapper;
 import org.apache.directory.studio.schemaeditor.view.wrappers.ObjectClassWrapper;
 import org.apache.directory.studio.schemaeditor.view.wrappers.TreeNode;
@@ -45,13 +45,6 @@
  */
 public class HierarchyViewContentProvider implements IStructuredContentProvider, ITreeContentProvider
 {
-    /** The SchemaHandler */
-    private SchemaHandler schemaHandler;
-
-    List<AttributeTypeImpl> attributeTypes;
-    List<ObjectClassImpl> objectClasses;
-
-
     /* (non-Javadoc)
      * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
      */
@@ -66,117 +59,269 @@
      */
     public Object[] getChildren( Object parentElement )
     {
-        int mode = Activator.getDefault().getDialogSettings().getInt( PluginConstants.PREFS_HIERARCHY_VIEW_MODE
);
-        List<TreeNode> children = null;
-
-        schemaHandler = Activator.getDefault().getSchemaHandler();
-        attributeTypes = schemaHandler.getAttributeTypes();
-        objectClasses = schemaHandler.getObjectClasses();
+        List<TreeNode> children = new ArrayList<TreeNode>();
 
         if ( parentElement instanceof ObjectClassImpl )
         {
             ObjectClassImpl oc = ( ObjectClassImpl ) parentElement;
 
-            ObjectClassWrapper ocw = new ObjectClassWrapper( oc, null );
-            children = new ArrayList<TreeNode>();
-            children.add( ocw );
+            children = createTypeHierarchyObjectClass( oc );
         }
         else if ( parentElement instanceof AttributeTypeImpl )
         {
             AttributeTypeImpl at = ( AttributeTypeImpl ) parentElement;
 
-            AttributeTypeWrapper atw = new AttributeTypeWrapper( at, null );
-            children = new ArrayList<TreeNode>();
-            children.add( atw );
+            children = createTypeHierarchyAttributeType( at );
         }
-        else if ( parentElement instanceof ObjectClassWrapper )
+        else if ( parentElement instanceof TreeNode )
         {
-            ObjectClassWrapper ocw = ( ObjectClassWrapper ) parentElement;
-            ObjectClassImpl oc = ocw.getObjectClass();
+            children = ( ( TreeNode ) parentElement ).getChildren();
+        }
+
+        return children.toArray();
+    }
+
+
+    /**
+     * Creates the Type Hierarchy for an object class.
+     *
+     * @param oc
+     *      the object class
+     * @return
+     *      the Type Hierarchy for an object class
+     */
+    private List<TreeNode> createTypeHierarchyObjectClass( ObjectClassImpl oc )
+    {
+        List<TreeNode> children = new ArrayList<TreeNode>();
+
+        HierarchyManager hierarchyManager = new HierarchyManager();
+
+        // Creating the wrapper of the object class
+        ObjectClassWrapper ocw = new ObjectClassWrapper( oc );
+
+        int mode = Activator.getDefault().getDialogSettings().getInt( PluginConstants.PREFS_HIERARCHY_VIEW_MODE
);
+        if ( mode == PluginConstants.PREFS_HIERARCHY_VIEW_MODE_TYPE )
+        {
+            // Creating its children's wrappers
+            createChildrenHierarchy( ocw, hierarchyManager.getChildren( oc ), hierarchyManager
);
+
+            // Creating its parents' wrappers
+            createParentHierarchy( hierarchyManager.getParents( oc ), children, ocw, hierarchyManager
);
+        }
+        else if ( mode == PluginConstants.PREFS_HIERARCHY_VIEW_MODE_SUPERTYPE )
+        {
+            // Creating its parents' wrappers
+            createParentHierarchy( hierarchyManager.getParents( oc ), children, ocw, hierarchyManager
);
+        }
+        else if ( mode == PluginConstants.PREFS_HIERARCHY_VIEW_MODE_SUBTYPE )
+        {
+            // Creating its children's wrappers
+            createChildrenHierarchy( ocw, hierarchyManager.getChildren( oc ), hierarchyManager
);
+
+            children.add( ocw );
+        }
+
+        return children;
+    }
 
-            if ( mode == PluginConstants.PREFS_HIERARCHY_VIEW_MODE_SUPERTYPE )
+
+    /**
+     * Creates the parent hierarchy.
+     *
+     * @param parents
+     *      the parents
+     * @param children
+     *      the children
+     * @param ocw
+     *      the object class wrapper
+     * @param hierarchyManager
+     *      the hierarchy manager
+     */
+    private void createParentHierarchy( List<Object> parents, List<TreeNode>
children, ObjectClassWrapper ocw,
+        HierarchyManager hierarchyManager )
+    {
+        if ( parents != null )
+        {
+            for ( Object parent : parents )
             {
-                String[] superiors = oc.getSuperClassesNames();
-                for ( String superior : superiors )
+                if ( parent instanceof ObjectClassImpl )
                 {
-                    if ( superior != null || "".equals( superior ) ) //$NON-NLS-1$
-                    {
-                        ObjectClassImpl supOC = schemaHandler.getObjectClass( superior );
-                        if ( supOC != null )
-                        {
-                            ObjectClassWrapper supOCW = new ObjectClassWrapper( supOC, ocw
);
-                            ocw.addChild( supOCW );
-                        }
-                    }
+                    ObjectClassImpl parentOC = ( ObjectClassImpl ) parent;
+                    ObjectClassWrapper duplicatedOCW = ( ObjectClassWrapper ) duplicateTreeNode(
ocw );
+
+                    ObjectClassWrapper ocw2 = new ObjectClassWrapper( parentOC );
+                    duplicatedOCW.setParent( ocw2 );
+                    ocw2.addChild( duplicatedOCW );
+
+                    createParentHierarchy( hierarchyManager.getParents( parentOC ), children,
ocw2, hierarchyManager );
+                }
+                else
+                {
+                    children.add( ocw );
                 }
             }
-            else if ( mode == PluginConstants.PREFS_HIERARCHY_VIEW_MODE_SUBTYPE )
+        }
+        else
+        {
+            children.add( ocw );
+        }
+    }
+
+
+    /**
+     * Duplicates the given node.
+     *
+     * @param node
+     *      the node
+     * @return
+     *      a duplicate of the given node
+     */
+    public TreeNode duplicateTreeNode( TreeNode node )
+    {
+        if ( node != null )
+        {
+            if ( node instanceof ObjectClassWrapper )
             {
-                for ( ObjectClassImpl objectClass : objectClasses )
+                ObjectClassWrapper ocNode = ( ObjectClassWrapper ) node;
+
+                ObjectClassWrapper duplicatedOCNode = new ObjectClassWrapper( ocNode.getObjectClass(),
ocNode
+                    .getParent() );
+
+                for ( TreeNode child : ocNode.getChildren() )
                 {
-                    String[] superiors = objectClass.getSuperClassesNames();
-                    for ( String superior : superiors )
+                    TreeNode duplicatedChild = duplicateTreeNode( child );
+                    if ( duplicatedChild != null )
                     {
-                        if ( superior != null || "".equals( superior ) ) //$NON-NLS-1$
-                        {
-                            ObjectClassImpl supOC = schemaHandler.getObjectClass( superior
);
-                            if ( supOC != null && oc.equals( supOC ) )
-                            {
-                                ObjectClassWrapper supOCW = new ObjectClassWrapper( objectClass,
ocw );
-                                ocw.addChild( supOCW );
-                            }
-                        }
+                        duplicatedOCNode.addChild( duplicatedChild );
                     }
                 }
-            }
 
-            children = ocw.getChildren();
+                return duplicatedOCNode;
+            }
         }
-        else if ( parentElement instanceof AttributeTypeWrapper )
+
+        return null;
+    }
+
+
+    /**
+     * Creates the Type Hierarchy for an attribute type.
+     *
+     * @param at
+     *      the attribute type
+     * @return
+     *      the Type Hierarchy for an attribute type
+     */
+    private List<TreeNode> createTypeHierarchyAttributeType( AttributeTypeImpl at )
+    {
+        List<TreeNode> children = new ArrayList<TreeNode>();
+        HierarchyManager hierarchyManager = new HierarchyManager();
+        int mode = Activator.getDefault().getDialogSettings().getInt( PluginConstants.PREFS_HIERARCHY_VIEW_MODE
);
+
+        // Creating the wrapper of the attribute type
+        AttributeTypeWrapper atw = new AttributeTypeWrapper( at );
+
+        if ( mode == PluginConstants.PREFS_HIERARCHY_VIEW_MODE_TYPE )
         {
-            AttributeTypeWrapper atw = ( AttributeTypeWrapper ) parentElement;
-            AttributeTypeImpl at = atw.getAttributeType();
+            // Creating the children's wrappers
+            createChildrenHierarchy( atw, hierarchyManager.getChildren( at ), hierarchyManager
);
 
-            if ( mode == PluginConstants.PREFS_HIERARCHY_VIEW_MODE_SUPERTYPE )
+            // Creating its parents' wrappers
+            List<Object> parents = hierarchyManager.getParents( at );
+            while ( ( parents != null ) && ( parents.size() == 1 ) )
             {
-                String superior = at.getSuperiorName();
-                if ( superior != null || "".equals( superior ) ) //$NON-NLS-1$
+                Object parent = parents.get( 0 );
+                if ( parent instanceof AttributeTypeImpl )
                 {
-                    AttributeTypeImpl supAT = schemaHandler.getAttributeType( superior );
-                    if ( supAT != null )
-                    {
-                        AttributeTypeWrapper supATW = new AttributeTypeWrapper( supAT, atw
);
-                        atw.addChild( supATW );
-                    }
+                    AttributeTypeImpl parentAT = ( AttributeTypeImpl ) parent;
+
+                    AttributeTypeWrapper atw2 = new AttributeTypeWrapper( parentAT );
+                    atw.setParent( atw2 );
+                    atw2.addChild( atw );
+
+                    atw = atw2;
+
+                    parents = hierarchyManager.getParents( parentAT );
+                }
+                else
+                {
+                    break;
                 }
             }
-            else if ( mode == PluginConstants.PREFS_HIERARCHY_VIEW_MODE_SUBTYPE )
+
+            children.add( atw );
+        }
+        else if ( mode == PluginConstants.PREFS_HIERARCHY_VIEW_MODE_SUPERTYPE )
+        {
+            // Creating its parents' wrappers
+            List<Object> parents = hierarchyManager.getParents( at );
+            while ( ( parents != null ) && ( parents.size() == 1 ) )
             {
-                for ( AttributeTypeImpl attributeType : attributeTypes )
+                Object parent = parents.get( 0 );
+                if ( parent instanceof AttributeTypeImpl )
                 {
-                    String superior = attributeType.getSuperiorName();
-                    if ( superior != null && !"".equals( superior ) ) //$NON-NLS-1$
-                    {
-                        AttributeTypeImpl supAT = schemaHandler.getAttributeType( superior
);
-                        if ( supAT != null && at.equals( supAT ) )
-                        {
-                            AttributeTypeWrapper supATW = new AttributeTypeWrapper( attributeType,
atw );
-                            atw.addChild( supATW );
-                        }
-                    }
+                    AttributeTypeImpl parentAT = ( AttributeTypeImpl ) parent;
+
+                    AttributeTypeWrapper atw2 = new AttributeTypeWrapper( parentAT );
+                    atw.setParent( atw2 );
+                    atw2.addChild( atw );
+
+                    atw = atw2;
+
+                    parents = hierarchyManager.getParents( parentAT );
+                }
+                else
+                {
+                    break;
                 }
             }
 
-            children = atw.getChildren();
+            children.add( atw );
         }
-
-        if ( children == null )
+        else if ( mode == PluginConstants.PREFS_HIERARCHY_VIEW_MODE_SUBTYPE )
         {
-            return new Object[0];
+            // Creating the children's wrappers
+            createChildrenHierarchy( atw, hierarchyManager.getChildren( at ), hierarchyManager
);
+
+            children.add( atw );
         }
-        else
+
+        return children;
+    }
+
+
+    /**
+     * Create the children hierarchy
+     *
+     * @param node
+     *      the parent node.
+     * @param children
+     *      the children
+     */
+    private void createChildrenHierarchy( TreeNode node, List<Object> children, HierarchyManager
hierarchyManager )
+    {
+        if ( ( children != null ) && ( children.size() > 0 ) )
         {
-            return children.toArray();
+            for ( Object child : children )
+            {
+                TreeNode childNode = null;
+                if ( child instanceof AttributeTypeImpl )
+                {
+                    AttributeTypeImpl at = ( AttributeTypeImpl ) child;
+                    childNode = new AttributeTypeWrapper( at, node );
+                    node.addChild( childNode );
+                }
+                else if ( child instanceof ObjectClassImpl )
+                {
+                    ObjectClassImpl oc = ( ObjectClassImpl ) child;
+                    childNode = new ObjectClassWrapper( oc, node );
+                    node.addChild( childNode );
+                }
+
+                // Recursively creating the hierarchy for all children
+                // of the given element.
+                createChildrenHierarchy( childNode, hierarchyManager.getChildren( child ),
hierarchyManager );
+            }
         }
     }
 

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/HierarchyViewLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/HierarchyViewLabelProvider.java?rev=581956&r1=581955&r2=581956&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/HierarchyViewLabelProvider.java
(original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/HierarchyViewLabelProvider.java
Thu Oct  4 09:04:11 2007
@@ -30,6 +30,7 @@
 import org.apache.directory.studio.schemaeditor.view.wrappers.ObjectClassWrapper;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.ui.ISharedImages;
 import org.eclipse.ui.PlatformUI;
@@ -49,13 +50,17 @@
     /** The preferences store */
     private IPreferenceStore store;
 
+    /** The TreeViewer */
+    private TreeViewer viewer;
+
 
     /**
      * Creates a new instance of SchemasViewLabelProvider.
      */
-    public HierarchyViewLabelProvider()
+    public HierarchyViewLabelProvider( TreeViewer viewer )
     {
         store = Activator.getDefault().getPreferenceStore();
+        this.viewer = viewer;
     }
 
 
@@ -273,13 +278,30 @@
     {
         if ( obj instanceof AttributeTypeWrapper )
         {
-            return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, PluginConstants.IMG_ATTRIBUTE_TYPE
)
-                .createImage();
+            if ( ( ( AttributeTypeWrapper ) obj ).getAttributeType().equals( viewer.getInput()
) )
+            {
+                return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+                    PluginConstants.IMG_ATTRIBUTE_TYPE_HIERARCHY_SELECTED ).createImage();
+            }
+            else
+            {
+                return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+                    PluginConstants.IMG_ATTRIBUTE_TYPE ).createImage();
+            }
         }
         else if ( obj instanceof ObjectClassWrapper )
         {
-            return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, PluginConstants.IMG_OBJECT_CLASS
)
-                .createImage();
+
+            if ( ( ( ObjectClassWrapper ) obj ).getObjectClass().equals( viewer.getInput()
) )
+            {
+                return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+                    PluginConstants.IMG_OBJECT_CLASS_HIERARCHY_SELECTED ).createImage();
+            }
+            else
+            {
+                return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+                    PluginConstants.IMG_OBJECT_CLASS ).createImage();
+            }
         }
 
         // Default



Mime
View raw message