directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r491293 [3/3] - in /directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor: ./ META-INF/ icons/ lib/ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/directory/ldapstudio/aciitemeditor/ ...
Date Sat, 30 Dec 2006 19:19:07 GMT
Modified: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemUserPermissionsComposite.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemUserPermissionsComposite.java?view=diff&rev=491293&r1=491291&r2=491293
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemUserPermissionsComposite.java
(original)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemUserPermissionsComposite.java
Sat Dec 30 11:19:04 2006
@@ -20,12 +20,12 @@
 package org.apache.directory.ldapstudio.aciitemeditor.widgets;
 
 
-import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.directory.ldapstudio.aciitemeditor.Activator;
 import org.apache.directory.ldapstudio.aciitemeditor.dialogs.TextDialog;
 import org.apache.directory.ldapstudio.aciitemeditor.dialogs.UserPermissionDialog;
 import org.apache.directory.shared.ldap.aci.GrantAndDenial;
@@ -51,8 +51,7 @@
 
 
 /**
- * This composite contains GUI elements to edit ACI item user permissions.
-
+ * This composite contains GUI elements to add, edit and delete ACI user permissions.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
@@ -62,37 +61,43 @@
 
     /** 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 user classes */
     private TableViewer tableViewer = null;
-    
+
     /** The composite containing the buttons */
     private Composite buttonComposite = null;
-    
+
     /** The add button */
     private Button addButton = null;
-    
+
     /** The select all button */
     private Button editButton = null;
-    
+
     /** The deselect all button */
     private Button deleteButton = null;
-    
+
     /** The selected user permissions, also input of the table viewer */
     List<UserPermissionWrapper> userPermissionWrappers = new ArrayList<UserPermissionWrapper>();
-    
-    
+
+    /**
+     * UserPermissionWrapper are used as input of the table viewer.
+     *
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     * @version $Rev$, $Date$
+     */
     private class UserPermissionWrapper
     {
         /** The user permission bean. */
         private UserPermission userPermission;
-        
+
+
         /**
          * Creates a new instance of UserPermissionWrapper.
          *
@@ -102,85 +107,95 @@
         {
             this.userPermission = userPermission;
         }
-        
+
+
+        /**
+         * Returns a user-friedly string, displayed in the table.
+         */
         public String toString()
         {
-            return getUserPermissionValue();
-        }
-        private String getUserPermissionValue()
-        {
-            if(userPermission == null)
+            if ( userPermission == null )
             {
-                return "<UNKNOWN>";
+                return "<UNKNOWN>"; //$NON-NLS-1$
             }
-            else 
+            else
             {
                 StringBuffer buffer = new StringBuffer();
-                if(userPermission.getPrecedence() > -1)
+                if ( userPermission.getPrecedence() > -1 )
                 {
                     buffer.append( '(' );
                     buffer.append( userPermission.getPrecedence() );
                     buffer.append( ')' );
                     buffer.append( ' ' );
                 }
-                for(Iterator<ProtectedItem> it = ((Collection<ProtectedItem>)userPermission.getProtectedItems()).iterator();
it.hasNext(); )
+                for ( Iterator<ProtectedItem> it = ( ( Collection<ProtectedItem>
) userPermission.getProtectedItems() )
+                    .iterator(); it.hasNext(); )
                 {
                     ProtectedItem item = it.next();
-                    String s = ACIItemProtectedItemsComposite.ProtectedItemWrapper.classToDisplayMap.get(
item.getClass() );
+                    String s = ACIItemProtectedItemsComposite.ProtectedItemWrapper.classToDisplayMap.get(
item
+                        .getClass() );
                     buffer.append( s );
-                    
-                    if(it.hasNext())
+
+                    if ( it.hasNext() )
                     {
                         buffer.append( ',' );
                     }
                 }
-                buffer.append( ": " );
-                for(Iterator<GrantAndDenial> it = ((Collection<GrantAndDenial>)userPermission.getGrantsAndDenials()).iterator();
it.hasNext(); )
+                buffer.append( ':' );
+                buffer.append( ' ' );
+                for ( Iterator<GrantAndDenial> it = ( ( Collection<GrantAndDenial>
) userPermission
+                    .getGrantsAndDenials() ).iterator(); it.hasNext(); )
                 {
                     GrantAndDenial gd = it.next();
-                    String s = (gd.isGrant() ? "+" : "-") + gd.getMicroOperation().getName();
-                    buffer.append( s );
-                    
-                    if(it.hasNext())
+                    buffer.append( gd.isGrant() ? '+' : '-' );
+                    buffer.append( gd.getMicroOperation().getName() );
+
+                    if ( it.hasNext() )
                     {
                         buffer.append( ',' );
                     }
                 }
-                
+
                 String s = buffer.toString();
                 s = s.replace( '\r', ' ' );
                 s = s.replace( '\n', ' ' );
-                if(s.length() > 50)
+                if ( s.length() > 50 )
                 {
                     String temp = s;
                     s = temp.substring( 0, 25 );
-                    s = s + "...";
+                    s = s + "..."; //$NON-NLS-1$
                     s = s + temp.substring( temp.length() - 25, temp.length() );
                 }
                 return s;
             }
         }
     }
