directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r748907 - in /directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser: BrowserContentProvider.java BrowserEntryPage.java BrowserSearchResultPage.java
Date Sat, 28 Feb 2009 19:16:39 GMT
Author: seelmann
Date: Sat Feb 28 19:16:39 2009
New Revision: 748907

URL: http://svn.apache.org/viewvc?rev=748907&view=rev
Log:
Fix for DIRSTUDIO-419 and DIRSTUDIO-420: when the page size changed (i.e. by deleting entries)
the old index was used and an AIOOB exception occured.

Modified:
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserContentProvider.java
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserEntryPage.java
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserSearchResultPage.java

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserContentProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserContentProvider.java?rev=748907&r1=748906&r2=748907&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserContentProvider.java
(original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserContentProvider.java
Sat Feb 28 19:16:39 2009
@@ -216,9 +216,13 @@
                     return null;
                 }
             }
-            else if ( entryToEntryPagesMap.containsKey( parentEntry ) )
+            else if ( parentEntry.getChildrenCount() <= preferences.getFoldingSize() ||
!preferences.isUseFolding() )
             {
-                BrowserEntryPage[] entryPages = entryToEntryPagesMap.get( parentEntry );
+                return parentEntry;
+            }
+            else
+            {
+                BrowserEntryPage[] entryPages = getEntryPages( parentEntry );
                 BrowserEntryPage ep = null;
                 for ( int i = 0; i < entryPages.length && ep == null; i++ )
                 {
@@ -226,10 +230,6 @@
                 }
                 return ep;
             }
-            else
-            {
-                return parentEntry;
-            }
         }
         else if ( child instanceof BrowserSearchResultPage )
         {
@@ -243,9 +243,15 @@
         else if ( child instanceof ISearchResult )
         {
             ISearch parentSearch = ( ( ISearchResult ) child ).getSearch();
-            if ( parentSearch != null && searchToSearchResultPagesMap.containsKey(
parentSearch ) )
+
+            if ( parentSearch == null || parentSearch.getSearchResults().length <= preferences.getFoldingSize()
+                || !preferences.isUseFolding() )
             {
-                BrowserSearchResultPage[] srPages = searchToSearchResultPagesMap.get( parentSearch
);
+                return parentSearch;
+            }
+            else
+            {
+                BrowserSearchResultPage[] srPages = getSearchResultPages( parentSearch );
                 BrowserSearchResultPage srp = null;
                 for ( int i = 0; i < srPages.length && srp == null; i++ )
                 {
@@ -253,10 +259,6 @@
                 }
                 return srp;
             }
-            else
-            {
-                return parentSearch;
-            }
         }
         else if ( child instanceof IBookmark )
         {
@@ -282,7 +284,7 @@
             if ( objects == null )
             {
                 return new String[]
-                    { Messages.getString("BrowserContentProvider.FetchingEntries") }; //$NON-NLS-1$
+                    { Messages.getString( "BrowserContentProvider.FetchingEntries" ) }; //$NON-NLS-1$
             }
             else if ( objects instanceof IEntry[] )
             {
@@ -303,7 +305,7 @@
                 new StudioBrowserJob( new InitializeChildrenRunnable( new IEntry[]
                     { rootDSE } ) ).execute();
                 return new String[]
-                    { Messages.getString("BrowserContentProvider.FetchingEntries") }; //$NON-NLS-1$
+                    { Messages.getString( "BrowserContentProvider.FetchingEntries" ) }; //$NON-NLS-1$
             }
 
             // get base entries
@@ -331,11 +333,10 @@
                 new StudioBrowserJob( new InitializeChildrenRunnable( new IEntry[]
                     { parentEntry } ) ).execute();
                 return new String[]
-                    { Messages.getString("BrowserContentProvider.FetchingEntries") }; //$NON-NLS-1$
+                    { Messages.getString( "BrowserContentProvider.FetchingEntries" ) }; //$NON-NLS-1$
             }
 
-            int childrenCount = parentEntry.getChildrenCount();
-            if ( childrenCount <= preferences.getFoldingSize() || !preferences.isUseFolding()
)
+            if ( parentEntry.getChildrenCount() <= preferences.getFoldingSize() || !preferences.isUseFolding()
)
             {
                 if ( entryToEntryPagesMap.containsKey( parentEntry ) )
                 {
@@ -363,7 +364,7 @@
                 if ( results == null )
                 {
                     return new String[]
-                        { Messages.getString("BrowserContentProvider.FetchingEntries") };
//$NON-NLS-1$
+                        { Messages.getString( "BrowserContentProvider.FetchingEntries" )
}; //$NON-NLS-1$
                 }
                 else
                 {
@@ -372,21 +373,7 @@
             }
             else
             {
-                BrowserEntryPage[] entryPages = null;
-                if ( !entryToEntryPagesMap.containsKey( parentEntry ) )
-                {
-                    entryPages = getEntryPages( parentEntry, 0, childrenCount - 1 );
-                    entryToEntryPagesMap.put( parentEntry, entryPages );
-                }
-                else
-                {
-                    entryPages = entryToEntryPagesMap.get( parentEntry );
-                    if ( childrenCount - 1 != entryPages[entryPages.length - 1].getLast()
)
-                    {
-                        entryPages = getEntryPages( parentEntry, 0, childrenCount - 1 );
-                        entryToEntryPagesMap.put( parentEntry, entryPages );
-                    }
-                }
+                BrowserEntryPage[] entryPages = getEntryPages( parentEntry );;
                 return entryPages;
             }
         }
@@ -397,7 +384,7 @@
             if ( objects == null )
             {
                 return new String[]
-                    { Messages.getString("BrowserContentProvider.FetchingSearchResults")
}; //$NON-NLS-1$
+                    { Messages.getString( "BrowserContentProvider.FetchingSearchResults"
) }; //$NON-NLS-1$
             }
             else if ( objects instanceof ISearchResult[] )
             {
@@ -417,15 +404,20 @@
                 new StudioBrowserJob( new SearchRunnable( new ISearch[]
                     { search } ) ).execute();
                 return new String[]
-                    { Messages.getString("BrowserContentProvider.PerformingSearch") }; //$NON-NLS-1$
+                    { Messages.getString( "BrowserContentProvider.PerformingSearch" ) };
//$NON-NLS-1$
             }
             else if ( search.getSearchResults().length == 0 )
             {
                 return new String[]
-                    { Messages.getString("BrowserContentProvider.NoResults") }; //$NON-NLS-1$
+                    { Messages.getString( "BrowserContentProvider.NoResults" ) }; //$NON-NLS-1$
             }
             else if ( search.getSearchResults().length <= preferences.getFoldingSize()
|| !preferences.isUseFolding() )
             {
+                if ( searchToSearchResultPagesMap.containsKey( search ) )
+                {
+                    searchToSearchResultPagesMap.remove( search );
+                }
+
                 Object[] results = search.getSearchResults();
                 List<Object> objects = new ArrayList<Object>();
 
@@ -447,21 +439,7 @@
             }
             else
             {
-                BrowserSearchResultPage[] srPages = null;
-                if ( !searchToSearchResultPagesMap.containsKey( search ) )
-                {
-                    srPages = getSearchResultPages( search, 0, search.getSearchResults().length
- 1 );
-                    searchToSearchResultPagesMap.put( search, srPages );
-                }
-                else
-                {
-                    srPages = searchToSearchResultPagesMap.get( search );
-                    if ( search.getSearchResults().length - 1 != srPages[srPages.length -
1].getLast() )
-                    {
-                        srPages = getSearchResultPages( search, 0, search.getSearchResults().length
- 1 );
-                        searchToSearchResultPagesMap.put( search, srPages );
-                    }
-                }
+                BrowserSearchResultPage[] srPages = getSearchResultPages( search );
                 return srPages;
             }
         }
@@ -481,7 +459,7 @@
                         new StudioBrowserJob( new OpenConnectionsRunnable( browserConnection.getConnection()
) )
                             .execute();
                         return new String[]
-                            { Messages.getString("BrowserContentProvider.OpeningConnection")
}; //$NON-NLS-1$
+                            { Messages.getString( "BrowserContentProvider.OpeningConnection"
) }; //$NON-NLS-1$
                     }
 
                     return new Object[]
