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 [5/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-ui...

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/FileEncodingInput.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/FileEncodingInput.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/FileEncodingInput.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/FileEncodingInput.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,85 @@
+/*
+ *  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;
+
+
+import java.nio.charset.Charset;
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreConstants;
+
+
+public class FileEncodingInput extends OptionsInput
+{
+
+    public FileEncodingInput( String initialRawValue, boolean asGroup )
+    {
+        super( "File Encoding", getDefaultDisplayValue(), getDefaultRawValue(), getOtherDisplayValues(),
+            getOtherRawValues(), initialRawValue, asGroup, false );
+
+    }
+
+
+    private static String getDefaultDisplayValue()
+    {
+        return getCharsetDisplayValue( getDefaultRawValue() );
+    }
+
+
+    private static String getDefaultRawValue()
+    {
+        return BrowserCoreConstants.DEFAULT_ENCODING;
+    }
+
+
+    private static String[] getOtherDisplayValues()
+    {
+        String[] otherEncodingsRawValues = getOtherRawValues();
+        String[] otherEncodingsDisplayValues = new String[otherEncodingsRawValues.length];
+        for ( int i = 0; i < otherEncodingsDisplayValues.length; i++ )
+        {
+            String rawValue = otherEncodingsRawValues[i];
+            otherEncodingsDisplayValues[i] = getCharsetDisplayValue( rawValue );
+        }
+        return otherEncodingsDisplayValues;
+    }
+
+
+    private static String[] getOtherRawValues()
+    {
+        String[] otherEncodingsRawValues = ( String[] ) Charset.availableCharsets().keySet().toArray( new String[0] );
+        return otherEncodingsRawValues;
+    }
+
+
+    private static String getCharsetDisplayValue( String charsetRawValue )
+    {
+        try
+        {
+            Charset charset = Charset.forName( charsetRawValue );
+            return charset.displayName();
+        }
+        catch ( Exception e )
+        {
+            return charsetRawValue;
+        }
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/HistoryUtils.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/HistoryUtils.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/HistoryUtils.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/HistoryUtils.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,69 @@
+/*
+ *  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;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+
+
+public class HistoryUtils
+{
+
+    public static void save( String key, String value )
+    {
+        // get current history
+        String[] history = load( key );
+        List list = new ArrayList( Arrays.asList( history ) );
+
+        // add new value or move to first position
+        if ( list.contains( value ) )
+            list.remove( value );
+        list.add( 0, value );
+
+        // check history size
+        while ( list.size() > BrowserUIConstants.HISTORYSIZE )
+        {
+            list.remove( list.size() - 1 );
+        }
+
+        // save
+        history = ( String[] ) list.toArray( new String[list.size()] );
+        BrowserUIPlugin.getDefault().getDialogSettings().put( key, history );
+
+    }
+
+
+    public static String[] load( String key )
+    {
+        String[] history = BrowserUIPlugin.getDefault().getDialogSettings().getArray( key );
+        if ( history == null )
+        {
+            history = new String[0];
+        }
+        return history;
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/LineSeparatorInput.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/LineSeparatorInput.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/LineSeparatorInput.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/LineSeparatorInput.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,93 @@
+/*
+ *  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;
+
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreConstants;
+
+import org.eclipse.core.runtime.Platform;
+
+
+public class LineSeparatorInput extends OptionsInput
+{
+
+    public LineSeparatorInput( String initialRawValue, boolean asGroup )
+    {
+        super( "Line Separator", getDefaultDisplayValue(), getDefaultRawValue(), getOtherDisplayValues(),
+            getOtherRawValues(), initialRawValue, asGroup, false );
+
+    }
+
+
+    private static String getDefaultDisplayValue()
+    {
+        Map lsMap = Platform.knownPlatformLineSeparators();
+        for ( Iterator iter = lsMap.keySet().iterator(); iter.hasNext(); )
+        {
+            String k = ( String ) iter.next();
+            String v = ( String ) lsMap.get( k );
+            if ( v.equals( getDefaultRawValue() ) )
+            {
+                k = k + " (" + ( v.replaceAll( "\n", "\\\\n" ).replaceAll( "\r", "\\\\r" ) ) + ")";
+                return k;
+            }
+        }
+        return getDefaultRawValue();
+    }
+
+
+    private static String getDefaultRawValue()
+    {
+        return BrowserCoreConstants.LINE_SEPARATOR;
+    }
+
+
+    private static String[] getOtherDisplayValues()
+    {
+        Map lsMap = Platform.knownPlatformLineSeparators();
+        String[] displayValues = ( String[] ) lsMap.keySet().toArray( new String[lsMap.size()] );
+        for ( int i = 0; i < displayValues.length; i++ )
+        {
+            displayValues[i] = displayValues[i]
+                + " ("
+                + ( ( ( String ) lsMap.get( displayValues[i] ) ).replaceAll( "\n", "\\\\n" ).replaceAll( "\r", "\\\\r" ) )
+                + ")";
+        }
+        return displayValues;
+    }
+
+
+    private static String[] getOtherRawValues()
+    {
+        Map lsMap = Platform.knownPlatformLineSeparators();
+        String[] displayValues = ( String[] ) lsMap.keySet().toArray( new String[lsMap.size()] );
+        String[] rawValues = new String[displayValues.length];
+        for ( int i = 0; i < rawValues.length; i++ )
+        {
+            rawValues[i] = ( String ) lsMap.get( displayValues[i] );
+        }
+        return rawValues;
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/ModWidget.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/ModWidget.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/ModWidget.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/ModWidget.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,526 @@
+/*
+ *  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;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreConstants;
+import org.apache.directory.ldapstudio.browser.core.model.schema.Schema;
+
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Point;
+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.Shell;
+import org.eclipse.swt.widgets.Text;
+
+
+public class ModWidget implements ModifyListener
+{
+
+    private Schema schema;
+
+    private Shell shell;
+
+    private Composite modComposite;
+
+    private ArrayList modGroupList;
+
+    private int modCompositeHeight = -1;
+
+    private String ldif;
+
+
+    public ModWidget( Schema schema )
+    {
+        this.schema = schema;
+        this.modGroupList = new ArrayList();
+        this.ldif = null;
+    }
+
+
+    public void dispose()
+    {
+    }
+
+
+    public String getLdif()
+    {
+        return this.ldif;
+    }
+
+
+    public Composite createContents( Composite parent )
+    {
+        this.shell = parent.getShell();
+
+        modComposite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 );
+        addModGroup( this.modComposite, 0 );
+
+        return modComposite;
+    }
+
+
+    public void modifyText( ModifyEvent e )
+    {
+        this.validate();
+    }
+
+    private List listeners;
+
+
+    public void addPropertyChangeListener( IPropertyChangeListener listener )
+    {
+        if ( listeners == null )
+            listeners = new ArrayList();
+
+        if ( !listeners.contains( listener ) )
+            listeners.add( listener );
+    }
+
+
+    public void removePropertyChangeListener( IPropertyChangeListener listener )
+    {
+        if ( listeners == null )
+            return;
+
+        if ( listeners.contains( listener ) )
+            listeners.remove( listener );
+    }
+
+
+    private void fire( String property, Object oldValue, Object newValue )
+    {
+        if ( listeners == null )
+            return;
+
+        for ( Iterator it = listeners.iterator(); it.hasNext(); )
+        {
+            ( ( IPropertyChangeListener ) it.next() ).propertyChange( new PropertyChangeEvent( this, property,
+                oldValue, newValue ) );
+        }
+    }
+
+
+    public void validate()
+    {
+
+        for ( int i = 0; i < this.modGroupList.size(); i++ )
+        {
+            ModGroup modGroup = ( ModGroup ) this.modGroupList.get( i );
+            if ( this.modGroupList.size() > 1 )
+            {
+                modGroup.modDeleteButton.setEnabled( true );
+            }
+            else
+            {
+                modGroup.modDeleteButton.setEnabled( false );
+            }
+            for ( int k = 0; k < modGroup.valueLineList.size(); k++ )
+            {
+                ValueLine valueLine = ( ValueLine ) modGroup.valueLineList.get( k );
+                if ( modGroup.valueLineList.size() > 1 )
+                {
+                    valueLine.valueDeleteButton.setEnabled( true );
+                }
+                else
+                {
+                    valueLine.valueDeleteButton.setEnabled( false );
+                }
+            }
+        }
+
+        fire( "ldif", null, null );
+    }
+
+
+    private void addModGroup( Composite modComposite, int index )
+    {
+
+        ModGroup[] modGroups = ( ModGroup[] ) modGroupList.toArray( new ModGroup[modGroupList.size()] );
+
+        if ( modGroups.length > 0 )
+        {
+            for ( int i = 0; i < modGroups.length; i++ )
+            {
+                ModGroup oldModGroup = modGroups[i];
+
+                // remember values
+                String oldType = oldModGroup.modType.getText();
+                String oldAttribute = oldModGroup.modAttribute.getText();
+                String[] oldValues = new String[oldModGroup.valueLineList.size()];
+                for ( int k = 0; k < oldValues.length; k++ )
+                {
+                    oldValues[k] = ( ( ValueLine ) oldModGroup.valueLineList.get( k ) ).valueText.getText();
+                }
+
+                // delete old
+                oldModGroup.modGroup.dispose();
+                oldModGroup.modAddButton.dispose();
+                oldModGroup.modDeleteButton.dispose();
+                modGroupList.remove( oldModGroup );
+
+                // add new
+                ModGroup newModGroup = createModGroup( modComposite );
+                modGroupList.add( newModGroup );
+
+                // restore values
+                newModGroup.modType.setText( oldType );
+                newModGroup.modAttribute.setText( oldAttribute );
+                deleteValueLine( newModGroup, 0 );
+                for ( int k = 0; k < oldValues.length; k++ )
+                {
+                    addValueLine( newModGroup, k );
+                    ValueLine newValueLine = ( ValueLine ) newModGroup.valueLineList.get( k );
+                    newValueLine.valueText.setText( oldValues[k] );
+                }
+
+                // check
+                if ( index == i + 1 )
+                {
+                    ModGroup modGroup = createModGroup( modComposite );
+                    modGroupList.add( modGroup );
+
+                }
+            }
+        }
+        else
+        {
+            ModGroup modGroup = createModGroup( modComposite );
+            modGroupList.add( modGroup );
+        }
+    }
+
+
+    private ModGroup createModGroup( final Composite modComposite )
+    {
+        final ModGroup modGroup = new ModGroup();
+
+        // this.connection.getSchema().getAttributeTypeDescriptionNames()
+        modGroup.modGroup = BaseWidgetUtils.createGroup( modComposite, "", 1 );
+        Composite modGroupComposite = BaseWidgetUtils.createColumnContainer( modGroup.modGroup, 2, 1 );
+        modGroup.modType = BaseWidgetUtils.createCombo( modGroupComposite, new String[]
+            { "add", "replace", "delete" }, 0, 1 );
+        modGroup.modType.addModifyListener( this );
+        String[] attributeDescriptions = schema.getAttributeTypeDescriptionNames();
+        Arrays.sort( attributeDescriptions );
+        modGroup.modAttribute = BaseWidgetUtils.createCombo( modGroupComposite, attributeDescriptions, -1, 1 );
+        modGroup.modAttribute.addModifyListener( this );
+
+        modGroup.modAddButton = new Button( modComposite, SWT.PUSH );
+        modGroup.modAddButton.setText( "  +   " );
+        modGroup.modAddButton.addSelectionListener( new SelectionListener()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                int index = modGroupList.size();
+                for ( int i = 0; i < modGroupList.size(); i++ )
+                {
+                    ModGroup modGroup = ( ModGroup ) modGroupList.get( i );
+                    if ( modGroup.modAddButton == e.widget )
+                    {
+                        index = i + 1;
+                    }
+                }
+                addModGroup( modComposite, index );
+
+                Point shellSize = shell.getSize();
+                Point modCompositeSize = modComposite.computeSize( SWT.DEFAULT, SWT.DEFAULT, true );
+                int newModCompositeSize = modCompositeSize.y;
+                shell.setSize( shellSize.x, shellSize.y + newModCompositeSize - modCompositeHeight );
+                modComposite.layout( true, true );
+                shell.layout( true, true );
+                modCompositeHeight = newModCompositeSize;
+
+                validate();
+            }
+
+
+            public void widgetDefaultSelected( SelectionEvent e )
+            {
+            }
+        } );
+
+        modGroup.modDeleteButton = new Button( modComposite, SWT.PUSH );
+        modGroup.modDeleteButton.setText( "  \u2212  " ); // \u2013
+        modGroup.modDeleteButton.addSelectionListener( new SelectionListener()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                int index = 0;
+                for ( int i = 0; i < modGroupList.size(); i++ )
+                {
+                    ModGroup modGroup = ( ModGroup ) modGroupList.get( i );
+                    if ( modGroup.modDeleteButton == e.widget )
+                    {
+                        index = i;
+                    }
+                }
+                deleteModGroup( modComposite, index );
+
+                Point shellSize = shell.getSize();
+                Point groupSize = modComposite.computeSize( SWT.DEFAULT, SWT.DEFAULT, true );
+                int newModCompositeSize = groupSize.y;
+                shell.setSize( shellSize.x, shellSize.y + newModCompositeSize - modCompositeHeight );
+                modComposite.layout( true, true );
+                shell.layout( true, true );
+                modCompositeHeight = newModCompositeSize;
+
+                validate();
+            }
+
+
+            public void widgetDefaultSelected( SelectionEvent e )
+            {
+            }
+        } );
+
+        addValueLine( modGroup, 0 );
+
+        return modGroup;
+    }
+
+
+    private void deleteModGroup( Composite modComposite, int index )
+    {
+        ModGroup modGroup = ( ModGroup ) modGroupList.remove( index );
+        if ( modGroup != null )
+        {
+            modGroup.modGroup.dispose();
+            modGroup.modAddButton.dispose();
+            modGroup.modDeleteButton.dispose();
+        }
+    }
+
+
+    private void addValueLine( ModGroup modGroup, int index )
+    {
+
+        ValueLine[] valueLines = ( ValueLine[] ) modGroup.valueLineList.toArray( new ValueLine[modGroup.valueLineList
+            .size()] );
+
+        if ( valueLines.length > 0 )
+        {
+            for ( int i = 0; i < valueLines.length; i++ )
+            {
+                ValueLine oldValueLine = valueLines[i];
+
+                // remember values
+                String oldValue = oldValueLine.valueText.getText();
+
+                // delete old
+                oldValueLine.valueComposite.dispose();
+                modGroup.valueLineList.remove( oldValueLine );
+
+                // add new
+                ValueLine newValueLine = createValueLine( modGroup );
+                modGroup.valueLineList.add( newValueLine );
+
+                // restore value
+                newValueLine.valueText.setText( oldValue );
+
+                // check
+                if ( index == i + 1 )
+                {
+                    ValueLine valueLine = createValueLine( modGroup );
+                    modGroup.valueLineList.add( valueLine );
+                }
+            }
+        }
+        else
+        {
+            ValueLine valueLine = createValueLine( modGroup );
+            modGroup.valueLineList.add( valueLine );
+        }
+    }
+
+
+    private ValueLine createValueLine( final ModGroup modGroup )
+    {
+        final ValueLine valueLine = new ValueLine();
+
+        // this.connection.getSchema().getAttributeTypeDescriptionNames()
+        valueLine.valueComposite = BaseWidgetUtils.createColumnContainer( modGroup.modGroup, 3, 1 );
+        valueLine.valueText = BaseWidgetUtils.createText( valueLine.valueComposite, "", 1 );
+        valueLine.valueText.addModifyListener( this );
+
+        valueLine.valueAddButton = new Button( valueLine.valueComposite, SWT.PUSH );
+        valueLine.valueAddButton.setText( "  +   " );
+        valueLine.valueAddButton.addSelectionListener( new SelectionListener()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                int index = modGroup.valueLineList.size();
+                for ( int i = 0; i < modGroup.valueLineList.size(); i++ )
+                {
+                    ValueLine valueLine = ( ValueLine ) modGroup.valueLineList.get( i );
+                    if ( valueLine.valueAddButton == e.widget )
+                    {
+                        index = i + 1;
+                    }
+                }
+                addValueLine( modGroup, index );
+
+                Point shellSize = shell.getSize();
+                Point modCompositeSize = modComposite.computeSize( SWT.DEFAULT, SWT.DEFAULT, true );
+                int newModCompositeSize = modCompositeSize.y;
+                shell.setSize( shellSize.x, shellSize.y + newModCompositeSize - modCompositeHeight );
+                modComposite.layout( true, true );
+                shell.layout( true, true );
+                modCompositeHeight = newModCompositeSize;
+
+                validate();
+            }
+
+
+            public void widgetDefaultSelected( SelectionEvent e )
+            {
+            }
+        } );
+
+        valueLine.valueDeleteButton = new Button( valueLine.valueComposite, SWT.PUSH );
+        valueLine.valueDeleteButton.setText( "  \u2212  " ); // \u2013
+        valueLine.valueDeleteButton.addSelectionListener( new SelectionListener()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                int index = 0;
+                for ( int i = 0; i < modGroup.valueLineList.size(); i++ )
+                {
+                    ValueLine valueLine = ( ValueLine ) modGroup.valueLineList.get( i );
+                    if ( valueLine.valueDeleteButton == e.widget )
+                    {
+                        index = i;
+                    }
+                }
+                deleteValueLine( modGroup, index );
+
+                Point shellSize = shell.getSize();
+                Point groupSize = modComposite.computeSize( SWT.DEFAULT, SWT.DEFAULT, true );
+                int newModCompositeSize = groupSize.y;
+                shell.setSize( shellSize.x, shellSize.y + newModCompositeSize - modCompositeHeight );
+                modComposite.layout( true, true );
+                shell.layout( true, true );
+                modCompositeHeight = newModCompositeSize;
+
+                validate();
+            }
+
+
+            public void widgetDefaultSelected( SelectionEvent e )
+            {
+            }
+        } );
+
+        return valueLine;
+    }
+
+
+    private void deleteValueLine( ModGroup modGroup, int index )
+    {
+        ValueLine valueLine = ( ValueLine ) modGroup.valueLineList.remove( index );
+        if ( valueLine != null )
+        {
+            valueLine.valueComposite.dispose();
+        }
+    }
+
+
+    public String getLdifFragment()
+    {
+
+        StringBuffer sb = new StringBuffer();
+        sb.append( "changetype: modify" ).append( BrowserCoreConstants.LINE_SEPARATOR );
+
+        ModGroup[] modGroups = ( ModGroup[] ) modGroupList.toArray( new ModGroup[modGroupList.size()] );
+
+        if ( modGroups.length > 0 )
+        {
+            for ( int i = 0; i < modGroups.length; i++ )
+            {
+                ModGroup modGroup = modGroups[i];
+
+                // get values
+                String type = modGroup.modType.getText();
+                String attribute = modGroup.modAttribute.getText();
+                String[] values = new String[modGroup.valueLineList.size()];
+                for ( int k = 0; k < values.length; k++ )
+                {
+                    values[k] = ( ( ValueLine ) modGroup.valueLineList.get( k ) ).valueText.getText();
+                }
+
+                // build ldif
+                sb.append( type ).append( ": " ).append( attribute ).append( BrowserCoreConstants.LINE_SEPARATOR );
+                for ( int k = 0; k < values.length; k++ )
+                {
+                    if ( values[k].length() > 0 )
+                    {
+                        sb.append( attribute ).append( ": " ).append( values[k] ).append(
+                            BrowserCoreConstants.LINE_SEPARATOR );
+                    }
+                }
+                sb.append( "-" ).append( BrowserCoreConstants.LINE_SEPARATOR );
+                // sb.append(BrowserCoreConstants.NEWLINE);
+            }
+        }
+
+        return sb.toString();
+    }
+
+    public class ModGroup
+    {
+        public Group modGroup;
+
+        public Combo modType;
+
+        public Combo modAttribute;
+
+        public Button modAddButton;
+
+        public Button modDeleteButton;
+
+        public ArrayList valueLineList = new ArrayList();;
+    }
+
+    public class ValueLine
+    {
+        public Composite valueComposite;
+
+        public Text valueText;
+
+        public Button valueAddButton;
+
+        public Button valueDeleteButton;
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/ObjectClassWidget.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/ObjectClassWidget.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/ObjectClassWidget.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/ObjectClassWidget.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,261 @@
+/*
+ *  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;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+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.Label;
+
+
+public class ObjectClassWidget extends BrowserWidget
+{
+
+    private final static int SIZING_SELECTION_WIDGET_HEIGHT = 250;
+
+    private final static int SIZING_SELECTION_WIDGET_WIDTH = 400;
+
+    private IConnection connection;
+
+    private String[] initialObjectClasses;
+
+    private List availableObjectClasses;
+
+    private ListViewer availableObjectClassesViewer;
+
+    private List selectedObjectClasses;
+
+    private ListViewer selectedObjectClassesViewer;
+
+    private Button addButton;
+
+    private Button removeButton;
+
+
+    public ObjectClassWidget( IConnection connection )
+    {
+        this( connection, ( IEntry ) null );
+    }
+
+
+    public ObjectClassWidget( IConnection connection, String[] ocValues )
+    {
+        this.connection = connection;
+        this.initialObjectClasses = ocValues;
+
+        if ( this.connection != null )
+        {
+            this.availableObjectClasses = new ArrayList( Arrays.asList( this.connection.getSchema()
+                .getObjectClassDescriptionNames() ) );
+            this.selectedObjectClasses = new ArrayList();
+        }
+        else
+        {
+            this.availableObjectClasses = new ArrayList();
+            this.selectedObjectClasses = new ArrayList();
+        }
+
+        if ( this.initialObjectClasses != null )
+        {
+            selectedObjectClasses.addAll( Arrays.asList( this.initialObjectClasses ) );
+        }
+    }
+
+
+    public ObjectClassWidget( IConnection connection, IEntry entry )
+    {
+        this.connection = connection;
+        this.initialObjectClasses = new String[0];
+
+        if ( this.connection != null )
+        {
+            this.availableObjectClasses = new ArrayList( Arrays.asList( this.connection.getSchema()
+                .getObjectClassDescriptionNames() ) );
+            this.selectedObjectClasses = new ArrayList();
+        }
+        else
+        {
+            this.availableObjectClasses = new ArrayList();
+            this.selectedObjectClasses = new ArrayList();
+        }
+
+        if ( entry != null )
+        {
+            IAttribute oca = entry.getAttribute( IAttribute.OBJECTCLASS_ATTRIBUTE );
+            if ( oca != null )
+            {
+                selectedObjectClasses.addAll( Arrays.asList( oca.getStringValues() ) );
+            }
+        }
+    }
+
+
+    public void dispose()
+    {
+
+    }
+
+
+    public String[] getSelectedObjectClassNames()
+    {
+        return ( String[] ) selectedObjectClasses.toArray( new String[selectedObjectClasses.size()] );
+    }
+
+
+    public Composite createContents( Composite parent )
+    {
+
+        Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 );
+
+        Label availableLabel = new Label( composite, SWT.NONE );
+        availableLabel.setText( "Available object classes" );
+        Label buttonLabel = new Label( composite, SWT.NONE );
+        buttonLabel.setText( "" );
+        Label selectedLabel = new Label( composite, SWT.NONE );
+        selectedLabel.setText( "Selected object classes" );
+
+        availableObjectClassesViewer = new ListViewer( composite );
+        GridData data = new GridData( GridData.FILL_BOTH );
+        data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT;
+        data.widthHint = ( int ) ( SIZING_SELECTION_WIDGET_WIDTH * 0.4 );
+        availableObjectClassesViewer.getList().setLayoutData( data );
+        availableObjectClassesViewer.setContentProvider( new ArrayContentProvider() );
+        availableObjectClassesViewer.setLabelProvider( new LabelProvider() );
+        availableObjectClassesViewer.setSorter( new ViewerSorter() );
+        availableObjectClassesViewer.setInput( availableObjectClasses );
+        availableObjectClassesViewer.addDoubleClickListener( new IDoubleClickListener()
+        {
+            public void doubleClick( DoubleClickEvent event )
+            {
+                add( event.getSelection() );
+            }
+        } );
+
+        Composite buttonComposite = new Composite( composite, SWT.NONE );
+        GridLayout gl = new GridLayout( 1, true );
+        buttonComposite.setLayout( gl );
+        data = new GridData( GridData.FILL_BOTH );
+        data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT;
+        // data.widthHint = (int)(SIZING_SELECTION_WIDGET_WIDTH * 0.2);
+        data.horizontalAlignment = SWT.CENTER;
+        buttonComposite.setLayoutData( data );
+        Label label0 = new Label( buttonComposite, SWT.NONE );
+        data = new GridData();
+        data.grabExcessHorizontalSpace = true;
+        data.grabExcessVerticalSpace = true;
+        label0.setLayoutData( data );
+        addButton = BaseWidgetUtils.createButton( buttonComposite, "&Add", 1 );
+        removeButton = BaseWidgetUtils.createButton( buttonComposite, "&Remove", 1 );
+        Label label3 = new Label( buttonComposite, SWT.NONE );
+        data = new GridData();
+        data.grabExcessHorizontalSpace = true;
+        data.grabExcessVerticalSpace = true;
+        label3.setLayoutData( data );
+
+        addButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                add( availableObjectClassesViewer.getSelection() );
+            }
+        } );
+
+        removeButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                remove( selectedObjectClassesViewer.getSelection() );
+            }
+        } );
+
+        selectedObjectClassesViewer = new ListViewer( composite );
+        data = new GridData( GridData.FILL_BOTH );
+        data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT;
+        data.widthHint = ( int ) ( SIZING_SELECTION_WIDGET_WIDTH * 0.4 );
+        selectedObjectClassesViewer.getList().setLayoutData( data );
+        selectedObjectClassesViewer.setContentProvider( new ArrayContentProvider() );
+        selectedObjectClassesViewer.setLabelProvider( new LabelProvider() );
+        selectedObjectClassesViewer.setSorter( new ViewerSorter() );
+        selectedObjectClassesViewer.setInput( selectedObjectClasses );
+        selectedObjectClassesViewer.addDoubleClickListener( new IDoubleClickListener()
+        {
+            public void doubleClick( DoubleClickEvent event )
+            {
+                remove( event.getSelection() );
+            }
+        } );
+
+        return composite;
+    }
+
+
+    private void add( ISelection iselection )
+    {
+        IStructuredSelection selection = ( IStructuredSelection ) iselection;
+        Iterator it = selection.iterator();
+        while ( it.hasNext() )
+        {
+            Object oc = it.next();
+            availableObjectClasses.remove( oc );
+            selectedObjectClasses.add( oc );
+            availableObjectClassesViewer.refresh();
+            selectedObjectClassesViewer.refresh();
+        }
+    }
+
+
+    private void remove( ISelection iselection )
+    {
+        IStructuredSelection selection = ( IStructuredSelection ) iselection;
+        Iterator it = selection.iterator();
+        while ( it.hasNext() )
+        {
+            Object oc = it.next();
+            selectedObjectClasses.remove( oc );
+            availableObjectClasses.add( oc );
+            availableObjectClassesViewer.refresh();
+            selectedObjectClassesViewer.refresh();
+        }
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/OptionsInput.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/OptionsInput.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/OptionsInput.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/OptionsInput.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,326 @@
+/*
+ *  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;
+
+
+import java.util.Arrays;
+
+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.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+
+public class OptionsInput extends BrowserWidget
+{
+
+    private String title;
+
+    private Group titleGroup;
+
+    private String defaultRawValue;
+
+    private String defaultDisplayValue;
+
+    private Button defaultButton;
+
+    private String[] otherRawValues;
+
+    private String[] otherDisplayValues;
+
+    private Button otherButton;
+
+    private Combo otherCombo;
+
+    private String initialRawValue;
+
+    private boolean asGroup;
+
+    private boolean allowCustomInput;
+
+
+    public OptionsInput( String title, String defaultDisplayValue, String defaultRawValue, String[] otherDisplayValues,
+        String[] otherRawValues, String initialRawValue, boolean asGroup, boolean allowCustomInput )
+    {
+        super();
+        this.title = title;
+        this.defaultDisplayValue = defaultDisplayValue;
+        this.defaultRawValue = defaultRawValue;
+        this.otherDisplayValues = otherDisplayValues;
+        this.otherRawValues = otherRawValues;
+        this.initialRawValue = initialRawValue;
+        this.asGroup = asGroup;
+        this.allowCustomInput = allowCustomInput;
+    }
+
+
+    public void createWidget( Composite parent )
+    {
+
+        Composite composite;
+        if ( asGroup )
+        {
+            titleGroup = BaseWidgetUtils.createGroup( parent, title, 1 );
+            composite = BaseWidgetUtils.createColumnContainer( titleGroup, 1, 1 );
+        }
+        else
+        {
+            composite = parent;
+            Composite labelComposite = BaseWidgetUtils.createColumnContainer( composite, 1, 1 );
+            BaseWidgetUtils.createLabel( labelComposite, title + ":", 1 );
+        }
+
+        Composite defaultComposite = BaseWidgetUtils.createColumnContainer( composite, 1, 1 );
+        defaultButton = BaseWidgetUtils.createRadiobutton( defaultComposite, defaultDisplayValue, 1 );
+        defaultButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                otherButton.setSelection( false );
+                otherCombo.setEnabled( false );
+                notifyListeners();
+            }
+        } );
+
+        Composite otherComposite = BaseWidgetUtils.createColumnContainer( composite, 2, 1 );
+        otherButton = BaseWidgetUtils.createRadiobutton( otherComposite, "Other: ", 1 );
+        otherButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                defaultButton.setSelection( false );
+                otherCombo.setEnabled( true );
+                notifyListeners();
+            }
+        } );
+
+        if ( allowCustomInput )
+        {
+            otherCombo = BaseWidgetUtils.createCombo( otherComposite, otherDisplayValues, 0, 1 );
+        }
+        else
+        {
+            otherCombo = BaseWidgetUtils.createReadonlyCombo( otherComposite, otherDisplayValues, 0, 1 );
+        }
+        otherCombo.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                notifyListeners();
+            }
+        } );
+
+        // buttons = new Button[rawValues.length];
+        // for (int i = 0; i < rawValues.length; i++) {
+        // final String rawValue = rawValues[i];
+        // Composite buttonComposite =
+        // BaseWidgetUtils.createColumnContainer(composite, 1, 1);
+        // buttons[i] = BaseWidgetUtils.createRadiobutton(buttonComposite,
+        // displayValues[i], 1);
+        // buttons[i].addSelectionListener(new SelectionAdapter() {
+        // public void widgetSelected(SelectionEvent e) {
+        // for (int j = 0; j < buttons.length; j++) {
+        // if(buttons[j] != e.widget) {
+        // buttons[j].setSelection(false);
+        // }
+        // }
+        // otherButton.setSelection(false);
+        // otherText.setEnabled(false);
+        // selectedRawValue = rawValue;
+        // notifyListeners();
+        // }
+        // });
+        // }
+        //
+        // Composite otherComposite =
+        // BaseWidgetUtils.createColumnContainer(composite, 2, 1);
+        // otherButton = BaseWidgetUtils.createRadiobutton(otherComposite,
+        // "Other:", 1);
+        // otherButton.addSelectionListener(new SelectionAdapter() {
+        // public void widgetSelected(SelectionEvent e) {
+        // for (int j = 0; j < buttons.length; j++) {
+        // buttons[j].setSelection(false);
+        // }
+        // otherText.setEnabled(true);
+        // selectedRawValue = otherText.getText();
+        // notifyListeners();
+        // }
+        // });
+        // otherText = BaseWidgetUtils.createText(otherComposite, "", 2, 1);
+        // otherText.setEnabled(otherButton.getSelection());
+        // otherText.addModifyListener(new ModifyListener() {
+        // public void modifyText(ModifyEvent e) {
+        // selectedRawValue = otherText.getText();
+        // notifyListeners();
+        // }
+        // });
+        //		
+        // Composite predefinedComposite =
+        // BaseWidgetUtils.createColumnContainer(composite, 2, 1);
+        // predefinedButton =
+        // BaseWidgetUtils.createRadiobutton(predefinedComposite, "", 1);
+        // predefinedButton.addSelectionListener(new SelectionAdapter() {
+        // public void widgetSelected(SelectionEvent e) {
+        // predefinedCombo.setEnabled(true);
+        // otherButton.setSelection(false);
+        // otherText.setEnabled(false);
+        // notifyListeners();
+        // }
+        // });
+        // predefinedCombo =
+        // BaseWidgetUtils.createReadonlyCombo(predefinedComposite,
+        // displayValues, 0, 1);
+        // predefinedCombo.addModifyListener(new ModifyListener() {
+        // public void modifyText(ModifyEvent e) {
+        // notifyListeners();
+        // }
+        // });
+        //		
+        // Composite otherComposite =
+        // BaseWidgetUtils.createColumnContainer(composite, 2, 1);
+        // otherButton = BaseWidgetUtils.createRadiobutton(otherComposite,
+        // "Other:", 1);
+        // otherButton.addSelectionListener(new SelectionAdapter() {
+        // public void widgetSelected(SelectionEvent e) {
+        // predefinedButton.setSelection(false);
+        // predefinedCombo.setEnabled(false);
+        // otherText.setEnabled(true);
+        // notifyListeners();
+        // }
+        // });
+        // otherText = BaseWidgetUtils.createText(otherComposite, "", 2, 1);
+        // otherText.setEnabled(otherButton.getSelection());
+        // otherText.addModifyListener(new ModifyListener() {
+        // public void modifyText(ModifyEvent e) {
+        // notifyListeners();
+        // }
+        // });
+
+        setRawValue( initialRawValue );
+    }
+
+
+    public String getRawValue()
+    {
+        if ( this.defaultButton.getSelection() )
+        {
+            return this.defaultRawValue;
+        }
+        else
+        {
+            String t = this.otherCombo.getText();
+            for ( int i = 0; i < this.otherDisplayValues.length; i++ )
+            {
+                if ( t.equals( this.otherDisplayValues[i] ) )
+                {
+                    return this.otherRawValues[i];
+                }
+            }
+            return t;
+        }
+    }
+
+
+    public void setRawValue( String rawValue )
+    {
+        int index = Arrays.asList( this.otherRawValues ).indexOf( rawValue );
+        if ( index == -1 )
+        {
+            index = Arrays.asList( this.otherDisplayValues ).indexOf( rawValue );
+        }
+
+        if ( this.defaultRawValue.equals( rawValue ) )
+        {
+            defaultButton.setSelection( true );
+            otherButton.setSelection( false );
+            otherCombo.setEnabled( false );
+            otherCombo.select( index );
+        }
+        else if ( index > -1 )
+        {
+            defaultButton.setSelection( false );
+            otherButton.setSelection( true );
+            otherCombo.setEnabled( true );
+            otherCombo.select( index );
+        }
+        else
+        {
+            defaultButton.setSelection( false );
+            otherButton.setSelection( true );
+            otherCombo.setEnabled( true );
+            otherCombo.setText( rawValue );
+        }
+    }
+
+    // public String getRawValue() {
+    // if(predefinedButton.getSelection()) {
+    // int index = predefinedCombo.getSelectionIndex();
+    // return rawValues[index];
+    // }
+    //		
+    // return otherText.getText();
+    // }
+    //	
+    // public void setRawValue(String rawValue) {
+    //		
+    // int index = Arrays.asList(rawValues).indexOf(rawValue);
+    // if(index > -1) {
+    // predefinedButton.setSelection(true);
+    // predefinedCombo.setEnabled(true);
+    // predefinedCombo.select(index);
+    // otherButton.setSelection(false);
+    // otherText.setEnabled(false);
+    // }
+    // else {
+    // predefinedButton.setSelection(false);
+    // predefinedCombo.setEnabled(false);
+    // otherButton.setSelection(true);
+    // otherText.setEnabled(true);
+    // otherText.setText(rawValue);
+    // }
+    // }
+
+    // public String getSelectedRawValue() {
+    // for (int i = 0; i < buttons.length; i++) {
+    // Button button = buttons[i];
+    // if(button.getSelection()) {
+    // return rawValues[i];
+    // }
+    // }
+    // return otherText.getText();
+    // }
+    //	
+    // public void setSelectedRawValue(String rawValue) {
+    // this.selectedRawValue = rawValue;
+    //		
+    // for (int i = 0; i < buttons.length; i++) {
+    // Button button = buttons[i];
+    // button.setSelection(rawValue.equals(rawValues[i]));
+    // }
+    // otherButton.setSelection(!Arrays.asList(rawValues).contains(rawValue));
+    // otherText.setText(otherButton.getSelection() ? rawValue : "");
+    // }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/ViewFormWidget.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/ViewFormWidget.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/ViewFormWidget.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/ViewFormWidget.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,193 @@
+/*
+ *  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;
+
+
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.ToolBarManager;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ViewForm;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+
+
+public abstract class ViewFormWidget
+{
+
+    protected ViewForm control;
+
+    protected Text infoText;
+
+    protected ToolBar actionToolBar;
+
+    protected IToolBarManager actionToolBarManager;
+
+    protected ToolBar menuToolBar;
+
+    protected MenuManager menuManager;
+
+    protected MenuManager contextMenuManager;
+
+
+    public void createWidget( Composite parent )
+    {
+
+        control = new ViewForm( parent, SWT.NONE );
+        // control.marginWidth = 0;
+        // control.marginHeight = 0;
+        // control.horizontalSpacing = 0;
+        // control.verticalSpacing = 0;
+        control.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+
+        // infoText = BaseWidgetUtils.createLabeledText(control, "", 1);
+        Composite infoTextControl = BaseWidgetUtils.createColumnContainer( control, 1, 1 );
+        infoTextControl.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+        infoText = BaseWidgetUtils.createLabeledText( infoTextControl, "", 1 );
+        infoText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, true ) );
+        control.setTopLeft( infoTextControl );
+
+        // tool bar
+        actionToolBar = new ToolBar( control, SWT.FLAT | SWT.RIGHT );
+        actionToolBar.setLayoutData( new GridData( SWT.END, SWT.NONE, true, false ) );
+        actionToolBarManager = new ToolBarManager( actionToolBar );
+        control.setTopCenter( actionToolBar );
+
+        // local menu
+        this.menuManager = new MenuManager();
+        menuToolBar = new ToolBar( control, SWT.FLAT | SWT.RIGHT );
+        ToolItem ti = new ToolItem( menuToolBar, SWT.PUSH, 0 );
+        ti.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_PULLDOWN ) );
+        ti.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                showViewMenu();
+            }
+        } );
+        control.setTopRight( menuToolBar );
+
+        // content
+        Composite composite = BaseWidgetUtils.createColumnContainer( control, 1, 1 );
+        GridLayout gl = new GridLayout();
+        gl.horizontalSpacing = 0;
+        gl.verticalSpacing = 0;
+        gl.marginHeight = 0;
+        gl.marginWidth = 0;
+        composite.setLayout( gl );
+        Control childControl = this.createContent( composite );
+        control.setContent( composite );
+
+        // context menu
+        this.contextMenuManager = new MenuManager();
+        Menu menu = this.contextMenuManager.createContextMenu( childControl );
+        childControl.setMenu( menu );
+    }
+
+
+    protected abstract Control createContent( Composite control );
+
+
+    private void showViewMenu()
+    {
+        Menu aMenu = menuManager.createContextMenu( control );
+        Point topLeft = new Point( 0, 0 );
+        topLeft.y += menuToolBar.getBounds().height;
+        topLeft = menuToolBar.toDisplay( topLeft );
+        aMenu.setLocation( topLeft.x, topLeft.y );
+        aMenu.setVisible( true );
+    }
+
+
+    public void dispose()
+    {
+        if ( this.control != null )
+        {
+
+            if ( this.contextMenuManager != null )
+            {
+                this.contextMenuManager.removeAll();
+                this.contextMenuManager.dispose();
+                this.contextMenuManager = null;
+            }
+            if ( this.menuToolBar != null )
+            {
+                this.menuToolBar.dispose();
+                this.menuToolBar = null;
+                this.menuManager.dispose();
+                this.menuManager = null;
+            }
+            if ( this.actionToolBar != null )
+            {
+                this.actionToolBar.dispose();
+                this.actionToolBar = null;
+                this.actionToolBarManager.removeAll();
+                this.actionToolBarManager = null;
+            }
+
+            if ( this.infoText != null )
+            {
+                this.infoText.dispose();
+                this.infoText = null;
+            }
+
+            this.control.dispose();
+            this.control = null;
+        }
+    }
+
+
+    public Text getInfoText()
+    {
+        return infoText;
+    }
+
+
+    public IToolBarManager getToolBarManager()
+    {
+        return this.actionToolBarManager;
+    }
+
+
+    public IMenuManager getMenuManager()
+    {
+        return menuManager;
+    }
+
+
+    public IMenuManager getContextMenuManager()
+    {
+        return this.contextMenuManager;
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/WidgetModifyEvent.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/WidgetModifyEvent.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/WidgetModifyEvent.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/WidgetModifyEvent.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,39 @@
+/*
+ *  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;
+
+
+import java.util.EventObject;
+
+
+public class WidgetModifyEvent extends EventObject
+{
+
+    private static final long serialVersionUID = 2421335730580648878L;
+
+
+    public WidgetModifyEvent( Object source )
+    {
+        super( source );
+
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/WidgetModifyListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/WidgetModifyListener.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/WidgetModifyListener.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/WidgetModifyListener.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,29 @@
+/*
+ *  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;
+
+
+public interface WidgetModifyListener
+{
+
+    public void widgetModified( WidgetModifyEvent event );
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserActionGroup.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserActionGroup.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserActionGroup.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserActionGroup.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,263 @@
+/*
+ *  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.browser;
+
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.ui.actions.CollapseAllAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.FilterSubtreeAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.PropertiesAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.RefreshAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.UnfilterSubtreeAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.UpAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.proxy.BrowserViewActionProxy;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.commands.ActionHandler;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.commands.ICommandService;
+
+
+public class BrowserActionGroup implements IMenuListener
+{
+
+    protected OpenSortDialogAction openSortDialogAction;
+
+    protected CollapseAllAction collapseAllAction;
+
+    protected static final String upAction = "upAction";
+
+    protected static final String refreshAction = "refreshAction";
+
+    protected static final String filterSubtreeAction = "filterSubtreeAction";
+
+    protected static final String unfilterSubtreeAction = "unfilterSubtreeAction";
+
+    protected static final String propertyDialogAction = "propertyDialogAction";
+
+    protected Map browserActionMap;
+
+    protected IActionBars actionBars;
+
+    protected BrowserWidget mainWidget;
+
+
+    public BrowserActionGroup( BrowserWidget mainWidget, BrowserConfiguration configuration )
+    {
+        this.mainWidget = mainWidget;
+        this.browserActionMap = new HashMap();
+        TreeViewer viewer = mainWidget.getViewer();
+
+        this.openSortDialogAction = new OpenSortDialogAction( ( BrowserPreferences ) configuration.getPreferences() );
+        this.collapseAllAction = new CollapseAllAction( viewer );
+
+        this.browserActionMap.put( upAction, new BrowserViewActionProxy( viewer, new UpAction( viewer ) ) );
+        this.browserActionMap.put( refreshAction, new BrowserViewActionProxy( viewer, new RefreshAction() ) );
+        this.browserActionMap
+            .put( filterSubtreeAction, new BrowserViewActionProxy( viewer, new FilterSubtreeAction() ) );
+        this.browserActionMap.put( unfilterSubtreeAction, new BrowserViewActionProxy( viewer,
+            new UnfilterSubtreeAction() ) );
+        this.browserActionMap.put( propertyDialogAction, new BrowserViewActionProxy( viewer, new PropertiesAction() ) );
+    }
+
+
+    public void dispose()
+    {
+        if ( this.mainWidget != null )
+        {
+
+            this.openSortDialogAction.dispose();
+            this.openSortDialogAction = null;
+            this.collapseAllAction.dispose();
+            this.collapseAllAction = null;
+
+            for ( Iterator it = this.browserActionMap.keySet().iterator(); it.hasNext(); )
+            {
+                String key = ( String ) it.next();
+                BrowserViewActionProxy action = ( BrowserViewActionProxy ) this.browserActionMap.get( key );
+                action.dispose();
+                action = null;
+                it.remove();
+            }
+            this.browserActionMap.clear();
+            this.browserActionMap = null;
+
+            this.actionBars = null;
+            this.mainWidget = null;
+        }
+    }
+
+
+    public void enableGlobalActionHandlers( IActionBars actionBars )
+    {
+        this.actionBars = actionBars;
+        this.activateGlobalActionHandlers();
+    }
+
+
+    public void fillToolBar( IToolBarManager toolBarManager )
+    {
+
+        toolBarManager.add( ( IAction ) this.browserActionMap.get( upAction ) );
+        toolBarManager.add( new Separator() );
+        toolBarManager.add( this.collapseAllAction );
+        toolBarManager.add( ( IAction ) this.browserActionMap.get( refreshAction ) );
+        toolBarManager.update( true );
+
+    }
+
+
+    public void fillMenu( IMenuManager menuManager )
+    {
+        menuManager.add( this.openSortDialogAction );
+        menuManager.add( new Separator() );
+        menuManager.update( true );
+    }
+
+
+    public void fillContextMenu( IMenuManager menuManager )
+    {
+        menuManager.setRemoveAllWhenShown( true );
+        menuManager.addMenuListener( this );
+    }
+
+
+    public void menuAboutToShow( IMenuManager menuManager )
+    {
+
+        // up
+        menuManager.add( ( IAction ) this.browserActionMap.get( upAction ) );
+        menuManager.add( new Separator() );
+
+        // filter
+        menuManager.add( ( IAction ) this.browserActionMap.get( filterSubtreeAction ) );
+        if ( ( ( IAction ) this.browserActionMap.get( unfilterSubtreeAction ) ).isEnabled() )
+        {
+            menuManager.add( ( IAction ) this.browserActionMap.get( unfilterSubtreeAction ) );
+        }
+        menuManager.add( new Separator() );
+
+        // refresh
+        menuManager.add( ( IAction ) this.browserActionMap.get( refreshAction ) );
+        menuManager.add( new Separator() );
+
+        // properties
+        menuManager.add( ( IAction ) this.browserActionMap.get( propertyDialogAction ) );
+
+    }
+
+
+    public void activateGlobalActionHandlers()
+    {
+
+        ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
+            ICommandService.class );
+
+        if ( this.actionBars != null )
+        {
+            actionBars.setGlobalActionHandler( ActionFactory.REFRESH.getId(), ( IAction ) this.browserActionMap
+                .get( refreshAction ) );
+            actionBars.setGlobalActionHandler( ActionFactory.PROPERTIES.getId(), ( IAction ) this.browserActionMap
+                .get( propertyDialogAction ) );
+            actionBars.updateActionBars();
+        }
+        else
+        {
+            if ( commandService != null )
+            {
+                IAction pda = ( IAction ) this.browserActionMap.get( propertyDialogAction );
+                pda.setActionDefinitionId( "org.apache.directory.ldapstudio.browser.action.properties" );
+                commandService.getCommand( pda.getActionDefinitionId() ).setHandler( new ActionHandler( pda ) );
+
+                IAction ra = ( IAction ) this.browserActionMap.get( refreshAction );
+                commandService.getCommand( ra.getActionDefinitionId() ).setHandler( new ActionHandler( ra ) );
+            }
+        }
+
+        if ( commandService != null )
+        {
+            IAction ua = ( IAction ) this.browserActionMap.get( upAction );
+            commandService.getCommand( ua.getActionDefinitionId() ).setHandler( new ActionHandler( ua ) );
+        }
+
+    }
+
+
+    public void deactivateGlobalActionHandlers()
+    {
+
+        ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
+            ICommandService.class );
+
+        if ( this.actionBars != null )
+        {
+            actionBars.setGlobalActionHandler( ActionFactory.REFRESH.getId(), null );
+            actionBars.setGlobalActionHandler( ActionFactory.PROPERTIES.getId(), null );
+            actionBars.updateActionBars();
+        }
+        else
+        {
+            if ( commandService != null )
+            {
+                IAction pda = ( IAction ) this.browserActionMap.get( propertyDialogAction );
+                commandService.getCommand( pda.getActionDefinitionId() ).setHandler( null );
+
+                IAction ra = ( IAction ) this.browserActionMap.get( refreshAction );
+                commandService.getCommand( ra.getActionDefinitionId() ).setHandler( null );
+            }
+        }
+
+        if ( commandService != null )
+        {
+            IAction ua = ( IAction ) this.browserActionMap.get( upAction );
+            commandService.getCommand( ua.getActionDefinitionId() ).setHandler( null );
+        }
+
+    }
+
+
+    public IAction getRefreshAction()
+    {
+        return ( IAction ) this.browserActionMap.get( refreshAction );
+    }
+
+
+    public void setInput( IConnection connection )
+    {
+        for ( Iterator it = this.browserActionMap.values().iterator(); it.hasNext(); )
+        {
+            BrowserViewActionProxy action = ( BrowserViewActionProxy ) it.next();
+            action.inputChanged( connection );
+        }
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserCategory.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserCategory.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserCategory.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserCategory.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,93 @@
+/*
+ *  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.browser;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+
+
+public class BrowserCategory
+{
+
+    public static final int TYPE_DIT = 0;
+
+    public static final int TYPE_SEARCHES = 1;
+
+    public static final int TYPE_BOOKMARKS = 2;
+
+    public static final String TITLE_DIT = "DIT";
+
+    public static final String TITLE_SEARCHES = "Searches";
+
+    public static final String TITLE_BOOKMARKS = "Bookmarks";
+
+    private IConnection parent;
+
+    private int type;
+
+    private Object[] children;
+
+
+    public BrowserCategory( int type, IConnection parent, Object[] children )
+    {
+        super();
+        this.children = children;
+        this.parent = parent;
+        this.type = type;
+    }
+
+
+    public Object[] getChildren()
+    {
+        return children;
+    }
+
+
+    public IConnection getParent()
+    {
+        return parent;
+    }
+
+
+    public int getType()
+    {
+        return type;
+    }
+
+
+    public String getTitle()
+    {
+        if ( type == TYPE_DIT )
+            return TITLE_DIT;
+        if ( type == TYPE_SEARCHES )
+            return TITLE_SEARCHES;
+        if ( type == TYPE_BOOKMARKS )
+            return TITLE_BOOKMARKS;
+        return "ERROR";
+    }
+
+
+    public void setChildren( Object[] children )
+    {
+        this.children = children;
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserConfiguration.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserConfiguration.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserConfiguration.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserConfiguration.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,136 @@
+/*
+ *  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.browser;
+
+
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.DecoratingLabelProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.widgets.Menu;
+
+
+public class BrowserConfiguration
+{
+
+    private boolean disposed = false;
+
+    protected BrowserSorter sorter;
+
+    protected BrowserPreferences preferences;
+
+    protected BrowserContentProvider contentProvider;
+
+    protected BrowserLabelProvider labelProvider;
+
+    protected DecoratingLabelProvider decoratingLabelProvider;
+
+    protected MenuManager contextMenuManager;
+
+
+    public BrowserConfiguration()
+    {
+    }
+
+
+    public void dispose()
+    {
+        if ( !this.disposed )
+        {
+
+            if ( this.sorter != null )
+                this.sorter.dispose();
+            this.sorter = null;
+
+            if ( this.preferences != null )
+                this.preferences.dispose();
+            this.preferences = null;
+
+            if ( this.contentProvider != null )
+                this.contentProvider.dispose();
+            this.contentProvider = null;
+
+            if ( this.labelProvider != null )
+                this.labelProvider.dispose();
+            this.labelProvider = null;
+
+            if ( this.contextMenuManager != null )
+                this.contextMenuManager.dispose();
+            this.contextMenuManager = null;
+
+            this.disposed = true;
+        }
+    }
+
+
+    public IMenuManager getContextMenuManager( TreeViewer viewer )
+    {
+        if ( this.contextMenuManager == null )
+        {
+            this.contextMenuManager = new MenuManager();
+            Menu menu = this.contextMenuManager.createContextMenu( viewer.getControl() );
+            viewer.getControl().setMenu( menu );
+        }
+        return this.contextMenuManager;
+    }
+
+
+    public BrowserContentProvider getContentProvider( TreeViewer viewer )
+    {
+        if ( this.contentProvider == null )
+            this.contentProvider = new BrowserContentProvider( this.getPreferences(), this.getSorter() );
+
+        return contentProvider;
+    }
+
+
+    public DecoratingLabelProvider getLabelProvider( TreeViewer viewer )
+    {
+        if ( this.labelProvider == null )
+        {
+            this.labelProvider = new BrowserLabelProvider( this.getPreferences() );
+            this.decoratingLabelProvider = new DecoratingLabelProvider( this.labelProvider, BrowserUIPlugin
+                .getDefault().getWorkbench().getDecoratorManager().getLabelDecorator() );
+        }
+
+        return decoratingLabelProvider;
+    }
+
+
+    public BrowserSorter getSorter()
+    {
+        if ( this.sorter == null )
+            this.sorter = new BrowserSorter( getPreferences() );
+
+        return sorter;
+    }
+
+
+    public BrowserPreferences getPreferences()
+    {
+        if ( this.preferences == null )
+            this.preferences = new BrowserPreferences();
+
+        return preferences;
+    }
+
+}