-    
-    
+
+
+    /**
+     * Creates a new instance of ACIItemUserPermissionsComposite.
+     *
+     * @param parent
+     * @param style
+     */
     public ACIItemUserPermissionsComposite( Composite parent, int style )
     {
         super( parent, style );
-        
+
         GridLayout layout = new GridLayout();
         layout.horizontalSpacing = 0;
         layout.verticalSpacing = 0;
         layout.marginHeight = 0;
         layout.marginWidth = 0;
         setLayout( layout );
-        
-        createComposite();
 
         GridData layoutData = new GridData();
         layoutData.horizontalAlignment = GridData.FILL;
         layoutData.grabExcessHorizontalSpace = true;
         layoutData.verticalAlignment = GridData.CENTER;
         setLayoutData( layoutData );
+
+        createComposite();
     }
 
 
@@ -190,33 +205,33 @@
      */
     private void createComposite()
     {
-        
+
         GridData labelGridData = new GridData();
         labelGridData.horizontalSpan = 2;
         labelGridData.verticalAlignment = GridData.CENTER;
         labelGridData.grabExcessHorizontalSpace = true;
         labelGridData.horizontalAlignment = GridData.FILL;
-        
+
         GridLayout gridLayout = new GridLayout();
         gridLayout.makeColumnsEqualWidth = false;
         gridLayout.numColumns = 2;
-        
+
         GridData gridData = new GridData();
         gridData.horizontalAlignment = GridData.FILL;
         gridData.grabExcessHorizontalSpace = true;
         gridData.verticalSpan = 1;
         gridData.verticalAlignment = GridData.BEGINNING;
-        
+
         composite = new Composite( this, SWT.NONE );
-        composite.setLayoutData(gridData);
-        composite.setLayout(gridLayout);
-        
-        label = new Label(composite, SWT.NONE);
-        label.setText("User Permissions:");
-        label.setLayoutData(labelGridData);
-        
+        composite.setLayoutData( gridData );
+        composite.setLayout( gridLayout );
+
+        label = new Label( composite, SWT.NONE );
+        label.setText( Messages.getString( "ACIItemUserPermissionsComposite.descripton" )
); //$NON-NLS-1$
+        label.setLayoutData( labelGridData );
+
         createTable();
-        
+
         createButtonComposite();
     }
 
@@ -249,16 +264,17 @@
                 userPermissionSelected();
             }
         } );
