directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r526693 [5/17] - in /directory/ldapstudio/trunk/ldapstudio-browser-common: ./ META-INF/ resources/ resources/icons/ resources/templates/ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/dir...
Date Mon, 09 Apr 2007 09:49:57 GMT
Added: directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/HexDialog.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/HexDialog.java?view=auto&rev=526693
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/HexDialog.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/HexDialog.java Mon Apr  9 02:49:48 2007
@@ -0,0 +1,251 @@
+/*
+ *  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.common.dialogs;
+
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import org.apache.directory.ldapstudio.browser.common.BrowserCommonActivator;
+import org.apache.directory.ldapstudio.browser.common.BrowserCommonConstants;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+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.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+
+public class HexDialog extends Dialog
+{
+
+    public static final String DIALOG_TITLE = "Hex Editor";
+
+    public static final double MAX_WIDTH = 550.0;
+
+    public static final double MAX_HEIGHT = 550.0;
+
+    public static final int LOAD_BUTTON_ID = 9998;
+
+    public static final int SAVE_BUTTON_ID = 9999;
+
+    private byte[] currentData;
+
+    private byte[] returnData;
+
+    private Text hexText;
+
+
+    public HexDialog( Shell parentShell, byte[] initialData )
+    {
+        super( parentShell );
+        super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+        this.currentData = initialData;
+    }
+
+
+    public boolean close()
+    {
+        return super.close();
+    }
+
+
+    protected void buttonPressed( int buttonId )
+    {
+        if ( buttonId == IDialogConstants.OK_ID )
+        {
+            this.returnData = this.currentData;
+        }
+        else if ( buttonId == SAVE_BUTTON_ID )
+        {
+            FileDialog fileDialog = new FileDialog( getShell(), SWT.SAVE );
+            fileDialog.setText( "Save Data" );
+            // fileDialog.setFilterExtensions(new String[]{"*.jpg"});
+            String returnedFileName = fileDialog.open();
+            if ( returnedFileName != null )
+            {
+                try
+                {
+                    File file = new File( returnedFileName );
+                    FileOutputStream out = new FileOutputStream( file );
+                    out.write( currentData );
+                    out.flush();
+                    out.close();
+                }
+                catch ( FileNotFoundException e )
+                {
+                    BrowserCommonActivator.getDefault().getExceptionHandler().handleException(
+                        new Status( IStatus.ERROR, BrowserCommonActivator.PLUGIN_ID, IStatus.ERROR, "Can't write to file", e ) );
+                }
+                catch ( IOException e )
+                {
+                    BrowserCommonActivator.getDefault().getExceptionHandler().handleException(
+                        new Status( IStatus.ERROR, BrowserCommonActivator.PLUGIN_ID, IStatus.ERROR, "Can't write to file", e ) );
+                }
+            }
+        }
+        else if ( buttonId == LOAD_BUTTON_ID )
+        {
+            FileDialog fileDialog = new FileDialog( getShell(), SWT.OPEN );
+            fileDialog.setText( "Load Data" );
+            String returnedFileName = fileDialog.open();
+            if ( returnedFileName != null )
+            {
+                try
+                {
+                    File file = new File( returnedFileName );
+                    FileInputStream in = new FileInputStream( file );
+                    ByteArrayOutputStream out = new ByteArrayOutputStream( ( int ) file.length() );
+                    byte[] buf = new byte[4096];
+                    int len;
+                    while ( ( len = in.read( buf ) ) > 0 )
+                    {
+                        out.write( buf, 0, len );
+                    }
+                    this.currentData = out.toByteArray();
+                    hexText.setText( toFormattedHex( this.currentData ) );
+                    out.close();
+                    in.close();
+                }
+                catch ( FileNotFoundException e )
+                {
+                    BrowserCommonActivator.getDefault().getExceptionHandler().handleException(
+                        new Status( IStatus.ERROR, BrowserCommonActivator.PLUGIN_ID, IStatus.ERROR, "Can't read file", e ) );
+                }
+                catch ( IOException e )
+                {
+                    BrowserCommonActivator.getDefault().getExceptionHandler().handleException(
+                        new Status( IStatus.ERROR, BrowserCommonActivator.PLUGIN_ID, IStatus.ERROR, "Can't read file", e ) );
+                }
+            }
+        }
+        else
+        {
+            this.returnData = null;
+        }
+
+        super.buttonPressed( buttonId );
+    }
+
+
+    protected void configureShell( Shell shell )
+    {
+        super.configureShell( shell );
+        shell.setText( DIALOG_TITLE );
+        shell.setImage( BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_HEXEDITOR ) );
+    }
+
+
+    protected void createButtonsForButtonBar( Composite parent )
+    {
+        createButton( parent, LOAD_BUTTON_ID, "Load Data...", false );
+        createButton( parent, SAVE_BUTTON_ID, "Save Data...", false );
+        createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false );
+        createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
+    }
+
+
+    protected Control createDialogArea( Composite parent )
+    {
+        // create composite
+        Composite composite = ( Composite ) super.createDialogArea( parent );
+
+        hexText = new Text( composite, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY );
+        hexText.setFont( JFaceResources.getFont( JFaceResources.TEXT_FONT ) );
+
+        hexText.setText( toFormattedHex( this.currentData ) );
+        // GridData gd = new GridData(GridData.GRAB_HORIZONTAL |
+        // GridData.HORIZONTAL_ALIGN_FILL);
+        GridData gd = new GridData( GridData.FILL_BOTH );
+        gd.widthHint = convertHorizontalDLUsToPixels( ( int ) ( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH * 1.6 ) );
+        gd.heightHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH / 2 );
+        hexText.setLayoutData( gd );
+
+        applyDialogFont( composite );
+        return composite;
+    }
+
+
+    private String toFormattedHex( byte[] data )
+    {
+        StringBuffer sb = new StringBuffer();
+        for ( int i = 0; i < data.length; i++ )
+        {
+            int b = ( int ) data[i];
+            if ( b < 0 )
+                b = 256 + b;
+            String s = Integer.toHexString( b );
+            if ( s.length() == 1 )
+                s = "0" + s;
+            sb.append( s ).append( " " );
+            if ( ( i + 1 ) % 8 == 0 )
+                sb.append( " " );
+
+            if ( i == data.length - 1 )
+            {
+                while ( ( i + 1 ) % 16 != 0 )
+                {
+                    sb.append( "   " );
+                    if ( ( i + 1 ) % 8 == 0 )
+                        sb.append( " " );
+                    i++;
+                }
+                sb.append( " " );
+            }
+
+            if ( ( i + 1 ) % 16 == 0 )
+            {
+                sb.append( "   " );
+                for ( int x = i - 16 + 1; x <= i && x < data.length; x++ )
+                {
+                    if ( data[x] > 32 && data[x] < 127 )
+                        sb.append( ( char ) data[x] );
+                    else
+                        sb.append( '.' );
+                    if ( ( x + 1 ) % 8 == 0 )
+                        sb.append( " " );
+                }
+            }
+
+            if ( ( i + 1 ) % 16 == 0 )
+            {
+                sb.append( "\r\n" );
+            }
+        }
+        return sb.toString();
+    }
+
+
+    public byte[] getData()
+    {
+        return this.returnData;
+    }
+}

Added: directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/MoveEntriesDialog.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/MoveEntriesDialog.java?view=auto&rev=526693
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/MoveEntriesDialog.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/MoveEntriesDialog.java Mon Apr  9 02:49:48 2007
@@ -0,0 +1,148 @@
+/*
+ *  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.common.dialogs;
+
+
+import org.apache.directory.ldapstudio.browser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.ldapstudio.browser.common.widgets.DnBuilderWidget;
+import org.apache.directory.ldapstudio.browser.common.widgets.WidgetModifyEvent;
+import org.apache.directory.ldapstudio.browser.common.widgets.WidgetModifyListener;
+import org.apache.directory.ldapstudio.browser.core.model.DN;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+
+public class MoveEntriesDialog extends Dialog implements WidgetModifyListener
+{
+
+    public static final String DIALOG_TITLE = "Move Entries";
+
+    private IEntry[] entries;
+
+    private DnBuilderWidget dnBuilderWidget;
+
+    private Button simulateMoveButton;
+
+    private Button okButton;
+
+    private DN parentDn;
+
+    private boolean simulateMove;
+
+
+    public MoveEntriesDialog( Shell parentShell, IEntry[] entries )
+    {
+        super( parentShell );
+        super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+        this.entries = entries;
+        this.parentDn = null;
+    }
+
+
+    protected void configureShell( Shell shell )
+    {
+        super.configureShell( shell );
+        shell.setText( DIALOG_TITLE );
+    }
+
+
+    public boolean close()
+    {
+        this.dnBuilderWidget.removeWidgetModifyListener( this );
+        this.dnBuilderWidget.dispose();
+        return super.close();
+    }
+
+
+    protected void okPressed()
+    {
+        this.parentDn = this.dnBuilderWidget.getParentDn();
+        this.simulateMove = this.simulateMoveButton.getSelection();
+
+        this.dnBuilderWidget.saveDialogSettings();
+
+        super.okPressed();
+    }
+
+
+    protected void createButtonsForButtonBar( Composite parent )
+    {
+        okButton = createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true );
+        createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
+    }
+
+
+    protected Control createDialogArea( Composite parent )
+    {
+
+        Composite composite = ( Composite ) super.createDialogArea( parent );
+        GridData gd = new GridData( GridData.FILL_BOTH );
+        gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH ) * 3 / 2;
+        composite.setLayoutData( gd );
+
+        BaseWidgetUtils.createLabel( composite,
+            "Please enter/select the parent DN where the selected entries should be moved to.", 1 );
+
+        this.dnBuilderWidget = new DnBuilderWidget( false, true );
+        this.dnBuilderWidget.addWidgetModifyListener( this );
+        this.dnBuilderWidget.createContents( composite );
+        this.dnBuilderWidget.setInput( this.entries[0].getConnection(), null, null, this.entries[0].getDn()
+            .getParentDn() );
+
+        this.simulateMoveButton = BaseWidgetUtils.createCheckbox( composite,
+            "Simulate subtree moving by searching/adding/deleting recursively", 1 );
+        this.simulateMoveButton.setSelection( false );
+        this.simulateMoveButton.setEnabled( false );
+
+        applyDialogFont( composite );
+        return composite;
+    }
+
+
+    public void widgetModified( WidgetModifyEvent event )
+    {
+        if ( this.okButton != null )
+        {
+            this.okButton.setEnabled( this.dnBuilderWidget.getParentDn() != null );
+        }
+    }
+
+
+    public DN getParentDn()
+    {
+        return this.parentDn;
+    }
+
+
+    public boolean isSimulateMove()
+    {
+        return simulateMove;
+    }
+
+}

Added: directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/MultivaluedDialog.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/MultivaluedDialog.java?view=auto&rev=526693
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/MultivaluedDialog.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/MultivaluedDialog.java Mon Apr  9 02:49:48 2007
@@ -0,0 +1,332 @@
+/*
+ *  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.common.dialogs;
+
+
+import java.util.Iterator;
+
+import org.apache.directory.ldapstudio.browser.common.BrowserCommonActivator;
+import org.apache.directory.ldapstudio.browser.common.BrowserCommonConstants;
+import org.apache.directory.ldapstudio.browser.common.widgets.entryeditor.EntryEditorWidget;
+import org.apache.directory.ldapstudio.browser.common.widgets.entryeditor.EntryEditorWidgetActionGroup;
+import org.apache.directory.ldapstudio.browser.common.widgets.entryeditor.EntryEditorWidgetConfiguration;
+import org.apache.directory.ldapstudio.browser.common.widgets.entryeditor.EntryEditorWidgetUniversalListener;
+import org.apache.directory.ldapstudio.browser.common.widgets.entryeditor.OpenDefaultEditorAction;
+import org.apache.directory.ldapstudio.browser.core.events.AttributeDeletedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.EmptyValueAddedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.EmptyValueDeletedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.EntryModificationEvent;
+import org.apache.directory.ldapstudio.browser.core.events.EventRegistry;
+import org.apache.directory.ldapstudio.browser.core.events.ValueAddedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.ValueDeletedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.ValueModifiedEvent;
+import org.apache.directory.ldapstudio.browser.core.internal.model.Attribute;
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierarchy;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+
+public class MultivaluedDialog extends Dialog
+{
+
+    public static final String DIALOG_TITLE = "Multivalued Editor";
+
+    public static final int MAX_WIDTH = 450;
+
+    public static final int MAX_HEIGHT = 250;
+
+    private AttributeHierarchy attributeHierarchie;
+
+    private EntryEditorWidgetConfiguration configuration;
+
+    private EntryEditorWidgetActionGroup actionGroup;
+
+    private EntryEditorWidget mainWidget;
+
+    private MultiValuedEntryEditorUniversalListener universalListener;
+
+
+    public MultivaluedDialog( Shell parentShell, AttributeHierarchy attributeHierarchie )
+    {
+        super( parentShell );
+        setShellStyle( getShellStyle() | SWT.RESIZE );
+        this.attributeHierarchie = attributeHierarchie;
+    }
+
+
+    protected void configureShell( Shell shell )
+    {
+        super.configureShell( shell );
+        shell.setText( DIALOG_TITLE );
+        shell.setImage( BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_MULTIVALUEDEDITOR ) );
+    }
+
+
+    protected void createButtonsForButtonBar( Composite parent )
+    {
+        createButton( parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, false );
+
+        getShell().update();
+        getShell().layout( true, true );
+    }
+
+
+    protected void buttonPressed( int buttonId )
+    {
+        if ( IDialogConstants.CLOSE_ID == buttonId )
+        {
+            close();
+        }
+        else
+        {
+            super.buttonPressed( buttonId );
+        }
+    }
+
+
+    public int open()
+    {
+        this.dialogOpened();
+        return super.open();
+    }
+
+
+    public boolean close()
+    {
+        boolean returnValue = super.close();
+        if ( returnValue )
+        {
+            this.dispose();
+            this.dialogClosed();
+        }
+        return returnValue;
+    }
+
+
+    public void dispose()
+    {
+        if ( this.configuration != null )
+        {
+            this.universalListener.dispose();
+            this.universalListener = null;
+            this.mainWidget.dispose();
+            this.mainWidget = null;
+            this.actionGroup.deactivateGlobalActionHandlers();
+            this.actionGroup.dispose();
+            this.actionGroup = null;
+            this.configuration.dispose();
+            this.configuration = null;
+        }
+    }
+
+
+    protected Control createDialogArea( Composite parent )
+    {
+
+        Composite composite = ( Composite ) super.createDialogArea( parent );
+
+        // create configuration
+        this.configuration = new EntryEditorWidgetConfiguration();
+
+        // create main widget
+        this.mainWidget = new EntryEditorWidget( this.configuration );
+        this.mainWidget.createWidget( composite );
+        this.mainWidget.getViewer().setInput( attributeHierarchie );
+        this.mainWidget.getViewer().getTree().setFocus();
+
+        // create actions
+        this.actionGroup = new EntryEditorWidgetActionGroup( this.mainWidget, this.configuration );
+        this.actionGroup.fillToolBar( this.mainWidget.getToolBarManager() );
+        this.actionGroup.fillMenu( this.mainWidget.getMenuManager() );
+        this.actionGroup.fillContextMenu( this.mainWidget.getContextMenuManager() );
+        this.actionGroup.activateGlobalActionHandlers();
+
+        // create the listener
+        this.universalListener = new MultiValuedEntryEditorUniversalListener( this.mainWidget.getViewer(),
+            this.actionGroup.getOpenDefaultEditorAction() );
+
+        // start edit mode if an empty value exists
+        for ( Iterator it = attributeHierarchie.iterator(); it.hasNext(); )
+        {
+            IAttribute attribute = ( IAttribute ) it.next();
+            IValue[] values = attribute.getValues();
+            for ( int i = 0; i < values.length; i++ )
+            {
+                IValue value = values[i];
+                if ( value.isEmpty() )
+                {
+                    this.mainWidget.getViewer().setSelection( new StructuredSelection( value ), true );
+                    if ( this.actionGroup.getOpenDefaultEditorAction().isEnabled() )
+                    {
+                        this.actionGroup.getOpenDefaultEditorAction().run();
+                        break;
+                    }
+                }
+            }
+        }
+
+        applyDialogFont( composite );
+        return composite;
+    }
+
+
+    private void dialogOpened()
+    {
+        if ( this.attributeHierarchie.getAttribute().getValueSize() == 0 )
+        {
+            this.attributeHierarchie.getAttribute().addEmptyValue();
+        }
+    }
+
+
+    private void dialogClosed()
+    {
+
+        for ( Iterator it = attributeHierarchie.iterator(); it.hasNext(); )
+        {
+            IAttribute attribute = ( IAttribute ) it.next();
+            if ( attribute != null )
+            {
+
+                // remove empty values
+                IValue[] values = attribute.getValues();
+                for ( int i = 0; i < values.length; i++ )
+                {
+                    if ( values[i].isEmpty() )
+                    {
+                        attribute.deleteEmptyValue();
+                    }
+                }
+
+                // are all values deleted?
+                if ( attribute.getValueSize() == 0 )
+                {
+                    try
+                    {
+                        attribute.getEntry().deleteAttribute( attribute );
+                    }
+                    catch ( ModelModificationException e )
+                    {
+                    }
+                    // new DeleteAttributeValueCommand(attribute).execute();
+                }
+            }
+        }
+
+    }
+
+    class MultiValuedEntryEditorUniversalListener extends EntryEditorWidgetUniversalListener
+    {
+
+        public MultiValuedEntryEditorUniversalListener( TreeViewer treeViewer, OpenDefaultEditorAction startEditAction )
+        {
+            super( treeViewer, startEditAction );
+        }
+
+
+        public void entryUpdated( EntryModificationEvent event )
+        {
+
+            if ( this.viewer == null || this.viewer.getTree() == null || this.viewer.getTree().isDisposed() )
+            {
+                return;
+            }
+
+            if ( this.viewer.isCellEditorActive() )
+                this.viewer.cancelEditing();
+
+            // set new input because attributes are newly created after a
+            // modification
+            IEntry entry = attributeHierarchie.getEntry();
+            String attributeDescription = attributeHierarchie.getAttributeDescription();
+            attributeHierarchie = entry.getAttributeWithSubtypes( attributeDescription );
+            if ( attributeHierarchie == null )
+            {
+                EventRegistry.suspendEventFireingInCurrentThread();
+                try
+                {
+                    IAttribute attribute = new Attribute( entry, attributeDescription );
+                    entry.addAttribute( attribute );
+                    attribute.addEmptyValue();
+                }
+                catch ( ModelModificationException e )
+                {
+                }
+                EventRegistry.resumeEventFireingInCurrentThread();
+                attributeHierarchie = entry.getAttributeWithSubtypes( attributeDescription );
+            }
+            this.viewer.setInput( attributeHierarchie );
+            this.viewer.refresh();
+
+            // select added/modified value
+            if ( event instanceof ValueAddedEvent )
+            {
+                ValueAddedEvent vaEvent = ( ValueAddedEvent ) event;
+                this.viewer.setSelection( new StructuredSelection( vaEvent.getAddedValue() ), true );
+                this.viewer.refresh();
+            }
+            else if ( event instanceof ValueModifiedEvent )
+            {
+                ValueModifiedEvent vmEvent = ( ValueModifiedEvent ) event;
+                this.viewer.setSelection( new StructuredSelection( vmEvent.getNewValue() ), true );
+            }
+            else if ( event instanceof ValueDeletedEvent )
+            {
+                ValueDeletedEvent vdEvent = ( ValueDeletedEvent ) event;
+                if ( vdEvent.getDeletedValue().getAttribute().getValueSize() > 0 )
+                {
+                    this.viewer.setSelection( new StructuredSelection( vdEvent.getDeletedValue().getAttribute()
+                        .getValues()[0] ), true );
+                }
+            }
+            else if ( event instanceof EmptyValueAddedEvent )
+            {
+                viewer.refresh();
+                EmptyValueAddedEvent evaEvent = ( EmptyValueAddedEvent ) event;
+                viewer.setSelection( new StructuredSelection( evaEvent.getAddedValue() ), true );
+                if ( startEditAction.isEnabled() )
+                    startEditAction.run();
+            }
+            else if ( event instanceof EmptyValueDeletedEvent )
+            {
+                EmptyValueDeletedEvent evdEvent = ( EmptyValueDeletedEvent ) event;
+                if ( viewer.getSelection().isEmpty() && evdEvent.getDeletedValue().getAttribute().getValueSize() > 0 )
+                    viewer.setSelection( new StructuredSelection(
+                        evdEvent.getDeletedValue().getAttribute().getValues()[0] ), true );
+            }
+            else if ( event instanceof AttributeDeletedEvent )
+            {
+
+            }
+        }
+    }
+
+}

Added: directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/RenameEntryDialog.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/RenameEntryDialog.java?view=auto&rev=526693
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/RenameEntryDialog.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/RenameEntryDialog.java Mon Apr  9 02:49:48 2007
@@ -0,0 +1,168 @@
+/*
+ *  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.common.dialogs;
+
+
+import org.apache.directory.ldapstudio.browser.common.BrowserCommonActivator;
+import org.apache.directory.ldapstudio.browser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.ldapstudio.browser.common.widgets.DnBuilderWidget;
+import org.apache.directory.ldapstudio.browser.common.widgets.WidgetModifyEvent;
+import org.apache.directory.ldapstudio.browser.common.widgets.WidgetModifyListener;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.RDN;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+
+public class RenameEntryDialog extends Dialog implements WidgetModifyListener
+{
+
+    public static final String DELETE_OLD_RDN_DIALOGSETTING_KEY = RenameEntryDialog.class.getName() + ".deleteOldRdn";
+
+    public static final String DIALOG_TITLE = "Rename Entry";
+
+    private IEntry entry;
+
+    private DnBuilderWidget dnBuilderWidget;
+
+    private Button deleteOldRdnButton;
+
+    private Button simulateRenameButton;
+
+    private Button okButton;
+
+    private RDN rdn;
+
+    private boolean deleteOldRdn;
+
+    private boolean simulateRename;
+
+
+    public RenameEntryDialog( Shell parentShell, IEntry entry )
+    {
+        super( parentShell );
+        super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+        this.entry = entry;
+        this.rdn = null;
+
+        if ( BrowserCommonActivator.getDefault().getDialogSettings().get( DELETE_OLD_RDN_DIALOGSETTING_KEY ) == null )
+            BrowserCommonActivator.getDefault().getDialogSettings().put( DELETE_OLD_RDN_DIALOGSETTING_KEY, true );
+        this.deleteOldRdn = BrowserCommonActivator.getDefault().getDialogSettings().getBoolean( DELETE_OLD_RDN_DIALOGSETTING_KEY );
+    }
+
+
+    protected void configureShell( Shell shell )
+    {
+        super.configureShell( shell );
+        shell.setText( DIALOG_TITLE );
+    }
+
+
+    public boolean close()
+    {
+        this.dnBuilderWidget.removeWidgetModifyListener( this );
+        this.dnBuilderWidget.dispose();
+        return super.close();
+    }
+
+
+    protected void okPressed()
+    {
+        this.rdn = this.dnBuilderWidget.getRdn();
+        this.deleteOldRdn = this.deleteOldRdnButton.getSelection();
+        this.simulateRename = this.simulateRenameButton.getSelection();
+
+        BrowserCommonActivator.getDefault().getDialogSettings().put( DELETE_OLD_RDN_DIALOGSETTING_KEY, this.deleteOldRdn );
+        this.dnBuilderWidget.saveDialogSettings();
+
+        super.okPressed();
+    }
+
+
+    protected void createButtonsForButtonBar( Composite parent )
+    {
+        okButton = createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true );
+        createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
+    }
+
+
+    protected Control createDialogArea( Composite parent )
+    {
+
+        Composite composite = ( Composite ) super.createDialogArea( parent );
+        GridData gd = new GridData( GridData.FILL_BOTH );
+        gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH ) * 3 / 2;
+        composite.setLayoutData( gd );
+
+        BaseWidgetUtils.createLabel( composite, "Please enter the new RDN of the selected entry.", 1 );
+
+        this.dnBuilderWidget = new DnBuilderWidget( true, false );
+        this.dnBuilderWidget.addWidgetModifyListener( this );
+        this.dnBuilderWidget.createContents( composite );
+        this.dnBuilderWidget.setInput( this.entry.getConnection(), this.entry.getSubschema().getAllAttributeNames(),
+            this.entry.getRdn(), null );
+
+        this.deleteOldRdnButton = BaseWidgetUtils.createCheckbox( composite, "Delete old RDN", 1 );
+        this.deleteOldRdnButton.setSelection( this.deleteOldRdn );
+
+        this.simulateRenameButton = BaseWidgetUtils.createCheckbox( composite,
+            "Simulate subtree renaming by searching/adding/deleting recursively", 1 );
+        this.simulateRenameButton.setSelection( false );
+        this.simulateRenameButton.setEnabled( false );
+
+        applyDialogFont( composite );
+        return composite;
+    }
+
+
+    public void widgetModified( WidgetModifyEvent event )
+    {
+        if ( this.okButton != null )
+        {
+            this.okButton.setEnabled( this.dnBuilderWidget.getRdn() != null );
+        }
+    }
+
+
+    public RDN getRdn()
+    {
+        return this.rdn;
+    }
+
+
+    public boolean isDeleteOldRdn()
+    {
+        return this.deleteOldRdn;
+    }
+
+
+    public boolean isSimulateRename()
+    {
+        return simulateRename;
+    }
+
+}

Added: directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/ScopeDialog.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/ScopeDialog.java?view=auto&rev=526693
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/ScopeDialog.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/ScopeDialog.java Mon Apr  9 02:49:48 2007
@@ -0,0 +1,120 @@
+/*
+ *  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.common.dialogs;
+
+
+import org.apache.directory.ldapstudio.browser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.ldapstudio.browser.core.model.ISearch;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Shell;
+
+
+public class ScopeDialog extends Dialog
+{
+
+    private String dialogTitle;
+
+    private boolean multi;
+
+    private int scope = -1;
+
+    private Button objectScopeButton;
+
+    private Button onelevelScopeButton;
+
+    private Button subtreeScopeButton;
+
+
+    public ScopeDialog( Shell parentShell, String dialogTitle, boolean multi )
+    {
+        super( parentShell );
+        super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+        this.dialogTitle = dialogTitle;
+        this.multi = multi;
+    }
+
+
+    protected void configureShell( Shell shell )
+    {
+        super.configureShell( shell );
+        shell.setText( dialogTitle );
+    }
+
+
+    public boolean close()
+    {
+        return super.close();
+    }
+
+
+    protected void okPressed()
+    {
+        this.scope = this.objectScopeButton.getSelection() ? ISearch.SCOPE_OBJECT : this.onelevelScopeButton
+            .getSelection() ? ISearch.SCOPE_ONELEVEL : ISearch.SCOPE_SUBTREE;
+        super.okPressed();
+    }
+
+
+    protected void createButtonsForButtonBar( Composite parent )
+    {
+        createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false );
+        createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
+    }
+
+
+    protected Control createDialogArea( Composite parent )
+    {
+
+        Composite composite = ( Composite ) super.createDialogArea( parent );
+        GridData gd = new GridData( GridData.FILL_BOTH );
+        composite.setLayoutData( gd );
+
+        Group group = BaseWidgetUtils.createGroup( composite, "Please select the copy depth", 1 );
+        this.objectScopeButton = new Button( group, SWT.RADIO );
+        this.objectScopeButton.setSelection( true );
+        this.objectScopeButton.setText( this.multi ? "&Object (Only the copied entries)"
+            : "&Object (Only the copied entry)" );
+        this.onelevelScopeButton = new Button( group, SWT.RADIO );
+        this.onelevelScopeButton.setText( this.multi ? "O&ne Level (The copied entries and their direct children)"
+            : "O&ne Level (The copied entry and its direct children)" );
+        this.subtreeScopeButton = new Button( group, SWT.RADIO );
+        this.subtreeScopeButton.setText( this.multi ? "&Subtree (The whole subtrees)" : "&Subtree (The whole subtree)" );
+
+        applyDialogFont( composite );
+        return composite;
+
+    }
+
+
+    public int getScope()
+    {
+        return this.scope;
+    }
+
+}

Added: directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/SelectConnectionDialog.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/SelectConnectionDialog.java?view=auto&rev=526693
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/SelectConnectionDialog.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/SelectConnectionDialog.java Mon Apr  9 02:49:48 2007
@@ -0,0 +1,202 @@
+/*
+ *  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.common.dialogs;
+
+
+import org.apache.directory.ldapstudio.browser.common.widgets.connection.ConnectionActionGroup;
+import org.apache.directory.ldapstudio.browser.common.widgets.connection.ConnectionConfiguration;
+import org.apache.directory.ldapstudio.browser.common.widgets.connection.ConnectionUniversalListener;
+import org.apache.directory.ldapstudio.browser.common.widgets.connection.ConnectionWidget;
+import org.apache.directory.ldapstudio.browser.core.BrowserCorePlugin;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+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.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+
+public class SelectConnectionDialog extends Dialog
+{
+
+    private String title;
+
+    private IConnection initialConnection;
+
+    private IConnection selectedConnection;
+
+    private ConnectionConfiguration configuration;
+
+    private ConnectionUniversalListener universalListener;
+
+    private ConnectionActionGroup actionGroup;
+
+    private ConnectionWidget mainWidget;
+
+
+    public SelectConnectionDialog( Shell parentShell, String title, IConnection initialConnection )
+    {
+        super( parentShell );
+        super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+        this.title = title;
+        this.initialConnection = initialConnection;
+        this.selectedConnection = null;
+    }
+
+
+    protected void configureShell( Shell shell )
+    {
+        super.configureShell( shell );
+        shell.setText( title );
+    }
+
+
+    public boolean close()
+    {
+        if ( this.mainWidget != null )
+        {
+            this.configuration.dispose();
+            this.configuration = null;
+            this.actionGroup.deactivateGlobalActionHandlers();
+            this.actionGroup.dispose();
+            this.actionGroup = null;
+            this.universalListener.dispose();
+            this.universalListener = null;
+            this.mainWidget.dispose();
+            this.mainWidget = null;
+        }
+        return super.close();
+    }
+
+
+    protected void okPressed()
+    {
+        this.selectedConnection = initialConnection;
+        super.okPressed();
+    }
+
+
+    protected void cancelPressed()
+    {
+        this.selectedConnection = null;
+        super.cancelPressed();
+    }
+
+
+    protected void createButtonsForButtonBar( Composite parent )
+    {
+        createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false );
+        createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
+    }
+
+
+    protected Control createDialogArea( Composite parent )
+    {
+
+        Composite composite = ( Composite ) super.createDialogArea( parent );
+        GridLayout gl = new GridLayout();
+        composite.setLayout( gl );
+        GridData gd = new GridData( GridData.FILL_BOTH );
+        gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH );
+        gd.heightHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH / 2 );
+        composite.setLayoutData( gd );
+
+        // create configuration
+        this.configuration = new ConnectionConfiguration();
+
+        // create main widget
+        this.mainWidget = new ConnectionWidget( this.configuration, null );
+        this.mainWidget.createWidget( composite );
+        this.mainWidget.setInput( BrowserCorePlugin.getDefault().getConnectionManager() );
+
+        // create actions and context menu (and register global actions)
+        this.actionGroup = new ConnectionActionGroup( this.mainWidget, this.configuration );
+        this.actionGroup.fillToolBar( this.mainWidget.getToolBarManager() );
+        this.actionGroup.fillMenu( this.mainWidget.getMenuManager() );
+        this.actionGroup.fillContextMenu( this.mainWidget.getContextMenuManager() );
+        this.actionGroup.activateGlobalActionHandlers();
+
+        // create the listener
+        this.universalListener = new ConnectionUniversalListener( this.mainWidget.getViewer() );
+
+        this.mainWidget.getViewer().addSelectionChangedListener( new ISelectionChangedListener()
+        {
+            public void selectionChanged( SelectionChangedEvent event )
+            {
+                if ( !event.getSelection().isEmpty() )
+                {
+                    Object o = ( ( IStructuredSelection ) event.getSelection() ).getFirstElement();
+                    if ( o instanceof IConnection )
+                    {
+                        initialConnection = ( IConnection ) o;
+                    }
+                }
+            }
+        } );
+
+        this.mainWidget.getViewer().addDoubleClickListener( new IDoubleClickListener()
+        {
+            public void doubleClick( DoubleClickEvent event )
+            {
+                if ( !event.getSelection().isEmpty() )
+                {
+                    Object o = ( ( IStructuredSelection ) event.getSelection() ).getFirstElement();
+                    if ( o instanceof IConnection )
+                    {
+                        initialConnection = ( IConnection ) o;
+                        okPressed();
+                    }
+                }
+            }
+        } );
+
+        if ( this.initialConnection != null )
+        {
+            IConnection connection = this.initialConnection;
+            this.mainWidget.getViewer().reveal( connection );
+            this.mainWidget.getViewer().setSelection( new StructuredSelection( connection ), true );
+        }
+
+        applyDialogFont( composite );
+
+        this.mainWidget.setFocus();
+
+        return composite;
+
+    }
+
+
+    public IConnection getSelectedConnection()
+    {
+        return this.selectedConnection;
+    }
+
+}

Added: directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/SelectEntryDialog.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/SelectEntryDialog.java?view=auto&rev=526693
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/SelectEntryDialog.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/SelectEntryDialog.java Mon Apr  9 02:49:48 2007
@@ -0,0 +1,199 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.common.dialogs;
+
+
+import org.apache.directory.ldapstudio.browser.common.widgets.browser.BrowserActionGroup;
+import org.apache.directory.ldapstudio.browser.common.widgets.browser.BrowserConfiguration;
+import org.apache.directory.ldapstudio.browser.common.widgets.browser.BrowserUniversalListener;
+import org.apache.directory.ldapstudio.browser.common.widgets.browser.BrowserWidget;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+
+public class SelectEntryDialog extends Dialog
+{
+
+    private String title;
+
+    private Image image;
+
+    private IConnection connection;
+
+    private IEntry initialEntry;
+
+    private IEntry selectedEntry;
+
+    private BrowserConfiguration configuration;
+
+    private BrowserUniversalListener universalListener;
+
+    private BrowserActionGroup actionGroup;
+
+    private BrowserWidget mainWidget;
+
+
+    public SelectEntryDialog( Shell parentShell, String title, IConnection connection, IEntry initialEntry )
+    {
+        super( parentShell );
+        super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+        this.title = title;
+        this.connection = connection;
+        this.initialEntry = initialEntry;
+        this.selectedEntry = null;
+    }
+
+
+    public SelectEntryDialog( Shell parentShell, String title, Image image, IConnection connection, IEntry initialEntry )
+    {
+        this( parentShell, title, connection, initialEntry );
+        this.image = image;
+    }
+
+
+    protected void configureShell( Shell shell )
+    {
+        super.configureShell( shell );
+        shell.setText( title );
+        shell.setImage( image );
+    }
+
+
+    public boolean close()
+    {
+        if ( this.mainWidget != null )
+        {
+            this.configuration.dispose();
+            this.configuration = null;
+            this.actionGroup.deactivateGlobalActionHandlers();
+            this.actionGroup.dispose();
+            this.actionGroup = null;
+            this.universalListener.dispose();
+            this.universalListener = null;
+            this.mainWidget.dispose();
+            this.mainWidget = null;
+        }
+        return super.close();
+    }
+
+
+    protected void okPressed()
+    {
+        this.selectedEntry = initialEntry;
+        super.okPressed();
+    }
+
+
+    protected void cancelPressed()
+    {
+        this.selectedEntry = null;
+        super.cancelPressed();
+    }
+
+
+    protected void createButtonsForButtonBar( Composite parent )
+    {
+        createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false );
+        createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
+    }
+
+
+    protected Control createDialogArea( Composite parent )
+    {
+
+        Composite composite = ( Composite ) super.createDialogArea( parent );
+        GridData gd = new GridData( GridData.FILL_BOTH );
+        gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH );
+        gd.heightHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH );
+        composite.setLayoutData( gd );
+
+        // create configuration
+        this.configuration = new BrowserConfiguration();
+
+        // create main widget
+        this.mainWidget = new BrowserWidget( this.configuration, null );
+        this.mainWidget.createWidget( composite );
+        this.mainWidget.setInput( new IEntry[]
+            { this.connection.getRootDSE() } );
+
+        // create actions and context menu (and register global actions)
+        this.actionGroup = new BrowserActionGroup( this.mainWidget, this.configuration );
+        this.actionGroup.fillToolBar( this.mainWidget.getToolBarManager() );
+        this.actionGroup.fillMenu( this.mainWidget.getMenuManager() );
+        this.actionGroup.fillContextMenu( this.mainWidget.getContextMenuManager() );
+        this.actionGroup.activateGlobalActionHandlers();
+
+        // create the listener
+        this.universalListener = new BrowserUniversalListener( this.mainWidget.getViewer() );
+
+        this.mainWidget.getViewer().addSelectionChangedListener( new ISelectionChangedListener()
+        {
+            public void selectionChanged( SelectionChangedEvent event )
+            {
+                if ( !event.getSelection().isEmpty() )
+                {
+                    Object o = ( ( IStructuredSelection ) event.getSelection() ).getFirstElement();
+                    if ( o instanceof IEntry )
+                    {
+                        initialEntry = ( IEntry ) o;
+                    }
+                }
+            }
+        } );
+
+        this.mainWidget.getViewer().expandToLevel( 2 );
+        if ( this.initialEntry != null )
+        {
+            IEntry entry = this.initialEntry;
+            this.mainWidget.getViewer().reveal( entry );
+            this.mainWidget.getViewer().refresh( entry, true );
+            this.mainWidget.getViewer().setSelection( new StructuredSelection( entry ), true );
+            this.mainWidget.getViewer().setSelection( new StructuredSelection( entry ), true );
+        }
+
+        applyDialogFont( composite );
+
+        this.mainWidget.setFocus();
+
+        return composite;
+
+    }
+
+
+    public IEntry getSelectedEntry()
+    {
+        return this.selectedEntry;
+    }
+
+}

Added: directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/SelectReferralConnectionDialog.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/SelectReferralConnectionDialog.java?view=auto&rev=526693
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/SelectReferralConnectionDialog.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/SelectReferralConnectionDialog.java Mon Apr  9 02:49:48 2007
@@ -0,0 +1,214 @@
+/*
+ *  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.common.dialogs;
+
+
+import org.apache.directory.ldapstudio.browser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.ldapstudio.browser.common.widgets.connection.ConnectionActionGroup;
+import org.apache.directory.ldapstudio.browser.common.widgets.connection.ConnectionConfiguration;
+import org.apache.directory.ldapstudio.browser.common.widgets.connection.ConnectionUniversalListener;
+import org.apache.directory.ldapstudio.browser.common.widgets.connection.ConnectionWidget;
+import org.apache.directory.ldapstudio.browser.core.BrowserCorePlugin;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.URL;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+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.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+
+public class SelectReferralConnectionDialog extends Dialog
+{
+
+    private String title;
+
+    private URL referralUrl;
+
+    private IConnection selectedConnection;
+
+    private ConnectionConfiguration configuration;
+
+    private ConnectionUniversalListener universalListener;
+
+    private ConnectionActionGroup actionGroup;
+
+    private ConnectionWidget mainWidget;
+
+
+    public SelectReferralConnectionDialog( Shell parentShell, URL referralUrl )
+    {
+        super( parentShell );
+        super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+        this.title = "Select Referral Connection";
+        this.referralUrl = referralUrl;
+        this.selectedConnection = null;
+    }
+
+
+    protected void configureShell( Shell shell )
+    {
+        super.configureShell( shell );
+        shell.setText( title );
+    }
+
+
+    public boolean close()
+    {
+        if ( this.mainWidget != null )
+        {
+            this.configuration.dispose();
+            this.configuration = null;
+            this.actionGroup.deactivateGlobalActionHandlers();
+            this.actionGroup.dispose();
+            this.actionGroup = null;
+            this.universalListener.dispose();
+            this.universalListener = null;
+            this.mainWidget.dispose();
+            this.mainWidget = null;
+        }
+        return super.close();
+    }
+
+
+    protected void okPressed()
+    {
+        super.okPressed();
+    }
+
+
+    protected void cancelPressed()
+    {
+        this.selectedConnection = null;
+        super.cancelPressed();
+    }
+
+
+    protected void createButtonsForButtonBar( Composite parent )
+    {
+        createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false );
+        createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
+    }
+
+
+    protected Control createDialogArea( Composite parent )
+    {
+
+        Composite composite = ( Composite ) super.createDialogArea( parent );
+        GridLayout gl = new GridLayout();
+        composite.setLayout( gl );
+        GridData gd = new GridData( GridData.FILL_BOTH );
+        gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH );
+        gd.heightHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH / 2 );
+        composite.setLayoutData( gd );
+
+        BaseWidgetUtils.createWrappedLabeledText( composite, "Please select a connection to handle referral "
+            + referralUrl, 1 );
+
+        // create configuration
+        this.configuration = new ConnectionConfiguration();
+
+        // create main widget
+        this.mainWidget = new ConnectionWidget( this.configuration, null );
+        this.mainWidget.createWidget( composite );
+        this.mainWidget.setInput( BrowserCorePlugin.getDefault().getConnectionManager() );
+
+        // create actions and context menu (and register global actions)
+        this.actionGroup = new ConnectionActionGroup( this.mainWidget, this.configuration );
+        this.actionGroup.fillToolBar( this.mainWidget.getToolBarManager() );
+        this.actionGroup.fillMenu( this.mainWidget.getMenuManager() );
+        this.actionGroup.fillContextMenu( this.mainWidget.getContextMenuManager() );
+        this.actionGroup.activateGlobalActionHandlers();
+
+        // create the listener
+        this.universalListener = new ConnectionUniversalListener( this.mainWidget.getViewer() );
+
+        this.mainWidget.getViewer().addSelectionChangedListener( new ISelectionChangedListener()
+        {
+            public void selectionChanged( SelectionChangedEvent event )
+            {
+                if ( !event.getSelection().isEmpty() )
+                {
+                    Object o = ( ( IStructuredSelection ) event.getSelection() ).getFirstElement();
+                    if ( o instanceof IConnection )
+                    {
+                        selectedConnection = ( IConnection ) o;
+                    }
+                }
+            }
+        } );
+
+        this.mainWidget.getViewer().addDoubleClickListener( new IDoubleClickListener()
+        {
+            public void doubleClick( DoubleClickEvent event )
+            {
+                if ( !event.getSelection().isEmpty() )
+                {
+                    Object o = ( ( IStructuredSelection ) event.getSelection() ).getFirstElement();
+                    if ( o instanceof IConnection )
+                    {
+                        selectedConnection = ( IConnection ) o;
+                        okPressed();
+                    }
+                }
+            }
+        } );
+
+        if ( this.referralUrl != null )
+        {
+            IConnection[] connections = BrowserCorePlugin.getDefault().getConnectionManager().getConnections();
+            for ( int i = 0; i < connections.length; i++ )
+            {
+                IConnection connection = connections[i];
+                URL connectionUrl = connection.getUrl();
+                if ( connectionUrl != null && referralUrl.toString().startsWith( connectionUrl.toString() ) )
+                {
+                    this.mainWidget.getViewer().reveal( connection );
+                    this.mainWidget.getViewer().setSelection( new StructuredSelection( connection ), true );
+                }
+            }
+        }
+
+        applyDialogFont( composite );
+
+        this.mainWidget.setFocus();
+
+        return composite;
+
+    }
+
+
+    public IConnection getReferralConnection()
+    {
+        return this.selectedConnection;
+    }
+
+}

Added: directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/TextDialog.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/TextDialog.java?view=auto&rev=526693
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/TextDialog.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/TextDialog.java Mon Apr  9 02:49:48 2007
@@ -0,0 +1,115 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.common.dialogs;
+
+
+import org.apache.directory.ldapstudio.browser.common.BrowserCommonActivator;
+import org.apache.directory.ldapstudio.browser.common.BrowserCommonConstants;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+
+public class TextDialog extends Dialog
+{
+
+    public static final String DIALOG_TITLE = "Text Editor";
+
+    public static final double MAX_WIDTH = 250.0;
+
+    public static final double MAX_HEIGHT = 250.0;
+
+    private String initialValue;
+
+    private String returnValue;
+
+    private Text text;
+
+
+    public TextDialog( Shell parentShell, String initialValue )
+    {
+        super( parentShell );
+        super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+        this.initialValue = initialValue;
+        this.returnValue = null;
+    }
+
+
+    public boolean close()
+    {
+        return super.close();
+    }
+
+
+    protected void configureShell( Shell shell )
+    {
+        super.configureShell( shell );
+        shell.setText( DIALOG_TITLE );
+        shell.setImage( BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_TEXTEDITOR ) );
+    }
+
+
+    protected void createButtonsForButtonBar( Composite parent )
+    {
+        createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false );
+        createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
+    }
+
+
+    protected void okPressed()
+    {
+        this.returnValue = this.text.getText();
+        super.okPressed();
+    }
+
+
+    protected Control createDialogArea( Composite parent )
+    {
+        // create composite
+        Composite composite = ( Composite ) super.createDialogArea( parent );
+        GridData gd = new GridData( GridData.FILL_BOTH );
+        composite.setLayoutData( gd );
+
+        // text widget
+        text = new Text( composite, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL );
+        text.setText( this.initialValue );
+        // GridData gd = new GridData(GridData.GRAB_HORIZONTAL |
+        // GridData.HORIZONTAL_ALIGN_FILL);
+        gd = new GridData( GridData.FILL_BOTH );
+        gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH );
+        gd.heightHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH / 2 );
+        text.setLayoutData( gd );
+
+        applyDialogFont( composite );
+        return composite;
+    }
+
+
+    public String getText()
+    {
+        return this.returnValue;
+    }
+}

Added: directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/preferences/AttributeDialog.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/preferences/AttributeDialog.java?view=auto&rev=526693
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/preferences/AttributeDialog.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/preferences/AttributeDialog.java Mon Apr  9 02:49:48 2007
@@ -0,0 +1,108 @@
+/*
+ *  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.common.dialogs.preferences;
+
+
+import org.apache.directory.ldapstudio.browser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.ldapstudio.browser.core.model.schema.BinaryAttribute;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+
+public class AttributeDialog extends Dialog
+{
+
+    private BinaryAttribute currentAttribute;
+
+    private String[] attributeTypesAndOids;
+
+    private BinaryAttribute returnAttribute;
+
+    private Combo typeOrOidCombo;
+
+
+    public AttributeDialog( Shell parentShell, BinaryAttribute currentAttribute, String[] attributeNamesAndOids )
+    {
+        super( parentShell );
+        this.currentAttribute = currentAttribute;
+        this.attributeTypesAndOids = attributeNamesAndOids;
+
+        this.returnAttribute = null;
+    }
+
+
+    protected void configureShell( Shell newShell )
+    {
+        super.configureShell( newShell );
+        newShell.setText( "Select Attribute Type or OID" );
+    }
+
+
+    protected void okPressed()
+    {
+        this.returnAttribute = new BinaryAttribute( typeOrOidCombo.getText() );
+        super.okPressed();
+    }
+
+
+    protected Control createDialogArea( Composite parent )
+    {
+
+        Composite composite = ( Composite ) super.createDialogArea( parent );
+
+        Composite c = BaseWidgetUtils.createColumnContainer( composite, 2, 1 );
+        BaseWidgetUtils.createLabel( c, "Attribute Type or OID:", 1 );
+        this.typeOrOidCombo = BaseWidgetUtils.createCombo( c, this.attributeTypesAndOids, -1, 1 );
+        if ( this.currentAttribute != null )
+        {
+            this.typeOrOidCombo.setText( currentAttribute.getAttributeNumericOidOrName() );
+        }
+        this.typeOrOidCombo.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                validate();
+            }
+        } );
+
+        return composite;
+    }
+
+
+    private void validate()
+    {
+        super.getButton( IDialogConstants.OK_ID ).setEnabled( !"".equals( this.typeOrOidCombo.getText() ) );
+    }
+
+
+    public BinaryAttribute getAttribute()
+    {
+        return returnAttribute;
+    }
+
+}

Added: directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/preferences/AttributeValueEditorDialog.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/preferences/AttributeValueEditorDialog.java?view=auto&rev=526693
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/preferences/AttributeValueEditorDialog.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/preferences/AttributeValueEditorDialog.java Mon Apr  9 02:49:48 2007
@@ -0,0 +1,146 @@
+/*
+ *  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.common.dialogs.preferences;
+
+
+import java.util.Iterator;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import org.apache.directory.ldapstudio.browser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.ldapstudio.browser.core.model.schema.AttributeValueProviderRelation;
+import org.apache.directory.ldapstudio.valueeditors.ValueEditorManager.ValueEditorExtension;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+
+public class AttributeValueEditorDialog extends Dialog
+{
+
+    private AttributeValueProviderRelation relation;
+
+    private SortedMap<String, ValueEditorExtension> class2ValueEditorProxyMap;
+
+    private String[] attributeTypesAndOids;
+
+    private SortedMap<String, String> vpName2classMap;
+
+    private AttributeValueProviderRelation returnRelation;
+
+    private Combo typeOrOidCombo;
+
+    private Combo valueEditorCombo;
+
+
+    public AttributeValueEditorDialog( Shell parentShell, AttributeValueProviderRelation relation,
+        SortedMap<String, ValueEditorExtension> class2ValueEditorProxyMap, String[] attributeTypesAndOids )
+    {
+        super( parentShell );
+        this.relation = relation;
+        this.class2ValueEditorProxyMap = class2ValueEditorProxyMap;
+        this.attributeTypesAndOids = attributeTypesAndOids;
+
+        this.returnRelation = null;
+
+        this.vpName2classMap = new TreeMap<String, String>();
+        for ( Iterator<ValueEditorExtension> it = this.class2ValueEditorProxyMap.values().iterator(); it.hasNext(); )
+        {
+            ValueEditorExtension vp = it.next();
+            vpName2classMap.put( vp.name, vp.className );
+        }
+    }
+
+
+    protected void configureShell( Shell newShell )
+    {
+        super.configureShell( newShell );
+        newShell.setText( "Attribute Value Editor" );
+    }
+
+
+    protected void okPressed()
+    {
+        this.returnRelation = new AttributeValueProviderRelation( this.typeOrOidCombo.getText(), this.vpName2classMap
+            .get( this.valueEditorCombo.getText() ) );
+        super.okPressed();
+    }
+
+
+    protected Control createDialogArea( Composite parent )
+    {
+
+        Composite composite = ( Composite ) super.createDialogArea( parent );
+
+        Composite c = BaseWidgetUtils.createColumnContainer( composite, 2, 1 );
+        BaseWidgetUtils.createLabel( c, "Attribute Type or OID:", 1 );
+        this.typeOrOidCombo = BaseWidgetUtils.createCombo( c, this.attributeTypesAndOids, -1, 1 );
+        if ( this.relation != null && this.relation.getAttributeNumericOidOrType() != null )
+        {
+            this.typeOrOidCombo.setText( this.relation.getAttributeNumericOidOrType() );
+        }
+        this.typeOrOidCombo.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                validate();
+            }
+        } );
+
+        BaseWidgetUtils.createLabel( c, "Value Editor:", 1 );
+        this.valueEditorCombo = BaseWidgetUtils.createReadonlyCombo( c, vpName2classMap.keySet()
+            .toArray( new String[0] ), -1, 1 );
+        if ( this.relation != null && this.relation.getValueProviderClassname() != null
+            && this.class2ValueEditorProxyMap.containsKey( this.relation.getValueProviderClassname() ) )
+        {
+            this.valueEditorCombo.setText( ( this.class2ValueEditorProxyMap.get( this.relation
+                .getValueProviderClassname() ) ).name );
+        }
+        this.valueEditorCombo.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                validate();
+            }
+        } );
+
+        return composite;
+    }
+
+
+    private void validate()
+    {
+        super.getButton( IDialogConstants.OK_ID ).setEnabled(
+            !"".equals( this.valueEditorCombo.getText() ) && !"".equals( this.typeOrOidCombo.getText() ) );
+    }
+
+
+    public AttributeValueProviderRelation getRelation()
+    {
+        return returnRelation;
+    }
+
+}

Added: directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/preferences/AttributesPreferencePage.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/preferences/AttributesPreferencePage.java?view=auto&rev=526693
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/preferences/AttributesPreferencePage.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/preferences/AttributesPreferencePage.java Mon Apr  9 02:49:48 2007
@@ -0,0 +1,217 @@
+/*
+ *  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.common.dialogs.preferences;
+
+
+import org.apache.directory.ldapstudio.browser.common.BrowserCommonActivator;
+import org.apache.directory.ldapstudio.browser.common.BrowserCommonConstants;
+import org.apache.directory.ldapstudio.browser.common.widgets.BaseWidgetUtils;
+import org.eclipse.jface.preference.ColorSelector;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.RGB;
+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.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+
+public class AttributesPreferencePage extends PreferencePage implements IWorkbenchPreferencePage
+{
+
+    private final String[] ATTRIBUTE_TYPES = new String[]
+        { "Objectclass attribute:", "Must attributes:", "May attributes:", "Operational attributes:" };
+
+    private final String[] ATTRIBUTE_FONT_CONSTANTS = new String[]
+        { BrowserCommonConstants.PREFERENCE_OBJECTCLASS_FONT, BrowserCommonConstants.PREFERENCE_MUSTATTRIBUTE_FONT,
+        BrowserCommonConstants.PREFERENCE_MAYATTRIBUTE_FONT, BrowserCommonConstants.PREFERENCE_OPERATIONALATTRIBUTE_FONT };
+
+    private final String[] ATTRIBUTE_COLOR_CONSTANTS = new String[]
+        { BrowserCommonConstants.PREFERENCE_OBJECTCLASS_COLOR, BrowserCommonConstants.PREFERENCE_MUSTATTRIBUTE_COLOR,
+        BrowserCommonConstants.PREFERENCE_MAYATTRIBUTE_COLOR, BrowserCommonConstants.PREFERENCE_OPERATIONALATTRIBUTE_COLOR };
+
+    private Label[] attributeTypeLabels = new Label[ATTRIBUTE_TYPES.length];
+
+    private ColorSelector[] attributeColorSelectors = new ColorSelector[ATTRIBUTE_TYPES.length];
+
+    private Button[] attributeBoldButtons = new Button[ATTRIBUTE_TYPES.length];
+
+    private Button[] attributeItalicButtons = new Button[ATTRIBUTE_TYPES.length];
+
+    private Button showRawValuesButton;
+
+
+    public AttributesPreferencePage()
+    {
+        super( "Attributes" );
+        super.setPreferenceStore( BrowserCommonActivator.getDefault().getPreferenceStore() );
+        super.setDescription( "General settings for attributes:" );
+    }
+
+
+    public void init( IWorkbench workbench )
+    {
+    }
+
+
+    protected Control createContents( Composite parent )
+    {
+
+        Composite composite = new Composite( parent, SWT.NONE );
+        GridLayout layout = new GridLayout( 1, false );
+        layout.marginWidth = 0;
+        layout.marginHeight = 0;
+        layout.marginLeft = 0;
+        layout.marginRight = 0;
+        layout.marginTop = 0;
+        layout.marginBottom = 0;
+        composite.setLayout( layout );
+        composite.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+
+        BaseWidgetUtils.createSpacer( composite, 1 );
+        BaseWidgetUtils.createSpacer( composite, 1 );
+        Group colorsAndFontsGroup = BaseWidgetUtils.createGroup( composite, "Attribute Colors and Fonts", 1 );
+        colorsAndFontsGroup.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+        Composite colorsAndFontsComposite = BaseWidgetUtils.createColumnContainer( colorsAndFontsGroup, 4, 1 );
+        for ( int i = 0; i < ATTRIBUTE_TYPES.length; i++ )
+        {
+            final int index = i;
+
+            attributeTypeLabels[i] = BaseWidgetUtils.createLabel( colorsAndFontsComposite, ATTRIBUTE_TYPES[i], 1 );
+            attributeTypeLabels[i].setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+            attributeColorSelectors[i] = new ColorSelector( colorsAndFontsComposite );
+            attributeBoldButtons[i] = BaseWidgetUtils.createCheckbox( colorsAndFontsComposite, "Bold", 1 );
+            attributeItalicButtons[i] = BaseWidgetUtils.createCheckbox( colorsAndFontsComposite, "Italic", 1 );
+
+            FontData[] fontDatas = PreferenceConverter.getFontDataArray( BrowserCommonActivator.getDefault()
+                .getPreferenceStore(), ATTRIBUTE_FONT_CONSTANTS[i] );
+            RGB rgb = PreferenceConverter.getColor( BrowserCommonActivator.getDefault().getPreferenceStore(),
+                ATTRIBUTE_COLOR_CONSTANTS[i] );
+            setColorsAndFonts( index, fontDatas, rgb );
+        }
+
+        BaseWidgetUtils.createSpacer( composite, 1 );
+        BaseWidgetUtils.createSpacer( composite, 1 );
+        showRawValuesButton = BaseWidgetUtils.createCheckbox( composite, "Show raw values", 1 );
+        showRawValuesButton.setSelection( getPreferenceStore().getBoolean(
+            BrowserCommonConstants.PREFERENCE_SHOW_RAW_VALUES ) );
+
+        applyDialogFont( composite );
+        return composite;
+    }
+
+
+    private void setColorsAndFonts( int index, FontData[] fontDatas, RGB rgb )
+    {
+        boolean bold = isBold( fontDatas );
+        boolean italic = isItalic( fontDatas );
+        attributeColorSelectors[index].setColorValue( rgb );
+        attributeBoldButtons[index].setSelection( bold );
+        attributeItalicButtons[index].setSelection( italic );
+    }
+
+
+    private void setFontData( FontData[] fontDatas, Button boldButton, Button italicButton )
+    {
+        for ( int j = 0; j < fontDatas.length; j++ )
+        {
+            int style = SWT.NORMAL;
+            if ( boldButton.getSelection() )
+                style |= SWT.BOLD;
+            if ( italicButton.getSelection() )
+                style |= SWT.ITALIC;
+            fontDatas[j].setStyle( style );
+        }
+    }
+
+
+    private boolean isBold( FontData[] fontDatas )
+    {
+        boolean bold = false;
+        for ( int j = 0; j < fontDatas.length; j++ )
+        {
+            if ( ( fontDatas[j].getStyle() & SWT.BOLD ) != SWT.NORMAL )
+                bold = true;
+        }
+        return bold;
+    }
+
+
+    private boolean isItalic( FontData[] fontDatas )
+    {
+        boolean italic = false;
+        for ( int j = 0; j < fontDatas.length; j++ )
+        {
+            if ( ( fontDatas[j].getStyle() & SWT.ITALIC ) != SWT.NORMAL )
+                italic = true;
+        }
+        return italic;
+    }
+
+
+    public boolean performOk()
+    {
+
+        for ( int i = 0; i < ATTRIBUTE_TYPES.length; i++ )
+        {
+            FontData[] fontDatas = PreferenceConverter.getFontDataArray( BrowserCommonActivator.getDefault()
+                .getPreferenceStore(), ATTRIBUTE_FONT_CONSTANTS[i] );
+            setFontData( fontDatas, this.attributeBoldButtons[i], this.attributeItalicButtons[i] );
+            RGB rgb = attributeColorSelectors[i].getColorValue();
+            PreferenceConverter.setValue( BrowserCommonActivator.getDefault().getPreferenceStore(),
+                ATTRIBUTE_FONT_CONSTANTS[i], fontDatas );
+            PreferenceConverter.setValue( BrowserCommonActivator.getDefault().getPreferenceStore(),
+                ATTRIBUTE_COLOR_CONSTANTS[i], rgb );
+        }
+
+        getPreferenceStore().setValue( BrowserCommonConstants.PREFERENCE_SHOW_RAW_VALUES,
+            this.showRawValuesButton.getSelection() );
+
+        return true;
+    }
+
+
+    protected void performDefaults()
+    {
+
+        for ( int i = 0; i < ATTRIBUTE_TYPES.length; i++ )
+        {
+            FontData[] fontDatas = PreferenceConverter.getDefaultFontDataArray( BrowserCommonActivator.getDefault()
+                .getPreferenceStore(), ATTRIBUTE_FONT_CONSTANTS[i] );
+            RGB rgb = PreferenceConverter.getDefaultColor( BrowserCommonActivator.getDefault().getPreferenceStore(),
+                ATTRIBUTE_COLOR_CONSTANTS[i] );
+            setColorsAndFonts( i, fontDatas, rgb );
+        }
+
+        showRawValuesButton.setSelection( getPreferenceStore().getDefaultBoolean(
+            BrowserCommonConstants.PREFERENCE_SHOW_RAW_VALUES ) );
+
+        super.performDefaults();
+    }
+
+}



Mime
View raw message