directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r490478 - in /directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor: dialogs/ widgets/
Date Wed, 27 Dec 2006 10:37:12 GMT
Author: seelmann
Date: Wed Dec 27 02:37:11 2006
New Revision: 490478

URL: http://svn.apache.org/viewvc?view=rev&rev=490478
Log:
Added ItemFirst support, switched style of UserClasses widget

Added:
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/dialogs/ItemPermissionDialog.java
Removed:
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/dialogs/UserClassDialog.java
Modified:
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/dialogs/UserPermissionDialog.java
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemComposite.java
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemItemPermissionsComposite.java
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemProtectedItemsComposite.java
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemUserClassesComposite.java
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemUserPermissionsComposite.java

Added: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/dialogs/ItemPermissionDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/dialogs/ItemPermissionDialog.java?view=auto&rev=490478
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/dialogs/ItemPermissionDialog.java (added)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/dialogs/ItemPermissionDialog.java Wed Dec 27 02:37:11 2006
@@ -0,0 +1,154 @@
+/*
+ *  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.ldapstudio.aciitemeditor.dialogs;
+
+
+import java.util.Collection;
+
+import org.apache.directory.ldapstudio.aciitemeditor.widgets.ACIItemGrantsAndDenialsComposite;
+import org.apache.directory.ldapstudio.aciitemeditor.widgets.ACIItemUserClassesComposite;
+import org.apache.directory.shared.ldap.aci.GrantAndDenial;
+import org.apache.directory.shared.ldap.aci.ItemPermission;
+import org.apache.directory.shared.ldap.aci.UserClass;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Spinner;
+
+
+public class ItemPermissionDialog extends Dialog
+{
+
+    public static final String DIALOG_TITLE = "Item Permission Editor";
+
+    public static final double MAX_WIDTH = 250.0;
+
+    public static final double MAX_HEIGHT = 350.0;
+
+    private ItemPermission initialItemPermission;
+
+    private ItemPermission returnItemPermission;
+    
+    private Label precedenceLabel = null;
+    
+    private Spinner precedenceSpinner = null;
+    
+    private ACIItemUserClassesComposite userClassesComposite;
+    
+    private ACIItemGrantsAndDenialsComposite grantsAndDenialsComposite;
+
+
+    public ItemPermissionDialog( Shell parentShell, ItemPermission initialItemPermission )
+    {
+        super( parentShell );
+        super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+        this.initialItemPermission = initialItemPermission;
+        this.returnItemPermission = null;
+    }
+
+
+    public boolean close()
+    {
+        return super.close();
+    }
+
+
+    protected void configureShell( Shell shell )
+    {
+        super.configureShell( shell );
+        shell.setText( DIALOG_TITLE );
+        //shell.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_TEXTEDITOR ) );
+    }
+
+
+    protected void createButtonsForButtonBar( Composite parent )
+    {
+        createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false );
+        createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
+    }
+
+
+    protected void okPressed()
+    {
+        try
+        {
+            int precedence = precedenceSpinner.getSelection();
+            Collection<UserClass> userClasses = userClassesComposite.getUserClasses();
+            Collection<GrantAndDenial> grantsAndDenials = grantsAndDenialsComposite.getGrantsAndDenials();
+            returnItemPermission = new ItemPermission(precedence, grantsAndDenials, userClasses);
+            super.okPressed();
+        }
+        catch ( Exception e )
+        {
+            MessageDialog.openError( getShell(), "Invalid Item Permission", e.getMessage() );
+        }
+    }
+
+
+    protected Control createDialogArea( Composite parent )
+    {
+        Composite composite = ( Composite ) super.createDialogArea( parent );
+        GridData gd = new GridData( GridData.FILL_BOTH );
+        composite.setLayoutData( gd );
+
+        Composite spinnerComposite = new Composite( composite, SWT.NONE );
+        spinnerComposite.setLayout( new GridLayout( 2, false ) );
+        spinnerComposite.setLayoutData( new GridData() );
+        precedenceLabel = new Label( spinnerComposite, SWT.NONE );
+        precedenceLabel.setText( "Precedence:" );
+        precedenceSpinner = new Spinner( spinnerComposite, SWT.BORDER );
+        precedenceSpinner.setValues( 0, 0, 255, 0, 1, 10 );
+        GridData precedenceGridData = new GridData();
+        precedenceGridData.grabExcessHorizontalSpace = true;
+        precedenceGridData.verticalAlignment = GridData.CENTER;
+        precedenceGridData.horizontalAlignment = GridData.BEGINNING;
+        precedenceGridData.widthHint = 3 * 12;
+        precedenceSpinner.setLayoutData( precedenceGridData );
+        
+        userClassesComposite = new ACIItemUserClassesComposite( composite, SWT.NONE );
+        
+        grantsAndDenialsComposite = new ACIItemGrantsAndDenialsComposite( composite, SWT.NONE );
+
+        
+        if(initialItemPermission != null)
+        {
+            precedenceSpinner.setSelection( initialItemPermission.getPrecedence() );
+            userClassesComposite.setUserClasses( initialItemPermission.getUserClasses() );
+            grantsAndDenialsComposite.setGrantsAndDenials( initialItemPermission.getGrantsAndDenials() );
+        }
+        
+        applyDialogFont( composite );
+        return composite;
+    }
+
+
+    public ItemPermission getItemPermission()
+    {
+        return returnItemPermission;
+    }
+}

Modified: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/dialogs/UserPermissionDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/dialogs/UserPermissionDialog.java?view=diff&rev=490478&r1=490477&r2=490478
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/dialogs/UserPermissionDialog.java (original)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/dialogs/UserPermissionDialog.java Wed Dec 27 02:37:11 2006
@@ -112,7 +112,7 @@
             returnUserPermission = new UserPermission(precedence, grantsAndDenials, protectedItems);
             super.okPressed();
         }
-        catch ( ParseException e )
+        catch ( Exception e )
         {
             MessageDialog.openError( getShell(), "Invalid User Permission", e.getMessage() );
         }

Modified: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemComposite.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemComposite.java?view=diff&rev=490478&r1=490477&r2=490478
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemComposite.java (original)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemComposite.java Wed Dec 27 02:37:11 2006
@@ -21,13 +21,12 @@
 
 
 import java.text.ParseException;
-import java.util.ArrayList;
 import java.util.Collection;
 
 import org.apache.directory.shared.ldap.aci.ACIItem;
 import org.apache.directory.shared.ldap.aci.AuthenticationLevel;
+import org.apache.directory.shared.ldap.aci.ItemFirstACIItem;
 import org.apache.directory.shared.ldap.aci.UserFirstACIItem;
-import org.apache.directory.shared.ldap.aci.UserPermission;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.ScrolledComposite;
@@ -37,7 +36,6 @@
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
 
 
 /**
@@ -70,7 +68,7 @@
     private ACIItemProtectedItemsComposite itemFirstProtectedItemsComposite = null;
 
     /** The item permission composite used for itemFirst selection */