-        
-        tableViewer.addDoubleClickListener( new IDoubleClickListener(){
+
+        tableViewer.addDoubleClickListener( new IDoubleClickListener()
+        {
             public void doubleClick( DoubleClickEvent event )
             {
                 editUserPermission();
             }
         } );
     }
-    
-    
+
+
     /**
      * This method initializes buttons  
      *
@@ -269,17 +285,20 @@
         deleteButtonGridData.horizontalAlignment = GridData.FILL;
         deleteButtonGridData.grabExcessHorizontalSpace = false;
         deleteButtonGridData.verticalAlignment = GridData.BEGINNING;
-        
+        deleteButtonGridData.widthHint = Activator.getButtonWidth( this );
+
         GridData editButtonGridData = new GridData();
         editButtonGridData.horizontalAlignment = GridData.FILL;
         editButtonGridData.grabExcessHorizontalSpace = false;
         editButtonGridData.verticalAlignment = GridData.BEGINNING;
-        
+        editButtonGridData.widthHint = Activator.getButtonWidth( this );
+
         GridData addButtonGridData = new GridData();
         addButtonGridData.horizontalAlignment = GridData.FILL;
         addButtonGridData.grabExcessHorizontalSpace = false;
         addButtonGridData.verticalAlignment = GridData.BEGINNING;
-        
+        addButtonGridData.widthHint = Activator.getButtonWidth( this );
+
         GridLayout gridLayout = new GridLayout();
         gridLayout.marginWidth = 0;
         gridLayout.marginHeight = 0;
@@ -288,54 +307,61 @@
         gridData.grabExcessHorizontalSpace = false;
         gridData.grabExcessVerticalSpace = false;
         gridData.verticalAlignment = GridData.FILL;
-        
+
         buttonComposite = new Composite( composite, SWT.NONE );
-        buttonComposite.setLayoutData(gridData);
+        buttonComposite.setLayoutData( gridData );
         buttonComposite.setLayout( gridLayout );
-        
-        addButton = new Button(buttonComposite, SWT.NONE);
-        addButton.setText("Add...");
-        addButton.setLayoutData(addButtonGridData);
-        addButton.addSelectionListener( new SelectionAdapter(){
+
+        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 )
             {
                 addUserPermission();
             }
         } );
-        
-        editButton = new Button(buttonComposite, SWT.NONE);
-        editButton.setText("Edit...");
-        editButton.setLayoutData(editButtonGridData);
-        editButton.addSelectionListener( new SelectionAdapter(){
+
+        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 )
             {
                 editUserPermission();
             }
         } );
         editButton.setEnabled( false );
-        
-        deleteButton = new Button(buttonComposite, SWT.NONE);
-        deleteButton.setText("Delete");
-        deleteButton.setLayoutData(deleteButtonGridData);
-        deleteButton.addSelectionListener( new SelectionAdapter(){
+
+        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 )
             {
                 deleteUserPermission();
             }
         } );
         deleteButton.setEnabled( false );
-        
+
     }
-    
 
-    
+
+    /**
+     * 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;
+        ( ( GridData ) getLayoutData() ).heightHint = visible ? -1 : 0;
     }
-    
-    
+
+
     /**
      * Sets the user permissions. 
      *
@@ -343,24 +369,25 @@
      */
     public void setUserPermissions( Collection<UserPermission> userPermissions )
     {
+        userPermissionWrappers.clear();
+
         for ( UserPermission userPermission : userPermissions )
         {
-            UserPermissionWrapper userPermissionWrapper = new UserPermissionWrapper(userPermission);
-            
+            UserPermissionWrapper userPermissionWrapper = new UserPermissionWrapper( userPermission
);
+
             userPermissionWrappers.add( userPermissionWrapper );
         }
 
         tableViewer.refresh();
     }
 
-    
+
     /**
      * Returns the user permissions as selected by the user.
      *
      * @return the user permissions
-     * @throws ParseException 
      */
-    public Collection<UserPermission> getUserPermissions() throws ParseException
+    public Collection<UserPermission> getUserPermissions()
     {
         Collection<UserPermission> userPermissions = new ArrayList<UserPermission>();
 
@@ -371,74 +398,84 @@
 
         return userPermissions;
     }
-    
+
+
     /**
      * 
      * @return the user permission that is selected in the table viewer, or null.
      */
-    private UserPermissionWrapper getSelectedUserPermissionWrapper() 
+    private UserPermissionWrapper getSelectedUserPermissionWrapper()
     {
         UserPermissionWrapper userPermissionWrapper = null;
-        
+
         IStructuredSelection selection = ( IStructuredSelection ) tableViewer.getSelection();
         if ( !selection.isEmpty() )
         {
             Object element = selection.getFirstElement();
             if ( element instanceof UserPermissionWrapper )
             {
-                userPermissionWrapper = (UserPermissionWrapper) element;
+                userPermissionWrapper = ( UserPermissionWrapper ) element;
             }
         }
-        
+
         return userPermissionWrapper;
     }
-    
-    
-    private void addUserPermission() 
+
+
+    /**
+     * Opens the UserPermissionDialog and adds the composed 
+     * user permission to the list.
+     */
+    private void addUserPermission()
     {
         UserPermissionDialog dialog = new UserPermissionDialog( getShell(), null );
         if ( dialog.open() == TextDialog.OK && dialog.getUserPermission() != null
)
         {
-            UserPermissionWrapper userPermissionWrapper = new UserPermissionWrapper(dialog.getUserPermission());
+            UserPermissionWrapper userPermissionWrapper = new UserPermissionWrapper( dialog.getUserPermission()
);
             userPermissionWrappers.add( userPermissionWrapper );
-            
+
             tableViewer.refresh();
         }
     }
-    
-    
-    private void editUserPermission() 
+
+
+    /**
+     * Opens the UserPermissionDialog with the currently selected
+     * user permission and puts the modified user permission into the list.
+     */
+    private void editUserPermission()
     {
         UserPermissionWrapper oldUserPermissionWrapper = getSelectedUserPermissionWrapper();
-        if(oldUserPermissionWrapper != null)
+        if ( oldUserPermissionWrapper != null )
         {
             UserPermissionDialog dialog = new UserPermissionDialog( getShell(), oldUserPermissionWrapper.userPermission
);
             if ( dialog.open() == TextDialog.OK )
             {
-                // remove old
-                userPermissionWrappers.remove( oldUserPermissionWrapper );
-                
-                // create and add new
-                UserPermissionWrapper newUserPermissionWrapper = new UserPermissionWrapper(dialog.getUserPermission());
-                userPermissionWrappers.add( newUserPermissionWrapper );
-                
+                oldUserPermissionWrapper.userPermission = dialog.getUserPermission();
                 tableViewer.refresh();
             }
         }
     }
-    
-    
-    private void deleteUserPermission() 
+
+
+    /**
+     * Deletes the currently selected user permission from list.
+     */
+    private void deleteUserPermission()
     {
         UserPermissionWrapper userPermissionWrapper = getSelectedUserPermissionWrapper();
-        if(userPermissionWrapper != null)
+        if ( userPermissionWrapper != null )
         {
             userPermissionWrappers.remove( userPermissionWrapper );
             tableViewer.refresh();
         }
     }
-    
-    
+
+
+    /**
+     * Called when an user permission is selected in table viewer.
+     * Updates the enabled/disabled state of the buttons.
+     */
     private void userPermissionSelected()
     {
         UserPermissionWrapper userPermissionWrapper = getSelectedUserPermissionWrapper();

Added: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemVisualEditorComposite.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemVisualEditorComposite.java?view=auto&rev=491293
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemVisualEditorComposite.java
(added)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemVisualEditorComposite.java
Sat Dec 30 11:19:04 2006
@@ -0,0 +1,269 @@
+/*
+ *  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.widgets;
+
+
+import java.text.ParseException;
+import java.util.Collection;
+
+import org.apache.directory.shared.ldap.aci.ACIItem;
+import org.apache.directory.shared.ldap.aci.ACIItemParser;
+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.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+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;
+
+
+/**
+ * This is the main widget of the ACI item visual editor. It manages
+ * the lifecyle of all other ACI item widgets. In particular it
+ * shows/hides the userFirst and itemFirst widgets depending on
+ * the user's selection. 
+ * <p>
+ * It extends ScrolledComposite.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ACIItemVisualEditorComposite extends ScrolledComposite implements WidgetModifyListener
+{
+    /** The inner composite for all the content */
+    private Composite composite = null;
+
+    /** The general composite contains id-tag, precedence, auth-level, userFirst/itemFirst
*/
+    private ACIItemGeneralComposite generalComposite = null;
+
+    /** The user classes composite used for userFirst selection */
+    private ACIItemUserClassesComposite userFirstUserClassesComposite = null;
+
+    /** The user permission composite used for userFirst selection */
+    private ACIItemUserPermissionsComposite userFirstUserPermissionsComposite = null;
+
+    /** The protected items composite used for itemFirst selection */
+    private ACIItemProtectedItemsComposite itemFirstProtectedItemsComposite = null;
+
+    /** The item permission composite used for itemFirst selection */
+    private ACIItemItemPermissionsComposite itemFirstItemPermissionsComposite = null;
+
+
+    /**
+     * Creates a new instance of ACIItemComposite.
+     *
+     * @param parent
+     * @param style
+     */
+    public ACIItemVisualEditorComposite( Composite parent, int style )
+    {
+        super( parent, style | SWT.H_SCROLL | SWT.V_SCROLL );
+        setExpandHorizontal( true );
+        setExpandVertical( true );
+
+        createComposite();
+
+        setContent( composite );
+        setMinSize( composite.computeSize( SWT.DEFAULT, SWT.DEFAULT ) );
+    }
+
+
+    /**
+     * This method initializes the inner composite with all contained widgets.
+     *
+     */
+    private void createComposite()
+    {
+        GridLayout gridLayout = new GridLayout();
+        gridLayout.numColumns = 1;
+        GridData gridData = new GridData();
+        gridData.horizontalAlignment = GridData.FILL;
+        gridData.grabExcessHorizontalSpace = true;
+        gridData.verticalAlignment = GridData.CENTER;
+
+        composite = new Composite( this, SWT.NONE );
+        composite.setLayout( gridLayout );
+        composite.setLayoutData( gridData );
+
+        // test button
+        // TODO: remove
+        Button testButton = new Button( composite, SWT.NONE );
+        testButton.setText( " C H E C K " ); //$NON-NLS-1$
+        testButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                try
+                {
+                    String input = getInput();
+                    MessageDialog.openInformation( getShell(), "Check", input ); //$NON-NLS-1$
+                }
+                catch ( ParseException e1 )
+                {
+                    MessageDialog.openError( getShell(), "Check Error", e1.getMessage() );
//$NON-NLS-1$
+                }
+            }
+        } );
+
+        generalComposite = new ACIItemGeneralComposite( composite, SWT.NONE );
+        generalComposite.addWidgetModifyListener( this );
+
+        userFirstUserClassesComposite = new ACIItemUserClassesComposite( composite, SWT.NONE
);
+        userFirstUserPermissionsComposite = new ACIItemUserPermissionsComposite( composite,
SWT.NONE );
+
+        itemFirstProtectedItemsComposite = new ACIItemProtectedItemsComposite( composite,
SWT.NONE );
+        itemFirstItemPermissionsComposite = new ACIItemItemPermissionsComposite( composite,
SWT.NONE );
+
+        widgetModified( null );
+    }
+
+
+    /**
+     * This method is called from the contained ACIItemXXXComposites 
+     * when they are modified.
+     * 
+     */
+    public void widgetModified( WidgetModifyEvent event )
+    {
+        // switch userFirst / itemFirst
+        if ( generalComposite.isItemFirst() && !generalComposite.isUserFirst()
+            && !itemFirstProtectedItemsComposite.isVisible() )
+        {
+            userFirstUserClassesComposite.setVisible( false );
+            userFirstUserPermissionsComposite.setVisible( false );
+            itemFirstProtectedItemsComposite.setVisible( true );
+            itemFirstItemPermissionsComposite.setVisible( true );
+
+            setMinSize( composite.computeSize( SWT.DEFAULT, SWT.DEFAULT ) );
+            layout( true, true );
+        }
+        else if ( generalComposite.isUserFirst() && !generalComposite.isItemFirst()
+            && !userFirstUserClassesComposite.isVisible() )
+        {
+            userFirstUserClassesComposite.setVisible( true );
+            userFirstUserPermissionsComposite.setVisible( true );
+            itemFirstProtectedItemsComposite.setVisible( false );
+            itemFirstItemPermissionsComposite.setVisible( false );
+
+            setMinSize( composite.computeSize( SWT.DEFAULT, SWT.DEFAULT ) );
+            layout( true, true );
+        }
+        else if ( !generalComposite.isItemFirst() && !generalComposite.isUserFirst()
)
+        {
+            userFirstUserClassesComposite.setVisible( false );
+            userFirstUserPermissionsComposite.setVisible( false );
+            itemFirstProtectedItemsComposite.setVisible( false );
+            itemFirstItemPermissionsComposite.setVisible( false );
+
+            setMinSize( composite.computeSize( SWT.DEFAULT, SWT.DEFAULT ) );
+            layout( true, true );
+        }
+
+    }
+
+
+    /**
+     * Sets the input. The given ACI Item string is parsed and
+     * populated to the GUI elements.
+     * 
+     *
+     * @param aciitem The string representation of the ACI item
+     * @throws ParseException if the syntax is invalid
+     */
+    public void setInput( String input ) throws ParseException
+    {
+        ACIItemParser parser = new ACIItemParser( null );
+        ACIItem aciItem = parser.parse( input );
+
+        if ( aciItem != null )
+        {
+            generalComposite.setIdentificationTag( aciItem.getIdentificationTag() );
+            generalComposite.setPrecedence( aciItem.getPrecedence() );
+            generalComposite.setAuthenticationLevel( aciItem.getAuthenticationLevel() );
+
+            if ( aciItem instanceof ItemFirstACIItem )
+            {
+                ItemFirstACIItem itemFirstACI = ( ItemFirstACIItem ) aciItem;
+                generalComposite.setItemFirst();
+                itemFirstProtectedItemsComposite.setProtectedItems( itemFirstACI.getProtectedItems()
);
+                itemFirstItemPermissionsComposite.setItemPermissions( itemFirstACI.getItemPermissions()
);
+            }
+            else if ( aciItem instanceof UserFirstACIItem )
+            {
+                UserFirstACIItem userFirstACI = ( UserFirstACIItem ) aciItem;
+                generalComposite.setUserFirst();
+                userFirstUserClassesComposite.setUserClasses( userFirstACI.getUserClasses()
);
+                userFirstUserPermissionsComposite.setUserPermissions( userFirstACI.getUserPermission()
);
+            }
+        }
+
+        // force userFirst/itemFirst switch
+        widgetModified( null );
+
+    }
+
+
+    /**
+     * Returns the string representation of the ACI item as defined in GUI.
+     * 
+     *
+     * @return the string representation of the ACI item
+     * @throws ParseException if the syntax is invalid
+     */
+    public String getInput() throws ParseException
+    {
+        String identificationTag = generalComposite.getIdentificationTag();
+        int precedence = generalComposite.getPrecedence();
+        AuthenticationLevel authenticationLevel = generalComposite.getAuthenticationLevel();
+
+        ACIItem aciItem = null;
+        if ( generalComposite.isUserFirst() )
+        {
+            Collection userClasses = userFirstUserClassesComposite.getUserClasses();
+            Collection userPermissions = userFirstUserPermissionsComposite.getUserPermissions();
+            aciItem = new UserFirstACIItem( identificationTag, precedence, authenticationLevel,
userClasses,
+                userPermissions );
+        }
+        else if ( generalComposite.isItemFirst() )
+        {
+            Collection protectedItems = itemFirstProtectedItemsComposite.getProtectedItems();
+            Collection itemPermissions = itemFirstItemPermissionsComposite.getItemPermissions();
+            aciItem = new ItemFirstACIItem( identificationTag, precedence, authenticationLevel,
protectedItems,
+                itemPermissions );
+        }
+        else
+        {
+            aciItem = null;
+        }
+        
+        StringBuffer buffer = new StringBuffer();
+        if(aciItem != null)
+        {
+            aciItem.printToBuffer( buffer );
+        }
+        return buffer.toString();
+    }
+
+}

