directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1683298 [1/2] - in /directory/studio/trunk/plugins/openldap.config.editor/src: main/java/org/apache/directory/studio/openldap/config/editor/dialogs/ main/java/org/apache/directory/studio/openldap/config/editor/pages/ main/java/org/apache/d...
Date Wed, 03 Jun 2015 11:42:41 GMT
Author: elecharny
Date: Wed Jun  3 11:42:41 2015
New Revision: 1683298

URL: http://svn.apache.org/r1683298
Log:
Big refactoring of the TimeLimit and SizeLimit classes : some abstract classes have been created to federate the common methods.

Added:
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/AbstractLimitDialog.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/AbstractLimitWrapper.java
Modified:
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/SizeLimitDialog.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/TimeLimitDialog.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/TuningPage.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SizeLimitWrapper.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/TimeLimitWrapper.java
    directory/studio/trunk/plugins/openldap.config.editor/src/test/java/org/apache/directory/studio/openldap/config/wrappers/SizeLimitWrapperTest.java

Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/AbstractLimitDialog.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/AbstractLimitDialog.java?rev=1683298&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/AbstractLimitDialog.java (added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/AbstractLimitDialog.java Wed Jun  3 11:42:41 2015
@@ -0,0 +1,583 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.openldap.config.editor.dialogs;
+
+import org.apache.directory.api.util.Strings;
+import org.apache.directory.studio.openldap.config.editor.wrappers.AbstractLimitWrapper;
+import org.apache.directory.studio.openldap.config.editor.wrappers.TimeLimitWrapper;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * A class that share elements of configuration between the SizeLimitDialog
+ * and TimeLimitDialog.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public abstract class AbstractLimitDialog extends Dialog
+{
+    // UI widgets
+    /** The SoftLimit Text and checkboxes */
+    protected Text softLimitText;
+    protected Button softUnlimitedCheckbox;
+    
+    /** The HardLimit Text and checkboxes */
+    protected Text hardLimitText;
+    protected Button hardUnlimitedCheckbox;
+    protected Button hardSoftCheckbox;
+    
+    /** The GlobalLimit Text and checkboxes */
+    protected Text globalLimitText;
+    protected Button globalUnlimitedCheckbox;
+    
+    /** The resulting Limit Text, or an error message */
+    protected Text limitText;
+    
+    /** The modified Limit, as a String */
+    protected String newLimitStr;
+    
+    /** The wrapper (either time or size) used to store tghe parameters */
+    protected AbstractLimitWrapper limitWrapper;
+
+
+    /**
+     * Create a new instance of the TimeSizeLimitDialog
+     * 
+     * @param parentShell The parent Shell
+     */
+    protected AbstractLimitDialog( Shell parentShell )
+    {
+        super( parentShell );
+    }
+    
+    
+    /**
+     * Check if the soft value is valid or not
+     */
+    protected boolean isValidSoft()
+    {
+        String softLimitStr = softLimitText.getText();
+        
+        if ( !Strings.isEmpty( softLimitStr ) )
+        {
+            if ( !TimeLimitWrapper.UNLIMITED_STR.equalsIgnoreCase( softLimitStr ) && 
+                !TimeLimitWrapper.NONE_STR.equals( softLimitStr ) )
+            {
+                try
+                {
+                    if ( Integer.parseInt( softLimitStr ) < -1 )
+                    {
+                       return false;
+                    }
+                }
+                catch ( NumberFormatException nfe )
+                {
+                    return false;
+                }
+            }
+        }
+        
+        return true;
+    }
+    
+    
+    /**
+     * Check if the hard value is valid or not
+     */
+    protected boolean isValidHard()
+    {
+        String hardLimitStr = hardLimitText.getText();
+        
+        if ( !Strings.isEmpty( hardLimitStr ) )
+        {
+            if ( !TimeLimitWrapper.UNLIMITED_STR.equalsIgnoreCase( hardLimitStr ) && 
+                 !TimeLimitWrapper.NONE_STR.equals( hardLimitStr ) && 
+                 !TimeLimitWrapper.SOFT_STR.equalsIgnoreCase( hardLimitStr ) )
+            {
+                try
+                {
+                    if ( Integer.parseInt( hardLimitStr ) < -1 )
+                    {
+                       return false;
+                    }
+                }
+                catch ( NumberFormatException nfe )
+                {
+                    return false;
+                }
+            }
+        }
+        
+        return true;
+    }
+    
+    
+    /**
+     * Check if the global value is valid or not
+     */
+    protected boolean isValidGlobal()
+    {
+        String globalLimitStr = hardLimitText.getText();
+        
+        if ( !Strings.isEmpty( globalLimitStr ) )
+        {
+            if ( !TimeLimitWrapper.UNLIMITED_STR.equalsIgnoreCase( globalLimitStr ) && 
+                 !TimeLimitWrapper.NONE_STR.equals( globalLimitStr ) )
+            {
+                try
+                {
+                    if ( Integer.parseInt( globalLimitStr ) < -1 )
+                    {
+                       return false;
+                    }
+                }
+                catch ( NumberFormatException nfe )
+                {
+                    return false;
+                }
+            }
+        }
+        
+        return true;
+    }
+    
+    
+    /**
+     * Check if the global TimeLimit is valid : 
+     * the values must be numeric, or "unlimited" or "none" or "soft" (for the hard limit). They
+     * also have to be >=0
+     */
+    protected boolean isValid()
+    {
+        return isValidSoft() && isValidHard() && isValidGlobal();
+    }
+    
+    
+    /**
+     * The listener for the Soft Limit Text
+     */
+    protected ModifyListener softLimitTextListener = new ModifyListener()
+    {
+        public void modifyText( ModifyEvent e )
+        {
+            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 )
+            {
+                return;
+            }
+
+            // The possible values are : 'unlimited' | 'none' | INT | -1
+            String softLimitStr = softLimitText.getText();
+
+            if ( Strings.isEmpty( softLimitStr ) )
+            {
+                // Check the case we don't have anything
+                limitWrapper.setSoftLimit( null );
+            }
+            else if ( TimeLimitWrapper.UNLIMITED_STR.equalsIgnoreCase( softLimitStr ) || 
+                TimeLimitWrapper.NONE_STR.equalsIgnoreCase( softLimitStr ) ) 
+            {
+                limitWrapper.setSoftLimit( TimeLimitWrapper.UNLIMITED );
+                unlimited = true;
+            }
+            else
+            {
+                // An integer
+                try
+                {
+                    int value = Integer.parseInt( softLimitStr );
+                    
+                    if ( value < TimeLimitWrapper.UNLIMITED )
+                    {
+                        // The value must be either -1 (unlimited) or a positive number
+                        color = SWT.COLOR_RED ;
+                    }
+                    else if ( value == TimeLimitWrapper.UNLIMITED )
+                    {
+                        limitWrapper.setSoftLimit( TimeLimitWrapper.UNLIMITED );
+                        unlimited = true;
+                    }
+                    else
+                    {
+                        limitWrapper.setSoftLimit( value );
+                    }
+                }
+                catch ( NumberFormatException nfe )
+                {
+                    // The value must be either -1 (unlimited) or a positive number
+                    color = SWT.COLOR_RED ;
+                }
+            }
+
+            softUnlimitedCheckbox.setSelection( unlimited );
+            softLimitText.setForeground( display.getSystemColor( color ) );
+            limitText.setText( limitWrapper.toString() );
+            
+            // Update the Hard limit if the hardSoft checkbox is set
+            if ( hardSoftCheckbox.getSelection() )
+            {
+                if ( Strings.isEmpty( softLimitStr ) )
+                {
+                    hardLimitText.setText( "" );
+                }
+                else
+                {
+                    hardLimitText.setText( softLimitStr );
+                    
+                    // Use the same color than for the soft
+                    Display displayHard = softLimitText.getDisplay();
+                    hardLimitText.setForeground( displayHard.getSystemColor( color ) );
+                }
+            }
+            
+            okButton.setEnabled( isValid() );
+        }
+    };
+    
+    
+    /**
+     * The listener for the Hard Limit Text
+     */
+    protected ModifyListener hardLimitTextListener = new ModifyListener()
+    {
+        public void modifyText( ModifyEvent e )
+        {
+            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 )
+            {
+                return;
+            }
+
+            // The possible values are : 'unlimited' | 'none' | 'soft' | INT | -1
+            String hardLimitStr = hardLimitText.getText();
+
+            if ( Strings.isEmpty( hardLimitStr ) )
+            {
+                // Check the case we don't have anything
+                limitWrapper.setHardLimit( null );
+            }
+            else if ( TimeLimitWrapper.UNLIMITED_STR.equalsIgnoreCase( hardLimitStr ) ||
+                TimeLimitWrapper.NONE_STR.equalsIgnoreCase( hardLimitStr ) ) 
+            {
+                limitWrapper.setHardLimit( TimeLimitWrapper.UNLIMITED );
+                unlimited = true;
+            }
+            else if ( TimeLimitWrapper.SOFT_STR.equalsIgnoreCase( hardLimitStr ) ) 
+            {
+                limitWrapper.setHardLimit( limitWrapper.getSoftLimit() );
+                unlimited = softUnlimitedCheckbox.getSelection();
+            }
+            else
+            {
+                // An integer
+                try
+                {
+                    int value = Integer.parseInt( hardLimitStr );
+                    
+                    if ( value < TimeLimitWrapper.UNLIMITED )
+                    {
+                        // The value must be either -1 (unlimited) or a positive number
+                        color = SWT.COLOR_RED;
+                    }
+                    else if ( value == TimeLimitWrapper.UNLIMITED )
+                    {
+                        limitWrapper.setHardLimit( TimeLimitWrapper.UNLIMITED );
+                        unlimited = true;
+                    }
+                    else
+                    {
+                        limitWrapper.setHardLimit( value );
+                    }
+                }
+                catch ( NumberFormatException nfe )
+                {
+                    // The value must be either -1 (unlimited) or a positive number
+                    color = SWT.COLOR_RED;
+                }
+            }
+
+            hardUnlimitedCheckbox.setSelection( unlimited );
+            hardLimitText.setForeground( display.getSystemColor( color ) );
+            limitText.setText( limitWrapper.toString() );
+            
+            if ( isValidSoft() )
+            { 
+                okButton.setEnabled( true );
+            }
+            else
+            {
+                okButton.setEnabled( isValid() );
+            }
+        }
+    };
+    
+    
+    /**
+     * The listener for the Global Limit Text
+     */
+    protected ModifyListener globalLimitTextListener = new ModifyListener()
+    {
+        public void modifyText( ModifyEvent e )
+        {
+            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 )
+            {
+                return;
+            }
+
+            // The possible values are : 'unlimited' | 'none' | INT | -1
+            String globalLimitStr = globalLimitText.getText();
+            
+            if ( Strings.isEmpty( globalLimitStr ) )
+            {
+                // Check the case we don't have anything
+                limitWrapper.setGlobalLimit( null );
+            }
+            else if ( TimeLimitWrapper.UNLIMITED_STR.equalsIgnoreCase( globalLimitStr ) || 
+                TimeLimitWrapper.NONE_STR.equalsIgnoreCase( globalLimitStr ) ) 
+            {
+                limitWrapper.setGlobalLimit( TimeLimitWrapper.UNLIMITED );
+                unlimited = true;
+            }
+            else
+            {
+                // An integer
+                try
+                {
+                    int value = Integer.parseInt( globalLimitStr );
+                    
+                    if ( value < TimeLimitWrapper.UNLIMITED )
+                    {
+                        // The value must be either -1 (unlimited) or a positive number
+                        color = SWT.COLOR_RED;
+                    }
+                    else if ( value == TimeLimitWrapper.UNLIMITED )
+                    {
+                        limitWrapper.setGlobalLimit( TimeLimitWrapper.UNLIMITED );
+                        unlimited = true;
+                    }
+                    else
+                    {
+                        limitWrapper.setGlobalLimit( value );
+                    }
+                }
+                catch ( NumberFormatException nfe )
+                {
+                    // The value must be either -1 (unlimited) or a positive number
+                    color = SWT.COLOR_RED;
+                }
+            }
+
+            limitText.setText( limitWrapper.toString() );
+            globalLimitText.setForeground( display.getSystemColor( color ) );
+            globalUnlimitedCheckbox.setSelection( unlimited );
+            okButton.setEnabled( isValid() );
+        }
+    };
+    
+    
+    /**
+     * The listener in charge of exposing the changes when the soft unlimited button is checked
+     */
+    protected SelectionListener softUnlimitedCheckboxSelectionListener = new SelectionAdapter()
+    {
+        public void widgetSelected( SelectionEvent e )
+        {
+            Display display = softLimitText.getDisplay();
+            Button okButton = getButton( IDialogConstants.OK_ID );
+
+            if ( softUnlimitedCheckbox.getSelection() )
+            {
+                softLimitText.setText( TimeLimitWrapper.UNLIMITED_STR );
+                limitWrapper.setSoftLimit( TimeLimitWrapper.UNLIMITED );
+            }
+            else
+            {
+                softLimitText.setText( "" );
+                limitWrapper.setSoftLimit( null );
+            }
+
+            if ( isValidSoft() )
+            {
+                softLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
+            }
+            else
+            {
+                softLimitText.setForeground( display.getSystemColor( SWT.COLOR_RED ) );
+            }
+            
+            limitText.setText( limitWrapper.toString() );
+            okButton.setEnabled( isValid() );
+        }
+    };
+    
+    
+    /**
+     * The listener in charge of exposing the changes when the hard unlimited button is checked
+     */
+    protected SelectionListener hardUnlimitedCheckboxSelectionListener = new SelectionAdapter()
+    {
+        public void widgetSelected( SelectionEvent e )
+        {
+            Display display = hardLimitText.getDisplay();
+            Button okButton = getButton( IDialogConstants.OK_ID );
+
+            if ( hardUnlimitedCheckbox.getSelection() )
+            {
+                hardLimitText.setText( TimeLimitWrapper.UNLIMITED_STR );
+                limitWrapper.setHardLimit( TimeLimitWrapper.UNLIMITED );
+                hardSoftCheckbox.setSelection( false );
+                hardLimitText.setEnabled( true );
+            }
+            else
+            {
+                hardLimitText.setText( "" );
+                limitWrapper.setHardLimit( null );
+            }
+
+            hardLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
+            limitText.setText( limitWrapper.toString() );
+            okButton.setEnabled( isValid() );
+        }
+    };
+    
+    
+    /**
+     * The listener in charge of exposing the changes when the hard unlimited button is checked.
+     * We will disable the hardLimitText.
+     */
+    protected SelectionListener hardSoftCheckboxSelectionListener = new SelectionAdapter()
+    {
+        public void widgetSelected( SelectionEvent e )
+        {
+            Display display = hardLimitText.getDisplay();
+            Button okButton = getButton( IDialogConstants.OK_ID );
+
+            if ( hardSoftCheckbox.getSelection() )
+            {
+                hardLimitText.setEnabled( false );
+                String softStr = softLimitText.getText();
+                
+                if ( softStr != null )
+                {
+                    hardLimitText.setText( softStr );
+                }
+                else
+                {
+                    hardLimitText.setText( "" );
+                }
+                
+                limitWrapper.setHardLimit( limitWrapper.getSoftLimit() );
+                hardUnlimitedCheckbox.setSelection( TimeLimitWrapper.UNLIMITED.equals( limitWrapper.getSoftLimit() ) );
+
+                if ( isValidSoft() )
+                { 
+                    hardLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
+                }
+                else
+                {
+                    hardLimitText.setForeground( display.getSystemColor( SWT.COLOR_RED ) );
+                }
+            }
+            else
+            {
+                hardLimitText.setText( "" );
+                hardLimitText.setEnabled( true );
+                limitWrapper.setHardLimit( null );
+            }
+
+            limitText.setText( limitWrapper.toString() );
+            okButton.setEnabled( isValid() );
+        }
+    };
+    
+    
+    /**
+     * The listener in charge of exposing the changes when the global unlimited button is checked
+     */
+    protected SelectionListener globalUnlimitedCheckboxSelectionListener = new SelectionAdapter()
+    {
+        public void widgetSelected( SelectionEvent e )
+        {
+            Display display = globalLimitText.getDisplay();
+            Button okButton = getButton( IDialogConstants.OK_ID );
+
+            if ( globalUnlimitedCheckbox.getSelection() )
+            {
+                globalLimitText.setText( TimeLimitWrapper.UNLIMITED_STR );
+                limitWrapper.setGlobalLimit( TimeLimitWrapper.UNLIMITED );
+            }
+            else
+            {
+                globalLimitText.setText( "" );
+                limitWrapper.setGlobalLimit( null );
+            }
+
+            globalLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
+            limitText.setText( limitWrapper.toString() );
+            okButton.setEnabled( isValid() );
+        }
+    };
+    
+    
+    /**
+     * Construct the new TimeLimit from what we have in the dialog
+     * {@inheritDoc}
+     */
+    protected void okPressed()
+    {
+        newLimitStr = limitWrapper.toString();
+        super.okPressed();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getNewLimit()
+    {
+        return newLimitStr;
+    }
+}

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/SizeLimitDialog.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/SizeLimitDialog.java?rev=1683298&r1=1683297&r2=1683298&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/SizeLimitDialog.java (original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/SizeLimitDialog.java Wed Jun  3 11:42:41 2015
@@ -22,7 +22,6 @@ package org.apache.directory.studio.open
 
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
-import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;
@@ -93,22 +92,8 @@ import org.apache.directory.studio.openl
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class SizeLimitDialog extends Dialog
+public class SizeLimitDialog extends AbstractLimitDialog
 {
-    // UI widgets
-    /** The SoftLimit Text and checkboxes */
-    private Text softLimitText;
-    private Button softUnlimitedCheckbox;
-    
-    /** The HardLimit Text and checkboxes */
-    private Text hardLimitText;
-    private Button hardUnlimitedCheckbox;
-    private Button hardSoftCheckbox;
-    
-    /** The GlobalLimit Text and checkboxes */
-    private Text globalLimitText;
-    private Button globalUnlimitedCheckbox;
-    
     /** The UncheckedLimit Text and checkboxes */
     private Text uncheckedLimitText;
     private Button uncheckedUnlimitedCheckbox;
@@ -124,15 +109,6 @@ public class SizeLimitDialog extends Dia
     private Button prTotalUnlimitedCheckbox;
     private Button prTotalDisabledCheckbox;
     private Button prTotalHardCheckbox;
-
-    /** The resulting SizeLimit Text, or an error message */
-    private Text sizeLimitText;
-    
-    /** The SizeLimitWrapper */
-    private SizeLimitWrapper sizeLimitWrapper;
-    
-    /** The modified SizeLimit, as a String */
-    private String newSizeLimitStr;
     
     /**
      * Create a new instance of the SizeLimitDialog
@@ -157,7 +133,7 @@ public class SizeLimitDialog extends Dia
         super( parentShell );
         super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
         
-        sizeLimitWrapper = new SizeLimitWrapper( sizeLimitStr );
+        limitWrapper = new SizeLimitWrapper( sizeLimitStr );
     }
     
     
@@ -166,315 +142,101 @@ public class SizeLimitDialog extends Dia
      * the values must be numeric, or "unlimited" or "none" or "soft" (for the hard limit). They
      * also have to be >=0
      */
-    private boolean isValid()
+    protected boolean isValid()
     {
-        String softLimitStr = softLimitText.getText();
-        String hardLimitStr = hardLimitText.getText();
-        String globalLimitStr = globalLimitText.getText();
-        
-        if ( !Strings.isEmpty( softLimitStr ) )
-        {
-            if ( !SizeLimitWrapper.UNLIMITED_STR.equalsIgnoreCase( softLimitStr ) && 
-                !SizeLimitWrapper.NONE_STR.equals( softLimitStr ) )
-            {
-                try
-                {
-                    if ( Integer.valueOf( softLimitStr ) < -1 )
-                    {
-                       return false;
-                    }
-                }
-                catch ( NumberFormatException nfe )
-                {
-                    return false;
-                }
-            }
-        }
-        
-        if ( !Strings.isEmpty( hardLimitStr ) )
-        {
-            if ( !SizeLimitWrapper.UNLIMITED_STR.equalsIgnoreCase( hardLimitStr ) && 
-                !SizeLimitWrapper.NONE_STR.equals( hardLimitStr ) && 
-                !SizeLimitWrapper.SOFT_STR.equalsIgnoreCase( hardLimitStr ) )
-            {
-                try
-                {
-                    if ( Integer.valueOf( hardLimitStr ) < -1 )
-                    {
-                       return false;
-                    }
-                }
-                catch ( NumberFormatException nfe )
-                {
-                    return false;
-                }
-            }
-        }
-        
-        if ( !Strings.isEmpty( globalLimitStr ) )
-        {
-            if ( !SizeLimitWrapper.UNLIMITED_STR.equalsIgnoreCase( globalLimitStr ) && 
-                !SizeLimitWrapper.NONE_STR.equals( globalLimitStr ) )
-            {
-                try
-                {
-                    if ( Integer.valueOf( globalLimitStr ) < -1 )
-                    {
-                       return false;
-                    }
-                }
-                catch ( NumberFormatException nfe )
-                {
-                    return false;
-                }
-            }
-        }
-        
-        return true;
+        return super.isValid() && isValidUnchecked() && isValidPr() && isValidPrTotal();
     }
     
     
-    
     /**
-     * The listener for the Soft Limit Text
+     * Check if the unchecked value is valid or not
      */
-    private ModifyListener softLimitTextListener = new ModifyListener()
+    protected boolean isValidUnchecked()
     {
-        public void modifyText( ModifyEvent e )
+        String uncheckedlLimitStr = uncheckedLimitText.getText();
+        
+        if ( !Strings.isEmpty( uncheckedlLimitStr ) )
         {
-            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 )
-            {
-                return;
-            }
-
-            // The possible values are : 'unlimited' | 'none' | INT | -1
-            String softLimitStr = softLimitText.getText();
-
-            if ( Strings.isEmpty( softLimitStr ) )
+            if ( !SizeLimitWrapper.UNLIMITED_STR.equalsIgnoreCase( uncheckedlLimitStr ) && 
+                 !SizeLimitWrapper.NONE_STR.equals( uncheckedlLimitStr ) )
             {
-                // Check the case we don't have anything
-                sizeLimitWrapper.setSoftLimit( null );
-            }
-            else if ( SizeLimitWrapper.UNLIMITED_STR.equalsIgnoreCase( softLimitStr ) || 
-                SizeLimitWrapper.NONE_STR.equalsIgnoreCase( softLimitStr ) ) 
-            {
-                sizeLimitWrapper.setSoftLimit( SizeLimitWrapper.UNLIMITED );
-                unlimited = true;
-            }
-            else
-            {
-                // An integer
                 try
                 {
-                    int value = Integer.parseInt( softLimitStr );
-                    
-                    if ( value < SizeLimitWrapper.UNLIMITED )
+                    if ( Integer.parseInt( uncheckedlLimitStr ) < SizeLimitWrapper.UNLIMITED.intValue() )
                     {
-                        // The value must be either -1 (unlimited) or a positive number
-                        color = SWT.COLOR_RED ;
-                    }
-                    else if ( value == SizeLimitWrapper.UNLIMITED )
-                    {
-                        sizeLimitWrapper.setSoftLimit( SizeLimitWrapper.UNLIMITED );
-                        unlimited = true;
-                    }
-                    else
-                    {
-                        sizeLimitWrapper.setSoftLimit( value );
+                       return false;
                     }
                 }
                 catch ( NumberFormatException nfe )
                 {
-                    // The value must be either -1 (unlimited) or a positive number
-                    color = SWT.COLOR_RED ;
-                }
-            }
-
-            softUnlimitedCheckbox.setSelection( unlimited );
-            softLimitText.setForeground( display.getSystemColor( color ) );
-            sizeLimitText.setText( sizeLimitWrapper.toString() );
-            
-            // Update the Hard limit if the hardSoft checkbox is set
-            if ( hardSoftCheckbox.getSelection() )
-            {
-                if ( Strings.isEmpty( softLimitStr ) )
-                {
-                    hardLimitText.setText( "" );
-                }
-                else
-                {
-                    hardLimitText.setText( softLimitStr );
+                    return false;
                 }
             }
-            
-            okButton.setEnabled( isValid() );
         }
-    };
-    
-    
+        
+        return true;
+    }
     
     
     /**
-     * The listener for the Hard Limit Text
+     * Check if the pr value is valid or not
      */