-    //private ACIItemItemPermissionsComposite itemFirstItemPermissionsComposite = null;
+    private ACIItemItemPermissionsComposite itemFirstItemPermissionsComposite = null;
 
     
     /**
@@ -132,9 +130,8 @@
                     else if( generalComposite.isItemFirst() )
                     {
                         Collection protectedItems = itemFirstProtectedItemsComposite.getProtectedItems();
-                        //Collection itemPermissions = itemFirstItemPermissionsComposite.getItemPermissions();
-                        Collection itemPermissions = new ArrayList();
-                        item = new UserFirstACIItem(identificationTag, precedence, authenticationLevel, protectedItems, itemPermissions);
+                        Collection itemPermissions = itemFirstItemPermissionsComposite.getItemPermissions();
+                        item = new ItemFirstACIItem(identificationTag, precedence, authenticationLevel, protectedItems, itemPermissions);
                     }
                     else {
                         throw new ParseException("No first selected", 0);
@@ -161,7 +158,7 @@
         userFirstUserPermissionsComposite = new ACIItemUserPermissionsComposite( composite, SWT.NONE );
         
         itemFirstProtectedItemsComposite = new ACIItemProtectedItemsComposite( composite, SWT.NONE );
-        //itemFirstItemPermissionsComposite = new ACIItemItemPermissionsComposite( composite, SWT.NONE );
+        itemFirstItemPermissionsComposite = new ACIItemItemPermissionsComposite( composite, SWT.NONE );
 
         
         widgetModified( null );
@@ -180,7 +177,7 @@
             userFirstUserClassesComposite.setVisible( false );
             userFirstUserPermissionsComposite.setVisible( false );
             itemFirstProtectedItemsComposite.setVisible( true );
-            //itemFirstItemPermissionsComposite.setVisible( true );
+            itemFirstItemPermissionsComposite.setVisible( true );
 
             setMinSize( composite.computeSize( SWT.DEFAULT, SWT.DEFAULT ) );
             layout( true, true );
@@ -190,7 +187,7 @@
             userFirstUserClassesComposite.setVisible( true );
             userFirstUserPermissionsComposite.setVisible( true );
             itemFirstProtectedItemsComposite.setVisible( false );
-            //itemFirstItemPermissionsComposite.setVisible( false );
+            itemFirstItemPermissionsComposite.setVisible( false );
 
             setMinSize( composite.computeSize( SWT.DEFAULT, SWT.DEFAULT ) );
             layout( true, true );
@@ -200,7 +197,7 @@
             userFirstUserClassesComposite.setVisible( false );
             userFirstUserPermissionsComposite.setVisible( false );
             itemFirstProtectedItemsComposite.setVisible( false );
-            //itemFirstItemPermissionsComposite.setVisible( false );
+            itemFirstItemPermissionsComposite.setVisible( false );
 
             setMinSize( composite.computeSize( SWT.DEFAULT, SWT.DEFAULT ) );
             layout( true, true );

Modified: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemItemPermissionsComposite.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemItemPermissionsComposite.java?view=diff&rev=490478&r1=490477&r2=490478
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemItemPermissionsComposite.java (original)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemItemPermissionsComposite.java Wed Dec 27 02:37:11 2006
@@ -26,9 +26,8 @@
 import java.util.List;
 
 import org.apache.directory.ldapstudio.aciitemeditor.dialogs.TextDialog;
-import org.apache.directory.ldapstudio.aciitemeditor.dialogs.UserClassDialog;
+import org.apache.directory.ldapstudio.aciitemeditor.dialogs.ItemPermissionDialog;
 import org.apache.directory.shared.ldap.aci.ItemPermission;
-import org.apache.directory.shared.ldap.aci.UserClass;
 import org.eclipse.jface.viewers.ArrayContentProvider;
 import org.eclipse.jface.viewers.DoubleClickEvent;
 import org.eclipse.jface.viewers.IDoubleClickListener;
@@ -49,7 +48,7 @@
 
 
 /**
- * This composite contains GUI elements to edit ACI item user classes.
+ * This composite contains GUI elements to edit ACI item item permissions.
 
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
@@ -67,7 +66,7 @@
     /** The table control for the table viewer */
     private Table table = null;
     
-    /** The table viewer containing all user classes */
+    /** The table viewer containing all item classes */
     private TableViewer tableViewer = null;
     
     /** The composite containing the buttons */
@@ -82,67 +81,38 @@
     /** The deselect all button */
     private Button deleteButton = null;
     
