directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r592094 [12/35] - in /directory/sandbox/felixk/studio-schemaeditor: ./ META-INF/ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/directory/ src/main/java/org/apache/directory/studio/ src/m...
Date Mon, 05 Nov 2007 17:15:02 GMT
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaChecker.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaChecker.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaChecker.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaChecker.java Mon Nov  5 09:14:24 2007
@@ -0,0 +1,930 @@
+/*
+ *  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.model.schemachecker;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.collections.MultiMap;
+import org.apache.commons.collections.map.MultiValueMap;
+import org.apache.directory.shared.ldap.schema.ObjectClassTypeEnum;
+import org.apache.directory.shared.ldap.schema.SchemaObject;
+import org.apache.directory.shared.ldap.schema.UsageEnum;
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.controller.SchemaHandler;
+import org.apache.directory.studio.schemaeditor.controller.SchemaHandlerAdapter;
+import org.apache.directory.studio.schemaeditor.controller.SchemaHandlerListener;
+import org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.schemaeditor.model.MatchingRuleImpl;
+import org.apache.directory.studio.schemaeditor.model.ObjectClassImpl;
+import org.apache.directory.studio.schemaeditor.model.Schema;
+import org.apache.directory.studio.schemaeditor.model.SyntaxImpl;
+import org.apache.directory.studio.schemaeditor.model.schemachecker.NonExistingMatchingRuleError.NonExistingMatchingRuleErrorEnum;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+
+
+/**
+ * This class represents the SchemaChecker.
+ * <p>
+ * It is used to check the schema integrity.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SchemaChecker
+{
+    /** The SchemaHandler */
+    private SchemaHandler schemaHandler;
+
+    /** The errors List */
+    private List<SchemaError> errorsList;
+
+    /** The errors MultiMap */
+    private MultiMap errorsMap;
+
+    /** The warnings List */
+    private List<SchemaWarning> warningsList;
+
+    /** The warnings MultiMap */
+    private MultiMap warningsMap;
+
+    /** The Dependencies MultiMap */
+    private MultiMap dependenciesMap;
+
+    /** The Depends On MultiMap */
+    private MultiMap dependsOnMap;
+
+    /** The 'listening to modifications' flag*/
+    private boolean listeningToModifications = false;
+
+    /** The listeners List */
+    private List<SchemaCheckerListener> listeners;
+
+    /** The SchemaHandlerListener */
+    private SchemaHandlerListener schemaHandlerListener = new SchemaHandlerAdapter()
+    {
+        public void attributeTypeAdded( AttributeTypeImpl at )
+        {
+            List<?> deps = getAndDeleteDependencies( at );
+
+            checkAttributeType( at );
+
+            checkDependencies( deps );
+
+            notifyListeners();
+        }
+
+
+        public void attributeTypeModified( AttributeTypeImpl at )
+        {
+            List<Object> deps = new ArrayList<Object>();
+            deps.addAll( ( List<?> ) dependenciesMap.get( at ) );
+
+            checkAttributeType( at );
+
+            checkDependencies( deps );
+
+            notifyListeners();
+        }
+
+
+        public void attributeTypeRemoved( AttributeTypeImpl at )
+        {
+            List<Object> deps = new ArrayList<Object>();
+            deps.addAll( ( List<?> ) dependenciesMap.get( at ) );
+
+            removeSchemaObject( at );
+
+            checkDependencies( deps );
+
+            notifyListeners();
+        }
+
+
+        public void objectClassAdded( ObjectClassImpl oc )
+        {
+            List<?> deps = getAndDeleteDependencies( oc );
+
+            checkObjectClass( oc );
+
+            checkDependencies( deps );
+
+            notifyListeners();
+        }
+
+
+        public void objectClassModified( ObjectClassImpl oc )
+        {
+            List<Object> deps = new ArrayList<Object>();
+            deps.addAll( ( List<?> ) dependenciesMap.get( oc ) );
+
+            checkObjectClass( oc );
+
+            checkDependencies( deps );
+
+            notifyListeners();
+        }
+
+
+        public void objectClassRemoved( ObjectClassImpl oc )
+        {
+            List<Object> deps = new ArrayList<Object>();
+            deps.addAll( ( List<?> ) dependenciesMap.get( oc ) );
+
+            removeSchemaObject( oc );
+
+            checkDependencies( deps );
+
+            notifyListeners();
+        }
+
+
+        public void schemaAdded( Schema schema )
+        {
+            List<AttributeTypeImpl> ats = schema.getAttributeTypes();
+            for ( AttributeTypeImpl at : ats )
+            {
+                checkAttributeType( at );
+            }
+
+            List<ObjectClassImpl> ocs = schema.getObjectClasses();
+            for ( ObjectClassImpl oc : ocs )
+            {
+                checkObjectClass( oc );
+            }
+
+            notifyListeners();
+        }
+
+
+        public void schemaRemoved( Schema schema )
+        {
+            List<AttributeTypeImpl> ats = schema.getAttributeTypes();
+            for ( AttributeTypeImpl at : ats )
+            {
+                removeSchemaObject( at );
+            }
+
+            List<ObjectClassImpl> ocs = schema.getObjectClasses();
+            for ( ObjectClassImpl oc : ocs )
+            {
+                removeSchemaObject( oc );
+            }
+
+            notifyListeners();
+        }
+    };
+
+
+    /**
+     * Creates a new instance of SchemaChecker.
+     */
+    public SchemaChecker()
+    {
+        schemaHandler = Activator.getDefault().getSchemaHandler();
+        errorsList = new ArrayList<SchemaError>();
+        errorsMap = new MultiValueMap();
+        warningsList = new ArrayList<SchemaWarning>();
+        warningsMap = new MultiValueMap();
+        dependenciesMap = new MultiValueMap();
+        dependsOnMap = new MultiValueMap();
+        listeners = new ArrayList<SchemaCheckerListener>();
+    }
+
+
+    /**
+     * Enables modifications listening.
+     */
+    public void enableModificationsListening()
+    {
+        if ( !listeningToModifications )
+        {
+            schemaHandler = Activator.getDefault().getSchemaHandler();
+            schemaHandler.addListener( schemaHandlerListener );
+            listeningToModifications = true;
+            checkWholeSchema();
+        }
+    }
+
+
+    /**
+     * Disables modifications listening.
+     */
+    public void disableModificationsListening()
+    {
+        if ( listeningToModifications )
+        {
+            schemaHandler.removeListener( schemaHandlerListener );
+            listeningToModifications = false;
+            clearErrorsAndWarnings();
+        }
+    }
+
+
+    /**
+     * Returns true if the SchemaChecker is listening to modifications, 
+     * false if not.
+     *
+     * @return
+     *      true if the SchemaChecker is listening to modifications, 
+     * false if not
+     */
+    public boolean isListeningToModifications()
+    {
+        return listeningToModifications;
+    }
+
+
+    /**
+     * Clears all the errors and warnings.
+     */
+    private void clearErrorsAndWarnings()
+    {
+        errorsList.clear();
+        errorsMap.clear();
+        warningsList.clear();
+        warningsMap.clear();
+        dependenciesMap.clear();
+        dependsOnMap.clear();
+    }
+
+
+    /**
+     * Checks the whole schema.
+     */
+    private void checkWholeSchema()
+    {
+        Job job = new Job( "Checking the Schema" )
+        {
+            protected IStatus run( IProgressMonitor monitor )
+            {
+                List<Schema> schemas = schemaHandler.getSchemas();
+                monitor.beginTask( "Checking schemas: ", schemas.size() );
+                for ( Schema schema : schemas )
+                {
+                    monitor.subTask( schema.getName() );
+                    List<AttributeTypeImpl> ats = schema.getAttributeTypes();
+                    for ( AttributeTypeImpl at : ats )
+                    {
+                        checkAttributeType( at );
+                    }
+
+                    List<ObjectClassImpl> ocs = schema.getObjectClasses();
+                    for ( ObjectClassImpl oc : ocs )
+                    {
+                        checkObjectClass( oc );
+                    }
+                    monitor.worked( 1 );
+                }
+                notifyListeners();
+                monitor.done();
+
+                return Status.OK_STATUS;
+            }
+        };
+
+        job.setUser( true );
+        //        job.setPriority( Job.SHORT );
+        job.schedule();
+    }
+
+
+    /**
+     * Checks the given attribute type.
+     *
+     * @param at
+     *      an attribute type
+     */
+    private void checkAttributeType( AttributeTypeImpl at )
+    {
+        removeSchemaObject( at );
+
+        // Checking OID
+        String oid = at.getOid();
+        if ( ( oid != null ) && ( !"".equals( oid ) ) )
+        {
+            List<?> list = getSchemaElementList( oid );
+            if ( ( list != null ) && ( list.size() >= 2 ) )
+            {
+                int counter = 0;
+                Object o = list.get( counter );
+                while ( ( at.equals( o ) ) && ( counter < ( list.size() - 1 ) ) )
+                {
+                    counter++;
+                    o = list.get( counter );
+                }
+                SchemaError error = new DuplicateOidError( at, oid, ( SchemaObject ) o );
+                errorsList.add( error );
+                errorsMap.put( at, error );
+            }
+        }
+
+        // Checking aliases
+        String[] aliases = at.getNames();
+        if ( ( aliases == null ) || ( aliases.length == 0 ) )
+        {
+            SchemaWarning warning = new NoAliasWarning( at );
+            warningsList.add( warning );
+            warningsMap.put( at, warning );
+        }
+        else if ( ( aliases != null ) && ( aliases.length >= 1 ) )
+        {
+            for ( String alias : aliases )
+            {
+                List<?> list = getSchemaElementList( alias );
+                if ( ( list != null ) && ( list.size() >= 2 ) )
+                {
+                    int counter = 0;
+                    Object o = list.get( counter );
+                    while ( ( at.equals( o ) ) && ( counter < ( list.size() - 1 ) ) )
+                    {
+                        counter++;
+                        o = list.get( counter );
+                    }
+                    SchemaError error = new DuplicateAliasError( at, alias, ( SchemaObject ) o );
+                    errorsList.add( error );
+                    errorsMap.put( at, error );
+                }
+            }
+        }
+
+        // Checking superior
+        String superior = at.getSuperiorName();
+        if ( ( superior != null ) && ( !"".equals( superior ) ) )
+        {
+            AttributeTypeImpl superiorAT = schemaHandler.getAttributeType( superior );
+            if ( superiorAT == null )
+            {
+                SchemaError error = new NonExistingATSuperiorError( at, superior );
+                errorsList.add( error );
+                errorsMap.put( at, error );
+                dependenciesMap.put( superior, at );
+                dependsOnMap.put( at, superior );
+            }
+            else
+            {
+                dependenciesMap.put( superiorAT, at );
+                dependsOnMap.put( at, superiorAT );
+
+                // Checking Usage with superior's
+                UsageEnum usage = at.getUsage();
+                UsageEnum superiorATUsage = superiorAT.getUsage();
+                if ( !usage.equals( superiorATUsage ) )
+                {
+                    SchemaError error = new DifferentUsageAsSuperiorError( at, superiorAT );
+                    errorsList.add( error );
+                    errorsMap.put( at, error );
+                }
+
+                // Checking Collective with superior's
+                boolean collective = at.isCollective();
+                boolean superiorATCollective = superiorAT.isCollective();
+                if ( superiorATCollective && !collective )
+                {
+                    SchemaError error = new DifferentCollectiveAsSuperiorError( at, superiorAT );
+                    errorsList.add( error );
+                    errorsMap.put( at, error );
+                }
+            }
+        }
+
+        // Checking syntax
+        String syntaxOid = at.getSyntaxOid();
+        if ( ( syntaxOid != null ) && ( !"".equals( syntaxOid ) ) )
+        {
+            SyntaxImpl syntax = schemaHandler.getSyntax( syntaxOid );
+            if ( syntax == null )
+            {
+                SchemaError error = new NonExistingSyntaxError( at, syntaxOid );
+                errorsList.add( error );
+                errorsMap.put( at, error );
+                dependenciesMap.put( syntaxOid, at );
+                dependsOnMap.put( at, syntaxOid );
+            }
+            else
+            {
+                dependenciesMap.put( syntax, at );
+                dependsOnMap.put( at, syntax );
+            }
+        }
+
+        // Equality matching rule
+        String equality = at.getEqualityName();
+        if ( ( equality != null ) && ( !"".equals( equality ) ) )
+        {
+            MatchingRuleImpl equalityMR = schemaHandler.getMatchingRule( equality );
+            if ( equalityMR == null )
+            {
+                SchemaError error = new NonExistingMatchingRuleError( at, equality,
+                    NonExistingMatchingRuleErrorEnum.EQUALITY );
+                errorsList.add( error );
+                errorsMap.put( at, error );
+                dependenciesMap.put( equality, at );
+                dependsOnMap.put( at, equality );
+            }
+            else
+            {
+                dependenciesMap.put( equalityMR, at );
+                dependsOnMap.put( at, equalityMR );
+            }
+        }
+
+        // Ordering matching rule
+        String ordering = at.getOrderingName();
+        if ( ( ordering != null ) && ( !"".equals( ordering ) ) )
+        {
+            MatchingRuleImpl orderingMR = schemaHandler.getMatchingRule( ordering );
+            if ( orderingMR == null )
+            {
+                SchemaError error = new NonExistingMatchingRuleError( at, ordering,
+                    NonExistingMatchingRuleErrorEnum.ORDERING );
+                errorsList.add( error );
+                errorsMap.put( at, error );
+                dependenciesMap.put( ordering, at );
+                dependsOnMap.put( at, ordering );
+            }
+            else
+            {
+                dependenciesMap.put( orderingMR, at );
+                dependsOnMap.put( at, orderingMR );
+            }
+        }
+
+        // Substring matching rule
+        String substring = at.getSubstrName();
+        if ( ( substring != null ) && ( !"".equals( substring ) ) )
+        {
+            MatchingRuleImpl substringMR = schemaHandler.getMatchingRule( substring );
+            if ( substringMR == null )
+            {
+                SchemaError error = new NonExistingMatchingRuleError( at, substring,
+                    NonExistingMatchingRuleErrorEnum.SUBSTRING );
+                errorsList.add( error );
+                errorsMap.put( at, error );
+                dependenciesMap.put( substring, at );
+                dependsOnMap.put( at, substring );
+            }
+            else
+            {
+                dependenciesMap.put( substringMR, at );
+                dependsOnMap.put( at, substringMR );
+            }
+        }
+    }
+
+
+    /**
+     * Checks the given object class.
+     *
+     * @param oc
+     *      an object class
+     */
+    private void checkObjectClass( ObjectClassImpl oc )
+    {
+        removeSchemaObject( oc );
+
+        // Checking OID
+        String oid = oc.getOid();
+        if ( ( oid != null ) && ( !"".equals( oid ) ) )
+        {
+            List<?> list = getSchemaElementList( oid );
+            if ( ( list != null ) && ( list.size() >= 2 ) )
+            {
+                int counter = 0;
+                Object o = list.get( counter );
+                while ( ( oc.equals( o ) ) && ( counter < ( list.size() - 1 ) ) )
+                {
+                    counter++;
+                    o = list.get( counter );
+                }
+                SchemaError error = new DuplicateOidError( oc, oid, ( SchemaObject ) o );
+                errorsList.add( error );
+                errorsMap.put( oc, error );
+            }
+        }
+
+        // Checking aliases
+        String[] aliases = oc.getNames();
+        if ( ( aliases == null ) || ( aliases.length == 0 ) )
+        {
+            SchemaWarning warning = new NoAliasWarning( oc );
+            warningsList.add( warning );
+            warningsMap.put( oc, warning );
+        }
+        else if ( ( aliases != null ) && ( aliases.length >= 1 ) )
+        {
+            for ( String alias : aliases )
+            {
+                List<?> list = getSchemaElementList( alias );
+                if ( ( list != null ) && ( list.size() >= 2 ) )
+                {
+                    int counter = 0;
+                    Object o = list.get( counter );
+                    while ( ( oc.equals( o ) ) && ( counter < ( list.size() - 1 ) ) )
+                    {
+                        counter++;
+                        o = list.get( counter );
+                    }
+                    SchemaError error = new DuplicateAliasError( oc, oid, ( SchemaObject ) o );
+                    errorsList.add( error );
+                    errorsMap.put( oc, error );
+                }
+            }
+        }
+
+        // Checking superiors
+        String[] superiors = oc.getSuperClassesNames();
+        if ( ( superiors != null ) && ( superiors.length >= 1 ) )
+        {
+            ObjectClassTypeEnum type = oc.getType();
+
+            for ( String superior : superiors )
+            {
+                ObjectClassImpl superiorOC = schemaHandler.getObjectClass( superior );
+                if ( superiorOC == null )
+                {
+                    SchemaError error = new NonExistingOCSuperiorError( oc, superior );
+                    errorsList.add( error );
+                    errorsMap.put( oc, error );
+                    dependenciesMap.put( superior, oc );
+                    dependsOnMap.put( oc, superior );
+                }
+                else
+                {
+                    dependenciesMap.put( superiorOC, oc );
+                    dependsOnMap.put( oc, superiorOC );
+
+                    // Checking Type of Superior Hierarchy
+                    ObjectClassTypeEnum superiorOCType = superiorOC.getType();
+                    switch ( type )
+                    {
+                        case ABSTRACT:
+                            if ( ( !superiorOCType.equals( ObjectClassTypeEnum.ABSTRACT ) )
+                                && ( !superiorOC.getOid().equals( "2.5.6.0" ) ) )
+                            {
+                                SchemaError error = new ClassTypeHierarchyError( oc, superiorOC );
+                                errorsList.add( error );
+                                errorsMap.put( oc, error );
+                            }
+                            break;
+                        case AUXILIARY:
+                            if ( ( superiorOCType.equals( ObjectClassTypeEnum.STRUCTURAL ) )
+                                && ( !superiorOC.getOid().equals( "2.5.6.0" ) ) )
+                            {
+                                SchemaError error = new ClassTypeHierarchyError( oc, superiorOC );
+                                errorsList.add( error );
+                                errorsMap.put( oc, error );
+                            }
+                            break;
+
+                        default:
+                            break;
+                    }
+                }
+            }
+        }
+
+        // Checking mandatory and optional attributes
+        String[] mandatoryATNames = oc.getMustNamesList();
+        String[] optionalATNames = oc.getMayNamesList();
+        if ( ( mandatoryATNames != null ) && ( optionalATNames != null ) )
+        {
+            for ( String mandatoryATName : mandatoryATNames )
+            {
+                AttributeTypeImpl mandatoryAT = schemaHandler.getAttributeType( mandatoryATName );
+                if ( mandatoryAT == null )
+                {
+                    SchemaError error = new NonExistingMandatoryATError( oc, mandatoryATName );
+                    errorsList.add( error );
+                    errorsMap.put( oc, error );
+                    dependenciesMap.put( mandatoryATName, oc );
+                    dependsOnMap.put( oc, mandatoryATName );
+                }
+                else
+                {
+                    dependenciesMap.put( mandatoryAT, oc );
+                    dependsOnMap.put( oc, mandatoryAT );
+                }
+            }
+
+            for ( String optionalATName : optionalATNames )
+            {
+                AttributeTypeImpl optionalAT = schemaHandler.getAttributeType( optionalATName );
+                if ( optionalAT == null )
+                {
+                    SchemaError error = new NonExistingOptionalATError( oc, optionalATName );
+                    errorsList.add( error );
+                    errorsMap.put( oc, error );
+                    dependenciesMap.put( optionalATName, oc );
+                    dependsOnMap.put( oc, optionalATName );
+                }
+                else
+                {
+                    dependenciesMap.put( optionalAT, oc );
+                    dependsOnMap.put( oc, optionalAT );
+                }
+            }
+        }
+    }
+
+
+    /**
+     * Remove the errors and warnings for the given schema element.
+     *
+     * @param element
+     *      a schema element
+     */
+    private void removeSchemaObject( SchemaObject element )
+    {
+        // Removing old errors and warnings
+        List<?> errors = ( List<?> ) errorsMap.get( element );
+        if ( ( errors != null ) && ( errors.size() >= 1 ) )
+        {
+            for ( Object error : errors )
+            {
+                errorsList.remove( error );
+            }
+            errorsMap.remove( element );
+        }
+        List<?> warnings = ( List<?> ) warningsMap.get( element );
+        if ( ( warnings != null ) && ( warnings.size() >= 1 ) )
+        {
+            for ( Object warning : warnings )
+            {
+                warningsList.remove( warning );
+            }
+            warningsMap.remove( element );
+        }
+
+        // Removing 'depends on' and dependencies
+        List<?> dependsOn = ( List<?> ) dependsOnMap.get( element );
+        if ( dependsOn != null )
+        {
+            for ( Object dep : dependsOn )
+            {
+                dependenciesMap.remove( dep, element );
+            }
+            dependsOnMap.remove( element );
+        }
+    }
+
+
+    @SuppressWarnings("unchecked")
+    private List<?> getSchemaElementList( String id )
+    {
+        List results = new ArrayList<Object>();
+
+        // Attribute types
+        List<?> atList = schemaHandler.getAttributeTypeList( id );
+        if ( ( atList != null ) && ( atList.size() >= 1 ) )
+        {
+            results.addAll( atList );
+        }
+
+        // Object classes
+        List<?> ocList = schemaHandler.getObjectClassList( id );
+        if ( ( ocList != null ) && ( ocList.size() >= 1 ) )
+        {
+            results.addAll( ocList );
+        }
+
+        return results;
+    }
+
+
+    /**
+     * Gets the errors.
+     *
+     * @return
+     *      the errors
+     */
+    public List<SchemaError> getErrors()
+    {
+        return errorsList;
+    }
+
+
+    /**
+     * Gets the warnings.
+     *
+     * @return
+     *      the warnings
+     */
+    public List<SchemaWarning> getWarnings()
+    {
+        return warningsList;
+    }
+
+
+    /**
+     * Adds a SchemaCheckerListener.
+     *
+     * @param listener
+     *      the listener
+     */
+    public void addListener( SchemaCheckerListener listener )
+    {
+        if ( !listeners.contains( listener ) )
+        {
+            listeners.add( listener );
+        }
+    }
+
+
+    /**
+     * Removes a SchemaCheckerListener.
+     *
+     * @param listener
+     *      the listener
+     */
+    public void removeListener( SchemaCheckerListener listener )
+    {
+        listeners.remove( listener );
+    }
+
+
+    /**
+     * Notifies the listeners.
+     */
+    private void notifyListeners()
+    {
+        for ( SchemaCheckerListener listener : listeners )
+        {
+            listener.schemaCheckerUpdated();
+        }
+    }
+
+
+    /**
+     * Gets the errors associated with the given Schema Object
+     *
+     * @param so
+     *      the Schema Object
+     * @return
+     *      the associated errors
+     */
+    public List<?> getErrors( SchemaObject so )
+    {
+        return ( List<?> ) errorsMap.get( so );
+    }
+
+
+    /**
+     * Returns whether the given Schema Object has errors.
+     *
+     * @param so
+     *      the Schema Object
+     * @return
+     *      true if the given Schema Object has errors.
+     */
+    public boolean hasErrors( SchemaObject so )
+    {
+        List<?> errors = getErrors( so );
+
+        if ( errors == null )
+        {
+            return false;
+        }
+        else
+        {
+            return errors.size() > 0;
+        }
+    }
+
+
+    /**
+     * Gets the warnings associated with the given Schema Object
+     *
+     * @param so
+     *      the Schema Object
+     * @return
+     *      the associated warnings
+     */
+    public List<?> getWarnings( SchemaObject so )
+    {
+        return ( List<?> ) warningsMap.get( so );
+    }
+
+
+    /**
+     * Returns whether the given Schema Object has warnings.
+     *
+     * @param so
+     *      the Schema Object
+     * @return
+     *      true if the given Schema Object has errors.
+     */
+    public boolean hasWarnings( SchemaObject so )
+    {
+        List<?> warnings = getWarnings( so );
+
+        if ( warnings == null )
+        {
+            return false;
+        }
+        else
+        {
+            return warnings.size() > 0;
+        }
+    }
+
+
+    /**
+     * Checks the given list of dependencies.
+     * 
+     * @param deps
+     *      the list of dependencies
+     */
+    public void checkDependencies( List<?> deps )
+    {
+        if ( deps != null )
+        {
+            for ( Object object : deps )
+            {
+                if ( object instanceof AttributeTypeImpl )
+                {
+                    checkAttributeType( ( AttributeTypeImpl ) object );
+                }
+                else if ( object instanceof ObjectClassImpl )
+                {
+                    checkObjectClass( ( ObjectClassImpl ) object );
+                }
+            }
+        }
+    }
+
+
+    /**
+     * Gets the dependencies for the given schema object
+     * and deletes them from the tables.
+     *
+     * @param sc
+     *      the schema object
+     * @return
+     *      the dependencies for the given schema object
+     * and deletes them from the tables.
+     */
+    @SuppressWarnings("unchecked")
+    private List<Object> getAndDeleteDependencies( SchemaObject sc )
+    {
+        List<Object> deps = new ArrayList<Object>();
+
+        // Checking OID
+        String oid = sc.getOid();
+        if ( ( oid != null ) && ( !"".equals( oid ) ) )
+        {
+            List<Object> oidDependencies = ( List<Object> ) dependenciesMap.get( oid );
+            if ( oidDependencies != null )
+            {
+                deps.addAll( oidDependencies );
+                dependenciesMap.remove( oid );
+                for ( Object oidDependency : oidDependencies )
+                {
+                    dependsOnMap.remove( oidDependency, oid );
+                }
+            }
+        }
+
+        // Checking aliases
+        String[] aliases = sc.getNames();
+        if ( ( aliases != null ) && ( aliases.length > 0 ) )
+        {
+            for ( String alias : aliases )
+            {
+                List<Object> aliasDependencies = ( List<Object> ) dependenciesMap.get( alias );
+                if ( aliasDependencies != null )
+                {
+                    deps.addAll( aliasDependencies );
+                    dependenciesMap.remove( alias );
+                    for ( Object aliasDependency : aliasDependencies )
+                    {
+                        dependsOnMap.remove( aliasDependency, alias );
+                    }
+                }
+            }
+        }
+
+        return deps;
+    }
+}

Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaChecker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaCheckerElement.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaCheckerElement.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaCheckerElement.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaCheckerElement.java Mon Nov  5 09:14:24 2007
@@ -0,0 +1,41 @@
+/*
+ *  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.model.schemachecker;
+
+
+import org.apache.directory.shared.ldap.schema.SchemaObject;
+
+
+/**
+ * Common interface for the all the schema errors.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface SchemaCheckerElement
+{
+    /**
+     * Gets the source object.
+     * 
+     * @return
+     *      the source object
+     */
+    public SchemaObject getSource();
+}

Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaCheckerElement.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaCheckerListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaCheckerListener.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaCheckerListener.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaCheckerListener.java Mon Nov  5 09:14:24 2007
@@ -0,0 +1,36 @@
+/*
+ *  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.model.schemachecker;
+
+
+/**
+ * Classes which implement this interface provide methods that deal with the 
+ * events that are generated when an event occurrs on the SchemaChecker.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface SchemaCheckerListener
+{
+    /**
+     * This methods is called when the SchemaChecker is updated.
+     */
+    public void schemaCheckerUpdated();
+}

Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaCheckerListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaError.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaError.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaError.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaError.java Mon Nov  5 09:14:24 2007
@@ -0,0 +1,31 @@
+/*
+ *  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.model.schemachecker;
+
+
+/**
+ * Common interface for the all the schema errors.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface SchemaError extends SchemaCheckerElement
+{
+}

Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaError.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaWarning.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaWarning.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaWarning.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaWarning.java Mon Nov  5 09:14:24 2007
@@ -0,0 +1,31 @@
+/*
+ *  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.model.schemachecker;
+
+
+/**
+ * Common interface for all the schema warnings.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface SchemaWarning extends SchemaCheckerElement
+{
+}

Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaWarning.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/Perspective.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/Perspective.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/Perspective.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/Perspective.java Mon Nov  5 09:14:24 2007
@@ -0,0 +1,101 @@
+/*
+ *  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.view;
+
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.view.views.HierarchyView;
+import org.apache.directory.studio.schemaeditor.view.views.ProblemsView;
+import org.apache.directory.studio.schemaeditor.view.views.ProjectsView;
+import org.apache.directory.studio.schemaeditor.view.views.SchemaView;
+import org.apache.directory.studio.schemaeditor.view.views.SearchView;
+import org.apache.directory.studio.schemaeditor.view.wizards.NewAttributeTypeWizard;
+import org.apache.directory.studio.schemaeditor.view.wizards.NewObjectClassWizard;
+import org.apache.directory.studio.schemaeditor.view.wizards.NewProjectWizard;
+import org.apache.directory.studio.schemaeditor.view.wizards.NewSchemaWizard;
+import org.eclipse.ui.IFolderLayout;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+
+
+/**
+ * This class represents the Schema Editor Perspective.
+ * <p>
+ * It is composed of two views, the Schema View and the Problems View, and the editor part.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class Perspective implements IPerspectiveFactory
+{
+    /** The ID of the view */
+    public static final String ID = Activator.PLUGIN_ID + ".perspective"; //$NON-NLS-1$
+
+    /** The ID of the top left folder */
+    public static final String topLeftFolderId = "org.apache.directory.studio.schemaeditor.topleftfolder"; //$NON-NLS-1$
+
+    /** The ID of the bottom folder */
+    public static final String bottomFolderId = "org.apache.directory.studio.schemaeditor.bottomfolder"; //$NON-NLS-1$
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui.IPageLayout)
+     */
+    public void createInitialLayout( IPageLayout layout )
+    {
+        // Allowing the Editor Area
+        layout.setEditorAreaVisible( true );
+        String editorAreaId = layout.getEditorArea();
+
+        // Creating top left folder 
+        IFolderLayout topLeftFolder = layout.createFolder( topLeftFolderId, IPageLayout.LEFT, 0.3f, editorAreaId );
+
+        // Creating bottom folder 
+        IFolderLayout bottomFolder = layout.createFolder( bottomFolderId, IPageLayout.BOTTOM, 0.7f, editorAreaId );
+
+        // Adding Views
+        topLeftFolder.addView( SchemaView.ID );
+        topLeftFolder.addView( HierarchyView.ID );
+        layout.addStandaloneView( ProjectsView.ID, true, IPageLayout.BOTTOM, 0.7f, topLeftFolderId );
+        bottomFolder.addView( ProblemsView.ID );
+        bottomFolder.addView( SearchView.ID );
+
+        // Setting up non-closeable views
+        layout.getViewLayout( SchemaView.ID ).setCloseable( false );
+        layout.getViewLayout( ProjectsView.ID ).setCloseable( false );
+
+        // Adding Perspective shortcuts
+        layout.addPerspectiveShortcut( "org.apache.directory.studio.ldapbrowser.ui.perspective.BrowserPerspective" ); //$NON-NLS-1$
+        layout.addPerspectiveShortcut( Perspective.ID );
+
+        // Adding View shortcuts
+        layout.addShowViewShortcut( SchemaView.ID );
+        layout.addShowViewShortcut( ProjectsView.ID );
+        layout.addShowViewShortcut( ProblemsView.ID );
+        layout.addShowViewShortcut( HierarchyView.ID );
+        layout.addShowViewShortcut( SearchView.ID );
+
+        // Adding New Wizard shortcuts
+        layout.addNewWizardShortcut( NewProjectWizard.ID );
+        layout.addNewWizardShortcut( NewSchemaWizard.ID );
+        layout.addNewWizardShortcut( NewAttributeTypeWizard.ID );
+        layout.addNewWizardShortcut( NewObjectClassWizard.ID );
+    }
+}

Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/Perspective.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/SchemaEditorSchemaCheckerLabelDecorator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/SchemaEditorSchemaCheckerLabelDecorator.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/SchemaEditorSchemaCheckerLabelDecorator.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/SchemaEditorSchemaCheckerLabelDecorator.java Mon Nov  5 09:14:24 2007
@@ -0,0 +1,250 @@
+/*
+ *  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.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;
+import org.apache.directory.studio.schemaeditor.model.ObjectClassImpl;
+import org.apache.directory.studio.schemaeditor.model.Schema;
+import org.apache.directory.studio.schemaeditor.model.schemachecker.SchemaChecker;
+import org.apache.directory.studio.schemaeditor.view.wrappers.AttributeTypeWrapper;
+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.TreeNode;
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.jface.viewers.ILightweightLabelDecorator;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class is the Schemas Editor Schema Checker Label Decorator. 
+ * It displays specific icons overlays for attribute types and object classes.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SchemaEditorSchemaCheckerLabelDecorator extends LabelProvider implements ILightweightLabelDecorator
+{
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, org.eclipse.jface.viewers.IDecoration)
+     */
+    public void decorate( Object element, IDecoration decoration )
+    {
+        SchemaChecker schemaChecker = Activator.getDefault().getSchemaChecker();
+
+        if ( element instanceof AttributeTypeWrapper )
+        {
+            AttributeTypeImpl at = ( ( AttributeTypeWrapper ) element ).getAttributeType();
+
+            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 ( element instanceof ObjectClassWrapper )
+        {
+            ObjectClassImpl oc = ( ( ObjectClassWrapper ) element ).getObjectClass();
+
+            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 );
+            }
+        }
+        else if ( element instanceof SchemaWrapper )
+        {
+            Schema schema = ( ( SchemaWrapper ) element ).getSchema();
+
+            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 );
+                }
+            }
+
+            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 );
+                }
+            }
+        }
+        else if ( element instanceof Folder )
+        {
+            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;
+    }
+}

Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/SchemaEditorSchemaCheckerLabelDecorator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/SchemaEditorTypeLabelDecorator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/SchemaEditorTypeLabelDecorator.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/SchemaEditorTypeLabelDecorator.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/SchemaEditorTypeLabelDecorator.java Mon Nov  5 09:14:24 2007
@@ -0,0 +1,120 @@
+/*
+ *  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.view;
+
+
+import org.apache.directory.shared.ldap.schema.ObjectClassTypeEnum;
+import org.apache.directory.shared.ldap.schema.UsageEnum;
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.schemaeditor.model.ObjectClassImpl;
+import org.apache.directory.studio.schemaeditor.view.wrappers.AttributeTypeWrapper;
+import org.apache.directory.studio.schemaeditor.view.wrappers.ObjectClassWrapper;
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.jface.viewers.ILightweightLabelDecorator;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class is the Schemas Editor Type Label Decorator. 
+ * It displays specific icons overlays for attribute types and object classes.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SchemaEditorTypeLabelDecorator extends LabelProvider implements ILightweightLabelDecorator
+{
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, org.eclipse.jface.viewers.IDecoration)
+     */
+    public void decorate( Object element, IDecoration decoration )
+    {
+        if ( element instanceof AttributeTypeWrapper )
+        {
+            UsageEnum usage = ( ( AttributeTypeWrapper ) element ).getAttributeType().getUsage();
+            if ( usage == UsageEnum.USER_APPLICATIONS )
+            {
+                decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+                    PluginConstants.IMG_ATTRIBUTE_TYPE_OVERLAY_USER_APPLICATION ), IDecoration.BOTTOM_RIGHT );
+            }
+            else if ( ( usage == UsageEnum.DIRECTORY_OPERATION ) || ( usage == UsageEnum.DISTRIBUTED_OPERATION )
+                || ( usage == UsageEnum.DSA_OPERATION ) )
+            {
+                decoration.addOverlay( Activator.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+                    PluginConstants.IMG_ATTRIBUTE_TYPE_OVERLAY_OPERATION ), IDecoration.BOTTOM_RIGHT );
+            }
+        }
+        else if ( element instanceof ObjectClassWrapper )
+        {
+            ObjectClassTypeEnum classType = ( ( ObjectClassWrapper ) element ).getObjectClass().getType();
+            if ( classType == ObjectClassTypeEnum.ABSTRACT )
+            {
+                decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+                    PluginConstants.IMG_OBJECT_CLASS_OVERLAY_ABSTRACT ), IDecoration.BOTTOM_RIGHT );
+            }
+            else if ( classType == ObjectClassTypeEnum.STRUCTURAL )
+            {
+                decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+                    PluginConstants.IMG_OBJECT_CLASS_OVERLAY_STRUCTURAL ), IDecoration.BOTTOM_RIGHT );
+            }
+            else if ( classType == ObjectClassTypeEnum.AUXILIARY )
+            {
+                decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+                    PluginConstants.IMG_OBJECT_CLASS_OVERLAY_AUXILIARY ), IDecoration.BOTTOM_RIGHT );
+            }
+        }
+        else if ( element instanceof AttributeTypeImpl )
+        {
+            UsageEnum usage = ( ( AttributeTypeImpl ) element ).getUsage();
+            if ( usage == UsageEnum.USER_APPLICATIONS )
+            {
+                decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+                    PluginConstants.IMG_ATTRIBUTE_TYPE_OVERLAY_USER_APPLICATION ), IDecoration.BOTTOM_RIGHT );
+            }
+            else if ( ( usage == UsageEnum.DIRECTORY_OPERATION ) || ( usage == UsageEnum.DISTRIBUTED_OPERATION )
+                || ( usage == UsageEnum.DSA_OPERATION ) )
+            {
+                decoration.addOverlay( Activator.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+                    PluginConstants.IMG_ATTRIBUTE_TYPE_OVERLAY_OPERATION ), IDecoration.BOTTOM_RIGHT );
+            }
+        }
+        else if ( element instanceof ObjectClassImpl )
+        {
+            ObjectClassTypeEnum classType = ( ( ObjectClassImpl ) element ).getType();
+            if ( classType == ObjectClassTypeEnum.ABSTRACT )
+            {
+                decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+                    PluginConstants.IMG_OBJECT_CLASS_OVERLAY_ABSTRACT ), IDecoration.BOTTOM_RIGHT );
+            }
+            else if ( classType == ObjectClassTypeEnum.STRUCTURAL )
+            {
+                decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+                    PluginConstants.IMG_OBJECT_CLASS_OVERLAY_STRUCTURAL ), IDecoration.BOTTOM_RIGHT );
+            }
+            else if ( classType == ObjectClassTypeEnum.AUXILIARY )
+            {
+                decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+                    PluginConstants.IMG_OBJECT_CLASS_OVERLAY_AUXILIARY ), IDecoration.BOTTOM_RIGHT );
+            }
+        }
+    }
+}

Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/SchemaEditorTypeLabelDecorator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/ViewUtils.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/ViewUtils.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/ViewUtils.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/ViewUtils.java Mon Nov  5 09:14:24 2007
@@ -0,0 +1,177 @@
+/*
+ *  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.view;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * This Helper Class contains useful methods used to create the UI.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ViewUtils
+{
+    /** The Black Color */
+    public static final Color COLOR_BLACK = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()
+        .getDisplay().getSystemColor( SWT.COLOR_BLACK );
+
+    /** The Red Color */
+    public static final Color COLOR_RED = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getDisplay()
+        .getSystemColor( SWT.COLOR_RED );
+
+
+    /**
+     * Concatenates all aliases in a String format. Aliases are separated with a comma (',')
+     *
+     * @param aliases
+     *      the aliases to concatenate
+     * @return
+     *      a String representing all aliases
+     */
+    public static String concateAliases( String[] aliases )
+    {
+        StringBuffer sb = new StringBuffer();
+        if ( aliases.length > 0 )
+        {
+            sb.append( aliases[0] );
+            for ( int i = 1; i < aliases.length; i++ )
+            {
+                sb.append( ", " ); //$NON-NLS-1$
+                sb.append( aliases[i] );
+            }
+        }
+
+        return sb.toString();
+    }
+
+
+    /**
+     * Verifies that the given name is syntaxely correct according to the RFC 2252 
+     * (Lightweight Directory Access Protocol (v3): Attribute Syntax Definitions).
+     *
+     * @param name
+     *      the name to test
+     * @return
+     *      true if the name is correct, false if the name is not correct.
+     */
+    public static boolean verifyName( String name )
+    {
+        return name.matches( "[a-zA-Z]+[a-zA-Z0-9;-]*" ); //$NON-NLS-1$
+    }
+
+
+    /**
+     * Displays an Error Message Box with the given title and message.
+     *
+     * @param title
+     *      the title of the window
+     * @param message
+     *      the message to display
+     * @return
+     *      the ID of the button that was selected to dismiss 
+     *      the message box (e.g. SWT.OK, SWT.CANCEL, etc...)
+     */
+    public static int displayErrorMessageBox( String title, String message )
+    {
+        return displayMessageBox( SWT.OK | SWT.ICON_ERROR, title, message );
+    }
+
+
+    /**
+     * Displays a Information Message Box with the given title and message.
+     *
+     * @param title
+     *      the title of the window
+     * @param message
+     *      the message to display
+     * @return
+     *      the ID of the button that was selected to dismiss 
+     *      the message box (e.g. SWT.OK, SWT.CANCEL, etc...)
+     */
+    public static int displayWarningMessageBox( String title, String message )
+    {
+        return displayMessageBox( SWT.OK | SWT.ICON_WARNING, title, message );
+    }
+
+
+    /**
+     * Displays a Information Message Box with the given title and message.
+     *
+     * @param title
+     *      the title of the window
+     * @param message
+     *      the message to display
+     * @return
+     *      the ID of the button that was selected to dismiss 
+     *      the message box (e.g. SWT.OK, SWT.CANCEL, etc...)
+     */
+    public static int displayInformationMessageBox( String title, String message )
+    {
+        return displayMessageBox( SWT.OK | SWT.ICON_INFORMATION, title, message );
+    }
+
+
+    /**
+     * Displays a Information Question Box with the given title and message.
+     *
+     * @param buttonStyle
+     *      the style of the buttons of the dialog (e.g. SWT.OK, SWT.CANCEL, etc...)
+     * @param title
+     *      the title of the window
+     * @param message
+     *      the message to display
+     * @return
+     *      the ID of the button that was selected to dismiss 
+     *      the message box (e.g. SWT.OK, SWT.CANCEL, etc...)
+     */
+    public static int displayQuestionMessageBox( int buttonStyle, String title, String message )
+    {
+        return displayMessageBox( SWT.ICON_QUESTION | buttonStyle, title, message );
+    }
+
+
+    /**
+     * Displays a Message Box with the given style, title and message.
+     *
+     * @param style
+     *      the style of dialog
+     * @param title
+     *      the title of the window
+     * @param message
+     *      the message to display
+     * @return
+     *      the ID of the button that was selected to dismiss 
+     *      the message box (e.g. SWT.OK, SWT.CANCEL, etc...)
+     */
+    private static int displayMessageBox( int style, String title, String message )
+    {
+        MessageBox messageBox = new MessageBox( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), style );
+        messageBox.setText( title );
+        messageBox.setMessage( message );
+        return messageBox.open();
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/ViewUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/dialogs/AttributeTypeSelectionDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/dialogs/AttributeTypeSelectionDialog.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/dialogs/AttributeTypeSelectionDialog.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/dialogs/AttributeTypeSelectionDialog.java Mon Nov  5 09:14:24 2007
@@ -0,0 +1,323 @@
+/*
+ *  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.view.dialogs;
+
+
+import java.util.ArrayList;
+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;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.DecoratingLabelProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class is Attribute Type Selection Dialog, that allows user to select an attribute type.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AttributeTypeSelectionDialog extends Dialog
+{
+    /** The selected attribute type */
+    private AttributeTypeImpl selectedAttributeType;
+
+    /** The hidden attribute types */
+    private List<AttributeTypeImpl> hiddenAttributeTypes;
+
+    // UI Fields
+    private Text searchText;
+    private Table attributeTypesTable;
+    private TableViewer attributeTypesTableViewer;
+    private Label schemaIconLabel;
+    private Label schemaNameLabel;
+    private Button chooseButton;
+
+
+    /**
+     * Creates a new instance of AttributeTypeSelectionDialog.
+     */
+    public AttributeTypeSelectionDialog()
+    {
+        super( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell() );
+        hiddenAttributeTypes = new ArrayList<AttributeTypeImpl>();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+     */
+    protected void configureShell( Shell newShell )
+    {
+        super.configureShell( newShell );
+        newShell.setText( "Attribute Type Selection" );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+     */
+    protected Control createDialogArea( Composite parent )
+    {
+        Composite composite = new Composite( parent, SWT.NONE );
+        GridLayout layout = new GridLayout( 1, false );
+        composite.setLayout( layout );
+
+        Label chooseLabel = new Label( composite, SWT.NONE );
+        chooseLabel.setText( "Choose an attribute type" );
+        chooseLabel.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        searchText = new Text( composite, SWT.BORDER );
+        searchText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+        searchText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                setSearchInput( searchText.getText() );
+            }
+        } );
+        searchText.addKeyListener( new KeyAdapter()
+        {
+            public void keyPressed( KeyEvent e )
+            {
+                if ( e.keyCode == SWT.ARROW_DOWN )
+                {
+                    attributeTypesTable.setFocus();
+                }
+            }
+        } );
+
+        Label matchingLabel = new Label( composite, SWT.NONE );
+        matchingLabel.setText( "Matching attribute type(s)" );
+        matchingLabel.setLayoutData( new GridData( SWT.FILL, SWT.None, true, false ) );
+
+        attributeTypesTable = new Table( composite, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL
+            | SWT.FULL_SELECTION | SWT.HIDE_SELECTION );
+        GridData gridData = new GridData( SWT.FILL, SWT.FILL, true, true );
+        gridData.heightHint = 148;
+        gridData.minimumHeight = 148;
+        gridData.widthHint = 350;
+        gridData.minimumWidth = 350;
+        attributeTypesTable.setLayoutData( gridData );
+        attributeTypesTable.addMouseListener( new MouseAdapter()
+        {
+            public void mouseDoubleClick( MouseEvent e )
+            {
+                if ( attributeTypesTable.getSelectionIndex() != -1 )
+                {
+                    okPressed();
+                }
+            }
+        } );
+
+        attributeTypesTableViewer = new TableViewer( attributeTypesTable );
+        attributeTypesTableViewer.setContentProvider( new AttributeTypeSelectionDialogContentProvider(
+            hiddenAttributeTypes ) );
+        attributeTypesTableViewer.setLabelProvider( new DecoratingLabelProvider(
+            new AttributeTypeSelectionDialogLabelProvider(), Activator.getDefault().getWorkbench()
+                .getDecoratorManager().getLabelDecorator() ) );
+        attributeTypesTableViewer.addSelectionChangedListener( new ISelectionChangedListener()
+        {
+            public void selectionChanged( SelectionChangedEvent event )
+            {
+                StructuredSelection selection = ( StructuredSelection ) attributeTypesTableViewer.getSelection();
+                if ( selection.isEmpty() )
+                {
+                    if ( ( chooseButton != null ) && ( !chooseButton.isDisposed() ) )
+                    {
+                        chooseButton.setEnabled( false );
+                    }
+                    schemaIconLabel.setImage( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+                        PluginConstants.IMG_TRANSPARENT_16X16 ).createImage() );
+                    schemaNameLabel.setText( "" );
+                }
+                else
+                {
+                    if ( ( chooseButton != null ) && ( !chooseButton.isDisposed() ) )
+                    {
+                        chooseButton.setEnabled( true );
+                    }
+                    schemaIconLabel.setImage( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+                        PluginConstants.IMG_SCHEMA ).createImage() );
+                    schemaNameLabel.setText( ( ( AttributeTypeImpl ) selection.getFirstElement() ).getSchema() );
+                }
+            }
+        } );
+
+        // Schema Composite
+        Composite schemaComposite = new Composite( composite, SWT.BORDER );
+        schemaComposite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+        GridLayout schemaCompositeGridLayout = new GridLayout( 2, false );
+        schemaCompositeGridLayout.horizontalSpacing = 0;
+        schemaCompositeGridLayout.verticalSpacing = 0;
+        schemaCompositeGridLayout.marginWidth = 2;
+        schemaCompositeGridLayout.marginHeight = 2;
+        schemaComposite.setLayout( schemaCompositeGridLayout );
+
+        // Schema Icon Label
+        schemaIconLabel = new Label( schemaComposite, SWT.NONE );
+        GridData schemaIconLabelGridData = new GridData( SWT.NONE, SWT.BOTTOM, false, false );
+        schemaIconLabelGridData.widthHint = 18;
+        schemaIconLabelGridData.heightHint = 16;
+        schemaIconLabel.setLayoutData( schemaIconLabelGridData );
+        schemaIconLabel.setImage( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+            PluginConstants.IMG_TRANSPARENT_16X16 ).createImage() );
+
+        // Schema Name Label
+        schemaNameLabel = new Label( schemaComposite, SWT.NONE );
+        schemaNameLabel.setLayoutData( new GridData( SWT.FILL, SWT.BOTTOM, true, false ) );
+        schemaNameLabel.setText( "" );
+
+        // We need to force the input to load the complete list of attribute types
+        setSearchInput( "" ); //$NON-NLS-1$
+
+        return composite;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+     */
+    protected void createButtonsForButtonBar( Composite parent )
+    {
+        chooseButton = createButton( parent, IDialogConstants.OK_ID, "Choose", true ); //$NON-NLS-1$
+        createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
+
+        StructuredSelection selection = ( StructuredSelection ) attributeTypesTableViewer.getSelection();
+        if ( selection.isEmpty() )
+        {
+            if ( ( chooseButton != null ) && ( !chooseButton.isDisposed() ) )
+            {
+                chooseButton.setEnabled( false );
+            }
+        }
+        else
+        {
+            if ( ( chooseButton != null ) && ( !chooseButton.isDisposed() ) )
+            {
+                chooseButton.setEnabled( true );
+            }
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+     */
+    protected void okPressed()
+    {
+        StructuredSelection selection = ( StructuredSelection ) attributeTypesTableViewer.getSelection();
+        if ( selection.isEmpty() )
+        {
+            MessageDialog.openError( getShell(), "Invalid Selection", "You have to choose an attribute type" );
+            return;
+        }
+        else
+        {
+            selectedAttributeType = ( AttributeTypeImpl ) selection.getFirstElement();
+        }
+
+        super.okPressed();
+    }
+
+
+    /**
+     * Returns the selected Attribute Type.
+     * 
+     * @return
+     *      the selected Attribute Type
+     */
+    public AttributeTypeImpl getSelectedAttributeType()
+    {
+        return selectedAttributeType;
+    }
+
+
+    /**
+     * Set the hidden Attribute Types.
+     *
+     * @param list
+     *      a list of Attribute Types to hide
+     */
+    public void setHiddenAttributeTypes( List<AttributeTypeImpl> list )
+    {
+        hiddenAttributeTypes = list;
+    }
+
+
+    /**
+     * Sets the hidden Attribute Types.
+     *
+     * @param attributeTypes
+     *      an array of Attribute Types to hide
+     */
+    public void setHiddenAttributeTypes( AttributeTypeImpl[] attributeTypes )
+    {
+        for ( AttributeTypeImpl objectClass : attributeTypes )
+        {
+            hiddenAttributeTypes.add( objectClass );
+        }
+    }
+
+
+    /**
+     * Set the Search Input.
+     *
+     * @param searchString
+     *      the Search String
+     */
+    private void setSearchInput( String searchString )
+    {
+        attributeTypesTableViewer.setInput( searchString );
+
+        Object firstElement = attributeTypesTableViewer.getElementAt( 0 );
+        if ( firstElement != null )
+        {
+            attributeTypesTableViewer.setSelection( new StructuredSelection( firstElement ), true );
+        }
+    }
+}

Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/dialogs/AttributeTypeSelectionDialog.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message