Added: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/Messages.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/Messages.java?view=auto&rev=491293
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/Messages.java
(added)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/Messages.java
Sat Dec 30 11:19:04 2006
@@ -0,0 +1,31 @@
+package org.apache.directory.ldapstudio.aciitemeditor.widgets;
+
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+
+public class Messages 
+{
+    private static final String BUNDLE_NAME = "org.apache.directory.ldapstudio.aciitemeditor.widgets.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 + '!';
+        }
+    }
+}

Modified: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/WidgetModifyEvent.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/WidgetModifyEvent.java?view=diff&rev=491293&r1=491291&r2=491293
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/WidgetModifyEvent.java
(original)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/WidgetModifyEvent.java
Sat Dec 30 11:19:04 2006
@@ -24,16 +24,26 @@
 import java.util.EventObject;
 
 
+/**
+ * A WidgetModifyEvent contains details of the widget modification.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class WidgetModifyEvent extends EventObject
 {
 
     private static final long serialVersionUID = 2421335730580648878L;
 
 
+    /**
+     * Creates a new instance of WidgetModifyEvent.
+     *
+     * @param source the object on which the event initially occurred
+     */
     public WidgetModifyEvent( Object source )
     {
         super( source );
-
     }
 
 }

Modified: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/WidgetModifyListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/WidgetModifyListener.java?view=diff&rev=491293&r1=491291&r2=491293
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/WidgetModifyListener.java
(original)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/java/org/apache/directory/ldapstudio/aciitemeditor/widgets/WidgetModifyListener.java
Sat Dec 30 11:19:04 2006
@@ -21,9 +21,20 @@
 package org.apache.directory.ldapstudio.aciitemeditor.widgets;
 
 
