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 [4/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/views/connection/ConnectionViewUniversalListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/connection/ConnectionViewUniversalListener.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/connection/ConnectionViewUniversalListener.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/connection/ConnectionViewUniversalListener.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,118 @@
+/*
+ *  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.views.connection;
+
+
+import org.apache.directory.ldapstudio.browser.core.jobs.OpenConnectionsJob;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.ui.actions.SelectionUtils;
+import org.apache.directory.ldapstudio.browser.ui.views.browser.BrowserView;
+import org.apache.directory.ldapstudio.browser.ui.views.modificationlogs.ModificationLogsView;
+import org.apache.directory.ldapstudio.browser.ui.widgets.connection.ConnectionUniversalListener;
+
+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.ui.ISelectionListener;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+
+
+public class ConnectionViewUniversalListener extends ConnectionUniversalListener implements ISelectionListener,
+    IDoubleClickListener
+{
+
+    protected ConnectionView view;
+
+
+    public ConnectionViewUniversalListener( ConnectionView view )
+    {
+        super( view.getMainWidget().getViewer() );
+        this.view = view;
+
+        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().addSelectionListener( this );
+        viewer.addDoubleClickListener( this );
+    }
+
+
+    public void dispose()
+    {
+        if ( this.view != null )
+        {
+            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().removeSelectionListener( this );
+            this.view = null;
+        }
+        if ( viewer != null )
+        {
+            viewer.removeDoubleClickListener( this );
+        }
+        super.dispose();
+    }
+
+
+    public void selectionChanged( IWorkbenchPart part, ISelection selection )
+    {
+        if ( this.view != null )
+        {
+            if ( part.getClass() == ConnectionView.class )
+            {
+                IConnection[] connections = SelectionUtils.getConnections( selection );
+                if ( connections.length == 1 )
+                {
+                    BrowserView.setInput( connections[0] );
+                    ModificationLogsView.setInput( connections[0] );
+                }
+                else
+                {
+                    BrowserView.setInput( null );
+                    ModificationLogsView.setInput( null );
+                }
+            }
+        }
+    }
+
+
+    public void doubleClick( DoubleClickEvent event )
+    {
+        if ( !event.getSelection().isEmpty() )
+        {
+            Object o = ( ( IStructuredSelection ) event.getSelection() ).getFirstElement();
+            if ( o instanceof IConnection )
+            {
+                IConnection connection = ( IConnection ) o;
+                if ( connection.isOpened() )
+                {
+                    if ( connection.canClose() )
+                    {
+                        connection.close();
+                    }
+                }
+                else
+                {
+                    OpenConnectionsJob ocj = new OpenConnectionsJob( connection );
+                    ocj.execute();
+                }
+            }
+        }
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/connection/DragConnectionListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/connection/DragConnectionListener.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/connection/DragConnectionListener.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/connection/DragConnectionListener.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,89 @@
+/*
+ *  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.views.connection;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.ui.dnd.ConnectionTransfer;
+
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DragSource;
+import org.eclipse.swt.dnd.DragSourceListener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+
+
+public class DragConnectionListener implements DragSourceListener
+{
+
+    public DragConnectionListener()
+    {
+    }
+
+
+    public void dispose()
+    {
+    }
+
+
+    public void dragStart( org.eclipse.swt.dnd.DragSourceEvent event )
+    {
+    }
+
+
+    public void dragSetData( org.eclipse.swt.dnd.DragSourceEvent event )
+    {
+        if ( ConnectionTransfer.getInstance().isSupportedType( event.dataType ) )
+        {
+            if ( event.widget instanceof DragSource )
+            {
+                DragSource dragSource = ( DragSource ) event.widget;
+                if ( dragSource.getControl() instanceof Table )
+                {
+                    Table table = ( Table ) dragSource.getControl();
+                    TableItem[] items = table.getSelection();
+                    List connectionList = new ArrayList();
+                    for ( int i = 0; i < items.length; i++ )
+                    {
+                        if ( items[i].getData() instanceof IConnection )
+                        {
+                            connectionList.add( items[i].getData() );
+                        }
+                    }
+                    event.data = ( IConnection[] ) connectionList.toArray( new IConnection[connectionList.size()] );
+                }
+            }
+        }
+    }
+
+
+    public void dragFinished( org.eclipse.swt.dnd.DragSourceEvent event )
+    {
+        if ( event.detail == DND.DROP_MOVE && event.doit )
+        {
+            // this.connectionManager.removeConnection(this.dragConnection);
+        }
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/connection/DropConnectionListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/connection/DropConnectionListener.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/connection/DropConnectionListener.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/connection/DropConnectionListener.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,194 @@
+/*
+ *  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.views.connection;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.core.ConnectionManager;
+import org.apache.directory.ldapstudio.browser.core.BrowserCorePlugin;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.ui.dnd.ConnectionTransfer;
+
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DropTarget;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.DropTargetListener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+
+
+public class DropConnectionListener implements DropTargetListener
+{
+
+    public DropConnectionListener()
+    {
+    }
+
+
+    public void dispose()
+    {
+    }
+
+
+    public void dragEnter( DropTargetEvent event )
+    {
+        if ( !ConnectionTransfer.getInstance().isSupportedType( event.currentDataType ) )
+        {
+            event.detail = DND.DROP_NONE;
+        }
+    }
+
+
+    public void dragOperationChanged( DropTargetEvent event )
+    {
+        this.dragOver( event );
+    }
+
+
+    public void dragLeave( DropTargetEvent event )
+    {
+    }
+
+
+    public void dragOver( DropTargetEvent event )
+    {
+        boolean isOverSelection = false;
+        if ( event.detail == DND.DROP_MOVE || event.detail == DND.DROP_NONE )
+        {
+            if ( ConnectionTransfer.getInstance().isSupportedType( event.currentDataType ) )
+            {
+                if ( event.item != null && event.item.getData() instanceof IConnection )
+                {
+                    IConnection overConn = ( IConnection ) event.item.getData();
+                    if ( event.widget instanceof DropTarget )
+                    {
+                        DropTarget dropTarget = ( DropTarget ) event.widget;
+                        if ( dropTarget.getControl() instanceof Table )
+                        {
+                            Table table = ( Table ) dropTarget.getControl();
+                            TableItem[] items = table.getSelection();
+                            List connectionList = new ArrayList();
+                            for ( int i = 0; i < items.length; i++ )
+                            {
+                                if ( items[i].getData() instanceof IConnection )
+                                {
+                                    connectionList.add( items[i].getData() );
+                                }
+                            }
+                            if ( connectionList.contains( overConn ) )
+                            {
+                                isOverSelection = true;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        if ( !ConnectionTransfer.getInstance().isSupportedType( event.currentDataType ) )
+        {
+            event.detail = DND.DROP_NONE;
+        }
+        else if ( event.item == null )
+        {
+            event.detail = DND.DROP_NONE;
+        }
+        else if ( isOverSelection )
+        {
+            event.detail = DND.DROP_NONE;
+        }
+        else if ( event.detail == DND.DROP_LINK )
+        {
+            event.detail = DND.DROP_NONE;
+        }
+        else if ( event.detail == DND.DROP_NONE )
+        {
+            event.detail = DND.DROP_DEFAULT;
+        }
+
+    }
+
+
+    public void dropAccept( DropTargetEvent event )
+    {
+    }
+
+
+    public void drop( DropTargetEvent event )
+    {
+        ConnectionManager connectionManager = BrowserCorePlugin.getDefault().getConnectionManager();
+
+        try
+        {
+            if ( ConnectionTransfer.getInstance().isSupportedType( event.currentDataType ) )
+            {
+                // get connection to handle
+                IConnection[] connections = ( IConnection[] ) event.data;
+                IConnection targetConnection = ( IConnection ) event.item.getData();
+
+                if ( event.detail == DND.DROP_MOVE )
+                {
+                    boolean fromTop = connectionManager.indexOf( connections[0] ) < connectionManager
+                        .indexOf( targetConnection );
+                    for ( int i = 0; i < connections.length; i++ )
+                    {
+                        connectionManager.removeConnection( connections[i] );
+                    }
+                    for ( int i = 0; i < connections.length; i++ )
+                    {
+                        int index = connectionManager.indexOf( targetConnection );
+                        if ( fromTop )
+                        {
+                            index++;
+                            connectionManager.addConnection( index + i, connections[i] );
+                        }
+                        else
+                        {
+                            connectionManager.addConnection( index, connections[i] );
+                        }
+
+                    }
+                }
+                else if ( event.detail == DND.DROP_COPY )
+                {
+                    for ( int i = 0; i < connections.length; i++ )
+                    {
+                        IConnection newConnection = ( IConnection ) connections[i].clone();
+                        int index = connectionManager.indexOf( targetConnection );
+                        connectionManager.addConnection( index + i + 1, newConnection );
+                    }
+                }
+            }
+            else
+            {
+                event.detail = DND.DROP_NONE;
+            }
+        }
+        catch ( Exception e )
+        {
+            event.detail = DND.DROP_NONE;
+            e.printStackTrace();
+        }
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ModificationLogsView.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ModificationLogsView.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ModificationLogsView.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ModificationLogsView.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,170 @@
+/*
+ *  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.views.modificationlogs;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.widgets.ldifeditor.LdifEditorWidget;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.ViewPart;
+
+
+public class ModificationLogsView extends ViewPart
+{
+
+    private ModificationLogsViewActionGroup actionGroup;
+
+    private LdifEditorWidget mainWidget;
+
+    private ModificationLogsViewUniversalListener universalListener;
+
+
+    public static String getId()
+    {
+        return ModificationLogsView.class.getName();
+    }
+
+
+    public ModificationLogsView()
+    {
+        super();
+    }
+
+
+    public void setFocus()
+    {
+
+    }
+
+
+    public void dispose()
+    {
+        if ( this.mainWidget != null )
+        {
+            this.actionGroup.dispose();
+            this.actionGroup = null;
+            this.universalListener.dispose();
+            this.universalListener = null;
+            this.mainWidget.dispose();
+            this.mainWidget = null;
+        }
+        super.dispose();
+    }
+
+
+    public void createPartControl( Composite parent )
+    {
+
+        Composite composite = new Composite( parent, SWT.NONE );
+        composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+        GridLayout layout = new GridLayout();
+        layout.marginWidth = 0;
+        layout.marginHeight = 0;
+        composite.setLayout( layout );
+
+        PlatformUI.getWorkbench().getHelpSystem().setHelp( composite,
+            BrowserUIPlugin.PLUGIN_ID + "." + "tools_modification_logs_view" );
+
+        // create main widget
+        mainWidget = new LdifEditorWidget( null, "", false );
+        mainWidget.createWidget( composite );
+        mainWidget.getSourceViewer().setEditable( false );
+
+        // create actions and context menu (and register global actions)
+        this.actionGroup = new ModificationLogsViewActionGroup( this );
+        this.actionGroup.fillActionBars( getViewSite().getActionBars() );
+        // this.actionGroup.fillContextMenu(this.configuration.getContextMenuManager(this.mainWidget.getViewer()));
+
+        // create the listener
+        this.universalListener = new ModificationLogsViewUniversalListener( this );
+    }
+
+
+    public LdifEditorWidget getMainWidget()
+    {
+        return mainWidget;
+    }
+
+
+    public static void setInput( IConnection connection )
+    {
+        try
+        {
+            String targetId = ModificationLogsView.getId();
+            IViewPart targetView = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(
+                targetId );
+
+            if ( targetView == null && connection != null )
+            {
+                try
+                {
+                    targetView = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(
+                        targetId, null, IWorkbenchPage.VIEW_VISIBLE );
+                }
+                catch ( PartInitException e )
+                {
+                }
+            }
+
+            try
+            {
+                targetView = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView( targetId,
+                    null, IWorkbenchPage.VIEW_VISIBLE );
+            }
+            catch ( PartInitException e )
+            {
+            }
+
+            // set input
+            if ( targetView != null && targetView instanceof ModificationLogsView )
+            {
+                ModificationLogsViewInput input = new ModificationLogsViewInput( connection, 0 );
+                ( ( ModificationLogsView ) targetView ).universalListener.setInput( input );
+                ( ( ModificationLogsView ) targetView ).universalListener.scrollToNewest();
+            }
+        }
+        catch ( NullPointerException npe )
+        {
+        }
+    }
+
+
+    public ModificationLogsViewUniversalListener getUniversalListener()
+    {
+        return universalListener;
+    }
+
+
+    public ModificationLogsViewActionGroup getActionGroup()
+    {
+        return actionGroup;
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ModificationLogsViewActionGroup.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ModificationLogsViewActionGroup.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ModificationLogsViewActionGroup.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ModificationLogsViewActionGroup.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,113 @@
+/*
+ *  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.views.modificationlogs;
+
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.directory.ldapstudio.browser.ui.actions.proxy.ModificationLogsViewActionProxy;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.ui.IActionBars;
+
+
+public class ModificationLogsViewActionGroup implements IMenuListener
+{
+
+    private ModificationLogsView view;
+
+    private static final String olderAction = "olderAction";
+
+    private static final String newerAction = "newerAction";
+
+    private static final String refreshAction = "refreshAction";
+
+    private Map modificationLogsViewActionMap;
+
+
+    public ModificationLogsViewActionGroup( ModificationLogsView view )
+    {
+        this.view = view;
+        SourceViewer viewer = this.view.getMainWidget().getSourceViewer();
+
+        this.modificationLogsViewActionMap = new HashMap();
+        this.modificationLogsViewActionMap.put( olderAction, new ModificationLogsViewActionProxy( viewer,
+            new OlderAction( view ) ) );
+        this.modificationLogsViewActionMap.put( newerAction, new ModificationLogsViewActionProxy( viewer,
+            new NewerAction( view ) ) );
+        this.modificationLogsViewActionMap.put( refreshAction, new ModificationLogsViewActionProxy( viewer,
+            new RefreshAction( view ) ) );
+    }
+
+
+    public void dispose()
+    {
+        if ( this.view != null )
+        {
+
+            for ( Iterator it = this.modificationLogsViewActionMap.keySet().iterator(); it.hasNext(); )
+            {
+                String key = ( String ) it.next();
+                ModificationLogsViewActionProxy action = ( ModificationLogsViewActionProxy ) this.modificationLogsViewActionMap
+                    .get( key );
+                action.dispose();
+                action = null;
+                it.remove();
+            }
+            this.modificationLogsViewActionMap.clear();
+            this.modificationLogsViewActionMap = null;
+
+            this.view = null;
+        }
+    }
+
+
+    public void fillActionBars( IActionBars actionBars )
+    {
+        // Tool Bar
+        actionBars.getToolBarManager().add( ( IAction ) this.modificationLogsViewActionMap.get( refreshAction ) );
+        actionBars.getToolBarManager().add( new Separator() );
+        actionBars.getToolBarManager().add( ( IAction ) this.modificationLogsViewActionMap.get( olderAction ) );
+        actionBars.getToolBarManager().add( ( IAction ) this.modificationLogsViewActionMap.get( newerAction ) );
+    }
+
+
+    public void menuAboutToShow( IMenuManager menuManager )
+    {
+
+    }
+
+
+    public void setInput( ModificationLogsViewInput input )
+    {
+        for ( Iterator it = this.modificationLogsViewActionMap.values().iterator(); it.hasNext(); )
+        {
+            ModificationLogsViewActionProxy action = ( ModificationLogsViewActionProxy ) it.next();
+            action.inputChanged( input );
+        }
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ModificationLogsViewInput.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ModificationLogsViewInput.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ModificationLogsViewInput.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ModificationLogsViewInput.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,41 @@
+/*
+ *  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.views.modificationlogs;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+
+
+public class ModificationLogsViewInput
+{
+
+    IConnection connection;
+
+    int index;
+
+
+    public ModificationLogsViewInput( IConnection connection, int index )
+    {
+        this.connection = connection;
+        this.index = index;
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ModificationLogsViewUniversalListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ModificationLogsViewUniversalListener.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ModificationLogsViewUniversalListener.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/ModificationLogsViewUniversalListener.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,141 @@
+/*
+ *  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.views.modificationlogs;
+
+
+import java.io.File;
+import java.io.FileReader;
+
+import org.apache.directory.ldapstudio.browser.core.events.AttributesInitializedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.ChildrenInitializedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.EntryModificationEvent;
+import org.apache.directory.ldapstudio.browser.core.events.EntryUpdateListener;
+import org.apache.directory.ldapstudio.browser.core.events.EventRegistry;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifContainer;
+
+
+public class ModificationLogsViewUniversalListener implements EntryUpdateListener
+{
+
+    private ModificationLogsView view;
+
+    ModificationLogsViewInput input;
+
+
+    public ModificationLogsViewUniversalListener( ModificationLogsView view )
+    {
+        this.view = view;
+
+        this.input = null;
+        EventRegistry.addEntryUpdateListener( this );
+    }
+
+
+    public void dispose()
+    {
+        if ( this.view != null )
+        {
+            EventRegistry.removeEntryUpdateListener( this );
+            this.view = null;
+        }
+    }
+
+
+    void refreshInput()
+    {
+        ModificationLogsViewInput input = this.input;
+        this.input = null;
+        setInput( input );
+    }
+
+
+    void setInput( ModificationLogsViewInput input )
+    {
+
+        // only if another connection is selected
+        if ( this.input != input )
+        {
+
+            this.input = input;
+
+            // load file %u %g
+            StringBuffer sb = new StringBuffer();
+            File[] files = input.connection.getModificationLogger().getFiles();
+            int i = input.index;
+            if ( 0 <= i && i < files.length && files[i] != null && files[i].exists() && files[i].canRead() )
+            {
+                try
+                {
+                    FileReader fr = new FileReader( files[i] );
+                    char[] cbuf = new char[4096];
+                    for ( int length = fr.read( cbuf ); length > 0; length = fr.read( cbuf ) )
+                    {
+                        sb.append( cbuf, 0, length );
+                    }
+                }
+                catch ( Exception e )
+                {
+                    sb.append( e.getMessage() );
+                }
+            }
+
+            // change input
+            this.view.getMainWidget().getSourceViewer().getDocument().set( sb.toString() );
+            this.view.getActionGroup().setInput( input );
+
+        }
+    }
+
+
+    public void entryUpdated( EntryModificationEvent event )
+    {
+        if ( !( event instanceof AttributesInitializedEvent ) && !( event instanceof ChildrenInitializedEvent ) )
+        {
+            refreshInput();
+            scrollToNewest();
+        }
+    }
+
+
+    public void scrollToOldest()
+    {
+        this.view.getMainWidget().getSourceViewer().setTopIndex( 0 );
+    }
+
+
+    public void scrollToNewest()
+    {
+        try
+        {
+            LdifContainer record = this.view.getMainWidget().getLdifModel().getLastContainer();
+            int offset = record.getOffset();
+            int line = this.view.getMainWidget().getSourceViewer().getDocument().getLineOfOffset( offset );
+            if ( line > 3 )
+                line -= 3;
+            this.view.getMainWidget().getSourceViewer().setTopIndex( line );
+        }
+        catch ( Exception e )
+        {
+        }
+
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/NewerAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/NewerAction.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/NewerAction.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/NewerAction.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,87 @@
+/*
+ *  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.views.modificationlogs;
+
+
+import org.apache.directory.ldapstudio.browser.core.events.ModelModifier;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.actions.BrowserAction;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+
+
+public class NewerAction extends BrowserAction implements ModelModifier
+{
+
+    ModificationLogsView view;
+
+
+    public NewerAction( ModificationLogsView view )
+    {
+        super();
+        this.view = view;
+    }
+
+
+    public void dispose()
+    {
+        super.dispose();
+    }
+
+
+    public void run()
+    {
+        ModificationLogsViewInput oldInput = ( ModificationLogsViewInput ) getInput();
+        ModificationLogsViewInput newInput = new ModificationLogsViewInput( oldInput.connection, oldInput.index - 1 );
+        view.getUniversalListener().setInput( newInput );
+        view.getUniversalListener().scrollToOldest();
+
+        // go to top
+        view.getMainWidget().getSourceViewer().setTopIndex( 0 );
+    }
+
+
+    public String getText()
+    {
+        return "Newer";
+    }
+
+
+    public ImageDescriptor getImageDescriptor()
+    {
+        return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_NEXT );
+    }
+
+
+    public String getCommandId()
+    {
+        return null;
+    }
+
+
+    public boolean isEnabled()
+    {
+        return getInput() != null && ( getInput() instanceof ModificationLogsViewInput )
+            && ( ( ModificationLogsViewInput ) getInput() ).index > 0;
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/OlderAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/OlderAction.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/OlderAction.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/OlderAction.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,99 @@
+/*
+ *  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.views.modificationlogs;
+
+
+import java.io.File;
+
+import org.apache.directory.ldapstudio.browser.core.events.ModelModifier;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.actions.BrowserAction;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+
+
+public class OlderAction extends BrowserAction implements ModelModifier
+{
+
+    private ModificationLogsView view;
+
+
+    public OlderAction( ModificationLogsView view )
+    {
+        super();
+        this.view = view;
+    }
+
+
+    public void dispose()
+    {
+        super.dispose();
+    }
+
+
+    public void run()
+    {
+        ModificationLogsViewInput oldInput = ( ModificationLogsViewInput ) getInput();
+        ModificationLogsViewInput newInput = new ModificationLogsViewInput( oldInput.connection, oldInput.index + 1 );
+        view.getUniversalListener().setInput( newInput );
+        view.getUniversalListener().scrollToNewest();
+
+        // go to bottom
+        // view.getMainWidget().getSourceViewer().setTopIndex(Integer.MAX_VALUE);
+    }
+
+
+    public String getText()
+    {
+        return "Older";
+    }
+
+
+    public ImageDescriptor getImageDescriptor()
+    {
+        return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_PREVIOUS );
+    }
+
+
+    public String getCommandId()
+    {
+        return null;
+    }
+
+
+    public boolean isEnabled()
+    {
+        if ( getInput() != null && ( getInput() instanceof ModificationLogsViewInput ) )
+        {
+            ModificationLogsViewInput input = ( ModificationLogsViewInput ) getInput();
+            File[] files = input.connection.getModificationLogger().getFiles();
+            int i = input.index + 1;
+            if ( 0 <= i && i < files.length && files[i] != null && files[i].exists() && files[i].canRead() )
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/RefreshAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/RefreshAction.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/RefreshAction.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/modificationlogs/RefreshAction.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,83 @@
+/*
+ *  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.views.modificationlogs;
+
+
+import org.apache.directory.ldapstudio.browser.core.events.ModelModifier;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.actions.BrowserAction;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+
+
+public class RefreshAction extends BrowserAction implements ModelModifier
+{
+
+    private ModificationLogsView view;
+
+
+    public RefreshAction( ModificationLogsView view )
+    {
+        super();
+        this.view = view;
+    }
+
+
+    public void dispose()
+    {
+        super.dispose();
+    }
+
+
+    public void run()
+    {
+        // int topIndex = view.getMainWidget().getSourceViewer().getTopIndex();
+        view.getUniversalListener().refreshInput();
+        view.getUniversalListener().scrollToNewest();
+        // view.getMainWidget().getSourceViewer().setTopIndex(topIndex);
+    }
+
+
+    public String getText()
+    {
+        return "Refresh";
+    }
+
+
+    public ImageDescriptor getImageDescriptor()
+    {
+        return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_REFRESH );
+    }
+
+
+    public String getCommandId()
+    {
+        return null;
+    }
+
+
+    public boolean isEnabled()
+    {
+        return getInput() != null && ( getInput() instanceof ModificationLogsViewInput );
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/BaseWidgetUtils.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/BaseWidgetUtils.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/BaseWidgetUtils.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/BaseWidgetUtils.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,310 @@
+/*
+ *  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.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.FontMetrics;
+import org.eclipse.swt.graphics.GC;
+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.Link;
+import org.eclipse.swt.widgets.Text;
+
+
+public class BaseWidgetUtils
+{
+
+    public static Group createGroup( Composite parent, String label, int span )
+    {
+        Group group = new Group( parent, SWT.NONE );
+        GridData gd = new GridData( GridData.FILL_BOTH );
+        gd.horizontalSpan = span;
+        group.setLayoutData( gd );
+        group.setText( label );
+        group.setLayout( new GridLayout() );
+        return group;
+    }
+
+
+    public static Composite createColumnContainer( Composite parent, int columnCount, int span )
+    {
+        Composite container = new Composite( parent, SWT.NONE );
+        GridLayout gl = new GridLayout( columnCount, false );
+        gl.marginHeight = gl.marginWidth = 0;
+        container.setLayout( gl );
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = span;
+        container.setLayoutData( gd );
+        return container;
+    }
+
+
+    public static Label createLabel( Composite parent, String text, int span )
+    {
+        Label l = new Label( parent, SWT.NONE );
+        GridData gd = new GridData();
+        gd.horizontalSpan = span;
+        // gd.verticalAlignment = SWT.BEGINNING;
+        l.setLayoutData( gd );
+        l.setText( text );
+        return l;
+    }
+
+
+    public static Label createWrappedLabel( Composite parent, String text, int span )
+    {
+        Label l = new Label( parent, SWT.WRAP );
+        GridData gd = new GridData();
+        gd.horizontalSpan = span;
+        // gd.verticalAlignment = SWT.BEGINNING;
+        l.setLayoutData( gd );
+        l.setText( text );
+        return l;
+    }
+
+
+    public static Text createText( Composite parent, String text, int span )
+    {
+        Text t = new Text( parent, SWT.NONE | SWT.BORDER );
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = span;
+        t.setLayoutData( gd );
+        t.setText( text );
+        return t;
+    }
+
+
+    public static Text createText( Composite parent, String text, int textWidth, int span )
+    {
+        Text t = new Text( parent, SWT.NONE | SWT.BORDER );
+        GridData gd = new GridData();
+        gd.horizontalSpan = span;
+        gd.widthHint = 9 * textWidth;
+        t.setLayoutData( gd );
+        t.setText( text );
+        t.setTextLimit( textWidth );
+        return t;
+    }
+
+
+    public static Text createPasswordText( Composite parent, String text, int span )
+    {
+        Text t = new Text( parent, SWT.NONE | SWT.BORDER | SWT.PASSWORD );
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = span;
+        t.setLayoutData( gd );
+        t.setText( text );
+        return t;
+    }
+
+
+    public static Text createReadonlyPasswordText( Composite parent, String text, int span )
+    {
+        Text t = new Text( parent, SWT.NONE | SWT.BORDER | SWT.PASSWORD | SWT.READ_ONLY );
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = span;
+        t.setLayoutData( gd );
+        t.setEditable( false );
+        t.setBackground( parent.getBackground() );
+        t.setText( text );
+        return t;
+    }
+
+
+    public static Text createLabeledText( Composite parent, String text, int span )
+    {
+        Text t = new Text( parent, SWT.NONE );
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = span;
+        t.setLayoutData( gd );
+        t.setEditable( false );
+        t.setBackground( parent.getBackground() );
+        t.setText( text );
+        return t;
+    }
+
+
+    public static Text createWrappedLabeledText( Composite parent, String text, int span )
+    {
+        Text t = new Text( parent, SWT.WRAP );
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = span;
+        gd.widthHint = 10;
+        gd.grabExcessHorizontalSpace = true;
+        gd.horizontalAlignment = GridData.FILL;
+        t.setLayoutData( gd );
+        t.setEditable( false );
+        t.setBackground( parent.getBackground() );
+        t.setText( text );
+        return t;
+    }
+
+
+    public static Text createReadonlyText( Composite parent, String text, int span )
+    {
+        Text t = new Text( parent, SWT.NONE | SWT.BORDER | SWT.READ_ONLY );
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = span;
+        t.setLayoutData( gd );
+        t.setEditable( false );
+        t.setBackground( parent.getBackground() );
+        t.setText( text );
+        return t;
+    }
+
+
+    public static String getNonNullString( String s )
+    {
+        return s == null ? "-" : s;
+    }
+
+
+    public static Combo createCombo( Composite parent, String[] items, int selectedIndex, int span )
+    {
+        Combo c = new Combo( parent, SWT.DROP_DOWN | SWT.BORDER );
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = span;
+        c.setLayoutData( gd );
+        c.setItems( items );
+        c.select( selectedIndex );
+        c.setVisibleItemCount( 20 );
+        return c;
+    }
+
+
+    public static Combo createReadonlyCombo( Composite parent, String[] items, int selectedIndex, int span )
+    {
+        Combo c = new Combo( parent, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER );
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = span;
+        c.setLayoutData( gd );
+        // c.setBackground(parent.getBackground());
+        c.setItems( items );
+        c.select( selectedIndex );
+        c.setVisibleItemCount( 20 );
+        return c;
+    }
+
+
+    public static Combo createReadonlyReadonlyCombo( Composite parent, String[] items, int selectedIndex, int span )
+    {
+        Combo c = new Combo( parent, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER );
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = span;
+        c.setLayoutData( gd );
+        c.setBackground( parent.getBackground() );
+        c.setItems( items );
+        c.select( selectedIndex );
+        c.setVisibleItemCount( 20 );
+        return c;
+    }
+
+
+    public static Button createCheckbox( Composite composite, String text, int span )
+    {
+        Button checkbox = new Button( composite, SWT.CHECK );
+        checkbox.setText( text );
+        GridData gd = new GridData();
+        gd.horizontalSpan = span;
+        checkbox.setLayoutData( gd );
+        return checkbox;
+    }
+
+
+    public static Button createRadiobutton( Composite composite, String text, int span )
+    {
+        Button radio = new Button( composite, SWT.RADIO );
+        radio.setText( text );
+        GridData gd = new GridData();
+        gd.horizontalSpan = span;
+        radio.setLayoutData( gd );
+        return radio;
+    }
+
+
+    public static Button createButton( Composite composite, String text, int span )
+    {
+        GC gc = new GC( composite );
+        gc.setFont( JFaceResources.getDialogFont() );
+        FontMetrics fontMetrics = gc.getFontMetrics();
+        gc.dispose();
+
+        Button button = new Button( composite, SWT.PUSH );
+        GridData gd = new GridData();
+        gd.widthHint = Dialog.convertHorizontalDLUsToPixels( fontMetrics, IDialogConstants.BUTTON_WIDTH );
+        button.setLayoutData( gd );
+        button.setText( text );
+        return button;
+    }
+
+
+    public static void createRadioIndent( Composite composite, int span )
+    {
+        Label l = new Label( composite, SWT.NONE );
+        GridData gd = new GridData();
+        gd.horizontalSpan = span;
+        gd.horizontalIndent = 22;
+        l.setLayoutData( gd );
+    }
+
+
+    public static void createSpacer( Composite composite, int span )
+    {
+        Label l = new Label( composite, SWT.NONE );
+        // GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+        GridData gd = new GridData();
+        gd.horizontalSpan = span;
+        gd.heightHint = 1;
+        l.setLayoutData( gd );
+    }
+
+
+    public static void createSeparator( Composite composite, int span )
+    {
+        Label l = new Label( composite, SWT.SEPARATOR | SWT.HORIZONTAL );
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = span;
+        // gd.heightHint = 1;
+        l.setLayoutData( gd );
+    }
+
+
+    public static Link createLink( Composite parent, String text, int span )
+    {
+        Link link = new Link( parent, SWT.NONE );
+        link.setText( text );
+        GridData gd = new GridData( SWT.FILL, SWT.BEGINNING, true, false );
+        gd.horizontalSpan = span;
+        gd.widthHint = 150;
+        link.setLayoutData( gd );
+        return link;
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/BinaryEncodingInput.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/BinaryEncodingInput.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/BinaryEncodingInput.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/BinaryEncodingInput.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,65 @@
+/*
+ *  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.core.BrowserCoreConstants;
+
+
+public class BinaryEncodingInput extends OptionsInput
+{
+
+    public BinaryEncodingInput( String initialRawValue, boolean asGroup )
+    {
+        super( "Binary Encoding", getDefaultDisplayValue(), getDefaultRawValue(), getOtherDisplayValues(),
+            getOtherRawValues(), initialRawValue, asGroup, false );
+
+    }
+
+
+    private static String getDefaultDisplayValue()
+    {
+        return "Ignore";
+    }
+
+
+    private static String getDefaultRawValue()
+    {
+        return Integer.toString( BrowserCoreConstants.BINARYENCODING_IGNORE );
+    }
+
+
+    private static String[] getOtherDisplayValues()
+    {
+        return new String[]
+            { "Ignore", "BASE-64", "HEX" };
+    }
+
+
+    private static String[] getOtherRawValues()
+    {
+        return new String[]
+            { Integer.toString( BrowserCoreConstants.BINARYENCODING_IGNORE ),
+                Integer.toString( BrowserCoreConstants.BINARYENCODING_BASE64 ),
+                Integer.toString( BrowserCoreConstants.BINARYENCODING_HEX ) };
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/BrowserWidget.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/BrowserWidget.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/BrowserWidget.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/BrowserWidget.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,65 @@
+/*
+ *  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.Iterator;
+import java.util.List;
+
+
+public abstract class BrowserWidget
+{
+
+    protected List modifyListenerList;
+
+
+    protected BrowserWidget()
+    {
+        modifyListenerList = new ArrayList( 3 );
+    }
+
+
+    public void addWidgetModifyListener( WidgetModifyListener listener )
+    {
+        if ( !modifyListenerList.contains( listener ) )
+            modifyListenerList.add( listener );
+    }
+
+
+    public void removeWidgetModifyListener( WidgetModifyListener listener )
+    {
+        if ( modifyListenerList.contains( listener ) )
+            modifyListenerList.remove( listener );
+    }
+
+
+    protected void notifyListeners()
+    {
+        WidgetModifyEvent event = new WidgetModifyEvent( this );
+        for ( Iterator it = modifyListenerList.iterator(); it.hasNext(); )
+        {
+            WidgetModifyListener listener = ( WidgetModifyListener ) it.next();
+            listener.widgetModified( event );
+        }
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/DialogContentAssistant.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/DialogContentAssistant.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/DialogContentAssistant.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/DialogContentAssistant.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,169 @@
+/*
+ *  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.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.jface.contentassist.ComboContentAssistSubjectAdapter;
+import org.eclipse.jface.contentassist.SubjectControlContentAssistant;
+import org.eclipse.jface.contentassist.TextContentAssistSubjectAdapter;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.events.TraverseEvent;
+import org.eclipse.swt.events.TraverseListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.IHandlerActivation;
+import org.eclipse.ui.handlers.IHandlerService;
+import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
+
+
+public class DialogContentAssistant extends SubjectControlContentAssistant implements FocusListener
+{
+
+    private Control control;
+
+    private IHandlerActivation handlerActivation;
+
+    private boolean possibleCompletionsVisible;
+
+
+    public DialogContentAssistant()
+    {
+        super();
+        this.possibleCompletionsVisible = false;
+    }
+
+
+    public void install( Text text )
+    {
+        this.control = text;
+        this.control.addFocusListener( this );
+        super.install( new TextContentAssistSubjectAdapter( text ) );
+    }
+
+
+    public void install( Combo combo )
+    {
+        this.control = combo;
+        this.control.addFocusListener( this );
+        super.install( new ComboContentAssistSubjectAdapter( combo ) );
+    }
+
+
+    public void install( ITextViewer viewer )
+    {
+        this.control = viewer.getTextWidget();
+        this.control.addFocusListener( this );
+
+        // stop traversal (ESC) if popup is shown
+        this.control.addTraverseListener( new TraverseListener()
+        {
+            public void keyTraversed( TraverseEvent e )
+            {
+                if ( possibleCompletionsVisible )
+                {
+                    e.doit = false;
+                }
+            }
+        } );
+
+        super.install( viewer );
+    }
+
+
+    public void uninstall()
+    {
+        if ( this.handlerActivation != null )
+        {
+            IHandlerService handlerService = ( IHandlerService ) PlatformUI.getWorkbench().getAdapter(
+                IHandlerService.class );
+            handlerService.deactivateHandler( this.handlerActivation );
+            this.handlerActivation = null;
+        }
+
+        if ( this.control != null )
+        {
+            this.control.removeFocusListener( this );
+        }
+
+        super.uninstall();
+    }
+
+
+    protected Point restoreCompletionProposalPopupSize()
+    {
+        possibleCompletionsVisible = true;
+        return super.restoreCompletionProposalPopupSize();
+    }
+
+
+    public String showPossibleCompletions()
+    {
+        possibleCompletionsVisible = true;
+        return super.showPossibleCompletions();
+    }
+
+
+    protected void possibleCompletionsClosed()
+    {
+        this.possibleCompletionsVisible = false;
+        super.possibleCompletionsClosed();
+    }
+
+
+    public void focusGained( FocusEvent e )
+    {
+        IHandlerService handlerService = ( IHandlerService ) PlatformUI.getWorkbench().getAdapter(
+            IHandlerService.class );
+        if ( handlerService != null )
+        {
+            IHandler handler = new org.eclipse.core.commands.AbstractHandler()
+            {
+                public Object execute( ExecutionEvent event ) throws org.eclipse.core.commands.ExecutionException
+                {
+                    showPossibleCompletions();
+                    return null;
+                }
+            };
+            this.handlerActivation = handlerService.activateHandler(
+                ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, handler );
+        }
+    }
+
+
+    public void focusLost( FocusEvent e )
+    {
+        if ( this.handlerActivation != null )
+        {
+            IHandlerService handlerService = ( IHandlerService ) PlatformUI.getWorkbench().getAdapter(
+                IHandlerService.class );
+            handlerService.deactivateHandler( this.handlerActivation );
+            this.handlerActivation = null;
+        }
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/DnBuilderWidget.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/DnBuilderWidget.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/DnBuilderWidget.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/DnBuilderWidget.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,496 @@
+/*
+ *  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 org.apache.directory.ldapstudio.browser.core.model.DN;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.RDN;
+import org.apache.directory.ldapstudio.browser.core.model.RDNPart;
+import org.apache.directory.ldapstudio.browser.ui.widgets.search.EntryWidget;
+
+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.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+
+public class DnBuilderWidget extends BrowserWidget implements ModifyListener
+{
+
+    private IConnection connection;
+
+    private String[] attributeNames;
+
+    private RDN currentRdn;
+
+    private DN currentParentDn;
+
+    private boolean showRDN;
+
+    private boolean showParent;
+
+    private Shell shell;
+
+    private DN parentDn;
+
+    private EntryWidget parentEntryWidget;
+
+    private Composite rdnComposite;
+
+    private RDN rdn;
+
+    private ArrayList rdnLineList;
+
+    // private int rdnGroupHeight = -1;
+
+    private Text dnOrRdnText;
+
+
+    public DnBuilderWidget( boolean showRDN, boolean showParent )
+    {
+        this.showRDN = showRDN;
+        this.showParent = showParent;
+    }
+
+
+    public void dispose()
+    {
+
+    }
+
+
+    public void setInput( IConnection connection, String[] attributeNames, RDN rdn, DN parentDn )
+    {
+        this.connection = connection;
+
+        this.attributeNames = attributeNames;
+        if ( showRDN )
+        {
+            for ( int i = 0; i < this.rdnLineList.size(); i++ )
+            {
+                RdnLine rdnLine = ( RdnLine ) this.rdnLineList.get( i );
+                String oldName = rdnLine.rdnNameCombo.getText();
+                rdnLine.rdnNameCombo.setItems( attributeNames );
+                if ( Arrays.asList( rdnLine.rdnNameCombo.getItems() ).contains( oldName ) )
+                {
+                    rdnLine.rdnNameCombo.setText( oldName );
+                }
+            }
+        }
+
+        this.currentRdn = rdn;
+        if ( showRDN )
+        {
+            while ( !rdnLineList.isEmpty() )
+            {
+                deleteRdnLine( this.rdnComposite, 0 );
+            }
+            if ( this.currentRdn == null || this.currentRdn.getParts().length == 0 )
+            {
+                addRdnLine( this.rdnComposite, 0 );
+            }
+            else
+            {
+                RDNPart[] parts = this.currentRdn.getParts();
+                for ( int i = 0; i < parts.length; i++ )
+                {
+                    addRdnLine( this.rdnComposite, i );
+                    ( ( RdnLine ) rdnLineList.get( i ) ).rdnNameCombo.setText( parts[i].getName() );
+                    ( ( RdnLine ) rdnLineList.get( i ) ).rdnValueText.setText( parts[i].getUnencodedValue() );
+                    if ( i == 0 )
+                    {
+                        ( ( RdnLine ) rdnLineList.get( i ) ).rdnValueText.setFocus();
+                    }
+                }
+            }
+        }
+
+        this.currentParentDn = parentDn;
+        if ( showParent )
+        {
+            parentEntryWidget.setInput( this.connection, this.currentParentDn );
+        }
+
+        validate();
+    }
+
+
+    public RDN getRdn()
+    {
+        return this.rdn;
+    }
+
+
+    public DN getParentDn()
+    {
+        return this.parentDn;
+    }
+
+
+    public Composite createContents( Composite parent )
+    {
+        this.shell = parent.getShell();
+
+        Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 );
+
+        // draw parent
+        if ( showParent )
+        {
+            BaseWidgetUtils.createLabel( composite, "Parent:", 1 );
+            parentEntryWidget = new EntryWidget();
+            parentEntryWidget.createWidget( composite );
+            // parentEntryWidget.setInput(this.connection,
+            // this.currentParentDn);
+            parentEntryWidget.addWidgetModifyListener( new WidgetModifyListener()
+            {
+                public void widgetModified( WidgetModifyEvent event )
+                {
+                    validate();
+                }
+            } );
+
+            BaseWidgetUtils.createSpacer( composite, 3 );
+        }
+
+        // draw RDN group
+        if ( showRDN )
+        {
+            BaseWidgetUtils.createLabel( composite, "RDN:", 1 );
+            this.rdnComposite = BaseWidgetUtils.createColumnContainer( composite, 5, 2 );
+            this.rdnLineList = new ArrayList();
+            BaseWidgetUtils.createSpacer( composite, 3 );
+        }
+
+        // draw dn/rdn preview
+        if ( showRDN )
+        {
+            BaseWidgetUtils.createLabel( composite, this.showParent ? "DN Preview: " : "RDN Preview: ", 1 );
+            this.dnOrRdnText = BaseWidgetUtils.createReadonlyText( composite, "", 2 );
+            BaseWidgetUtils.createSpacer( composite, 3 );
+        }
+
+        // fill RDN
+        // if(showRDN) {
+        // setRdn(currentRdn);
+        // }
+
+        return composite;
+    }
+
+
+    public void modifyText( ModifyEvent e )
+    {
+        this.validate();
+    }
+
+
+    public void saveDialogSettings()
+    {
+        if ( this.parentEntryWidget != null )
+        {
+            this.parentEntryWidget.saveDialogSettings();
+        }
+    }
+
+
+    public void validate()
+    {
+
+        Exception rdnE = null;
+        if ( showRDN )
+        {
+            try
+            {
+                // calculate RDN
+                String[] rdnNames = new String[this.rdnLineList.size()];
+                String[] rdnValues = new String[this.rdnLineList.size()];
+                for ( int i = 0; i < this.rdnLineList.size(); i++ )
+                {
+                    RdnLine rdnLine = ( RdnLine ) this.rdnLineList.get( i );
+                    rdnNames[i] = rdnLine.rdnNameCombo.getText();
+                    rdnValues[i] = rdnLine.rdnValueText.getText();
+
+                    if ( this.rdnLineList.size() > 1 )
+                    {
+                        rdnLine.rdnDeleteButton.setEnabled( true );
+                    }
+                    else
+                    {
+                        rdnLine.rdnDeleteButton.setEnabled( false );
+                    }
+                }
+                this.rdn = new RDN( rdnNames, rdnValues, false );
+            }
+            catch ( Exception e )
+            {
+                rdnE = e;
+                this.rdn = null;
+            }
+        }
+
+        Exception parentE = null;
+        if ( showParent )
+        {
+            try
+            {
+                // calculate DN
+                this.parentDn = new DN( parentEntryWidget.getDn() );
+            }
+            catch ( Exception e )
+            {
+                parentE = e;
+                this.parentDn = null;
+            }
+        }
+
+        String s = "";
+        if ( rdnE != null )
+        {
+            s += rdnE.getMessage() != null ? rdnE.getMessage() : "Error in RDN ";
+        }
+        if ( parentE != null )
+        {
+            s += ", " + parentE.getMessage() != null ? parentE.getMessage() : "Error in Parent DN ";
+        }
+
+        if ( this.dnOrRdnText != null )
+        {
+            if ( s.length() > 0 )
+            {
+                this.dnOrRdnText.setText( s );
+            }
+            else
+            {
+                DN dn;
+                if ( this.showParent && this.showRDN )
+                {
+                    dn = new DN( rdn, parentDn );
+                }
+                else if ( this.showParent )
+                {
+                    dn = new DN( parentDn );
+                }
+                else if ( this.showRDN )
+                {
+                    dn = new DN( rdn );
+                }
+                else
+                {
+                    dn = new DN();
+                }
+                this.dnOrRdnText.setText( dn.toString() );
+            }
+        }
+
+        notifyListeners();
+    }
+
+
+    private void addRdnLine( Composite rdnGroup, int index )
+    {
+
+        RdnLine[] rdnLines = ( RdnLine[] ) rdnLineList.toArray( new RdnLine[rdnLineList.size()] );
+
+        if ( rdnLines.length > 0 )
+        {
+            for ( int i = 0; i < rdnLines.length; i++ )
+            {
+                RdnLine oldRdnLine = rdnLines[i];
+
+                // remember values
+                String oldName = oldRdnLine.rdnNameCombo.getText();
+                String oldValue = oldRdnLine.rdnValueText.getText();
+
+                // delete old
+                oldRdnLine.rdnNameCombo.dispose();
+                oldRdnLine.rdnEqualsLabel.dispose();
+                oldRdnLine.rdnValueText.dispose();
+                oldRdnLine.rdnAddButton.dispose();
+                oldRdnLine.rdnDeleteButton.dispose();
+                rdnLineList.remove( oldRdnLine );
+
+                // add new
+                RdnLine newRdnLine = createRdnLine( rdnGroup );
+                rdnLineList.add( newRdnLine );
+
+                // restore value
+                newRdnLine.rdnNameCombo.setText( oldName );
+                newRdnLine.rdnValueText.setText( oldValue );
+
+                // check
+                if ( index == i + 1 )
+                {
+                    RdnLine rdnLine = createRdnLine( rdnGroup );
+                    rdnLineList.add( rdnLine );
+                }
+            }
+        }
+        else
+        {
+            RdnLine rdnLine = createRdnLine( rdnGroup );
+            rdnLineList.add( rdnLine );
+        }
+
+        // Point shellSize = shell.getSize();
+        // Point groupSize = rdnGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT,
+        // true);
+        // int newRdnGroupHeight = groupSize.y;
+        // shell.setSize(shellSize.x, shellSize.y + newRdnGroupHeight -
+        // rdnGroupHeight);
+        rdnGroup.layout( true, true );
+        shell.layout( true, true );
+        // rdnGroupHeight = newRdnGroupHeight;
+    }
+
+
+    private RdnLine createRdnLine( final Composite rdnGroup )
+    {
+        final RdnLine rdnLine = new RdnLine();
+
+        rdnLine.rdnNameCombo = new Combo( rdnGroup, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER );
+        GridData gd = new GridData();
+        gd.widthHint = 180;
+        rdnLine.rdnNameCombo.setLayoutData( gd );
+        rdnLine.rdnNameCombo.setVisibleItemCount( 20 );
+
+        rdnLine.rdnEqualsLabel = new Label( rdnGroup, SWT.NONE );
+        rdnLine.rdnEqualsLabel.setText( "=" );
+
+        rdnLine.rdnValueText = new Text( rdnGroup, SWT.BORDER );
+        gd = new GridData( GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL );
+        rdnLine.rdnValueText.setLayoutData( gd );
+
+        rdnLine.rdnAddButton = new Button( rdnGroup, SWT.PUSH );
+        rdnLine.rdnAddButton.setText( "  +   " );
+        rdnLine.rdnAddButton.addSelectionListener( new SelectionListener()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                int index = rdnLineList.size();
+                for ( int i = 0; i < rdnLineList.size(); i++ )
+                {
+                    RdnLine rdnLine = ( RdnLine ) rdnLineList.get( i );
+                    if ( rdnLine.rdnAddButton == e.widget )
+                    {
+                        index = i + 1;
+                    }
+                }
+                addRdnLine( rdnGroup, index );
+
+                validate();
+            }
+
+
+            public void widgetDefaultSelected( SelectionEvent e )
+            {
+            }
+        } );
+
+        rdnLine.rdnDeleteButton = new Button( rdnGroup, SWT.PUSH );
+        rdnLine.rdnDeleteButton.setText( "  \u2212  " ); // \u2013
+        rdnLine.rdnDeleteButton.addSelectionListener( new SelectionListener()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                int index = 0;
+                for ( int i = 0; i < rdnLineList.size(); i++ )
+                {
+                    RdnLine rdnLine = ( RdnLine ) rdnLineList.get( i );
+                    if ( rdnLine.rdnDeleteButton == e.widget )
+                    {
+                        index = i;
+                    }
+                }
+                deleteRdnLine( rdnGroup, index );
+
+                validate();
+            }
+
+
+            public void widgetDefaultSelected( SelectionEvent e )
+            {
+            }
+        } );
+
+        if ( this.attributeNames != null )
+        {
+            // Subschema subschema = new Subschema(this.attributeNames,
+            // this.connection.getSchema());
+            rdnLine.rdnNameCombo.setItems( this.attributeNames );
+        }
+
+        rdnLine.rdnNameCombo.addModifyListener( this );
+        rdnLine.rdnValueText.addModifyListener( this );
+
+        return rdnLine;
+    }
+
+
+    private void deleteRdnLine( Composite rdnGroup, int index )
+    {
+        RdnLine rdnLine = ( RdnLine ) rdnLineList.remove( index );
+        if ( rdnLine != null )
+        {
+            rdnLine.rdnNameCombo.dispose();
+            rdnLine.rdnEqualsLabel.dispose();
+            rdnLine.rdnValueText.dispose();
+            rdnLine.rdnAddButton.dispose();
+            rdnLine.rdnDeleteButton.dispose();
+
+            // Point shellSize = shell.getSize();
+            // Point groupSize = rdnGroup.computeSize(SWT.DEFAULT,
+            // SWT.DEFAULT,
+            // true);
+            // int newRdnGroupHeight = groupSize.y;
+            // shell.setSize(shellSize.x, shellSize.y + newRdnGroupHeight -
+            // rdnGroupHeight);
+            rdnGroup.layout( true, true );
+            shell.layout( true, true );
+            // rdnGroupHeight = newRdnGroupHeight;
+        }
+    }
+
+    public class RdnLine
+    {
+        public Combo rdnNameCombo;
+
+        public Text rdnValueText;
+
+        public Label rdnEqualsLabel;
+
+        public Button rdnAddButton;
+
+        public Button rdnDeleteButton;
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/FileBrowserWidget.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/FileBrowserWidget.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/FileBrowserWidget.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/widgets/FileBrowserWidget.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,152 @@
+/*
+ *  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.io.File;
+
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+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.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+
+
+public class FileBrowserWidget extends BrowserWidget
+{
+
+    public static final int TYPE_OPEN = SWT.OPEN;
+
+    public static final int TYPE_SAVE = SWT.SAVE;
+
+    private Combo fileCombo;
+
+    private Button browseButton;
+
+    private String title;
+
+    private String[] extensions;
+
+    private int type;
+
+
+    public FileBrowserWidget( String title, String[] extensions, int type )
+    {
+        this.title = title;
+        this.extensions = extensions;
+        this.type = type;
+    }
+
+
+    public void createWidget( final Composite parent )
+    {
+
+        // Combo
+        fileCombo = BaseWidgetUtils.createCombo( parent, new String[0], -1, 1 );
+        fileCombo.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                notifyListeners();
+            }
+        } );
+
+        // Button
+        browseButton = BaseWidgetUtils.createButton( parent, "Bro&wse...", 1 );
+        browseButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent event )
+            {
+                FileDialog fileDialog = new FileDialog( parent.getShell(), type );
+                fileDialog.setText( title );
+
+                fileDialog.setFilterExtensions( extensions );
+
+                File file = new File( fileCombo.getText() );
+                if ( file.isFile() )
+                {
+                    fileDialog.setFilterPath( file.getParent() );
+                    fileDialog.setFileName( file.getName() );
+                }
+                else if ( file.isDirectory() )
+                {
+                    fileDialog.setFilterPath( file.getPath() );
+                }
+                else
+                {
+                    fileDialog.setFilterPath( BrowserUIPlugin.getDefault().getDialogSettings().get(
+                        BrowserUIConstants.DIALOGSETTING_KEY_RECENT_FILE_PATH ) );
+                }
+
+                String returnedFileName = fileDialog.open();
+                if ( returnedFileName != null )
+                {
+                    fileCombo.setText( returnedFileName );
+                    File file2 = new File( returnedFileName );
+                    BrowserUIPlugin.getDefault().getDialogSettings().put(
+                        BrowserUIConstants.DIALOGSETTING_KEY_RECENT_FILE_PATH, file2.getParent() );
+                }
+            }
+        } );
+
+        // filter history
+        String[] history = HistoryUtils.load( BrowserUIConstants.DIALOGSETTING_KEY_FILE_HISTORY );
+        fileCombo.setItems( history );
+    }
+
+
+    public String getFilename()
+    {
+        return this.fileCombo.getText();
+    }
+
+
+    public void setFilename( String filename )
+    {
+        this.fileCombo.setText( filename );
+    }
+
+
+    public void saveDialogSettings()
+    {
+        HistoryUtils.save( BrowserUIConstants.DIALOGSETTING_KEY_FILE_HISTORY, this.fileCombo.getText() );
+    }
+
+
+    public void setFocus()
+    {
+        fileCombo.setFocus();
+    }
+
+
+    public void setEnabled( boolean b )
+    {
+        this.fileCombo.setEnabled( b );
+        this.browseButton.setEnabled( b );
+    }
+
+}