You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2007/10/04 12:02:30 UTC

svn commit: r581831 - /directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/SchemaEditorSchemaCheckerLabelDecorator.java

Author: pamarcelot
Date: Thu Oct  4 03:02:27 2007
New Revision: 581831

URL: http://svn.apache.org/viewvc?rev=581831&view=rev
Log:
Part of a fix for DIRSTUDIO-200 (Add an OC and AT hierarchical global view)

Modified:
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/SchemaEditorSchemaCheckerLabelDecorator.java

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/SchemaEditorSchemaCheckerLabelDecorator.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/SchemaEditorSchemaCheckerLabelDecorator.java?rev=581831&r1=581830&r2=581831&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/SchemaEditorSchemaCheckerLabelDecorator.java (original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/SchemaEditorSchemaCheckerLabelDecorator.java Thu Oct  4 03:02:27 2007
@@ -20,6 +20,8 @@
 package org.apache.directory.studio.schemaeditor.view;
 
 
+import java.util.List;
+
 import org.apache.directory.studio.schemaeditor.Activator;
 import org.apache.directory.studio.schemaeditor.PluginConstants;
 import org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl;
@@ -30,7 +32,7 @@
 import org.apache.directory.studio.schemaeditor.view.wrappers.Folder;
 import org.apache.directory.studio.schemaeditor.view.wrappers.ObjectClassWrapper;
 import org.apache.directory.studio.schemaeditor.view.wrappers.SchemaWrapper;
-import org.apache.directory.studio.schemaeditor.view.wrappers.Folder.FolderType;
+import org.apache.directory.studio.schemaeditor.view.wrappers.TreeNode;
 import org.eclipse.jface.viewers.IDecoration;
 import org.eclipse.jface.viewers.ILightweightLabelDecorator;
 import org.eclipse.jface.viewers.LabelProvider;
@@ -125,47 +127,124 @@
         }
         else if ( element instanceof Folder )
         {
-            //TODO Add a workaround
-//            Folder folder = ( Folder ) element;
-//            
-//            Schema schema = ( ( SchemaWrapper ) folder.getParent() ).getSchema();
-//
-//            if ( folder.getType().equals( FolderType.ATTRIBUTE_TYPE ) )
-//            {
-//                for ( AttributeTypeImpl at : schema.getAttributeTypes() )
-//                {
-//                    if ( schemaChecker.hasErrors( at ) )
-//                    {
-//                        decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
-//                            PluginConstants.IMG_OVERLAY_ERROR ), IDecoration.BOTTOM_LEFT );
-//                        return;
-//                    }
-//
-//                    if ( schemaChecker.hasWarnings( at ) )
-//                    {
-//                        decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
-//                            PluginConstants.IMG_OVERLAY_WARNING ), IDecoration.BOTTOM_LEFT );
-//                    }
-//                }
-//            }
-//            else if ( folder.getType().equals( FolderType.OBJECT_CLASS ) )
-//            {
-//                for ( ObjectClassImpl oc : schema.getObjectClasses() )
-//                {
-//                    if ( schemaChecker.hasErrors( oc ) )
-//                    {
-//                        decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
-//                            PluginConstants.IMG_OVERLAY_ERROR ), IDecoration.BOTTOM_LEFT );
-//                        return;
-//                    }
-//
-//                    if ( schemaChecker.hasWarnings( oc ) )
-//                    {
-//                        decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
-//                            PluginConstants.IMG_OVERLAY_WARNING ), IDecoration.BOTTOM_LEFT );
-//                    }
-//                }
-//            }
+            Folder folder = ( Folder ) element;
+
+            if ( childrenHasErrors( folder.getChildren(), schemaChecker ) )
+            {
+                decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+                    PluginConstants.IMG_OVERLAY_ERROR ), IDecoration.BOTTOM_LEFT );
+                return;
+            }
+
+            if ( childrenHasWarnings( folder.getChildren(), schemaChecker ) )
+            {
+                decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+                    PluginConstants.IMG_OVERLAY_WARNING ), IDecoration.BOTTOM_LEFT );
+            }
         }
+    }
+
+
+    /**
+     * Verifies if the given children list contains elements that have warnings.
+     *
+     * @param children
+     *      the children list
+     * @param schemaChecker
+     *      the schemaChecker
+     * @return
+     *      true if the given children list contains elements that have warnings
+     */
+    public boolean childrenHasWarnings( List<TreeNode> children, SchemaChecker schemaChecker )
+    {
+        for ( TreeNode child : children )
+        {
+            if ( child instanceof AttributeTypeWrapper )
+            {
+                AttributeTypeImpl at = ( ( AttributeTypeWrapper ) child ).getAttributeType();
+
+                if ( schemaChecker.hasWarnings( at ) )
+                {
+                    return true;
+                }
+                else
+                {
+                    if ( childrenHasWarnings( child.getChildren(), schemaChecker ) )
+                    {
+                        return true;
+                    }
+                }
+            }
+            else if ( child instanceof ObjectClassWrapper )
+            {
+                ObjectClassImpl oc = ( ( ObjectClassWrapper ) child ).getObjectClass();
+
+                if ( schemaChecker.hasWarnings( oc ) )
+                {
+                    return true;
+                }
+                else
+                {
+                    if ( childrenHasWarnings( child.getChildren(), schemaChecker ) )
+                    {
+                        return true;
+                    }
+                }
+            }
+        }
+
+        return false;
+    }
+
+
+    /**
+    * Verifies if the given children list contains elements that have warnings.
+    *
+    * @param children
+    *      the children list
+    * @param schemaChecker
+    *      the schemaChecker
+    * @return
+    *      true if the given children list contains elements that have warnings
+    */
+    public boolean childrenHasErrors( List<TreeNode> children, SchemaChecker schemaChecker )
+    {
+        for ( TreeNode child : children )
+        {
+            if ( child instanceof AttributeTypeWrapper )
+            {
+                AttributeTypeImpl at = ( ( AttributeTypeWrapper ) child ).getAttributeType();
+
+                if ( schemaChecker.hasErrors( at ) )
+                {
+                    return true;
+                }
+                else
+                {
+                    if ( childrenHasErrors( child.getChildren(), schemaChecker ) )
+                    {
+                        return true;
+                    }
+                }
+            }
+            else if ( child instanceof ObjectClassWrapper )
+            {
+                ObjectClassImpl oc = ( ( ObjectClassWrapper ) child ).getObjectClass();
+
+                if ( schemaChecker.hasErrors( oc ) )
+                {
+                    return true;
+                }
+                else
+                {
+                    if ( childrenHasErrors( child.getChildren(), schemaChecker ) )
+                    {
+                        return true;
+                    }
+                }
+            }
+        }
+
+        return false;
     }
 }