directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r495424 - in /directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui: views/browser/ widgets/browser/
Date Thu, 11 Jan 2007 23:02:15 GMT
Author: seelmann
Date: Thu Jan 11 15:02:14 2007
New Revision: 495424

URL: http://svn.apache.org/viewvc?view=rev&rev=495424
Log:
Another fix for DIRSTUDIO-27, removed warnings

Modified:
    directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserViewUniversalListener.java
    directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserContentProvider.java
    directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserUniversalListener.java

Modified: directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserViewUniversalListener.java
URL: http://svn.apache.org/viewvc/directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserViewUniversalListener.java?view=diff&rev=495424&r1=495423&r2=495424
==============================================================================
--- directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserViewUniversalListener.java
(original)
+++ directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserViewUniversalListener.java
Thu Jan 11 15:02:14 2007
@@ -279,9 +279,20 @@
 
     public void entryUpdated( EntryModificationEvent event )
     {
+        
+        // Don't handle attribute initalization, could cause double
+        // retrieval of children. 
+        //
+        // When double-clicking an entry two Jobs/Threads are started:
+        // - InitializeAttributesJob and
+        // - InitializeChildrenJob
+        // If the InitializeAttributesJob is finished first the
+        // AttributesInitializedEvent is fired. If this causes
+        // a refresh of the tree before the children are initialized
+        // another InitializeChildrenJob is executed.
         if ( event instanceof AttributesInitializedEvent )
         {
-            this.viewer.refresh(); // This was added to fix the DIRSTUDIO-27 Jira.
+            return;
         }
 
         if ( event instanceof EntryAddedEvent )

Modified: directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserContentProvider.java
URL: http://svn.apache.org/viewvc/directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserContentProvider.java?view=diff&rev=495424&r1=495423&r2=495424
==============================================================================
--- directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserContentProvider.java
(original)
+++ directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserContentProvider.java
Thu Jan 11 15:02:14 2007
@@ -52,20 +52,20 @@
 
     protected BrowserSorter sorter;
 
-    private Map entryToEntryPagesMap;
+    private Map<IEntry, BrowserEntryPage[]> entryToEntryPagesMap;
 
-    private Map searchToSearchResultPagesMap;
+    private Map<ISearch, BrowserSearchResultPage[]> searchToSearchResultPagesMap;
 
-    private Map connectionToCategoriesMap;
+    private Map<IConnection, BrowserCategory[]> connectionToCategoriesMap;
 
 
     public BrowserContentProvider( BrowserPreferences layout, BrowserSorter sorter )
     {
         this.layout = layout;
         this.sorter = sorter;
-        this.entryToEntryPagesMap = new HashMap();
-        this.searchToSearchResultPagesMap = new HashMap();
-        this.connectionToCategoriesMap = new HashMap();
+        this.entryToEntryPagesMap = new HashMap<IEntry, BrowserEntryPage[]>();
+        this.searchToSearchResultPagesMap = new HashMap<ISearch, BrowserSearchResultPage[]>();
+        this.connectionToCategoriesMap = new HashMap<IConnection, BrowserCategory[]>();
     }
 
 
@@ -103,34 +103,15 @@
             if ( !this.connectionToCategoriesMap.containsKey( connection ) )
             {
                 BrowserCategory[] categories = new BrowserCategory[3];
-                List entryList = new ArrayList();
-                if ( connection.isOpened() )
-                {
-                    entryList.addAll( Arrays.asList( connection.getBaseDNEntries() ) );
-                    entryList.add( connection.getRootDSE() );
-                    entryList.addAll( Arrays.asList( connection.getMetadataEntries() ) );
-                }
-                categories[0] = new BrowserCategory( BrowserCategory.TYPE_DIT, connection,
entryList.toArray() );
-                categories[1] = new BrowserCategory( BrowserCategory.TYPE_SEARCHES, connection,
connection
-                    .getSearchManager().getSearches() );
-                categories[2] = new BrowserCategory( BrowserCategory.TYPE_BOOKMARKS, connection,
connection
-                    .getBookmarkManager().getBookmarks() );
+                categories[0] = new BrowserCategory( BrowserCategory.TYPE_DIT, connection,
null );
+                categories[1] = new BrowserCategory( BrowserCategory.TYPE_SEARCHES, connection,
null );
+                categories[2] = new BrowserCategory( BrowserCategory.TYPE_BOOKMARKS, connection,
null );
                 this.connectionToCategoriesMap.put( connection, categories );
             }
 
-            BrowserCategory[] categories = ( BrowserCategory[] ) this.connectionToCategoriesMap.get(
connection );
-            List entryList = new ArrayList();
-            if ( connection.isOpened() )
-            {
-                entryList.addAll( Arrays.asList( connection.getBaseDNEntries() ) );
-                entryList.add( connection.getRootDSE() );
-                entryList.addAll( Arrays.asList( connection.getMetadataEntries() ) );
-            }
-            categories[0].setChildren( entryList.toArray() );
-            categories[1].setChildren( connection.getSearchManager().getSearches() );
-            categories[2].setChildren( connection.getBookmarkManager().getBookmarks() );
+            BrowserCategory[] categories = this.connectionToCategoriesMap.get( connection
);
 
-            List catList = new ArrayList( 3 );
+            List<BrowserCategory> catList = new ArrayList<BrowserCategory>( 3
);
             if ( this.layout.isShowDIT() )
                 catList.add( categories[0] );
             if ( this.layout.isShowSearches() )
@@ -138,7 +119,7 @@
             if ( this.layout.isShowBookmarks() )
                 catList.add( categories[2] );
 
-            return ( BrowserCategory[] ) catList.toArray( new BrowserCategory[0] );
+            return catList.toArray( new BrowserCategory[0] );
         }
         else if ( parent instanceof IEntry[] )
         {
@@ -168,8 +149,7 @@
             {
                 if ( this.connectionToCategoriesMap.get( ( ( IEntry ) child ).getConnection()
) != null )
                 {
-                    return ( ( BrowserCategory[] ) this.connectionToCategoriesMap.get( (
( IEntry ) child )
-                        .getConnection() ) )[0];
+                    return this.connectionToCategoriesMap.get( ( ( IEntry ) child ).getConnection()
)[0];
                 }
                 else
                 {
@@ -178,7 +158,7 @@
             }
             else if ( this.entryToEntryPagesMap.containsKey( parentEntry ) )
             {
-                BrowserEntryPage[] entryPages = ( BrowserEntryPage[] ) this.entryToEntryPagesMap.get(
parentEntry );
+                BrowserEntryPage[] entryPages = this.entryToEntryPagesMap.get( parentEntry
);
                 BrowserEntryPage ep = null;
                 for ( int i = 0; i < entryPages.length && ep == null; i++ )
                 {
@@ -198,15 +178,14 @@
         else if ( child instanceof ISearch )
         {
             ISearch search = ( ( ISearch ) child );
-            return ( ( BrowserCategory[] ) this.connectionToCategoriesMap.get( search.getConnection()
) )[1];
+            return this.connectionToCategoriesMap.get( search.getConnection() )[1];
         }
         else if ( child instanceof ISearchResult )
         {
             ISearch parentSearch = ( ( ISearchResult ) child ).getSearch();
             if ( parentSearch != null && this.searchToSearchResultPagesMap.containsKey(
parentSearch ) )
             {
-                BrowserSearchResultPage[] srPages = ( BrowserSearchResultPage[] ) this.searchToSearchResultPagesMap
-                    .get( parentSearch );
+                BrowserSearchResultPage[] srPages = this.searchToSearchResultPagesMap.get(
parentSearch );
                 BrowserSearchResultPage srp = null;
                 for ( int i = 0; i < srPages.length && srp == null; i++ )
                 {
@@ -222,7 +201,7 @@
         else if ( child instanceof IBookmark )
         {
             IBookmark bookmark = ( ( IBookmark ) child );
-            return ( ( BrowserCategory[] ) this.connectionToCategoriesMap.get( bookmark.getConnection()
) )[2];
+            return this.connectionToCategoriesMap.get( bookmark.getConnection() )[2];
         }
         else
         {
@@ -294,7 +273,7 @@
                 }
                 else
                 {
-                    entryPages = ( BrowserEntryPage[] ) this.entryToEntryPagesMap.get( parentEntry
);
+                    entryPages = this.entryToEntryPagesMap.get( parentEntry );
                     if ( childrenCount - 1 != entryPages[entryPages.length - 1].getLast()
)
                     {
                         entryPages = getEntryPages( parentEntry, 0, childrenCount - 1 );
@@ -354,7 +333,7 @@
                 }
                 else
                 {
-                    srPages = ( BrowserSearchResultPage[] ) this.searchToSearchResultPagesMap.get(
search );
+                    srPages = this.searchToSearchResultPagesMap.get( search );
                     if ( search.getSearchResults().length - 1 != srPages[srPages.length -
1].getLast() )
                     {
                         srPages = getSearchResultPages( search, 0, search.getSearchResults().length
- 1 );
@@ -367,27 +346,58 @@
         else if ( parent instanceof BrowserCategory )
         {
             BrowserCategory category = ( BrowserCategory ) parent;
+            IConnection connection = category.getParent();
 
-            List objects = new ArrayList( Arrays.asList( category.getChildren() ) );
-            for ( Iterator it = objects.iterator(); it.hasNext(); )
+            switch ( category.getType() )
             {
-                Object o = it.next();
-                if ( !this.layout.isShowDirectoryMetaEntries()
-                    && ( o instanceof DirectoryMetadataEntry || o instanceof RootDSE
) )
+
+                case BrowserCategory.TYPE_DIT:
+                {
+
+                    // open connection when expanding DIT
+                    if ( !connection.isOpened() )
+                    {
+                        new OpenConnectionsJob( connection ).execute();
+                        return new String[]
+                            { "Fetching Entries..." };
+                    }
+
+                    // get base entries
+                    List<IEntry> entryList = new ArrayList<IEntry>();
+                    if ( connection.isOpened() )
+                    {
+                        entryList.addAll( Arrays.asList( connection.getBaseDNEntries() )
);
+                        entryList.add( connection.getRootDSE() );
+                        entryList.addAll( Arrays.asList( connection.getMetadataEntries()
) );
+                    }
+
+                    // remove non-visible entries
+                    for ( Iterator<IEntry> it = entryList.iterator(); it.hasNext();
)
+                    {
+                        Object o = it.next();
+                        if ( !this.layout.isShowDirectoryMetaEntries()
+                            && ( o instanceof DirectoryMetadataEntry || o instanceof
RootDSE ) )
+                        {
+                            it.remove();
+                        }
+                    }
+
+                    return entryList.toArray();
+                }
+
+                case BrowserCategory.TYPE_SEARCHES:
                 {
-                    it.remove();
+                    return connection.getSearchManager().getSearches();
+                }
+
+                case BrowserCategory.TYPE_BOOKMARKS:
+                {
+                    return connection.getBookmarkManager().getBookmarks();
                 }
-            }
 
-            // open connection when expanding DIT
-            if ( category.getType() == BrowserCategory.TYPE_DIT && !category.getParent().isOpened()
)
-            {
-                new OpenConnectionsJob( category.getParent() ).execute();
-                return new String[]
-                    { "Fetching Entries..." };
             }
 
-            return objects.toArray();
+            return new Object[0];
         }
         else
         {

Modified: directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserUniversalListener.java
URL: http://svn.apache.org/viewvc/directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserUniversalListener.java?view=diff&rev=495424&r1=495423&r2=495424
==============================================================================
--- directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserUniversalListener.java
(original)
+++ directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserUniversalListener.java
Thu Jan 11 15:02:14 2007
@@ -106,7 +106,15 @@
     {
 
         // Don't handle attribute initalization, could cause double
-        // retrieval of children
+        // retrieval of children. 
+        //
+        // When double-clicking an entry two Jobs/Threads are started:
+        // - InitializeAttributesJob and
+        // - InitializeChildrenJob
+        // If the InitializeAttributesJob is finished first the
+        // AttributesInitializedEvent is fired. If this causes
+        // a refresh of the tree before the children are initialized
+        // another InitializeChildrenJob is executed.
         if ( event instanceof AttributesInitializedEvent )
         {
             return;



Mime
View raw message