Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 55142 invoked from network); 2 Oct 2007 16:32:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Oct 2007 16:32:14 -0000 Received: (qmail 59462 invoked by uid 500); 2 Oct 2007 16:32:03 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 59404 invoked by uid 500); 2 Oct 2007 16:32:03 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 59393 invoked by uid 99); 2 Oct 2007 16:32:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Oct 2007 09:32:03 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Oct 2007 16:32:13 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 1A52B1A9832; Tue, 2 Oct 2007 09:31:53 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r581294 - /directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/SchemaViewContentProvider.java Date: Tue, 02 Oct 2007 16:31:52 -0000 To: commits@directory.apache.org From: pamarcelot@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071002163153.1A52B1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pamarcelot Date: Tue Oct 2 09:31:51 2007 New Revision: 581294 URL: http://svn.apache.org/viewvc?rev=581294&view=rev Log: Adding correct behavior of the UI when modifying an object class. Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/SchemaViewContentProvider.java Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/SchemaViewContentProvider.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/SchemaViewContentProvider.java?rev=581294&r1=581293&r2=581294&view=diff ============================================================================== --- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/SchemaViewContentProvider.java (original) +++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/SchemaViewContentProvider.java Tue Oct 2 09:31:51 2007 @@ -466,6 +466,12 @@ } + /** + * This method is called when an attribute type is added. + * + * @param at + * the added attribute type + */ public void attributeTypeAdded( AttributeTypeImpl at ) { hierarchyManager.attributeTypeAdded( at ); @@ -531,15 +537,20 @@ } } } - } + /** + * This method is called when an attribute type is modified. + * + * @param at + * the modified attribute type + */ public void attributeTypeModified( AttributeTypeImpl at ) { // Propagating the modification to the hierarchy manager hierarchyManager.attributeTypeModified( at ); - + // Removing the Wrappers List wrappers = getWrappers( at ); if ( wrappers != null ) @@ -595,8 +606,20 @@ } + /** + * This method is called when an attribute type is removed. + * + * @param at + * the removed attribute type + */ public void attributeTypeRemoved( AttributeTypeImpl at ) { + removeAttributeTypeHierarchicalPresentation( at ); + } + + + private void removeAttributeTypeHierarchicalPresentation( AttributeTypeImpl at ) + { // Creating children nodes of the AT // and attaching them to the root List children = hierarchyManager.getChildren( at ); @@ -631,9 +654,6 @@ } } - // Propagating the removal to the hierarchy manager - hierarchyManager.attributeTypeRemoved( at ); - // Removing the Wrappers List wrappers = getWrappers( at ); if ( wrappers != null ) @@ -646,45 +666,263 @@ elementsToWrappersMap.remove( at ); } + + // Propagating the removal to the hierarchy manager + hierarchyManager.attributeTypeRemoved( at ); } + /** + * Recursively removes the children of the given wrapper. + * + * @param wrapper + * the wrapper + */ private void removeRecursiveChildren( TreeNode wrapper ) { for ( TreeNode child : wrapper.getChildren() ) { if ( child instanceof AttributeTypeWrapper ) { - elementsToWrappersMap.remove( ( ( AttributeTypeWrapper ) child ).getAttributeType(), child ); + AttributeTypeWrapper atw = ( AttributeTypeWrapper ) child; + elementsToWrappersMap.remove( atw.getAttributeType(), child ); + removeRecursiveChildren( atw ); } else if ( child instanceof ObjectClassWrapper ) { - elementsToWrappersMap.remove( ( ( ObjectClassWrapper ) child ).getObjectClass(), child ); + ObjectClassWrapper ocw = ( ObjectClassWrapper ) child; + elementsToWrappersMap.remove( ocw.getObjectClass(), child ); + removeRecursiveChildren( ocw ); } } } + /** + * This method is called when an object class is added. + * + * @param oc + * the added object class + */ public void objectClassAdded( ObjectClassImpl oc ) { + // Propagating the addition to the hierarchy manager + hierarchyManager.objectClassAdded( oc ); + + List createdWrappers = new ArrayList(); + + List parents = hierarchyManager.getParents( oc ); + + if ( parents != null ) + { + for ( Object parent : parents ) + { + ObjectClassWrapper parentOCW = ( ObjectClassWrapper ) getWrapper( parent ); + ObjectClassWrapper ocw = null; + if ( parentOCW == null ) + { + int group = store.getInt( PluginConstants.PREFS_SCHEMA_VIEW_GROUPING ); + if ( group == PluginConstants.PREFS_SCHEMA_VIEW_GROUPING_FOLDERS ) + { + for ( TreeNode child : root.getChildren() ) + { + if ( child instanceof Folder ) + { + Folder folder = ( Folder ) child; + if ( folder.getType().equals( FolderType.OBJECT_CLASS ) ) + { + ocw = new ObjectClassWrapper( oc, folder ); + break; + } + } + } + } + else if ( group == PluginConstants.PREFS_SCHEMA_VIEW_GROUPING_MIXED ) + { + ocw = new ObjectClassWrapper( oc, root ); + } + + } + else + { + ocw = new ObjectClassWrapper( oc, parentOCW ); + } + ocw.getParent().addChild( ocw ); + createdWrappers.add( ocw ); + elementsToWrappersMap.put( oc, ocw ); + } + } + + // List children = hierarchyManager.getChildren( oc ); + // if ( children != null ) + // { + // for ( Object child : children ) + // { + // List childOCWs = getWrappers( child ); + // if ( childOCWs != null ) + // { + // + // } + // + // + // elementsToWrappersMap.remove( child ); + // childATW.getParent().removeChild( childATW ); + // + // for ( TreeNode createdWrapper : createdWrappers ) + // { + // AttributeTypeWrapper atw = new AttributeTypeWrapper( ( AttributeTypeImpl ) child, createdWrapper ); + // atw.getParent().addChild( atw ); + // elementsToWrappersMap.put( ( AttributeTypeImpl ) child, atw ); + // } + // } + // } } + /** + * This method is called when an object class is modified. + * + * @param oc + * the modified object class + */ public void objectClassModified( ObjectClassImpl oc ) { + // Propagating the modification to the hierarchy manager + hierarchyManager.objectClassModified( oc ); + + // Removing the Wrappers + List wrappers = getWrappers( oc ); + if ( wrappers != null ) + { + for ( TreeNode wrapper : wrappers ) + { + wrapper.getParent().removeChild( wrapper ); + } + + elementsToWrappersMap.remove( oc ); + } + + // Creating the wrapper + List parents = hierarchyManager.getParents( oc ); + if ( parents != null ) + { + for ( Object parent : parents ) + { + ObjectClassWrapper parentOCW = ( ObjectClassWrapper ) getWrapper( parent ); + ObjectClassWrapper ocw = null; + if ( parentOCW == null ) + { + int group = store.getInt( PluginConstants.PREFS_SCHEMA_VIEW_GROUPING ); + if ( group == PluginConstants.PREFS_SCHEMA_VIEW_GROUPING_FOLDERS ) + { + for ( TreeNode child : root.getChildren() ) + { + if ( child instanceof Folder ) + { + Folder folder = ( Folder ) child; + if ( folder.getType().equals( FolderType.ATTRIBUTE_TYPE ) ) + { + ocw = new ObjectClassWrapper( oc, folder ); + break; + } + } + } + } + else if ( group == PluginConstants.PREFS_SCHEMA_VIEW_GROUPING_MIXED ) + { + ocw = new ObjectClassWrapper( oc, root ); + } + + } + else + { + ocw = new ObjectClassWrapper( oc, parentOCW ); + } + ocw.getParent().addChild( ocw ); + elementsToWrappersMap.put( oc, ocw ); + } + } } + /** + * This method is called when an object class is removed. + * + * @param oc + * the removed object class + */ public void objectClassRemoved( ObjectClassImpl oc ) { + // Creating children nodes of the OC + // and attaching them to the root + List children = hierarchyManager.getChildren( oc ); + if ( children != null ) + { + for ( Object child : children ) + { + ObjectClassWrapper ocw = null; + int group = store.getInt( PluginConstants.PREFS_SCHEMA_VIEW_GROUPING ); + if ( group == PluginConstants.PREFS_SCHEMA_VIEW_GROUPING_FOLDERS ) + { + for ( TreeNode rootChild : root.getChildren() ) + { + if ( rootChild instanceof Folder ) + { + Folder folder = ( Folder ) rootChild; + if ( folder.getType().equals( FolderType.OBJECT_CLASS ) ) + { + ocw = new ObjectClassWrapper( ( ObjectClassImpl ) child, folder ); + break; + } + } + } + } + else if ( group == PluginConstants.PREFS_SCHEMA_VIEW_GROUPING_MIXED ) + { + ocw = new ObjectClassWrapper( ( ObjectClassImpl ) child, root ); + } + + ocw.getParent().addChild( ocw ); + elementsToWrappersMap.put( ( ObjectClassImpl ) child, ocw ); + addHierarchyChildren( ocw, hierarchyManager.getChildren( child ) ); + } + } + + // Removing the Wrappers + List wrappers = getWrappers( oc ); + if ( wrappers != null ) + { + for ( TreeNode wrapper : wrappers ) + { + wrapper.getParent().removeChild( wrapper ); + removeRecursiveChildren( wrapper ); + } + + elementsToWrappersMap.remove( oc ); + } + + // Propagating the removal to the hierarchy manager + hierarchyManager.objectClassRemoved( oc ); } + /** + * This method is called when a schema is added. + * + * @param schema + * the added schema + */ public void schemaAdded( Schema schema ) { } + /** + * This method is called when a schema is removed. + * + * @param schema + * the removed schema + */ public void schemaRemoved( Schema schema ) { }