directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1691651 - in /directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor: dialogs/ wrappers/
Date Fri, 17 Jul 2015 22:00:11 GMT
Author: elecharny
Date: Fri Jul 17 22:00:10 2015
New Revision: 1691651

URL: http://svn.apache.org/r1691651
Log:
o Added the SizeTimeLimit dialog to manage the olcLimits content
o Added the OrderedSizeLimitWrapper
o Modified the SizeLimitWrapper to be able to extend it
o Removed a useless import
o Change the way we parse the Limits, as it's ordered : we get rid of the prefix.
o Used OrderedSize/TimeLimit in the LimitsWrapper class


Added:
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/SizeTimeLimitDialog.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/OrderedSizeLimitWrapper.java
Modified:
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/LimitDecorator.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/LimitsWrapper.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/OrderedTimeLimitWrapper.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SizeLimitWrapper.java

Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/SizeTimeLimitDialog.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/SizeTimeLimitDialog.java?rev=1691651&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/SizeTimeLimitDialog.java
(added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/SizeTimeLimitDialog.java
Fri Jul 17 22:00:10 2015
@@ -0,0 +1,441 @@
+/*
+ *  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.studio.common.ui.AddEditDialog;
+import org.apache.directory.studio.common.ui.CommonUIConstants;
+import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
+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.Group;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.apache.directory.studio.openldap.config.editor.wrappers.LimitWrapper;
+import org.apache.directory.studio.openldap.config.editor.wrappers.OrderedSizeLimitWrapper;
+import org.apache.directory.studio.openldap.config.editor.wrappers.OrderedTimeLimitWrapper;
+
+
+/**
+ * The LimitDialog is used to edit the size and time limit parameter<br/>
+ * 
+ * The dialog overlay is like :
+ * 
+ * <pre>
+ * +--------------------------------------------------------------------------+
+ * | Limit                                                                    |
+ * | .----------------------------------------------------------------------. |
+ * | | (o) Size Limit  : [                                      ] (Edit...) | |
+ * | | (o) TimeLimit :   [                                      ] (Edit...) | |
+ * | '----------------------------------------------------------------------' |
+ * |                                                                          |
+ * |  (Cancel)                                                         (OK)   |
+ * +--------------------------------------------------------------------------+
+ * </pre>
+ * 
+ * A second option for the Dialog would be like :
+ * 
+ * +--------------------------------------------------------------------------+
+ * | Limit                                                                    |
+ * | .----------------------------------------------------------------------. |
+ * | |   (o) Size Limit                  (o) TimeLimit                      | |
+ * | '----------------------------------------------------------------------' |
+ * ............................................................................
+ * 
+ * SizeLimit :
+ * ............................................................................
+ * | .----------------------------------------------------------------------. |
+ * | | Soft Limit :          [----------]  [] Unlimited                     | |
+ * | |                                                                      | |
+ * | | Hard Limit :          [----------]  [] Unlimited [] Soft             | |
+ * | |                                                                      | |
+ * | | Global Limit :        [----------]  [] Unlimited                     | |
+ * | |                                                                      | |
+ * | | Unchecked Limit :     [----------]  [] Unlimited [] Disabled         | |
+ * | |                                                                      | |
+ * | | Paged Results Limit : [----------]  [] Unlimited [] No Estimate      | |
+ * | |                                                                      | |
+ * | | Paged Results Total : [----------]  [] Unlimited [] Disabled [] Hard | |
+ * | '----------------------------------------------------------------------' |
+ * ............................................................................
+ * TimeLimit :
+ * ............................................................................
+ * | .----------------------------------------------------------------------. |
+ * | | Soft Limit :  [----------]  [] Unlimited                             | |
+ * | |                                                                      | |
+ * | | Hard Limit :  [----------]  [] Unlimited  [] Soft                    | |
+ * | |                                                                      | |
+ * | | Global :      [----------]  [] Unlimited                             | |
+ * | '----------------------------------------------------------------------' |
+ * ............................................................................
+ * End :
+ * ............................................................................
+ * | Resulting Limit                                                          |
+ * | .----------------------------------------------------------------------. |
+ * | | <//////////////////////////////////////////////////////////////////> | |
+ * | '----------------------------------------------------------------------' |
+ * |                                                                          |
+ * |  (Cancel)                                                         (OK)   |
+ * +--------------------------------------------------------------------------+
+ * </pre>
+ * 
+ * But this would mean a duplication of code.
+ *  
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SizeTimeLimitDialog extends AddEditDialog<LimitWrapper>
+{
+    /** The TimeLimit radio button */
+    private Button timeLimitButton;
+    
+    /** The Text that contains the TimeLimit (either as typed or as built from the TimeLimitDialog)
*/
+    private Text timeLimitText;
+    
+    /** A Button used to edit the TimeLimit value */
+    private Button timeLimitEditButton;
+    
+    /** The SizeLimit radio button */
+    private Button sizeLimitButton;
+    
+    /** The Text that contains the SizeLimit (either as typed or as built from the SizeLimitDialog)
*/
+    private Text sizeLimitText;
+    
+    /** A Button used to edit the SizeLimit value */
+    private Button sizeLimitEditButton;
+    
+    /**
+     * Listeners for the Selector radioButtons. It will enable or disable the dnSpec or Group
accordingly
+     * to the selection.
+     **/ 
+    private SelectionListener sizeTimeButtonsSelectionListener = new SelectionAdapter()
+    {
+        public void widgetSelected( SelectionEvent event )
+        {
+            if ( event.getSource() instanceof Button )
+            {
+                Button button = (Button)event.getSource();
+                
+                if ( button == sizeLimitButton )
+                {
+                    if ( button.getSelection() )
+                    {
+                        setEditedElement( new OrderedSizeLimitWrapper( "" ) );
+
+                        // Enable the SizeLimit elements, disable the TimeLimit ones
+                        sizeLimitEditButton.setEnabled( true );
+                        sizeLimitText.setEnabled( true );
+                        timeLimitEditButton.setEnabled( false );
+                        timeLimitText.setEnabled( false );
+                        timeLimitText.clearSelection();
+                    }
+                }
+                else
+                {
+                    setEditedElement( new OrderedTimeLimitWrapper( "" ) );
+                    
+                    // Enable the TimeLimit elements, disable the SizeLimit ones
+                    timeLimitEditButton.setEnabled( true );
+                    timeLimitText.setEnabled( true );
+                    sizeLimitEditButton.setEnabled( false );
+                    sizeLimitText.setEnabled( false );
+                    sizeLimitText.clearSelection();
+                }
+            }
+        }
+    };
+    
+    
+    /**
+     * The listener for the sizeLimit Text
+     */
+    private SelectionListener sizeLimitEditSelectionListener = new SelectionAdapter()
+    {
+        public void widgetSelected( SelectionEvent e )
+        {
+            SizeLimitDialog dialog = new SizeLimitDialog( sizeLimitText.getShell(), sizeLimitText.getText()
);
+
+            if ( dialog.open() == OverlayDialog.OK )
+            {
+                String newSizeLimitStr = dialog.getNewLimit();
+                
+                if ( newSizeLimitStr != null )
+                {
+                    sizeLimitText.setText( newSizeLimitStr );
+                }
+            }
+        }
+    };
+    
+    
+    /**
+     * The listener for the timeLimit Text
+     */
+    private SelectionListener timeLimitEditSelectionListener = new SelectionAdapter()
+    {
+        public void widgetSelected( SelectionEvent e )
+        {
+            TimeLimitDialog dialog = new TimeLimitDialog( timeLimitText.getShell(), timeLimitText.getText()
);
+
+            if ( dialog.open() == OverlayDialog.OK )
+            {
+                String newTimeLimitStr = dialog.getNewLimit();
+                
+                if ( newTimeLimitStr != null )
+                {
+                    timeLimitText.setText( newTimeLimitStr );
+                }
+            }
+        }
+    };
+
+    
+    protected ModifyListener sizeLimitTextListener = new ModifyListener()
+    {
+        public void modifyText( ModifyEvent e )
+        {
+            Button okButton = getButton( IDialogConstants.OK_ID );
+
+            // This button might be null when the dialog is called.
+            if ( okButton == null )
+            {
+                return;
+            }
+
+            // The String must be a valid SizeLimit
+            String sizeLimitStr = sizeLimitText.getText();
+            
+            OrderedSizeLimitWrapper sizeLimitWrapper = new OrderedSizeLimitWrapper( sizeLimitStr
);
+            
+            if ( sizeLimitWrapper.isValid() )
+            {
+                sizeLimitText.setForeground( CommonUIConstants.BLACK_COLOR );
+                setEditedElement( sizeLimitWrapper );
+                okButton.setEnabled( true );
+            }
+            else
+            {
+                sizeLimitText.setForeground( CommonUIConstants.RED_COLOR );
+                okButton.setEnabled( false );
+            }
+        }
+    };
+
+    
+    protected ModifyListener timeLimitTextListener = new ModifyListener()
+    {
+        public void modifyText( ModifyEvent e )
+        {
+            Button okButton = getButton( IDialogConstants.OK_ID );
+
+            // This button might be null when the dialog is called.
+            if ( okButton == null )
+            {
+                return;
+            }
+
+            // The String must be a valid TimeLimit
+            String timeLimitStr = timeLimitText.getText();
+            
+            OrderedTimeLimitWrapper timeLimitWrapper = new OrderedTimeLimitWrapper( timeLimitStr
);
+            
+            if ( timeLimitWrapper.isValid() )
+            {
+                timeLimitText.setForeground( CommonUIConstants.BLACK_COLOR );
+                setEditedElement( timeLimitWrapper );
+                okButton.setEnabled( true );
+            }
+            else
+            {
+                timeLimitText.setForeground( CommonUIConstants.RED_COLOR );
+                okButton.setEnabled( false );
+            }
+        }
+    };
+    
+    /**
+     * Create a new instance of the SizeTimeLimitsDialog
+     * 
+     * @param parentShell The parent Shell
+     */
+    public SizeTimeLimitDialog( Shell parentShell )
+    {
+        super( parentShell );
+        super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+    }
+
+
+    /**
+     * Create a new instance of the SizeTimeLimitDialog
+     * 
+     * @param parentShell The parent Shell
+     * @param timeLimitStr The instance containing the Limits data
+     */
+    public SizeTimeLimitDialog( Shell parentShell, String limitStr )
+    {
+        super( parentShell );
+        super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+    }
+    
+    
+    /**
+     * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+     */
+    protected void configureShell( Shell shell )
+    {
+        super.configureShell( shell );
+        shell.setText( "Size/Time Limit" );
+    }
+    
+    
+    /**
+     * Create the Dialog for TimeLimit :
+     * <pre>
+     * Limit
+     * .----------------------------------------------------------------------.
+     * | (o) Size Limit  : [                                      ] (Edit...) |
+     * | (o) TimeLimit :   [                                      ] (Edit...) |
+     * '----------------------------------------------------------------------'
+     * </pre>
+     * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+     */
+    protected Control createDialogArea( Composite parent )
+    {
+        Composite composite = ( Composite ) super.createDialogArea( parent );
+        GridData gd = new GridData( GridData.FILL_BOTH );
+        composite.setLayoutData( gd );
+        
+        // Create the selection group
+        Group selectionGroup = BaseWidgetUtils.createGroup( parent, "Limit selection", 1
);
+        GridLayout selectionGridLayout = new GridLayout( 3, false );
+        selectionGroup.setLayout( selectionGridLayout );
+        selectionGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // SizeLimit button
+        sizeLimitButton = BaseWidgetUtils.createRadiobutton( selectionGroup, "SizeLimit",
1 );
+        sizeLimitButton.addSelectionListener( sizeTimeButtonsSelectionListener );
+        
+        // SizeLimit Text
+        sizeLimitText = BaseWidgetUtils.createText( selectionGroup, "", 1 );
+        sizeLimitText.addModifyListener( sizeLimitTextListener );
+
+        // SizeLimit Edit button
+        sizeLimitEditButton = BaseWidgetUtils.createButton( selectionGroup, "Edit...", 1
);
+        sizeLimitEditButton.addSelectionListener( sizeLimitEditSelectionListener );
+
+        // TimeLimit button
+        timeLimitButton = BaseWidgetUtils.createRadiobutton( selectionGroup, "TimeLimit",
1 );
+        timeLimitButton.addSelectionListener( sizeTimeButtonsSelectionListener );
+
+        // TimeLimit Text
+        timeLimitText = BaseWidgetUtils.createText( selectionGroup, "", 1 );
+        timeLimitText.addModifyListener( timeLimitTextListener );
+
+        // TimeLimit Edit button
+        timeLimitEditButton = BaseWidgetUtils.createButton( selectionGroup, "Edit...", 1
);
+        timeLimitEditButton.addSelectionListener( timeLimitEditSelectionListener );
+
+        // create the SizeLimit
+        initDialog();
+        addListeners();
+        
+        applyDialogFont( composite );
+
+        return composite;
+    }
+
+
+    /**
+     * Adds listeners.
+     */
+    private void addListeners()
+    {
+        /*
+        softLimitText.addModifyListener( softLimitTextListener );
+        softUnlimitedCheckbox.addSelectionListener( softUnlimitedCheckboxSelectionListener
);
+        hardLimitText.addModifyListener( hardLimitTextListener );
+        hardUnlimitedCheckbox.addSelectionListener( hardUnlimitedCheckboxSelectionListener
);
+        hardSoftCheckbox.addSelectionListener( hardSoftCheckboxSelectionListener );
+        globalLimitText.addModifyListener( globalLimitTextListener );
+        globalUnlimitedCheckbox.addSelectionListener( globalUnlimitedCheckboxSelectionListener
);
+        */
+    }
+
+
+    @Override
+    public void addNewElement()
+    {
+        setEditedElement( null );
+    }
+
+
+    /**
+     * Initializes the UI from the Limit
+     */
+    protected void initDialog()
+    {
+        LimitWrapper editedElement = (LimitWrapper)getEditedElement();
+        
+        if ( editedElement != null )
+        {
+            if ( editedElement instanceof OrderedSizeLimitWrapper )
+            {
+                sizeLimitButton.setSelection( true );
+                
+                // Enable the SizeLimit elements, disable the TimeLimit ones
+                sizeLimitEditButton.setEnabled( true );
+                sizeLimitText.setEnabled( true );
+                sizeLimitText.setText( editedElement.toString() );
+                timeLimitEditButton.setEnabled( false );
+                timeLimitText.setEnabled( false );
+            }
+            else
+            {
+                timeLimitButton.setSelection( true );
+                
+                // Enable the TimeLimit elements, disable the SizeLimit ones
+                timeLimitEditButton.setEnabled( true );
+                timeLimitText.setEnabled( true );
+                timeLimitText.setText( editedElement.toString() );
+                sizeLimitEditButton.setEnabled( false );
+                sizeLimitText.setEnabled( false );
+            }
+        }
+        else
+        {
+            // Nothing selected, disable the Text and Button
+            timeLimitEditButton.setEnabled( false );
+            timeLimitText.setEnabled( false );
+            timeLimitText.clearSelection();
+            sizeLimitEditButton.setEnabled( false );
+            sizeLimitText.setEnabled( false );
+            sizeLimitText.clearSelection();
+        }
+    }
+}

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/LimitDecorator.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/LimitDecorator.java?rev=1691651&r1=1691650&r2=1691651&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/LimitDecorator.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/LimitDecorator.java
Fri Jul 17 22:00:10 2015
@@ -20,16 +20,29 @@
 package org.apache.directory.studio.openldap.config.editor.wrappers;
 
 import org.apache.directory.studio.common.ui.TableDecorator;