+/**
+ * A widget modify listeners gets informed if a widget was modified.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public interface WidgetModifyListener
 {
 
+    /**
+     * Informs this listener that a widget was modified
+     *
+     * @param event
+     */
     public void widgetModified( WidgetModifyEvent event );
 
 }

Added: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/resources/org/apache/directory/ldapstudio/aciitemeditor/dialogs/messages.properties
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/resources/org/apache/directory/ldapstudio/aciitemeditor/dialogs/messages.properties?view=auto&rev=491293
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/resources/org/apache/directory/ldapstudio/aciitemeditor/dialogs/messages.properties
(added)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/resources/org/apache/directory/ldapstudio/aciitemeditor/dialogs/messages.properties
Sat Dec 30 11:19:04 2006
@@ -0,0 +1,12 @@
+ACIItemDialog.dialog.text=ACI Item Editor
+ACIItemDialog.dialog.icon=icons/aciitemeditor.gif
+ACIItemDialog.error.title=Syntax Error
+ACIItemDialog.error.invalidSyntax=Invalid syntax.
+ItemPermissionDialog.dialog.text=Item Permission Editor
+ItemPermissionDialog.dialog.icon=icons/aciitemeditor.gif
+ItemPermissionDialog.error.invalidItemPermission=Invalid Item Permission
+ItemPermissionDialog.precedence.label=Precedence:
+UserPermissionDialog.dialog.text=User Permission Editor
+UserPermissionDialog.dialog.icon=icons/aciitemeditor.gif
+UserPermissionDialog.error.invalidUserPermission=Invalid User Permission
+UserPermissionDialog.precedence.label=Precedence:

