directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r493883 [1/2] - in /directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor: lib/ src/main/java/org/apache/directory/ldapstudio/aciitemeditor/ src/main/java/org/apache/directory/ldapstudio/aciitemeditor/dialogs/ src/main/java/org/apache/d...
Date Mon, 08 Jan 2007 00:07:37 GMT
Author: seelmann
Date: Sun Jan  7 16:07:36 2007
New Revision: 493883

URL: http://svn.apache.org/viewvc?view=rev&rev=493883
Log:
Added MultiValuedDialog, added DnValueEditor for name and userGroups, added contextual information, refactored wrappers, replaced ldap-shared with trunks version.

Added:
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/ACIItemValueWithContext.java
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/dialogs/MultiValuedDialog.java
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/Messages.java
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/ProtectedItemWrapper.java
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/ProtectedItemWrapperFactory.java
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/UserClassWrapper.java
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/UserClassWrapperFactory.java
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/resources/org/apache/directory/ldapstudio/aciitemeditor/model/
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/resources/org/apache/directory/ldapstudio/aciitemeditor/model/messages.properties
Modified:
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/lib/shared-ldap-0.9.6-SNAPSHOT.jar
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/ACIItemValueEditor.java
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/dialogs/ACIItemDialog.java
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/dialogs/ItemPermissionDialog.java
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/dialogs/UserPermissionDialog.java
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemItemPermissionsComposite.java
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemProtectedItemsComposite.java
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemSourceEditorComposite.java
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemTabFolderComposite.java
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemUserClassesComposite.java
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemUserPermissionsComposite.java
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemVisualEditorComposite.java
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/resources/org/apache/directory/ldapstudio/aciitemeditor/widgets/messages.properties

Modified: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/lib/shared-ldap-0.9.6-SNAPSHOT.jar
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/lib/shared-ldap-0.9.6-SNAPSHOT.jar?view=diff&rev=493883&r1=493882&r2=493883
==============================================================================
Binary files - no diff available.