-    private ModifyListener hardLimitTextListener = new ModifyListener()
+    protected boolean isValidPr()
     {
-        public void modifyText( ModifyEvent e )
+        String prLimitStr = prLimitText.getText();
+        
+        if ( !Strings.isEmpty( prLimitStr ) )
         {
-            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 )
+            if ( !SizeLimitWrapper.UNLIMITED_STR.equalsIgnoreCase( prLimitStr ) && 
+                 !SizeLimitWrapper.NONE_STR.equals( prLimitStr ) )
             {
-                return;
-            }
-
-            // The possible values are : 'unlimited' | 'none' | 'soft' | INT | -1
-            String hardLimitStr = hardLimitText.getText();
-
-            if ( Strings.isEmpty( hardLimitStr ) )
-            {
-                // Check the case we don't have anything
-                sizeLimitWrapper.setHardLimit( null );
-            }
-            else if ( SizeLimitWrapper.UNLIMITED_STR.equalsIgnoreCase( hardLimitStr ) || 
-                SizeLimitWrapper.NONE_STR.equalsIgnoreCase( hardLimitStr ) ) 
-            {
-                sizeLimitWrapper.setHardLimit( SizeLimitWrapper.UNLIMITED );
-                unlimited = true;
-            }
-            else if ( SizeLimitWrapper.SOFT_STR.equalsIgnoreCase( hardLimitStr ) ) 
-            {
-                sizeLimitWrapper.setHardLimit( sizeLimitWrapper.getSoftLimit() );
-                unlimited = softUnlimitedCheckbox.getSelection();
-            }
-            else
-            {
-                // An integer
                 try
                 {
-                    int value = Integer.parseInt( hardLimitStr );
-                    
-                    if ( value < SizeLimitWrapper.UNLIMITED )
-                    {
-                        // The value must be either -1 (unlimited) or a positive number
-                        color = SWT.COLOR_RED;
-                    }
-                    else if ( value == SizeLimitWrapper.UNLIMITED )
+                    if ( Integer.parseInt( prLimitStr ) < SizeLimitWrapper.UNLIMITED.intValue() )
                     {
-                        sizeLimitWrapper.setHardLimit( SizeLimitWrapper.UNLIMITED );
-                        unlimited = true;
-                    }
-                    else
-                    {
-                        sizeLimitWrapper.setHardLimit( value );
+                       return false;
                     }
                 }
                 catch ( NumberFormatException nfe )
                 {
-                    // The value must be either -1 (unlimited) or a positive number
-                    color = SWT.COLOR_RED;
+                    return false;
                 }
             }
-
-            // Udate the Soft checkbox
-            if ( sizeLimitWrapper.getHardLimit() == null )
-            {
-                hardSoftCheckbox.setSelection( false );
-            }
-            else
-            {
-                hardSoftCheckbox.setSelection( sizeLimitWrapper.getHardLimit().equals( sizeLimitWrapper.getSoftLimit() ) );
-            }
-            
-            hardUnlimitedCheckbox.setSelection( unlimited );
-            hardLimitText.setForeground( display.getSystemColor( color ) );
-            sizeLimitText.setText( sizeLimitWrapper.toString() );
-            okButton.setEnabled( isValid() );
         }
