directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1683040 - /directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/TimeLimitDialog.java
Date Tue, 02 Jun 2015 04:38:41 GMT
Author: elecharny
Date: Tue Jun  2 04:38:41 2015
New Revision: 1683040

URL: http://svn.apache.org/r1683040
Log:
Various fixes in the way we handle the unlimited and soft checkboxes

Modified:
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/TimeLimitDialog.java

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/TimeLimitDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/TimeLimitDialog.java?rev=1683040&r1=1683039&r2=1683040&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/TimeLimitDialog.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/TimeLimitDialog.java
Tue Jun  2 04:38:41 2015
@@ -222,7 +222,9 @@ public class TimeLimitDialog extends Dia
         {
             Display display = softLimitText.getDisplay();
             Button okButton = getButton( IDialogConstants.OK_ID );
-            
+            boolean unlimited = false;
+            int color = SWT.COLOR_BLACK;
+
             // This button might be null when the dialog is called.
             if ( okButton == null )
             {
@@ -236,14 +238,11 @@ public class TimeLimitDialog extends Dia
             {
                 // Check the case we don't have anything
                 timeLimitWrapper.setSoftLimit( null );
-                softUnlimitedCheckbox.setSelection( false );
-                softLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
             }
             else if ( UNLIMITED_STR.equalsIgnoreCase( softLimitStr ) || NONE_STR.equalsIgnoreCase(
softLimitStr ) ) 
             {
                 timeLimitWrapper.setSoftLimit( TimeLimitWrapper.UNLIMITED );
-                softUnlimitedCheckbox.setSelection( true );
-                softLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
+                unlimited = true;
             }
             else
             {
@@ -255,31 +254,42 @@ public class TimeLimitDialog extends Dia
                     if ( value < TimeLimitWrapper.UNLIMITED )
                     {
                         // The value must be either -1 (unlimited) or a positive number
-                        softLimitText.setForeground( display.getSystemColor( SWT.COLOR_RED
) );
-                        softUnlimitedCheckbox.setSelection( false );
+                        color = SWT.COLOR_RED ;
                     }
                     else if ( value == TimeLimitWrapper.UNLIMITED )
                     {
                         timeLimitWrapper.setSoftLimit( TimeLimitWrapper.UNLIMITED );
-                        softUnlimitedCheckbox.setSelection( true );
-                        softLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK
) );
+                        unlimited = true;
                     }
                     else
                     {
                         timeLimitWrapper.setSoftLimit( value );
-                        softUnlimitedCheckbox.setSelection( false );
-                        softLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK
) );
                     }
                 }
                 catch ( NumberFormatException nfe )
                 {
                     // The value must be either -1 (unlimited) or a positive number
-                    softLimitText.setForeground( display.getSystemColor( SWT.COLOR_RED )
);
-                    softUnlimitedCheckbox.setSelection( false );
+                    color = SWT.COLOR_RED ;
                 }
             }
 
+            softUnlimitedCheckbox.setSelection( unlimited );
+            softLimitText.setForeground( display.getSystemColor( color ) );
             timeLimitText.setText( timeLimitWrapper.toString() );
+            
+            // Update the Hard limit if the hardSoft checkbox is set
+            if ( hardSoftCheckbox.getSelection() )
+            {
+                if ( Strings.isEmpty( softLimitStr ) )
+                {
+                    hardLimitText.setText( "" );
+                }
+                else
+                {
+                    hardLimitText.setText( softLimitStr );
+                }
+            }
+            
             okButton.setEnabled( isValid() );
         }
     };
