You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2006/12/18 18:57:49 UTC

svn commit: r488371 [10/14] - in /directory/sandbox/pamarcelot/ldapstudio: ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/jobs/ ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/perspective/ ldapstudio-browser-u...

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/search/SearchPageWrapper.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/search/SearchPageWrapper.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/search/SearchPageWrapper.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/search/SearchPageWrapper.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,765 @@
+/*
+ *  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.browser.ui.widgets.search;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.core.jobs.SearchJob;
+import org.apache.directory.ldapstudio.browser.core.model.Control;
+import org.apache.directory.ldapstudio.browser.core.model.DN;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.ISearch;
+import org.apache.directory.ldapstudio.browser.core.model.filter.parser.LdapFilterParser;
+import org.apache.directory.ldapstudio.browser.core.model.schema.AttributeTypeDescription;
+import org.apache.directory.ldapstudio.browser.core.model.schema.SchemaUtils;
+import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils;
+import org.apache.directory.ldapstudio.browser.ui.widgets.BrowserWidget;
+import org.apache.directory.ldapstudio.browser.ui.widgets.WidgetModifyEvent;
+import org.apache.directory.ldapstudio.browser.ui.widgets.WidgetModifyListener;
+
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+
+public class SearchPageWrapper extends BrowserWidget
+{
+
+    public static final int NONE = 0;
+
+    public static final int NAME_INVISIBLE = 1 << 1;
+
+    public static final int NAME_READONLY = 1 << 2;
+
+    public static final int CONNECTION_INVISIBLE = 1 << 3;
+
+    public static final int CONNECTION_READONLY = 1 << 4;
+
+    public static final int SEARCHBASE_INVISIBLE = 1 << 5;
+
+    public static final int SEARCHBASE_READONLY = 1 << 6;
+
+    public static final int FILTER_INVISIBLE = 1 << 7;
+
+    public static final int FILTER_READONLY = 1 << 8;
+
+    public static final int RETURNINGATTRIBUTES_INVISIBLE = 1 << 9;
+
+    public static final int RETURNINGATTRIBUTES_READONLY = 1 << 10;
+
+    public static final int DN_VISIBLE = 1 << 11;
+
+    public static final int DN_CHECKED = 1 << 12;
+
+    public static final int ALLATTRIBUTES_VISIBLE = 1 << 13;
+
+    public static final int ALLATTRIBUTES_CHECKED = 1 << 14;
+
+    public static final int OPERATIONALATTRIBUTES_VISIBLE = 1 << 15;
+
+    public static final int OPERATIONALATTRIBUTES_CHECKED = 1 << 16;
+
+    public static final int OPTIONS_INVISIBLE = 1 << 21;
+
+    public static final int SCOPEOPTIONS_READONLY = 1 << 22;
+
+    public static final int LIMITOPTIONS_READONLY = 1 << 23;
+
+    public static final int ALIASOPTIONS_READONLY = 1 << 24;
+
+    public static final int REFERRALOPTIONS_READONLY = 1 << 25;
+
+    public static final int CONTROLS_INVISIBLE = 1 << 30;
+
+    protected int style;
+
+    protected LdapFilterParser parser;
+
+    protected Label searchNameLabel;
+
+    protected Text searchNameText;
+
+    protected Label connectionLabel;
+
+    protected ConnectionWidget connectionWidget;
+
+    protected Label searchBaseLabel;
+
+    protected EntryWidget searchBaseWidget;
+
+    protected Label filterLabel;
+
+    protected FilterWidget filterWidget;
+
+    protected Label returningAttributesLabel;
+
+    protected ReturningAttributesWidget returningAttributesWidget;
+
+    protected Button dnButton;
+
+    protected Button allAttributesButton;
+
+    protected Button operationalAttributesButton;
+
+    protected ScopeWidget scopeWidget;
+
+    protected LimitWidget limitWidget;
+
+    protected AliasesDereferencingWidget aliasesDereferencingWidget;
+
+    protected ReferralsHandlingWidget referralsHandlingWidget;
+
+    protected Label controlLabel;
+
+    protected Button subentriesControlButton;
+
+
+    public SearchPageWrapper( int style )
+    {
+        this.parser = new LdapFilterParser();
+        this.style = style;
+    }
+
+
+    public void createContents( final Composite composite )
+    {
+
+        // Search Name
+        createSearchNameLine( composite );
+
+        // Connection
+        createConnectionLine( composite );
+
+        // Search Base
+        createSearchBaseLine( composite );
+
+        // Filter
+        createFilterLine( composite );
+
+        // Returning Attributes
+        createReturningAttributesLine( composite );
+
+        // control
+        createControlComposite( composite );
+
+        // scope, limit, alias, referral
+        createOptionsComposite( composite );
+
+    }
+
+
+    protected boolean isActive( int requiredStyle )
+    {
+        return ( this.style & requiredStyle ) != 0;
+    }
+
+
+    protected void createSearchNameLine( final Composite composite )
+    {
+        if ( isActive( NAME_INVISIBLE ) )
+            return;
+
+        searchNameLabel = BaseWidgetUtils.createLabel( composite, "Search Name:", 1 );
+        if ( isActive( NAME_READONLY ) )
+        {
+            searchNameText = BaseWidgetUtils.createReadonlyText( composite, "", 2 );
+        }
+        else
+        {
+            searchNameText = BaseWidgetUtils.createText( composite, "", 2 );
+        }
+        searchNameText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                validate();
+            }
+        } );
+
+        BaseWidgetUtils.createSpacer( composite, 3 );
+    }
+
+
+    protected void createConnectionLine( final Composite composite )
+    {
+        if ( isActive( CONNECTION_INVISIBLE ) )
+            return;
+
+        connectionLabel = BaseWidgetUtils.createLabel( composite, "Connection:", 1 );
+        connectionWidget = new ConnectionWidget();
+        connectionWidget.createWidget( composite );
+        connectionWidget.setEnabled( !isActive( CONNECTION_READONLY ) );
+        connectionWidget.addWidgetModifyListener( new WidgetModifyListener()
+        {
+            public void widgetModified( WidgetModifyEvent event )
+            {
+                validate();
+            }
+        } );
+        BaseWidgetUtils.createSpacer( composite, 3 );
+    }
+
+
+    protected void createSearchBaseLine( final Composite composite )
+    {
+        if ( isActive( SEARCHBASE_INVISIBLE ) )
+            return;
+
+        searchBaseLabel = BaseWidgetUtils.createLabel( composite, "Search Base:", 1 );
+        searchBaseWidget = new EntryWidget();
+        searchBaseWidget.createWidget( composite );
+        searchBaseWidget.setEnabled( !isActive( SEARCHBASE_READONLY ) );
+        searchBaseWidget.addWidgetModifyListener( new WidgetModifyListener()
+        {
+            public void widgetModified( WidgetModifyEvent event )
+            {
+                validate();
+            }
+        } );
+        BaseWidgetUtils.createSpacer( composite, 3 );
+    }
+
+
+    protected void createFilterLine( final Composite composite )
+    {
+        if ( isActive( FILTER_INVISIBLE ) )
+            return;
+
+        filterLabel = BaseWidgetUtils.createLabel( composite, "Filter:", 1 );
+        filterWidget = new FilterWidget();
+        filterWidget.createWidget( composite );
+        filterWidget.setEnabled( !isActive( FILTER_READONLY ) );
+        filterWidget.addWidgetModifyListener( new WidgetModifyListener()
+        {
+            public void widgetModified( WidgetModifyEvent event )
+            {
+                validate();
+            }
+        } );
+        BaseWidgetUtils.createSpacer( composite, 3 );
+    }
+
+
+    protected void createReturningAttributesLine( final Composite composite )
+    {
+        if ( isActive( RETURNINGATTRIBUTES_INVISIBLE ) )
+            return;
+
+        BaseWidgetUtils.createLabel( composite, "Returning Attributes:", 1 );
+        Composite retComposite = BaseWidgetUtils.createColumnContainer( composite, 1, 2 );
+        returningAttributesWidget = new ReturningAttributesWidget();
+        returningAttributesWidget.createWidget( retComposite );
+        returningAttributesWidget.setEnabled( !isActive( RETURNINGATTRIBUTES_READONLY ) );
+        returningAttributesWidget.addWidgetModifyListener( new WidgetModifyListener()
+        {
+            public void widgetModified( WidgetModifyEvent event )
+            {
+                validate();
+            }
+        } );
+
+        if ( isActive( DN_VISIBLE ) || isActive( ALLATTRIBUTES_VISIBLE ) || isActive( OPERATIONALATTRIBUTES_VISIBLE ) )
+        {
+            BaseWidgetUtils.createSpacer( composite, 1 );
+            Composite buttonComposite = BaseWidgetUtils.createColumnContainer( composite, 3, 1 );
+            if ( isActive( DN_VISIBLE ) )
+            {
+                dnButton = BaseWidgetUtils.createCheckbox( buttonComposite, "Export DN", 1 );
+                dnButton.addSelectionListener( new SelectionAdapter()
+                {
+                    public void widgetSelected( SelectionEvent e )
+                    {
+                        validate();
+                    }
+                } );
+                dnButton.setSelection( isActive( DN_CHECKED ) );
+            }
+            if ( isActive( ALLATTRIBUTES_VISIBLE ) )
+            {
+                allAttributesButton = BaseWidgetUtils.createCheckbox( buttonComposite, "All user attributes", 1 );
+                allAttributesButton.addSelectionListener( new SelectionAdapter()
+                {
+                    public void widgetSelected( SelectionEvent e )
+                    {
+                        validate();
+                    }
+                } );
+                allAttributesButton.setSelection( isActive( ALLATTRIBUTES_CHECKED ) );
+            }
+            if ( isActive( OPERATIONALATTRIBUTES_VISIBLE ) )
+            {
+                operationalAttributesButton = BaseWidgetUtils.createCheckbox( buttonComposite,
+                    "Operational attributes", 1 );
+                operationalAttributesButton.addSelectionListener( new SelectionAdapter()
+                {
+                    public void widgetSelected( SelectionEvent e )
+                    {
+                        validate();
+                    }
+                } );
+                operationalAttributesButton.setSelection( isActive( OPERATIONALATTRIBUTES_CHECKED ) );
+            }
+        }
+
+        BaseWidgetUtils.createSpacer( composite, 3 );
+    }
+
+
+    protected void createOptionsComposite( final Composite composite )
+    {
+        if ( isActive( OPTIONS_INVISIBLE ) )
+            return;
+
+        Composite optionsComposite = BaseWidgetUtils.createColumnContainer( composite, 2, 3 );
+        scopeWidget = new ScopeWidget();
+        scopeWidget.createWidget( optionsComposite );
+        scopeWidget.setEnabled( !isActive( SCOPEOPTIONS_READONLY ) );
+        scopeWidget.addWidgetModifyListener( new WidgetModifyListener()
+        {
+            public void widgetModified( WidgetModifyEvent event )
+            {
+                validate();
+            }
+        } );
+        limitWidget = new LimitWidget();
+        limitWidget.createWidget( optionsComposite );
+        limitWidget.setEnabled( !isActive( LIMITOPTIONS_READONLY ) );
+        limitWidget.addWidgetModifyListener( new WidgetModifyListener()
+        {
+            public void widgetModified( WidgetModifyEvent event )
+            {
+                validate();
+            }
+        } );
+        aliasesDereferencingWidget = new AliasesDereferencingWidget();
+        aliasesDereferencingWidget.createWidget( optionsComposite );
+        aliasesDereferencingWidget.setEnabled( !isActive( ALIASOPTIONS_READONLY ) );
+        aliasesDereferencingWidget.addWidgetModifyListener( new WidgetModifyListener()
+        {
+            public void widgetModified( WidgetModifyEvent event )
+            {
+                validate();
+            }
+        } );
+        referralsHandlingWidget = new ReferralsHandlingWidget();
+        referralsHandlingWidget.createWidget( optionsComposite );
+        referralsHandlingWidget.setEnabled( !isActive( REFERRALOPTIONS_READONLY ) );
+        referralsHandlingWidget.addWidgetModifyListener( new WidgetModifyListener()
+        {
+            public void widgetModified( WidgetModifyEvent event )
+            {
+                validate();
+            }
+        } );
+    }
+
+
+    protected void createControlComposite( final Composite composite )
+    {
+        if ( isActive( CONTROLS_INVISIBLE ) )
+            return;
+
+        controlLabel = BaseWidgetUtils.createLabel( composite, "Controls:", 1 );
+
+        subentriesControlButton = BaseWidgetUtils.createCheckbox( composite, Control.SUBENTRIES_CONTROL.getName(), 2 );
+        subentriesControlButton.addSelectionListener( new SelectionListener()
+        {
+            public void widgetDefaultSelected( SelectionEvent e )
+            {
+            }
+
+
+            public void widgetSelected( SelectionEvent e )
+            {
+                validate();
+            }
+        } );
+
+    }
+
+
+    protected void validate()
+    {
+
+        if ( connectionWidget.getConnection() != null )
+        {
+            if ( searchBaseWidget.getDn() == null
+                || searchBaseWidget.getConnection() != connectionWidget.getConnection() )
+            {
+                searchBaseWidget.setInput( connectionWidget.getConnection(), null );
+            }
+        }
+
+        filterWidget.setConnection( connectionWidget.getConnection() );
+
+        // this.fireSearchPageModified();
+        super.notifyListeners();
+    }
+
+
+    public boolean isExportDn()
+    {
+        return dnButton != null && dnButton.getSelection();
+    }
+
+
+    public void loadFromSearch( ISearch search )
+    {
+
+        if ( searchNameText != null )
+        {
+            searchNameText.setText( search.getName() );
+        }
+
+        if ( search.getConnection() != null )
+        {
+            IConnection connection = search.getConnection();
+            DN searchBase = search.getSearchBase();
+
+            if ( connectionWidget != null )
+            {
+                connectionWidget.setConnection( connection );
+            }
+
+            if ( searchBase != null )
+            {
+                searchBaseWidget.setInput( connection, searchBase );
+            }
+
+            if ( filterWidget != null )
+            {
+                filterWidget.setConnection( connection );
+                filterWidget.setFilter( search.getFilter() );
+            }
+
+            if ( returningAttributesWidget != null )
+            {
+                returningAttributesWidget.setConnection( connection );
+                returningAttributesWidget.setInitialReturningAttributes( search.getReturningAttributes() );
+            }
+
+            if ( this.scopeWidget != null )
+            {
+                scopeWidget.setScope( search.getScope() );
+            }
+            if ( this.limitWidget != null )
+            {
+                limitWidget.setCountLimit( search.getCountLimit() );
+                limitWidget.setTimeLimit( search.getTimeLimit() );
+            }
+            if ( this.aliasesDereferencingWidget != null )
+            {
+                aliasesDereferencingWidget.setAliasesDereferencingMethod( search.getAliasesDereferencingMethod() );
+            }
+            if ( this.referralsHandlingWidget != null )
+            {
+                referralsHandlingWidget.setReferralsHandlingMethod( search.getReferralsHandlingMethod() );
+            }
+            if ( this.subentriesControlButton != null )
+            {
+                Control[] searchControls = search.getControls();
+                if ( searchControls != null && searchControls.length > 0 )
+                {
+                    for ( int i = 0; i < searchControls.length; i++ )
+                    {
+                        Control c = searchControls[i];
+                        if ( Control.SUBENTRIES_CONTROL.equals( c ) )
+                        {
+                            this.subentriesControlButton.setSelection( true );
+                        }
+                    }
+
+                }
+            }
+        }
+    }
+
+
+    public boolean saveToSearch( ISearch search )
+    {
+        boolean searchModified = false;
+
+        if ( this.searchNameText != null && !this.searchNameText.getText().equals( search.getName() ) )
+        {
+            search.getSearchParameter().setName( this.searchNameText.getText() );
+            searchModified = true;
+        }
+        if ( this.connectionWidget != null && this.connectionWidget.getConnection() != null
+            && this.connectionWidget.getConnection() != search.getConnection() )
+        {
+            search.setConnection( this.connectionWidget.getConnection() );
+            searchModified = true;
+        }
+        if ( this.searchBaseWidget != null && this.searchBaseWidget.getDn() != null
+            && !this.searchBaseWidget.getDn().equals( search.getSearchBase() ) )
+        {
+            search.getSearchParameter().setSearchBase( this.searchBaseWidget.getDn() );
+            searchModified = true;
+            this.searchBaseWidget.saveDialogSettings();
+        }
+        if ( this.filterWidget != null )
+        {
+            this.parser.parse( filterWidget.getFilter() );
+            if ( !this.parser.getModel().toString().equals( search.getFilter() ) )
+            {
+                search.getSearchParameter().setFilter( this.parser.getModel().toString() );
+                searchModified = true;
+            }
+            this.filterWidget.saveDialogSettings();
+        }
+
+        if ( returningAttributesWidget != null )
+        {
+            if ( !Arrays.equals( this.returningAttributesWidget.getReturningAttributes(), search
+                .getReturningAttributes() ) )
+            {
+                search.getSearchParameter().setReturningAttributes(
+                    this.returningAttributesWidget.getReturningAttributes() );
+                searchModified = true;
+            }
+            this.returningAttributesWidget.saveDialogSettings();
+
+            if ( allAttributesButton != null || operationalAttributesButton != null )
+            {
+                List raList = new ArrayList();
+                raList.addAll( Arrays.asList( search.getReturningAttributes() ) );
+                if ( allAttributesButton != null )
+                {
+                    if ( allAttributesButton.getSelection() )
+                    {
+                        raList.add( ISearch.ALL_USER_ATTRIBUTES );
+                    }
+                    if ( allAttributesButton.getSelection() != isActive( ALLATTRIBUTES_CHECKED ) )
+                    {
+                        searchModified = true;
+                    }
+                }
+                if ( operationalAttributesButton != null )
+                {
+                    if ( operationalAttributesButton.getSelection() )
+                    {
+                        AttributeTypeDescription[] opAtds = SchemaUtils
+                            .getOperationalAttributeDescriptions( connectionWidget.getConnection().getSchema() );
+                        String[] attributeTypeDescriptionNames = SchemaUtils.getAttributeTypeDescriptionNames( opAtds );
+                        raList.addAll( Arrays.asList( attributeTypeDescriptionNames ) );
+                        raList.add( ISearch.ALL_OPERATIONAL_ATTRIBUTES );
+                    }
+                    if ( operationalAttributesButton.getSelection() != isActive( OPERATIONALATTRIBUTES_CHECKED ) )
+                    {
+                        searchModified = true;
+                    }
+                }
+                String[] returningAttributes = ( String[] ) raList.toArray( new String[raList.size()] );
+                search.getSearchParameter().setReturningAttributes( returningAttributes );
+            }
+        }
+
+        if ( this.scopeWidget != null )
+        {
+            int scope = scopeWidget.getScope();;
+            if ( scope != search.getScope() )
+            {
+                search.getSearchParameter().setScope( scope );
+                searchModified = true;
+            }
+        }
+        if ( this.limitWidget != null )
+        {
+            int countLimit = limitWidget.getCountLimit();
+            int timeLimit = limitWidget.getTimeLimit();
+            if ( countLimit != search.getCountLimit() )
+            {
+                search.getSearchParameter().setCountLimit( countLimit );
+                searchModified = true;
+            }
+            if ( timeLimit != search.getTimeLimit() )
+            {
+                search.getSearchParameter().setTimeLimit( timeLimit );
+                searchModified = true;
+            }
+        }
+        if ( this.aliasesDereferencingWidget != null )
+        {
+            int aliasesDereferencingMethod = aliasesDereferencingWidget.getAliasesDereferencingMethod();
+            if ( aliasesDereferencingMethod != search.getAliasesDereferencingMethod() )
+            {
+                search.getSearchParameter().setAliasesDereferencingMethod( aliasesDereferencingMethod );
+                searchModified = true;
+            }
+        }
+        if ( this.referralsHandlingWidget != null )
+        {
+            int referralsHandlingMethod = referralsHandlingWidget.getReferralsHandlingMethod();
+            if ( referralsHandlingMethod != search.getReferralsHandlingMethod() )
+            {
+                search.getSearchParameter().setReferralsHandlingMethod( referralsHandlingMethod );
+                searchModified = true;
+            }
+        }
+        if ( this.subentriesControlButton != null )
+        {
+            Control selectedSubControl = this.subentriesControlButton.getSelection() ? Control.SUBENTRIES_CONTROL
+                : null;
+            Control searchSubentriesControl = null;
+            Control[] searchControls = search.getControls();
+            if ( searchControls != null && searchControls.length > 0 )
+            {
+                for ( int i = 0; i < searchControls.length; i++ )
+                {
+                    Control c = searchControls[i];
+                    if ( Control.SUBENTRIES_CONTROL.equals( c ) )
+                    {
+                        searchSubentriesControl = Control.SUBENTRIES_CONTROL;
+                        break;
+                    }
+                }
+            }
+            if ( selectedSubControl != searchSubentriesControl )
+            {
+                if ( selectedSubControl == null )
+                {
+                    search.getSearchParameter().setControls( null );
+                }
+                else
+                {
+                    search.getSearchParameter().setControls( new Control[]
+                        { selectedSubControl } );
+                }
+                searchModified = true;
+            }
+
+        }
+
+        return searchModified;
+    }
+
+
+    public boolean performSearch( final ISearch search )
+    {
+        if ( search.getConnection() != null )
+        {
+            new SearchJob( new ISearch[]
+                { search } ).execute();
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+
+    public boolean isValid()
+    {
+        if ( this.connectionWidget != null && this.connectionWidget.getConnection() == null )
+        {
+            return false;
+        }
+        if ( this.searchBaseWidget != null && this.searchBaseWidget.getDn() == null )
+        {
+            return false;
+        }
+        if ( this.searchNameText != null && "".equals( this.searchNameText.getText() ) )
+        {
+            return false;
+        }
+        if ( this.filterWidget != null && "".equals( this.filterWidget.getFilter() ) )
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+
+    public void setEnabled( boolean b )
+    {
+        if ( this.searchNameText != null )
+        {
+            this.searchNameLabel.setEnabled( b );
+            this.searchNameText.setEnabled( b );
+        }
+        if ( this.connectionWidget != null )
+        {
+            this.connectionLabel.setEnabled( b );
+            this.connectionWidget.setEnabled( b && !isActive( CONNECTION_READONLY ) );
+        }
+        if ( this.searchBaseWidget != null )
+        {
+            this.searchBaseLabel.setEnabled( b );
+            this.searchBaseWidget.setEnabled( b && !isActive( SEARCHBASE_READONLY ) );
+        }
+        if ( this.filterWidget != null )
+        {
+            this.filterLabel.setEnabled( b );
+            this.filterWidget.setEnabled( b && !isActive( FILTER_READONLY ) );
+        }
+        if ( this.returningAttributesWidget != null )
+        {
+            this.returningAttributesLabel.setEnabled( b );
+            this.returningAttributesWidget.setEnabled( b && !isActive( RETURNINGATTRIBUTES_READONLY ) );
+        }
+        if ( this.dnButton != null )
+        {
+            this.dnButton.setEnabled( b );
+        }
+        if ( this.allAttributesButton != null )
+        {
+            this.allAttributesButton.setEnabled( b );
+        }
+        if ( this.operationalAttributesButton != null )
+        {
+            this.operationalAttributesButton.setEnabled( b );
+        }
+        if ( this.scopeWidget != null )
+        {
+            this.scopeWidget.setEnabled( b && !isActive( SCOPEOPTIONS_READONLY ) );
+        }
+        if ( this.limitWidget != null )
+        {
+            this.limitWidget.setEnabled( b && !isActive( LIMITOPTIONS_READONLY ) );
+        }
+        if ( this.aliasesDereferencingWidget != null )
+        {
+            this.aliasesDereferencingWidget.setEnabled( b && !isActive( ALIASOPTIONS_READONLY ) );
+        }
+        if ( this.referralsHandlingWidget != null )
+        {
+            this.referralsHandlingWidget.setEnabled( b && !isActive( REFERRALOPTIONS_READONLY ) );
+        }
+        if ( this.controlLabel != null )
+        {
+            this.controlLabel.setEnabled( b );
+            this.subentriesControlButton.setEnabled( b );
+        }
+
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/AttributeOptionsWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/AttributeOptionsWizardPage.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/AttributeOptionsWizardPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/AttributeOptionsWizardPage.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,692 @@
+/*
+ *  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.browser.ui.wizards;
+
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+
+public class AttributeOptionsWizardPage extends WizardPage
+{
+
+    private AttributeWizard wizard;
+
+    private String initialAttributeDescription;
+
+    private String[] possibleLanguages;
+
+    private Map possibleLangToCountriesMap;
+
+    private List parsedLangList;
+
+    private List parsedOptionList;
+
+    private boolean parsedBinary;
+
+    private Group langGroup;
+
+    private ArrayList langLineList;
+
+    private Group optionsGroup;
+
+    private ArrayList optionLineList;
+
+    private Button binaryOptionButton;
+
+    private Text previewText;
+
+    private int langGroupHeight = -1;
+
+    private int optionGroupHeight = -1;
+
+
+    public AttributeOptionsWizardPage( String pageName, String initialAttributeDescription, AttributeWizard wizard )
+    {
+        super( pageName );
+        super.setTitle( "Options" );
+        super.setDescription( "Optionally you may specify options (e.g. language tags)." );
+        // super.setImageDescriptor(BrowserUIPlugin.getDefault().getImageDescriptor(BrowserUIConstants.IMG_ATTRIBUTE_WIZARD));
+        super.setPageComplete( false );
+
+        this.wizard = wizard;
+        this.initialAttributeDescription = initialAttributeDescription;
+
+        SortedSet languageSet = new TreeSet();
+        Map languageToCountrySetMap = new HashMap();
+        Locale[] locales = Locale.getAvailableLocales();
+        for ( int i = 0; i < locales.length; i++ )
+        {
+            Locale locale = locales[i];
+            languageSet.add( locale.getLanguage() );
+            if ( !languageToCountrySetMap.containsKey( locale.getLanguage() ) )
+            {
+                languageToCountrySetMap.put( locale.getLanguage(), new TreeSet() );
+            }
+            SortedSet countrySet = ( SortedSet ) languageToCountrySetMap.get( locale.getLanguage() );
+            countrySet.add( locale.getCountry() );
+        }
+        this.possibleLanguages = ( String[] ) languageSet.toArray( new String[languageSet.size()] );
+        this.possibleLangToCountriesMap = new HashMap();
+        for ( Iterator it = languageToCountrySetMap.keySet().iterator(); it.hasNext(); )
+        {
+            String language = ( String ) it.next();
+            SortedSet countrySet = ( SortedSet ) languageToCountrySetMap.get( language );
+            String[] countries = ( String[] ) countrySet.toArray( new String[countrySet.size()] );
+            this.possibleLangToCountriesMap.put( language, countries );
+        }
+
+        String attributeDescription = this.initialAttributeDescription;
+        if ( attributeDescription == null )
+            attributeDescription = "";
+        String[] attributeDescriptionComponents = attributeDescription.split( ";" );
+        this.parsedLangList = new ArrayList();
+        this.parsedOptionList = new ArrayList();
+        this.parsedBinary = false;
+        for ( int i = 1; i < attributeDescriptionComponents.length; i++ )
+        {
+            if ( attributeDescriptionComponents[i].startsWith( "lang-" ) )
+            {
+                this.parsedLangList.add( attributeDescriptionComponents[i] );
+            }
+            else if ( attributeDescriptionComponents[i].equals( "binary" ) )
+            {
+                this.parsedBinary = true;
+            }
+            else
+            {
+                this.parsedOptionList.add( attributeDescriptionComponents[i] );
+            }
+        }
+    }
+
+
+    private void validate()
+    {
+        this.previewText.setText( wizard.getAttributeDescription() );
+        setPageComplete( true );
+    }
+
+
+    public void setVisible( boolean visible )
+    {
+        super.setVisible( visible );
+        if ( visible )
+        {
+            this.validate();
+        }
+    }
+
+
+    public void createControl( Composite parent )
+    {
+
+        Composite composite = new Composite( parent, SWT.NONE );
+        GridLayout gl = new GridLayout( 2, false );
+        composite.setLayout( gl );
+        composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+
+        // Lang group
+        this.langGroup = BaseWidgetUtils.createGroup( composite, "Language tags", 2 );
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = 2;
+        langGroup.setLayoutData( gd );
+        Composite langComposite = BaseWidgetUtils.createColumnContainer( this.langGroup, 6, 1 );
+        this.langLineList = new ArrayList();
+
+        BaseWidgetUtils.createSpacer( composite, 2 );
+
+        // Options group with binary option
+        this.optionsGroup = BaseWidgetUtils.createGroup( composite, "Other options", 2 );
+        gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = 2;
+        optionsGroup.setLayoutData( gd );
+        Composite optionsComposite = BaseWidgetUtils.createColumnContainer( this.optionsGroup, 3, 1 );
+        this.optionLineList = new ArrayList();
+        Composite binaryComposite = BaseWidgetUtils.createColumnContainer( this.optionsGroup, 1, 1 );
+        this.binaryOptionButton = BaseWidgetUtils.createCheckbox( binaryComposite, "binary option", 1 );
+        this.binaryOptionButton.setSelection( parsedBinary );
+
+        Label la = new Label( composite, SWT.NONE );
+        gd = new GridData( GridData.GRAB_VERTICAL );
+        gd.horizontalSpan = 2;
+        la.setLayoutData( gd );
+
+        // Preview text
+        /* this.previewLabel = */BaseWidgetUtils.createLabel( composite, "Preview:", 1 );
+        this.previewText = BaseWidgetUtils.createReadonlyText( composite, "", 1 );
+
+        // fill lang
+        if ( parsedLangList.isEmpty() )
+        {
+            addLangLine( langComposite, 0 );
+        }
+        else
+        {
+            for ( int i = 0; i < parsedLangList.size(); i++ )
+            {
+                addLangLine( langComposite, i );
+                String l = ( String ) parsedLangList.get( i );
+                String[] ls = l.split( "-", 3 );
+                if ( ls.length > 1 )
+                {
+                    ( ( LangLine ) langLineList.get( i ) ).languageCombo.setText( ls[1] );
+                }
+                if ( ls.length > 2 )
+                {
+                    ( ( LangLine ) langLineList.get( i ) ).countryCombo.setText( ls[2] );
+                }
+            }
+        }
+
+        // fill options
+        if ( parsedOptionList.isEmpty() )
+        {
+            addOptionLine( optionsComposite, 0 );
+        }
+        else
+        {
+            for ( int i = 0; i < parsedOptionList.size(); i++ )
+            {
+                addOptionLine( optionsComposite, i );
+                ( ( OptionLine ) optionLineList.get( i ) ).optionText.setText( ( String ) parsedOptionList.get( i ) );
+            }
+        }
+
+        // binary listener
+        this.binaryOptionButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                validate();
+            }
+        } );
+
+        validate();
+
+        setControl( composite );
+    }
+
+
+    String getAttributeOptions()
+    {
+
+        if ( this.binaryOptionButton == null || this.binaryOptionButton.isDisposed() )
+        {
+            return "";
+        }
+
+        // attribute type
+        StringBuffer sb = new StringBuffer();
+        // sb.append(wizard.getAttributeType());
+
+        // options
+        // sort and unique options
+        Comparator comparator = new Comparator()
+        {
+            public int compare( Object o1, Object o2 )
+            {
+                if ( o1 == null || !( o1 instanceof String ) || o2 == null || !( o2 instanceof String ) )
+                {
+                    throw new ClassCastException( "Must be String" );
+                }
+                return ( ( String ) o1 ).compareToIgnoreCase( ( String ) o2 );
+            }
+        };
+        SortedSet options = new TreeSet( comparator );
+        if ( this.binaryOptionButton.getSelection() )
+        {
+            options.add( "binary" );
+        }
+        for ( int i = 0; i < this.optionLineList.size(); i++ )
+        {
+            OptionLine optionLine = ( OptionLine ) this.optionLineList.get( i );
+            if ( !"".equals( optionLine.optionText.getText() ) )
+            {
+                options.add( optionLine.optionText.getText() );
+            }
+
+            if ( this.optionLineList.size() > 1 )
+            {
+                optionLine.optionDeleteButton.setEnabled( true );
+            }
+            else
+            {
+                optionLine.optionDeleteButton.setEnabled( false );
+            }
+        }
+        for ( int i = 0; i < this.langLineList.size(); i++ )
+        {
+            LangLine langLine = ( LangLine ) this.langLineList.get( i );
+            String l = langLine.languageCombo.getText();
+            String c = langLine.countryCombo.getText();
+
+            if ( !"".equals( l ) )
+            {
+                String s = "lang-" + l;
+                if ( !"".equals( c ) )
+                {
+                    s += "-" + c;
+                }
+                options.add( s );
+            }
+
+            if ( this.langLineList.size() > 1 )
+            {
+                langLine.deleteButton.setEnabled( true );
+            }
+            else
+            {
+                langLine.deleteButton.setEnabled( false );
+            }
+        }
+
+        // append options
+        for ( Iterator it = options.iterator(); it.hasNext(); )
+        {
+            String option = ( String ) it.next();
+            sb.append( ';' );
+            sb.append( option );
+        }
+
+        return sb.toString();
+    }
+
+
+    private void addOptionLine( Composite optionComposite, int index )
+    {
+
+        OptionLine[] optionLines = ( OptionLine[] ) optionLineList.toArray( new OptionLine[optionLineList.size()] );
+
+        if ( optionLines.length > 0 )
+        {
+            for ( int i = 0; i < optionLines.length; i++ )
+            {
+                OptionLine oldOptionLine = optionLines[i];
+
+                // remember values
+                String oldValue = oldOptionLine.optionText.getText();
+
+                // delete old
+                oldOptionLine.optionText.dispose();
+                oldOptionLine.optionAddButton.dispose();
+                oldOptionLine.optionDeleteButton.dispose();
+                optionLineList.remove( oldOptionLine );
+
+                // add new
+                OptionLine newOptionLine = createOptionLine( optionComposite );
+                optionLineList.add( newOptionLine );
+
+                // restore value
+                newOptionLine.optionText.setText( oldValue );
+
+                // check
+                if ( index == i + 1 )
+                {
+                    OptionLine optionLine = createOptionLine( optionComposite );
+                    optionLineList.add( optionLine );
+                }
+            }
+        }
+        else
+        {
+            OptionLine optionLine = createOptionLine( optionComposite );
+            optionLineList.add( optionLine );
+        }
+    }
+
+
+    private OptionLine createOptionLine( final Composite optionComposite )
+    {
+        OptionLine optionLine = new OptionLine();
+
+        optionLine.optionText = new Text( optionComposite, SWT.BORDER );
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL );
+        optionLine.optionText.setLayoutData( gd );
+
+        optionLine.optionAddButton = new Button( optionComposite, SWT.PUSH );
+        optionLine.optionAddButton.setText( "  +   " );
+        optionLine.optionAddButton.addSelectionListener( new SelectionListener()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                int index = optionLineList.size();
+                for ( int i = 0; i < optionLineList.size(); i++ )
+                {
+                    OptionLine optionLine = ( OptionLine ) optionLineList.get( i );
+                    if ( optionLine.optionAddButton == e.widget )
+                    {
+                        index = i + 1;
+                    }
+                }
+                addOptionLine( optionComposite, index );
+
+                Shell shell = getShell();
+                Point shellSize = shell.getSize();
+                Point groupSize = optionComposite.computeSize( SWT.DEFAULT, SWT.DEFAULT, true );
+                int newOptionGroupHeight = groupSize.y;
+                shell.setSize( shellSize.x, shellSize.y + newOptionGroupHeight - optionGroupHeight );
+                optionComposite.layout( true, true );
+                shell.layout( true, true );
+                optionGroupHeight = newOptionGroupHeight;
+
+                validate();
+            }
+
+
+            public void widgetDefaultSelected( SelectionEvent e )
+            {
+            }
+        } );
+
+        optionLine.optionDeleteButton = new Button( optionComposite, SWT.PUSH );
+        optionLine.optionDeleteButton.setText( "  \u2212  " ); // \u2013
+        optionLine.optionDeleteButton.addSelectionListener( new SelectionListener()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                int index = 0;
+                for ( int i = 0; i < optionLineList.size(); i++ )
+                {
+                    OptionLine optionLine = ( OptionLine ) optionLineList.get( i );
+                    if ( optionLine.optionDeleteButton == e.widget )
+                    {
+                        index = i;
+                    }
+                }
+                deleteOptionLine( optionComposite, index );
+
+                Shell shell = getShell();
+                Point shellSize = shell.getSize();
+                Point groupSize = optionComposite.computeSize( SWT.DEFAULT, SWT.DEFAULT, true );
+                int newOptionGroupHeight = groupSize.y;
+                shell.setSize( shellSize.x, shellSize.y + newOptionGroupHeight - optionGroupHeight );
+                optionComposite.layout( true, true );
+                shell.layout( true, true );
+                optionGroupHeight = newOptionGroupHeight;
+
+                validate();
+            }
+
+
+            public void widgetDefaultSelected( SelectionEvent e )
+            {
+            }
+        } );
+
+        optionLine.optionText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                validate();
+            }
+        } );
+
+        return optionLine;
+    }
+
+
+    private void deleteOptionLine( Composite optionComposite, int index )
+    {
+        OptionLine optionLine = ( OptionLine ) optionLineList.remove( index );
+        if ( optionLine != null )
+        {
+            optionLine.optionText.dispose();
+            optionLine.optionAddButton.dispose();
+            optionLine.optionDeleteButton.dispose();
+        }
+    }
+
+    public class OptionLine
+    {
+        public Text optionText;
+
+        public Button optionAddButton;
+
+        public Button optionDeleteButton;
+    }
+
+
+    private void addLangLine( Composite langComposite, int index )
+    {
+
+        LangLine[] langLines = ( LangLine[] ) langLineList.toArray( new LangLine[langLineList.size()] );
+
+        if ( langLines.length > 0 )
+        {
+            for ( int i = 0; i < langLines.length; i++ )
+            {
+                LangLine oldLangLine = langLines[i];
+
+                // remember values
+                String oldLanguage = oldLangLine.languageCombo.getText();
+                String oldCountry = oldLangLine.countryCombo.getText();
+
+                // delete old
+                oldLangLine.langLabel.dispose();
+                oldLangLine.languageCombo.dispose();
+                oldLangLine.minusLabel.dispose();
+                oldLangLine.countryCombo.dispose();
+                oldLangLine.addButton.dispose();
+                oldLangLine.deleteButton.dispose();
+                langLineList.remove( oldLangLine );
+
+                // add new
+                LangLine newLangLine = createLangLine( langComposite );
+                langLineList.add( newLangLine );
+
+                // restore value
+                newLangLine.languageCombo.setText( oldLanguage );
+                newLangLine.countryCombo.setText( oldCountry );
+
+                // check
+                if ( index == i + 1 )
+                {
+                    LangLine langLine = createLangLine( langComposite );
+                    langLineList.add( langLine );
+                }
+            }
+        }
+        else
+        {
+            LangLine langLine = createLangLine( langComposite );
+            langLineList.add( langLine );
+        }
+    }
+
+
+    private LangLine createLangLine( final Composite langComposite )
+    {
+        final LangLine langLine = new LangLine();
+
+        langLine.langLabel = BaseWidgetUtils.createLabel( langComposite, "lang-", 1 );
+
+        langLine.languageCombo = BaseWidgetUtils.createCombo( langComposite, possibleLanguages, -1, 1 );
+
+        langLine.minusLabel = BaseWidgetUtils.createLabel( langComposite, "-", 1 );
+
+        langLine.countryCombo = BaseWidgetUtils.createCombo( langComposite, new String[0], -1, 1 );
+        langLine.countryCombo.setEnabled( false );
+
+        langLine.addButton = new Button( langComposite, SWT.PUSH );
+        langLine.addButton.setText( "  +   " );
+        langLine.addButton.addSelectionListener( new SelectionListener()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                int index = langLineList.size();
+                for ( int i = 0; i < langLineList.size(); i++ )
+                {
+                    LangLine langLine = ( LangLine ) langLineList.get( i );
+                    if ( langLine.addButton == e.widget )
+                    {
+                        index = i + 1;
+                    }
+                }
+                addLangLine( langComposite, index );
+
+                Shell shell = getShell();
+                Point shellSize = shell.getSize();
+                Point groupSize = langComposite.computeSize( SWT.DEFAULT, SWT.DEFAULT, true );
+                int newLangGroupHeight = groupSize.y;
+                shell.setSize( shellSize.x, shellSize.y + newLangGroupHeight - langGroupHeight );
+                langComposite.layout( true, true );
+                shell.layout( true, true );
+                langGroupHeight = newLangGroupHeight;
+
+                validate();
+            }
+
+
+            public void widgetDefaultSelected( SelectionEvent e )
+            {
+            }
+        } );
+
+        langLine.deleteButton = new Button( langComposite, SWT.PUSH );
+        langLine.deleteButton.setText( "  \u2212  " ); // \u2013
+        langLine.deleteButton.addSelectionListener( new SelectionListener()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                int index = 0;
+                for ( int i = 0; i < langLineList.size(); i++ )
+                {
+                    LangLine langLine = ( LangLine ) langLineList.get( i );
+                    if ( langLine.deleteButton == e.widget )
+                    {
+                        index = i;
+                    }
+                }
+                deleteLangLine( langComposite, index );
+
+                Shell shell = getShell();
+                Point shellSize = shell.getSize();
+                Point groupSize = langComposite.computeSize( SWT.DEFAULT, SWT.DEFAULT, true );
+                int newLangGroupHeight = groupSize.y;
+                shell.setSize( shellSize.x, shellSize.y + newLangGroupHeight - langGroupHeight );
+                langComposite.layout( true, true );
+                shell.layout( true, true );
+                langGroupHeight = newLangGroupHeight;
+
+                validate();
+            }
+
+
+            public void widgetDefaultSelected( SelectionEvent e )
+            {
+            }
+        } );
+
+        langLine.languageCombo.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                if ( "".equals( langLine.languageCombo.getText() ) )
+                {
+                    langLine.countryCombo.setEnabled( false );
+                }
+                else
+                {
+                    langLine.countryCombo.setEnabled( true );
+                    String oldValue = langLine.countryCombo.getText();
+                    if ( possibleLangToCountriesMap.containsKey( langLine.languageCombo.getText() ) )
+                    {
+                        langLine.countryCombo.setItems( ( String[] ) possibleLangToCountriesMap
+                            .get( langLine.languageCombo.getText() ) );
+                    }
+                    else
+                    {
+                        langLine.countryCombo.setItems( new String[0] );
+                    }
+                    langLine.countryCombo.setText( oldValue );
+                }
+                validate();
+            }
+        } );
+        langLine.countryCombo.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                validate();
+            }
+        } );
+
+        return langLine;
+    }
+
+
+    private void deleteLangLine( Composite langComposite, int index )
+    {
+        LangLine langLine = ( LangLine ) langLineList.remove( index );
+        if ( langLine != null )
+        {
+            langLine.langLabel.dispose();
+            langLine.languageCombo.dispose();
+            langLine.minusLabel.dispose();
+            langLine.countryCombo.dispose();
+            langLine.addButton.dispose();
+            langLine.deleteButton.dispose();
+        }
+    }
+
+    public class LangLine
+    {
+        public Label langLabel;
+
+        public Combo languageCombo;
+
+        public Label minusLabel;
+
+        public Combo countryCombo;
+
+        public Button addButton;
+
+        public Button deleteButton;
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/AttributeTypeWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/AttributeTypeWizardPage.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/AttributeTypeWizardPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/AttributeTypeWizardPage.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,237 @@
+/*
+ *  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.browser.ui.wizards;
+
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+
+public class AttributeTypeWizardPage extends WizardPage
+{
+
+    private AttributeWizard wizard;
+
+    private boolean initialShowSubschemaAttributesOnly;
+
+    private boolean initialHideExistingAttributes;
+
+    private String initialAttributeDescription;
+
+    private IEntry initialEntry;
+
+    private String parsedAttributeType;
+
+    private String[] possibleAttributeTypes;
+
+    private String[] possibleAttributeTypesSubschemaOnly;
+
+    private String[] possibleAttributeTypesSubschemaOnlyAndExistingHidden;
+
+    private Combo attributeTypeCombo;
+
+    private Button showSubschemAttributesOnlyButton;
+
+    private Button hideExistingAttributesButton;
+
+    private Text previewText;
+
+
+    public AttributeTypeWizardPage( String pageName, IEntry initialEntry, String initialAttributeDescription,
+        boolean initialShowSubschemaAttributesOnly, boolean initialHideExistingAttributes, AttributeWizard wizard )
+    {
+        super( pageName );
+        super.setTitle( "Attribute Type" );
+        super.setDescription( "Please enter or select the attribute type." );
+        // super.setImageDescriptor(BrowserUIPlugin.getDefault().getImageDescriptor(BrowserUIConstants.IMG_ATTRIBUTE_WIZARD));
+        super.setPageComplete( false );
+
+        this.wizard = wizard;
+        this.initialEntry = initialEntry;
+        this.initialAttributeDescription = initialAttributeDescription;
+        this.initialShowSubschemaAttributesOnly = initialShowSubschemaAttributesOnly;
+        this.initialHideExistingAttributes = initialHideExistingAttributes;
+
+        this.possibleAttributeTypes = this.initialEntry.getConnection().getSchema().getAttributeTypeDescriptionNames();
+        Arrays.sort( this.possibleAttributeTypes );
+        this.possibleAttributeTypesSubschemaOnly = this.initialEntry.getSubschema().getAllAttributeNames();
+        Arrays.sort( this.possibleAttributeTypesSubschemaOnly );
+
+        Set set = new HashSet( Arrays.asList( this.initialEntry.getSubschema().getAllAttributeNames() ) );
+        IAttribute[] existingAttributes = this.initialEntry.getAttributes();
+        for ( int i = 0; existingAttributes != null && i < existingAttributes.length; i++ )
+        {
+            set.remove( existingAttributes[i].getDescription() );
+        }
+        this.possibleAttributeTypesSubschemaOnlyAndExistingHidden = ( String[] ) set.toArray( new String[set.size()] );
+        Arrays.sort( this.possibleAttributeTypesSubschemaOnlyAndExistingHidden );
+
+        String attributeDescription = this.initialAttributeDescription;
+        if ( attributeDescription == null )
+            attributeDescription = "";
+        String[] attributeDescriptionComponents = attributeDescription.split( ";" );
+        this.parsedAttributeType = attributeDescriptionComponents[0];
+
+    }
+
+
+    private void validate()
+    {
+        this.previewText.setText( wizard.getAttributeDescription() );
+        this.setPageComplete( !"".equals( this.attributeTypeCombo.getText() ) );
+    }
+
+
+    public void setVisible( boolean visible )
+    {
+        super.setVisible( visible );
+        if ( visible )
+        {
+            this.validate();
+        }
+    }
+
+
+    public void createControl( Composite parent )
+    {
+
+        Composite composite = new Composite( parent, SWT.NONE );
+        GridLayout gl = new GridLayout( 2, false );
+        composite.setLayout( gl );
+        composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+
+        BaseWidgetUtils.createLabel( composite, "Attribute type:", 1 );
+        this.attributeTypeCombo = BaseWidgetUtils.createCombo( composite, possibleAttributeTypes, -1, 1 );
+        this.attributeTypeCombo.setText( parsedAttributeType );
+
+        BaseWidgetUtils.createSpacer( composite, 1 );
+        this.showSubschemAttributesOnlyButton = BaseWidgetUtils.createCheckbox( composite,
+            "Show subschema attributes only", 1 );
+        this.showSubschemAttributesOnlyButton.setSelection( initialShowSubschemaAttributesOnly );
+
+        BaseWidgetUtils.createSpacer( composite, 1 );
+        this.hideExistingAttributesButton = BaseWidgetUtils.createCheckbox( composite, "Hide existing attributes", 1 );
+        this.hideExistingAttributesButton.setSelection( initialHideExistingAttributes );
+
+        Label l = new Label( composite, SWT.NONE );
+        GridData gd = new GridData( GridData.FILL_BOTH );
+        gd.horizontalSpan = 2;
+        l.setLayoutData( gd );
+
+        /* this.previewLabel = */BaseWidgetUtils.createLabel( composite, "Preview:", 1 );
+        this.previewText = BaseWidgetUtils.createReadonlyText( composite, "", 1 );
+
+        // attribute type listener
+        this.attributeTypeCombo.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                validate();
+            }
+        } );
+
+        // filter listener
+        this.showSubschemAttributesOnlyButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                updateFilter();
+                validate();
+            }
+        } );
+        this.hideExistingAttributesButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                updateFilter();
+                validate();
+            }
+        } );
+        updateFilter();
+
+        setControl( composite );
+    }
+
+
+    private void updateFilter()
+    {
+        // enable/disable filter buttons
+        this.hideExistingAttributesButton.setEnabled( this.showSubschemAttributesOnlyButton.getSelection() );
+        if ( this.possibleAttributeTypesSubschemaOnly.length == 0 )
+        {
+            this.showSubschemAttributesOnlyButton.setSelection( false );
+            this.showSubschemAttributesOnlyButton.setEnabled( false );
+        }
+        if ( this.possibleAttributeTypesSubschemaOnlyAndExistingHidden.length == 0 )
+        {
+            this.hideExistingAttributesButton.setEnabled( false );
+            this.hideExistingAttributesButton.setSelection( false );
+        }
+
+        // update filters
+        String value = this.attributeTypeCombo.getText();
+        if ( this.hideExistingAttributesButton.getSelection() && this.showSubschemAttributesOnlyButton.getSelection() )
+        {
+            this.attributeTypeCombo.setItems( this.possibleAttributeTypesSubschemaOnlyAndExistingHidden );
+        }
+        else if ( this.showSubschemAttributesOnlyButton.getSelection() )
+        {
+            this.attributeTypeCombo.setItems( this.possibleAttributeTypesSubschemaOnly );
+        }
+        else
+        {
+            this.attributeTypeCombo.setItems( this.possibleAttributeTypes );
+        }
+        this.attributeTypeCombo.setText( value );
+    }
+
+
+    String getAttributeType()
+    {
+
+        if ( this.attributeTypeCombo == null | this.attributeTypeCombo.isDisposed() )
+        {
+            return "";
+        }
+
+        return attributeTypeCombo.getText();
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/AttributeWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/AttributeWizard.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/AttributeWizard.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/AttributeWizard.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,164 @@
+/*
+ *  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.browser.ui.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.core.events.ModelModifier;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
+
+
+public class AttributeWizard extends Wizard implements INewWizard, ModelModifier
+{
+
+    private AttributeTypeWizardPage typePage;
+
+    private AttributeOptionsWizardPage optionsPage;
+
+    private boolean initialShowSubschemaAttributesOnly;
+
+    private boolean initialHideExistingAttributes;
+
+    private String initialAttributeDescription;
+
+    private IEntry initialEntry;
+
+    private String finalAttributeDescription = null;
+
+
+    public AttributeWizard()
+    {
+        super.setWindowTitle( "New Attribute" );
+        super.setNeedsProgressMonitor( false );
+        this.initialShowSubschemaAttributesOnly = true;
+        this.initialHideExistingAttributes = true;
+        this.initialAttributeDescription = "";
+        this.initialEntry = null;
+    }
+
+
+    public AttributeWizard( String title, boolean showSubschemaAttributesOnly, boolean hideExistingAttributes,
+        String attributeDescription, IEntry entry )
+    {
+        super.setWindowTitle( title );
+        super.setNeedsProgressMonitor( false );
+        this.initialShowSubschemaAttributesOnly = showSubschemaAttributesOnly;
+        this.initialHideExistingAttributes = hideExistingAttributes;
+        this.initialAttributeDescription = attributeDescription;
+        this.initialEntry = entry;
+    }
+
+
+    public static String getId()
+    {
+        return AttributeWizard.class.getName();
+    }
+
+
+    public void init( IWorkbench workbench, IStructuredSelection selection )
+    {
+    }
+
+
+    public void addPages()
+    {
+        if ( this.initialEntry != null )
+        {
+            typePage = new AttributeTypeWizardPage( AttributeTypeWizardPage.class.getName(), this.initialEntry,
+                this.initialAttributeDescription, this.initialShowSubschemaAttributesOnly,
+                this.initialHideExistingAttributes, this );
+            addPage( typePage );
+
+            optionsPage = new AttributeOptionsWizardPage( AttributeOptionsWizardPage.class.getName(),
+                this.initialAttributeDescription, this );
+            addPage( optionsPage );
+        }
+        else
+        {
+            IWizardPage page = new DummyWizardPage();
+            addPage( page );
+        }
+
+        PlatformUI.getWorkbench().getHelpSystem().setHelp( getContainer().getShell(),
+            BrowserUIPlugin.PLUGIN_ID + "." + "tools_attribute_wizard" );
+    }
+
+    class DummyWizardPage extends WizardPage
+    {
+
+        protected DummyWizardPage()
+        {
+            super( "" );
+            super.setTitle( "No entry selected" );
+            super.setDescription( "In order to use the attribute creation wizard please select an entry." );
+            // super.setImageDescriptor(BrowserUIPlugin.getDefault().getImageDescriptor(BrowserUIConstants.IMG_ATTRIBUTE_WIZARD));
+            super.setPageComplete( true );
+        }
+
+
+        public void createControl( Composite parent )
+        {
+            Composite composite = new Composite( parent, SWT.NONE );
+            GridLayout gl = new GridLayout( 1, false );
+            composite.setLayout( gl );
+            composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+
+            setControl( composite );
+        }
+    }
+
+
+    public boolean performCancel()
+    {
+        return true;
+    }
+
+
+    public boolean performFinish()
+    {
+        finalAttributeDescription = getAttributeDescription();
+        return true;
+    }
+
+
+    public String getAttributeDescription()
+    {
+        if ( finalAttributeDescription != null )
+        {
+            return finalAttributeDescription;
+        }
+
+        return typePage.getAttributeType() + optionsPage.getAttributeOptions();
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationApplyOnWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationApplyOnWizardPage.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationApplyOnWizardPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationApplyOnWizardPage.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,320 @@
+/*
+ *  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.browser.ui.wizards;
+
+
+import java.util.ArrayList;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.directory.ldapstudio.browser.core.model.DN;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IBookmark;
+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.ISearch;
+import org.apache.directory.ldapstudio.browser.core.model.ISearchResult;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.core.model.NameException;
+import org.apache.directory.ldapstudio.browser.ui.actions.SelectionUtils;
+import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils;
+import org.apache.directory.ldapstudio.browser.ui.widgets.WidgetModifyEvent;
+import org.apache.directory.ldapstudio.browser.ui.widgets.WidgetModifyListener;
+import org.apache.directory.ldapstudio.browser.ui.widgets.search.SearchPageWrapper;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.PlatformUI;
+
+
+public class BatchOperationApplyOnWizardPage extends WizardPage
+{
+
+    private String[] initCurrentSelectionTexts;
+
+    private DN[][] initCurrentSelectionDns;
+
+    private ISearch initSearch;
+
+    private Button currentSelectionButton;
+
+    private Combo currentSelectionCombo;
+
+    private Button searchButton;
+
+    private SearchPageWrapper spw;
+
+
+    public BatchOperationApplyOnWizardPage( String pageName, BatchOperationWizard wizard )
+    {
+        super( pageName );
+        super.setTitle( "Select Application Entries" );
+        super.setDescription( "Please select the entries where the batch operation should be applied to." );
+        super.setPageComplete( false );
+
+        this.prepareCurrentSelection();
+        this.prepareSearch();
+    }
+
+
+    private void validate()
+    {
+        setPageComplete( getApplyOnDns() != null || this.spw.isValid() );
+    }
+
+
+    public void createControl( Composite parent )
+    {
+
+        Composite composite = new Composite( parent, SWT.NONE );
+        GridLayout gl = new GridLayout( 1, false );
+        composite.setLayout( gl );
+        composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+
+        Composite applyOnGroup = composite;
+
+        this.currentSelectionButton = BaseWidgetUtils.createRadiobutton( applyOnGroup, "Current Selection:", 1 );
+        this.currentSelectionButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                enableCurrentSelectionWidgets( currentSelectionButton.getSelection() );
+                validate();
+            }
+        } );
+
+        Composite currentSelectionComposite = BaseWidgetUtils.createColumnContainer( applyOnGroup, 2, 1 );
+        BaseWidgetUtils.createRadioIndent( currentSelectionComposite, 1 );
+        this.currentSelectionCombo = BaseWidgetUtils.createReadonlyCombo( currentSelectionComposite,
+            this.initCurrentSelectionTexts, 0, 1 );
+        this.currentSelectionCombo.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                validate();
+            }
+        } );
+
+        BaseWidgetUtils.createSpacer( applyOnGroup, 1 );
+        BaseWidgetUtils.createSpacer( applyOnGroup, 1 );
+
+        this.searchButton = BaseWidgetUtils.createRadiobutton( applyOnGroup, "Results of following Search:", 1 );
+        this.searchButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                enableSearchWidgets( searchButton.getSelection() );
+                validate();
+            }
+        } );
+
+        Composite searchComposite = BaseWidgetUtils.createColumnContainer( applyOnGroup, 2, 1 );
+        BaseWidgetUtils.createRadioIndent( searchComposite, 1 );
+        Composite innerSearchComposite = BaseWidgetUtils.createColumnContainer( searchComposite, 3, 1 );
+        this.spw = new SearchPageWrapper( SearchPageWrapper.NAME_INVISIBLE
+            | SearchPageWrapper.RETURNINGATTRIBUTES_INVISIBLE | SearchPageWrapper.REFERRALOPTIONS_READONLY );
+        this.spw.createContents( innerSearchComposite );
+        this.spw.loadFromSearch( this.initSearch );
+        this.spw.addWidgetModifyListener( new WidgetModifyListener()
+        {
+            public void widgetModified( WidgetModifyEvent event )
+            {
+                validate();
+            }
+        } );
+
+        this.currentSelectionButton.setSelection( this.currentSelectionCombo.getItemCount() > 0 );
+        this.currentSelectionButton.setEnabled( this.currentSelectionCombo.getItemCount() > 0 );
+        this.searchButton.setSelection( this.currentSelectionCombo.getItemCount() == 0 );
+        this.enableCurrentSelectionWidgets( this.currentSelectionButton.getSelection() );
+        this.enableSearchWidgets( this.searchButton.getSelection() );
+
+        validate();
+
+        setControl( composite );
+    }
+
+
+    public DN[] getApplyOnDns()
+    {
+        if ( currentSelectionButton.getSelection() )
+        {
+            int index = currentSelectionCombo.getSelectionIndex();
+            return initCurrentSelectionDns[index];
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    public ISearch getApplyOnSearch()
+    {
+        if ( searchButton.getSelection() )
+        {
+            return this.initSearch;
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    private void enableCurrentSelectionWidgets( boolean b )
+    {
+        currentSelectionCombo.setEnabled( b );
+    }
+
+
+    private void enableSearchWidgets( boolean b )
+    {
+        spw.setEnabled( b );
+    }
+
+
+    private void prepareSearch()
+    {
+        ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService()
+            .getSelection();
+        this.initSearch = SelectionUtils.getExampleSearch( selection );
+        this.initSearch.setName( null );
+
+        // never follow referrals for a batch operation!
+        this.initSearch.setReferralsHandlingMethod( IConnection.HANDLE_REFERRALS_IGNORE );
+    }
+
+
+    private void prepareCurrentSelection()
+    {
+
+        ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService()
+            .getSelection();
+        ISearch[] searches = SelectionUtils.getSearches( selection );
+        IEntry[] entries = SelectionUtils.getEntries( selection );
+        ISearchResult[] searchResults = SelectionUtils.getSearchResults( selection );
+        IBookmark[] bookmarks = SelectionUtils.getBookmarks( selection );
+        IAttribute[] attributes = SelectionUtils.getAttributes( selection );
+        IValue[] values = SelectionUtils.getValues( selection );
+
+        List textList = new ArrayList();
+        List dnsList = new ArrayList();
+
+        if ( attributes.length + values.length > 0 )
+        {
+            Set internalDnSet = new LinkedHashSet();
+            for ( int v = 0; v < values.length; v++ )
+            {
+                if ( values[v].isString() )
+                {
+                    try
+                    {
+                        DN dn = new DN( values[v].getStringValue() );
+                        internalDnSet.add( dn );
+                    }
+                    catch ( NameException e )
+                    {
+                    }
+                }
+            }
+
+            for ( int a = 0; a < attributes.length; a++ )
+            {
+                IValue[] vals = attributes[a].getValues();
+                for ( int v = 0; v < vals.length; v++ )
+                {
+                    if ( vals[v].isString() )
+                    {
+                        try
+                        {
+                            DN dn = new DN( vals[v].getStringValue() );
+                            internalDnSet.add( dn );
+                        }
+                        catch ( NameException e )
+                        {
+                        }
+                    }
+                }
+            }
+
+            if ( !internalDnSet.isEmpty() )
+            {
+                dnsList.add( internalDnSet.toArray( new DN[internalDnSet.size()] ) );
+                textList.add( "DNs of selected Attributes (" + internalDnSet.size() + " Entries)" );
+            }
+        }
+        if ( searches.length == 1 && searches[0].getSearchResults() != null )
+        {
+            Set internalDnSet = new LinkedHashSet();
+            ISearchResult[] srs = searches[0].getSearchResults();
+            for ( int i = 0; i < srs.length; i++ )
+            {
+                internalDnSet.add( srs[i].getDn() );
+            }
+
+            dnsList.add( internalDnSet.toArray( new DN[internalDnSet.size()] ) );
+            textList.add( "Search Results of '" + searches[0].getName() + "' (" + searches[0].getSearchResults().length
+                + " Entries)" );
+        }
+        if ( entries.length + searchResults.length + bookmarks.length > 0 )
+        {
+            Set internalDnSet = new LinkedHashSet();
+            for ( int i = 0; i < entries.length; i++ )
+            {
+                internalDnSet.add( entries[i].getDn() );
+            }
+            for ( int i = 0; i < searchResults.length; i++ )
+            {
+                internalDnSet.add( searchResults[i].getDn() );
+            }
+            for ( int i = 0; i < bookmarks.length; i++ )
+            {
+                internalDnSet.add( bookmarks[i].getDn() );
+            }
+
+            dnsList.add( internalDnSet.toArray( new DN[internalDnSet.size()] ) );
+            textList.add( "Selected Entries (" + internalDnSet.size() + " Entries)" );
+        }
+
+        this.initCurrentSelectionTexts = ( String[] ) textList.toArray( new String[textList.size()] );
+        this.initCurrentSelectionDns = ( DN[][] ) dnsList.toArray( new DN[0][0] );
+
+    }
+
+
+    public void saveDialogSettings()
+    {
+        this.spw.saveToSearch( initSearch );
+    }
+
+}
\ No newline at end of file

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationFinishWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationFinishWizardPage.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationFinishWizardPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationFinishWizardPage.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,115 @@
+/*
+ *  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.browser.ui.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils;
+import org.eclipse.jface.wizard.WizardPage;
+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;
+
+
+public class BatchOperationFinishWizardPage extends WizardPage
+{
+
+    public final static int EXECUTION_METHOD_NONE = -1;
+
+    public final static int EXECUTION_METHOD_LDIF = 0;
+
+    public final static int EXECUTION_METHOD_ONLINE = 1;
+
+    private Button executeOnlineButton;
+
+    private Button generateLdifButton;
+
+
+    public BatchOperationFinishWizardPage( String pageName, BatchOperationWizard wizard )
+    {
+        super( pageName );
+        super.setTitle( "Select Execution Method" );
+        super
+            .setDescription( "Please select if the batch operation should be executed online or a LDIF should be generated." );
+        super.setPageComplete( false );
+    }
+
+
+    private void validate()
+    {
+        setPageComplete( getExecutionMethod() != EXECUTION_METHOD_NONE );
+    }
+
+
+    public void createControl( Composite parent )
+    {
+
+        Composite composite = new Composite( parent, SWT.NONE );
+        GridLayout gl = new GridLayout( 1, false );
+        composite.setLayout( gl );
+        composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+
+        generateLdifButton = BaseWidgetUtils.createRadiobutton( composite, "Generate LDIF", 1 );
+        generateLdifButton.setSelection( true );
+        generateLdifButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                validate();
+            }
+        } );
+
+        executeOnlineButton = BaseWidgetUtils.createRadiobutton( composite, "Excecute online", 1 );
+        executeOnlineButton.setEnabled( false );
+        executeOnlineButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                validate();
+            }
+        } );
+
+        validate();
+
+        setControl( composite );
+    }
+
+
+    public int getExecutionMethod()
+    {
+        if ( executeOnlineButton.getSelection() )
+        {
+            return EXECUTION_METHOD_ONLINE;
+        }
+        else if ( generateLdifButton.getSelection() )
+        {
+            return EXECUTION_METHOD_LDIF;
+        }
+        else
+        {
+            return EXECUTION_METHOD_NONE;
+        }
+    }
+
+}