directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r488371 [12/14] - in /directory/sandbox/pamarcelot/ldapstudio: ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/jobs/ ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/perspective/ ldapstudio-browser-u...
Date Mon, 18 Dec 2006 17:57:49 GMT
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewBookmarkMainWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewBookmarkMainWizardPage.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewBookmarkMainWizardPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewBookmarkMainWizardPage.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,144 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.DN;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils;
+import org.apache.directory.ldapstudio.browser.ui.widgets.WidgetModifyEvent;
+import org.apache.directory.ldapstudio.browser.ui.widgets.WidgetModifyListener;
+import org.apache.directory.ldapstudio.browser.ui.widgets.search.EntryWidget;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+
+public class NewBookmarkMainWizardPage extends WizardPage implements WidgetModifyListener
+{
+
+    private IEntry entry;
+
+    private Text bookmarkNameText;
+
+    private EntryWidget bookmarkEntryWidget;
+
+
+    public NewBookmarkMainWizardPage( String pageName, IEntry entry, NewBookmarkWizard wizard )
+    {
+        super( pageName );
+        super.setTitle( "New Bookmark" );
+        super.setDescription( "Please enter the bookmark parameters." );
+        // super.setImageDescriptor(BrowserUIPlugin.getDefault().getImageDescriptor(BrowserUIConstants.IMG_ATTRIBUTE_WIZARD));
+        super.setPageComplete( false );
+
+        this.entry = entry;
+    }
+
+
+    public void dispose()
+    {
+        super.dispose();
+        this.bookmarkEntryWidget.removeWidgetModifyListener( this );
+    }
+
+
+    private void validate()
+    {
+        if ( this.bookmarkNameText != null && !this.bookmarkNameText.isDisposed() )
+        {
+            this.setPageComplete( this.bookmarkEntryWidget.getDn() != null
+                && !"".equals( this.bookmarkNameText.getText() ) );
+        }
+    }
+
+
+    public void setVisible( boolean visible )
+    {
+        super.setVisible( visible );
+        if ( visible )
+        {
+            this.validate();
+        }
+    }
+
+
+    public void createControl( Composite parent )
+    {
+
+        Composite composite = new Composite( parent, SWT.NONE );
+        GridLayout gl = new GridLayout( 1, false );
+        composite.setLayout( gl );
+        composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+
+        Composite innerComposite = BaseWidgetUtils.createColumnContainer( composite, 3, 1 );
+
+        BaseWidgetUtils.createLabel( innerComposite, "Bookmark Name:", 1 );
+        this.bookmarkNameText = BaseWidgetUtils.createText( innerComposite, this.entry.getDn().toString(), 2 );
+        this.bookmarkNameText.setFocus();
+        this.bookmarkNameText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                validate();
+            }
+        } );
+
+        BaseWidgetUtils.createLabel( innerComposite, "Bookmark DN:", 1 );
+        this.bookmarkEntryWidget = new EntryWidget();
+        this.bookmarkEntryWidget.addWidgetModifyListener( this );
+        this.bookmarkEntryWidget.createWidget( innerComposite );
+        this.bookmarkEntryWidget.setInput( this.entry.getConnection(), this.entry.getDn() );
+
+        setControl( composite );
+    }
+
+
+    public void widgetModified( WidgetModifyEvent event )
+    {
+        validate();
+    }
+
+
+    public DN getBookmarkDn()
+    {
+        return this.bookmarkEntryWidget.getDn();
+    }
+
+
+    public String getBookmarkName()
+    {
+        return this.bookmarkNameText.getText();
+    }
+
+
+    public void saveDialogSettings()
+    {
+        this.bookmarkEntryWidget.saveDialogSettings();
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewBookmarkWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewBookmarkWizard.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewBookmarkWizard.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewBookmarkWizard.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,155 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.core.events.ModelModifier;
+import org.apache.directory.ldapstudio.browser.core.internal.model.Bookmark;
+import org.apache.directory.ldapstudio.browser.core.model.DN;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IBookmark;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.ISearchResult;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+
+public class NewBookmarkWizard extends Wizard implements INewWizard, ModelModifier
+{
+
+    private NewBookmarkMainWizardPage mainPage;
+
+    private IEntry selectedEntry;
+
+
+    public NewBookmarkWizard()
+    {
+        super.setWindowTitle( "New Bookmark" );
+        super.setNeedsProgressMonitor( false );
+    }
+
+
+    public static String getId()
+    {
+        return NewBookmarkWizard.class.getName();
+    }
+
+
+    public void init( IWorkbench workbench, IStructuredSelection selection )
+    {
+        Object o = selection.getFirstElement();
+        if ( o instanceof IEntry )
+        {
+            this.selectedEntry = ( ( IEntry ) o );
+        }
+        else if ( o instanceof ISearchResult )
+        {
+            this.selectedEntry = ( ( ISearchResult ) o ).getEntry();
+        }
+        else if ( o instanceof Bookmark )
+        {
+            this.selectedEntry = ( ( Bookmark ) o ).getEntry();
+        }
+        else if ( o instanceof IAttribute )
+        {
+            this.selectedEntry = ( ( IAttribute ) o ).getEntry();
+        }
+        else if ( o instanceof IValue )
+        {
+            this.selectedEntry = ( ( IValue ) o ).getAttribute().getEntry();
+        }
+        else
+        {
+            this.selectedEntry = null;
+        }
+    }
+
+
+    public void addPages()
+    {
+        if ( this.selectedEntry != null )
+        {
+            mainPage = new NewBookmarkMainWizardPage( NewBookmarkMainWizardPage.class.getName(), this.selectedEntry,
+                this );
+            addPage( mainPage );
+        }
+        else
+        {
+            IWizardPage page = new DummyWizardPage();
+            addPage( page );
+        }
+    }
+
+    class DummyWizardPage extends WizardPage
+    {
+
+        protected DummyWizardPage()
+        {
+            super( "" );
+            super.setTitle( "No entry selected" );
+            super.setDescription( "In order to use the bookmark creation wizard please select an entry." );
+            // super.setImageDescriptor(BrowserUIPlugin.getDefault().getImageDescriptor(BrowserUIConstants.IMG_ATTRIBUTE_WIZARD));
+            super.setPageComplete( true );
+        }
+
+
+        public void createControl( Composite parent )
+        {
+            Composite composite = new Composite( parent, SWT.NONE );
+            GridLayout gl = new GridLayout( 1, false );
+            composite.setLayout( gl );
+            composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+
+            setControl( composite );
+        }
+    }
+
+
+    public boolean performCancel()
+    {
+        return true;
+    }
+
+
+    public boolean performFinish()
+    {
+        if ( selectedEntry != null )
+        {
+            String name = mainPage.getBookmarkName();
+            DN dn = mainPage.getBookmarkDn();
+            IBookmark bookmark = new Bookmark( selectedEntry.getConnection(), dn, name );
+            selectedEntry.getConnection().getBookmarkManager().addBookmark( bookmark );
+        }
+        mainPage.saveDialogSettings();
+        return true;
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewConnectionAuthWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewConnectionAuthWizardPage.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewConnectionAuthWizardPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewConnectionAuthWizardPage.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,116 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.widgets.connection.ConnectionPageModifyListener;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+
+
+public class NewConnectionAuthWizardPage extends WizardPage implements ConnectionPageModifyListener
+{
+
+    private NewConnectionWizard wizard;
+
+
+    public NewConnectionAuthWizardPage( String pageName, NewConnectionWizard wizard )
+    {
+        super( pageName );
+        super.setTitle( "Authentification" );
+        super.setDescription( "Please select an authentification method and input authentification data." );
+        super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor(
+            BrowserUIConstants.IMG_CONNECTION_WIZARD ) );
+        super.setPageComplete( false );
+
+        this.wizard = wizard;
+        wizard.getCpw().addConnectionPageModifyListener( this );
+    }
+
+
+    public void connectionPageModified()
+    {
+        if ( isCurrentPage() )
+        {
+            validate();
+        }
+    }
+
+
+    public void setMessage( String message )
+    {
+        if ( isCurrentPage() )
+        {
+            super.setMessage( message );
+            validate();
+        }
+    }
+
+
+    public void setErrorMessage( String errorMessage )
+    {
+        if ( isCurrentPage() )
+        {
+            super.setErrorMessage( errorMessage );
+            validate();
+        }
+    }
+
+
+    public IConnection getRealConnection()
+    {
+        return null;
+    }
+
+
+    public void setVisible( boolean visible )
+    {
+        super.setVisible( visible );
+        // this.validate();
+    }
+
+
+    private void validate()
+    {
+        setPageComplete( getMessage() == null );
+        getContainer().updateButtons();
+    }
+
+
+    public void createControl( Composite parent )
+    {
+        Composite composite = new Composite( parent, SWT.NONE );
+        GridLayout gl = new GridLayout( 1, false );
+        composite.setLayout( gl );
+
+        wizard.getCpw().addAuthenticationMethodInput( IConnection.AUTH_SIMPLE, composite );
+        wizard.getCpw().addSimpleAuthInput( true, "", "", composite );
+
+        setControl( composite );
+    }
+
+}
\ No newline at end of file

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewConnectionMainWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewConnectionMainWizardPage.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewConnectionMainWizardPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewConnectionMainWizardPage.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,122 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.widgets.connection.ConnectionPageModifyListener;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+
+
+public class NewConnectionMainWizardPage extends WizardPage implements ConnectionPageModifyListener
+{
+
+    private NewConnectionWizard wizard;
+
+
+    public NewConnectionMainWizardPage( String pageName, NewConnectionWizard wizard )
+    {
+        super( pageName );
+        super.setTitle( "New LDAP Connection" );
+        super.setDescription( "Please enter connection name and network parameters." );
+        super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor(
+            BrowserUIConstants.IMG_CONNECTION_WIZARD ) );
+        super.setPageComplete( false );
+
+        this.wizard = wizard;
+        wizard.getCpw().addConnectionPageModifyListener( this );
+    }
+
+
+    public void dispose()
+    {
+        super.dispose();
+    }
+
+
+    public void setVisible( boolean visible )
+    {
+        super.setVisible( visible );
+    }
+
+
+    public void connectionPageModified()
+    {
+        if ( isCurrentPage() )
+        {
+            validate();
+        }
+    }
+
+
+    public void setMessage( String message )
+    {
+        if ( isCurrentPage() )
+        {
+            super.setMessage( message );
+            validate();
+        }
+    }
+
+
+    public void setErrorMessage( String errorMessage )
+    {
+        if ( isCurrentPage() )
+        {
+            super.setErrorMessage( errorMessage );
+            validate();
+        }
+    }
+
+
+    public IConnection getRealConnection()
+    {
+        return null;
+    }
+
+
+    private void validate()
+    {
+        setPageComplete( getMessage() == null );
+        getContainer().updateButtons();
+    }
+
+
+    public void createControl( Composite parent )
+    {
+        Composite composite = new Composite( parent, SWT.NONE );
+        GridLayout gl = new GridLayout( 1, false );
+        composite.setLayout( gl );
+
+        wizard.getCpw().addMainInput( "", "", 389, IConnection.ENCYRPTION_NONE, composite );
+        wizard.getCpw().addOpenConnectionInput( true, composite );
+
+        setControl( composite );
+        // nameText.setFocus();
+    }
+
+}
\ No newline at end of file

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewConnectionOptionsWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewConnectionOptionsWizardPage.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewConnectionOptionsWizardPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewConnectionOptionsWizardPage.java Mon Dec 18 09:57:38 2006
@@ -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.ui.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.widgets.connection.ConnectionPageModifyListener;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+
+
+public class NewConnectionOptionsWizardPage extends WizardPage implements ConnectionPageModifyListener
+{
+
+    private NewConnectionWizard wizard;
+
+
+    public NewConnectionOptionsWizardPage( String pageName, NewConnectionWizard wizard )
+    {
+        super( pageName );
+        super.setTitle( "Connection Parameter" );
+        super.setDescription( "You can specify additional connection parameters." );
+        super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor(
+            BrowserUIConstants.IMG_CONNECTION_WIZARD ) );
+        super.setPageComplete( true );
+
+        this.wizard = wizard;
+        wizard.getCpw().addConnectionPageModifyListener( this );
+    }
+
+
+    public void connectionPageModified()
+    {
+        if ( isCurrentPage() )
+        {
+            validate();
+        }
+    }
+
+
+    public void setMessage( String message )
+    {
+        if ( isCurrentPage() )
+        {
+            super.setMessage( message );
+            validate();
+        }
+    }
+
+
+    public void setErrorMessage( String errorMessage )
+    {
+        if ( isCurrentPage() )
+        {
+            super.setErrorMessage( errorMessage );
+            validate();
+        }
+    }
+
+
+    public IConnection getRealConnection()
+    {
+        return null;
+    }
+
+
+    public void setVisible( boolean visible )
+    {
+        super.setVisible( visible );
+        // this.validate();
+    }
+
+
+    private void validate()
+    {
+        setPageComplete( getMessage() == null );
+        getContainer().updateButtons();
+    }
+
+
+    public void createControl( Composite parent )
+    {
+        Composite composite = new Composite( parent, SWT.NONE );
+        GridLayout gl = new GridLayout( 1, false );
+        composite.setLayout( gl );
+
+        wizard.getCpw().addBaseDNInput( true, "", composite );
+        wizard.getCpw().addLimitInput(
+            BrowserUIPlugin.getDefault().getPreferenceStore().getInt( BrowserUIConstants.PREFERENCE_COUNT_LIMIT ),
+            BrowserUIPlugin.getDefault().getPreferenceStore().getInt( BrowserUIConstants.PREFERENCE_TIME_LIMIT ),
+            IConnection.DEREFERENCE_ALIASES_ALWAYS, IConnection.HANDLE_REFERRALS_FOLLOW, composite );
+
+        setControl( composite );
+        // baseDNText.setFocus();
+    }
+
+}
\ No newline at end of file

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewConnectionWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewConnectionWizard.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewConnectionWizard.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewConnectionWizard.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,180 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCorePlugin;
+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.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.widgets.connection.ConnectionPageModifyListener;
+import org.apache.directory.ldapstudio.browser.ui.widgets.connection.ConnectionPageWrapper;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
+
+
+public class NewConnectionWizard extends Wizard implements INewWizard, ConnectionPageModifyListener
+{
+
+    private ConnectionPageWrapper cpw;
+
+    private NewConnectionMainWizardPage mainPage;
+
+    private NewConnectionAuthWizardPage authPage;
+
+    private NewConnectionOptionsWizardPage optionsPage;
+
+
+    public NewConnectionWizard()
+    {
+        super.setWindowTitle( "New LDAP Connection" );
+        super.setNeedsProgressMonitor( true );
+
+    }
+
+
+    public boolean needsProgressMonitor()
+    {
+        return true;
+    }
+
+
+    public static String getId()
+    {
+        return NewConnectionWizard.class.getName();
+    }
+
+
+    public void init( IWorkbench workbench, IStructuredSelection selection )
+    {
+
+    }
+
+
+    public void addPages()
+    {
+
+        cpw = new ConnectionPageWrapper( this, this.getContainer() );
+
+        mainPage = new NewConnectionMainWizardPage( NewConnectionMainWizardPage.class.getName(), this );
+        addPage( mainPage );
+
+        authPage = new NewConnectionAuthWizardPage( NewConnectionAuthWizardPage.class.getName(), this );
+        addPage( authPage );
+
+        optionsPage = new NewConnectionOptionsWizardPage( NewConnectionOptionsWizardPage.class.getName(), this );
+        addPage( optionsPage );
+
+        PlatformUI.getWorkbench().getHelpSystem().setHelp( getContainer().getShell(),
+            BrowserUIPlugin.PLUGIN_ID + "." + "tools_newconnection_wizard" );
+    }
+
+
+    public IWizardPage getNextPage( IWizardPage page )
+    {
+        if ( page == this.mainPage )
+        {
+            return this.authPage;
+        }
+        else if ( page == this.authPage )
+        {
+            return this.optionsPage;
+        }
+        else if ( page == this.optionsPage )
+        {
+            return null;
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    public boolean canFinish()
+    {
+        if ( cpw.getAuthenticationMethod() == IConnection.AUTH_ANONYMOUS )
+        {
+            return this.mainPage.isPageComplete() && this.optionsPage.isPageComplete();
+        }
+        else if ( cpw.getAuthenticationMethod() == IConnection.AUTH_SIMPLE )
+        {
+            return this.mainPage.isPageComplete() && this.authPage.isPageComplete()
+                && this.optionsPage.isPageComplete();
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+
+    public boolean performFinish()
+    {
+        final IConnection conn = cpw.getTestConnection();
+        conn.setName( cpw.getName() );
+        if ( conn != null )
+        {
+            BrowserCorePlugin.getDefault().getConnectionManager().addConnection( conn );
+            if ( cpw.isOpenConnectionOnFinish() )
+            {
+                new OpenConnectionsJob( conn ).execute();
+            }
+            cpw.saveDialogSettings();
+            return true;
+        }
+        return false;
+    }
+
+
+    public void connectionPageModified()
+    {
+
+    }
+
+
+    public void setMessage( String message )
+    {
+    }
+
+
+    public void setErrorMessage( String errorMessage )
+    {
+    }
+
+
+    public IConnection getRealConnection()
+    {
+        return null;
+    }
+
+
+    public ConnectionPageWrapper getCpw()
+    {
+        return cpw;
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryAttributesWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryAttributesWizardPage.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryAttributesWizardPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryAttributesWizardPage.java Mon Dec 18 09:57:38 2006
@@ -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.ui.wizards;
+
+
+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.internal.model.Attribute;
+import org.apache.directory.ldapstudio.browser.core.internal.model.DummyEntry;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.widgets.entryeditor.EntryEditorWidget;
+import org.apache.directory.ldapstudio.browser.ui.widgets.entryeditor.EntryEditorWidgetActionGroup;
+import org.apache.directory.ldapstudio.browser.ui.widgets.entryeditor.EntryEditorWidgetConfiguration;
+import org.apache.directory.ldapstudio.browser.ui.widgets.entryeditor.EntryEditorWidgetUniversalListener;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+
+
+public class NewEntryAttributesWizardPage extends WizardPage implements EntryUpdateListener
+{
+
+    private NewEntryWizard wizard;
+
+    private EntryEditorWidgetConfiguration configuration;
+
+    private EntryEditorWidgetActionGroup actionGroup;
+
+    private EntryEditorWidget mainWidget;
+
+    private EntryEditorWidgetUniversalListener universalListener;
+
+
+    public NewEntryAttributesWizardPage( String pageName, NewEntryWizard wizard )
+    {
+        super( pageName );
+        super.setTitle( "Attributes" );
+        super.setDescription( "Please enter the attributes for the entry. Enter at least the MUST attributes." );
+        super
+            .setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_ENTRY_WIZARD ) );
+        super.setPageComplete( false );
+        this.wizard = wizard;
+    }
+
+
+    public void dispose()
+    {
+        if ( this.configuration != null )
+        {
+            EventRegistry.removeEntryUpdateListener( this );
+            this.universalListener.dispose();
+            this.universalListener = null;
+            this.mainWidget.dispose();
+            this.mainWidget = null;
+            this.actionGroup.dispose();
+            this.actionGroup = null;
+            this.configuration.dispose();
+            this.configuration = null;
+        }
+        super.dispose();
+    }
+
+
+    public void setVisible( boolean visible )
+    {
+        super.setVisible( visible );
+
+        if ( visible )
+        {
+
+            DummyEntry newEntry = wizard.getNewEntry();
+
+            try
+            {
+                EventRegistry.suspendEventFireingInCurrentThread();
+
+                // remove empty must attributes
+                String[] oldMust = newEntry.getSubschema().getMustAttributeNames();
+                for ( int i = 0; i < oldMust.length; i++ )
+                {
+                    IAttribute attribute = newEntry.getAttribute( oldMust[i] );
+                    if ( attribute != null )
+                    {
+                        IValue[] values = attribute.getValues();
+                        for ( int v = 0; v < values.length; v++ )
+                        {
+                            if ( values[v].isEmpty() )
+                            {
+                                attribute.deleteValue( values[v], wizard );
+                            }
+                        }
+                        if ( attribute.getValueSize() == 0 )
+                        {
+                            newEntry.deleteAttribute( attribute, wizard );
+                        }
+                    }
+                }
+
+                // add must attributes
+                String[] newMust = newEntry.getSubschema().getMustAttributeNames();
+                for ( int i = 0; i < newMust.length; i++ )
+                {
+                    if ( newEntry.getAttribute( newMust[i] ) == null )
+                    {
+                        IAttribute att = new Attribute( newEntry, newMust[i] );
+                        newEntry.addAttribute( att, wizard );
+                        att.addEmptyValue( wizard );
+                    }
+                }
+            }
+            catch ( ModelModificationException e )
+            {
+                e.printStackTrace();
+            }
+            finally
+            {
+                EventRegistry.resumeEventFireingInCurrentThread();
+            }
+
+            this.mainWidget.getViewer().setInput( newEntry );
+            this.mainWidget.getViewer().refresh();
+            validate();
+        }
+        else
+        {
+            this.mainWidget.getViewer().setInput( "" );
+            this.mainWidget.getViewer().refresh();
+            setPageComplete( false );
+        }
+    }
+
+
+    private void validate()
+    {
+        if ( this.wizard.getNewEntry() != null && this.wizard.getNewEntry().isConsistent() )
+        {
+            super.setPageComplete( true );
+        }
+        else
+        {
+            super.setPageComplete( false );
+        }
+    }
+
+
+    public void createControl( Composite parent )
+    {
+
+        Composite composite = new Composite( parent, SWT.NONE );
+        GridLayout gl = new GridLayout( 1, false );
+        composite.setLayout( gl );
+        composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+
+        // create configuration
+        this.configuration = new EntryEditorWidgetConfiguration();
+
+        // create main widget
+        this.mainWidget = new EntryEditorWidget( this.configuration );
+        this.mainWidget.createWidget( composite );
+        this.mainWidget.getViewer().getTree().setFocus();
+
+        // create actions
+        this.actionGroup = new NewEntryAttributesWizardPageActionGroup( this.mainWidget, this.configuration );
+        this.actionGroup.fillToolBar( this.mainWidget.getToolBarManager() );
+        this.actionGroup.fillMenu( this.mainWidget.getMenuManager() );
+        this.actionGroup.fillContextMenu( this.mainWidget.getContextMenuManager() );
+
+        // create the listener
+        this.universalListener = new EntryEditorWidgetUniversalListener( this.mainWidget.getViewer(), this.actionGroup
+            .getOpenDefaultEditorAction() );
+        EventRegistry.addEntryUpdateListener( this );
+
+        setControl( composite );
+    }
+
+
+    public void entryUpdated( EntryModificationEvent event )
+    {
+        if ( event.getModifiedEntry() == this.wizard.getNewEntry() && !this.isDisposed() && getControl().isVisible() )
+        {
+            this.validate();
+        }
+    }
+
+
+    public boolean isDisposed()
+    {
+        return this.configuration == null;
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryAttributesWizardPageActionGroup.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryAttributesWizardPageActionGroup.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryAttributesWizardPageActionGroup.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryAttributesWizardPageActionGroup.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,153 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.ui.actions.DeleteAllValuesAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.NewAttributeAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.proxy.EntryEditorActionProxy;
+import org.apache.directory.ldapstudio.browser.ui.widgets.entryeditor.EditAttributeDescriptionAction;
+import org.apache.directory.ldapstudio.browser.ui.widgets.entryeditor.EntryEditorWidget;
+import org.apache.directory.ldapstudio.browser.ui.widgets.entryeditor.EntryEditorWidgetActionGroup;
+import org.apache.directory.ldapstudio.browser.ui.widgets.entryeditor.EntryEditorWidgetConfiguration;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.commands.ActionHandler;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
+
+
+public class NewEntryAttributesWizardPageActionGroup extends EntryEditorWidgetActionGroup
+{
+
+    private EditAttributeDescriptionAction editAttributeDescriptionAction;
+
+    private static final String newAttributeAction = "newAttributeAction";
+
+    private static final String deleteAllValuesAction = "deleteAllValuesAction";
+
+
+    public NewEntryAttributesWizardPageActionGroup( EntryEditorWidget mainWidget,
+        EntryEditorWidgetConfiguration configuration )
+    {
+        super( mainWidget, configuration );
+        TreeViewer viewer = mainWidget.getViewer();
+
+        this.editAttributeDescriptionAction = new EditAttributeDescriptionAction( viewer );
+
+        this.entryEditorActionMap.put( newAttributeAction,
+            new EntryEditorActionProxy( viewer, new NewAttributeAction() ) );
+        this.entryEditorActionMap.put( deleteAllValuesAction, new EntryEditorActionProxy( viewer,
+            new DeleteAllValuesAction() ) );
+
+    }
+
+
+    public void dispose()
+    {
+        if ( this.editAttributeDescriptionAction != null )
+        {
+
+            this.editAttributeDescriptionAction.dispose();
+            this.editAttributeDescriptionAction = null;
+        }
+        super.dispose();
+    }
+
+
+    public void fillToolBar( IToolBarManager toolBarManager )
+    {
+        toolBarManager.add( ( IAction ) this.entryEditorActionMap.get( newValueAction ) );
+        toolBarManager.add( ( IAction ) this.entryEditorActionMap.get( newAttributeAction ) );
+        toolBarManager.add( new Separator() );
+        toolBarManager.add( ( IAction ) this.entryEditorActionMap.get( deleteAction ) );
+        toolBarManager.add( ( IAction ) this.entryEditorActionMap.get( deleteAllValuesAction ) );
+        toolBarManager.add( new Separator() );
+        toolBarManager.add( this.showQuickFilterAction );
+        toolBarManager.update( true );
+    }
+
+
+    public void menuAboutToShow( IMenuManager menuManager )
+    {
+
+        // new
+        menuManager.add( ( IAction ) this.entryEditorActionMap.get( newAttributeAction ) );
+        menuManager.add( ( IAction ) this.entryEditorActionMap.get( newValueAction ) );
+        menuManager.add( new Separator() );
+
+        // copy, paste, delete
+        menuManager.add( ( IAction ) this.entryEditorActionMap.get( copyAction ) );
+        menuManager.add( ( IAction ) this.entryEditorActionMap.get( pasteAction ) );
+        menuManager.add( ( IAction ) this.entryEditorActionMap.get( deleteAction ) );
+        menuManager.add( ( IAction ) this.entryEditorActionMap.get( selectAllAction ) );
+        MenuManager copyMenuManager = new MenuManager( "Advanced" );
+        copyMenuManager.add( ( IAction ) this.entryEditorActionMap.get( deleteAllValuesAction ) );
+        menuManager.add( copyMenuManager );
+        menuManager.add( new Separator() );
+
+        // edit
+        menuManager.add( this.editAttributeDescriptionAction );
+        super.addEditMenu( menuManager );
+        menuManager.add( new Separator() );
+
+        // properties
+        menuManager.add( ( IAction ) this.entryEditorActionMap.get( propertyDialogAction ) );
+    }
+
+
+    public void activateGlobalActionHandlers()
+    {
+
+        super.activateGlobalActionHandlers();
+
+        ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
+            ICommandService.class );
+        if ( commandService != null )
+        {
+            IAction naa = ( IAction ) this.entryEditorActionMap.get( newAttributeAction );
+            commandService.getCommand( naa.getActionDefinitionId() ).setHandler( new ActionHandler( naa ) );
+            commandService.getCommand( editAttributeDescriptionAction.getActionDefinitionId() ).setHandler(
+                new ActionHandler( editAttributeDescriptionAction ) );
+        }
+    }
+
+
+    public void deactivateGlobalActionHandlers()
+    {
+
+        super.deactivateGlobalActionHandlers();
+
+        ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
+            ICommandService.class );
+        if ( commandService != null )
+        {
+            IAction naa = ( IAction ) this.entryEditorActionMap.get( newAttributeAction );
+            commandService.getCommand( naa.getActionDefinitionId() ).setHandler( null );
+            commandService.getCommand( editAttributeDescriptionAction.getActionDefinitionId() ).setHandler( null );
+        }
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryDnWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryDnWizardPage.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryDnWizardPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryDnWizardPage.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,273 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.wizards;
+
+
+import java.util.Arrays;
+
+import org.apache.directory.ldapstudio.browser.core.events.EventRegistry;
+import org.apache.directory.ldapstudio.browser.core.internal.model.Attribute;
+import org.apache.directory.ldapstudio.browser.core.internal.model.DummyEntry;
+import org.apache.directory.ldapstudio.browser.core.internal.model.Value;
+import org.apache.directory.ldapstudio.browser.core.jobs.ReadEntryJob;
+import org.apache.directory.ldapstudio.browser.core.model.DN;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException;
+import org.apache.directory.ldapstudio.browser.core.model.RDN;
+import org.apache.directory.ldapstudio.browser.core.model.RDNPart;
+import org.apache.directory.ldapstudio.browser.core.model.schema.Subschema;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.jobs.RunnableContextJobAdapter;
+import org.apache.directory.ldapstudio.browser.ui.widgets.DnBuilderWidget;
+import org.apache.directory.ldapstudio.browser.ui.widgets.WidgetModifyEvent;
+import org.apache.directory.ldapstudio.browser.ui.widgets.WidgetModifyListener;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.widgets.Composite;
+
+
+public class NewEntryDnWizardPage extends WizardPage implements WidgetModifyListener
+{
+
+    private NewEntryWizard wizard;
+
+    private DnBuilderWidget dnBuilderWidget;
+
+
+    public NewEntryDnWizardPage( String pageName, NewEntryWizard wizard )
+    {
+        super( pageName );
+        super.setTitle( "Distinguished Name" );
+        super.setDescription( "Please select the parent of the new entry and enter the RDN." );
+        super
+            .setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_ENTRY_WIZARD ) );
+        super.setPageComplete( false );
+
+        this.wizard = wizard;
+    }
+
+
+    public void dispose()
+    {
+        if ( this.dnBuilderWidget != null )
+        {
+            this.dnBuilderWidget.removeWidgetModifyListener( this );
+            this.dnBuilderWidget.dispose();
+            this.dnBuilderWidget = null;
+        }
+        super.dispose();
+    }
+
+
+    private void validate()
+    {
+        if ( this.dnBuilderWidget.getRdn() != null && this.dnBuilderWidget.getParentDn() != null )
+        {
+            super.setPageComplete( true );
+            saveState();
+        }
+        else
+        {
+            super.setPageComplete( false );
+        }
+    }
+
+
+    private void loadState()
+    {
+
+        DummyEntry newEntry = this.wizard.getNewEntry();
+
+        Subschema subschema = newEntry.getSubschema();
+        String[] attributeNames = subschema.getAllAttributeNames();
+
+        DN parentDn = null;
+        if ( newEntry.getDn().getParentDn() != null )
+        {
+            parentDn = newEntry.getDn().getParentDn();
+        }
+        else if ( wizard.getSelectedEntry() != null )
+        {
+            parentDn = wizard.getSelectedEntry().getDn();
+        }
+
+        RDN rdn = newEntry.getRdn();
+
+        this.dnBuilderWidget.setInput( wizard.getSelectedConnection(), attributeNames, rdn, parentDn );
+    }
+
+
+    private void saveState()
+    {
+        DummyEntry newEntry = wizard.getNewEntry();
+
+        try
+        {
+            EventRegistry.suspendEventFireingInCurrentThread();
+
+            // remove old RDN
+            RDNPart[] oldRdnParts = newEntry.getRdn().getParts();
+            for ( int i = 0; i < oldRdnParts.length; i++ )
+            {
+                IAttribute attribute = newEntry.getAttribute( oldRdnParts[i].getName() );
+                if ( attribute != null )
+                {
+                    IValue[] values = attribute.getValues();
+                    for ( int v = 0; v < values.length; v++ )
+                    {
+                        if ( values[v].getStringValue().equals( oldRdnParts[i].getUnencodedValue() ) )
+                        {
+                            attribute.deleteValue( values[v], wizard );
+                        }
+                    }
+                }
+            }
+
+            // set new DN
+            DN dn = new DN( this.dnBuilderWidget.getRdn(), this.dnBuilderWidget.getParentDn() );
+            newEntry.setDn( dn );
+
+            // add new RDN
+            RDNPart[] newRdnParts = dn.getRdn().getParts();
+            for ( int i = 0; i < newRdnParts.length; i++ )
+            {
+                IAttribute rdnAttribute = newEntry.getAttribute( newRdnParts[i].getName() );
+                if ( rdnAttribute == null )
+                {
+                    rdnAttribute = new Attribute( newEntry, newRdnParts[i].getName() );
+                    newEntry.addAttribute( rdnAttribute, wizard );
+                }
+                String rdnValue = newRdnParts[i].getUnencodedValue();
+                String[] stringValues = rdnAttribute.getStringValues();
+                if ( !Arrays.asList( stringValues ).contains( rdnValue ) )
+                {
+                    rdnAttribute.addValue( new Value( rdnAttribute, rdnValue ), wizard );
+                }
+            }
+
+        }
+        catch ( ModelModificationException e )
+        {
+            e.printStackTrace();
+        }
+        finally
+        {
+            EventRegistry.resumeEventFireingInCurrentThread();
+        }
+    }
+
+
+    public void setVisible( boolean visible )
+    {
+        super.setVisible( visible );
+
+        if ( visible )
+        {
+            loadState();
+            validate();
+        }
+    }
+
+
+    public boolean canFlipToNextPage()
+    {
+        return isPageComplete();
+    }
+
+
+    public IWizardPage getNextPage()
+    {
+
+        this.dnBuilderWidget.validate();
+        final RDN[] rdns = new RDN[]
+            { this.dnBuilderWidget.getRdn() };
+        final DN[] parentDns = new DN[]
+            { this.dnBuilderWidget.getParentDn() };
+        final DN dn = new DN( rdns[0], parentDns[0] );
+
+        // check if parent exists or new entry already exists
+        ReadEntryJob readEntryJob1 = new ReadEntryJob( wizard.getSelectedConnection(), parentDns[0] );
+        RunnableContextJobAdapter.execute( readEntryJob1, getContainer(), false );
+        IEntry parentEntry = readEntryJob1.getReadEntry();
+        if ( parentEntry == null )
+        {
+            getShell().getDisplay().syncExec( new Runnable()
+            {
+                public void run()
+                {
+                    MessageDialog.openError( getShell(), "Error", "Parent " + dnBuilderWidget.getParentDn().toString()
+                        + " doesn't exists" );
+                }
+            } );
+            return null;
+        }
+        ReadEntryJob readEntryJob2 = new ReadEntryJob( wizard.getSelectedConnection(), dn );
+        RunnableContextJobAdapter.execute( readEntryJob2, getContainer(), false );
+        IEntry entry = readEntryJob2.getReadEntry();
+        if ( entry != null )
+        {
+            getShell().getDisplay().syncExec( new Runnable()
+            {
+                public void run()
+                {
+                    MessageDialog.openError( getShell(), "Error", "Entry " + dn.toString() + " already exists" );
+                }
+            } );
+            return null;
+        }
+
+        return super.getNextPage();
+    }
+
+
+    public IWizardPage getPreviousPage()
+    {
+        return super.getPreviousPage();
+    }
+
+
+    public void createControl( Composite parent )
+    {
+        this.dnBuilderWidget = new DnBuilderWidget( true, true );
+        this.dnBuilderWidget.addWidgetModifyListener( this );
+        Composite composite = this.dnBuilderWidget.createContents( parent );
+
+        setControl( composite );
+    }
+
+
+    public void widgetModified( WidgetModifyEvent event )
+    {
+        validate();
+    }
+
+
+    public void saveDialogSettings()
+    {
+        this.dnBuilderWidget.saveDialogSettings();
+    }
+
+}
\ No newline at end of file

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryObjectclassWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryObjectclassWizardPage.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryObjectclassWizardPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryObjectclassWizardPage.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,337 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.wizards;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.core.events.EventRegistry;
+import org.apache.directory.ldapstudio.browser.core.internal.model.Attribute;
+import org.apache.directory.ldapstudio.browser.core.internal.model.DummyEntry;
+import org.apache.directory.ldapstudio.browser.core.internal.model.Value;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils;
+
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+
+public class NewEntryObjectclassWizardPage extends WizardPage
+{
+
+    private final static int SIZING_SELECTION_WIDGET_HEIGHT = 250;
+
+    private final static int SIZING_SELECTION_WIDGET_WIDTH = 400;
+
+    private NewEntryWizard wizard;
+
+    private List availableObjectClasses;
+
+    private ListViewer availableObjectClassesViewer;
+
+    private List selectedObjectClasses;
+
+    private ListViewer selectedObjectClassesViewer;
+
+    private Button addButton;
+
+    private Button removeButton;
+
+
+    public NewEntryObjectclassWizardPage( String pageName, NewEntryWizard wizard )
+    {
+        super( pageName );
+        super.setTitle( "Object Classes" );
+        super
+            .setDescription( "Please select object classes of the new entry. Select at least one structural object class." );
+        super
+            .setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_ENTRY_WIZARD ) );
+        super.setPageComplete( false );
+
+        this.wizard = wizard;
+
+        this.availableObjectClasses = new ArrayList();
+        this.selectedObjectClasses = new ArrayList();
+    }
+
+
+    private void validate()
+    {
+        if ( !this.selectedObjectClasses.isEmpty() )
+        {
+            super.setPageComplete( true );
+            saveState();
+        }
+        else
+        {
+            super.setPageComplete( false );
+        }
+    }
+
+
+    private void loadState()
+    {
+        availableObjectClasses.clear();
+        selectedObjectClasses.clear();
+
+        if ( wizard.getSelectedConnection() != null )
+        {
+            availableObjectClasses.addAll( Arrays.asList( wizard.getSelectedConnection().getSchema()
+                .getObjectClassDescriptionNames() ) );
+        }
+
+        DummyEntry newEntry = wizard.getNewEntry();
+        IAttribute ocAttribute = newEntry.getAttribute( IAttribute.OBJECTCLASS_ATTRIBUTE );
+        if ( ocAttribute != null )
+        {
+            String[] ocValues = ocAttribute.getStringValues();
+            for ( int i = 0; i < ocValues.length; i++ )
+            {
+                String oc = ocValues[i];
+                availableObjectClasses.remove( oc );
+                selectedObjectClasses.add( oc );
+            }
+        }
+
+        availableObjectClassesViewer.refresh();
+        selectedObjectClassesViewer.refresh();
+    }
+
+
+    private void saveState()
+    {
+        DummyEntry newEntry = wizard.getNewEntry();
+
+        try
+        {
+            EventRegistry.suspendEventFireingInCurrentThread();
+
+            // set new objectClass values
+            IAttribute ocAttribute = newEntry.getAttribute( IAttribute.OBJECTCLASS_ATTRIBUTE );
+            if ( ocAttribute == null )
+            {
+                ocAttribute = new Attribute( newEntry, IAttribute.OBJECTCLASS_ATTRIBUTE );
+                newEntry.addAttribute( ocAttribute, wizard );
+            }
+            IValue[] values = ocAttribute.getValues();
+            for ( int i = 0; i < values.length; i++ )
+            {
+                ocAttribute.deleteValue( values[i], wizard );
+            }
+            for ( Iterator it = selectedObjectClasses.iterator(); it.hasNext(); )
+            {
+                Object oc = ( Object ) it.next();
+                ocAttribute.addValue( new Value( ocAttribute, oc ), wizard );
+            }
+
+        }
+        catch ( ModelModificationException e )
+        {
+            e.printStackTrace();
+        }
+        finally
+        {
+            EventRegistry.resumeEventFireingInCurrentThread();
+        }
+    }
+
+
+    public void setVisible( boolean visible )
+    {
+        super.setVisible( visible );
+
+        if ( visible )
+        {
+            loadState();
+            validate();
+        }
+    }
+
+
+    public boolean canFlipToNextPage()
+    {
+        return isPageComplete();
+    }
+
+
+    public IWizardPage getNextPage()
+    {
+        return super.getNextPage();
+    }
+
+
+    public IWizardPage getPreviousPage()
+    {
+        return super.getPreviousPage();
+    }
+
+
+    public void createControl( Composite parent )
+    {
+
+        Composite composite = new Composite( parent, SWT.NONE );
+        GridLayout gl = new GridLayout( 3, false );
+        composite.setLayout( gl );
+        composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+
+        Label availableLabel = new Label( composite, SWT.NONE );
+        availableLabel.setText( "Available object classes" );
+        Label buttonLabel = new Label( composite, SWT.NONE );
+        buttonLabel.setText( "" );
+        Label selectedLabel = new Label( composite, SWT.NONE );
+        selectedLabel.setText( "Selected object classes" );
+
+        availableObjectClassesViewer = new ListViewer( composite );
+        GridData data = new GridData( GridData.FILL_BOTH );
+        data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT;
+        data.widthHint = ( int ) ( SIZING_SELECTION_WIDGET_WIDTH * 0.4 );
+        availableObjectClassesViewer.getList().setLayoutData( data );
+        availableObjectClassesViewer.setContentProvider( new ArrayContentProvider() );
+        availableObjectClassesViewer.setLabelProvider( new LabelProvider() );
+        availableObjectClassesViewer.setSorter( new ViewerSorter() );
+        availableObjectClassesViewer.setInput( availableObjectClasses );
+        availableObjectClassesViewer.addDoubleClickListener( new IDoubleClickListener()
+        {
+            public void doubleClick( DoubleClickEvent event )
+            {
+                add( event.getSelection() );
+            }
+        } );
+
+        Composite buttonComposite = new Composite( composite, SWT.NONE );
+        gl = new GridLayout( 1, true );
+        buttonComposite.setLayout( gl );
+        data = new GridData( GridData.FILL_BOTH );
+        data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT;
+        // data.widthHint = (int)(SIZING_SELECTION_WIDGET_WIDTH * 0.2);
+        data.horizontalAlignment = SWT.CENTER;
+        buttonComposite.setLayoutData( data );
+        Label label0 = new Label( buttonComposite, SWT.NONE );
+        data = new GridData();
+        data.grabExcessHorizontalSpace = true;
+        data.grabExcessVerticalSpace = true;
+        label0.setLayoutData( data );
+        addButton = BaseWidgetUtils.createButton( buttonComposite, "&Add", 1 );
+        removeButton = BaseWidgetUtils.createButton( buttonComposite, "&Remove", 1 );
+        Label label3 = new Label( buttonComposite, SWT.NONE );
+        data = new GridData();
+        data.grabExcessHorizontalSpace = true;
+        data.grabExcessVerticalSpace = true;
+        label3.setLayoutData( data );
+
+        addButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                add( availableObjectClassesViewer.getSelection() );
+            }
+        } );
+
+        removeButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                remove( selectedObjectClassesViewer.getSelection() );
+            }
+        } );
+
+        selectedObjectClassesViewer = new ListViewer( composite );
+        data = new GridData( GridData.FILL_BOTH );
+        data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT;
+        data.widthHint = ( int ) ( SIZING_SELECTION_WIDGET_WIDTH * 0.4 );
+        selectedObjectClassesViewer.getList().setLayoutData( data );
+        selectedObjectClassesViewer.setContentProvider( new ArrayContentProvider() );
+        selectedObjectClassesViewer.setLabelProvider( new LabelProvider() );
+        selectedObjectClassesViewer.setSorter( new ViewerSorter() );
+        selectedObjectClassesViewer.setInput( selectedObjectClasses );
+        selectedObjectClassesViewer.addDoubleClickListener( new IDoubleClickListener()
+        {
+            public void doubleClick( DoubleClickEvent event )
+            {
+                remove( event.getSelection() );
+            }
+        } );
+
+        setControl( composite );
+    }
+
+
+    private void add( ISelection iselection )
+    {
+        IStructuredSelection selection = ( IStructuredSelection ) iselection;
+        Iterator it = selection.iterator();
+        while ( it.hasNext() )
+        {
+            Object oc = it.next();
+            availableObjectClasses.remove( oc );
+            selectedObjectClasses.add( oc );
+            availableObjectClassesViewer.refresh();
+            selectedObjectClassesViewer.refresh();
+            this.validate();
+        }
+    }
+
+
+    private void remove( ISelection iselection )
+    {
+        IStructuredSelection selection = ( IStructuredSelection ) iselection;
+        Iterator it = selection.iterator();
+        while ( it.hasNext() )
+        {
+            Object oc = it.next();
+            selectedObjectClasses.remove( oc );
+            availableObjectClasses.add( oc );
+            availableObjectClassesViewer.refresh();
+            selectedObjectClassesViewer.refresh();
+            this.validate();
+        }
+    }
+
+
+    public void saveDialogSettings()
+    {
+
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryTypeWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryTypeWizardPage.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryTypeWizardPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryTypeWizardPage.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,260 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.core.events.EventRegistry;
+import org.apache.directory.ldapstudio.browser.core.internal.model.DummyEntry;
+import org.apache.directory.ldapstudio.browser.core.jobs.InitializeAttributesJob;
+import org.apache.directory.ldapstudio.browser.core.jobs.ReadEntryJob;
+import org.apache.directory.ldapstudio.browser.core.model.DN;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifContentRecord;
+import org.apache.directory.ldapstudio.browser.core.model.schema.SchemaUtils;
+import org.apache.directory.ldapstudio.browser.core.utils.ModelConverter;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.jobs.RunnableContextJobAdapter;
+import org.apache.directory.ldapstudio.browser.ui.widgets.BaseWidgetUtils;
+import org.apache.directory.ldapstudio.browser.ui.widgets.WidgetModifyEvent;
+import org.apache.directory.ldapstudio.browser.ui.widgets.WidgetModifyListener;
+import org.apache.directory.ldapstudio.browser.ui.widgets.search.EntryWidget;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+
+
+public class NewEntryTypeWizardPage extends WizardPage implements WidgetModifyListener, SelectionListener
+{
+
+    public static final String PREFERRED_ENTRY_CREATION_METHOD_DIALOGSETTING_KEY = NewEntryTypeWizardPage.class
+        .getName()
+        + ".preferredEntryCreationMethod";
+
+    private NewEntryWizard wizard;
+
+    private Button schemaButton;
+
+    private Button templateButton;
+
+    private EntryWidget entryWidget;
+
+
+    public NewEntryTypeWizardPage( String pageName, NewEntryWizard wizard )
+    {
+        super( pageName );
+        super.setTitle( "Entry Creation Method" );
+        super.setDescription( "Please select the entry creation method." );
+        super
+            .setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_ENTRY_WIZARD ) );
+        super.setPageComplete( false );
+
+        this.wizard = wizard;
+    }
+
+
+    private void validate()
+    {
+        if ( schemaButton.getSelection() )
+        {
+            super.setPageComplete( true );
+        }
+        else if ( templateButton.getSelection() )
+        {
+            super.setPageComplete( entryWidget.getConnection() != null && entryWidget.getDn() != null );
+        }
+        else
+        {
+            super.setPageComplete( false );
+        }
+    }
+
+
+    public void setVisible( boolean visible )
+    {
+        super.setVisible( visible );
+    }
+
+
+    public boolean canFlipToNextPage()
+    {
+        return isPageComplete();
+    }
+
+
+    public IWizardPage getNextPage()
+    {
+
+        if ( templateButton.getSelection() )
+        {
+            final IConnection connection = entryWidget.getConnection();
+            final DN dn = entryWidget.getDn();
+            final IEntry[] templateEntries = new IEntry[1];
+
+            if ( connection == null )
+            {
+                getShell().getDisplay().syncExec( new Runnable()
+                {
+                    public void run()
+                    {
+                        MessageDialog.openError( getShell(), "Error", "No connection" );
+                    }
+                } );
+                return null;
+            }
+            if ( dn == null )
+            {
+                getShell().getDisplay().syncExec( new Runnable()
+                {
+                    public void run()
+                    {
+                        MessageDialog.openError( getShell(), "Error", "No dn" );
+                    }
+                } );
+                return null;
+            }
+
+            // check if selected DN exists
+            ReadEntryJob readEntryJob = new ReadEntryJob( connection, dn );
+            RunnableContextJobAdapter.execute( readEntryJob, getContainer(), false );
+            templateEntries[0] = readEntryJob.getReadEntry();
+            if ( templateEntries[0] == null )
+            {
+                getShell().getDisplay().syncExec( new Runnable()
+                {
+                    public void run()
+                    {
+                        MessageDialog.openError( getShell(), "Error", "Entry " + dn.toString() + " doesn't exists" );
+                    }
+                } );
+                return null;
+            }
+
+            // init attributes
+            if ( !templateEntries[0].isAttributesInitialized() )
+            {
+                InitializeAttributesJob job = new InitializeAttributesJob( templateEntries, false );
+                RunnableContextJobAdapter.execute( job, getContainer() );
+            }
+
+            // clone entry and remove non-modifyable attributes
+            try
+            {
+                EventRegistry.suspendEventFireingInCurrentThread();
+
+                LdifContentRecord record = ModelConverter.entryToLdifContentRecord( templateEntries[0] );
+                DummyEntry newEntry = ModelConverter.ldifContentRecordToEntry( record, connection );
+                IAttribute[] attributes = newEntry.getAttributes();
+                for ( int i = 0; i < attributes.length; i++ )
+                {
+                    if ( !SchemaUtils.isModifyable( attributes[i].getAttributeTypeDescription() ) )
+                    {
+                        newEntry.deleteAttribute( attributes[i], wizard );
+                    }
+                }
+                wizard.setNewEntry( newEntry );
+            }
+            catch ( Exception e )
+            {
+                e.printStackTrace();
+            }
+            finally
+            {
+                EventRegistry.resumeEventFireingInCurrentThread();
+            }
+        }
+        else
+        {
+            wizard.setNewEntry( new DummyEntry( new DN(), wizard.getSelectedConnection() ) );
+        }
+
+        return super.getNextPage();
+    }
+
+
+    public void createControl( Composite parent )
+    {
+
+        Composite composite = new Composite( parent, SWT.NONE );
+        GridLayout gl = new GridLayout( 1, false );
+        composite.setLayout( gl );
+        composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+
+        schemaButton = BaseWidgetUtils.createRadiobutton( composite, "Create entry from scratch", 1 );
+        schemaButton.addSelectionListener( this );
+        templateButton = BaseWidgetUtils.createRadiobutton( composite, "Use existing entry as template", 1 );
+        templateButton.addSelectionListener( this );
+
+        Composite entryComposite = BaseWidgetUtils.createColumnContainer( composite, 3, 1 );
+        BaseWidgetUtils.createRadioIndent( entryComposite, 1 );
+        entryWidget = new EntryWidget( this.wizard.getSelectedConnection(),
+            this.wizard.getSelectedEntry() != null ? this.wizard.getSelectedEntry().getDn() : null );
+        entryWidget.createWidget( entryComposite );
+        entryWidget.addWidgetModifyListener( this );
+
+        if ( BrowserUIPlugin.getDefault().getDialogSettings().get( PREFERRED_ENTRY_CREATION_METHOD_DIALOGSETTING_KEY ) == null )
+            BrowserUIPlugin.getDefault().getDialogSettings().put( PREFERRED_ENTRY_CREATION_METHOD_DIALOGSETTING_KEY,
+                true );
+        schemaButton.setSelection( BrowserUIPlugin.getDefault().getDialogSettings().getBoolean(
+            PREFERRED_ENTRY_CREATION_METHOD_DIALOGSETTING_KEY ) );
+        templateButton.setSelection( !BrowserUIPlugin.getDefault().getDialogSettings().getBoolean(
+            PREFERRED_ENTRY_CREATION_METHOD_DIALOGSETTING_KEY ) );
+        widgetSelected( null );
+
+        setControl( composite );
+    }
+
+
+    public void widgetModified( WidgetModifyEvent event )
+    {
+        validate();
+    }
+
+
+    public void widgetDefaultSelected( SelectionEvent e )
+    {
+    }
+
+
+    public void widgetSelected( SelectionEvent e )
+    {
+        entryWidget.setEnabled( templateButton.getSelection() );
+        validate();
+    }
+
+
+    public void saveDialogSettings()
+    {
+        BrowserUIPlugin.getDefault().getDialogSettings().put( PREFERRED_ENTRY_CREATION_METHOD_DIALOGSETTING_KEY,
+            this.schemaButton.getSelection() );
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryWizard.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryWizard.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryWizard.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,256 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.core.events.EventRegistry;
+import org.apache.directory.ldapstudio.browser.core.events.ModelModifier;
+import org.apache.directory.ldapstudio.browser.core.internal.model.Bookmark;
+import org.apache.directory.ldapstudio.browser.core.internal.model.DummyEntry;
+import org.apache.directory.ldapstudio.browser.core.jobs.CreateEntryJob;
+import org.apache.directory.ldapstudio.browser.core.model.DN;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.ISearch;
+import org.apache.directory.ldapstudio.browser.core.model.ISearchResult;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.jobs.RunnableContextJobAdapter;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
+
+
+public class NewEntryWizard extends Wizard implements INewWizard, ModelModifier
+{
+
+    private NewEntryTypeWizardPage typePage;
+
+    private NewEntryObjectclassWizardPage ocPage;
+
+    private NewEntryDnWizardPage dnPage;
+
+    private NewEntryAttributesWizardPage attributePage;
+
+    private IEntry selectedEntry;
+
+    private IConnection selectedConnection;
+
+    private DummyEntry newEntry;
+
+
+    public NewEntryWizard()
+    {
+        super.setWindowTitle( "New Entry" );
+        super.setNeedsProgressMonitor( true );
+    }
+
+
+    public static String getId()
+    {
+        return NewEntryWizard.class.getName();
+    }
+
+
+    public void init( IWorkbench workbench, IStructuredSelection selection )
+    {
+        Object o = selection.getFirstElement();
+        if ( o instanceof IEntry )
+        {
+            this.selectedEntry = ( ( IEntry ) o );
+            this.selectedConnection = this.selectedEntry.getConnection();
+        }
+        else if ( o instanceof ISearchResult )
+        {
+            this.selectedEntry = ( ( ISearchResult ) o ).getEntry();
+            this.selectedConnection = this.selectedEntry.getConnection();
+        }
+        else if ( o instanceof Bookmark )
+        {
+            this.selectedEntry = ( ( Bookmark ) o ).getEntry();
+            this.selectedConnection = this.selectedEntry.getConnection();
+        }
+        else if ( o instanceof IAttribute )
+        {
+            this.selectedEntry = ( ( IAttribute ) o ).getEntry();
+            this.selectedConnection = this.selectedEntry.getConnection();
+        }
+        else if ( o instanceof IValue )
+        {
+            this.selectedEntry = ( ( IValue ) o ).getAttribute().getEntry();
+            this.selectedConnection = this.selectedEntry.getConnection();
+        }
+        else if ( o instanceof ISearch )
+        {
+            this.selectedEntry = null;
+            this.selectedConnection = ( ( ISearch ) o ).getConnection();
+        }
+        else if ( o instanceof IConnection )
+        {
+            this.selectedEntry = null;
+            this.selectedConnection = ( IConnection ) o;
+        }
+        else
+        {
+            this.selectedEntry = null;
+            this.selectedConnection = null;
+        }
+
+        if ( this.selectedConnection != null )
+        {
+            this.selectedConnection.suspend();
+            this.newEntry = new DummyEntry( new DN(), this.selectedConnection );
+        }
+    }
+
+
+    public void addPages()
+    {
+        if ( this.selectedConnection != null && this.selectedConnection.isOpened() )
+        {
+            typePage = new NewEntryTypeWizardPage( NewEntryTypeWizardPage.class.getName(), this );
+            addPage( typePage );
+
+            ocPage = new NewEntryObjectclassWizardPage( NewEntryObjectclassWizardPage.class.getName(), this );
+            addPage( ocPage );
+
+            dnPage = new NewEntryDnWizardPage( NewEntryDnWizardPage.class.getName(), this );
+            addPage( dnPage );
+
+            attributePage = new NewEntryAttributesWizardPage( NewEntryAttributesWizardPage.class.getName(), this );
+            addPage( attributePage );
+        }
+        else
+        {
+            IWizardPage page = new DummyWizardPage();
+            addPage( page );
+        }
+
+        PlatformUI.getWorkbench().getHelpSystem().setHelp( getContainer().getShell(),
+            BrowserUIPlugin.PLUGIN_ID + "." + "tools_newentry_wizard" );
+    }
+
+    class DummyWizardPage extends WizardPage
+    {
+
+        protected DummyWizardPage()
+        {
+            super( "" );
+            super.setTitle( "No connection selected or connection is closed" );
+            super.setDescription( "In order to use the entry creation wizard please select a opened connection." );
+            super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor(
+                BrowserUIConstants.IMG_ENTRY_WIZARD ) );
+            super.setPageComplete( true );
+        }
+
+
+        public void createControl( Composite parent )
+        {
+            Composite composite = new Composite( parent, SWT.NONE );
+            GridLayout gl = new GridLayout( 1, false );
+            composite.setLayout( gl );
+            composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+
+            setControl( composite );
+        }
+    }
+
+
+    public boolean performCancel()
+    {
+        if ( this.selectedConnection != null && this.selectedConnection.isOpened() )
+        {
+            EventRegistry.suspendEventFireingInCurrentThread();
+            this.selectedConnection.reset();
+            EventRegistry.resumeEventFireingInCurrentThread();
+            this.selectedConnection.reset();
+        }
+
+        return true;
+    }
+
+
+    public boolean performFinish()
+    {
+        if ( this.selectedConnection != null && this.selectedConnection.isOpened() )
+        {
+            this.typePage.saveDialogSettings();
+            this.ocPage.saveDialogSettings();
+            this.dnPage.saveDialogSettings();
+
+            this.getSelectedConnection().reset();
+
+            CreateEntryJob job = new CreateEntryJob( new IEntry[]
+                { this.getNewEntry() } );
+            RunnableContextJobAdapter.execute( job, getContainer() );
+
+            if ( !job.getExternalResult().isOK() )
+            {
+                this.getSelectedConnection().suspend();
+                return false;
+            }
+            else
+            {
+                return true;
+            }
+        }
+        else
+        {
+            return true;
+        }
+    }
+
+
+    public IEntry getSelectedEntry()
+    {
+        return selectedEntry;
+    }
+
+
+    public IConnection getSelectedConnection()
+    {
+        return selectedConnection;
+    }
+
+
+    public DummyEntry getNewEntry()
+    {
+        return newEntry;
+    }
+
+
+    public void setNewEntry( DummyEntry newEntry )
+    {
+        this.newEntry = newEntry;
+    }
+
+}



Mime
View raw message