-    /** The selected user classes, also input of the table viewer */
-    List<UserClassWrapper> userClasses = new ArrayList<UserClassWrapper>();
+    /** The selected item permissions, also input of the table viewer */
+    List<ItemPermissionWrapper> itemPermissionWrappers = new ArrayList<ItemPermissionWrapper>();
     
     
-    private class UserClassWrapper
+    private class ItemPermissionWrapper
     {
-        /** The class of the user class, never null. */
-        private final Class userClassClass;
-        
-        /** The user class bean, may be null. */
-        private UserClass userClass;
-        
-        /** The user class as string, may be null. */
-        private String userClassValue;
+        /** The item permission bean. */
+        private ItemPermission itemPermission;
         
         /**
-         * Creates a new instance of UserClassWrapper.
+         * Creates a new instance of ItemPermissionWrapper.
          *
-         * @param userClassClass
+         * @param itemClassClass
          */
-        public UserClassWrapper( Class userClassClass )
+        public ItemPermissionWrapper( ItemPermission itemPermission )
         {
-            this.userClassClass = userClassClass;
-            this.userClass = null;
-            this.userClassValue = null;
+            this.itemPermission = itemPermission;
         }
         
         public String toString()
         {
-            if(userClassClass == UserClass.AllUsers.class) 
-            {
-                return "All Users";
-            }
-            else if(userClassClass == UserClass.ThisEntry.class) 
-            {
-                return "This Entry";
-            }
-            else if(userClassClass == UserClass.Name.class) 
-            {
-                return "Name" + getUserClassValue();
-            }
-            else if(userClassClass == UserClass.UserGroup.class) 
-            {
-                return "User Group" + getUserClassValue();
-            }
-            else if(userClassClass == UserClass.Subtree.class) 
-            {
-                return "Subtree" + getUserClassValue();
-            }
-            
-            return "<UNKNOWN>";
+            return getItemPermissionValue();
         }
-        private String getUserClassValue()
+        private String getItemPermissionValue()
         {
-            if(userClassValue == null)
+            if(itemPermission == null)
             {
-                return " ...";
+                return "<UNKNOWN>";
             }
             else 
             {
-                String s = userClassValue;
+                String s = itemPermission.toString();
                 s = s.replace( '\r', ' ' );
                 s = s.replace( '\n', ' ' );
                 s = ": " + s;
@@ -208,7 +178,7 @@
         composite.setLayout(gridLayout);
         
         label = new Label(composite, SWT.NONE);
-        label.setText("User Classes:");
+        label.setText("Item Permissions:");
         label.setLayoutData(labelGridData);
         
         createTable();
@@ -236,20 +206,20 @@
         tableViewer = new TableViewer( table );
         tableViewer.setContentProvider( new ArrayContentProvider() );
         tableViewer.setLabelProvider( new LabelProvider() );
-        tableViewer.setInput( userClasses );
+        tableViewer.setInput( itemPermissionWrappers );
 
         tableViewer.addSelectionChangedListener( new ISelectionChangedListener()
         {
             public void selectionChanged( SelectionChangedEvent event )
             {
-                userClassSelected();
+                itemPermissionSelected();
             }
         } );
         
         tableViewer.addDoubleClickListener( new IDoubleClickListener(){
             public void doubleClick( DoubleClickEvent event )
             {
-                editUserClass();
+                editItemPermission();
             }
         } );
     }
@@ -295,7 +265,7 @@
         addButton.addSelectionListener( new SelectionAdapter(){
             public void widgetSelected( SelectionEvent e )
             {
-                addUserClass();
+                addItemPermission();
             }
         } );
         
@@ -305,7 +275,7 @@
         editButton.addSelectionListener( new SelectionAdapter(){
             public void widgetSelected( SelectionEvent e )
             {
-                editUserClass();
+                editItemPermission();
             }
         } );
         editButton.setEnabled( false );
@@ -316,88 +286,14 @@
         deleteButton.addSelectionListener( new SelectionAdapter(){
             public void widgetSelected( SelectionEvent e )
             {
-                deleteUserClass();
+                deleteItemPermission();
             }
         } );
         deleteButton.setEnabled( false );
         
     }
     
-    
-    
-    
-    
-//    public void setUserClasses( List<UserClass> userClasses )
-//    {
-//        //this.userClasses = userClasses;
-//
-//        for ( UserClass userClass : userClasses )
-//        {
-//            if ( userClass instanceof UserClass.AllUsers )
-//            {
-//                allUsersCheckBox.setSelection( true );
-//            }
-//            if ( userClass instanceof UserClass.ThisEntry )
-//            {
-//                thisEntryCheckBox.setSelection( true );
-//            }
-//            if ( userClass instanceof UserClass.Name )
-//            {
-//                nameCheckBox.setSelection( true );
-//                UserClass.Name name = ( UserClass.Name ) userClass;
-//                nameLabel.setText( getNumValuesText( name.getNames() ) );
-//                nameNames = ( Set<LdapDN> ) name.getNames();
-//            }
-//            if ( userClass instanceof UserClass.UserGroup )
-//            {
-//                userGroupCheckBox.setSelection( true );
-//                UserClass.UserGroup userGroup = ( UserClass.UserGroup ) userClass;
-//                userGroupLabel.setText( getNumValuesText( userGroup.getNames() ) );
-//                userGroupNames = ( Set<LdapDN> ) userGroup.getNames();
-//            }
-//            if ( userClass instanceof UserClass.Subtree )
-//            {
-//                subtreeCheckBox.setSelection( true );
-//                UserClass.Subtree subtree = ( UserClass.Subtree ) userClass;
-//                subtreeLabel.setText( getNumValuesText( subtree.getSubtreeSpecifications() ) );
-//                subtreeSpecifications = ( Collection<SubtreeSpecification> ) subtree.getSubtreeSpecifications();
-//            }
-//        }
-//    }
-
-
-    
-
-//    public List<UserClass> getUserClasses()
-//    {
-//
-//        List<UserClass> userClasses = new ArrayList<UserClass>();
-//
-//        if ( allUsersCheckBox.getSelection() )
-//        {
-//            userClasses.add( UserClass.ALL_USERS );
-//        }
-//        if ( thisEntryCheckBox.getSelection() )
-//        {
-//            userClasses.add( UserClass.THIS_ENTRY );
-//        }
-//        if ( nameCheckBox.getSelection() )
-//        {
-//
-//        }
-//        if ( userGroupCheckBox.getSelection() )
-//        {
-//            
-//        }
-//        if ( subtreeCheckBox.getSelection() )
-//        {
-//            
-//        }
-//
-//        return userClasses;
-//
-//    }
-//    
+
     
     public void setVisible( boolean visible )
     {
@@ -406,37 +302,21 @@
     }
     
     
-    
     /**
      * Sets the item permissions. 
      *
-     * @param protectedItems
+     * @param itemPermissions
      */
     public void setItemPermissions( Collection<ItemPermission> itemPermissions )
     {
-        // TODO
-//        for ( ProtectedItem item : protectedItems )
-//        {
-//            for(int i=0; i<protectedItemWrappers.length; i++) 
-//            {
-//                ProtectedItemWrapper protectedItemWrapper = protectedItemWrappers[i];
-//                
-//                if( protectedItemWrapper.protectedItemClass == item.getClass() )
-//                {
-//                    StringBuffer buffer = new StringBuffer();
-//                    item.printToBuffer( buffer );
-//                    String s = buffer.toString();
-//                    if(s.indexOf( ' ' ) > -1)
-//                    {
-//                        s = s.substring( s.indexOf( ' ' ), s.length() );
-//                    }
-//                    protectedItemWrapper.protectedItemValue = s;
-//                    tableViewer.setChecked( protectedItemWrapper, true );
-//                }
-//            }
-//        }
-//        
-//        tableViewer.refresh();
+        for ( ItemPermission itemPermission : itemPermissions )
+        {
+            ItemPermissionWrapper itemPermissionWrapper = new ItemPermissionWrapper(itemPermission);
+            
+            itemPermissionWrappers.add( itemPermissionWrapper );
+        }
+
+        tableViewer.refresh();
     }
 
     
@@ -448,76 +328,65 @@
      */
     public Collection<ItemPermission> getItemPermissions() throws ParseException
     {
-
         Collection<ItemPermission> itemPermissions = new ArrayList<ItemPermission>();
 
-        // TODO
-//        this.
-//        
-//        for(int i=0; i<protectedItemWrappers.length; i++) 
-//        {
-//            ProtectedItemWrapper protectedItemWrapper = protectedItemWrappers[i];
-//            if(tableViewer.getChecked( protectedItemWrapper ) )
-//            {
-//                protectedItems.add( protectedItemWrapper.getProtectedItem() );
-//            }
-//        }
+        for ( ItemPermissionWrapper itemPermissionWrapper : itemPermissionWrappers )
+        {
+            itemPermissions.add( itemPermissionWrapper.itemPermission );
+        }
 
         return itemPermissions;
-
     }
     
     /**
      * 
-     * @return the user class that is selected in the table viewer, or null.
+     * @return the item permission that is selected in the table viewer, or null.
      */
-    private UserClassWrapper getSelectedUserClassWrapper() 
+    private ItemPermissionWrapper getSelectedItemPermissionWrapper() 
     {
-        UserClassWrapper userClassWrapper = null;
+        ItemPermissionWrapper itemPermissionWrapper = null;
         
         IStructuredSelection selection = ( IStructuredSelection ) tableViewer.getSelection();
         if ( !selection.isEmpty() )
         {
             Object element = selection.getFirstElement();
-            if ( element instanceof UserClassWrapper )
+            if ( element instanceof ItemPermissionWrapper )
             {
-                userClassWrapper = (UserClassWrapper) element;
+                itemPermissionWrapper = (ItemPermissionWrapper) element;
             }
         }
         
-        return userClassWrapper;
+        return itemPermissionWrapper;
     }
     
     
-    private void addUserClass() 
+    private void addItemPermission() 
     {
-        UserClassDialog dialog = new UserClassDialog( getShell(), null, null );
-        if ( dialog.open() == TextDialog.OK && dialog.getUserClassClass() != null )
+        ItemPermissionDialog dialog = new ItemPermissionDialog( getShell(), null );
+        if ( dialog.open() == TextDialog.OK && dialog.getItemPermission() != null )
         {
-            UserClassWrapper userClassWrapper = new UserClassWrapper(dialog.getUserClassClass());
-            userClassWrapper.userClassValue = dialog.getText();
-            userClasses.add( userClassWrapper );
+            ItemPermissionWrapper itemPermissionWrapper = new ItemPermissionWrapper(dialog.getItemPermission());
+            itemPermissionWrappers.add( itemPermissionWrapper );
             
             tableViewer.refresh();
         }
     }
     
     
-    private void editUserClass() 
+    private void editItemPermission() 
     {
-        UserClassWrapper oldUserClassWrapper = getSelectedUserClassWrapper();
-        if(oldUserClassWrapper != null)
+        ItemPermissionWrapper oldItemPermissionWrapper = getSelectedItemPermissionWrapper();
+        if(oldItemPermissionWrapper != null)
         {
-            UserClassDialog dialog = new UserClassDialog( getShell(), oldUserClassWrapper.userClassClass, oldUserClassWrapper.userClassValue );
+            ItemPermissionDialog dialog = new ItemPermissionDialog( getShell(), oldItemPermissionWrapper.itemPermission );
             if ( dialog.open() == TextDialog.OK )
             {
                 // remove old
-                userClasses.remove( oldUserClassWrapper );
+                itemPermissionWrappers.remove( oldItemPermissionWrapper );
                 
                 // create and add new
-                UserClassWrapper newUserClassWrapper = new UserClassWrapper(dialog.getUserClassClass());
-                newUserClassWrapper.userClassValue = dialog.getText();
-                userClasses.add( newUserClassWrapper );
+                ItemPermissionWrapper newItemPermissionWrapper = new ItemPermissionWrapper(dialog.getItemPermission());
+                itemPermissionWrappers.add( newItemPermissionWrapper );
                 
                 tableViewer.refresh();
             }
@@ -525,22 +394,22 @@
     }
     
     
-    private void deleteUserClass() 
+    private void deleteItemPermission() 
     {
-        UserClassWrapper userClassWrapper = getSelectedUserClassWrapper();
-        if(userClassWrapper != null)
+        ItemPermissionWrapper itemPermissionWrapper = getSelectedItemPermissionWrapper();
+        if(itemPermissionWrapper != null)
         {
-            userClasses.remove( userClassWrapper );
+            itemPermissionWrappers.remove( itemPermissionWrapper );
             tableViewer.refresh();
         }
     }
     
     
-    private void userClassSelected()
+    private void itemPermissionSelected()
     {
-        UserClassWrapper userClassWrapper = getSelectedUserClassWrapper();
+        ItemPermissionWrapper itemPermissionWrapper = getSelectedItemPermissionWrapper();
 
-        if ( userClassWrapper == null )
+        if ( itemPermissionWrapper == null )
         {
             editButton.setEnabled( false );
             deleteButton.setEnabled( false );

Modified: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemProtectedItemsComposite.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemProtectedItemsComposite.java?view=diff&rev=490478&r1=490477&r2=490478
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemProtectedItemsComposite.java (original)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemProtectedItemsComposite.java Wed Dec 27 02:37:11 2006
@@ -24,11 +24,9 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.HashMap;
 import java.util.List;
 
 import org.apache.directory.ldapstudio.aciitemeditor.dialogs.TextDialog;
-import org.apache.directory.shared.ldap.aci.ACIItem;
 import org.apache.directory.shared.ldap.aci.ACIItemParser;
 import org.apache.directory.shared.ldap.aci.ItemFirstACIItem;
 import org.apache.directory.shared.ldap.aci.ProtectedItem;
@@ -51,7 +49,6 @@
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
 
 
 /**
@@ -63,7 +60,34 @@
 public class ACIItemProtectedItemsComposite extends Composite 
 {
 
-    /** The protected items used as input for the table viewer */
+    /** The inner composite for all the content */
+    private Composite composite = null;
+    
+    /** The description label */
+    private Label label = null;
+    
+    /** The table control for the table viewer */
+    private Table table = null;
+    
+    /** The table viewer containing all protected items */
+    private CheckboxTableViewer tableViewer = null;
+    
+    /** The composite containing the buttons */
+    private Composite buttonComposite = null;
+    
+    /** The edit button */
+    private Button editButton = null;
+    
+    /** The select all button */
+    private Button selectAllButton = null;
+    
+    /** The deselect all button */
+    private Button deselectAllButton = null;
+    
+    /** The reverse button */
+    private Button reverseSelectionButton = null;
+    
+    /** The possible protected items, used as input for the table viewer */
     private ProtectedItemWrapper[] protectedItemWrappers = new ProtectedItemWrapper[]
     { 
         new ProtectedItemWrapper(ProtectedItem.Entry.class), // null
@@ -80,6 +104,13 @@
         new ProtectedItemWrapper(ProtectedItem.Classes.class), // classes and : { item: xyz , or:{item:X,item:Y}   }
     };
     
+    /**
+     * The ProtectedItemWrapper is used as input for the table viewer. 
+     * The protected item values are always stored as raw string value.
+     *
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     * @version $Rev$, $Date$
+     */
     private class ProtectedItemWrapper
     {
         private static final String DUMMY = 
@@ -91,7 +122,7 @@
         /** The class of the protected item, never null. */
         private final Class protectedItemClass;
         
-        /** The protected item as string, may be null. */
+        /** The protected item as string, may be empty. */
         private String protectedItemValue;
         
         /**
@@ -105,7 +136,15 @@
             this.protectedItemValue = "";
         }
         
-        public ProtectedItem getProtectedItem() throws ParseException
+        /**
+         * Creates a new protected item object. Therefor it uses the 
+         * dummy ACI, injects the protected item and its value, parses
+         * the ACI and extracts the protected item from the parsed bean.
+         *
+         * @return
+         * @throws ParseException
+         */
+        private ProtectedItem getProtectedItem() throws ParseException
         {
             String type = "";
             
@@ -238,32 +277,6 @@
         }
     }
 
-    /** The inner composite for all the content */
-    private Composite composite = null;
-    
-    /** The description label */
-    private Label label = null;
-    
-    /** The table control for the table viewer */
-    private Table table = null;
-    
-    /** The table viewer containing all protected items */
-    private CheckboxTableViewer tableViewer = null;
-    
-    /** The composite containing the buttons */
-    private Composite buttonComposite = null;
-    
-    /** The edit button */
-    private Button editButton = null;
-    
-    /** The select all button */
-    private Button selectAllButton = null;
-    
-    /** The deselect all button */
-    private Button deselectAllButton = null;
-    
-    /** The reverse button */
-    private Button reverseSelectionButton = null;
 
 
     /**
@@ -472,10 +485,8 @@
     {
         for ( ProtectedItem item : protectedItems )
         {
-            for(int i=0; i<protectedItemWrappers.length; i++) 
+            for ( ProtectedItemWrapper protectedItemWrapper : protectedItemWrappers )
             {
-                ProtectedItemWrapper protectedItemWrapper = protectedItemWrappers[i];
-                
                 if( protectedItemWrapper.protectedItemClass == item.getClass() )
                 {
                     StringBuffer buffer = new StringBuffer();
@@ -499,27 +510,31 @@
      * Returns the protected items as selected by the user.
      *
      * @return the protected items
-     * @throws ParseException 
+     * @throws ParseException if the protected items or its values are not valid.
      */
     public Collection<ProtectedItem> getProtectedItems() throws ParseException
     {
 
         Collection<ProtectedItem> protectedItems = new ArrayList<ProtectedItem>();
 
-        for(int i=0; i<protectedItemWrappers.length; i++) 
+        for ( ProtectedItemWrapper protectedItemWrapper : protectedItemWrappers )
         {
-            ProtectedItemWrapper protectedItemWrapper = protectedItemWrappers[i];
             if(tableViewer.getChecked( protectedItemWrapper ) )
             {
-                protectedItems.add( protectedItemWrapper.getProtectedItem() );
+                ProtectedItem protectedItem = protectedItemWrapper.getProtectedItem();
+                protectedItems.add( protectedItem );
             }
         }
 
         return protectedItems;
-
     }
     
     
+    /**
+     * Shows or hides this composite.
+     * 
+     * @see org.eclipse.swt.widgets.control#setVisible(boolean)
+     */
     public void setVisible( boolean visible )
     {
         super.setVisible( visible );
@@ -552,7 +567,6 @@
     /**
      * Called, when a protected item is selected in the table viewer.
      * - enables/disables the edit button
-     * 
      *
      */
     private void protectedItemSelected()
@@ -573,6 +587,10 @@
     }
     
     
+    /**
+     * Called, when a protected item checkbox is checked or unchecked.
+     *
+     */
     private void protectedItemChecked()
     {
         
@@ -580,7 +598,7 @@
 
 
     /**
-     * Caled, when pushing the edit button. Opens the text editor.
+     * Called, when pushing the edit button. Opens the text editor.
      *
      */
     private void editProtectedItem()

Modified: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemUserClassesComposite.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemUserClassesComposite.java?view=diff&rev=490478&r1=490477&r2=490478
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemUserClassesComposite.java (original)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemUserClassesComposite.java Wed Dec 27 02:37:11 2006
@@ -22,23 +22,25 @@
 
 import java.text.ParseException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
 
 import org.apache.directory.ldapstudio.aciitemeditor.dialogs.TextDialog;
-import org.apache.directory.ldapstudio.aciitemeditor.dialogs.UserClassDialog;
 import org.apache.directory.shared.ldap.aci.ACIItemParser;
 import org.apache.directory.shared.ldap.aci.ProtectedItem;
 import org.apache.directory.shared.ldap.aci.UserClass;
 import org.apache.directory.shared.ldap.aci.UserFirstACIItem;
 import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
 import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.ICheckStateListener;
 import org.eclipse.jface.viewers.IDoubleClickListener;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
@@ -70,23 +72,32 @@
     private Table table = null;
     
     /** The table viewer containing all user classes */
-    private TableViewer tableViewer = null;
+    private CheckboxTableViewer tableViewer = null;
     
     /** The composite containing the buttons */
     private Composite buttonComposite = null;
     
-    /** The add button */
-    private Button addButton = null;
+    /** The edit button */
+    private Button editButton = null;
     
     /** The select all button */
-    private Button editButton = null;
+    private Button selectAllButton = null;
     
     /** The deselect all button */
-    private Button deleteButton = null;
+    private Button deselectAllButton = null;
     
-    /** The selected user classes, also input of the table viewer */
-    List<UserClassWrapper> userClassWrappers = new ArrayList<UserClassWrapper>();
+    /** The reverse button */
+    private Button reverseSelectionButton = null;
     
+    /** The possible user classes, used as input for the table viewer */
+    private UserClassWrapper[] userClassWrappers = new UserClassWrapper[]
+    { 
+        new UserClassWrapper(UserClass.AllUsers.class), // allUsers
+        new UserClassWrapper(UserClass.ThisEntry.class), // thisEntry
+        new UserClassWrapper(UserClass.Name.class), // name { "cn=abc", "cn=def" }
+        new UserClassWrapper(UserClass.UserGroup.class), // userGroup { "cn=abc", "cn=def" }
+        new UserClassWrapper(UserClass.Subtree.class) // subtree { { base \"ou=people\" } }
+    };
     
     private class UserClassWrapper
     {
@@ -99,7 +110,7 @@
         /** The class of the user class, never null. */
         private final Class userClassClass;
         
-        /** The user class as string, may be null. */
+        /** The user class as string, may be empty. */
         private String userClassValue;
         
         /**
@@ -110,7 +121,7 @@
         public UserClassWrapper( Class userClassClass )
         {
             this.userClassClass = userClassClass;
-            this.userClassValue = null;
+            this.userClassValue = "";
         }
         
         public UserClass getUserClass() throws ParseException
@@ -176,7 +187,7 @@
         {
             if(userClassValue == null)
             {
-                return " ...";
+                return "";
             }
             else 
             {
@@ -267,11 +278,11 @@
         tableGridData.horizontalAlignment = GridData.FILL;
         //tableGridData.heightHint = 100;
 
-        table = new Table( composite, SWT.BORDER );
+        table = new Table( composite, SWT.BORDER | SWT.CHECK );
         table.setHeaderVisible( false );
         table.setLayoutData( tableGridData );
         table.setLinesVisible( true );
-        tableViewer = new TableViewer( table );
+        tableViewer = new CheckboxTableViewer( table );
         tableViewer.setContentProvider( new ArrayContentProvider() );
         tableViewer.setLabelProvider( new LabelProvider() );
         tableViewer.setInput( userClassWrappers );
@@ -283,7 +294,13 @@
                 userClassSelected();
             }
         } );
-        
+        tableViewer.addCheckStateListener( new ICheckStateListener()
+        {
+            public void checkStateChanged( CheckStateChangedEvent event )
+            {
+                userClassChecked();
+            }   
+        } );
         tableViewer.addDoubleClickListener( new IDoubleClickListener(){
             public void doubleClick( DoubleClickEvent event )
             {
@@ -299,21 +316,26 @@
      */
     private void createButtonComposite()
     {
-        GridData deleteButtonGridData = new GridData();
-        deleteButtonGridData.horizontalAlignment = GridData.FILL;
-        deleteButtonGridData.grabExcessHorizontalSpace = false;
-        deleteButtonGridData.verticalAlignment = GridData.BEGINNING;
+        GridData reverseSelectionButtonGridData = new GridData();
+        reverseSelectionButtonGridData.horizontalAlignment = GridData.FILL;
+        reverseSelectionButtonGridData.grabExcessHorizontalSpace = false;
+        reverseSelectionButtonGridData.verticalAlignment = GridData.BEGINNING;
+        
+        GridData deselectAllButtonGridData = new GridData();
+        deselectAllButtonGridData.horizontalAlignment = GridData.FILL;
+        deselectAllButtonGridData.grabExcessHorizontalSpace = false;
+        deselectAllButtonGridData.verticalAlignment = GridData.BEGINNING;
+        
+        GridData selectAllButtonGridData = new GridData();
+        selectAllButtonGridData.horizontalAlignment = GridData.FILL;
+        selectAllButtonGridData.grabExcessHorizontalSpace = false;
+        selectAllButtonGridData.verticalAlignment = GridData.BEGINNING;
         
         GridData editButtonGridData = new GridData();
         editButtonGridData.horizontalAlignment = GridData.FILL;
         editButtonGridData.grabExcessHorizontalSpace = false;
         editButtonGridData.verticalAlignment = GridData.BEGINNING;
         
-        GridData addButtonGridData = new GridData();
-        addButtonGridData.horizontalAlignment = GridData.FILL;
-        addButtonGridData.grabExcessHorizontalSpace = false;
-        addButtonGridData.verticalAlignment = GridData.BEGINNING;
-        
         GridLayout gridLayout = new GridLayout();
         gridLayout.marginWidth = 0;
         gridLayout.marginHeight = 0;
@@ -327,16 +349,6 @@
         buttonComposite.setLayoutData(gridData);
         buttonComposite.setLayout( gridLayout );
         
-        addButton = new Button(buttonComposite, SWT.NONE);
-        addButton.setText("Add...");
-        addButton.setLayoutData(addButtonGridData);
-        addButton.addSelectionListener( new SelectionAdapter(){
-            public void widgetSelected( SelectionEvent e )
-            {
-                addUserClass();
-            }
-        } );
-        
         editButton = new Button(buttonComposite, SWT.NONE);
         editButton.setText("Edit...");
         editButton.setLayoutData(editButtonGridData);
@@ -348,99 +360,40 @@
         } );
         editButton.setEnabled( false );
         
-        deleteButton = new Button(buttonComposite, SWT.NONE);
-        deleteButton.setText("Delete");
-        deleteButton.setLayoutData(deleteButtonGridData);
-        deleteButton.addSelectionListener( new SelectionAdapter(){
+        selectAllButton = new Button(buttonComposite, SWT.NONE);
+        selectAllButton.setText("Select All");
+        selectAllButton.setLayoutData(selectAllButtonGridData);
+        selectAllButton.addSelectionListener( new SelectionAdapter(){
             public void widgetSelected( SelectionEvent e )
             {
-                deleteUserClass();
+                tableViewer.setCheckedElements( userClassWrappers );
+            }
+        } );
+        
+        deselectAllButton = new Button(buttonComposite, SWT.NONE);
+        deselectAllButton.setText("Deselect All");
+        deselectAllButton.setLayoutData(deselectAllButtonGridData);
+        deselectAllButton.addSelectionListener( new SelectionAdapter(){
+            public void widgetSelected( SelectionEvent e )
+            {
+                tableViewer.setCheckedElements( new ProtectedItem[0] );
+            }
+        } );
+        
+        reverseSelectionButton = new Button(buttonComposite, SWT.NONE);
+        reverseSelectionButton.setText("Reverse");
+        reverseSelectionButton.setLayoutData(reverseSelectionButtonGridData);
+        reverseSelectionButton.addSelectionListener( new SelectionAdapter(){
+            public void widgetSelected( SelectionEvent e )
+            {
+                List<Object> elements = new ArrayList<Object>();
+                elements.addAll( Arrays.asList( userClassWrappers ) );
+                elements.removeAll( Arrays.asList( tableViewer.getCheckedElements() ) );
+                tableViewer.setCheckedElements( elements.toArray() );
+                
             }
         } );
-        deleteButton.setEnabled( false );
         
-    }
-    
-    
-    
-    
-    
-//    public void setUserClasses( List<UserClass> userClasses )
-//    {
-//        //this.userClasses = userClasses;
-//
-//        for ( UserClass userClass : userClasses )
-//        {
-//            if ( userClass instanceof UserClass.AllUsers )
-//            {
-//                allUsersCheckBox.setSelection( true );
-//            }
-//            if ( userClass instanceof UserClass.ThisEntry )
-//            {
-//                thisEntryCheckBox.setSelection( true );
-//            }
-//            if ( userClass instanceof UserClass.Name )
-//            {
-//                nameCheckBox.setSelection( true );
-//                UserClass.Name name = ( UserClass.Name ) userClass;
-//                nameLabel.setText( getNumValuesText( name.getNames() ) );
-//                nameNames = ( Set<LdapDN> ) name.getNames();
-//            }
-//            if ( userClass instanceof UserClass.UserGroup )
-//            {
-//                userGroupCheckBox.setSelection( true );
-//                UserClass.UserGroup userGroup = ( UserClass.UserGroup ) userClass;
-//                userGroupLabel.setText( getNumValuesText( userGroup.getNames() ) );
-//                userGroupNames = ( Set<LdapDN> ) userGroup.getNames();
-//            }
-//            if ( userClass instanceof UserClass.Subtree )
-//            {
-//                subtreeCheckBox.setSelection( true );
-//                UserClass.Subtree subtree = ( UserClass.Subtree ) userClass;
-//                subtreeLabel.setText( getNumValuesText( subtree.getSubtreeSpecifications() ) );
-//                subtreeSpecifications = ( Collection<SubtreeSpecification> ) subtree.getSubtreeSpecifications();
-//            }
-//        }
-//    }
-
-
-    
-
-//    public List<UserClass> getUserClasses()
-//    {
-//
-//        List<UserClass> userClasses = new ArrayList<UserClass>();
-//
-//        if ( allUsersCheckBox.getSelection() )
-//        {
-//            userClasses.add( UserClass.ALL_USERS );
-//        }
-//        if ( thisEntryCheckBox.getSelection() )
-//        {
-//            userClasses.add( UserClass.THIS_ENTRY );
-//        }
-//        if ( nameCheckBox.getSelection() )
-//        {
-//
-//        }
-//        if ( userGroupCheckBox.getSelection() )
-//        {
-//            
-//        }
-//        if ( subtreeCheckBox.getSelection() )
-//        {
-//            
-//        }
-//
-//        return userClasses;
-//
-//    }
-//    
-    
-    public void setVisible( boolean visible )
-    {
-        super.setVisible( visible );
-        ((GridData)getLayoutData()).heightHint = visible ? -1 : 0;
     }
     
     
@@ -453,17 +406,21 @@
     {
         for ( UserClass userClass : userClasses )
         {
-            
-            UserClassWrapper userClassWrapper = new UserClassWrapper(userClass.getClass());
-            
-            StringBuffer buffer = new StringBuffer();
-            userClass.printToBuffer( buffer );
-            String s = buffer.toString();
-            if(s.indexOf( ' ' ) > -1)
+            for ( UserClassWrapper userClassWrapper : userClassWrappers )
             {
-                s = s.substring( s.indexOf( ' ' ), s.length() );
+                if( userClassWrapper.userClassClass == userClass.getClass() )
+                {
+                    StringBuffer buffer = new StringBuffer();
+                    userClass.printToBuffer( buffer );
+                    String s = buffer.toString();
+                    if(s.indexOf( ' ' ) > -1)
+                    {
+                        s = s.substring( s.indexOf( ' ' ), s.length() );
+                        userClassWrapper.userClassValue = s;
+                    }
+                    tableViewer.setChecked( userClassWrapper, true );
+                }
             }
-            userClassWrapper.userClassValue = s;
         }
         
         tableViewer.refresh();
@@ -478,19 +435,36 @@
      */
     public Collection<UserClass> getUserClasses() throws ParseException
     {
-
+        System.out.println(tableViewer.getCheckedElements().length);
+        
+        
         Collection<UserClass> userClasses = new ArrayList<UserClass>();
 
-        for ( UserClassWrapper userClassWrapper : this.userClassWrappers )
+        for ( UserClassWrapper userClassWrapper : userClassWrappers )
         {
-            UserClass userClass = userClassWrapper.getUserClass();
-            userClasses.add( userClass );
+            if(tableViewer.getChecked( userClassWrapper ) )
+            {
+                UserClass userClass = userClassWrapper.getUserClass();
+                userClasses.add( userClass );
+            }
         }
 
         return userClasses;
-
     }
     
+    
+    /**
+     * Shows or hides this composite.
+     * 
+     * @see org.eclipse.swt.widgets.control#setVisible(boolean)
+     */
+    public void setVisible( boolean visible )
+    {
+        super.setVisible( visible );
+        ((GridData)getLayoutData()).heightHint = visible ? -1 : 0;
+    }
+    
+    
     /**
      * 
      * @return the user class that is selected in the table viewer, or null.
@@ -513,67 +487,53 @@
     }
     
     
-    private void addUserClass() 
+    /**
+     * Called, when a user class is selected in the table viewer.
+     * - enables/disables the edit button
+     *
+     */
+    private void userClassSelected()
     {
-        UserClassDialog dialog = new UserClassDialog( getShell(), null, null );
-        if ( dialog.open() == TextDialog.OK && dialog.getUserClassClass() != null )
+        UserClassWrapper userClassWrapper = getSelectedUserClassWrapper();
+
+        if ( userClassWrapper == null 
+            || userClassWrapper.userClassClass == UserClass.AllUsers.class
+            || userClassWrapper.userClassClass == UserClass.ThisEntry.class )
         {
-            UserClassWrapper userClassWrapper = new UserClassWrapper(dialog.getUserClassClass());
-            userClassWrapper.userClassValue = dialog.getText();
-            userClassWrappers.add( userClassWrapper );
-            
-            tableViewer.refresh();
+            editButton.setEnabled( false );
         }
-    }
-    
-    
-    private void editUserClass() 
-    {
-        UserClassWrapper oldUserClassWrapper = getSelectedUserClassWrapper();
-        if(oldUserClassWrapper != null)
+        else
         {
-            UserClassDialog dialog = new UserClassDialog( getShell(), oldUserClassWrapper.userClassClass, oldUserClassWrapper.userClassValue );
-            if ( dialog.open() == TextDialog.OK )
-            {
-                // remove old
-                userClassWrappers.remove( oldUserClassWrapper );
-                
-                // create and add new
-                UserClassWrapper newUserClassWrapper = new UserClassWrapper(dialog.getUserClassClass());
-                newUserClassWrapper.userClassValue = dialog.getText();
-                userClassWrappers.add( newUserClassWrapper );
-                
-                tableViewer.refresh();
-            }
+            editButton.setEnabled( true );
         }
     }
     
     
-    private void deleteUserClass() 
+    /**
+     * Called, when a user class checkbox is checked or unchecked.
+     *
+     */
+    private void userClassChecked()
     {
-        UserClassWrapper userClassWrapper = getSelectedUserClassWrapper();
-        if(userClassWrapper != null)
-        {
-            userClassWrappers.remove( userClassWrapper );
-            tableViewer.refresh();
-        }
+        
     }
-    
-    
-    private void userClassSelected()
+
+
+    /**
+     * Called, when pushing the edit button. Opens the text editor.
+     *
+     */
+    private void editUserClass()
     {
         UserClassWrapper userClassWrapper = getSelectedUserClassWrapper();
-
-        if ( userClassWrapper == null )
-        {
-            editButton.setEnabled( false );
-            deleteButton.setEnabled( false );
-        }
-        else
+        
+        TextDialog dialog = new TextDialog( getShell(), userClassWrapper.userClassValue );
+        if ( dialog.open() == TextDialog.OK )
         {
-            editButton.setEnabled( true );
-            deleteButton.setEnabled( true );
+            userClassWrapper.userClassValue = dialog.getText();
+            tableViewer.refresh();
         }
+        
     }
 
 }

Modified: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemUserPermissionsComposite.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemUserPermissionsComposite.java?view=diff&rev=490478&r1=490477&r2=490478
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemUserPermissionsComposite.java (original)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemUserPermissionsComposite.java Wed Dec 27 02:37:11 2006
@@ -87,10 +87,7 @@
     
     private class UserPermissionWrapper
     {
-        /** The class of the user permission, never null. */
-        private final Class userPermissionClass;
-        
-        /** The user permission bean, may be null. */
+        /** The user permission bean. */
         private UserPermission userPermission;
         
         /**
@@ -98,10 +95,9 @@
          *
          * @param userClassClass
          */
-        public UserPermissionWrapper( Class userPermissionClass )
+        public UserPermissionWrapper( UserPermission userPermission )
         {
-            this.userPermissionClass = userPermissionClass;
-            this.userPermission = null;
+            this.userPermission = userPermission;
         }
         
         public String toString()
@@ -315,8 +311,7 @@
     {
         for ( UserPermission userPermission : userPermissions )
         {
-            UserPermissionWrapper userPermissionWrapper = new UserPermissionWrapper(userPermission.getClass());
-            userPermissionWrapper.userPermission = userPermission;
+            UserPermissionWrapper userPermissionWrapper = new UserPermissionWrapper(userPermission);
             
             userPermissionWrappers.add( userPermissionWrapper );
         }
@@ -370,8 +365,7 @@
         UserPermissionDialog dialog = new UserPermissionDialog( getShell(), null );
         if ( dialog.open() == TextDialog.OK && dialog.getUserPermission() != null )
         {
-            UserPermissionWrapper userPermissionWrapper = new UserPermissionWrapper(dialog.getUserPermission().getClass());
-            userPermissionWrapper.userPermission = dialog.getUserPermission();
+            UserPermissionWrapper userPermissionWrapper = new UserPermissionWrapper(dialog.getUserPermission());
             userPermissionWrappers.add( userPermissionWrapper );
             
             tableViewer.refresh();
@@ -391,8 +385,7 @@
                 userPermissionWrappers.remove( oldUserPermissionWrapper );
                 
                 // create and add new
-                UserPermissionWrapper newUserPermissionWrapper = new UserPermissionWrapper(dialog.getUserPermission().getClass());
-                newUserPermissionWrapper.userPermission = dialog.getUserPermission();
+                UserPermissionWrapper newUserPermissionWrapper = new UserPermissionWrapper(dialog.getUserPermission());
                 userPermissionWrappers.add( newUserPermissionWrapper );
                 
                 tableViewer.refresh();



Mime
View raw message