@@ -294,7 +304,9 @@ public class TimeLimitDialog extends Dia
         {
             Display display = hardLimitText.getDisplay();
             Button okButton = getButton( IDialogConstants.OK_ID );
-            
+            boolean unlimited = false;
+            int color = SWT.COLOR_BLACK;
+
             // This button might be null when the dialog is called.
             if ( okButton == null )
             {
@@ -308,23 +320,16 @@ public class TimeLimitDialog extends Dia
             {
                 // Check the case we don't have anything
                 timeLimitWrapper.setHardLimit( null );
-                hardUnlimitedCheckbox.setSelection( false );
-                hardSoftCheckbox.setSelection( false );
-                hardLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
             }
             else if ( UNLIMITED_STR.equalsIgnoreCase( hardLimitStr ) || NONE_STR.equalsIgnoreCase(
hardLimitStr ) ) 
             {
                 timeLimitWrapper.setHardLimit( TimeLimitWrapper.UNLIMITED );
-                hardUnlimitedCheckbox.setSelection( true );
-                hardSoftCheckbox.setSelection( false );
-                hardLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
+                unlimited = true;
             }
             else if ( SOFT_STR.equalsIgnoreCase( hardLimitStr ) ) 
             {
                 timeLimitWrapper.setHardLimit( timeLimitWrapper.getSoftLimit() );
-                hardSoftCheckbox.setSelection( true );
-                hardUnlimitedCheckbox.setSelection( softUnlimitedCheckbox.getSelection()
);
-                hardLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
+                unlimited = softUnlimitedCheckbox.getSelection();
             }
             else
             {
@@ -336,34 +341,37 @@ public class TimeLimitDialog extends Dia
                     if ( value < TimeLimitWrapper.UNLIMITED )
                     {
                         // The value must be either -1 (unlimited) or a positive number
-                        hardUnlimitedCheckbox.setSelection( false );
-                        hardSoftCheckbox.setSelection( false );
-                        hardLimitText.setForeground( display.getSystemColor( SWT.COLOR_RED
) );
+                        color = SWT.COLOR_RED;
                     }
                     else if ( value == TimeLimitWrapper.UNLIMITED )
                     {
                         timeLimitWrapper.setHardLimit( TimeLimitWrapper.UNLIMITED );
-                        hardUnlimitedCheckbox.setSelection( true );
-                        hardSoftCheckbox.setSelection( false );
-                        hardLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK
) );
+                        unlimited = true;
                     }
                     else
                     {
                         timeLimitWrapper.setHardLimit( value );
-                        hardUnlimitedCheckbox.setSelection( false );
-                        hardSoftCheckbox.setSelection( false );
-                        hardLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK
) );
                     }
                 }
                 catch ( NumberFormatException nfe )
                 {
                     // The value must be either -1 (unlimited) or a positive number
-                    hardLimitText.setForeground( display.getSystemColor( SWT.COLOR_RED )
);
-                    hardUnlimitedCheckbox.setSelection( false );
-                    hardSoftCheckbox.setSelection( false );
+                    color = SWT.COLOR_RED;
                 }
             }
 
+            // Udate the Soft checkbox
+            if ( timeLimitWrapper.getHardLimit() == null )
+            {
+                hardSoftCheckbox.setSelection( timeLimitWrapper.getSoftLimit() == null );
+            }
+            else
+            {
+                hardSoftCheckbox.setSelection( timeLimitWrapper.getHardLimit().equals( timeLimitWrapper.getSoftLimit()
) );
+            }
+            
+            hardUnlimitedCheckbox.setSelection( unlimited );
+            hardLimitText.setForeground( display.getSystemColor( color ) );
             timeLimitText.setText( timeLimitWrapper.toString() );
             okButton.setEnabled( isValid() );
         }
