directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r881836 - /directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewUniversalListener.java
Date Wed, 18 Nov 2009 17:06:25 GMT
Author: pamarcelot
Date: Wed Nov 18 17:06:25 2009
New Revision: 881836

URL: http://svn.apache.org/viewvc?rev=881836&view=rev
Log:
Fix for DIRSTUDIO-592 (LDAP Browser view is refreshed twice after the initialization of the
children of an entry).

Modified:
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewUniversalListener.java

Modified: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewUniversalListener.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewUniversalListener.java?rev=881836&r1=881835&r2=881836&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewUniversalListener.java
(original)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewUniversalListener.java
Wed Nov 18 17:06:25 2009
@@ -32,6 +32,7 @@
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
 import org.apache.directory.studio.ldapbrowser.common.actions.BrowserSelectionUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.browser.BrowserContentProvider;
 import org.apache.directory.studio.ldapbrowser.common.widgets.browser.BrowserUniversalListener;
 import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
 import org.apache.directory.studio.ldapbrowser.core.events.AttributesInitializedEvent;
@@ -612,12 +613,30 @@
         }
         else if ( event instanceof ChildrenInitializedEvent )
         {
-            boolean expandedState = viewer.getExpandedState( event.getModifiedEntry() );
-            viewer.collapseToLevel( event.getModifiedEntry(), TreeViewer.ALL_LEVELS );
-            if ( expandedState )
+            // Getting the children of the entry to collapse their nodes
+            // See DIRSTUDIO-481 (refreshing of attributes and children)
+            Object[] children = ( ( BrowserContentProvider ) viewer.getContentProvider()
).getChildren( event
+                .getModifiedEntry() );
+            for ( Object child : children )
             {
-                viewer.expandToLevel( event.getModifiedEntry(), 1 );
+                // We're only collapsing the node if it is expanded
+                if ( viewer.getExpandedState( child ) )
+                {
+                    viewer.collapseToLevel( child, TreeViewer.ALL_LEVELS );
+
+                    // There seem to be a bug (maybe it's a feature?!?) with nodes that were
expanded
+                    // but does not have any child.
+                    // The call to 'viewer.collapseToLevel(...)' has no effect, the node
stays expanded...
+                    if ( viewer.getExpandedState( child ) )
+                    {
+                        // In that particular case, we need to remove the child from the
tree viewer.
+                        // As it's a costlyĂŠoperation we're only using this in that particular
case,
+                        // and not as default option.
+                        viewer.remove( child );
+                    }
+                }
             }
+
             viewer.refresh( event.getModifiedEntry(), true );
         }
         else if ( !( event.getModifiedEntry() instanceof DummyEntry ) )



Mime
View raw message