You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by fe...@apache.org on 2007/11/05 17:48:54 UTC

svn commit: r592079 [15/17] - in /directory/sandbox/felixk/studio-ldapbrowser-common: ./ META-INF/ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/directory/ src/main/java/org/apache/directory/studio/...

Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/ReturningAttributesWidget.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/ReturningAttributesWidget.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/ReturningAttributesWidget.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/ReturningAttributesWidget.java Mon Nov  5 08:48:35 2007
@@ -0,0 +1,199 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.common.widgets.search;
+
+
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.BrowserWidget;
+import org.apache.directory.studio.ldapbrowser.common.widgets.DialogContentAssistant;
+import org.apache.directory.studio.ldapbrowser.common.widgets.HistoryUtils;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.utils.Utils;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+
+
+/**
+ * The ReturningAttributesWidget could be used to enter a list of attribute types
+ * return by an LDPA search. It is composed of a combo with content assist
+ * and a history.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ReturningAttributesWidget extends BrowserWidget
+{
+
+    /** The returning attributes combo. */
+    private Combo returningAttributesCombo;
+
+    /** The content assist processor. */
+    private ReturningAttributesContentAssistProcessor contentAssistProcessor;
+
+    /** The connection. */
+    private IBrowserConnection browserConnection;
+
+    /** The initial returning attributes. */
+    private String[] initialReturningAttributes;
+
+
+    /**
+     * Creates a new instance of ReturningAttributesWidget.
+     * 
+     * @param initialReturningAttributes the initial returning attributes
+     * @param browserConnection the browser  connection
+     */
+    public ReturningAttributesWidget( IBrowserConnection browserConnection, String[] initialReturningAttributes )
+    {
+        this.browserConnection = browserConnection;
+        this.initialReturningAttributes = initialReturningAttributes;
+    }
+
+
+    /**
+     * Creates a new instance of ReturningAttributesWidget with no connection
+     * and no initial returning attributes. 
+     *
+     */
+    public ReturningAttributesWidget()
+    {
+        this.browserConnection = null;
+        this.initialReturningAttributes = null;
+    }
+
+
+    /**
+     * Creates the widget.
+     * 
+     * @param parent the parent
+     */
+    public void createWidget( Composite parent )
+    {
+        // Combo
+        returningAttributesCombo = BaseWidgetUtils.createCombo( parent, new String[0], -1, 1 );
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = 1;
+        gd.widthHint = 200;
+        returningAttributesCombo.setLayoutData( gd );
+
+        // Content assist
+        contentAssistProcessor = new ReturningAttributesContentAssistProcessor( new String[0] );
+        DialogContentAssistant raca = new DialogContentAssistant();
+        raca.enableAutoInsert( true );
+        raca.enableAutoActivation( true );
+        raca.setAutoActivationDelay( 500 );
+        raca.setContentAssistProcessor( contentAssistProcessor, IDocument.DEFAULT_CONTENT_TYPE );
+        raca.install( returningAttributesCombo );
+
+        // History
+        String[] history = HistoryUtils.load( BrowserCommonConstants.DIALOGSETTING_KEY_RETURNING_ATTRIBUTES_HISTORY );
+        for ( int i = 0; i < history.length; i++ )
+        {
+            history[i] = Utils.arrayToString( Utils.stringToArray( history[i] ) );
+        }
+        returningAttributesCombo.setItems( history );
+        returningAttributesCombo.setText( Utils.arrayToString( this.initialReturningAttributes ) );
+
+        returningAttributesCombo.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                notifyListeners();
+            }
+        } );
+
+        setBrowserConnection( browserConnection );
+    }
+
+
+    /**
+     * Sets the browser connection.
+     * 
+     * @param browserConnection the browser connection
+     */
+    public void setBrowserConnection( IBrowserConnection browserConnection )
+    {
+        this.browserConnection = browserConnection;
+        contentAssistProcessor.setPossibleAttributeTypes( browserConnection == null ? new String[0] : browserConnection.getSchema()
+            .getAttributeTypeDescriptionNames() );
+    }
+
+
+    /**
+     * Sets the initial returning attributes.
+     * 
+     * @param initialReturningAttributes the initial returning attributes
+     */
+    public void setInitialReturningAttributes( String[] initialReturningAttributes )
+    {
+        this.initialReturningAttributes = initialReturningAttributes;
+        returningAttributesCombo.setText( Utils.arrayToString( initialReturningAttributes ) );
+    }
+
+
+    /**
+     * Sets the enabled state of the widget.
+     * 
+     * @param b true to enable the widget, false to disable the widget
+     */
+    public void setEnabled( boolean b )
+    {
+        this.returningAttributesCombo.setEnabled( b );
+    }
+
+
+    /**
+     * Gets the returning attributes.
+     * 
+     * @return the returning attributes
+     */
+    public String[] getReturningAttributes()
+    {
+        String s = this.returningAttributesCombo.getText();
+        return Utils.stringToArray( s );
+    }
+
+
+    /**
+     * Saves dialog settings.
+     */
+    public void saveDialogSettings()
+    {
+        HistoryUtils.save( BrowserCommonConstants.DIALOGSETTING_KEY_RETURNING_ATTRIBUTES_HISTORY, Utils
+            .arrayToString( getReturningAttributes() ) );
+    }
+
+
+    /**
+     * Sets the focus.
+     */
+    public void setFocus()
+    {
+        returningAttributesCombo.setFocus();
+
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/ReturningAttributesWidget.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/ScopeWidget.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/ScopeWidget.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/ScopeWidget.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/ScopeWidget.java Mon Nov  5 08:48:35 2007
@@ -0,0 +1,192 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.common.widgets.search;
+
+
+import org.apache.directory.studio.ldapbrowser.common.widgets.BrowserWidget;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearch.SearchScope;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+
+/**
+ * The ScopeWidget could be used to select the scope of a search. 
+ * It is composed of a group with radio buttons.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ScopeWidget extends BrowserWidget
+{
+
+    /** The initial scope. */
+    private SearchScope initialScope;
+
+    /** The scope group. */
+    private Group scopeGroup;
+
+    /** The scope object button. */
+    private Button scopeObjectButton;
+
+    /** The scope onelevel button. */
+    private Button scopeOnelevelButton;
+
+    /** The scope subtree button. */
+    private Button scopeSubtreeButton;
+
+
+    /**
+     * Creates a new instance of ScopeWidget with the given
+     * initial scope.
+     * 
+     * @param initialScope the initial scope
+     */
+    public ScopeWidget( SearchScope initialScope )
+    {
+        this.initialScope = initialScope;
+    }
+
+
+    /**
+     * Creates a new instance of ScopeWidget with initial scope
+     * {@link SearchScope.OBJECT}.
+     */
+    public ScopeWidget()
+    {
+        this.initialScope = SearchScope.OBJECT;
+    }
+
+
+    /**
+     * Creates the widget.
+     * 
+     * @param parent the parent
+     */
+    public void createWidget( Composite parent )
+    {
+
+        // Scope group
+        scopeGroup = new Group( parent, SWT.NONE );
+        scopeGroup.setText( "Scope" );
+        scopeGroup.setLayout( new GridLayout( 1, false ) );
+        scopeGroup.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+
+        // Object radio
+        scopeObjectButton = new Button( scopeGroup, SWT.RADIO );
+        scopeObjectButton.setText( "&Object" );
+        scopeObjectButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                notifyListeners();
+            }
+        } );
+
+        // Onelevel radio
+        scopeOnelevelButton = new Button( scopeGroup, SWT.RADIO );
+        scopeOnelevelButton.setText( "One &Level" );
+        scopeOnelevelButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                notifyListeners();
+            }
+        } );
+
+        // subtree button
+        scopeSubtreeButton = new Button( scopeGroup, SWT.RADIO );
+        scopeSubtreeButton.setText( "&Subtree" );
+        scopeSubtreeButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                notifyListeners();
+            }
+        } );
+
+        setScope( initialScope );
+    }
+
+
+    /**
+     * Sets the scope.
+     * 
+     * @param scope the scope
+     */
+    public void setScope( SearchScope scope )
+    {
+        initialScope = scope;
+        scopeObjectButton.setSelection( initialScope == SearchScope.OBJECT );
+        scopeOnelevelButton.setSelection( initialScope == SearchScope.ONELEVEL );
+        scopeSubtreeButton.setSelection( initialScope == SearchScope.SUBTREE );
+    }
+
+
+    /**
+     * Gets the scope.
+     * 
+     * @return the scope
+     */
+    public SearchScope getScope()
+    {
+        SearchScope scope;
+
+        if ( scopeSubtreeButton.getSelection() )
+        {
+            scope = SearchScope.SUBTREE;
+        }
+        else if ( scopeOnelevelButton.getSelection() )
+        {
+            scope =SearchScope.ONELEVEL;
+        }
+        else if ( scopeObjectButton.getSelection() )
+        {
+            scope = SearchScope.OBJECT;
+        }
+        else
+        {
+            scope = SearchScope.ONELEVEL;
+        }
+
+        return scope;
+    }
+
+
+    /**
+     * Sets the enabled state of the widget.
+     * 
+     * @param b true to enable the widget, false to disable the widget
+     */
+    public void setEnabled( boolean b )
+    {
+        scopeGroup.setEnabled( b );
+        scopeObjectButton.setEnabled( b );
+        scopeOnelevelButton.setEnabled( b );
+        scopeSubtreeButton.setEnabled( b );
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/ScopeWidget.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/SearchPageWrapper.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/SearchPageWrapper.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/SearchPageWrapper.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/SearchPageWrapper.java Mon Nov  5 08:48:35 2007
@@ -0,0 +1,945 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.common.widgets.search;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.BrowserWidget;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyEvent;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyListener;
+import org.apache.directory.studio.ldapbrowser.core.jobs.SearchJob;
+import org.apache.directory.studio.ldapbrowser.core.model.Control;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection.AliasDereferencingMethod;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection.ReferralHandlingMethod;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearch.SearchScope;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.AttributeTypeDescription;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils;
+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;
+
+
+/**
+ * The SearchPageWrapper is used to arrange all input elements of a
+ * search page. It is used by the search page, the search properties page,
+ * the batch operation wizard and the export wizards.
+ * 
+ * The style is used to specify the invisible and readonly elements. 
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SearchPageWrapper extends BrowserWidget
+{
+
+    /** The default style */
+    public static final int NONE = 0;
+
+    /** Style for invisible name field */
+    public static final int NAME_INVISIBLE = 1 << 1;
+
+    /** Style for read-only name field */
+    public static final int NAME_READONLY = 1 << 2;
+
+    /** Style for invisible connection field */
+    public static final int CONNECTION_INVISIBLE = 1 << 3;
+
+    /** Style for read-only connection field */
+    public static final int CONNECTION_READONLY = 1 << 4;
+
+    /** Style for invisible search base field */
+    public static final int SEARCHBASE_INVISIBLE = 1 << 5;
+
+    /** Style for read-only search base field */
+    public static final int SEARCHBASE_READONLY = 1 << 6;
+
+    /** Style for invisible filter field */
+    public static final int FILTER_INVISIBLE = 1 << 7;
+
+    /** Style for read-only filter field */
+    public static final int FILTER_READONLY = 1 << 8;
+
+    /** Style for invisible returning attributes field */
+    public static final int RETURNINGATTRIBUTES_INVISIBLE = 1 << 9;
+
+    /** Style for read-only returning attributes field */
+    public static final int RETURNINGATTRIBUTES_READONLY = 1 << 10;
+
+    /** Style for visible return DN checkbox */
+    public static final int RETURN_DN_VISIBLE = 1 << 11;
+
+    /** Style for checked return DN checkbox */
+    public static final int RETURN_DN_CHECKED = 1 << 12;
+
+    /** Style for visible return all attributes checkbox */
+    public static final int RETURN_ALLATTRIBUTES_VISIBLE = 1 << 13;
+
+    /** Style for checked return all attributes checkbox */
+    public static final int RETURN_ALLATTRIBUTES_CHECKED = 1 << 14;
+
+    /** Style for visible return operational attributes checkbox */
+    public static final int RETURN_OPERATIONALATTRIBUTES_VISIBLE = 1 << 15;
+
+    /** Style for checked return operational attributes checkbox */
+    public static final int RETURN_OPERATIONALATTRIBUTES_CHECKED = 1 << 16;
+
+    /** Style for invisible options */
+    public static final int OPTIONS_INVISIBLE = 1 << 21;
+
+    /** Style for read-only scope options */
+    public static final int SCOPEOPTIONS_READONLY = 1 << 22;
+
+    /** Style for read-only limit options */
+    public static final int LIMITOPTIONS_READONLY = 1 << 23;
+
+    /** Style for read-only alias options */
+    public static final int ALIASOPTIONS_READONLY = 1 << 24;
+
+    /** Style for read-only referrals options */
+    public static final int REFERRALOPTIONS_READONLY = 1 << 25;
+
+    /** Style for invisible controls fields */
+    public static final int CONTROLS_INVISIBLE = 1 << 30;
+
+    /** The style. */
+    protected int style;
+
+    /** The search name label. */
+    protected Label searchNameLabel;
+
+    /** The search name text. */
+    protected Text searchNameText;
+
+    /** The connection label. */
+    protected Label connectionLabel;
+
+    /** The browser connection widget. */
+    protected BrowserConnectionWidget browserConnectionWidget;
+
+    /** The search base label. */
+    protected Label searchBaseLabel;
+
+    /** The search base widget. */
+    protected EntryWidget searchBaseWidget;
+
+    /** The filter label. */
+    protected Label filterLabel;
+
+    /** The filter widget. */
+    protected FilterWidget filterWidget;
+
+    /** The returning attributes label. */
+    protected Label returningAttributesLabel;
+
+    /** The returning attributes widget. */
+    protected ReturningAttributesWidget returningAttributesWidget;
+
+    /** The return dn button. */
+    protected Button returnDnButton;
+
+    /** The return all attributes button. */
+    protected Button returnAllAttributesButton;
+
+    /** The return operational attributes button. */
+    protected Button returnOperationalAttributesButton;
+
+    /** The scope widget. */
+    protected ScopeWidget scopeWidget;
+
+    /** The limit widget. */
+    protected LimitWidget limitWidget;
+
+    /** The aliases dereferencing widget. */
+    protected AliasesDereferencingWidget aliasesDereferencingWidget;
+
+    /** The referrals handling widget. */
+    protected ReferralsHandlingWidget referralsHandlingWidget;
+
+    /** The control label. */
+    protected Label controlLabel;
+
+    /** The subentries control button. */
+    protected Button subentriesControlButton;
+
+
+    /**
+     * Creates a new instance of SearchPageWrapper.
+     * 
+     * @param style the style
+     */
+    public SearchPageWrapper( int style )
+    {
+        this.style = style;
+    }
+
+
+    /**
+     * Creates the contents.
+     * 
+     * @param composite the composite
+     */
+    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 );
+    }
+
+
+    /**
+     * Checks if the given style is active.
+     * 
+     * @param requiredStyle the required style to check
+     * 
+     * @return true, if the required style is active
+     */
+    protected boolean isActive( int requiredStyle )
+    {
+        return ( style & requiredStyle ) != 0;
+    }
+
+
+    /**
+     * Creates the search name line.
+     * 
+     * @param composite the composite
+     */
+    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 );
+    }
+
+
+    /**
+     * Creates the connection line.
+     * 
+     * @param composite the composite
+     */
+    protected void createConnectionLine( final Composite composite )
+    {
+        if ( isActive( CONNECTION_INVISIBLE ) )
+        {
+            return;
+        }
+
+        connectionLabel = BaseWidgetUtils.createLabel( composite, "Connection:", 1 );
+        browserConnectionWidget = new BrowserConnectionWidget();
+        browserConnectionWidget.createWidget( composite );
+        browserConnectionWidget.setEnabled( !isActive( CONNECTION_READONLY ) );
+        browserConnectionWidget.addWidgetModifyListener( new WidgetModifyListener()
+        {
+            public void widgetModified( WidgetModifyEvent event )
+            {
+                validate();
+            }
+        } );
+        BaseWidgetUtils.createSpacer( composite, 3 );
+    }
+
+
+    /**
+     * Creates the search base line.
+     * 
+     * @param composite the composite
+     */
+    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 );
+    }
+
+
+    /**
+     * Creates the filter line.
+     * 
+     * @param composite the composite
+     */
+    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 );
+    }
+
+
+    /**
+     * Creates the returning attributes line.
+     * 
+     * @param composite the composite
+     */
+    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();
+            }
+        } );
+
+        // special returning attributes options
+        if ( isActive( RETURN_DN_VISIBLE ) || isActive( RETURN_ALLATTRIBUTES_VISIBLE )
+            || isActive( RETURN_OPERATIONALATTRIBUTES_VISIBLE ) )
+        {
+            BaseWidgetUtils.createSpacer( composite, 1 );
+            Composite buttonComposite = BaseWidgetUtils.createColumnContainer( composite, 3, 1 );
+            if ( isActive( RETURN_DN_VISIBLE ) )
+            {
+                returnDnButton = BaseWidgetUtils.createCheckbox( buttonComposite, "Export DN", 1 );
+                returnDnButton.addSelectionListener( new SelectionAdapter()
+                {
+                    public void widgetSelected( SelectionEvent e )
+                    {
+                        validate();
+                    }
+                } );
+                returnDnButton.setSelection( isActive( RETURN_DN_CHECKED ) );
+            }
+            if ( isActive( RETURN_ALLATTRIBUTES_VISIBLE ) )
+            {
+                returnAllAttributesButton = BaseWidgetUtils.createCheckbox( buttonComposite, "All user attributes", 1 );
+                returnAllAttributesButton.addSelectionListener( new SelectionAdapter()
+                {
+                    public void widgetSelected( SelectionEvent e )
+                    {
+                        validate();
+                    }
+                } );
+                returnAllAttributesButton.setSelection( isActive( RETURN_ALLATTRIBUTES_CHECKED ) );
+            }
+            if ( isActive( RETURN_OPERATIONALATTRIBUTES_VISIBLE ) )
+            {
+                returnOperationalAttributesButton = BaseWidgetUtils.createCheckbox( buttonComposite,
+                    "Operational attributes", 1 );
+                returnOperationalAttributesButton.addSelectionListener( new SelectionAdapter()
+                {
+                    public void widgetSelected( SelectionEvent e )
+                    {
+                        validate();
+                    }
+                } );
+                returnOperationalAttributesButton.setSelection( isActive( RETURN_OPERATIONALATTRIBUTES_CHECKED ) );
+            }
+        }
+
+        BaseWidgetUtils.createSpacer( composite, 3 );
+    }
+
+
+    /**
+     * Creates the options composite, this includes the
+     * scope, limit, alias and referral widgets.
+     * 
+     * @param composite the composite
+     */
+    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();
+            }
+        } );
+    }
+
+
+    /**
+     * Creates the control composite.
+     * 
+     * @param composite the composite
+     */
+    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();
+            }
+        } );
+    }
+
+
+    /**
+     * Validates all elements.
+     */
+    protected void validate()
+    {
+
+        if ( browserConnectionWidget.getBrowserConnection() != null )
+        {
+            if ( searchBaseWidget.getDn() == null
+                || searchBaseWidget.getBrowserConnection() != browserConnectionWidget.getBrowserConnection() )
+            {
+                searchBaseWidget.setInput( browserConnectionWidget.getBrowserConnection(), null );
+            }
+        }
+
+        filterWidget.setBrowserConnection( browserConnectionWidget.getBrowserConnection() );
+
+        super.notifyListeners();
+    }
+
+
+    /**
+     * Checks if the DNs should be returned/exported.
+     * 
+     * @return true, if DNs should be returnde/exported
+     */
+    public boolean isReturnDn()
+    {
+        return returnDnButton != null && returnDnButton.getSelection();
+    }
+
+
+    /**
+     * Initializes all search page widgets from the given search.
+     * 
+     * @param search the search
+     */
+    public void loadFromSearch( ISearch search )
+    {
+        if ( searchNameText != null )
+        {
+            searchNameText.setText( search.getName() );
+        }
+
+        if ( search.getBrowserConnection() != null )
+        {
+            IBrowserConnection browserConnection = search.getBrowserConnection();
+            LdapDN searchBase = search.getSearchBase();
+
+            if ( browserConnectionWidget != null )
+            {
+                browserConnectionWidget.setBrowserConnection( browserConnection );
+            }
+
+            if ( searchBase != null )
+            {
+                searchBaseWidget.setInput( browserConnection, searchBase );
+            }
+
+            if ( filterWidget != null )
+            {
+                filterWidget.setBrowserConnection( browserConnection );
+                filterWidget.setFilter( search.getFilter() );
+            }
+
+            if ( returningAttributesWidget != null )
+            {
+                returningAttributesWidget.setBrowserConnection( browserConnection );
+                returningAttributesWidget.setInitialReturningAttributes( search.getReturningAttributes() );
+            }
+
+            if ( scopeWidget != null )
+            {
+                scopeWidget.setScope( search.getScope() );
+            }
+            if ( limitWidget != null )
+            {
+                limitWidget.setCountLimit( search.getCountLimit() );
+                limitWidget.setTimeLimit( search.getTimeLimit() );
+            }
+            if ( aliasesDereferencingWidget != null )
+            {
+                aliasesDereferencingWidget.setAliasesDereferencingMethod( search.getAliasesDereferencingMethod() );
+            }
+            if ( referralsHandlingWidget != null )
+            {
+                referralsHandlingWidget.setReferralsHandlingMethod( search.getReferralsHandlingMethod() );
+            }
+            if ( 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 ) )
+                        {
+                            subentriesControlButton.setSelection( true );
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+
+    /**
+     * Saves all search pages element to the given search.
+     * 
+     * @param search the search
+     * 
+     * @return true, if the given search has been modified.
+     */
+    public boolean saveToSearch( ISearch search )
+    {
+        boolean searchModified = false;
+
+        if ( searchNameText != null && !searchNameText.getText().equals( search.getName() ) )
+        {
+            search.getSearchParameter().setName( searchNameText.getText() );
+            searchModified = true;
+        }
+        if ( browserConnectionWidget != null && browserConnectionWidget.getBrowserConnection() != null
+            && browserConnectionWidget.getBrowserConnection() != search.getBrowserConnection() )
+        {
+            search.setBrowserConnection( browserConnectionWidget.getBrowserConnection() );
+            searchModified = true;
+        }
+        if ( searchBaseWidget != null && searchBaseWidget.getDn() != null
+            && !searchBaseWidget.getDn().equals( search.getSearchBase() ) )
+        {
+            search.getSearchParameter().setSearchBase( searchBaseWidget.getDn() );
+            searchModified = true;
+            searchBaseWidget.saveDialogSettings();
+        }
+        if ( filterWidget != null && filterWidget.getFilter() != null )
+        {
+            if ( !filterWidget.getFilter().equals( search.getFilter() ) )
+            {
+                search.getSearchParameter().setFilter( filterWidget.getFilter() );
+                searchModified = true;
+            }
+            filterWidget.saveDialogSettings();
+        }
+
+        if ( returningAttributesWidget != null )
+        {
+            if ( !Arrays.equals( returningAttributesWidget.getReturningAttributes(), search.getReturningAttributes() ) )
+            {
+                search.getSearchParameter().setReturningAttributes( returningAttributesWidget.getReturningAttributes() );
+                searchModified = true;
+            }
+            returningAttributesWidget.saveDialogSettings();
+
+            if ( returnAllAttributesButton != null || returnOperationalAttributesButton != null )
+            {
+                List<String> raList = new ArrayList<String>();
+                raList.addAll( Arrays.asList( search.getReturningAttributes() ) );
+                if ( returnAllAttributesButton != null )
+                {
+                    if ( returnAllAttributesButton.getSelection() )
+                    {
+                        raList.add( ISearch.ALL_USER_ATTRIBUTES );
+                    }
+                    if ( returnAllAttributesButton.getSelection() != isActive( RETURN_ALLATTRIBUTES_CHECKED ) )
+                    {
+                        searchModified = true;
+                    }
+                }
+                if ( returnOperationalAttributesButton != null )
+                {
+                    if ( returnOperationalAttributesButton.getSelection() )
+                    {
+                        AttributeTypeDescription[] opAtds = SchemaUtils
+                            .getOperationalAttributeDescriptions( browserConnectionWidget.getBrowserConnection().getSchema() );
+                        String[] attributeTypeDescriptionNames = SchemaUtils.getAttributeTypeDescriptionNames( opAtds );
+                        raList.addAll( Arrays.asList( attributeTypeDescriptionNames ) );
+                        raList.add( ISearch.ALL_OPERATIONAL_ATTRIBUTES );
+                    }
+                    if ( returnOperationalAttributesButton.getSelection() != isActive( RETURN_OPERATIONALATTRIBUTES_CHECKED ) )
+                    {
+                        searchModified = true;
+                    }
+                }
+                String[] returningAttributes = raList.toArray( new String[raList.size()] );
+                search.getSearchParameter().setReturningAttributes( returningAttributes );
+            }
+        }
+
+        if ( scopeWidget != null )
+        {
+            SearchScope scope = scopeWidget.getScope();
+            if ( scope != search.getScope() )
+            {
+                search.getSearchParameter().setScope( scope );
+                searchModified = true;
+            }
+        }
+        if ( 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 ( aliasesDereferencingWidget != null )
+        {
+            AliasDereferencingMethod aliasesDereferencingMethod = aliasesDereferencingWidget
+                .getAliasesDereferencingMethod();
+            if ( aliasesDereferencingMethod != search.getAliasesDereferencingMethod() )
+            {
+                search.getSearchParameter().setAliasesDereferencingMethod( aliasesDereferencingMethod );
+                searchModified = true;
+            }
+        }
+        if ( referralsHandlingWidget != null )
+        {
+            ReferralHandlingMethod referralsHandlingMethod = referralsHandlingWidget.getReferralsHandlingMethod();
+            if ( referralsHandlingMethod != search.getReferralsHandlingMethod() )
+            {
+                search.getSearchParameter().setReferralsHandlingMethod( referralsHandlingMethod );
+                searchModified = true;
+            }
+        }
+        if ( subentriesControlButton != null )
+        {
+            Control selectedSubControl = 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;
+    }
+
+
+    /**
+     * Performs the search.
+     * 
+     * @param search the search
+     * 
+     * @return true, if perform search
+     */
+    public boolean performSearch( final ISearch search )
+    {
+        if ( search.getBrowserConnection() != null )
+        {
+            new SearchJob( new ISearch[]
+                { search } ).execute();
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+
+    /**
+     * Checks if the search page parameters are valid.
+     * 
+     * @return true, it the search page parameters are valid
+     */
+    public boolean isValid()
+    {
+        if ( browserConnectionWidget != null && browserConnectionWidget.getBrowserConnection() == null )
+        {
+            return false;
+        }
+        if ( searchBaseWidget != null && searchBaseWidget.getDn() == null )
+        {
+            return false;
+        }
+        if ( searchNameText != null && "".equals( searchNameText.getText() ) )
+        {
+            return false;
+        }
+        if ( filterWidget != null && filterWidget.getFilter() == null )
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+
+    
+    /**
+     * Gets the error message or null if the search page is valid.
+     * 
+     * @return the error message or null if the search page is valid
+     */
+    public String getErrorMessage()
+    {
+        if ( browserConnectionWidget != null && browserConnectionWidget.getBrowserConnection() == null )
+        {
+            return "Please select a connection.";
+        }
+        if ( searchBaseWidget != null && searchBaseWidget.getDn() == null )
+        {
+            return "Please enter a valid search base DN.";
+        }
+        if ( searchNameText != null && "".equals( searchNameText.getText() ) )
+        {
+            return "Please enter a search name.";
+        }
+        if ( filterWidget != null && filterWidget.getFilter() == null )
+        {
+            return "Please enter a valid filter.";
+        }
+        
+        return null;
+    }
+    
+    
+    /**
+     * Sets the enabled state of the widget.
+     * 
+     * @param b true to enable the widget, false to disable the widget
+     */
+    public void setEnabled( boolean b )
+    {
+        if ( searchNameText != null )
+        {
+            searchNameLabel.setEnabled( b );
+            searchNameText.setEnabled( b );
+        }
+        if ( browserConnectionWidget != null )
+        {
+            connectionLabel.setEnabled( b );
+            browserConnectionWidget.setEnabled( b && !isActive( CONNECTION_READONLY ) );
+        }
+        if ( searchBaseWidget != null )
+        {
+            searchBaseLabel.setEnabled( b );
+            searchBaseWidget.setEnabled( b && !isActive( SEARCHBASE_READONLY ) );
+        }
+        if ( filterWidget != null )
+        {
+            filterLabel.setEnabled( b );
+            filterWidget.setEnabled( b && !isActive( FILTER_READONLY ) );
+        }
+        if ( returningAttributesWidget != null )
+        {
+            returningAttributesLabel.setEnabled( b );
+            returningAttributesWidget.setEnabled( b && !isActive( RETURNINGATTRIBUTES_READONLY ) );
+        }
+        if ( returnDnButton != null )
+        {
+            returnDnButton.setEnabled( b );
+        }
+        if ( returnAllAttributesButton != null )
+        {
+            returnAllAttributesButton.setEnabled( b );
+        }
+        if ( returnOperationalAttributesButton != null )
+        {
+            returnOperationalAttributesButton.setEnabled( b );
+        }
+        if ( scopeWidget != null )
+        {
+            scopeWidget.setEnabled( b && !isActive( SCOPEOPTIONS_READONLY ) );
+        }
+        if ( limitWidget != null )
+        {
+            limitWidget.setEnabled( b && !isActive( LIMITOPTIONS_READONLY ) );
+        }
+        if ( aliasesDereferencingWidget != null )
+        {
+            aliasesDereferencingWidget.setEnabled( b && !isActive( ALIASOPTIONS_READONLY ) );
+        }
+        if ( referralsHandlingWidget != null )
+        {
+            referralsHandlingWidget.setEnabled( b && !isActive( REFERRALOPTIONS_READONLY ) );
+        }
+        if ( controlLabel != null )
+        {
+            controlLabel.setEnabled( b );
+            subentriesControlButton.setEnabled( b );
+        }
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/SearchPageWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/AttributeOptionsWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/AttributeOptionsWizardPage.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/AttributeOptionsWizardPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/AttributeOptionsWizardPage.java Mon Nov  5 08:48:35 2007
@@ -0,0 +1,749 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.common.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.studio.ldapbrowser.common.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.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+
+/**
+ * The AttributeOptionsWizardPageprovides input elements for various options
+ * and a preview field.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AttributeOptionsWizardPage extends WizardPage
+{
+
+    /** The wizard. */
+    private AttributeWizard wizard;
+
+    /** The shell */
+    private Shell shell;
+
+    /** The possible languages. */
+    private String[] possibleLanguages;
+
+    /** The possible language to countries map. */
+    private Map<String, String[]> possibleLangToCountriesMap;
+
+    /** The parsed lang list. */
+    private List<String> parsedLangList;
+
+    /** The parsed option list. */
+    private List<String> parsedOptionList;
+
+    /** The parsed binary option. */
+    private boolean parsedBinary;
+
+    /** The language group. */
+    private Group langGroup;
+
+    /** The lang line list. */
+    private ArrayList<LangLine> langLineList;
+
+    /** The options group. */
+    private Group optionsGroup;
+
+    /** The option line list. */
+    private ArrayList<OptionLine> optionLineList;
+
+    /** The binary option button. */
+    private Button binaryOptionButton;
+
+    /** The preview text. */
+    private Text previewText;
+
+
+    /**
+     * Creates a new instance of AttributeOptionsWizardPage.
+     * 
+     * @param pageName the page name
+     * @param initialAttributeDescription the initial attribute description
+     * @param wizard the wizard
+     */
+    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;
+
+        // init possible languages and countries
+        SortedSet<String> languageSet = new TreeSet<String>();
+        Map<String, SortedSet<String>> languageToCountrySetMap = new HashMap<String, SortedSet<String>>();
+        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<String>() );
+            }
+            SortedSet<String> countrySet = languageToCountrySetMap.get( locale.getLanguage() );
+            countrySet.add( locale.getCountry() );
+        }
+        possibleLanguages = languageSet.toArray( new String[languageSet.size()] );
+        possibleLangToCountriesMap = new HashMap<String, String[]>();
+        for ( Iterator<String> it = languageToCountrySetMap.keySet().iterator(); it.hasNext(); )
+        {
+            String language = it.next();
+            SortedSet<String> countrySet = languageToCountrySetMap.get( language );
+            String[] countries = countrySet.toArray( new String[countrySet.size()] );
+            possibleLangToCountriesMap.put( language, countries );
+        }
+
+        // parse options
+        if ( initialAttributeDescription == null )
+        {
+            initialAttributeDescription = "";
+        }
+        String[] attributeDescriptionComponents = initialAttributeDescription.split( ";" );
+        parsedLangList = new ArrayList<String>();
+        parsedOptionList = new ArrayList<String>();
+        parsedBinary = false;
+        for ( int i = 1; i < attributeDescriptionComponents.length; i++ )
+        {
+            if ( attributeDescriptionComponents[i].startsWith( "lang-" ) )
+            {
+                parsedLangList.add( attributeDescriptionComponents[i] );
+            }
+            else if ( attributeDescriptionComponents[i].equals( "binary" ) )
+            {
+                parsedBinary = true;
+            }
+            else
+            {
+                parsedOptionList.add( attributeDescriptionComponents[i] );
+            }
+        }
+    }
+
+
+    /**
+     * Validates the options.
+     */
+    private void validate()
+    {
+        previewText.setText( wizard.getAttributeDescription() );
+        setPageComplete( true );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setVisible( boolean visible )
+    {
+        super.setVisible( visible );
+        if ( visible )
+        {
+            validate();
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void createControl( Composite parent )
+    {
+        shell = parent.getShell();
+
+        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
+        langGroup = BaseWidgetUtils.createGroup( composite, "Language tags", 2 );
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = 2;
+        langGroup.setLayoutData( gd );
+        Composite langComposite = BaseWidgetUtils.createColumnContainer( langGroup, 6, 1 );
+        langLineList = new ArrayList<LangLine>();
+
+        BaseWidgetUtils.createSpacer( composite, 2 );
+
+        // Options group with binary option
+        optionsGroup = BaseWidgetUtils.createGroup( composite, "Other options", 2 );
+        gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = 2;
+        optionsGroup.setLayoutData( gd );
+        Composite optionsComposite = BaseWidgetUtils.createColumnContainer( optionsGroup, 3, 1 );
+        optionLineList = new ArrayList<OptionLine>();
+        Composite binaryComposite = BaseWidgetUtils.createColumnContainer( optionsGroup, 1, 1 );
+        binaryOptionButton = BaseWidgetUtils.createCheckbox( binaryComposite, "binary option", 1 );
+        binaryOptionButton.setSelection( parsedBinary );
+
+        Label la = new Label( composite, SWT.NONE );
+        gd = new GridData( GridData.GRAB_VERTICAL );
+        gd.horizontalSpan = 2;
+        la.setLayoutData( gd );
+
+        // Preview text
+        BaseWidgetUtils.createLabel( composite, "Preview:", 1 );
+        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 = parsedLangList.get( i );
+                String[] ls = l.split( "-", 3 );
+                if ( ls.length > 1 )
+                {
+                    langLineList.get( i ).languageCombo.setText( ls[1] );
+                }
+                if ( ls.length > 2 )
+                {
+                    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 );
+                optionLineList.get( i ).optionText.setText( parsedOptionList.get( i ) );
+            }
+        }
+
+        // binary listener
+        binaryOptionButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                validate();
+            }
+        } );
+
+        validate();
+
+        setControl( composite );
+    }
+
+
+    /**
+     * Gets the attribute options.
+     * 
+     * @return the attribute options
+     */
+    String getAttributeOptions()
+    {
+
+        if ( binaryOptionButton == null || binaryOptionButton.isDisposed() )
+        {
+            return "";
+        }
+
+        // attribute type
+        StringBuffer sb = new StringBuffer();
+
+        // options
+        // sort and unique options
+        Comparator<String> comparator = new Comparator<String>()
+        {
+            public int compare( String s1, String s2 )
+            {
+                if ( s1 == null || s2 == null )
+                {
+                    throw new ClassCastException( "Must not be null" );
+                }
+                return s1.compareToIgnoreCase( s2 );
+            }
+        };
+        SortedSet<String> options = new TreeSet<String>( comparator );
+        if ( binaryOptionButton.getSelection() )
+        {
+            options.add( "binary" );
+        }
+        for ( int i = 0; i < optionLineList.size(); i++ )
+        {
+            OptionLine optionLine = optionLineList.get( i );
+            if ( !"".equals( optionLine.optionText.getText() ) )
+            {
+                options.add( optionLine.optionText.getText() );
+            }
+
+            if ( optionLineList.size() > 1 )
+            {
+                optionLine.optionDeleteButton.setEnabled( true );
+            }
+            else
+            {
+                optionLine.optionDeleteButton.setEnabled( false );
+            }
+        }
+        for ( int i = 0; i < langLineList.size(); i++ )
+        {
+            LangLine langLine = 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 ( langLineList.size() > 1 )
+            {
+                langLine.deleteButton.setEnabled( true );
+            }
+            else
+            {
+                langLine.deleteButton.setEnabled( false );
+            }
+        }
+
+        // append options
+        for ( Iterator<String> it = options.iterator(); it.hasNext(); )
+        {
+            String option = it.next();
+            sb.append( ';' );
+            sb.append( option );
+        }
+
+        return sb.toString();
+    }
+
+
+    /**
+     * Adds an option line at the given index.
+     * 
+     * @param optionComposite the option composite
+     * @param index the index
+     */
+    private void addOptionLine( Composite optionComposite, int index )
+    {
+        OptionLine[] optionLines = 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 );
+        }
+
+        shell.layout( true, true );
+    }
+
+
+    /**
+     * Creates the option line.
+     * 
+     * @param optionComposite the option composite
+     * 
+     * @return the option line
+     */
+    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 SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                int index = optionLineList.size();
+                for ( int i = 0; i < optionLineList.size(); i++ )
+                {
+                    OptionLine optionLine = optionLineList.get( i );
+                    if ( optionLine.optionAddButton == e.widget )
+                    {
+                        index = i + 1;
+                    }
+                }
+
+                addOptionLine( optionComposite, index );
+
+                validate();
+            }
+        } );
+
+        optionLine.optionDeleteButton = new Button( optionComposite, SWT.PUSH );
+        optionLine.optionDeleteButton.setText( "  \u2212  " ); // \u2013
+        optionLine.optionDeleteButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                int index = 0;
+                for ( int i = 0; i < optionLineList.size(); i++ )
+                {
+                    OptionLine optionLine = optionLineList.get( i );
+                    if ( optionLine.optionDeleteButton == e.widget )
+                    {
+                        index = i;
+                    }
+                }
+
+                deleteOptionLine( optionComposite, index );
+
+                validate();
+            }
+        } );
+
+        optionLine.optionText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                validate();
+            }
+        } );
+
+        return optionLine;
+    }
+
+
+    /**
+     * Deletes the option line at the given index.
+     * 
+     * @param optionComposite the option composite
+     * @param index the index
+     */
+    private void deleteOptionLine( Composite optionComposite, int index )
+    {
+        OptionLine optionLine = optionLineList.remove( index );
+        if ( optionLine != null )
+        {
+            optionLine.optionText.dispose();
+            optionLine.optionAddButton.dispose();
+            optionLine.optionDeleteButton.dispose();
+
+            if ( !optionComposite.isDisposed() )
+            {
+                shell.layout( true, true );
+            }
+        }
+    }
+
+    /**
+     * The class OptionLine is a wrapper for all input elements of an option.
+     *
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     * @version $Rev$, $Date$
+     */
+    public class OptionLine
+    {
+        /** The option text. */
+        public Text optionText;
+
+        /** The option add button. */
+        public Button optionAddButton;
+
+        /** The option delete button. */
+        public Button optionDeleteButton;
+    }
+
+
+    /**
+     * Adds a language line at the given index.
+     * 
+     * @param langComposite the language composite
+     * @param index the index
+     */
+    private void addLangLine( Composite langComposite, int index )
+    {
+        LangLine[] langLines = 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 );
+        }
+
+        shell.layout( true, true );
+    }
+
+
+    /**
+     * Creates a language line.
+     * 
+     * @param langComposite the language composite
+     * 
+     * @return the language line
+     */
+    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 SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                int index = langLineList.size();
+                for ( int i = 0; i < langLineList.size(); i++ )
+                {
+                    LangLine langLine = langLineList.get( i );
+                    if ( langLine.addButton == e.widget )
+                    {
+                        index = i + 1;
+                    }
+                }
+
+                addLangLine( langComposite, index );
+
+                validate();
+            }
+        } );
+
+        langLine.deleteButton = new Button( langComposite, SWT.PUSH );
+        langLine.deleteButton.setText( "  \u2212  " ); // \u2013
+        langLine.deleteButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                int index = 0;
+                for ( int i = 0; i < langLineList.size(); i++ )
+                {
+                    LangLine langLine = langLineList.get( i );
+                    if ( langLine.deleteButton == e.widget )
+                    {
+                        index = i;
+                    }
+                }
+
+                deleteLangLine( langComposite, index );
+
+                validate();
+            }
+        } );
+
+        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( 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;
+    }
+
+
+    /**
+     * Deletes the language line at the given index.
+     * 
+     * @param langComposite the language composite
+     * @param index the index
+     */
+    private void deleteLangLine( Composite langComposite, int index )
+    {
+        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();
+
+            if ( !langComposite.isDisposed() )
+            {
+                shell.layout( true, true );
+            }
+        }
+    }
+
+    /**
+     * The class LangLine is a wrapper for all input elements of a language tag.
+     *
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     * @version $Rev$, $Date$
+     */
+    public class LangLine
+    {
+
+        /** The lang label. */
+        public Label langLabel;
+
+        /** The language combo. */
+        public Combo languageCombo;
+
+        /** The minus label. */
+        public Label minusLabel;
+
+        /** The country combo. */
+        public Combo countryCombo;
+
+        /** The add button. */
+        public Button addButton;
+
+        /** The delete button. */
+        public Button deleteButton;
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/AttributeOptionsWizardPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/AttributeTypeWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/AttributeTypeWizardPage.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/AttributeTypeWizardPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/AttributeTypeWizardPage.java Mon Nov  5 08:48:35 2007
@@ -0,0 +1,313 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.common.wizards;
+
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.ListContentProposalProvider;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.eclipse.jface.fieldassist.ComboContentAdapter;
+import org.eclipse.jface.fieldassist.ContentProposalAdapter;
+import org.eclipse.jface.fieldassist.DecoratedField;
+import org.eclipse.jface.fieldassist.FieldDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
+import org.eclipse.jface.fieldassist.IControlCreator;
+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.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+
+/**
+ * The AttributeTypeWizardPage provides a combo to select the attribute type,
+ * some filter and a preview field.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AttributeTypeWizardPage extends WizardPage
+{
+
+    /** The parent wizard. */
+    private AttributeWizard wizard;
+
+    /** The initial show subschema attributes only. */
+    private boolean initialShowSubschemaAttributesOnly;
+
+    /** The initial hide existing attributes. */
+    private boolean initialHideExistingAttributes;
+
+    /** The parsed attribute type. */
+    private String parsedAttributeType;
+
+    /** The possible attribute types. */
+    private String[] possibleAttributeTypes;
+
+    /** The possible attribute types applicable to the entry's schema only. */
+    private String[] possibleAttributeTypesSubschemaOnly;
+
+    /** The possible attribute types applicable to the entry's schema only, existing attributes are hidden. */
+    private String[] possibleAttributeTypesSubschemaOnlyAndExistingHidden;
+    
+    /** The attribute type combo field. */
+    private DecoratedField attributeTypeComboField;
+
+    /** The attribute type combo. */
+    private Combo attributeTypeCombo;
+
+    /** The attribute type content proposal adapter */
+    private ContentProposalAdapter attributeTypeCPA;
+
+    /** The show subschem attributes only button. */
+    private Button showSubschemAttributesOnlyButton;
+
+    /** The hide existing attributes button. */
+    private Button hideExistingAttributesButton;
+
+    /** The preview text. */
+    private Text previewText;
+
+
+    /**
+     * Creates a new instance of AttributeTypeWizardPage.
+     * 
+     * @param pageName the page name
+     * @param initialEntry the initial entry
+     * @param initialAttributeDescription the initial attribute description
+     * @param initialShowSubschemaAttributesOnly the initial show subschema attributes only
+     * @param initialHideExistingAttributes the initial hide existing attributes
+     * @param wizard the wizard
+     */
+    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.initialShowSubschemaAttributesOnly = initialShowSubschemaAttributesOnly;
+        this.initialHideExistingAttributes = initialHideExistingAttributes;
+
+        possibleAttributeTypes = initialEntry.getBrowserConnection().getSchema().getAttributeTypeDescriptionNames();
+        Arrays.sort( possibleAttributeTypes );
+        possibleAttributeTypesSubschemaOnly = initialEntry.getSubschema().getAllAttributeNames();
+        Arrays.sort( possibleAttributeTypesSubschemaOnly );
+
+        Set<String> set = new HashSet<String>( Arrays.asList( initialEntry.getSubschema().getAllAttributeNames() ) );
+        IAttribute[] existingAttributes = initialEntry.getAttributes();
+        for ( int i = 0; existingAttributes != null && i < existingAttributes.length; i++ )
+        {
+            set.remove( existingAttributes[i].getDescription() );
+        }
+        possibleAttributeTypesSubschemaOnlyAndExistingHidden = ( String[] ) set.toArray( new String[set.size()] );
+        Arrays.sort( possibleAttributeTypesSubschemaOnlyAndExistingHidden );
+
+        String attributeDescription = initialAttributeDescription;
+        if ( attributeDescription == null )
+        {
+            attributeDescription = "";
+        }
+        String[] attributeDescriptionComponents = attributeDescription.split( ";" );
+        parsedAttributeType = attributeDescriptionComponents[0];
+    }
+
+
+    /**
+     * Validates this page.
+     */
+    private void validate()
+    {
+        previewText.setText( wizard.getAttributeDescription() );
+        setPageComplete( !"".equals( attributeTypeCombo.getText() ) );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setVisible( boolean visible )
+    {
+        super.setVisible( visible );
+        if ( visible )
+        {
+            validate();
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    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 );
+//        attributeTypeCombo = BaseWidgetUtils.createCombo( composite, possibleAttributeTypes, -1, 1 );
+//        attributeTypeCombo.setText( parsedAttributeType );
+
+        // attribute combo with field decoration
+        final FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(
+            FieldDecorationRegistry.DEC_CONTENT_PROPOSAL );
+        attributeTypeComboField = new DecoratedField( composite, SWT.NONE, new IControlCreator()
+        {
+            public Control createControl( Composite parent, int style )
+            {
+                Combo combo = BaseWidgetUtils.createCombo( parent, new String[0], -1, 1 );
+                combo.setVisibleItemCount( 20 );
+                return combo;
+            }
+        } );
+        attributeTypeComboField.addFieldDecoration( fieldDecoration, SWT.TOP | SWT.LEFT, true );
+        attributeTypeComboField.getLayoutControl().setLayoutData(
+            new GridData( SWT.FILL, SWT.CENTER, true, false ) );
+        attributeTypeCombo = ( Combo ) attributeTypeComboField.getControl();
+        attributeTypeCombo.setItems( possibleAttributeTypes );
+        attributeTypeCombo.setText( parsedAttributeType );
+
+        // content proposal adapter
+        attributeTypeCPA = new ContentProposalAdapter (attributeTypeCombo, new ComboContentAdapter(),
+            new ListContentProposalProvider( possibleAttributeTypes ), null, null );
+        attributeTypeCPA.setFilterStyle( ContentProposalAdapter.FILTER_NONE );
+        attributeTypeCPA.setProposalAcceptanceStyle( ContentProposalAdapter.PROPOSAL_REPLACE );  
+
+        BaseWidgetUtils.createSpacer( composite, 1 );
+        showSubschemAttributesOnlyButton = BaseWidgetUtils.createCheckbox( composite, "Show subschema attributes only",
+            1 );
+        showSubschemAttributesOnlyButton.setSelection( initialShowSubschemaAttributesOnly );
+
+        BaseWidgetUtils.createSpacer( composite, 1 );
+        hideExistingAttributesButton = BaseWidgetUtils.createCheckbox( composite, "Hide existing attributes", 1 );
+        hideExistingAttributesButton.setSelection( initialHideExistingAttributes );
+
+        Label l = new Label( composite, SWT.NONE );
+        GridData gd = new GridData( GridData.FILL_BOTH );
+        gd.horizontalSpan = 2;
+        l.setLayoutData( gd );
+
+        BaseWidgetUtils.createLabel( composite, "Preview:", 1 );
+        previewText = BaseWidgetUtils.createReadonlyText( composite, "", 1 );
+
+        // attribute type listener
+        attributeTypeCombo.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                validate();
+            }
+        } );
+
+        // filter listener
+        showSubschemAttributesOnlyButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                updateFilter();
+                validate();
+            }
+        } );
+        hideExistingAttributesButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                updateFilter();
+                validate();
+            }
+        } );
+        updateFilter();
+
+        setControl( composite );
+    }
+
+
+    /**
+     * Updates the filter.
+     */
+    private void updateFilter()
+    {
+        // enable/disable filter buttons
+        hideExistingAttributesButton.setEnabled( showSubschemAttributesOnlyButton.getSelection() );
+        if ( possibleAttributeTypesSubschemaOnly.length == 0 )
+        {
+            showSubschemAttributesOnlyButton.setSelection( false );
+            showSubschemAttributesOnlyButton.setEnabled( false );
+        }
+        if ( possibleAttributeTypesSubschemaOnlyAndExistingHidden.length == 0 )
+        {
+            hideExistingAttributesButton.setEnabled( false );
+            hideExistingAttributesButton.setSelection( false );
+        }
+
+        // update combo items and proposals
+        String value = attributeTypeCombo.getText();
+        if ( hideExistingAttributesButton.getSelection() && showSubschemAttributesOnlyButton.getSelection() )
+        {
+            attributeTypeCombo.setItems( possibleAttributeTypesSubschemaOnlyAndExistingHidden );
+        }
+        else if ( showSubschemAttributesOnlyButton.getSelection() )
+        {
+            attributeTypeCombo.setItems( possibleAttributeTypesSubschemaOnly );
+        }
+        else
+        {
+            attributeTypeCombo.setItems( possibleAttributeTypes );
+        }
+        attributeTypeCombo.setText( value );
+    }
+
+
+    /**
+     * Gets the attribute type.
+     * 
+     * @return the attribute type
+     */
+    String getAttributeType()
+    {
+        if ( attributeTypeCombo == null | attributeTypeCombo.isDisposed() )
+        {
+            return "";
+        }
+
+        return attributeTypeCombo.getText();
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/AttributeTypeWizardPage.java
------------------------------------------------------------------------------
    svn:eol-style = native