-    };
+        
+        return true;
+    }
     
     
     /**
-     * The listener for the Global Limit Text
+     * Check if the prtotal value is valid or not
      */
-    private ModifyListener globalLimitTextListener = new ModifyListener()
+    protected boolean isValidPrTotal()
     {
-        public void modifyText( ModifyEvent e )
+        String prTotalLimitStr = prTotalLimitText.getText();
+        
+        if ( !Strings.isEmpty( prTotalLimitStr ) )
         {
-            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 )
-            {
-                return;
-            }
-
-            // The possible values are : 'unlimited' | 'none' | INT | -1
-            String globalLimitStr = globalLimitText.getText();
-            
-            if ( Strings.isEmpty( globalLimitStr ) )
-            {
-                // Check the case we don't have anything
-                sizeLimitWrapper.setGlobalLimit( null );
-            }
-            else if ( SizeLimitWrapper.UNLIMITED_STR.equalsIgnoreCase( globalLimitStr ) || 
-                SizeLimitWrapper.NONE_STR.equalsIgnoreCase( globalLimitStr ) ) 
+            if ( !SizeLimitWrapper.UNLIMITED_STR.equalsIgnoreCase( prTotalLimitStr ) && 
+                 !SizeLimitWrapper.NONE_STR.equals( prTotalLimitStr ) &&
+                 !SizeLimitWrapper.DISABLED_STR.equals( prTotalLimitStr ) )
             {
-                sizeLimitWrapper.setGlobalLimit( SizeLimitWrapper.UNLIMITED );
-                unlimited = true;
-            }
-            else
-            {
-                // An integer
                 try
                 {
-                    int value = Integer.parseInt( globalLimitStr );
-                    
-                    if ( value < SizeLimitWrapper.UNLIMITED )
+                    if ( Integer.parseInt( prTotalLimitStr ) < SizeLimitWrapper.PR_DISABLED.intValue() )
                     {
-                        // The value must be either -1 (unlimited) or a positive number
-                        color = SWT.COLOR_RED;
-                    }
-                    else if ( value == SizeLimitWrapper.UNLIMITED )
-                    {
-                        sizeLimitWrapper.setGlobalLimit( SizeLimitWrapper.UNLIMITED );
-                        unlimited = true;
-                    }
-                    else
-                    {
-                        sizeLimitWrapper.setGlobalLimit( value );
+                       return false;
                     }
                 }
                 catch ( NumberFormatException nfe )
                 {
-                    // The value must be either -1 (unlimited) or a positive number
-                    color = SWT.COLOR_RED;
+                    return false;
                 }
             }
-
-            sizeLimitText.setText( sizeLimitWrapper.toString() );
-            globalLimitText.setForeground( display.getSystemColor( color ) );
-            globalUnlimitedCheckbox.setSelection( unlimited );
-            okButton.setEnabled( isValid() );
         }