Modified: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/ACIItemValueEditor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/ACIItemValueEditor.java?view=diff&rev=493883&r1=493882&r2=493883
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/ACIItemValueEditor.java (original)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/ACIItemValueEditor.java Sun Jan  7 16:07:36 2007
@@ -21,20 +21,26 @@
 
 
 import org.apache.directory.ldapstudio.aciitemeditor.dialogs.ACIItemDialog;
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierarchy;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
 import org.apache.directory.ldapstudio.browser.ui.valueeditors.AbstractDialogStringValueEditor;
 import org.eclipse.swt.widgets.Shell;
 
 
 /**
- * The IValueEditor implementation of this plugin. 
- *  
- *
+ * The IValueEditor implementation of this plugin.
+ * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
 public class ACIItemValueEditor extends AbstractDialogStringValueEditor
 {
 
+    /**
+     * The Constructor.
+     */
     public ACIItemValueEditor()
     {
         super();
@@ -43,13 +49,19 @@
 
     /**
      * Opens the ACI item dialog.
+     * 
+     * @param shell the shell
+     * 
+     * @return true, if open dialog
      */
     public boolean openDialog( Shell shell )
     {
         Object value = getValue();
-        if ( value != null && value instanceof String )
+        if ( value != null && value instanceof ACIItemValueWithContext )
         {
-            ACIItemDialog dialog = new ACIItemDialog( shell, ( String ) value );
+            ACIItemValueWithContext context = (ACIItemValueWithContext)value;
+            
+            ACIItemDialog dialog = new ACIItemDialog( shell, context );
             if ( dialog.open() == ACIItemDialog.OK && !"".equals( dialog.getACIItemValue() ) ) //$NON-NLS-1$
             {
                 setValue( dialog.getACIItemValue() );
@@ -59,4 +71,110 @@
         return false;
     }
 
+    
+    /**
+     * Returns a ACIItemValueContext with the connection
+     * and entry of the attribute hierarchy and an empty value if there
+     * are no values in attributeHierarchy.
+     * 
+     * Returns a ACIItemValueContext with the connection
+     * and entry of the attribute hierarchy and a value if there is
+     * one value in attributeHierarchy.
+     * 
+     * @param attributeHierarchy the attribute hierarchy
+     * 
+     * @return the raw value
+     */
+    public Object getRawValue( AttributeHierarchy attributeHierarchy )
+    {
+        if ( attributeHierarchy == null )
+        {
+            return null;
+        }
+        else if ( attributeHierarchy.size() == 1 && attributeHierarchy.getAttribute().getValueSize() == 0 )
+        {
+            IEntry entry = attributeHierarchy.getAttribute().getEntry();
+            IConnection connection = entry.getConnection();
+            return new ACIItemValueWithContext( connection, entry, "" );
+        }
+        else if ( attributeHierarchy.size() == 1 && attributeHierarchy.getAttribute().getValueSize() == 1 )
+        {
+            IEntry entry = attributeHierarchy.getAttribute().getEntry();
+            IConnection connection = entry.getConnection();
+            String value = getDisplayValue( attributeHierarchy );
+            return new ACIItemValueWithContext( connection, entry, value );
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    /**
+     * Returns a ACIItemValueContext with the connection,
+     * entry and string value of the given value.
+     * 
+     * @param value the value
+     * 
+     * @return the raw value
+     */
+    public Object getRawValue( IValue value )
+    {
+        Object o = super.getRawValue( value );
+        if ( o != null && o instanceof String )
+        {
+            IEntry entry = value.getAttribute().getEntry();
+            IConnection connection = entry.getConnection();
+            String v = (String) o;
+            return new ACIItemValueWithContext( connection, entry, v );
+        }
+
+        return null;
+    }
+
+
+    /**
+     * Returns a ACIItemValueContext with the given
+     * connection, value and null entry.
+     * 
+     * @param value the value
+     * @param connection the connection
+     * 
+     * @return the raw value
+     */
+    public Object getRawValue( IConnection connection, Object value )
+    {
+        Object o = super.getRawValue( connection, value );
+        if ( o != null && o instanceof String )
+        {
+            String v = (String) o;
+            return new ACIItemValueWithContext( connection, null, v );
+        }
+
+        return null;
+    }
+
+
+    /**
+     * Returns always the string value.
+     * 
+     * Reimplementation, because getRawValue() returns a
+     * DnValueEditorRawValueWrapper.
+     * 
+     * @param value the value
+     * 
+     * @return the display value
+     */
+    public String getDisplayValue( IValue value )
+    {
+        if ( value == null )
+        {
+            return "NULL";
+        }
+
+        String displayValue = value.getStringValue();
+        return displayValue;
+    }
+    
 }

Added: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/ACIItemValueWithContext.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/ACIItemValueWithContext.java?view=auto&rev=493883
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/ACIItemValueWithContext.java (added)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/ACIItemValueWithContext.java Sun Jan  7 16:07:36 2007
@@ -0,0 +1,71 @@
+package org.apache.directory.ldapstudio.aciitemeditor;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+
+
+/**
+ * The ACIItemValueContext is used to pass contextual
+ * information to the opened ACIItemDialog.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ACIItemValueWithContext
+{
+
+    /** The connection, used to browse the directory. */
+    private IConnection connection;
+
+    /** The entry. */
+    private IEntry entry;
+
+    /** The ACI item. */
+    private String aciItemValue;
+
+
+    /**
+     * Creates a new instance of ACIItemValueContext.
+     * 
+     * @param aciItemValue the ACI item value
+     * @param connection the connection
+     * @param entry the entry
+     */
+    public ACIItemValueWithContext( IConnection connection, IEntry entry, String aciItemValue )
+    {
+        this.connection = connection;
+        this.entry = entry;
+        this.aciItemValue = aciItemValue;
+    }
+
+
+    /**
+     * Gets the aci item value.
+     * 
+     * @return the aciItemValue
+     */
+    public String getACIItemValue()
+    {
+        return aciItemValue;
+    }
+
+
+    /**
+     * @return the connection
+     */
+    public IConnection getConnection()
+    {
+        return connection;
+    }
+
+
+    /**
+     * @return the entry
+     */
+    public IEntry getEntry()
+    {
+        return entry;
+    }
+
+}
\ No newline at end of file

Modified: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/dialogs/ACIItemDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/dialogs/ACIItemDialog.java?view=diff&rev=493883&r1=493882&r2=493883
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/dialogs/ACIItemDialog.java (original)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/dialogs/ACIItemDialog.java Sun Jan  7 16:07:36 2007
@@ -23,6 +23,7 @@
 
 import java.text.ParseException;
 
+import org.apache.directory.ldapstudio.aciitemeditor.ACIItemValueWithContext;
 import org.apache.directory.ldapstudio.aciitemeditor.Activator;
 import org.apache.directory.ldapstudio.aciitemeditor.widgets.ACIItemTabFolderComposite;
 import org.eclipse.core.runtime.IStatus;
@@ -46,9 +47,9 @@
 public class ACIItemDialog extends Dialog
 {
 
-    /** The initial value, passed by the constructor */
-    private String initialValue;
-
+    /** The context containing the initial value, passed by the constructor */
+    private ACIItemValueWithContext context;
+    
     /** The resulting value returned by getACIItemValue() */
     private String returnValue;
 
@@ -63,11 +64,18 @@
      * @param initialValue the initial ACI item to edit, or null to 
      *        create a new ACI item
      */
-    public ACIItemDialog( Shell parentShell, String initialValue )
+    public ACIItemDialog( Shell parentShell, ACIItemValueWithContext context )
     {
+        
         super( parentShell );
         super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
-        this.initialValue = initialValue;
+
+        assert context != null;
+        assert context.getACIItemValue() != null;
+        assert context.getConnection() != null;
+        
+        this.context = context;
+        
         this.returnValue = null;
     }
 
@@ -118,9 +126,10 @@
         tabFolderComposite = new ACIItemTabFolderComposite( composite, SWT.NONE );
 
         // set initial value
-        if ( initialValue != null )
+        if ( context != null )
         {
-            tabFolderComposite.setInput( initialValue );
+            tabFolderComposite.setContext( context );
+            tabFolderComposite.setInput( context.getACIItemValue() );
         }
 
         applyDialogFont( composite );

Modified: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/dialogs/ItemPermissionDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/dialogs/ItemPermissionDialog.java?view=diff&rev=493883&r1=493882&r2=493883
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/dialogs/ItemPermissionDialog.java (original)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/dialogs/ItemPermissionDialog.java Sun Jan  7 16:07:36 2007
@@ -23,6 +23,7 @@
 
 import java.util.Collection;
 
+import org.apache.directory.ldapstudio.aciitemeditor.ACIItemValueWithContext;
 import org.apache.directory.ldapstudio.aciitemeditor.Activator;
 import org.apache.directory.ldapstudio.aciitemeditor.widgets.ACIItemGrantsAndDenialsComposite;
 import org.apache.directory.ldapstudio.aciitemeditor.widgets.ACIItemUserClassesComposite;
@@ -52,7 +53,10 @@
  */
 public class ItemPermissionDialog extends Dialog
 {
-
+    
+    /** The context */
+    private ACIItemValueWithContext context;
+    
     /** The initial value, passed by the constructor */
     private ItemPermission initialItemPermission;
 
@@ -79,10 +83,11 @@
      * @param initialValue the initial item permission to edit, 
      *        or null to create a new item permission
      */
-    public ItemPermissionDialog( Shell parentShell, ItemPermission initialItemPermission )
+    public ItemPermissionDialog( Shell parentShell, ItemPermission initialItemPermission, ACIItemValueWithContext context )
     {
         super( parentShell );
         super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+        this.context = context;
         this.initialItemPermission = initialItemPermission;
         this.returnItemPermission = null;
     }
@@ -162,6 +167,7 @@
 
         // user classes
         userClassesComposite = new ACIItemUserClassesComposite( composite, SWT.NONE );
+        userClassesComposite.setContext( context );
 
         // grants and denial
         grantsAndDenialsComposite = new ACIItemGrantsAndDenialsComposite( composite, SWT.NONE );

Added: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/dialogs/MultiValuedDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/dialogs/MultiValuedDialog.java?view=auto&rev=493883
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/dialogs/MultiValuedDialog.java (added)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/dialogs/MultiValuedDialog.java Sun Jan  7 16:07:36 2007
@@ -0,0 +1,377 @@
+/*
+ *  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.List;
+
+import org.apache.directory.ldapstudio.aciitemeditor.ACIItemValueWithContext;
+import org.apache.directory.ldapstudio.aciitemeditor.Activator;
+import org.apache.directory.ldapstudio.aciitemeditor.widgets.Messages;
+import org.apache.directory.ldapstudio.browser.ui.valueeditors.AbstractDialogStringValueEditor;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+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;
+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.Shell;
+import org.eclipse.swt.widgets.Table;
+
+
+/**
+ * Dialog to edit user classes or protected items with multiple values.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class MultiValuedDialog extends Dialog
+{
+    /** The dialog title */
+    private String displayName;
+
+    /** The value editor */
+    private AbstractDialogStringValueEditor valueEditor;
+    
+    /** The values, may be empty. */
+    private List<String> values;
+    
+    /** The context */
+    private ACIItemValueWithContext context;
+    
+    /** The inner composite for all the content */
+    private Composite composite = null;
+
+    /** The table control for the table viewer */
+    private Table table = null;
+
+    /** The table viewer containing all user classes */
+    private TableViewer 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 delete button */
+    private Button deleteButton = null;
+
+    
+    /**
+     * Creates a new instance of MultiValuedDialog.
+     *
+     * @param parentShell the shell
+     * @param displayName the display name of the edited element
+     * @param values a modifyable list of values
+     * @param context the context
+     * @param valueEditor the detail value editor
+     */
+    public MultiValuedDialog( Shell parentShell, String displayName, List<String> values, ACIItemValueWithContext context, AbstractDialogStringValueEditor valueEditor )
+    {
+        super( parentShell );
+        super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+        
+        this.displayName = displayName;
+        this.values = values;
+        this.context = context;
+        this.valueEditor = valueEditor;
+    }
+
+    
+    /**
+     * Sets the dialog title.
+     */
+    protected void configureShell( Shell shell )
+    {
+        super.configureShell( shell );
+        shell.setText( "Edit " + displayName + " Values" );
+    }
+
+    
+    /**
+     * Creates only a OK button.
+     */
+    protected void createButtonsForButtonBar( Composite parent )
+    {
+        createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false );
+    }
+
+
+    
+    /** 
+     * {@inheritDoc}
+     */
+    protected Control createDialogArea( Composite parent )
+    {
+        // create composite
+        composite = ( Composite ) super.createDialogArea( parent );
+        GridData gd = new GridData( GridData.FILL_BOTH );
+        gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH );
+        gd.heightHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH / 2 );
+        composite.setLayoutData( gd );
+        GridLayout layout = ( GridLayout ) composite.getLayout();
+        layout.makeColumnsEqualWidth = false;
+        layout.numColumns = 2;
+
+        createTable();
+
+        createButtonComposite();
+        
+        applyDialogFont( composite );
+        return composite;
+    }
+    
+    
+    /**
+     * This method initializes table and table viewer
+     */
+    private void createTable()
+    {
+        GridData tableGridData = new GridData( GridData.FILL_BOTH );
+        tableGridData.grabExcessHorizontalSpace = true;
+        tableGridData.verticalAlignment = GridData.FILL;
+        tableGridData.horizontalAlignment = GridData.FILL;
+        //tableGridData.heightHint = 100;
+
+        table = new Table( composite, SWT.BORDER );
+        table.setHeaderVisible( false );
+        table.setLayoutData( tableGridData );
+        table.setLinesVisible( false );
+        tableViewer = new TableViewer( table );
+        tableViewer.setContentProvider( new ArrayContentProvider() );
+        tableViewer.setLabelProvider( new LabelProvider() );
+        tableViewer.setInput( values );
+
+        tableViewer.addSelectionChangedListener( new ISelectionChangedListener()
+        {
+            public void selectionChanged( SelectionChangedEvent event )
+            {
+                valueSelected();
+            }
+        } );
+
+        tableViewer.addDoubleClickListener( new IDoubleClickListener()
+        {
+            public void doubleClick( DoubleClickEvent event )
+            {
+                editValue();
+            }
+        } );
+    }
+   
+    
+    /**
+     * This method initializes buttons  
+     */
+    private void createButtonComposite()
+    {
+        GridData deleteButtonGridData = new GridData();
+        deleteButtonGridData.horizontalAlignment = GridData.FILL;
+        deleteButtonGridData.grabExcessHorizontalSpace = false;
+        deleteButtonGridData.verticalAlignment = GridData.BEGINNING;
+        deleteButtonGridData.widthHint = Activator.getButtonWidth( composite );
+
+        GridData editButtonGridData = new GridData();
+        editButtonGridData.horizontalAlignment = GridData.FILL;
+        editButtonGridData.grabExcessHorizontalSpace = false;
+        editButtonGridData.verticalAlignment = GridData.BEGINNING;
+        editButtonGridData.widthHint = Activator.getButtonWidth( composite );
+
+        GridData addButtonGridData = new GridData();
+        addButtonGridData.horizontalAlignment = GridData.FILL;
+        addButtonGridData.grabExcessHorizontalSpace = false;
+        addButtonGridData.verticalAlignment = GridData.BEGINNING;
+        addButtonGridData.widthHint = Activator.getButtonWidth( composite );
+
+        GridLayout gridLayout = new GridLayout();
+        gridLayout.marginWidth = 0;
+        gridLayout.marginHeight = 0;
+        GridData gridData = new GridData();
+        gridData.horizontalAlignment = GridData.CENTER;
+        gridData.grabExcessHorizontalSpace = false;
+        gridData.grabExcessVerticalSpace = false;
+        gridData.verticalAlignment = GridData.FILL;
+
+        buttonComposite = new Composite( composite, SWT.NONE );
+        buttonComposite.setLayoutData( gridData );
+        buttonComposite.setLayout( gridLayout );
+
+        addButton = new Button( buttonComposite, SWT.NONE );
+        addButton.setText( Messages.getString( "ACIItemUserPermissionsComposite.add.button" ) ); //$NON-NLS-1$
+        addButton.setLayoutData( addButtonGridData );
+        addButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                addValue();
+            }
+        } );
+
+        editButton = new Button( buttonComposite, SWT.NONE );
+        editButton.setText( Messages.getString( "ACIItemUserPermissionsComposite.edit.button" ) ); //$NON-NLS-1$
+        editButton.setLayoutData( editButtonGridData );
+        editButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                editValue();
+            }
+        } );
+        editButton.setEnabled( false );
+
+        deleteButton = new Button( buttonComposite, SWT.NONE );
+        deleteButton.setText( Messages.getString( "ACIItemUserPermissionsComposite.delete.button" ) ); //$NON-NLS-1$
+        deleteButton.setLayoutData( deleteButtonGridData );
+        deleteButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                deleteValue();
+            }
+        } );
+        deleteButton.setEnabled( false );
+
+    }
+    
+    
+    /**
+     * Opens the editor and adds the new value to the list.
+     */
+    private void addValue()
+    {
+        Object oldRawValue = valueEditor.getRawValue( context.getConnection(), "" );
+        
+        CellEditor cellEditor = valueEditor.getCellEditor();
+        cellEditor.setValue( oldRawValue );
+        cellEditor.activate();
+        Object newRawValue = cellEditor.getValue();
+        
+        if(newRawValue != null) 
+        {
+            String newValue = (String) valueEditor.getStringOrBinaryValue( newRawValue );
+            
+            values.add( newValue );
+            tableViewer.refresh();
+        }
+    }
+
+
+    /**
+     * Opens the editor with the currently selected
+     * value and puts the modified value into the list.
+     */
+    private void editValue()
+    {
+        String oldValue = getSelectedValue();
+        if ( oldValue != null )
+        {
+            Object oldRawValue = valueEditor.getRawValue( context.getConnection(), oldValue );
+            
+            CellEditor cellEditor = valueEditor.getCellEditor();
+            cellEditor.setValue( oldRawValue );
+            cellEditor.activate();
+            Object newRawValue = cellEditor.getValue();
+            
+            if(newRawValue != null) 
+            {
+                String newValue = (String) valueEditor.getStringOrBinaryValue( newRawValue );
+                
+                values.remove( oldValue );
+                values.add( newValue );
+                tableViewer.refresh();
+            }
+        }
+    }
+
+
+    /**
+     * Deletes the currently selected value from list.
+     */
+    private void deleteValue()
+    {
+        String value = getSelectedValue();
+        if ( value != null )
+        {
+            values.remove( value );
+            tableViewer.refresh();
+        }
+    }
+
+
+    /**
+     * Called when value is selected in table viewer.
+     * Updates the enabled/disabled state of the buttons.
+     */
+    private void valueSelected()
+    {
+        String value = getSelectedValue();
+
+        if ( value == null )
+        {
+            editButton.setEnabled( false );
+            deleteButton.setEnabled( false );
+        }
+        else
+        {
+            editButton.setEnabled( true );
+            deleteButton.setEnabled( true );
+        }
+    }
+    
+    
+    /**
+     * @return the value that is selected in the table viewer, or null.
+     */
+    private String getSelectedValue()
+    {
+        String value = null;
+
+        IStructuredSelection selection = ( IStructuredSelection ) tableViewer.getSelection();
+        if ( !selection.isEmpty() )
+        {
+            Object element = selection.getFirstElement();
+            if ( element instanceof String )
+            {
+                value = ( String ) element;
+            }
+        }
+
+        return value;
+    }
+    
+}