+import org.apache.directory.studio.openldap.config.editor.dialogs.LimitsDialog;
+import org.apache.directory.studio.openldap.config.editor.dialogs.SizeTimeLimitDialog;
 import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Shell;
 
 /**
  * A decorator for the TimeLimitWrapper class.
  *  
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public abstract class LimitDecorator<E> extends TableDecorator<E>
+public class LimitDecorator extends TableDecorator<LimitWrapper>
 {
     /**
+     * Create a new instance of LimitDecorator
+     * @param parentShell The parent Shell
+     */
+    public LimitDecorator( Shell parentShell, String title )
+    {
+        setDialog( new SizeTimeLimitDialog( parentShell ) );
+    }
+    
+    
+    /**
      * Construct the label for a TimeLimit. It can be one of :
      * 
      */
@@ -52,5 +65,13 @@ public abstract class LimitDecorator<E>
     public Image getImage( Object element )
     {
         return null;
+    }
+
+
+    @Override
+    public int compare( LimitWrapper e1, LimitWrapper e2 )
+    {
+        // TODO Auto-generated method stub
+        return 0;
     };
 }

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/LimitsWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/LimitsWrapper.java?rev=1691651&r1=1691650&r2=1691651&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/LimitsWrapper.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/LimitsWrapper.java
Fri Jul 17 22:00:10 2015
@@ -106,46 +106,78 @@ public class LimitsWrapper implements Cl
             String lowerCaseLimits = limitsStr.toLowerCase();
             int pos = 0;
             