-    };
-    
-    
-
-    
+        
+        return true;
+    }
     
     
     /**
@@ -502,17 +264,17 @@ public class SizeLimitDialog extends Dia
             if ( Strings.isEmpty( uncheckedLimitStr ) )
             {
                 // Check the case we don't have anything
-                sizeLimitWrapper.setUncheckedLimit( null );
+                ((SizeLimitWrapper)limitWrapper).setUncheckedLimit( null );
             }
             else if ( SizeLimitWrapper.UNLIMITED_STR.equalsIgnoreCase( uncheckedLimitStr ) || 
                 SizeLimitWrapper.NONE_STR.equalsIgnoreCase( uncheckedLimitStr ) ) 
             {
-                sizeLimitWrapper.setUncheckedLimit( SizeLimitWrapper.UNLIMITED );
+                ((SizeLimitWrapper)limitWrapper).setUncheckedLimit( SizeLimitWrapper.UNLIMITED );
                 unlimited = true;
             }
             else if ( SizeLimitWrapper.DISABLED_STR.equalsIgnoreCase( uncheckedLimitStr ) )
             {
-                sizeLimitWrapper.setUncheckedLimit( SizeLimitWrapper.PR_DISABLED );
+                ((SizeLimitWrapper)limitWrapper).setUncheckedLimit( SizeLimitWrapper.PR_DISABLED );
                 disabled = true;
             }
             else
@@ -529,17 +291,17 @@ public class SizeLimitDialog extends Dia
                     }
                     else if ( value == SizeLimitWrapper.UNLIMITED )
                     {
-                        sizeLimitWrapper.setUncheckedLimit( SizeLimitWrapper.UNLIMITED );
+                        ((SizeLimitWrapper)limitWrapper).setUncheckedLimit( SizeLimitWrapper.UNLIMITED );
                         unlimited = true;
                     }
                     else if ( value == SizeLimitWrapper.UC_DISABLED )
                     {
-                        sizeLimitWrapper.setUncheckedLimit( SizeLimitWrapper.UC_DISABLED );
+                        ((SizeLimitWrapper)limitWrapper).setUncheckedLimit( SizeLimitWrapper.UC_DISABLED );
                         disabled = true;
                     }
                     else
                     {
-                        sizeLimitWrapper.setUncheckedLimit( value );
+                        ((SizeLimitWrapper)limitWrapper).setUncheckedLimit( value );
                     }
                 }
                 catch ( NumberFormatException nfe )
@@ -552,7 +314,7 @@ public class SizeLimitDialog extends Dia
             uncheckedLimitText.setForeground( display.getSystemColor( color ) );
             uncheckedUnlimitedCheckbox.setSelection( unlimited );
             uncheckedDisabledCheckbox.setSelection( disabled );
-            sizeLimitText.setText( sizeLimitWrapper.toString() );
+            limitText.setText( limitWrapper.toString() );
             okButton.setEnabled( isValid() );
         }
     };
@@ -582,12 +344,12 @@ public class SizeLimitDialog extends Dia
             if ( Strings.isEmpty( prLimitStr ) )
             {
                 // Check the case we don't have anything
-                sizeLimitWrapper.setPrLimit( null );
+                ((SizeLimitWrapper)limitWrapper).setPrLimit( null );
             }
             else if ( SizeLimitWrapper.UNLIMITED_STR.equalsIgnoreCase( prLimitStr ) || 
                 SizeLimitWrapper.NONE_STR.equalsIgnoreCase( prLimitStr ) ) 
             {
-                sizeLimitWrapper.setPrLimit( SizeLimitWrapper.UNLIMITED );
+                ((SizeLimitWrapper)limitWrapper).setPrLimit( SizeLimitWrapper.UNLIMITED );
                 unlimited = true;
             }
             else
@@ -604,12 +366,12 @@ public class SizeLimitDialog extends Dia
                     }
                     else if ( value == SizeLimitWrapper.UNLIMITED )
                     {
-                        sizeLimitWrapper.setPrLimit( SizeLimitWrapper.UNLIMITED );
+                        ((SizeLimitWrapper)limitWrapper).setPrLimit( SizeLimitWrapper.UNLIMITED );
                         unlimited = true;
                     }
                     else
                     {
-                        sizeLimitWrapper.setPrLimit( value );
+                        ((SizeLimitWrapper)limitWrapper).setPrLimit( value );
                     }
                 }
                 catch ( NumberFormatException nfe )
@@ -621,7 +383,7 @@ public class SizeLimitDialog extends Dia
 
             prLimitText.setForeground( display.getSystemColor( color ) );
             prUnlimitedCheckbox.setSelection( unlimited );
-            sizeLimitText.setText( sizeLimitWrapper.toString() );
+            limitText.setText( limitWrapper.toString() );
             okButton.setEnabled( isValid() );
         }
     };
@@ -655,22 +417,22 @@ public class SizeLimitDialog extends Dia
             if ( Strings.isEmpty( prTotalLimitStr ) )
             {
                 // Check the case we don't have anything
-                sizeLimitWrapper.setPrTotalLimit( null );
+                ((SizeLimitWrapper)limitWrapper).setPrTotalLimit( null );
             }
             else if ( SizeLimitWrapper.UNLIMITED_STR.equalsIgnoreCase( prTotalLimitStr ) || 
                 SizeLimitWrapper.NONE_STR.equalsIgnoreCase( prTotalLimitStr ) ) 
             {
-                sizeLimitWrapper.setPrTotalLimit( SizeLimitWrapper.UNLIMITED );
+                ((SizeLimitWrapper)limitWrapper).setPrTotalLimit( SizeLimitWrapper.UNLIMITED );
                 unlimited = true;
             }
             else if ( SizeLimitWrapper.HARD_STR.equalsIgnoreCase( prTotalLimitStr ) ) 
             {
-                sizeLimitWrapper.setPrTotalLimit( SizeLimitWrapper.PR_HARD );
+                ((SizeLimitWrapper)limitWrapper).setPrTotalLimit( SizeLimitWrapper.PR_HARD );
                 hard = true;
             }
             else if ( SizeLimitWrapper.DISABLED_STR.equalsIgnoreCase( prTotalLimitStr ) )
             {
-                sizeLimitWrapper.setPrTotalLimit( SizeLimitWrapper.PR_DISABLED );
+                ((SizeLimitWrapper)limitWrapper).setPrTotalLimit( SizeLimitWrapper.PR_DISABLED );
                 disabled = true;
             }
             else
@@ -687,21 +449,21 @@ public class SizeLimitDialog extends Dia
                     }
                     else if ( value == SizeLimitWrapper.PR_DISABLED )
                     {
-                        sizeLimitWrapper.setPrTotalLimit( SizeLimitWrapper.PR_DISABLED );
+                        ((SizeLimitWrapper)limitWrapper).setPrTotalLimit( SizeLimitWrapper.PR_DISABLED );
                         disabled = true;
                     }
                     else if ( value == SizeLimitWrapper.UNLIMITED )
                     {
-                        sizeLimitWrapper.setPrTotalLimit( SizeLimitWrapper.UNLIMITED );
+                        ((SizeLimitWrapper)limitWrapper).setPrTotalLimit( SizeLimitWrapper.UNLIMITED );
                         unlimited = true;
                     }
                     else if ( value == SizeLimitWrapper.PR_HARD )
                     {
-                        sizeLimitWrapper.setPrTotalLimit( SizeLimitWrapper.PR_HARD );
+                        ((SizeLimitWrapper)limitWrapper).setPrTotalLimit( SizeLimitWrapper.PR_HARD );
                     }
                     else
                     {
-                        sizeLimitWrapper.setPrTotalLimit( value );
+                        ((SizeLimitWrapper)limitWrapper).setPrTotalLimit( value );
                     }
                 }
                 catch ( NumberFormatException nfe )
@@ -715,218 +477,219 @@ public class SizeLimitDialog extends Dia
             prTotalUnlimitedCheckbox.setSelection( unlimited );
             prTotalDisabledCheckbox.setSelection( disabled );
             prTotalHardCheckbox.setSelection( hard );
-            sizeLimitText.setText( sizeLimitWrapper.toString() );
+            limitText.setText( limitWrapper.toString() );
             okButton.setEnabled( isValid() );
         }
     };
-
+    
     
     /**
-     * The listener in charge of exposing the changes when the soft unlimited button is checked
+     * The listener in charge of exposing the changes when the unchecked unlimited button is checked
      */