@@ -379,7 +387,9 @@ public class TimeLimitDialog extends Dia
         {
             Display display = globalLimitText.getDisplay();
             Button okButton = getButton( IDialogConstants.OK_ID );
-            
+            boolean unlimited = false;
+            int color = SWT.COLOR_BLACK;
+
             // This button might be null when the dialog is called.
             if ( okButton == null )
             {
@@ -393,14 +403,11 @@ public class TimeLimitDialog extends Dia
             {
                 // Check the case we don't have anything
                 timeLimitWrapper.setGlobalLimit( null );
-                globalUnlimitedCheckbox.setEnabled( false );
-                globalLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK )
);
             }
             else if ( UNLIMITED_STR.equalsIgnoreCase( globalLimitStr ) || NONE_STR.equalsIgnoreCase(
globalLimitStr ) ) 
             {
                 timeLimitWrapper.setGlobalLimit( TimeLimitWrapper.UNLIMITED );
-                globalUnlimitedCheckbox.setSelection( true );
-                globalLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK )
);
+                unlimited = true;
             }
             else
             {
@@ -412,30 +419,28 @@ public class TimeLimitDialog extends Dia
                     if ( value < TimeLimitWrapper.UNLIMITED )
                     {
                         // The value must be either -1 (unlimited) or a positive number
-                        globalLimitText.setForeground( display.getSystemColor( SWT.COLOR_RED
) );
+                        color = SWT.COLOR_RED;
                     }
                     else if ( value == TimeLimitWrapper.UNLIMITED )
                     {
                         timeLimitWrapper.setGlobalLimit( TimeLimitWrapper.UNLIMITED );
-                        globalUnlimitedCheckbox.setSelection( true );
-                        globalLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK
) );
+                        unlimited = true;
                     }
                     else
                     {
                         timeLimitWrapper.setGlobalLimit( value );
-                        globalUnlimitedCheckbox.setSelection( false );
-                        globalLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK
) );
                     }
                 }
                 catch ( NumberFormatException nfe )
                 {
                     // The value must be either -1 (unlimited) or a positive number
-                    globalUnlimitedCheckbox.setEnabled( false );
-                    globalLimitText.setForeground( display.getSystemColor( SWT.COLOR_RED
) );
+                    color = SWT.COLOR_RED;
                 }
             }
 
             timeLimitText.setText( timeLimitWrapper.toString() );
+            globalLimitText.setForeground( display.getSystemColor( color ) );
+            globalUnlimitedCheckbox.setSelection( unlimited );
             okButton.setEnabled( isValid() );
         }
     };
@@ -454,16 +459,15 @@ public class TimeLimitDialog extends Dia
             if ( softUnlimitedCheckbox.getSelection() )
             {
                 softLimitText.setText( UNLIMITED_STR );
-                softLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
                 timeLimitWrapper.setSoftLimit( TimeLimitWrapper.UNLIMITED );
             }
             else
             {
                 softLimitText.setText( "" );
-                softLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
                 timeLimitWrapper.setSoftLimit( null );
             }
 
+            softLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
             timeLimitText.setText( timeLimitWrapper.toString() );
             okButton.setEnabled( isValid() );
         }
@@ -483,17 +487,16 @@ public class TimeLimitDialog extends Dia
             if ( hardUnlimitedCheckbox.getSelection() )
             {
                 hardLimitText.setText( UNLIMITED_STR );
-                hardLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
                 timeLimitWrapper.setHardLimit( TimeLimitWrapper.UNLIMITED );
                 hardSoftCheckbox.setSelection( false );
             }
             else
             {
                 hardLimitText.setText( "" );
-                hardLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
                 timeLimitWrapper.setHardLimit( null );
             }
 
+            hardLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
             timeLimitText.setText( timeLimitWrapper.toString() );
             okButton.setEnabled( isValid() );
         }
@@ -523,17 +526,16 @@ public class TimeLimitDialog extends Dia
                     hardLimitText.setText( "" );
                 }
                 
-                hardLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
-                hardUnlimitedCheckbox.setSelection( false );
                 timeLimitWrapper.setHardLimit( timeLimitWrapper.getSoftLimit() );
+                hardUnlimitedCheckbox.setSelection( TimeLimitWrapper.UNLIMITED.equals( timeLimitWrapper.getSoftLimit()
) );
             }
             else
             {
                 hardLimitText.setText( "" );
-                hardLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
                 timeLimitWrapper.setHardLimit( null );
             }
 
+            hardLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
             timeLimitText.setText( timeLimitWrapper.toString() );
             okButton.setEnabled( isValid() );
         }
@@ -553,16 +555,15 @@ public class TimeLimitDialog extends Dia
             if ( globalUnlimitedCheckbox.getSelection() )
             {
                 globalLimitText.setText( UNLIMITED_STR );
-                globalLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK )
);
                 timeLimitWrapper.setGlobalLimit( TimeLimitWrapper.UNLIMITED );
             }
             else
             {
                 globalLimitText.setText( "" );
-                globalLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK )
);
                 timeLimitWrapper.setGlobalLimit( null );
             }
 
+            globalLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
             timeLimitText.setText( timeLimitWrapper.toString() );
             okButton.setEnabled( isValid() );
         }



Mime
View raw message