-            // Process the selector
-            if ( lowerCaseLimits.startsWith( LimitSelectorEnum.ANY.getName() ) )
+            // It's ordered : process the prefix
+            if ( Strings.isCharASCII( lowerCaseLimits, pos, '{' ) )
             {
-                selector = LimitSelectorEnum.ANY;
-                pos += LimitSelectorEnum.ANY.getName().length();
-            }
-            if ( lowerCaseLimits.startsWith( LimitSelectorEnum.ANONYMOUS.getName() ) )
-            {
-                selector = LimitSelectorEnum.ANONYMOUS;
-                pos += LimitSelectorEnum.ANONYMOUS.getName().length();
-            }
-            else if ( lowerCaseLimits.startsWith( LimitSelectorEnum.USERS.getName() ) )
-            {
-                selector = LimitSelectorEnum.USERS;
-                pos += LimitSelectorEnum.USERS.getName().length();
-            }
-            else if ( lowerCaseLimits.startsWith( LimitSelectorEnum.DNSPEC.getName() ) )
-            {
-                selector = LimitSelectorEnum.DNSPEC;
-                pos += LimitSelectorEnum.DNSPEC.getName().length();
+                pos++;
+                prefix = 0;
                 
-                // parse the type
-                pos = parseDnSpec( lowerCaseLimits, pos );
-                
-                if ( pos == ERROR )
+                while ( pos < lowerCaseLimits.length() )
                 {
-                    isValid = false;
+                    char c = lowerCaseLimits.charAt( pos );
+                    
+                    if ( ( c >= '0' ) && ( c <= '9' ) )
+                    {
+                        prefix = prefix * 10 + ( c - '0' );
+                        pos++;
+                    }
+                    else if ( c == '}' )
+                    {
+                        pos++;
+                        break;
+                    }
+                    else
+                    {
+                        isValid = false;
+                        break;
+                    }
                 }
             }