-    private SelectionListener softUnlimitedCheckboxSelectionListener = new SelectionAdapter()
+    private SelectionListener uncheckedUnlimitedCheckboxSelectionListener = new SelectionAdapter()
     {
         public void widgetSelected( SelectionEvent e )
         {
-            Display display = softLimitText.getDisplay();
+            Display display = uncheckedLimitText.getDisplay();
             Button okButton = getButton( IDialogConstants.OK_ID );
 
-            if ( softUnlimitedCheckbox.getSelection() )
+            if ( uncheckedUnlimitedCheckbox.getSelection() )
             {
-                softLimitText.setText( SizeLimitWrapper.UNLIMITED_STR );
-                sizeLimitWrapper.setSoftLimit( SizeLimitWrapper.UNLIMITED );
+                uncheckedLimitText.setText( SizeLimitWrapper.UNLIMITED_STR );
+                uncheckedDisabledCheckbox.setSelection( false );
+                ((SizeLimitWrapper)limitWrapper).setUncheckedLimit( SizeLimitWrapper.UNLIMITED );
             }
             else
             {
-                softLimitText.setText( "" );
-                sizeLimitWrapper.setSoftLimit( null );
+                uncheckedLimitText.setText( "" );
+                ((SizeLimitWrapper)limitWrapper).setUncheckedLimit( null );
             }
 
-            softLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
-            sizeLimitText.setText( sizeLimitWrapper.toString() );
+            uncheckedLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
+            limitText.setText( limitWrapper.toString() );
             okButton.setEnabled( isValid() );
         }
     };
     
     
     /**
-     * The listener in charge of exposing the changes when the hard unlimited button is checked
+     * The listener in charge of exposing the changes when the unchecked disabled button is checked
      */
-    private SelectionListener hardUnlimitedCheckboxSelectionListener = new SelectionAdapter()
+    private SelectionListener uncheckedDisabledCheckboxSelectionListener = new SelectionAdapter()
     {
         public void widgetSelected( SelectionEvent e )
         {
-            Display display = hardLimitText.getDisplay();
+            Display display = uncheckedLimitText.getDisplay();
             Button okButton = getButton( IDialogConstants.OK_ID );
 
-            if ( hardUnlimitedCheckbox.getSelection() )
+            if ( uncheckedDisabledCheckbox.getSelection() )
             {
-                hardLimitText.setText( SizeLimitWrapper.UNLIMITED_STR );
-                sizeLimitWrapper.setHardLimit( SizeLimitWrapper.UNLIMITED );
-                hardSoftCheckbox.setSelection( false );
+                uncheckedLimitText.setText( SizeLimitWrapper.DISABLED_STR );
+                uncheckedUnlimitedCheckbox.setSelection( false );
+                ((SizeLimitWrapper)limitWrapper).setUncheckedLimit( SizeLimitWrapper.UC_DISABLED );
             }
             else
             {
-                hardLimitText.setText( "" );
-                sizeLimitWrapper.setHardLimit( null );
+                uncheckedLimitText.setText( "" );
+                ((SizeLimitWrapper)limitWrapper).setUncheckedLimit( null );
             }
 
-            hardLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
-            sizeLimitText.setText( sizeLimitWrapper.toString() );
+            uncheckedLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
+            limitText.setText( limitWrapper.toString() );
             okButton.setEnabled( isValid() );
         }
     };
     
     
     /**
-     * The listener in charge of exposing the changes when the hard unlimited button is checked
+     * The listener in charge of exposing the changes when the pr unlimited button is checked
      */
-    private SelectionListener hardSoftCheckboxSelectionListener = new SelectionAdapter()
+    private SelectionListener prUnlimitedCheckboxSelectionListener = new SelectionAdapter()
     {
         public void widgetSelected( SelectionEvent e )
         {
-            Display display = hardLimitText.getDisplay();
+            Display display = prLimitText.getDisplay();
             Button okButton = getButton( IDialogConstants.OK_ID );
 
-            if ( hardSoftCheckbox.getSelection() )
+            if ( prUnlimitedCheckbox.getSelection() )
             {
-                String softStr = softLimitText.getText();
-                
-                if ( softStr != null )
-                {
-                    hardLimitText.setText( softStr );
-                }
-                else
-                {
-                    hardLimitText.setText( "" );
-                }
-                
-                sizeLimitWrapper.setHardLimit( sizeLimitWrapper.getSoftLimit() );
-                hardUnlimitedCheckbox.setSelection( SizeLimitWrapper.UNLIMITED.equals( sizeLimitWrapper.getSoftLimit() ) );
+                prLimitText.setText( SizeLimitWrapper.UNLIMITED_STR );
+                ((SizeLimitWrapper)limitWrapper).setPrLimit( SizeLimitWrapper.UNLIMITED );
             }
             else
             {
-                hardLimitText.setText( "" );
-                sizeLimitWrapper.setHardLimit( null );
+                prLimitText.setText( "" );
+                ((SizeLimitWrapper)limitWrapper).setPrLimit( null );
             }
 
-            hardLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
-            sizeLimitText.setText( sizeLimitWrapper.toString() );
+            prLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
+            limitText.setText( limitWrapper.toString() );
             okButton.setEnabled( isValid() );
         }
     };
     
     
     /**
-     * The listener in charge of exposing the changes when the global unlimited button is checked
+     * The listener in charge of exposing the changes when the pr noEstimate button is checked
      */
-    private SelectionListener globalUnlimitedCheckboxSelectionListener = new SelectionAdapter()
+    private SelectionListener prNoEstimateCheckboxSelectionListener = new SelectionAdapter()
     {
         public void widgetSelected( SelectionEvent e )
         {
-            Display display = globalLimitText.getDisplay();
             Button okButton = getButton( IDialogConstants.OK_ID );
 
-            if ( globalUnlimitedCheckbox.getSelection() )
-            {
-                globalLimitText.setText( SizeLimitWrapper.UNLIMITED_STR );
-                sizeLimitWrapper.setGlobalLimit( SizeLimitWrapper.UNLIMITED );
-            }
-            else
-            {
-                globalLimitText.setText( "" );
-                sizeLimitWrapper.setGlobalLimit( null );
-            }
-
-            globalLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
-            sizeLimitText.setText( sizeLimitWrapper.toString() );
+            ((SizeLimitWrapper)limitWrapper).setNoEstimate( prNoEstimateCheckbox.getSelection() );
+            limitText.setText( limitWrapper.toString() );
             okButton.setEnabled( isValid() );
         }
     };
     
     
     /**
-     * The listener in charge of exposing the changes when the unchecked unlimited button is checked
+     * The listener in charge of exposing the changes when the prTotal unlimited button is checked
      */
-    private SelectionListener uncheckedUnlimitedCheckboxSelectionListener = new SelectionAdapter()
+    private SelectionListener prTotalUnlimitedCheckboxSelectionListener = new SelectionAdapter()
     {
         public void widgetSelected( SelectionEvent e )
         {
-            Display display = uncheckedLimitText.getDisplay();
+            Display display = prTotalLimitText.getDisplay();
             Button okButton = getButton( IDialogConstants.OK_ID );
 
-            if ( uncheckedUnlimitedCheckbox.getSelection() )
+            if ( prTotalUnlimitedCheckbox.getSelection() )
             {
-                uncheckedLimitText.setText( SizeLimitWrapper.UNLIMITED_STR );
-                uncheckedDisabledCheckbox.setSelection( false );
-                sizeLimitWrapper.setUncheckedLimit( SizeLimitWrapper.UNLIMITED );
+                prTotalLimitText.setText( SizeLimitWrapper.UNLIMITED_STR );
+                ((SizeLimitWrapper)limitWrapper).setPrTotalLimit( SizeLimitWrapper.UNLIMITED );
             }
             else
             {
-                uncheckedLimitText.setText( "" );
-                sizeLimitWrapper.setUncheckedLimit( null );
+                prTotalLimitText.setText( "" );
+                ((SizeLimitWrapper)limitWrapper).setPrTotalLimit( null );
             }
 
-            uncheckedLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
-            sizeLimitText.setText( sizeLimitWrapper.toString() );
+            prTotalLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
+            prTotalDisabledCheckbox.setSelection( false );
+            prTotalHardCheckbox.setSelection( false );
+            limitText.setText( limitWrapper.toString() );
             okButton.setEnabled( isValid() );
         }
     };
     
     
     /**
-     * The listener in charge of exposing the changes when the unchecked disabled button is checked
+     * The listener in charge of exposing the changes when the prTotal disabled button is checked
      */