Modified: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/dialogs/UserPermissionDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/dialogs/UserPermissionDialog.java?view=diff&rev=493883&r1=493882&r2=493883
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/dialogs/UserPermissionDialog.java (original)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/dialogs/UserPermissionDialog.java Sun Jan  7 16:07:36 2007
@@ -23,6 +23,7 @@
 
 import java.util.Collection;
 
+import org.apache.directory.ldapstudio.aciitemeditor.ACIItemValueWithContext;
 import org.apache.directory.ldapstudio.aciitemeditor.Activator;
 import org.apache.directory.ldapstudio.aciitemeditor.widgets.ACIItemGrantsAndDenialsComposite;
 import org.apache.directory.ldapstudio.aciitemeditor.widgets.ACIItemProtectedItemsComposite;
@@ -53,6 +54,9 @@
 public class UserPermissionDialog extends Dialog
 {
 
+    /** The context */
+    private ACIItemValueWithContext context;
+    
     /** The initial value, passed by the constructor */
     private UserPermission initialUserPermission;
 
@@ -79,11 +83,12 @@
      * @param initialValue the initial user permission to edit, 
      *        or null to create a new user permission
      */
-    public UserPermissionDialog( Shell parentShell, UserPermission initialUserPermission )
+    public UserPermissionDialog( Shell parentShell, UserPermission initialUserPermission, ACIItemValueWithContext context )
     {
         super( parentShell );
         super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
         this.initialUserPermission = initialUserPermission;
+        this.context = context;
         this.returnUserPermission = null;
     }
 
@@ -162,6 +167,7 @@
 
         // protected items
         protectedItemsComposite = new ACIItemProtectedItemsComposite( composite, SWT.NONE );
+        protectedItemsComposite.setContext( context );
 
         // grants and denials
         grantsAndDenialsComposite = new ACIItemGrantsAndDenialsComposite( composite, SWT.NONE );

Added: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/Messages.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/Messages.java?view=auto&rev=493883
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/Messages.java (added)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/Messages.java Sun Jan  7 16:07:36 2007
@@ -0,0 +1,31 @@
+package org.apache.directory.ldapstudio.aciitemeditor.model;
+
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+
+public class Messages 
+{
+    private static final String BUNDLE_NAME = "org.apache.directory.ldapstudio.aciitemeditor.model.messages"; //$NON-NLS-1$
+
+    private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
+
+
+    private Messages()
+    {
+    }
+
+
+    public static String getString( String key )
+    {
+        try
+        {
+            return RESOURCE_BUNDLE.getString( key );
+        }
+        catch ( MissingResourceException e )
+        {
+            return '!' + key + '!';
+        }
+    }
+}

Added: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/ProtectedItemWrapper.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/ProtectedItemWrapper.java?view=auto&rev=493883
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/ProtectedItemWrapper.java (added)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/ProtectedItemWrapper.java Sun Jan  7 16:07:36 2007
@@ -0,0 +1,399 @@
+
+package org.apache.directory.ldapstudio.aciitemeditor.model;
+
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+
+import org.apache.directory.ldapstudio.browser.ui.valueeditors.AbstractDialogStringValueEditor;
+import org.apache.directory.shared.ldap.aci.ACIItemParser;
+import org.apache.directory.shared.ldap.aci.ItemFirstACIItem;
+import org.apache.directory.shared.ldap.aci.ProtectedItem;
+import org.eclipse.osgi.util.NLS;
+
+
+/**
+ * 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$
+ */
+public class ProtectedItemWrapper
+{
+    /** This map contains all possible protected item identifiers */
+    public static final Map<Class, String> classToIdentifierMap;
+    static
+    {
+        Map<Class, String> map = new HashMap<Class, String>();
+        map.put( ProtectedItem.Entry.class, "entry" ); //$NON-NLS-1$
+        map.put( ProtectedItem.AllUserAttributeTypes.class, "allUserAttributeTypes" ); //$NON-NLS-1$
+        map.put( ProtectedItem.AttributeType.class, "attributeType" ); //$NON-NLS-1$
+        map.put( ProtectedItem.AllAttributeValues.class, "allAttributeValues" ); //$NON-NLS-1$
+        map.put( ProtectedItem.AllUserAttributeTypesAndValues.class, "allUserAttributeTypesAndValues" ); //$NON-NLS-1$
+        map.put( ProtectedItem.AttributeValue.class, "attributeValue" ); //$NON-NLS-1$
+        map.put( ProtectedItem.SelfValue.class, "selfValue" ); //$NON-NLS-1$
+        map.put( ProtectedItem.RangeOfValues.class, "rangeOfValues" ); //$NON-NLS-1$
+        map.put( ProtectedItem.MaxValueCount.class, "maxValueCount" ); //$NON-NLS-1$
+        map.put( ProtectedItem.MaxImmSub.class, "maxImmSub" ); //$NON-NLS-1$
+        map.put( ProtectedItem.RestrictedBy.class, "restrictedBy" ); //$NON-NLS-1$
+        map.put( ProtectedItem.Classes.class, "classes" ); //$NON-NLS-1$
+        classToIdentifierMap = Collections.unmodifiableMap( map );
+    }
+
+    /** This map contains all protected item display values */
+    public static final Map<Class, String> classToDisplayMap;
+    static
+    {
+        Map<Class, String> map = new HashMap<Class, String>();
+        map.put( ProtectedItem.Entry.class, Messages
+            .getString( "ProtectedItemWrapper.protectedItem.entry.label" ) ); //$NON-NLS-1$
+        map.put( ProtectedItem.AllUserAttributeTypes.class, Messages
+            .getString( "ProtectedItemWrapper.protectedItem.allUserAttributeTypes.label" ) ); //$NON-NLS-1$
+        map.put( ProtectedItem.AttributeType.class, Messages
+            .getString( "ProtectedItemWrapper.protectedItem.attributeType.label" ) ); //$NON-NLS-1$
+        map.put( ProtectedItem.AllAttributeValues.class, Messages
+            .getString( "ProtectedItemWrapper.protectedItem.allAttributeValues.label" ) ); //$NON-NLS-1$
+        map.put( ProtectedItem.AllUserAttributeTypesAndValues.class, Messages
+            .getString( "ProtectedItemWrapper.protectedItem.allUserAttributeTypesAndValues.label" ) ); //$NON-NLS-1$
+        map.put( ProtectedItem.AttributeValue.class, Messages
+            .getString( "ProtectedItemWrapper.protectedItem.attributeValue.label" ) ); //$NON-NLS-1$
+        map.put( ProtectedItem.SelfValue.class, Messages
+            .getString( "ProtectedItemWrapper.protectedItem.selfValue.label" ) ); //$NON-NLS-1$
+        map.put( ProtectedItem.RangeOfValues.class, Messages
+            .getString( "ProtectedItemWrapper.protectedItem.rangeOfValues.label" ) ); //$NON-NLS-1$
+        map.put( ProtectedItem.MaxValueCount.class, Messages
+            .getString( "ProtectedItemWrapper.protectedItem.maxValueCount.label" ) ); //$NON-NLS-1$
+        map.put( ProtectedItem.MaxImmSub.class, Messages
+            .getString( "ProtectedItemWrapper.protectedItem.maxImmSub.label" ) ); //$NON-NLS-1$
+        map.put( ProtectedItem.RestrictedBy.class, Messages
+            .getString( "ProtectedItemWrapper.protectedItem.restrictedBy.label" ) ); //$NON-NLS-1$
+        map.put( ProtectedItem.Classes.class, Messages
+            .getString( "ProtectedItemWrapper.protectedItem.classes.label" ) ); //$NON-NLS-1$
+        classToDisplayMap = Collections.unmodifiableMap( map );
+    }
+    
+    /** A dummy ACI to check syntax of the protectedItemValue */
+    private static final String DUMMY = "{ identificationTag \"id1\", precedence 1, authenticationLevel simple, " //$NON-NLS-1$
+        + "itemOrUserFirst itemFirst: { protectedItems  { #identifier# #values# }, " //$NON-NLS-1$
+        + "itemPermissions { { userClasses { allUsers }, grantsAndDenials { grantRead } } } } }"; //$NON-NLS-1$ 
+
+    /** The class of the protected item, never null. */
+    private final Class clazz;
+
+    /** The protected item values, may be empty. */
+    private List<String> values;
+
+    /** The value prefix, prepended to the value. */
+    private String valuePrefix;
+    
+    /** The value suffix, appended to the value. */
+    private String valueSuffix;
+    
+    /** The value editor, null means no value. */
+    private AbstractDialogStringValueEditor valueEditor;
+    
+    /** The multivalued. */
+    private boolean isMultivalued;
+    
+
+    /**
+     * Creates a new instance of ProtectedItemWrapper.
+     * 
+     * @param clazz the java class of the UserClass
+     * @param valuePrefix the identifier
+     * @param valueSuffix the dislpay name
+     * @param valueEditor the value editor
+     */
+    public ProtectedItemWrapper( Class clazz, boolean isMultivalued, String valuePrefix, String valueSuffix, AbstractDialogStringValueEditor valueEditor )
+    {
+        this.clazz = clazz;
+        this.isMultivalued = isMultivalued;
+        this.valuePrefix = valuePrefix;
+        this.valueSuffix = valueSuffix;
+        this.valueEditor = valueEditor;
+
+        this.values = new ArrayList<String>();
+    }
+    
+    
+    /**
+     * Creates a new protected item object. Therefore 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 the parsed protected item
+     * 
+     * @throws ParseException if parsing fails
+     */
+    public ProtectedItem getProtectedItem() throws ParseException
+    {
+        String flatValue = getFlatValue();
+        String spec = DUMMY;
+        spec = spec.replaceAll( "#identifier#", getIdentifier() ); //$NON-NLS-1$
+        spec = spec.replaceAll( "#values#", flatValue ); //$NON-NLS-1$
+        ACIItemParser parser = new ACIItemParser( null );
+        ItemFirstACIItem aci = null;
+        try
+        {
+            aci = ( ItemFirstACIItem ) parser.parse( spec );
+        }
+        catch ( ParseException e )
+        {
+
+            String msg = NLS
+                .bind(
+                    Messages.getString( "ProtectedItemWrapper.error.message" ), new String[] { getIdentifier(), flatValue } ); //$NON-NLS-1$
+            throw new ParseException( msg, 0 );
+        }
+        ProtectedItem item = ( ProtectedItem ) aci.getProtectedItems().iterator().next();
+        return item;
+    }
+    
+    
+    /**
+     * Sets the protected item.
+     * 
+     * @param item the protected item
+     */
+    public void setProtectedItem( ProtectedItem item )
+    {
+        assert item.getClass() == getClazz();
+
+        // first clear values
+        values.clear();
+
+        // switch on userClass type
+        // no value in ProtectedItem.Entry, ProtectedItem.AllUserAttributeTypes and ProtectedItem.AllUserAttributeTypesAndValues
+        if ( item.getClass() == ProtectedItem.AttributeType.class )
+        {
+            ProtectedItem.AttributeType at = ( ProtectedItem.AttributeType ) item;
+            for ( Iterator it = at.iterator(); it.hasNext(); )
+            {
+                values.add( it.next().toString() );
+            }
+        }
+        else if ( item.getClass() == ProtectedItem.AllAttributeValues.class )
+        {
+            ProtectedItem.AllAttributeValues aav = ( ProtectedItem.AllAttributeValues ) item;
+            for ( Iterator it = aav.iterator(); it.hasNext(); )
+            {
+                values.add( it.next().toString() );
+            }
+        }
+        else if ( item.getClass() == ProtectedItem.AttributeValue.class )
+        {
+            ProtectedItem.AttributeValue av = ( ProtectedItem.AttributeValue ) item;
+            for ( Iterator it = av.iterator(); it.hasNext(); )
+            {
+                Attribute attribute = ( Attribute ) it.next();
+                try
+                {
+                    values.add( attribute.getID() + "=" + attribute.get() );
+                }
+                catch ( NamingException e )
+                {
+                }
+            }
+        }
+        else if ( item.getClass() == ProtectedItem.SelfValue.class )
+        {
+            ProtectedItem.SelfValue sv = ( ProtectedItem.SelfValue ) item;
+            for ( Iterator it = sv.iterator(); it.hasNext(); )
+            {
+                values.add( it.next().toString() );
+            }
+        }
+        else if ( item.getClass() == ProtectedItem.RangeOfValues.class )
+        {
+            ProtectedItem.RangeOfValues rov = ( ProtectedItem.RangeOfValues ) item;
+            StringBuffer buffer = new StringBuffer();
+            rov.getFilter().printToBuffer( buffer );
+            values.add( buffer.toString() );
+        }
+        else if ( item.getClass() == ProtectedItem.MaxValueCount.class )
+        {
+            ProtectedItem.MaxValueCount mvc = ( ProtectedItem.MaxValueCount ) item;
+            for ( Iterator it = mvc.iterator(); it.hasNext(); )
+            {
+                ProtectedItem.MaxValueCountItem mvci = ( ProtectedItem.MaxValueCountItem ) it.next();
+                StringBuffer buffer = new StringBuffer();
+                mvci.printToBuffer( buffer );
+                values.add( buffer.toString() );
+            }
+        }
+        else if ( item.getClass() == ProtectedItem.MaxImmSub.class )
+        {
+            ProtectedItem.MaxImmSub mis = ( ProtectedItem.MaxImmSub ) item;
+            values.add( Integer.toString( mis.getValue() ) );
+        }
+        else if ( item.getClass() == ProtectedItem.RestrictedBy.class )
+        {
+            ProtectedItem.RestrictedBy rb = ( ProtectedItem.RestrictedBy ) item;
+            for ( Iterator it = rb.iterator(); it.hasNext(); )
+            {
+                ProtectedItem.RestrictedByItem rbi = ( ProtectedItem.RestrictedByItem ) it.next();
+                StringBuffer buffer = new StringBuffer();
+                rbi.printToBuffer( buffer );
+                values.add( buffer.toString() );
+            }
+        }
+        else if ( item.getClass() == ProtectedItem.Classes.class )
+        {
+            ProtectedItem.Classes classes = ( ProtectedItem.Classes ) item;
+            StringBuffer buffer = new StringBuffer();
+            classes.getClasses().printRefinementToBuffer( buffer );
+            values.add( buffer.toString() );
+        }
+
+    }
+    
+    
+    /**
+     * Returns a user-friedly string, displayed in the table.
+     * 
+     * @return the string
+     */
+    public String toString()
+    {
+        String flatValue = getFlatValue();
+        if ( flatValue.length() > 0 )
+        {
+            flatValue = flatValue.replace( '\r', ' ' );
+            flatValue = flatValue.replace( '\n', ' ' );
+            flatValue = ": " + flatValue; //$NON-NLS-1$
+            if ( flatValue.length() > 40 )
+            {
+                String temp = flatValue;
+                flatValue = temp.substring( 0, 20 );
+                flatValue = flatValue + "..."; //$NON-NLS-1$
+                flatValue = flatValue + temp.substring( temp.length() - 20, temp.length() );
+            }
+        }
+
+        return getDisplayName() + " " + flatValue; //$NON-NLS-1$
+    }
+    
+    
+    /**
+     * Returns the flat value.
+     * 
+     * @return the flat value
+     */
+    private String getFlatValue()
+    {
+        if ( valueEditor == null || values.isEmpty() )
+        {
+            return ""; //$NON-NLS-1$
+        }
+
+        StringBuffer sb = new StringBuffer();
+        if(isMultivalued())
+        {
+            sb.append( "{ " ); //$NON-NLS-1$
+        }
+        for ( Iterator<String> it = values.iterator(); it.hasNext(); )
+        {
+            sb.append( valuePrefix );
+            String value = it.next();
+            sb.append( value );
+            sb.append( valueSuffix );
+            if ( it.hasNext() )
+            {
+                sb.append( ", " ); //$NON-NLS-1$
+            }
+        }
+        if(isMultivalued())
+        {
+            sb.append( " }" ); //$NON-NLS-1$
+        }
+        return sb.toString();
+    }
+    
+    
+    /**
+     * Returns the list of values, may be modified.
+     * 
+     * @return the modifyable list of values.
+     */
+    public List<String> getValues()
+    {
+        return values;
+    }
+    
+    
+    /**
+     * Gets the display name.
+     * 
+     * @return the display name
+     */
+    public String getDisplayName()
+    {
+        return classToDisplayMap.get( clazz );
+    }
+
+
+
+    /**
+     * Gets the identifier.
+     * 
+     * @return the identifier
+     */
+    public String getIdentifier()
+    {
+        return classToIdentifierMap.get( clazz );
+    }
+
+
+
+    /**
+     * Returns the class of the user class.
+     * 
+     * @return the class of the user class.
+     */
+    public Class getClazz()
+    {
+        return clazz;
+    }
+
+    
+    /**
+     * Checks if is editable.
+     * 
+     * @return true, if is editable
+     */
+    public boolean isEditable()
+    {
+        return valueEditor != null;
+    }
+
+
+
+    /**
+     * Gets the value editor.
+     * 
+     * @return the value editor, may be null.
+     */
+    public AbstractDialogStringValueEditor getValueEditor()
+    {
+        return valueEditor;
+    }
+
+
+    /**
+     * Checks if is multivalued.
+     * 
+     * @return true, if is multivalued
+     */
+    public boolean isMultivalued()
+    {
+        return isMultivalued;
+    }
+}

Added: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/ProtectedItemWrapperFactory.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/ProtectedItemWrapperFactory.java?view=auto&rev=493883
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/ProtectedItemWrapperFactory.java (added)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/ProtectedItemWrapperFactory.java Sun Jan  7 16:07:36 2007
@@ -0,0 +1,139 @@
+
+package org.apache.directory.ldapstudio.aciitemeditor.model;
+
+import org.apache.directory.ldapstudio.browser.ui.valueeditors.internal.TextValueEditor;
+import org.apache.directory.shared.ldap.aci.ProtectedItem;
+
+public class ProtectedItemWrapperFactory
+{
+    
+    public static final ProtectedItemWrapper[] createProtectedItemWrappers()
+    {
+        ProtectedItemWrapper[] protectedItemWrappers = new ProtectedItemWrapper[]
+            { 
+                // entry
+                new ProtectedItemWrapper
+                ( 
+                    ProtectedItem.Entry.class, 
+                    false,
+                    "",  //$NON-NLS-1$
+                    "", //$NON-NLS-1$
+                    null 
+                ),
+                
+                // allUserAttributeTypes
+                new ProtectedItemWrapper
+                ( 
+                    ProtectedItem.AllUserAttributeTypes.class, 
+                    false,
+                    "",  //$NON-NLS-1$
+                    "", //$NON-NLS-1$
+                    null 
+                ),
+                
+                // attributeType { 1.2.3, cn }
+                new ProtectedItemWrapper
+                ( 
+                    ProtectedItem.AttributeType.class, 
+                    true,
+                    "",  //$NON-NLS-1$
+                    "", //$NON-NLS-1$
+                    new TextValueEditor() // TODO: AttributeTypeValueEditor
+                ),
+                
+                // allAttributeValues { 1.2.3, cn }
+                new ProtectedItemWrapper
+                ( 
+                    ProtectedItem.AllAttributeValues.class, 
+                    true,
+                    "",  //$NON-NLS-1$
+                    "", //$NON-NLS-1$
+                    new TextValueEditor() // TODO: AttributeTypeValueEditor
+                ),
+                
+                // attributeType
+                new ProtectedItemWrapper
+                ( 
+                    ProtectedItem.AllUserAttributeTypesAndValues.class, 
+                    false,
+                    "",  //$NON-NLS-1$
+                    "", //$NON-NLS-1$
+                    null 
+                ),
+                
+                // attributeValue { ou=people, cn=Ersin }
+                new ProtectedItemWrapper
+                ( 
+                    ProtectedItem.AttributeValue.class, 
+                    true,
+                    "",  //$NON-NLS-1$
+                    "", //$NON-NLS-1$
+                    new TextValueEditor() // TODO: AttributeTypeAndValueValueEditor
+                ),
+                
+                // selfValue { 1.2.3, cn }
+                new ProtectedItemWrapper
+                ( 
+                    ProtectedItem.SelfValue.class, 
+                    true,
+                    "",  //$NON-NLS-1$
+                    "", //$NON-NLS-1$
+                    new TextValueEditor() // TODO: AttributeTypeValueEditor
+                ),
+                
+                // rangeOfValues (cn=E*)
+                new ProtectedItemWrapper
+                ( 
+                    ProtectedItem.RangeOfValues.class, 
+                    false,
+                    "",  //$NON-NLS-1$
+                    "", //$NON-NLS-1$
+                    new TextValueEditor() 
+                ),
+                
+                // maxValueCount { { type 10.11.12, maxCount 10 }, { maxCount 20, type 11.12.13  } }
+                new ProtectedItemWrapper
+                ( 
+                    ProtectedItem.MaxValueCount.class, 
+                    true,
+                    "",  //$NON-NLS-1$
+                    "", //$NON-NLS-1$
+                    new TextValueEditor() // TODO: MaxValueCountValueEditor
+                ),
+                
+                // maxImmSub 3
+                new ProtectedItemWrapper
+                ( 
+                    ProtectedItem.MaxImmSub.class, 
+                    false,
+                    "",  //$NON-NLS-1$
+                    "", //$NON-NLS-1$
+                    new TextValueEditor() // TODO: IntegerValueEditor
+                ),
+                
+                // restrictedBy { { type 10.11.12, valuesIn ou }, { valuesIn cn, type 11.12.13  } }
+                new ProtectedItemWrapper
+                ( 
+                    ProtectedItem.RestrictedBy.class, 
+                    true,
+                    "",  //$NON-NLS-1$
+                    "", //$NON-NLS-1$
+                    new TextValueEditor() // TODO: RestrictedByValueEditor
+                ),
+                
+                // classes and : { item: xyz , or:{item:X,item:Y}   }
+                new ProtectedItemWrapper
+                ( 
+                    ProtectedItem.Classes.class, 
+                    false,
+                    "",  //$NON-NLS-1$
+                    "", //$NON-NLS-1$
+                    new TextValueEditor() // TODO: RefinementValueEditor 
+                ),
+                
+            };
+        
+        return protectedItemWrappers;
+    }
+    
+}

Added: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/UserClassWrapper.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/UserClassWrapper.java?view=auto&rev=493883
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/UserClassWrapper.java (added)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/UserClassWrapper.java Sun Jan  7 16:07:36 2007
@@ -0,0 +1,301 @@
+package org.apache.directory.ldapstudio.aciitemeditor.model;
+
+
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.naming.Name;
+
+import org.apache.directory.ldapstudio.browser.ui.valueeditors.AbstractDialogStringValueEditor;
+import org.apache.directory.shared.ldap.aci.ACIItemParser;
+import org.apache.directory.shared.ldap.aci.UserClass;
+import org.apache.directory.shared.ldap.aci.UserFirstACIItem;
+import org.apache.directory.shared.ldap.subtree.SubtreeSpecification;
+import org.eclipse.osgi.util.NLS;
+
+
+/**
+ * The UserClassWrapper is used as input for the table viewer.
+ * The user class values are always stored as raw string values.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class UserClassWrapper
+{
+
+    /** This map contains all possible user class identifiers */
+    public static final Map<Class, String> classToIdentifierMap;
+    static
+    {
+        Map<Class, String> map = new HashMap<Class, String>();
+        map.put( UserClass.AllUsers.class, "allUsers" ); //$NON-NLS-1$
+        map.put( UserClass.ThisEntry.class, "thisEntry" ); //$NON-NLS-1$
+        map.put( UserClass.Name.class, "name" ); //$NON-NLS-1$
+        map.put( UserClass.UserGroup.class, "userGroup" ); //$NON-NLS-1$
+        map.put( UserClass.Subtree.class, "subtree" ); //$NON-NLS-1$
+        classToIdentifierMap = Collections.unmodifiableMap( map );
+    }
+
+    /** This map contains all user class display values */
+    public static final Map<Class, String> classToDisplayMap;
+    static
+    {
+        Map<Class, String> map = new HashMap<Class, String>();
+        map.put( UserClass.AllUsers.class, Messages.getString( "UserClassWrapper.userClass.allUsers.label" ) ); //$NON-NLS-1$
+        map.put( UserClass.ThisEntry.class, Messages.getString( "UserClassWrapper.userClass.thisEntry.label" ) ); //$NON-NLS-1$
+        map.put( UserClass.Name.class, Messages.getString( "UserClassWrapper.userClass.name.label" ) ); //$NON-NLS-1$
+        map.put( UserClass.UserGroup.class, Messages.getString( "UserClassWrapper.userClass.userGroup.label" ) ); //$NON-NLS-1$
+        map.put( UserClass.Subtree.class, Messages.getString( "UserClassWrapper.userClass.subtree.label" ) ); //$NON-NLS-1$
+        classToDisplayMap = Collections.unmodifiableMap( map );
+    }
+
+    /** A dummy ACI to check syntax of the userClassValue. */
+    private static final String DUMMY = "{ identificationTag \"id1\", precedence 1, authenticationLevel simple, " //$NON-NLS-1$
+        + "itemOrUserFirst userFirst: { userClasses  { #identifier# #values# }, " //$NON-NLS-1$
+        + "userPermissions { { protectedItems { entry }, grantsAndDenials { grantRead } } } } }"; //$NON-NLS-1$
+
+    /** The class of the user class, never null. */
+    private final Class clazz;
+
+    /** The user class values, may be empty. */
+    private List<String> values;
+
+    /** The value prefix, prepended to the value. */
+    private String valuePrefix;
+
+    /** The value suffix, appended to the value. */
+    private String valueSuffix;
+
+    /** The value editor, null means no value. */
+    private AbstractDialogStringValueEditor valueEditor;
+
+
+    /**
+     * Creates a new instance of UserClassWrapper.
+     * 
+     * @param clazz the java class of the UserClass
+     * @param valuePrefix the identifier
+     * @param valueSuffix the dislpay name
+     * @param valueEditor the value editor
+     */
+    public UserClassWrapper( Class clazz, String valuePrefix, String valueSuffix,
+        AbstractDialogStringValueEditor valueEditor )
+    {
+        this.clazz = clazz;
+        this.valuePrefix = valuePrefix;
+        this.valueSuffix = valueSuffix;
+        this.valueEditor = valueEditor;
+
+        this.values = new ArrayList<String>();
+    }
+
+
+    /**
+     * Creates a new user class object. Therefore it uses the 
+     * dummy ACI, injects the user class and its value, parses
+     * the ACI and extracts the user class from the parsed bean.
+     * 
+     * @return the parsed user class
+     * 
+     * @throws ParseException if parsing fails
+     */
+    public UserClass getUserClass() throws ParseException
+    {
+        String flatValue = getFlatValue();
+        String spec = DUMMY;
+        spec = spec.replaceAll( "#identifier#", getIdentifier() ); //$NON-NLS-1$
+        spec = spec.replaceAll( "#values#", flatValue ); //$NON-NLS-1$
+        ACIItemParser parser = new ACIItemParser( null );
+        UserFirstACIItem aci = null;
+        try
+        {
+            aci = ( UserFirstACIItem ) parser.parse( spec );
+        }
+        catch ( ParseException e )
+        {
+            String msg = NLS.bind(
+                Messages.getString( "UserClassWrapper.error.message" ), new String[] { getIdentifier(), flatValue } ); //$NON-NLS-1$
+            throw new ParseException( msg, 0 );
+        }
+        UserClass userClass = ( UserClass ) aci.getUserClasses().iterator().next();
+        return userClass;
+    }
+
+
+    /**
+     * Sets the user class.
+     * 
+     * @param userClass the user class
+     */
+    public void setUserClass( UserClass userClass )
+    {
+        assert userClass.getClass() == getClazz();
+
+        // first clear values
+        values.clear();
+
+        // switch on userClass type
+        // no value in UserClass.AllUsers and UserClass.ThisEntry
+        if ( userClass.getClass() == UserClass.Name.class )
+        {
+            UserClass.Name name = ( UserClass.Name ) userClass;
+            Set<Name> jndiNames = name.getNames();
+            for ( Name jndiName : jndiNames )
+            {
+                values.add( jndiName.toString() );
+            }
+        }
+        else if ( userClass.getClass() == UserClass.UserGroup.class )
+        {
+            UserClass.UserGroup userGrops = ( UserClass.UserGroup ) userClass;
+            Set<Name> jndiNames = userGrops.getNames();
+            for ( Name jndiName : jndiNames )
+            {
+                values.add( jndiName.toString() );
+            }
+        }
+        else if ( userClass.getClass() == UserClass.Subtree.class )
+        {
+            UserClass.Subtree subtree = ( UserClass.Subtree ) userClass;
+            Collection<SubtreeSpecification> subtreeSpecifications = subtree.getSubtreeSpecifications();
+            for ( SubtreeSpecification subtreeSpecification : subtreeSpecifications )
+            {
+                StringBuffer buffer = new StringBuffer();
+                subtreeSpecification.printToBuffer( buffer );
+                String s = buffer.toString();
+                values.add( s );
+            }
+        }
+    }
+
+
+    /**
+     * Returns a user-friedly string, displayed in the table.
+     * 
+     * @return the string
+     */
+    public String toString()
+    {
+        String flatValue = getFlatValue();
+        if ( flatValue.length() > 0 )
+        {
+            flatValue = flatValue.replace( '\r', ' ' );
+            flatValue = flatValue.replace( '\n', ' ' );
+            flatValue = ": " + flatValue; //$NON-NLS-1$
+            if ( flatValue.length() > 40 )
+            {
+                String temp = flatValue;
+                flatValue = temp.substring( 0, 20 );
+                flatValue = flatValue + "..."; //$NON-NLS-1$
+                flatValue = flatValue + temp.substring( temp.length() - 20, temp.length() );
+            }
+        }
+
+        return getDisplayName() + " " + flatValue; //$NON-NLS-1$
+    }
+
+
+    /**
+     * Returns the flat value.
+     * 
+     * @return the flat value
+     */
+    private String getFlatValue()
+    {
+        if ( valueEditor == null || values.isEmpty() )
+        {
+            return ""; //$NON-NLS-1$
+        }
+
+        StringBuffer sb = new StringBuffer();
+        sb.append( "{ " ); //$NON-NLS-1$
+        for ( Iterator<String> it = values.iterator(); it.hasNext(); )
+        {
+            sb.append( valuePrefix );
+            String value = it.next();
+            sb.append( value );
+            sb.append( valueSuffix );
+            if ( it.hasNext() )
+            {
+                sb.append( ", " ); //$NON-NLS-1$
+            }
+        }
+        sb.append( " }" ); //$NON-NLS-1$
+        return sb.toString();
+    }
+
+
+    /**
+     * Returns the list of values, may be modified.
+     * 
+     * @return the modifyable list of values.
+     */
+    public List<String> getValues()
+    {
+        return values;
+    }
+
+
+    /**
+     * Gets the display name.
+     * 
+     * @return the display name
+     */
+    public String getDisplayName()
+    {
+        return classToDisplayMap.get( clazz );
+    }
+
+
+    /**
+     * Gets the identifier.
+     * 
+     * @return the identifier
+     */
+    public String getIdentifier()
+    {
+        return classToIdentifierMap.get( clazz );
+    }
+
+
+    /**
+     * Returns the class of the user class.
+     * 
+     * @return the class of the user class.
+     */
+    public Class getClazz()
+    {
+        return clazz;
+    }
+
+
+    /**
+     * Checks if is editable.
+     * 
+     * @return true, if is editable
+     */
+    public boolean isEditable()
+    {
+        return valueEditor != null;
+    }
+
+
+    /**
+     * Gets the value editor.
+     * 
+     * @return the value editor, may be null.
+     */
+    public AbstractDialogStringValueEditor getValueEditor()
+    {
+        return valueEditor;
+    }
+
+}

