directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r898733 - in /directory/studio/trunk: ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/ ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/
Date Wed, 13 Jan 2010 12:59:48 GMT
Author: pamarcelot
Date: Wed Jan 13 12:59:48 2010
New Revision: 898733

URL: http://svn.apache.org/viewvc?rev=898733&view=rev
Log:
Fix for DIRSTUDIO-424 (Canceling a search gives an error sometimes).

Modified:
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserSorter.java
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorSorter.java

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserSorter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserSorter.java?rev=898733&r1=898732&r2=898733&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserSorter.java
(original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserSorter.java
Wed Jan 13 12:59:48 2010
@@ -355,48 +355,63 @@
      */
     private int compareRdnValues( IEntry entry1, IEntry entry2 )
     {
-        Rdn rdn1 = entry1.getRdn();
-        Rdn rdn2 = entry2.getRdn();
-
-        if ( ( rdn1 == null || rdn1.getValue() == null || "".equals( rdn1.getValue() ) )
//$NON-NLS-1$
-            && ( rdn2 == null || rdn2.getValue() == null || "".equals( rdn2.getValue()
) ) ) //$NON-NLS-1$
+        if ( ( entry1 == null ) && ( entry2 == null ) )
         {
             return equal();
         }
-        else if ( ( rdn1 == null || rdn1.getValue() == null || "".equals( rdn1.getValue()
) ) //$NON-NLS-1$
-            && !( rdn2 == null || rdn2.getValue() == null || "".equals( rdn2.getValue()
) ) ) //$NON-NLS-1$
+        else if ( ( entry1 != null ) && ( entry2 == null ) )
         {
             return greaterThan();
         }
-        else if ( !( rdn1 == null || rdn1.getValue() == null || "".equals( rdn1.getValue()
) ) //$NON-NLS-1$
-            && ( rdn2 == null || rdn2.getValue() == null || "".equals( rdn2.getValue()
) ) ) //$NON-NLS-1$
+        else if ( ( entry1 == null ) && ( entry2 != null ) )
         {
             return lessThan();
         }
-
-        String rdn1Value = ( String ) rdn1.getUpValue();
-        String rdn2Value = ( String ) rdn2.getUpValue();
-        if ( rdn1Value.matches( "\\d*" ) && !rdn2Value.matches( "\\d*" ) ) //$NON-NLS-1$
//$NON-NLS-2$
-        {
-            // return lessThan();
-            return compare( rdn1Value, rdn2Value );
-        }
-        else if ( !rdn1Value.matches( "\\d*" ) && rdn2Value.matches( "\\d*" ) ) //$NON-NLS-1$
//$NON-NLS-2$
-        {
-            // return greaterThan();
-            return compare( rdn1Value, rdn2Value );
-        }
-        else if ( rdn2Value.matches( "\\d*" ) && rdn2Value.matches( "\\d*" ) ) //$NON-NLS-1$
//$NON-NLS-2$
-        {
-            BigInteger bi1 = new BigInteger( rdn1Value );
-            BigInteger bi2 = new BigInteger( rdn2Value );
-            return compare( bi1, bi2 );
-            // return Integer.parseInt(rdn1.getValue()) -
-            // Integer.parseInt(rdn2.getValue());
-        }
         else
         {
-            return compare( rdn1Value, rdn2Value );
+            Rdn rdn1 = entry1.getRdn();
+            Rdn rdn2 = entry2.getRdn();
+
+            if ( ( rdn1 == null || rdn1.getValue() == null || "".equals( rdn1.getValue()
) ) //$NON-NLS-1$
+                && ( rdn2 == null || rdn2.getValue() == null || "".equals( rdn2.getValue()
) ) ) //$NON-NLS-1$
+            {
+                return equal();
+            }
+            else if ( ( rdn1 == null || rdn1.getValue() == null || "".equals( rdn1.getValue()
) ) //$NON-NLS-1$
+                && !( rdn2 == null || rdn2.getValue() == null || "".equals( rdn2.getValue()
) ) ) //$NON-NLS-1$
+            {
+                return greaterThan();
+            }
+            else if ( !( rdn1 == null || rdn1.getValue() == null || "".equals( rdn1.getValue()
) ) //$NON-NLS-1$
+                && ( rdn2 == null || rdn2.getValue() == null || "".equals( rdn2.getValue()
) ) ) //$NON-NLS-1$
+            {
+                return lessThan();
+            }
+
+            String rdn1Value = ( String ) rdn1.getUpValue();
+            String rdn2Value = ( String ) rdn2.getUpValue();
+            if ( rdn1Value.matches( "\\d*" ) && !rdn2Value.matches( "\\d*" ) ) //$NON-NLS-1$
//$NON-NLS-2$
+            {
+                // return lessThan();
+                return compare( rdn1Value, rdn2Value );
+            }
+            else if ( !rdn1Value.matches( "\\d*" ) && rdn2Value.matches( "\\d*" )
) //$NON-NLS-1$ //$NON-NLS-2$
+            {
+                // return greaterThan();
+                return compare( rdn1Value, rdn2Value );
+            }
+            else if ( rdn2Value.matches( "\\d*" ) && rdn2Value.matches( "\\d*" )
) //$NON-NLS-1$ //$NON-NLS-2$
+            {
+                BigInteger bi1 = new BigInteger( rdn1Value );
+                BigInteger bi2 = new BigInteger( rdn2Value );
+                return compare( bi1, bi2 );
+                // return Integer.parseInt(rdn1.getValue()) -
+                // Integer.parseInt(rdn2.getValue());
+            }
+            else
+            {
+                return compare( rdn1Value, rdn2Value );
+            }
         }
     }
 

Modified: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorSorter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorSorter.java?rev=898733&r1=898732&r2=898733&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorSorter.java
(original)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorSorter.java
Wed Jan 13 12:59:48 2010
@@ -257,49 +257,64 @@
         IEntry entry1 = sr1.getEntry();
         IEntry entry2 = sr2.getEntry();
 
-        String attributeName;
-        if ( showDn && sortBy == 0 )
+        if ( ( entry1 == null ) && ( entry2 == null ) )
         {
-            attributeName = BrowserUIConstants.DN;
+            return equal();
         }
-        else if ( showDn && sortBy > 0 )
+        else if ( ( entry1 != null ) && ( entry2 == null ) )
         {
-            attributeName = search.getReturningAttributes()[sortBy - 1];
+            return greaterThan();
         }
-        else
+        else if ( ( entry1 == null ) && ( entry2 != null ) )
         {
-            attributeName = search.getReturningAttributes()[sortBy];
-        }
-
-        if ( attributeName == BrowserUIConstants.DN )
-        {
-            // compare normalized names
-            return compare( entry1.getDn().getNormName(), entry2.getDn().getNormName() );
+            return lessThan();
         }
         else
         {
-            AttributeHierarchy ah1 = entry1.getAttributeWithSubtypes( attributeName );
-            AttributeHierarchy ah2 = entry2.getAttributeWithSubtypes( attributeName );
-            if ( ah1 == null && ah2 == null )
+            String attributeName;
+            if ( showDn && sortBy == 0 )
             {
-                return equal();
+                attributeName = BrowserUIConstants.DN;
             }
-            else if ( ah1 == null && ah2 != null )
+            else if ( showDn && sortBy > 0 )
             {
-                return lessThan();
+                attributeName = search.getReturningAttributes()[sortBy - 1];
             }
-            else if ( ah1 != null && ah2 == null )
+            else
             {
-                return greaterThan();
+                attributeName = search.getReturningAttributes()[sortBy];
+            }
+
+            if ( attributeName == BrowserUIConstants.DN )
+            {
+                // compare normalized names
+                return compare( entry1.getDn().getNormName(), entry2.getDn().getNormName()
);
             }
             else
             {
-                IAttribute attribute1 = ah1.getAttribute();
-                IAttribute attribute2 = ah2.getAttribute();
-
-                String value1 = getValue( attribute1 );
-                String value2 = getValue( attribute2 );
-                return compare( value1, value2 );
+                AttributeHierarchy ah1 = entry1.getAttributeWithSubtypes( attributeName );
+                AttributeHierarchy ah2 = entry2.getAttributeWithSubtypes( attributeName );
+                if ( ah1 == null && ah2 == null )
+                {
+                    return equal();
+                }
+                else if ( ah1 == null && ah2 != null )
+                {
+                    return lessThan();
+                }
+                else if ( ah1 != null && ah2 == null )
+                {
+                    return greaterThan();
+                }
+                else
+                {
+                    IAttribute attribute1 = ah1.getAttribute();
+                    IAttribute attribute2 = ah2.getAttribute();
+
+                    String value1 = getValue( attribute1 );
+                    String value2 = getValue( attribute2 );
+                    return compare( value1, value2 );
+                }
             }
         }
     }



Mime
View raw message