@@ -545,6 +523,27 @@
     }
 
 
+    private BrowserEntryPage[] getEntryPages( final IEntry parentEntry )
+    {
+        BrowserEntryPage[] entryPages;
+        if ( !entryToEntryPagesMap.containsKey( parentEntry ) )
+        {
+            entryPages = getEntryPages( parentEntry, 0, parentEntry.getChildrenCount() -
1 );
+            entryToEntryPagesMap.put( parentEntry, entryPages );
+        }
+        else
+        {
+            entryPages = entryToEntryPagesMap.get( parentEntry );
+            if ( parentEntry.getChildrenCount() - 1 != entryPages[entryPages.length - 1].getLast()
)
+            {
+                entryPages = getEntryPages( parentEntry, 0, parentEntry.getChildrenCount()
- 1 );
+                entryToEntryPagesMap.put( parentEntry, entryPages );
+            }
+        }
+        return entryPages;
+    }
+
+
     /**
      * Creates and returns the entry pages for the given entry. The number of pages
      * depends on the number of entries and the paging size. 
@@ -577,6 +576,27 @@
     }
 
 
+    private BrowserSearchResultPage[] getSearchResultPages( ISearch search )
+    {
+        BrowserSearchResultPage[] srPages;
+        if ( !searchToSearchResultPagesMap.containsKey( search ) )
+        {
+            srPages = getSearchResultPages( search, 0, search.getSearchResults().length -
1 );
+            searchToSearchResultPagesMap.put( search, srPages );
+        }
+        else
+        {
+            srPages = searchToSearchResultPagesMap.get( search );
+            if ( search.getSearchResults().length - 1 != srPages[srPages.length - 1].getLast()
)
+            {
+                srPages = getSearchResultPages( search, 0, search.getSearchResults().length
- 1 );
+                searchToSearchResultPagesMap.put( search, srPages );
+            }
+        }
+        return srPages;
+    }
+
+
     /**
      * Creates and returns the search result pages for the given search. The number of pages
      * depends on the number of search results and the paging size. 

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserEntryPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserEntryPage.java?rev=748907&r1=748906&r2=748907&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserEntryPage.java
(original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserEntryPage.java
Sat Feb 28 19:16:39 2009
@@ -101,7 +101,7 @@
             // 2. sort
             sorter.sort( null, children );
 
-            // 3. extraxt range
+            // 3. extract range
             if ( children != null )
             {
                 IEntry[] childrenRange = new IEntry[last - first + 1];

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserSearchResultPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserSearchResultPage.java?rev=748907&r1=748906&r2=748907&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserSearchResultPage.java
(original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserSearchResultPage.java
Sat Feb 28 19:16:39 2009
@@ -104,7 +104,7 @@
             // 2. sort
             sorter.sort( null, children );
 
-            // 3. extraxt range
+            // 3. extract range
             if ( children != null )
             {
                 ISearchResult[] childrenRange = new ISearchResult[last - first + 1];



Mime
View raw message