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

svn commit: r592087 [15/16] - in /directory/sandbox/felixk/studio-ldapbrowser-ui: ./ META-INF/ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/directory/ src/main/java/org/apache/directory/studio/ src...

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewEntryAttributesWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewEntryAttributesWizardPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewEntryAttributesWizardPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewEntryAttributesWizardPage.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,297 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+
+package org.apache.directory.studio.ldapbrowser.ui.wizards;
+
+
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
+import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EntryEditorWidget;
+import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EntryEditorWidgetActionGroup;
+import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EntryEditorWidgetActionGroupWithAttribute;
+import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EntryEditorWidgetConfiguration;
+import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EntryEditorWidgetUniversalListener;
+import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.OpenDefaultEditorAction;
+import org.apache.directory.studio.ldapbrowser.core.events.EntryModificationEvent;
+import org.apache.directory.studio.ldapbrowser.core.events.EntryUpdateListener;
+import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.ldapbrowser.core.model.impl.Attribute;
+import org.apache.directory.studio.ldapbrowser.core.model.impl.DummyEntry;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.eclipse.jface.viewers.StructuredSelection;
+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.PlatformUI;
+import org.eclipse.ui.contexts.IContextActivation;
+import org.eclipse.ui.contexts.IContextService;
+
+
+/**
+ * The NewEntryAttributesWizardPage is used to fill the attributes of
+ * the new entry.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NewEntryAttributesWizardPage extends WizardPage implements EntryUpdateListener
+{
+
+    /** The wizard. */
+    private NewEntryWizard wizard;
+
+    /** The configuration. */
+    private EntryEditorWidgetConfiguration configuration;
+
+    /** The action group. */
+    private EntryEditorWidgetActionGroup actionGroup;
+
+    /** The main widget. */
+    private EntryEditorWidget mainWidget;
+
+    /** The universal listener. */
+    private EntryEditorWidgetUniversalListener universalListener;
+
+    /** Token used to activate and deactivate shortcuts in the editor */
+    private IContextActivation contextActivation;
+
+
+    /**
+     * Creates a new instance of NewEntryAttributesWizardPage.
+     *
+     * @param pageName the page name
+     * @param wizard the wizard
+     */
+    public NewEntryAttributesWizardPage( String pageName, NewEntryWizard wizard )
+    {
+        super( pageName );
+        setTitle( "Attributes" );
+        setDescription( "Please enter the attributes for the entry. Enter at least the MUST attributes." );
+        setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_ENTRY_WIZARD ) );
+        setPageComplete( false );
+
+        this.wizard = wizard;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose()
+    {
+        if ( configuration != null )
+        {
+            EventRegistry.removeEntryUpdateListener( this );
+            universalListener.dispose();
+            universalListener = null;
+            mainWidget.dispose();
+            mainWidget = null;
+            actionGroup.dispose();
+            actionGroup = null;
+            configuration.dispose();
+            configuration = null;
+
+            if ( contextActivation != null )
+            {
+                IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter(
+                    IContextService.class );
+                contextService.deactivateContext( contextActivation );
+                contextActivation = null;
+            }
+        }
+        super.dispose();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     *
+     * This implementation initializes the must attributes of the
+     * protoype entry and initializes the entry widget when this
+     * page becomes visible.
+     */
+    public void setVisible( boolean visible )
+    {
+        super.setVisible( visible );
+
+        if ( visible )
+        {
+            DummyEntry newEntry = wizard.getPrototypeEntry();
+            IValue editValue = null;
+
+            try
+            {
+                EventRegistry.suspendEventFireingInCurrentThread();
+
+                // remove empty must attributes
+                // necessary when navigating back, modifying object classes
+                // and DN and navigation forward again.
+                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] );
+                            }
+                        }
+                        if ( attribute.getValueSize() == 0 )
+                        {
+                            newEntry.deleteAttribute( attribute );
+                        }
+                    }
+                }
+
+                // 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 );
+                        att.addEmptyValue();
+
+                        if ( editValue == null )
+                        {
+                            editValue = att.getValues()[0];
+                        }
+                    }
+                }
+            }
+            finally
+            {
+                EventRegistry.resumeEventFireingInCurrentThread();
+            }
+
+            // set the input
+            mainWidget.getViewer().setInput( newEntry );
+            mainWidget.getViewer().refresh();
+            validate();
+
+            // set focus to the viewer
+            mainWidget.getViewer().getControl().setFocus();
+
+            // start editing if there is an empty value
+            if ( editValue != null )
+            {
+                mainWidget.getViewer().setSelection( new StructuredSelection( editValue ), true );
+                OpenDefaultEditorAction openDefaultEditorAction = actionGroup.getOpenDefaultEditorAction();
+                if ( openDefaultEditorAction.isEnabled() )
+                {
+                    openDefaultEditorAction.run();
+                }
+            }
+        }
+        else
+        {
+            mainWidget.getViewer().setInput( "" );
+            mainWidget.getViewer().refresh();
+            setPageComplete( false );
+        }
+    }
+
+
+    /**
+     * Checks if the prototype entry is completed.
+     */
+    private void validate()
+    {
+        if ( wizard.getPrototypeEntry() != null && wizard.getPrototypeEntry().isConsistent() )
+        {
+            setPageComplete( true );
+        }
+        else
+        {
+            setPageComplete( false );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    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
+        configuration = new EntryEditorWidgetConfiguration();
+
+        // create main widget
+        mainWidget = new EntryEditorWidget( this.configuration );
+        mainWidget.createWidget( composite );
+        mainWidget.getViewer().getTree().setFocus();
+
+        // create actions
+        actionGroup = new EntryEditorWidgetActionGroupWithAttribute( mainWidget, configuration );
+        actionGroup.fillToolBar( mainWidget.getToolBarManager() );
+        actionGroup.fillMenu( mainWidget.getMenuManager() );
+        actionGroup.fillContextMenu( mainWidget.getContextMenuManager() );
+        IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter(
+            IContextService.class );
+        contextActivation = contextService.activateContext( BrowserCommonConstants.CONTEXT_DIALOGS );
+        actionGroup.activateGlobalActionHandlers();
+
+        // create the listener
+        universalListener = new EntryEditorWidgetUniversalListener( mainWidget.getViewer(), actionGroup
+            .getOpenDefaultEditorAction() );
+        EventRegistry.addEntryUpdateListener( this, BrowserCommonActivator.getDefault().getEventRunner() );
+
+        setControl( composite );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void entryUpdated( EntryModificationEvent event )
+    {
+        if ( event.getModifiedEntry() == wizard.getPrototypeEntry() && !isDisposed() && getControl().isVisible() )
+        {
+            validate();
+        }
+    }
+
+
+    /**
+     * Checks if is disposed.
+     *
+     * @return true, if is disposed
+     */
+    private boolean isDisposed()
+    {
+        return configuration == null;
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewEntryDnWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewEntryDnWizardPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewEntryDnWizardPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewEntryDnWizardPage.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,323 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.ui.wizards;
+
+
+import java.util.Arrays;
+import java.util.Iterator;
+
+import org.apache.directory.shared.ldap.name.AttributeTypeAndValue;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.name.Rdn;
+import org.apache.directory.studio.ldapbrowser.common.jobs.RunnableContextJobAdapter;
+import org.apache.directory.studio.ldapbrowser.common.widgets.DnBuilderWidget;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyEvent;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyListener;
+import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
+import org.apache.directory.studio.ldapbrowser.core.jobs.ReadEntryJob;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.ldapbrowser.core.model.impl.Attribute;
+import org.apache.directory.studio.ldapbrowser.core.model.impl.DummyEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.impl.Value;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.Subschema;
+import org.apache.directory.studio.ldapbrowser.core.utils.DnUtils;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.widgets.Composite;
+
+
+/**
+ * The NewEntryDnWizardPage is used to compose the new entry's 
+ * distinguished name.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NewEntryDnWizardPage extends WizardPage implements WidgetModifyListener
+{
+
+    /** The wizard. */
+    private NewEntryWizard wizard;
+
+    /** The DN builder widget. */
+    private DnBuilderWidget dnBuilderWidget;
+
+
+    /**
+     * Creates a new instance of NewEntryDnWizardPage.
+     * 
+     * @param pageName the page name
+     * @param wizard the wizard
+     */
+    public NewEntryDnWizardPage( String pageName, NewEntryWizard wizard )
+    {
+        super( pageName );
+        setTitle( "Distinguished Name" );
+        setDescription( "Please select the parent of the new entry and enter the RDN." );
+        setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_ENTRY_WIZARD ) );
+        setPageComplete( false );
+
+        this.wizard = wizard;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose()
+    {
+        if ( dnBuilderWidget != null )
+        {
+            dnBuilderWidget.removeWidgetModifyListener( this );
+            dnBuilderWidget.dispose();
+            dnBuilderWidget = null;
+        }
+        super.dispose();
+    }
+
+
+    /**
+     * Validates the input fields.
+     */
+    private void validate()
+    {
+        if ( dnBuilderWidget.getRdn() != null && dnBuilderWidget.getParentDn() != null )
+        {
+            setPageComplete( true );
+            saveState();
+        }
+        else
+        {
+            setPageComplete( false );
+        }
+    }
+
+
+    /**
+     * Initializes the DN builder widget with the DN of 
+     * the prototype entry. Called when this page becomes visible.
+     */
+    private void loadState()
+    {
+        DummyEntry newEntry = wizard.getPrototypeEntry();
+
+        Subschema subschema = newEntry.getSubschema();
+        String[] attributeNames = subschema.getAllAttributeNames();
+
+        LdapDN parentDn = null;
+        if ( DnUtils.getParent( newEntry.getDn() ) != null )
+        {
+            parentDn = DnUtils.getParent( newEntry.getDn() );
+        }
+        else if ( wizard.getSelectedEntry() != null )
+        {
+            parentDn = wizard.getSelectedEntry().getDn();
+        }
+
+        Rdn rdn = newEntry.getRdn();
+
+        dnBuilderWidget.setInput( wizard.getSelectedConnection(), attributeNames, rdn, parentDn );
+    }
+
+
+    /**
+     * Saves the DN of the DN builder widget to the prototype entry.
+     */
+    private void saveState()
+    {
+        DummyEntry newEntry = wizard.getPrototypeEntry();
+
+        try
+        {
+            EventRegistry.suspendEventFireingInCurrentThread();
+
+            // remove old RDN
+            if( newEntry.getRdn().size() > 0 )
+            {
+                Iterator<AttributeTypeAndValue> atavIterator = newEntry.getRdn().iterator();
+                while(atavIterator.hasNext())
+                {
+                    AttributeTypeAndValue atav = atavIterator.next();
+                    IAttribute attribute = newEntry.getAttribute( atav.getUpType() );
+                    if ( attribute != null )
+                    {
+                        IValue[] values = attribute.getValues();
+                        for ( int v = 0; v < values.length; v++ )
+                        {
+                            if ( values[v].getStringValue().equals( atav.getUpValue() ) )
+                            {
+                                attribute.deleteValue( values[v] );
+                            }
+                        }
+                    }
+                }
+            }
+
+            // set new DN
+            LdapDN dn = DnUtils.composeDn( dnBuilderWidget.getRdn(), dnBuilderWidget.getParentDn() );
+            newEntry.setDn( dn );
+
+            // add new RDN
+            if( dn.getRdn().size() > 0 )
+            {
+                Iterator<AttributeTypeAndValue> atavIterator = dn.getRdn().iterator();
+                while(atavIterator.hasNext())
+                {
+                    AttributeTypeAndValue atav = atavIterator.next();
+                    IAttribute rdnAttribute = newEntry.getAttribute( atav.getUpType() );
+                    if ( rdnAttribute == null )
+                    {
+                        rdnAttribute = new Attribute( newEntry, atav.getUpType() );
+                        newEntry.addAttribute( rdnAttribute );
+                    }
+                    Object rdnValue = atav.getUpValue();
+                    String[] stringValues = rdnAttribute.getStringValues();
+                    if ( !Arrays.asList( stringValues ).contains( rdnValue ) )
+                    {
+                        rdnAttribute.addValue( new Value( rdnAttribute, rdnValue ) );
+                    }
+                }
+            }
+
+        }
+        finally
+        {
+            EventRegistry.resumeEventFireingInCurrentThread();
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation initializes DN builder widghet with the
+     * DN of the protoype entry.
+     */
+    public void setVisible( boolean visible )
+    {
+        super.setVisible( visible );
+
+        if ( visible )
+        {
+            loadState();
+            validate();
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation just checks if this page is complete. It 
+     * doesn't call {@link #getNextPage()} to avoid unneeded 
+     * invokings of {@link ReadEntryJob}s.
+     */
+    public boolean canFlipToNextPage()
+    {
+        return isPageComplete();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation invokes a {@link ReadEntryJob} to check if an
+     * entry with the composed DN already exists.
+     */
+    public IWizardPage getNextPage()
+    {
+        dnBuilderWidget.validate();
+        
+        Rdn rdn = dnBuilderWidget.getRdn();
+        LdapDN parentDn = dnBuilderWidget.getParentDn();
+        final LdapDN dn = DnUtils.composeDn( rdn, parentDn );
+
+        // check if parent exists or new entry already exists
+        ReadEntryJob readEntryJob1 = new ReadEntryJob( wizard.getSelectedConnection(), parentDn );
+        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();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void createControl( Composite parent )
+    {
+        dnBuilderWidget = new DnBuilderWidget( true, true );
+        dnBuilderWidget.addWidgetModifyListener( this );
+        Composite composite = dnBuilderWidget.createContents( parent );
+
+        setControl( composite );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void widgetModified( WidgetModifyEvent event )
+    {
+        validate();
+    }
+
+
+    /**
+     * Saves the dialogs settings.
+     */
+    public void saveDialogSettings()
+    {
+        dnBuilderWidget.saveDialogSettings();
+    }
+
+}
\ No newline at end of file

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewEntryObjectclassWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewEntryObjectclassWizardPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewEntryObjectclassWizardPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewEntryObjectclassWizardPage.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,577 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.ui.wizards;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.ldapbrowser.core.model.impl.Attribute;
+import org.apache.directory.studio.ldapbrowser.core.model.impl.DummyEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.impl.Value;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.ObjectClassDescription;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.eclipse.jface.fieldassist.DecoratedField;
+import org.eclipse.jface.fieldassist.FieldDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
+import org.eclipse.jface.fieldassist.IControlCreator;
+import org.eclipse.jface.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.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+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.Label;
+import org.eclipse.swt.widgets.Text;
+
+
+/**
+ * The NewEntryTypeWizardPage is used to select the entry's object classes.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NewEntryObjectclassWizardPage extends WizardPage
+{
+
+    /** The Constant SIZING_SELECTION_WIDGET_HEIGHT. */
+    private final static int SIZING_SELECTION_WIDGET_HEIGHT = 250;
+
+    /** The Constant SIZING_SELECTION_WIDGET_WIDTH. */
+    private final static int SIZING_SELECTION_WIDGET_WIDTH = 400;
+
+    /** The wizard. */
+    private NewEntryWizard wizard;
+
+    /** The available object classes. */
+    private List<ObjectClassDescription> availableObjectClasses;
+
+    /** The available object classes instant search. */
+    private Text availableObjectClassesInstantSearch;
+
+    /** The available object classes viewer. */
+    private TableViewer availableObjectClassesViewer;
+
+    /** The selected object classes. */
+    private List<ObjectClassDescription> selectedObjectClasses;
+
+    /** The selected object classes viewer. */
+    private TableViewer selectedObjectClassesViewer;
+
+    /** The add button. */
+    private Button addButton;
+
+    /** The remove button. */
+    private Button removeButton;
+
+    private LabelProvider labelProvider = new LabelProvider()
+    {
+        /* (non-Javadoc)
+         * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
+         */
+        public Image getImage( Object element )
+        {
+            if ( element instanceof ObjectClassDescription )
+            {
+                ObjectClassDescription ocd = ( ObjectClassDescription ) element;
+
+                if ( ocd.isAbstract() )
+                {
+                    return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_OCD_ABSTRACT )
+                        .createImage();
+                }
+                else if ( ocd.isAuxiliary() )
+                {
+                    return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_OCD_AUXILIARY )
+                        .createImage();
+                }
+                else if ( ocd.isStructural() )
+                {
+                    return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_OCD_STRUCTURAL )
+                        .createImage();
+                }
+                else
+                {
+                    return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_OCD ).createImage();
+                }
+            }
+
+            // Default
+            return super.getImage( element );
+        }
+    };
+
+
+    /**
+     * Creates a new instance of NewEntryObjectclassWizardPage.
+     * 
+     * @param pageName the page name
+     * @param wizard the wizard
+     */
+    public NewEntryObjectclassWizardPage( String pageName, NewEntryWizard wizard )
+    {
+        super( pageName );
+        setTitle( "Object Classes" );
+        setDescription( "Please select object classes of the new entry. Select at least one structural object class." );
+        setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_ENTRY_WIZARD ) );
+        setPageComplete( false );
+
+        this.wizard = wizard;
+        this.availableObjectClasses = new ArrayList<ObjectClassDescription>();
+        this.selectedObjectClasses = new ArrayList<ObjectClassDescription>();
+    }
+
+
+    /**
+     * Validates the input fields.
+     */
+    private void validate()
+    {
+        if ( !selectedObjectClasses.isEmpty() )
+        {
+            boolean hasOneStructuralOC = false;
+            for ( ObjectClassDescription ocd : selectedObjectClasses )
+            {
+                if ( ocd.isStructural() )
+                {
+                    hasOneStructuralOC = true;
+                    break;
+                }
+            }
+            if ( !hasOneStructuralOC )
+            {
+                setMessage( "Please select at least one structural object class.", WizardPage.WARNING );
+            }
+            else
+            {
+                setMessage( null );
+            }
+
+            setPageComplete( true );
+            saveState();
+        }
+        else
+        {
+            setPageComplete( false );
+            setMessage( null );
+        }
+    }
+
+
+    /**
+     * Loads the state of selected and available object classes from
+     * the prototype entry. Called when this page becomes visible.
+     */
+    private void loadState()
+    {
+        availableObjectClasses.clear();
+        selectedObjectClasses.clear();
+
+        if ( wizard.getSelectedConnection() != null )
+        {
+            //            if ( !wizard.getSelectedConnection().isOpened() )
+            //            {
+            //                OpenConnectionsJob job = new OpenConnectionsJob( wizard.getSelectedConnection().getConnection() );
+            //                RunnableContextJobAdapter.execute( job, getContainer() );
+            //            }
+
+            availableObjectClasses.addAll( Arrays.asList( wizard.getSelectedConnection().getSchema()
+                .getObjectClassDescriptions() ) );
+
+            DummyEntry newEntry = wizard.getPrototypeEntry();
+            IAttribute ocAttribute = newEntry.getAttribute( IAttribute.OBJECTCLASS_ATTRIBUTE );
+            if ( ocAttribute != null )
+            {
+                String[] ocValues = ocAttribute.getStringValues();
+                for ( int i = 0; i < ocValues.length; i++ )
+                {
+                    String ocValue = ocValues[i];
+                    ObjectClassDescription ocd = wizard.getSelectedConnection().getSchema().getObjectClassDescription(
+                        ocValue );
+                    availableObjectClasses.remove( ocd );
+                    selectedObjectClasses.add( ocd );
+                }
+            }
+        }
+
+        availableObjectClassesViewer.refresh();
+        selectedObjectClassesViewer.refresh();
+    }
+
+
+    /**
+     * Saves the state of selected object classes to the entry.
+     */
+    private void saveState()
+    {
+        DummyEntry newEntry = wizard.getPrototypeEntry();
+
+        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 );
+            }
+            IValue[] values = ocAttribute.getValues();
+            for ( int i = 0; i < values.length; i++ )
+            {
+                ocAttribute.deleteValue( values[i] );
+            }
+            for ( Iterator<ObjectClassDescription> it = selectedObjectClasses.iterator(); it.hasNext(); )
+            {
+                ObjectClassDescription ocd = it.next();
+                ocAttribute.addValue( new Value( ocAttribute, ocd.getNames()[0] ) );
+            }
+        }
+        finally
+        {
+            EventRegistry.resumeEventFireingInCurrentThread();
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation initializes the list of available and selected
+     * object classes when this page becomes visible.
+     */
+    public void setVisible( boolean visible )
+    {
+        super.setVisible( visible );
+
+        if ( visible )
+        {
+            loadState();
+            validate();
+            availableObjectClassesInstantSearch.setFocus();
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    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" );
+
+        Composite availableObjectClassesComposite = BaseWidgetUtils.createColumnContainer( composite, 1, 1 );
+
+        if ( FieldDecorationRegistry.getDefault().getFieldDecoration( getClass().getName() ) == null )
+        {
+            FieldDecoration dummy = FieldDecorationRegistry.getDefault().getFieldDecoration(
+                FieldDecorationRegistry.DEC_CONTENT_PROPOSAL );
+            FieldDecorationRegistry.getDefault().registerFieldDecoration( getClass().getName(),
+                "You may enter a filter to restrict the list below", dummy.getImage() );
+        }
+        final FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(
+            getClass().getName() );
+        final DecoratedField availabeObjectClassesInstantSearchField = new DecoratedField(
+            availableObjectClassesComposite, SWT.BORDER, new IControlCreator()
+            {
+                public Control createControl( Composite parent, int style )
+                {
+                    return BaseWidgetUtils.createText( parent, "", 1 );
+                }
+            } );
+        availabeObjectClassesInstantSearchField.addFieldDecoration( fieldDecoration, SWT.TOP | SWT.LEFT, true );
+        availabeObjectClassesInstantSearchField.getLayoutControl().setLayoutData(
+            new GridData( SWT.FILL, SWT.CENTER, true, false ) );
+        availableObjectClassesInstantSearch = ( Text ) availabeObjectClassesInstantSearchField.getControl();
+        availableObjectClassesInstantSearch.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                availableObjectClassesViewer.refresh();
+                if ( availableObjectClassesViewer.getTable().getItemCount() >= 1 )
+                {
+                    Object item = availableObjectClassesViewer.getElementAt( 0 );
+                    availableObjectClassesViewer.setSelection( new StructuredSelection( item ) );
+                }
+            }
+        } );
+        availableObjectClassesInstantSearch.addKeyListener( new KeyAdapter()
+        {
+            public void keyPressed( KeyEvent e )
+            {
+                if ( e.keyCode == SWT.ARROW_DOWN )
+                {
+                    availableObjectClassesViewer.getTable().setFocus();
+                }
+            }
+        } );
+
+        availableObjectClassesViewer = new TableViewer( availableObjectClassesComposite );
+        GridData data = new GridData( GridData.FILL_BOTH );
+        data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT;
+        data.widthHint = ( int ) ( SIZING_SELECTION_WIDGET_WIDTH * 0.4 );
+        availableObjectClassesViewer.getTable().setLayoutData( data );
+        availableObjectClassesViewer.setContentProvider( new ArrayContentProvider() );
+        availableObjectClassesViewer.setLabelProvider( labelProvider );
+        availableObjectClassesViewer.setSorter( new ViewerSorter() );
+        availableObjectClassesViewer.addFilter( new InstantSearchFilter( availableObjectClassesInstantSearch ) );
+        availableObjectClassesViewer.setInput( availableObjectClasses );
+        availableObjectClassesViewer.addDoubleClickListener( new IDoubleClickListener()
+        {
+            public void doubleClick( DoubleClickEvent event )
+            {
+                add( event.getSelection() );
+            }
+        } );
+        availableObjectClassesViewer.getTable().addKeyListener( new KeyAdapter()
+        {
+            public void keyPressed( KeyEvent e )
+            {
+                if ( e.keyCode == SWT.ARROW_UP )
+                {
+                    if ( availableObjectClassesViewer.getTable().getSelectionIndex() <= 0 )
+                    {
+                        availableObjectClassesInstantSearch.setFocus();
+                    }
+                }
+            }
+        } );
+
+        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 TableViewer( composite );
+        data = new GridData( GridData.FILL_BOTH );
+        data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT;
+        data.widthHint = ( int ) ( SIZING_SELECTION_WIDGET_WIDTH * 0.4 );
+        selectedObjectClassesViewer.getTable().setLayoutData( data );
+        selectedObjectClassesViewer.setContentProvider( new ArrayContentProvider() );
+        selectedObjectClassesViewer.setLabelProvider( labelProvider );
+        selectedObjectClassesViewer.setSorter( new ViewerSorter() );
+        selectedObjectClassesViewer.setInput( selectedObjectClasses );
+        selectedObjectClassesViewer.addDoubleClickListener( new IDoubleClickListener()
+        {
+            public void doubleClick( DoubleClickEvent event )
+            {
+                remove( event.getSelection() );
+            }
+        } );
+
+        setControl( composite );
+    }
+
+
+    /**
+     * Adds the selected object classes to the list of selected 
+     * object classes.
+     * 
+     * @param iselection the selection
+     */
+    private void add( ISelection iselection )
+    {
+        IStructuredSelection selection = ( IStructuredSelection ) iselection;
+        Iterator it = selection.iterator();
+        while ( it.hasNext() )
+        {
+            ObjectClassDescription ocd = ( ObjectClassDescription ) it.next();
+            if ( availableObjectClasses.contains( ocd ) && !selectedObjectClasses.contains( ocd ) )
+            {
+                availableObjectClasses.remove( ocd );
+                selectedObjectClasses.add( ocd );
+
+                // recursively add superior object classes
+                ObjectClassDescription[] superiorObjectClassDescriptions = ocd.getSuperiorObjectClassDescriptions();
+                if ( superiorObjectClassDescriptions.length > 0 )
+                {
+                    add( new StructuredSelection( superiorObjectClassDescriptions ) );
+                }
+            }
+        }
+
+        availableObjectClassesViewer.refresh();
+        selectedObjectClassesViewer.refresh();
+        validate();
+
+        if ( !"".equals( availableObjectClassesInstantSearch.getText() ) )
+        {
+            availableObjectClassesInstantSearch.setText( "" );
+            availableObjectClassesInstantSearch.setFocus();
+        }
+    }
+
+
+    /**
+     * Removes the selected object classes from the list of selected
+     * object classes.
+     * 
+     * @param iselection the iselection
+     */
+    private void remove( ISelection iselection )
+    {
+        IStructuredSelection selection = ( IStructuredSelection ) iselection;
+        Iterator it = selection.iterator();
+        while ( it.hasNext() )
+        {
+            ObjectClassDescription ocd = ( ObjectClassDescription ) it.next();
+            if ( !availableObjectClasses.contains( ocd ) && selectedObjectClasses.contains( ocd ) )
+            {
+                selectedObjectClasses.remove( ocd );
+                availableObjectClasses.add( ocd );
+
+                // recursively remove sub object classes
+                ObjectClassDescription[] subObjectClassDescriptions = ocd.getSubObjectClassDescriptions();
+                if ( subObjectClassDescriptions.length > 0 )
+                {
+                    remove( new StructuredSelection( subObjectClassDescriptions ) );
+                }
+            }
+        }
+
+        availableObjectClassesViewer.refresh();
+        selectedObjectClassesViewer.refresh();
+        validate();
+    }
+
+
+    /**
+     * Saves dialog settings.
+     */
+    public void saveDialogSettings()
+    {
+
+    }
+
+    /**
+     * The Class InstantSearchFilter.
+     */
+    private class InstantSearchFilter extends ViewerFilter
+    {
+
+        /** The filter text. */
+        private Text filterText;
+
+
+        /**
+         * Creates a new instance of InstantSearchFilter.
+         * 
+         * @param filterText the filter text
+         */
+        private InstantSearchFilter( Text filterText )
+        {
+            this.filterText = filterText;
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public boolean select( Viewer viewer, Object parentElement, Object element )
+        {
+            if ( element instanceof ObjectClassDescription )
+            {
+                ObjectClassDescription ocd = ( ObjectClassDescription ) element;
+                Set<String> lowerCaseIdentifierSet = ocd.getLowerCaseIdentifierSet();
+                for ( Iterator<String> it = lowerCaseIdentifierSet.iterator(); it.hasNext(); )
+                {
+                    String s = it.next();
+                    if ( s.toLowerCase().startsWith( filterText.getText().toLowerCase() ) )
+                    {
+                        return true;
+                    }
+                }
+            }
+            return false;
+        }
+    }
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewEntryTypeWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewEntryTypeWizardPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewEntryTypeWizardPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewEntryTypeWizardPage.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,299 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.ui.wizards;
+
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.studio.ldapbrowser.common.jobs.RunnableContextJobAdapter;
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyEvent;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyListener;
+import org.apache.directory.studio.ldapbrowser.common.widgets.search.EntryWidget;
+import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
+import org.apache.directory.studio.ldapbrowser.core.jobs.InitializeAttributesJob;
+import org.apache.directory.studio.ldapbrowser.core.jobs.ReadEntryJob;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.impl.DummyConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.impl.DummyEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.container.LdifContentRecord;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils;
+import org.apache.directory.studio.ldapbrowser.core.utils.ModelConverter;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+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;
+
+
+/**
+ * The NewEntryTypeWizardPage is used to choose the entry creation method.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NewEntryTypeWizardPage extends WizardPage implements WidgetModifyListener, SelectionListener
+{
+
+    /** The Constant PREFERRED_ENTRY_CREATION_METHOD_DIALOGSETTING_KEY. */
+    public static final String PREFERRED_ENTRY_CREATION_METHOD_DIALOGSETTING_KEY = NewEntryTypeWizardPage.class
+        .getName()
+        + ".preferredEntryCreationMethod";
+
+    /** The wizard. */
+    private NewEntryWizard wizard;
+
+    /** The schema button. */
+    private Button schemaButton;
+
+    /** The template button. */
+    private Button templateButton;
+
+    /** The entry widget to select the template entry. */
+    private EntryWidget entryWidget;
+
+
+    /**
+     * Creates a new instance of NewEntryTypeWizardPage.
+     * 
+     * @param pageName the page name
+     * @param wizard the wizard
+     */
+    public NewEntryTypeWizardPage( String pageName, NewEntryWizard wizard )
+    {
+        super( pageName );
+        setTitle( "Entry Creation Method" );
+        setDescription( "Please select the entry creation method." );
+        setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_ENTRY_WIZARD ) );
+        setPageComplete( false );
+
+        this.wizard = wizard;
+    }
+
+
+    /**
+     * Validates the input fields.
+     */
+    private void validate()
+    {
+        if ( schemaButton.getSelection() )
+        {
+            setPageComplete( true );
+        }
+        else if ( templateButton.getSelection() )
+        {
+            setPageComplete( entryWidget.getBrowserConnection() != null && entryWidget.getDn() != null );
+        }
+        else
+        {
+            setPageComplete( false );
+        }
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation just checks if this page is complete. IIt 
+     * doesn't call {@link #getNextPage()} to avoid unneeded 
+     * creations of new prototype entries.
+     */
+    public boolean canFlipToNextPage()
+    {
+        return isPageComplete();
+    }
+    
+
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation creates the prototype entry depending on the 
+     * selected entry creation method before flipping to the next page.
+     */
+    public IWizardPage getNextPage()
+    {
+        if ( templateButton.getSelection() )
+        {
+            final IBrowserConnection browserConnection = entryWidget.getBrowserConnection();
+            final LdapDN dn = entryWidget.getDn();
+            final IEntry[] templateEntries = new IEntry[1];
+
+            if ( browserConnection == 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( browserConnection, 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 prototypeEntry = ModelConverter.ldifContentRecordToEntry( record, new DummyConnection( browserConnection.getSchema() ) );
+                IAttribute[] attributes = prototypeEntry.getAttributes();
+                for ( int i = 0; i < attributes.length; i++ )
+                {
+                    if ( !SchemaUtils.isModifyable( attributes[i].getAttributeTypeDescription() ) )
+                    {
+                        prototypeEntry.deleteAttribute( attributes[i] );
+                    }
+                }
+                wizard.setPrototypeEntry( prototypeEntry );
+            }
+            catch ( Exception e )
+            {
+                e.printStackTrace();
+            }
+            finally
+            {
+                EventRegistry.resumeEventFireingInCurrentThread();
+            }
+        }
+        else
+        {
+            wizard.setPrototypeEntry( new DummyEntry( new LdapDN(), new DummyConnection( wizard.getSelectedConnection().getSchema() ) ) );
+        }
+
+        return super.getNextPage();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    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( wizard.getSelectedConnection(), wizard.getSelectedEntry() != null ? 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 );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void widgetModified( WidgetModifyEvent event )
+    {
+        validate();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void widgetDefaultSelected( SelectionEvent e )
+    {
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void widgetSelected( SelectionEvent e )
+    {
+        entryWidget.setEnabled( templateButton.getSelection() );
+        validate();
+    }
+
+
+    /**
+     * Saves the dialog settings.
+     */
+    public void saveDialogSettings()
+    {
+        BrowserUIPlugin.getDefault().getDialogSettings().put( PREFERRED_ENTRY_CREATION_METHOD_DIALOGSETTING_KEY,
+            schemaButton.getSelection() );
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewEntryWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewEntryWizard.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewEntryWizard.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewEntryWizard.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,365 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.ui.wizards;
+
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.studio.ldapbrowser.common.jobs.RunnableContextJobAdapter;
+import org.apache.directory.studio.ldapbrowser.common.widgets.browser.BrowserCategory;
+import org.apache.directory.studio.ldapbrowser.common.widgets.browser.BrowserEntryPage;
+import org.apache.directory.studio.ldapbrowser.common.widgets.browser.BrowserSearchResultPage;
+import org.apache.directory.studio.ldapbrowser.core.jobs.CreateEntryJob;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.IBookmark;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.ldapbrowser.core.model.impl.DummyConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.impl.DummyEntry;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+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;
+
+
+/**
+ * The NewEntryWizard is used to create a new entry from scratch or by 
+ * using another entry as template.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NewEntryWizard extends Wizard implements INewWizard
+{
+
+    /** The type page. */
+    private NewEntryTypeWizardPage typePage;
+
+    /** The object class page. */
+    private NewEntryObjectclassWizardPage ocPage;
+
+    /** The dn page. */
+    private NewEntryDnWizardPage dnPage;
+
+    /** The attributes page. */
+    private NewEntryAttributesWizardPage attributePage;
+
+    /** The selected entry. */
+    private IEntry selectedEntry;
+
+    /** The selected connection. */
+    private IBrowserConnection selectedConnection;
+
+    /** The prototype entry. */
+    private DummyEntry prototypeEntry;
+
+
+    /**
+     * Creates a new instance of NewEntryWizard.
+     */
+    public NewEntryWizard()
+    {
+        setWindowTitle( "New Entry" );
+        setNeedsProgressMonitor( true );
+    }
+
+
+    /**
+     * Gets the id.
+     * 
+     * @return the id
+     */
+    public static String getId()
+    {
+        return NewEntryWizard.class.getName();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void init( IWorkbench workbench, IStructuredSelection selection )
+    {
+        // determine the currently selected entry
+        Object o = selection.getFirstElement();
+        if ( o instanceof IEntry )
+        {
+            selectedEntry = ( ( IEntry ) o );
+            selectedConnection = selectedEntry.getBrowserConnection();
+        }
+        else if ( o instanceof ISearchResult )
+        {
+            selectedEntry = ( ( ISearchResult ) o ).getEntry();
+            selectedConnection = selectedEntry.getBrowserConnection();
+        }
+        else if ( o instanceof IBookmark )
+        {
+            selectedEntry = ( ( IBookmark ) o ).getEntry();
+            selectedConnection = selectedEntry.getBrowserConnection();
+        }
+        else if ( o instanceof IAttribute )
+        {
+            selectedEntry = ( ( IAttribute ) o ).getEntry();
+            selectedConnection = selectedEntry.getBrowserConnection();
+        }
+        else if ( o instanceof IValue )
+        {
+            selectedEntry = ( ( IValue ) o ).getAttribute().getEntry();
+            selectedConnection = selectedEntry.getBrowserConnection();
+        }
+        else if ( o instanceof ISearch )
+        {
+            selectedEntry = null;
+            selectedConnection = ( ( ISearch ) o ).getBrowserConnection();
+        }
+        else if ( o instanceof IBrowserConnection )
+        {
+            selectedEntry = null;
+            selectedConnection = ( IBrowserConnection ) o;
+        }
+        else if ( o instanceof BrowserCategory )
+        {
+            selectedEntry = null;
+            selectedConnection = ( ( BrowserCategory ) o ).getParent();
+        }
+        else if ( o instanceof BrowserSearchResultPage )
+        {
+            selectedEntry = null;
+            selectedConnection = ( ( BrowserSearchResultPage ) o ).getSearch().getBrowserConnection();
+        }
+        else if ( o instanceof BrowserEntryPage )
+        {
+            selectedEntry = null;
+            selectedConnection = ( ( BrowserEntryPage ) o ).getEntry().getBrowserConnection();
+        }
+        else
+        {
+            selectedEntry = null;
+            selectedConnection = null;
+        }
+
+        if ( selectedConnection != null )
+        {
+            DummyConnection prototypeConnection = new DummyConnection( selectedConnection.getSchema() ); 
+            prototypeEntry = new DummyEntry( new LdapDN(), prototypeConnection );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addPages()
+    {
+        if ( selectedConnection != null )
+        {
+            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 );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void createPageControls( Composite pageContainer )
+    {
+        super.createPageControls( pageContainer );
+
+        // set help context ID
+        if ( selectedConnection != null )
+        {
+            PlatformUI.getWorkbench().getHelpSystem().setHelp( typePage.getControl(),
+                BrowserUIPlugin.PLUGIN_ID + "." + "tools_newentry_wizard" );
+            PlatformUI.getWorkbench().getHelpSystem().setHelp( ocPage.getControl(),
+                BrowserUIPlugin.PLUGIN_ID + "." + "tools_newentry_wizard" );
+            PlatformUI.getWorkbench().getHelpSystem().setHelp( dnPage.getControl(),
+                BrowserUIPlugin.PLUGIN_ID + "." + "tools_newentry_wizard" );
+            PlatformUI.getWorkbench().getHelpSystem().setHelp( attributePage.getControl(),
+                BrowserUIPlugin.PLUGIN_ID + "." + "tools_newentry_wizard" );
+        }
+    }
+
+    /**
+     * Just a dummy page.
+     *
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     * @version $Rev$, $Date$
+     */
+    class DummyWizardPage extends WizardPage
+    {
+
+        /**
+         * Creates a new instance of DummyWizardPage.
+         */
+        protected DummyWizardPage()
+        {
+            super( "" );
+            setTitle( "No connection selected or connection is closed" );
+            setDescription( "In order to use the entry creation wizard please select an entry or connection." );
+            setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor(
+                BrowserUIConstants.IMG_ENTRY_WIZARD ) );
+            setPageComplete( true );
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        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 );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean performCancel()
+    {
+        if ( selectedConnection != null )
+        {
+//            EventRegistry.suspendEventFireingInCurrentThread();
+//            selectedConnection.reset();
+//            EventRegistry.resumeEventFireingInCurrentThread();
+//            selectedConnection.reset();
+        }
+
+        return true;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean performFinish()
+    {
+        try
+        {
+            if ( selectedConnection != null )
+            {
+                typePage.saveDialogSettings();
+                ocPage.saveDialogSettings();
+                dnPage.saveDialogSettings();
+
+//                getSelectedConnection().reset();
+                
+                CreateEntryJob job = new CreateEntryJob( prototypeEntry, selectedConnection );
+                RunnableContextJobAdapter.execute( job, getContainer() );
+
+                if ( !job.getExternalResult().isOK() )
+                {
+//                    getSelectedConnection().suspend();
+                    return false;
+                }
+                else
+                {
+                    return true;
+                }
+            }
+            else
+            {
+                return true;
+            }
+        }
+        catch ( Throwable t )
+        {
+            t.printStackTrace();
+            return false;
+        }
+    }
+
+
+    /**
+     * Gets the selected entry.
+     * 
+     * @return the selected entry
+     */
+    public IEntry getSelectedEntry()
+    {
+        return selectedEntry;
+    }
+
+
+    /**
+     * Gets the selected connection.
+     * 
+     * @return the selected connection
+     */
+    public IBrowserConnection getSelectedConnection()
+    {
+        return selectedConnection;
+    }
+
+
+    /**
+     * Gets the prototype entry.
+     * 
+     * @return the prototype entry
+     */
+    public DummyEntry getPrototypeEntry()
+    {
+        return prototypeEntry;
+    }
+
+
+    /**
+     * Sets the prototype entry.
+     * 
+     * @param getPrototypeEntry the prototype entry
+     */
+    public void setPrototypeEntry( DummyEntry getPrototypeEntry )
+    {
+        this.prototypeEntry = getPrototypeEntry;
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewSearchWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewSearchWizard.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewSearchWizard.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewSearchWizard.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,93 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.ui.wizards;
+
+
+import org.apache.directory.studio.ldapbrowser.ui.search.SearchPage;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.search.ui.NewSearchUI;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWindow;
+
+
+/**
+ * The NewSearchWizard is used to add a "New Search" action to the platforms
+ * "New..." menu. It just opens the platform's search dialog.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NewSearchWizard extends Wizard implements INewWizard
+{
+
+    /** The window. */
+    private IWorkbenchWindow window;
+
+
+    /**
+     * Creates a new instance of NewSearchWizard.
+     */
+    public NewSearchWizard()
+    {
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void init( IWorkbench workbench, IStructuredSelection selection )
+    {
+        window = workbench.getActiveWorkbenchWindow();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose()
+    {
+        window = null;
+    }
+
+
+    /**
+     * Gets the id.
+     * 
+     * @return the id
+     */
+    public static String getId()
+    {
+        return NewSearchWizard.class.getName();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean performFinish()
+    {
+        NewSearchUI.openSearchDialog( window, SearchPage.getId() );
+        return true;
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/resources/about.html
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/resources/about.html?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/resources/about.html (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/resources/about.html Mon Nov  5 09:01:21 2007
@@ -0,0 +1,35 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html>
+<head>
+<title>About</title>
+<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
+</head>
+<body lang="EN-US">
+<h2>About Apache Directory Studio Browser</h2>
+
+<h3>Copyright</h3>
+
+<p>Copyright (c) 2006 Apache Software Foundation. All rights reserved.</p>
+
+<h3>License</h3>
+
+<p>Apache Directory Studio Browser is provided to you under the terms and conditions of the
+Apache License Version 2.0. A copy of the Apache Licence can be found in <a href="about_files/licence.txt">about_files/license.txt</a>
+and is also available at <a href="http://www.apache.org/licenses/LICENSE-2.0.html</a>.</p>
+
+<h3>Third Party Content</h3>
+
+<p>The Content includes items that have been sourced from third parties as follows:</p>
+
+<h4>Eclipse</h4>
+
+<p>The plug-in is accompanied by software developed by the Eclipse Foundation at
+<a href="http://www.eclipse.org/">http://www.eclipse.org/</a>.
+Parts of Eclipse code, icons and documents are included with the plug-in.
+Your use of Eclipse is subject to the terms and conditions of the Eclipse Public License Version 1.0 (&quot;EPL&quot;).
+A copy of the EPL can be found in <a href="about_files/epl-v10.txt">about_files/epl-v10.txt</a>
+and is also available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+The source code for Eclipse is available at <a href="http://www.eclipse.org/">http://www.eclipse.org/</a>.</p>
+
+</body>
+</html>
\ No newline at end of file

Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/resources/about.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/resources/about_files/epl-v10.txt
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/resources/about_files/epl-v10.txt?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/resources/about_files/epl-v10.txt (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/resources/about_files/epl-v10.txt Mon Nov  5 09:01:21 2007
@@ -0,0 +1,88 @@
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claim
 s or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) a
 nd 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+ 

Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/resources/about_files/epl-v10.txt
------------------------------------------------------------------------------
    svn:eol-style = native