-    private SelectionListener uncheckedDisabledCheckboxSelectionListener = new SelectionAdapter()
+    private SelectionListener prTotalDisabledCheckboxSelectionListener = new SelectionAdapter()
     {
         public void widgetSelected( SelectionEvent e )
         {
-            Display display = uncheckedLimitText.getDisplay();
+            Display display = prTotalLimitText.getDisplay();
             Button okButton = getButton( IDialogConstants.OK_ID );
 
-            if ( uncheckedDisabledCheckbox.getSelection() )
+            if ( prTotalDisabledCheckbox.getSelection() )
             {
-                uncheckedLimitText.setText( SizeLimitWrapper.DISABLED_STR );
-                uncheckedUnlimitedCheckbox.setSelection( false );
-                sizeLimitWrapper.setUncheckedLimit( SizeLimitWrapper.UC_DISABLED );
+                prTotalLimitText.setText( SizeLimitWrapper.DISABLED_STR );
+                ((SizeLimitWrapper)limitWrapper).setPrTotalLimit( SizeLimitWrapper.PR_DISABLED );
             }
             else
             {
-                uncheckedLimitText.setText( "" );
-                sizeLimitWrapper.setUncheckedLimit( null );
+                prTotalLimitText.setText( "" );
+                ((SizeLimitWrapper)limitWrapper).setPrTotalLimit( null );
             }
 
-            uncheckedLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
-            sizeLimitText.setText( sizeLimitWrapper.toString() );
+            prTotalLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
+            prTotalUnlimitedCheckbox.setSelection( false );
+            prTotalHardCheckbox.setSelection( false );
+            limitText.setText( limitWrapper.toString() );
             okButton.setEnabled( isValid() );
         }
     };
     
     
     /**
-     * The listener in charge of exposing the changes when the pr unlimted button is checked
+     * The listener in charge of exposing the changes when the prTotal hard button is checked
      */
-    private SelectionListener prUnlimitedCheckboxSelectionListener = new SelectionAdapter()
+    private SelectionListener prTotalHardCheckboxSelectionListener = new SelectionAdapter()
     {
         public void widgetSelected( SelectionEvent e )
         {
-            Display display = prLimitText.getDisplay();
+            Display display = prTotalLimitText.getDisplay();
             Button okButton = getButton( IDialogConstants.OK_ID );
 
-            if ( prUnlimitedCheckbox.getSelection() )
+            if ( prTotalHardCheckbox.getSelection() )
             {
-                prLimitText.setText( SizeLimitWrapper.UNLIMITED_STR );
-                sizeLimitWrapper.setPrLimit( SizeLimitWrapper.UNLIMITED );
+                String hardStr = hardLimitText.getText();
+                
+                if ( Strings.isEmpty( hardStr ) )
+                {
+                    prTotalLimitText.setText( "" );
+                }
+                else
+                {
+                    prTotalLimitText.setText( hardStr );
+                }
+
+                ((SizeLimitWrapper)limitWrapper).setPrTotalLimit( limitWrapper.getHardLimit() );
             }
             else
             {
-                prLimitText.setText( "" );
-                sizeLimitWrapper.setPrLimit( null );
+                prTotalLimitText.setText( "" );
+                ((SizeLimitWrapper)limitWrapper).setPrTotalLimit( null );
             }
 
-            prLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
-            sizeLimitText.setText( sizeLimitWrapper.toString() );
-            okButton.setEnabled( isValid() );
+            if ( isValid() )
+            {
+                okButton.setEnabled( true );
+                prTotalLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
+            }
+            else
+            {
+                okButton.setEnabled( false );
+                prTotalLimitText.setForeground( display.getSystemColor( SWT.COLOR_RED ) );
+            }
+            
+            prTotalUnlimitedCheckbox.setSelection( false );
+            prTotalHardCheckbox.setSelection( false );
+            limitText.setText( limitWrapper.toString() );
         }
     };
 
@@ -942,17 +705,6 @@ public class SizeLimitDialog extends Dia
 
 
     /**
-     * Construct the new SizeLimit from what we have in the dialog
-     * {@inheritDoc}
-     */
-    protected void okPressed()
-    {
-        setNewSizeLimit( sizeLimitWrapper.toString() );
-        super.okPressed();
-    }
-
-
-    /**
      * Create the Dialog for SizeLimit :
      * <pre>
      * +--------------------------------------------------------------------------+
@@ -1099,7 +851,7 @@ public class SizeLimitDialog extends Dia
 
         // Paged Results Limit noEstimate checkbox Button
         prNoEstimateCheckbox = BaseWidgetUtils.createCheckbox( sizeLimitGroup, "No Estimate", 2 );
-        //prNoEstimateCheckbox.addSelectionListener( prNoEstimateCheckboxSelectionListener );
+        prNoEstimateCheckbox.addSelectionListener( prNoEstimateCheckboxSelectionListener );
 
         // 2 tabs to fill the line
         BaseWidgetUtils.createLabel( sizeLimitGroup, "", 2 );
@@ -1112,15 +864,15 @@ public class SizeLimitDialog extends Dia
 
         // Paged Results Limit unlimited checkbox Button
         prTotalUnlimitedCheckbox = BaseWidgetUtils.createCheckbox( sizeLimitGroup, "Unlimited", 2 );
-        //prTotalUnlimitedCheckbox.addSelectionListener( prUnlimitedCheckboxSelectionListener );
+        prTotalUnlimitedCheckbox.addSelectionListener( prTotalUnlimitedCheckboxSelectionListener );
 
         // Paged Results Limit disabled checkbox Button
         prTotalDisabledCheckbox = BaseWidgetUtils.createCheckbox( sizeLimitGroup, "Disabled", 2 );
-        //prTotalDisabledCheckbox.addSelectionListener( prDisabledCheckboxSelectionListener );
+        prTotalDisabledCheckbox.addSelectionListener( prTotalDisabledCheckboxSelectionListener );
 
         // Paged Results Limit hard checkbox Button
         prTotalHardCheckbox = BaseWidgetUtils.createCheckbox( sizeLimitGroup, "Hard", 2 );
-        //prTotalHardCheckbox.addSelectionListener( prDisabledCheckboxSelectionListener );
+        prTotalHardCheckbox.addSelectionListener( prTotalHardCheckboxSelectionListener );
     }
 
 
@@ -1146,9 +898,9 @@ public class SizeLimitDialog extends Dia
         sizeLimitGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
 
         // SizeLimit Text
-        sizeLimitText = BaseWidgetUtils.createText( sizeLimitGroup, "", 1 );
-        sizeLimitText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
-        sizeLimitText.setEditable( false );
+        limitText = BaseWidgetUtils.createText( sizeLimitGroup, "", 1 );
+        limitText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+        limitText.setEditable( false );
     }
 
 
@@ -1157,10 +909,10 @@ public class SizeLimitDialog extends Dia
      */
     private void initFromSizeLimit()
     {
-        if ( sizeLimitWrapper != null )
+        if ( limitWrapper != null )
         {
             // The SoftLimit
-            Integer softLimit = sizeLimitWrapper.getSoftLimit();
+            Integer softLimit = limitWrapper.getSoftLimit();
             
             if ( softLimit == null )
             {
@@ -1179,7 +931,7 @@ public class SizeLimitDialog extends Dia
             }
             
             // The HardLimit
-            Integer hardLimit = sizeLimitWrapper.getHardLimit();
+            Integer hardLimit = limitWrapper.getHardLimit();
             
             if ( hardLimit == null )
             {
@@ -1207,7 +959,7 @@ public class SizeLimitDialog extends Dia
             }
             
             // The GlobalLimit
-            Integer globalLimit = sizeLimitWrapper.getGlobalLimit();
+            Integer globalLimit = limitWrapper.getGlobalLimit();
             
             if ( globalLimit == null )
             {
@@ -1225,25 +977,7 @@ public class SizeLimitDialog extends Dia
                 globalUnlimitedCheckbox.setSelection( false );
             }
             
-            sizeLimitText.setText( sizeLimitWrapper.toString() );
+            limitText.setText( limitWrapper.toString() );
         }
     }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public String getNewSizeLimit()
-    {
-        return newSizeLimitStr;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void setNewSizeLimit( String newSizeLimitStr )
-    {
-        this.newSizeLimitStr = newSizeLimitStr;
-    }
 }

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=1683298&r1=1683297&r2=1683298&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 Wed Jun  3 11:42:41 2015
@@ -20,25 +20,14 @@
 package org.apache.directory.studio.openldap.config.editor.dialogs;
 
 
-import org.apache.directory.api.util.Strings;
 import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Group;
 import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
 import org.apache.directory.studio.openldap.config.editor.wrappers.TimeLimitWrapper;
 
 