Added: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/UserClassWrapperFactory.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/UserClassWrapperFactory.java?view=auto&rev=493883
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/UserClassWrapperFactory.java (added)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/model/UserClassWrapperFactory.java Sun Jan  7 16:07:36 2007
@@ -0,0 +1,66 @@
+
+package org.apache.directory.ldapstudio.aciitemeditor.model;
+
+import org.apache.directory.ldapstudio.browser.ui.valueeditors.internal.DnValueEditor;
+import org.apache.directory.ldapstudio.browser.ui.valueeditors.internal.TextValueEditor;
+import org.apache.directory.shared.ldap.aci.UserClass;
+
+public class UserClassWrapperFactory
+{
+    
+    
+    public static final UserClassWrapper[] createUserClassWrappers()
+    {
+        UserClassWrapper[] userClassWrappers = new UserClassWrapper[]
+            { 
+                // allUsers
+                new UserClassWrapper
+                ( 
+                    UserClass.AllUsers.class, 
+                    "",  //$NON-NLS-1$
+                    "", //$NON-NLS-1$
+                    null 
+                ),
+                
+                // thisEntry
+                new UserClassWrapper
+                ( 
+                    UserClass.ThisEntry.class, 
+                    "",  //$NON-NLS-1$
+                    "", //$NON-NLS-1$
+                    null 
+                ),
+                
+                // name
+                new UserClassWrapper
+                ( 
+                    UserClass.Name.class, 
+                    "\"",  //$NON-NLS-1$
+                    "\"", //$NON-NLS-1$
+                    new DnValueEditor() 
+                ),
+                
+                // userGroup
+                new UserClassWrapper
+                ( 
+                    UserClass.UserGroup.class, 
+                    "\"",  //$NON-NLS-1$
+                    "\"", //$NON-NLS-1$
+                    new DnValueEditor() 
+                ),
+                
+                // subtree
+                new UserClassWrapper
+                ( 
+                    UserClass.Subtree.class, 
+                    "",  //$NON-NLS-1$
+                    "", //$NON-NLS-1$
+                    new TextValueEditor() // TODO: SubtreeSpecificationValueEditor
+                )
+            };
+        
+        return userClassWrappers;
+    }
+    
+    
+}