Added: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/resources/org/apache/directory/ldapstudio/aciitemeditor/widgets/messages.properties
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/resources/org/apache/directory/ldapstudio/aciitemeditor/widgets/messages.properties?view=auto&rev=491293
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/resources/org/apache/directory/ldapstudio/aciitemeditor/widgets/messages.properties
(added)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/main/resources/org/apache/directory/ldapstudio/aciitemeditor/widgets/messages.properties
Sat Dec 30 11:19:04 2006
@@ -0,0 +1,65 @@
+ACIItemGeneralComposite.idTag.label=Identification Tag:
+ACIItemTabFolderComposite.source.tab=Source
+ACIItemTabFolderComposite.visual.tab=Visual Editor
+ACIItemTabFolderComposite.error.onVisualEditor=Invalid syntax, switching back to visual editor.
+ACIItemTabFolderComposite.error.title=Syntax Error
+ACIItemTabFolderComposite.error.onSourceEditor=Invalid syntax, switching back to source editor.
+ACIItemTabFolderComposite.error.onInput=Invalid syntax, activating source editor.
+ACIItemGeneralComposite.precedence.label=Precedence:
+ACIItemUserClassesComposite.revert.buton=Revert
+ACIItemGeneralComposite.authLevel.label=Authentication Level:
+ACIItemGeneralComposite.userOrItemFirst.label=User or Item first:
+ACIItemItemPermissionsComposite.delete.button=Delete
+ACIItemGeneralComposite.userFirst.label=User First
+ACIItemGeneralComposite.itemFirst.label=Item First
+ACIItemUserClassesComposite.description=User Classes:
+ACIItemUserClassesComposite.edit.button=Edit...
+ACIItemUserClassesComposite.error.icon=icons/error.gif
+ACIItemGrantsAndDenialsComposite.column1.header=Right
+ACIItemGrantsAndDenialsComposite.column2.header=Grant/Deny
+ACIItemGrantsAndDenialsComposite.category.read=Read Rights
+ACIItemUserClassesComposite.deselectAll.button=Deselect All
+ACIItemGrantsAndDenialsComposite.category.modify=Modification Rights
+ACIItemGrantsAndDenialsComposite.category.advanced=Advanced Rights
+ACIItemGrantsAndDenialsComposite.description=Grants and Denials:
+ACIItemGrantsAndDenialsComposite.grantAll.button=Grant All
+ACIItemUserClassesComposite.userClass.name.label=Name
+ACIItemGrantsAndDenialsComposite.denyAll.button=Deny All
+ACIItemProtectedItemsComposite.selectAll.button=Select All
+ACIItemGrantsAndDenialsComposite.deselectAll.button=Deselect All
+ACIItemUserClassesComposite.userClass.allUsers.label=All Users
+ACIItemUserClassesComposite.userClass.thisEntry.label=This Entry
+ACIItemUserClassesComposite.userClass.userGroup.label=User Group
+ACIItemUserClassesComposite.userClass.subtree.label=Subtree
+ACIItemProtectedItemsComposite.protectedItem.entry.label=Entry
+ACIItemGrantsAndDenialsComposite.undo.button=Undo
+ACIItemGrantsAndDenialsComposite.redo.button=Redo
+ACIItemProtectedItemsComposite.revers.button=Revert
+ACIItemGrantsAndDenialsComposite.unspecified.icon=icons/checkbox_unchecked.gif
+ACIItemProtectedItemsComposite.deselectAll.button=Deselect All
+ACIItemGrantsAndDenialsComposite.grant.icon=icons/checkbox_grant.gif
+ACIItemItemPermissionsComposite.description=Item Permissions:
+ACIItemItemPermissionsComposite.edit.button=Edit...
+ACIItemGrantsAndDenialsComposite.deny.icon=icons/checkbox_deny.gif
+ACIItemItemPermissionsComposite.add.button=Add...
+ACIItemProtectedItemsComposite.protectedItem.allUserAttributeTypes.label=All User Attribute
Types
+ACIItemProtectedItemsComposite.protectedItem.attributeType.label=Attribute Type
+ACIItemProtectedItemsComposite.protectedItem.allAttributeValues.label=All Attribute Values
+ACIItemProtectedItemsComposite.protectedItem.allUserAttributeTypesAndValues.label=All User
Attribute Types and Values
+ACIItemProtectedItemsComposite.protectedItem.attributeValue.label=Attribute Value
+ACIItemProtectedItemsComposite.protectedItem.selfValue.label=Self Value
+ACIItemProtectedItemsComposite.protectedItem.rangeOfValues.label=Range of Values
+ACIItemProtectedItemsComposite.protectedItem.maxValueCount.label=Max. Value Count
+ACIItemProtectedItemsComposite.protectedItem.maxImmSub.label=Max. Number of Immediate Subordinates
+ACIItemProtectedItemsComposite.protectedItem.restrictedBy.label=Restricted by
+ACIItemProtectedItemsComposite.protectedItem.classes.label=Classes
+ACIItemProtectedItemsComposite.description=Protected Items:
+ACIItemProtectedItemsComposite.edit.button=Edit...
+ACIItemProtectedItemsComposite.error.icon=icons/error.gif
+ACIItemUserClassesComposite.error.message=Invalid user class "{0}" with value "{1}"
+ACIItemUserPermissionsComposite.descripton=User Permissions:
+ACIItemUserPermissionsComposite.add.button=Add...
+ACIItemProtectedItemsComposite.error.message=Invalid protected item "{0}" with value "{1}"
+ACIItemUserClassesComposite.selectAll.button=Select All
+ACIItemUserPermissionsComposite.edit.button=Edit...
+ACIItemUserPermissionsComposite.delete.button=Delete



Mime
View raw message