@@ -83,41 +72,8 @@ import org.apache.directory.studio.openl
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class TimeLimitDialog extends Dialog
+public class TimeLimitDialog extends AbstractLimitDialog
 {
-    // UI widgets
-    /** The SoftLimit Text */
-    private Text softLimitText;
-    
-    /** The HardLimit Text */
-    private Text hardLimitText;
-    
-    /** The GlobalLimit Text */
-    private Text globalLimitText;
-    
-    /** The unlimited checkboxes */
-    private Button softUnlimitedCheckbox;
-    private Button hardUnlimitedCheckbox;
-    private Button globalUnlimitedCheckbox;
-    
-    /** The hard limit Soft checkbox */
-    private Button hardSoftCheckbox;
-    
-    /** The resulting TimeLimit Text, or an error message */
-    private Text timeLimitText;
-    
-    /** The TimeLimitWrapper */
-    private TimeLimitWrapper timeLimitWrapper;
-    
-    /** The modified TimeLimit, as a String */
-    private String newTimeLimitStr;
-    
-    // Some constants
-    private static final String UNLIMITED_STR = "unlimited";
-    private static final String NONE_STR = "none";
-    private static final String SOFT_STR = "soft";
-
-
     /**
      * Create a new instance of the TimeLimitDialog
      * 
@@ -141,490 +97,11 @@ public class TimeLimitDialog extends Dia
         super( parentShell );
         super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
         
-        timeLimitWrapper = new TimeLimitWrapper( timeLimitStr );
-    }
-    
-    
-    /**
-     * Check if the global TimeLimit is valid : 
-     * the values must be numeric, or "unlimited" or "none" or "soft" (for the hard limit). They
-     * also have to be >=0
-     */
-    private boolean isValid()
-    {
-        return isValidSoft() && isValidHard() && isValidGlobal();
-    }
-    
-    
-    /**
-     * Check if the soft value is valid or not
-     */
-    private boolean isValidSoft()
-    {
-        String softLimitStr = softLimitText.getText();
-        
-        if ( !Strings.isEmpty( softLimitStr ) )
-        {
-            if ( !UNLIMITED_STR.equalsIgnoreCase( softLimitStr ) && !NONE_STR.equals( softLimitStr ) )
-            {
-                try
-                {
-                    if ( Integer.valueOf( softLimitStr ).intValue() < -1 )
-                    {
-                       return false;
-                    }
-                }
-                catch ( NumberFormatException nfe )
-                {
-                    return false;
-                }
-            }
-        }
-        
-        return true;
-    }
-    
-    
-    /**
-     * Check if the hard value is valid or not
-     */
-    private boolean isValidHard()
-    {
-        String hardLimitStr = hardLimitText.getText();
-        
-        if ( !Strings.isEmpty( hardLimitStr ) )
-        {
-            if ( !UNLIMITED_STR.equalsIgnoreCase( hardLimitStr ) && 
-                 !NONE_STR.equals( hardLimitStr ) && 
-                 !SOFT_STR.equalsIgnoreCase( hardLimitStr ) )
-            {
-                try
-                {
-                    if ( Integer.valueOf( hardLimitStr ).intValue() < -1 )
-                    {
-                       return false;
-                    }
-                }
-                catch ( NumberFormatException nfe )
-                {
-                    return false;
-                }
-            }
-        }
-        
-        return true;
-    }
-    
-    
-    /**
-     * Check if the global value is valid or not
-     */
-    private boolean isValidGlobal()
-    {
-        String globalLimitStr = hardLimitText.getText();
-        
-        if ( !Strings.isEmpty( globalLimitStr ) )
-        {
-            if ( !UNLIMITED_STR.equalsIgnoreCase( globalLimitStr ) && !NONE_STR.equals( globalLimitStr ) )
-            {
-                try
-                {
-                    if ( Integer.valueOf( globalLimitStr ) < -1 )
-                    {
-                       return false;
-                    }
-                }
-                catch ( NumberFormatException nfe )
-                {
-                    return false;
-                }
-            }
-        }
-        
-        return true;
+        limitWrapper = new TimeLimitWrapper( timeLimitStr );
     }
     
     
     /**
-     * The listener for the Soft Limit Text
-     */
-    private ModifyListener softLimitTextListener = new ModifyListener()
-    {
-        public void modifyText( ModifyEvent e )
-        {
-            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 )
-            {
-                return;
-            }
-
-            // The possible values are : 'unlimited' | 'none' | INT | -1
-            String softLimitStr = softLimitText.getText();
-
-            if ( Strings.isEmpty( softLimitStr ) )
-            {
-                // Check the case we don't have anything
-                timeLimitWrapper.setSoftLimit( null );
-            }
-            else if ( UNLIMITED_STR.equalsIgnoreCase( softLimitStr ) || NONE_STR.equalsIgnoreCase( softLimitStr ) ) 
-            {
-                timeLimitWrapper.setSoftLimit( TimeLimitWrapper.UNLIMITED );
-                unlimited = true;
-            }
-            else
-            {
-                // An integer
-                try
-                {
-                    int value = Integer.parseInt( softLimitStr );
-                    
-                    if ( value < TimeLimitWrapper.UNLIMITED )
-                    {
-                        // The value must be either -1 (unlimited) or a positive number
-                        color = SWT.COLOR_RED ;
-                    }
-                    else if ( value == TimeLimitWrapper.UNLIMITED )
-                    {
-                        timeLimitWrapper.setSoftLimit( TimeLimitWrapper.UNLIMITED );
-                        unlimited = true;
-                    }
-                    else
-                    {
-                        timeLimitWrapper.setSoftLimit( value );
-                    }
-                }
-                catch ( NumberFormatException nfe )
-                {
-                    // The value must be either -1 (unlimited) or a positive number
-                    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 );
-                    
-                    // Use the same color than for the soft
-                    Display displayHard = softLimitText.getDisplay();
-                    hardLimitText.setForeground( displayHard.getSystemColor( color ) );
-                }
-            }
-            
-            okButton.setEnabled( isValid() );
-        }
-    };
-    
-    
-    /**
-     * The listener for the Hard Limit Text
-     */
-    private ModifyListener hardLimitTextListener = new ModifyListener()
-    {
-        public void modifyText( ModifyEvent e )
-        {
-            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 )
-            {
-                return;
-            }
-
-            // The possible values are : 'unlimited' | 'none' | 'soft' | INT | -1
-            String hardLimitStr = hardLimitText.getText();
-
-            if ( Strings.isEmpty( hardLimitStr ) )
-            {
-                // Check the case we don't have anything
-                timeLimitWrapper.setHardLimit( null );
-            }
-            else if ( UNLIMITED_STR.equalsIgnoreCase( hardLimitStr ) || NONE_STR.equalsIgnoreCase( hardLimitStr ) ) 
-            {
-                timeLimitWrapper.setHardLimit( TimeLimitWrapper.UNLIMITED );
-                unlimited = true;
-            }
-            else if ( SOFT_STR.equalsIgnoreCase( hardLimitStr ) ) 
-            {
-                timeLimitWrapper.setHardLimit( timeLimitWrapper.getSoftLimit() );
-                unlimited = softUnlimitedCheckbox.getSelection();
-            }
-            else
-            {
-                // An integer
-                try
-                {
-                    int value = Integer.parseInt( hardLimitStr );
-                    
-                    if ( value < TimeLimitWrapper.UNLIMITED )
-                    {
-                        // The value must be either -1 (unlimited) or a positive number
-                        color = SWT.COLOR_RED;
-                    }
-                    else if ( value == TimeLimitWrapper.UNLIMITED )
-                    {
-                        timeLimitWrapper.setHardLimit( TimeLimitWrapper.UNLIMITED );
-                        unlimited = true;
-                    }
-                    else
-                    {
-                        timeLimitWrapper.setHardLimit( value );
-                    }
-                }
-                catch ( NumberFormatException nfe )
-                {
-                    // The value must be either -1 (unlimited) or a positive number
-                    color = SWT.COLOR_RED;
-                }
-            }
-
-            hardUnlimitedCheckbox.setSelection( unlimited );
-            hardLimitText.setForeground( display.getSystemColor( color ) );
-            timeLimitText.setText( timeLimitWrapper.toString() );
-            
-            if ( isValidSoft() )
-            { 
-                okButton.setEnabled( true );
-            }
-            else
-            {
-                okButton.setEnabled( isValid() );
-            }
-        }
-    };
-    
-    
-    /**
-     * The listener for the Global Limit Text
-     */
-    private ModifyListener globalLimitTextListener = new ModifyListener()
-    {
-        public void modifyText( ModifyEvent e )
-        {
-            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 )
-            {
-                return;
-            }
-
-            // The possible values are : 'unlimited' | 'none' | INT | -1
-            String globalLimitStr = globalLimitText.getText();
-            
-            if ( Strings.isEmpty( globalLimitStr ) )
-            {
-                // Check the case we don't have anything
-                timeLimitWrapper.setGlobalLimit( null );
-            }
-            else if ( UNLIMITED_STR.equalsIgnoreCase( globalLimitStr ) || NONE_STR.equalsIgnoreCase( globalLimitStr ) ) 
-            {
-                timeLimitWrapper.setGlobalLimit( TimeLimitWrapper.UNLIMITED );
-                unlimited = true;
-            }
-            else
-            {
-                // An integer
-                try
-                {
-                    int value = Integer.parseInt( globalLimitStr );
-                    
-                    if ( value < TimeLimitWrapper.UNLIMITED )
-                    {
-                        // The value must be either -1 (unlimited) or a positive number
-                        color = SWT.COLOR_RED;
-                    }
-                    else if ( value == TimeLimitWrapper.UNLIMITED )
-                    {
-                        timeLimitWrapper.setGlobalLimit( TimeLimitWrapper.UNLIMITED );
-                        unlimited = true;
-                    }
-                    else
-                    {
-                        timeLimitWrapper.setGlobalLimit( value );
-                    }
-                }
-                catch ( NumberFormatException nfe )
-                {
-                    // The value must be either -1 (unlimited) or a positive number
-                    color = SWT.COLOR_RED;
-                }
-            }
-
-            timeLimitText.setText( timeLimitWrapper.toString() );
-            globalLimitText.setForeground( display.getSystemColor( color ) );
-            globalUnlimitedCheckbox.setSelection( unlimited );
-            okButton.setEnabled( isValid() );
-        }
-    };
-    
-    
-    /**
-     * The listener in charge of exposing the changes when the soft unlimited button is checked
-     */
-    private SelectionListener softUnlimitedCheckboxSelectionListener = new SelectionAdapter()
-    {
-        public void widgetSelected( SelectionEvent e )
-        {
-            Display display = softLimitText.getDisplay();
-            Button okButton = getButton( IDialogConstants.OK_ID );
-
-            if ( softUnlimitedCheckbox.getSelection() )
-            {
-                softLimitText.setText( UNLIMITED_STR );
-                timeLimitWrapper.setSoftLimit( TimeLimitWrapper.UNLIMITED );
-            }
-            else
-            {
-                softLimitText.setText( "" );
-                timeLimitWrapper.setSoftLimit( null );
-            }
-
-            if ( isValidSoft() )
-            {
-                softLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
-            }
-            else
-            {
-                softLimitText.setForeground( display.getSystemColor( SWT.COLOR_RED ) );
-            }
-            
-            timeLimitText.setText( timeLimitWrapper.toString() );
-            okButton.setEnabled( isValid() );
-        }
-    };
-    
-    
-    /**
-     * The listener in charge of exposing the changes when the hard unlimited button is checked
-     */
-    private SelectionListener hardUnlimitedCheckboxSelectionListener = new SelectionAdapter()
-    {
-        public void widgetSelected( SelectionEvent e )
-        {
-            Display display = hardLimitText.getDisplay();
-            Button okButton = getButton( IDialogConstants.OK_ID );
-
-            if ( hardUnlimitedCheckbox.getSelection() )
-            {
-                hardLimitText.setText( UNLIMITED_STR );
-                timeLimitWrapper.setHardLimit( TimeLimitWrapper.UNLIMITED );
-                hardSoftCheckbox.setSelection( false );
-                hardLimitText.setEnabled( true );
-            }
-            else
-            {
-                hardLimitText.setText( "" );
-                timeLimitWrapper.setHardLimit( null );
-            }
-
-            hardLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
-            timeLimitText.setText( timeLimitWrapper.toString() );
-            okButton.setEnabled( isValid() );
-        }
-    };
-    
-    
-    /**
-     * The listener in charge of exposing the changes when the hard unlimited button is checked.
-     * We will disable the hardLimitText.
-     */
-    private SelectionListener hardSoftCheckboxSelectionListener = new SelectionAdapter()
-    {
-        public void widgetSelected( SelectionEvent e )
-        {
-            Display display = hardLimitText.getDisplay();
-            Button okButton = getButton( IDialogConstants.OK_ID );
-
-            if ( hardSoftCheckbox.getSelection() )
-            {
-                hardLimitText.setEnabled( false );
-                String softStr = softLimitText.getText();
-                
-                if ( softStr != null )
-                {
-                    hardLimitText.setText( softStr );
-                }
-                else
-                {
-                    hardLimitText.setText( "" );
-                }
-                
-                timeLimitWrapper.setHardLimit( timeLimitWrapper.getSoftLimit() );
-                hardUnlimitedCheckbox.setSelection( TimeLimitWrapper.UNLIMITED.equals( timeLimitWrapper.getSoftLimit() ) );
-
-                if ( isValidSoft() )
-                { 
-                    hardLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
-                }
-                else
-                {
-                    hardLimitText.setForeground( display.getSystemColor( SWT.COLOR_RED ) );
-                }
-            }
-            else
-            {
-                hardLimitText.setText( "" );
-                hardLimitText.setEnabled( true );
-                timeLimitWrapper.setHardLimit( null );
-            }
-
-            timeLimitText.setText( timeLimitWrapper.toString() );
-            okButton.setEnabled( isValid() );
-        }
-    };
-    
-    
-    /**
-     * The listener in charge of exposing the changes when the global unlimited button is checked
-     */
-    private SelectionListener globalUnlimitedCheckboxSelectionListener = new SelectionAdapter()
-    {
-        public void widgetSelected( SelectionEvent e )
-        {
-            Display display = globalLimitText.getDisplay();
-            Button okButton = getButton( IDialogConstants.OK_ID );
-
-            if ( globalUnlimitedCheckbox.getSelection() )
-            {
-                globalLimitText.setText( UNLIMITED_STR );
-                timeLimitWrapper.setGlobalLimit( TimeLimitWrapper.UNLIMITED );
-            }
-            else
-            {
-                globalLimitText.setText( "" );
-                timeLimitWrapper.setGlobalLimit( null );
-            }
-
-            globalLimitText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
-            timeLimitText.setText( timeLimitWrapper.toString() );
-            okButton.setEnabled( isValid() );
-        }
-    };
-
-    
-    /**
      * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
      */
     protected void configureShell( Shell shell )