-            else if ( lowerCaseLimits.startsWith( LimitSelectorEnum.GROUP.getName() ) )
+            
+            if ( isValid )
             {
-                selector = LimitSelectorEnum.GROUP;
-                pos += LimitSelectorEnum.GROUP.getName().length();
-                
-                pos = parseGroup( lowerCaseLimits, pos );
-                
-                if ( pos == ERROR )
+                lowerCaseLimits = lowerCaseLimits.substring( pos );
+                // Process the selector
+                if ( lowerCaseLimits.startsWith( LimitSelectorEnum.ANY.getName() ) )
+                {
+                    selector = LimitSelectorEnum.ANY;
+                    pos += LimitSelectorEnum.ANY.getName().length();
+                }
+                if ( lowerCaseLimits.startsWith( LimitSelectorEnum.ANONYMOUS.getName() )
)
                 {
-                    // This is an error
-                    isValid = false;
+                    selector = LimitSelectorEnum.ANONYMOUS;
+                    pos += LimitSelectorEnum.ANONYMOUS.getName().length();
+                }
+                else if ( lowerCaseLimits.startsWith( LimitSelectorEnum.USERS.getName() )
)
+                {
+                    selector = LimitSelectorEnum.USERS;
+                    pos += LimitSelectorEnum.USERS.getName().length();
+                }
+                else if ( lowerCaseLimits.startsWith( LimitSelectorEnum.DNSPEC.getName()
) )
+                {
+                    selector = LimitSelectorEnum.DNSPEC;
+                    pos += LimitSelectorEnum.DNSPEC.getName().length();
+                    
+                    // parse the type
+                    pos = parseDnSpec( lowerCaseLimits, pos );
+                    
+                    if ( pos == ERROR )
+                    {
+                        isValid = false;
+                    }
+                }
+                else if ( lowerCaseLimits.startsWith( LimitSelectorEnum.GROUP.getName() )
)
+                {
+                    selector = LimitSelectorEnum.GROUP;
+                    pos += LimitSelectorEnum.GROUP.getName().length();
+                    
+                    pos = parseGroup( lowerCaseLimits, pos );
+                    
+                    if ( pos == ERROR )
+                    {
+                        // This is an error
+                        isValid = false;
+                    }
                 }
             }
             