Modified: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemItemPermissionsComposite.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemItemPermissionsComposite.java?view=diff&rev=493883&r1=493882&r2=493883
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemItemPermissionsComposite.java (original)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemItemPermissionsComposite.java Sun Jan  7 16:07:36 2007
@@ -25,9 +25,11 @@
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.directory.ldapstudio.aciitemeditor.ACIItemValueWithContext;
 import org.apache.directory.ldapstudio.aciitemeditor.Activator;
 import org.apache.directory.ldapstudio.aciitemeditor.dialogs.ItemPermissionDialog;
 import org.apache.directory.ldapstudio.aciitemeditor.dialogs.TextDialog;
+import org.apache.directory.ldapstudio.aciitemeditor.model.UserClassWrapper;
 import org.apache.directory.shared.ldap.aci.GrantAndDenial;
 import org.apache.directory.shared.ldap.aci.ItemPermission;
 import org.apache.directory.shared.ldap.aci.UserClass;
@@ -58,6 +60,9 @@
  */
 public class ACIItemItemPermissionsComposite extends Composite
 {
+    
+    /** The context. */
+    private ACIItemValueWithContext context;
 
     /** The inner composite for all the content */
     private Composite composite = null;
@@ -77,10 +82,10 @@
     /** The add button */
     private Button addButton = null;
 
-    /** The select all button */
+    /** The edit button */
     private Button editButton = null;
 
-    /** The deselect all button */
+    /** The delete button */
     private Button deleteButton = null;
 
     /** The selected item permissions, input of the table viewer */
@@ -132,7 +137,7 @@
                     .hasNext(); )
                 {
                     UserClass uc = it.next();
-                    String s = ACIItemUserClassesComposite.UserClassWrapper.classToDisplayMap.get( uc.getClass() );
+                    String s = UserClassWrapper.classToDisplayMap.get( uc.getClass() );
                     buffer.append( s );
 
                     if ( it.hasNext() )
@@ -363,6 +368,17 @@
 
 
     /**
+     * Sets the context.
+     * 
+     * @param context the context
+     */
+    public void setContext( ACIItemValueWithContext context ) 
+    {
+        this.context = context;
+    }
+    
+    
+    /**
      * Sets the item permissions. 
      *
      * @param itemPermissions
@@ -428,7 +444,7 @@
      */
     private void addItemPermission()
     {
-        ItemPermissionDialog dialog = new ItemPermissionDialog( getShell(), null );
+        ItemPermissionDialog dialog = new ItemPermissionDialog( getShell(), null, context );
         if ( dialog.open() == TextDialog.OK && dialog.getItemPermission() != null )
         {
             ItemPermissionWrapper itemPermissionWrapper = new ItemPermissionWrapper( dialog.getItemPermission() );
@@ -448,7 +464,7 @@
         ItemPermissionWrapper oldItemPermissionWrapper = getSelectedItemPermissionWrapper();
         if ( oldItemPermissionWrapper != null )
         {
-            ItemPermissionDialog dialog = new ItemPermissionDialog( getShell(), oldItemPermissionWrapper.itemPermission );
+            ItemPermissionDialog dialog = new ItemPermissionDialog( getShell(), oldItemPermissionWrapper.itemPermission, context );
             if ( dialog.open() == TextDialog.OK )
             {
                 oldItemPermissionWrapper.itemPermission = dialog.getItemPermission();

Modified: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemProtectedItemsComposite.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemProtectedItemsComposite.java?view=diff&rev=493883&r1=493882&r2=493883
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemProtectedItemsComposite.java (original)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemProtectedItemsComposite.java Sun Jan  7 16:07:36 2007
@@ -24,16 +24,17 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
+import org.apache.directory.ldapstudio.aciitemeditor.ACIItemValueWithContext;
 import org.apache.directory.ldapstudio.aciitemeditor.Activator;
-import org.apache.directory.ldapstudio.aciitemeditor.dialogs.TextDialog;
-import org.apache.directory.shared.ldap.aci.ACIItemParser;
-import org.apache.directory.shared.ldap.aci.ItemFirstACIItem;
+import org.apache.directory.ldapstudio.aciitemeditor.dialogs.MultiValuedDialog;
+import org.apache.directory.ldapstudio.aciitemeditor.model.ProtectedItemWrapper;
+import org.apache.directory.ldapstudio.aciitemeditor.model.ProtectedItemWrapperFactory;
+import org.apache.directory.ldapstudio.browser.ui.valueeditors.AbstractDialogStringValueEditor;
 import org.apache.directory.shared.ldap.aci.ProtectedItem;
 import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CellEditor;
 import org.eclipse.jface.viewers.CheckStateChangedEvent;
 import org.eclipse.jface.viewers.CheckboxTableViewer;
 import org.eclipse.jface.viewers.DoubleClickEvent;
@@ -43,7 +44,6 @@
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.osgi.util.NLS;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
@@ -65,6 +65,9 @@
 public class ACIItemProtectedItemsComposite extends Composite
 {
 
+    /** The context. */
+    private ACIItemValueWithContext context;
+    
     /** The inner composite for all the content */
     private Composite composite = null;
 
@@ -93,171 +96,9 @@
     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
-            new ProtectedItemWrapper( ProtectedItem.AllUserAttributeTypes.class ), // null
-            new ProtectedItemWrapper( ProtectedItem.AttributeType.class ), // attributeType { 1.2.3, cn }
-            new ProtectedItemWrapper( ProtectedItem.AllAttributeValues.class ), // allAttributeValues { 1.2.3, cn }
-            new ProtectedItemWrapper( ProtectedItem.AllUserAttributeTypesAndValues.class ), // null
-            new ProtectedItemWrapper( ProtectedItem.AttributeValue.class ), // attributeValue { ou=people, cn=Ersin }
-            new ProtectedItemWrapper( ProtectedItem.SelfValue.class ), // selfValue { 1.2.3, cn }
-            new ProtectedItemWrapper( ProtectedItem.RangeOfValues.class ), // rangeOfValues (cn=ErsinEr)
-            new ProtectedItemWrapper( ProtectedItem.MaxValueCount.class ), // maxValueCount { { type 10.11.12, maxCount 10 }, { maxCount 20, type 11.12.13  } }
-            new ProtectedItemWrapper( ProtectedItem.MaxImmSub.class ), // maxImmSub 3
-            new ProtectedItemWrapper( ProtectedItem.RestrictedBy.class ), // restrictedBy { { type 10.11.12, valuesIn ou }, { valuesIn cn, type 11.12.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$
-     */
-    static class ProtectedItemWrapper
-    {
-        /** This map contains all possible protected item identifiers */
-        static final Map<Class, String> classToItemMap = new HashMap<Class, String>();
-        static
-        {
-            classToItemMap.put( ProtectedItem.Entry.class, "entry" ); //$NON-NLS-1$
-            classToItemMap.put( ProtectedItem.AllUserAttributeTypes.class, "allUserAttributeTypes" ); //$NON-NLS-1$
-            classToItemMap.put( ProtectedItem.AttributeType.class, "attributeType" ); //$NON-NLS-1$
-            classToItemMap.put( ProtectedItem.AllAttributeValues.class, "allAttributeValues" ); //$NON-NLS-1$
-            classToItemMap.put( ProtectedItem.AllUserAttributeTypesAndValues.class, "allUserAttributeTypesAndValues" ); //$NON-NLS-1$
-            classToItemMap.put( ProtectedItem.AttributeValue.class, "attributeValue" ); //$NON-NLS-1$
-            classToItemMap.put( ProtectedItem.SelfValue.class, "selfValue" ); //$NON-NLS-1$
-            classToItemMap.put( ProtectedItem.RangeOfValues.class, "rangeOfValues" ); //$NON-NLS-1$
-            classToItemMap.put( ProtectedItem.MaxValueCount.class, "maxValueCount" ); //$NON-NLS-1$
-            classToItemMap.put( ProtectedItem.MaxImmSub.class, "maxImmSub" ); //$NON-NLS-1$
-            classToItemMap.put( ProtectedItem.RestrictedBy.class, "restrictedBy" ); //$NON-NLS-1$
-            classToItemMap.put( ProtectedItem.Classes.class, "classes" ); //$NON-NLS-1$
-        }
-
-        /** This map contains all protected item display values */
-        static final Map<Class, String> classToDisplayMap = new HashMap<Class, String>();
-        static
-        {
-            classToDisplayMap.put( ProtectedItem.Entry.class, Messages
-                .getString( "ACIItemProtectedItemsComposite.protectedItem.entry.label" ) ); //$NON-NLS-1$
-            classToDisplayMap.put( ProtectedItem.AllUserAttributeTypes.class, Messages
-                .getString( "ACIItemProtectedItemsComposite.protectedItem.allUserAttributeTypes.label" ) ); //$NON-NLS-1$
-            classToDisplayMap.put( ProtectedItem.AttributeType.class, Messages
-                .getString( "ACIItemProtectedItemsComposite.protectedItem.attributeType.label" ) ); //$NON-NLS-1$
-            classToDisplayMap.put( ProtectedItem.AllAttributeValues.class, Messages
-                .getString( "ACIItemProtectedItemsComposite.protectedItem.allAttributeValues.label" ) ); //$NON-NLS-1$
-            classToDisplayMap.put( ProtectedItem.AllUserAttributeTypesAndValues.class, Messages
-                .getString( "ACIItemProtectedItemsComposite.protectedItem.allUserAttributeTypesAndValues.label" ) ); //$NON-NLS-1$
-            classToDisplayMap.put( ProtectedItem.AttributeValue.class, Messages
-                .getString( "ACIItemProtectedItemsComposite.protectedItem.attributeValue.label" ) ); //$NON-NLS-1$
-            classToDisplayMap.put( ProtectedItem.SelfValue.class, Messages
-                .getString( "ACIItemProtectedItemsComposite.protectedItem.selfValue.label" ) ); //$NON-NLS-1$
-            classToDisplayMap.put( ProtectedItem.RangeOfValues.class, Messages
-                .getString( "ACIItemProtectedItemsComposite.protectedItem.rangeOfValues.label" ) ); //$NON-NLS-1$
-            classToDisplayMap.put( ProtectedItem.MaxValueCount.class, Messages
-                .getString( "ACIItemProtectedItemsComposite.protectedItem.maxValueCount.label" ) ); //$NON-NLS-1$
-            classToDisplayMap.put( ProtectedItem.MaxImmSub.class, Messages
-                .getString( "ACIItemProtectedItemsComposite.protectedItem.maxImmSub.label" ) ); //$NON-NLS-1$
-            classToDisplayMap.put( ProtectedItem.RestrictedBy.class, Messages
-                .getString( "ACIItemProtectedItemsComposite.protectedItem.restrictedBy.label" ) ); //$NON-NLS-1$
-            classToDisplayMap.put( ProtectedItem.Classes.class, Messages
-                .getString( "ACIItemProtectedItemsComposite.protectedItem.classes.label" ) ); //$NON-NLS-1$
-        }
-
-        /** A dummy ACI to check syntax of the protectedItemValue */
-        private static final String DUMMY = "{ identificationTag \"id1\", precedence 1, authenticationLevel simple, " //$NON-NLS-1$
-            + "itemOrUserFirst itemFirst: { protectedItems  { #item# #value# }, " //$NON-NLS-1$
-            + "itemPermissions { { userClasses { allUsers }, grantsAndDenials { grantRead } } } } }"; //$NON-NLS-1$ 
-
-        /** The class of the protected item, never null. */
-        private final Class protectedItemClass;
-
-        /** The protected item as string, may be empty. */
-        private String protectedItemValue;
-
-
-        /**
-         * Creates a new instance of ProtectedItemWrapper.
-         *
-         * @param protectedItemClass
-         */
-        private ProtectedItemWrapper( Class protectedItemClass )
-        {
-            this.protectedItemClass = protectedItemClass;
-            this.protectedItemValue = ""; //$NON-NLS-1$
-        }
-
-
-        /**
-         * Creates a new protected item object. Therefore 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 = classToItemMap.get( protectedItemClass );
-            String spec = DUMMY;
-            spec = spec.replaceAll( "#item#", type ); //$NON-NLS-1$
-            spec = spec.replaceAll( "#value#", protectedItemValue ); //$NON-NLS-1$
-            ACIItemParser parser = Activator.getDefault().getACIItemParser();
-            ItemFirstACIItem aci = null;
-            try
-            {
-                aci = ( ItemFirstACIItem ) parser.parse( spec );
-            }
-            catch ( ParseException e )
-            {
-
-                String msg = NLS
-                    .bind(
-                        Messages.getString( "ACIItemProtectedItemsComposite.error.message" ), new String[] { type, protectedItemValue } ); //$NON-NLS-1$
-                throw new ParseException( msg, 0 );
-            }
-            ProtectedItem item = ( ProtectedItem ) aci.getProtectedItems().iterator().next();
-            return item;
-        }
-
-
-        /**
-         * Returns a user-friedly string, displayed in the table.
-         */
-        public String toString()
-        {
-            String string = classToDisplayMap.get( protectedItemClass );
-            if ( string == null )
-                string = "<UNKNOWN>"; //$NON-NLS-1$
-            return string + getProtectedItemValue();
-        }
-
-
-        /**
-         * Helper to format the value
-         */
-        private String getProtectedItemValue()
-        {
-            String s = protectedItemValue;
-            if ( s.length() > 0 )
-            {
-                s = s.replace( '\r', ' ' );
-                s = s.replace( '\n', ' ' );
-                s = ": " + s; //$NON-NLS-1$
-                if ( s.length() > 40 )
-                {
-                    String temp = s;
-                    s = temp.substring( 0, 20 );
-                    s = s + "..."; //$NON-NLS-1$
-                    s = s + temp.substring( temp.length() - 20, temp.length() );
-                }
-            }
-            return s;
-        }
-    }
-
-
+    private ProtectedItemWrapper[] protectedItemWrappers = ProtectedItemWrapperFactory.createProtectedItemWrappers(); 
+        
+        
     /**
      * Creates a new instance of ACIItemProtectedItemsComposite.
      *
@@ -500,6 +341,17 @@
         }
     }
 
+    
+    /**
+     * Sets the context.
+     * 
+     * @param context the context
+     */
+    public void setContext( ACIItemValueWithContext context ) 
+    {
+        this.context = context;
+    }
+    
 
     /**
      * Sets the protected items. 
@@ -508,20 +360,20 @@
      */
     public void setProtectedItems( Collection<ProtectedItem> protectedItems )
     {
+        // reset first
+        for ( ProtectedItemWrapper protectedItemWrapper : protectedItemWrappers )
+        {
+            tableViewer.setChecked( protectedItemWrapper, false );
+        }
+
         for ( ProtectedItem item : protectedItems )
         {
             for ( ProtectedItemWrapper protectedItemWrapper : protectedItemWrappers )
             {
-                if ( protectedItemWrapper.protectedItemClass == item.getClass() )
+                
+                if ( protectedItemWrapper.getClazz() == 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;
-                    }
+                    protectedItemWrapper.setProtectedItem( item );
                     tableViewer.setChecked( protectedItemWrapper, true );
                 }
             }
@@ -598,9 +450,7 @@
     {
         ProtectedItemWrapper protectedItemWrapper = getSelectedProtectedItemWrapper();
 
-        if ( protectedItemWrapper == null || protectedItemWrapper.protectedItemClass == ProtectedItem.Entry.class
-            || protectedItemWrapper.protectedItemClass == ProtectedItem.AllUserAttributeTypes.class
-            || protectedItemWrapper.protectedItemClass == ProtectedItem.AllUserAttributeTypesAndValues.class )
+        if ( protectedItemWrapper == null || !protectedItemWrapper.isEditable() )
         {
             editButton.setEnabled( false );
         }
@@ -627,12 +477,40 @@
     private void editProtectedItem()
     {
         ProtectedItemWrapper protectedItemWrapper = getSelectedProtectedItemWrapper();
-
-        TextDialog dialog = new TextDialog( getShell(), protectedItemWrapper.protectedItemValue );
-        if ( dialog.open() == TextDialog.OK )
+        
+        AbstractDialogStringValueEditor valueEditor = protectedItemWrapper.getValueEditor();
+        if(valueEditor != null)
         {
-            protectedItemWrapper.protectedItemValue = dialog.getText();
-            refreshTable();
+            if(protectedItemWrapper.isMultivalued())
+            {
+                MultiValuedDialog dialog = new MultiValuedDialog( getShell(), protectedItemWrapper.getDisplayName(), protectedItemWrapper.getValues(), context, valueEditor );
+                dialog.open();
+                refreshTable();
+            }
+            else
+            {
+                List<String> values = protectedItemWrapper.getValues();
+                String oldValue = values.isEmpty() ? null : values.get( 0 );
+                if ( oldValue == null )
+                {
+                    oldValue = "";
+                }
+                Object oldRawValue = valueEditor.getRawValue( context.getConnection(), oldValue );
+                
+                CellEditor cellEditor = valueEditor.getCellEditor();
+                cellEditor.setValue( oldRawValue );
+                cellEditor.activate();
+                Object newRawValue = cellEditor.getValue();
+                
+                if(newRawValue != null) 
+                {
+                    String newValue = (String) valueEditor.getStringOrBinaryValue( newRawValue );
+                    
+                    values.clear();
+                    values.add( newValue );
+                    tableViewer.refresh();
+                }
+            }
         }
     }
     
@@ -644,5 +522,6 @@
     {
         tableViewer.refresh();
     }
+
 
 }



Mime
View raw message