@@ -635,17 +112,6 @@ public class TimeLimitDialog extends Dia
 
 
     /**
-     * Construct the new TimeLimit from what we have in the dialog
-     * {@inheritDoc}
-     */
-    protected void okPressed()
-    {
-        setNewTimeLimit( timeLimitWrapper.toString() );
-        super.okPressed();
-    }
-
-
-    /**
      * Create the Dialog for TimeLimit :
      * <pre>
      * +-------------------------------------------------------+
@@ -769,9 +235,9 @@ public class TimeLimitDialog extends Dia
         timeLimitGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
 
         // TimeLimit Text
-        timeLimitText = BaseWidgetUtils.createText( timeLimitGroup, "", 1 );
-        timeLimitText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
-        timeLimitText.setEditable( false );
+        limitText = BaseWidgetUtils.createText( timeLimitGroup, "", 1 );
+        limitText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+        limitText.setEditable( false );
     }
 
 
@@ -780,10 +246,10 @@ public class TimeLimitDialog extends Dia
      */
     private void initFromTimeLimit()
     {
-        if ( timeLimitWrapper != null )
+        if ( limitWrapper != null )
         {
             // The SoftLimit
-            Integer softLimit = timeLimitWrapper.getSoftLimit();
+            Integer softLimit = limitWrapper.getSoftLimit();
             
             if ( softLimit == null )
             {
@@ -792,7 +258,7 @@ public class TimeLimitDialog extends Dia
             }
             else if ( softLimit.equals( TimeLimitWrapper.UNLIMITED ) )
             {
-                softLimitText.setText( UNLIMITED_STR );
+                softLimitText.setText( TimeLimitWrapper.UNLIMITED_STR );
                 softUnlimitedCheckbox.setSelection( true );
             }
             else
@@ -802,7 +268,7 @@ public class TimeLimitDialog extends Dia
             }
             
             // The HardLimit
-            Integer hardLimit = timeLimitWrapper.getHardLimit();
+            Integer hardLimit = limitWrapper.getHardLimit();
             
             if ( hardLimit == null )
             {
@@ -812,13 +278,13 @@ public class TimeLimitDialog extends Dia
             }
             else if ( hardLimit.equals( TimeLimitWrapper.UNLIMITED ) )
             {
-                hardLimitText.setText( UNLIMITED_STR );
+                hardLimitText.setText( TimeLimitWrapper.UNLIMITED_STR );
                 hardUnlimitedCheckbox.setSelection( true );
                 hardSoftCheckbox.setSelection( false );
             }
             else if ( hardLimit.equals( TimeLimitWrapper.HARD_SOFT ) )
             {
-                hardLimitText.setText( SOFT_STR );
+                hardLimitText.setText( TimeLimitWrapper.SOFT_STR );
                 hardUnlimitedCheckbox.setSelection( false );
                 hardSoftCheckbox.setSelection( true );
             }
@@ -830,7 +296,7 @@ public class TimeLimitDialog extends Dia
             }
             
             // The GlobalLimit
-            Integer globalLimit = timeLimitWrapper.getGlobalLimit();
+            Integer globalLimit = limitWrapper.getGlobalLimit();
             
             if ( globalLimit == null )
             {
@@ -839,7 +305,7 @@ public class TimeLimitDialog extends Dia
             }
             else if ( globalLimit.equals( TimeLimitWrapper.UNLIMITED ) )
             {
-                globalLimitText.setText( UNLIMITED_STR );
+                globalLimitText.setText( TimeLimitWrapper.UNLIMITED_STR );
                 globalUnlimitedCheckbox.setSelection( true );
             }
             else
@@ -848,25 +314,7 @@ public class TimeLimitDialog extends Dia
                 globalUnlimitedCheckbox.setSelection( false );
             }
             
-            timeLimitText.setText( timeLimitWrapper.toString() );
+            limitText.setText( limitWrapper.toString() );
         }
     }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public String getNewTimeLimit()
-    {
-        return newTimeLimitStr;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void setNewTimeLimit( String newTimeLimitStr )
-    {
-        this.newTimeLimitStr = newTimeLimitStr;
-    }
 }



Mime
View raw message