@@ -423,7 +455,7 @@ public class LimitsWrapper implements Cl
                 return ERROR;
             }
             
-            TimeLimitWrapper timeLimitWrapper = new TimeLimitWrapper( limitStr.substring(
0, i ) );
+            OrderedTimeLimitWrapper timeLimitWrapper = new OrderedTimeLimitWrapper( limitStr.substring(
0, i ) );
             
             if ( timeLimitWrapper.isValid() )
             {
@@ -451,7 +483,7 @@ public class LimitsWrapper implements Cl
                 return ERROR;
             }
             
-            SizeLimitWrapper sizeLimitWrapper = new SizeLimitWrapper( limitStr.substring(
0, i ) );
+            OrderedSizeLimitWrapper sizeLimitWrapper = new OrderedSizeLimitWrapper( limitStr.substring(
0, i ) );
             
             if ( sizeLimitWrapper.isValid() )
             {

Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/OrderedSizeLimitWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/OrderedSizeLimitWrapper.java?rev=1691651&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/OrderedSizeLimitWrapper.java
(added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/OrderedSizeLimitWrapper.java
Fri Jul 17 22:00:10 2015
@@ -0,0 +1,177 @@
+/*
+ *  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.wrappers;
+
+import org.apache.directory.studio.common.ui.widgets.OrderedElement;
+
+/**
+ * This class wraps the SizeLimit parameter :
+ * <pre>
+ * size      ::= 'size' sizeLimit size-e
+ * size-e    ::= ' size' sizeLimit size-e | e
+ * sizeLimit ::= '.soft=' limit | '.hard=' hardLimit | '.pr=' prLimit | '.prtotal=' prTLimit
+ *                  | '.unchecked=' uLimit | '=' limit
+ * limit     ::= 'unlimited' | 'none' | INT
+ * hardLimit ::= 'soft' | limit
+ * ulimit    ::= 'disabled' | limit
+ * prLimit   ::= 'noEstimate' | limit
+ * prTLimit  ::= ulimit | 'hard'
+ * </pre>
+ * 
+ * Note : each of the limit is an Integer, so that we can have two states :
+ * <ul>
+ * <li>not existent</li>
+ * <li>has a value</li>
+ * </ul>
+ * A -1 value means unlimited. Any other value is accepted, if > 0.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class OrderedSizeLimitWrapper extends SizeLimitWrapper implements OrderedElement
+{
+    /** The prefix, used to order the values */
+    private int prefix;
+
+
+    /**
+     * Create a SizeLimitWrapper instance from a String. 
+     * 
+     * @param sizeLimitStr The String that contain the value
+     */
+    public OrderedSizeLimitWrapper( String sizeLimitStr )
+    {
+        super( sizeLimitStr );
+    }
+
+
+    /**
+     * Sets a new prefix
+     * 
+     * @param prefix the prefix to set
+     */
+    public void setPrefix( int prefix )
+    {
+        this.prefix = prefix;
+    }
+
+    
+    /**
+     * @return the prefix
+     */
+    public int getPrefix()
+    {
+        return prefix;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void decrementPrefix()
+    {
+        prefix--;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void incrementPrefix()
+    {
+        prefix++;
+    }
+    
+    
+    /**
+     * @see Comparable#compareTo()
+     */
+    public int compareTo( OrderedSizeLimitWrapper that )
+    {
+        if ( that == null )
+        {
+            return 1;
+        }
+        
+        // Check the prefix
+        if ( prefix < that.prefix )
+        {
+            return -1;
+        }
+        else if ( prefix > that.prefix )
+        {
+            return 1;
+        }
+        
+        return super.compareTo( that );
+    }
+
+    
+    /**
+     * @see Object#hashCode()
+     */
+    public int hashCode()
+    {
+        int h = 37;
+        
+        h += h*17 + prefix;
+        
+        h += h*17 + super.hashCode();
+        
+        return h;
+    }
+
+    
+    /**
+     * @see Object#equals(Object)
+     */
+    public boolean equals( Object that )
+    {
+        // Quick test
+        if ( this == that )
+        {
+            return true;
+        }
+        
+        if ( that instanceof OrderedSizeLimitWrapper )
+        {
+            OrderedSizeLimitWrapper thatInstance = (OrderedSizeLimitWrapper)that;
+            
+            if ( prefix != thatInstance.prefix )
+            {
+                return false;
+            }
+
+            return super.equals( that );
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return '{' + Integer.toString( prefix ) + '}' + super.toString();
+    }
+}

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/OrderedTimeLimitWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/OrderedTimeLimitWrapper.java?rev=1691651&r1=1691650&r2=1691651&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/OrderedTimeLimitWrapper.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/OrderedTimeLimitWrapper.java
Fri Jul 17 22:00:10 2015
@@ -19,7 +19,6 @@
  */
 package org.apache.directory.studio.openldap.config.editor.wrappers;
 
-import org.apache.directory.api.util.Strings;
 import org.apache.directory.studio.common.ui.widgets.OrderedElement;
 
 /**

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SizeLimitWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SizeLimitWrapper.java?rev=1691651&r1=1691650&r2=1691651&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SizeLimitWrapper.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SizeLimitWrapper.java
Fri Jul 17 22:00:10 2015
@@ -70,7 +70,7 @@ public class SizeLimitWrapper extends Ab
     /**
      * Create a SizeLimitWrapper instance
      */
-    private SizeLimitWrapper()
+    protected SizeLimitWrapper()
     {
         super();
     }



Mime
View raw message