directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r963760 - in /directory/studio/trunk/ldapservers: resources/icons/ src/main/java/org/apache/directory/studio/ldapservers/ src/main/java/org/apache/directory/studio/ldapservers/model/ src/main/java/org/apache/directory/studio/ldapservers/wiz...
Date Tue, 13 Jul 2010 15:26:23 GMT
Author: pamarcelot
Date: Tue Jul 13 15:26:23 2010
New Revision: 963760

URL: http://svn.apache.org/viewvc?rev=963760&view=rev
Log:
Implemented the first wizard page of the NewServerWizard.

Added:
    directory/studio/trunk/ldapservers/resources/icons/folder.gif   (with props)
    directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/LdapServerAdapterExtensionsContentProvider.java
    directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/LdapServerAdapterExtensionsLabelProvider.java
Removed:
    directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/AbstractLdapServerInstance.java
Modified:
    directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/LdapServersPluginConstants.java
    directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServer.java
    directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/NewServerWizard.java
    directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/NewServerWizardPage.java
    directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/messages.properties
    directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/messages_de.properties
    directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/messages_fr.properties

Added: directory/studio/trunk/ldapservers/resources/icons/folder.gif
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/resources/icons/folder.gif?rev=963760&view=auto
==============================================================================
Binary file - no diff available.

Propchange: directory/studio/trunk/ldapservers/resources/icons/folder.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/LdapServersPluginConstants.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/LdapServersPluginConstants.java?rev=963760&r1=963759&r2=963760&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/LdapServersPluginConstants.java
(original)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/LdapServersPluginConstants.java
Tue Jul 13 15:26:23 2010
@@ -38,6 +38,7 @@ public interface LdapServersPluginConsta
     // ------
     // IMAGES
     // ------
+    public static final String IMG_FOLDER = "resources/icons/folder.gif";
     public static final String IMG_SERVER_NEW = "resources/icons/server_new.gif";
     public static final String IMG_SERVER_NEW_WIZARD = "resources/icons/server_new_wizard.png";
     public static final String IMG_SERVER = "resources/icons/server.gif";

Modified: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServer.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServer.java?rev=963760&r1=963759&r2=963760&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServer.java
(original)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServer.java
Tue Jul 13 15:26:23 2010
@@ -21,44 +21,79 @@
 package org.apache.directory.studio.ldapservers.model;
 
 
+import java.util.UUID;
+
+import org.eclipse.core.runtime.IAdaptable;
+
+
 /**
  * The {@link LdapServer} interface defines the required methods
  * to implement an LDAP Server instance.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class LdapServer
+public class LdapServer implements IAdaptable
 {
+    /** The ID of the server */
     private String id;
 
+    /** The name of the server*/
     private String name;
 
+    /** The status of the server */
     private LdapServerStatus status = LdapServerStatus.STOPPED;
 
+    /** The LDAP Server Adapater Extension */
     private LdapServerAdapterExtension ldapServerAdapterExtension;
 
 
-    public void setLdapServerAdapterExtension( LdapServerAdapterExtension ldapServerAdapterExtension
)
+    /**
+     * Creates a new instance of LDAP Server.
+     * <p>
+     * An ID is automatically created.
+     */
+    public LdapServer()
     {
-        this.ldapServerAdapterExtension = ldapServerAdapterExtension;
+        id = createId();
     }
 
 
     /**
-     * Gets the name of the server.
+     * Creates a new instance of LDAP Server.
+     * <p>
+     * An ID is automatically created.
      *
-     * @return
+     * @param name
      *      the name of the server
      */
-    public String getName()
+    public LdapServer( String name )
     {
-        return name;
+        this.name = name;
+        id = createId();
     }
 
 
-    public void setName( String name )
+    /**
+     * Creates a new ID.
+     *
+     * @return
+     *      a new ID
+     */
+    private static String createId()
     {
-        this.name = name;
+        return UUID.randomUUID().toString();
+    }
+
+
+    /**
+     * Adds the {@link LdapServerListener} to the server.
+     *
+     * @param listener
+     *      the listener to be added
+     */
+    public void addListener( LdapServerListener listener )
+    {
+
     }
 
 
@@ -74,12 +109,6 @@ public class LdapServer
     }
 
 
-    public void setId( String id )
-    {
-        this.id = id;
-    }
-
-
     /**
      * Gets the associated {@link LdapServerAdapterExtension}.
      *
@@ -88,19 +117,31 @@ public class LdapServer
      */
     public LdapServerAdapterExtension getLdapServerAdapterExtension()
     {
-        return null;
+        return ldapServerAdapterExtension;
     }
 
 
     /**
-     * Adds the {@link LdapServerListener} to the server.
+     * Gets the name of the server.
      *
-     * @param listener
-     *      the listener to be added
+     * @return
+     *      the name of the server
      */
-    public void addListener( LdapServerListener listener )
+    public String getName()
     {
+        return name;
+    }
+
 
+    /**
+     * Gets the status of the server.
+     *
+     * @return
+     *      the status of the server
+     */
+    public LdapServerStatus getStatus()
+    {
+        return status;
     }
 
 
@@ -117,49 +158,76 @@ public class LdapServer
 
 
     /**
-     * Starts the server.
+     * Restarts the server.
      *
      * @throws Exception
      *      if an error occurs when restarting the server
      */
-    public void start() throws Exception
+    public void restart() throws Exception
     {
 
     }
 
 
     /**
-     * Stops the server.
+     * Sets the ID of the server
+     *
+     * @param id
+     *      the ID of the server
+     */
+    public void setId( String id )
+    {
+        this.id = id;
+    }
+
+
+    public void setLdapServerAdapterExtension( LdapServerAdapterExtension ldapServerAdapterExtension
)
+    {
+        this.ldapServerAdapterExtension = ldapServerAdapterExtension;
+    }
+
+
+    /**
+     * Sets the name of the server
+     *
+     * @param name
+     *      the name of the server
+     */
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+
+    /**
+     * Starts the server.
      *
      * @throws Exception
      *      if an error occurs when restarting the server
      */
-    public void stop() throws Exception
+    public void start() throws Exception
     {
 
     }
 
 
     /**
-     * Restarts the server.
+     * Stops the server.
      *
      * @throws Exception
      *      if an error occurs when restarting the server
      */
-    public void restart() throws Exception
+    public void stop() throws Exception
     {
 
     }
 
 
     /**
-     * Gets the status of the server.
-     *
-     * @return
-     *      the status of the server
+     * {@inheritDoc}
      */
-    public LdapServerStatus getStatus()
+    public Object getAdapter( Class adapter )
     {
-        return status;
+        return null;
     }
 }

Added: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/LdapServerAdapterExtensionsContentProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/LdapServerAdapterExtensionsContentProvider.java?rev=963760&view=auto
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/LdapServerAdapterExtensionsContentProvider.java
(added)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/LdapServerAdapterExtensionsContentProvider.java
Tue Jul 13 15:26:23 2010
@@ -0,0 +1,130 @@
+/*
+ *  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.ldapservers.wizards;
+
+
+import java.util.List;
+
+import org.apache.commons.collections.map.MultiValueMap;
+import org.apache.directory.studio.ldapservers.LdapServerAdapterExtensionsManager;
+import org.apache.directory.studio.ldapservers.model.LdapServerAdapterExtension;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+
+
+/**
+ * This class implements a {@link ITreeContentProvider} for LDAP Server Adapter Extensions
{@link TreeViewer}.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class LdapServerAdapterExtensionsContentProvider implements ITreeContentProvider
+{
+    /** The {@link MultiValueMap} used to store LDAP Server Adapter Extensions and order
them by vendor (used as key) */
+    private MultiValueMap ldapServerAdapterExtensionsMap = new MultiValueMap();
+
+
+    /**
+     * Creates a new instance of LdapServerAdaptersContentProvider.
+     */
+    public LdapServerAdapterExtensionsContentProvider()
+    {
+        for ( LdapServerAdapterExtension extension : LdapServerAdapterExtensionsManager.getDefault()
+            .getLdapServerAdapterExtensions() )
+        {
+            ldapServerAdapterExtensionsMap.put( extension.getVendor(), extension );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Object[] getElements( Object inputElement )
+    {
+        return ldapServerAdapterExtensionsMap.keySet().toArray();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Object[] getChildren( Object parentElement )
+    {
+        Object children = ldapServerAdapterExtensionsMap.get( parentElement );
+        if ( children != null )
+        {
+            if ( children instanceof List )
+            {
+                return ( ( List<?> ) children ).toArray();
+            }
+            else
+            {
+                return new Object[]
+                    { children };
+            }
+        }
+
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean hasChildren( Object element )
+    {
+        if ( element instanceof String )
+        {
+            return true;
+        }
+
+        return false;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose()
+    {
+        // Nothing to do
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
+    {
+        // Nothing to do
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Object getParent( Object element )
+    {
+        // Hierarchy is only descending.
+        // Should not be used.
+        return null;
+    }
+}

Added: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/LdapServerAdapterExtensionsLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/LdapServerAdapterExtensionsLabelProvider.java?rev=963760&view=auto
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/LdapServerAdapterExtensionsLabelProvider.java
(added)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/LdapServerAdapterExtensionsLabelProvider.java
Tue Jul 13 15:26:23 2010
@@ -0,0 +1,76 @@
+/*
+ *  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.ldapservers.wizards;
+
+
+import org.apache.directory.studio.ldapservers.LdapServersPlugin;
+import org.apache.directory.studio.ldapservers.LdapServersPluginConstants;
+import org.apache.directory.studio.ldapservers.model.LdapServerAdapterExtension;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.graphics.Image;
+
+
+/**
+ * This class implements a {@link ILabelProvider} for LDAP Server Adapter Extensions {@link
TreeViewer}.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class LdapServerAdapterExtensionsLabelProvider extends LabelProvider
+{
+    /**
+    * {@inheritDoc}
+    */
+    public Image getImage( Object element )
+    {
+        if ( element instanceof String )
+        {
+            return LdapServersPlugin.getDefault().getImage( LdapServersPluginConstants.IMG_FOLDER
);
+        }
+        else if ( element instanceof LdapServerAdapterExtension )
+        {
+            return LdapServersPlugin.getDefault().getImage( LdapServersPluginConstants.IMG_SERVER
);
+        }
+
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getText( Object element )
+    {
+        if ( element instanceof String )
+        {
+            return ( String ) element;
+
+        }
+        else if ( element instanceof LdapServerAdapterExtension )
+        {
+            LdapServerAdapterExtension extension = ( LdapServerAdapterExtension ) element;
+
+            return extension.getName() + " " + extension.getVersion();
+        }
+
+        return super.getText( element );
+    }
+}

Modified: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/NewServerWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/NewServerWizard.java?rev=963760&r1=963759&r2=963760&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/NewServerWizard.java
(original)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/NewServerWizard.java
Tue Jul 13 15:26:23 2010
@@ -39,8 +39,8 @@ public class NewServerWizard extends Wiz
     private NewServerWizardPage page;
 
 
-    /* (non-Javadoc)
-     * @see org.eclipse.jface.wizard.Wizard#addPages()
+    /**
+     * {@inheritDoc}
      */
     public void addPages()
     {
@@ -49,14 +49,15 @@ public class NewServerWizard extends Wiz
     }
 
 
-    /* (non-Javadoc)
-     * @see org.eclipse.jface.wizard.Wizard#performFinish()
+    /**
+     * {@inheritDoc}
      */
     public boolean performFinish()
     {
         // Creating the new server
         LdapServer server = new LdapServer();
         server.setName( page.getServerName() );
+        server.setLdapServerAdapterExtension( page.getLdapServerAdapterExtension() );
 
         // Adding the new server to the servers handler
         LdapServersManager.getDefault().addServer( server );
@@ -68,8 +69,8 @@ public class NewServerWizard extends Wiz
     }
 
 
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+    /**
+     * {@inheritDoc}
      */
     public void init( IWorkbench workbench, IStructuredSelection selection )
     {

Modified: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/NewServerWizardPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/NewServerWizardPage.java?rev=963760&r1=963759&r2=963760&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/NewServerWizardPage.java
(original)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/NewServerWizardPage.java
Tue Jul 13 15:26:23 2010
@@ -20,9 +20,18 @@
 package org.apache.directory.studio.ldapservers.wizards;
 
 
+import java.util.regex.Pattern;
+
 import org.apache.directory.studio.ldapservers.LdapServersManager;
 import org.apache.directory.studio.ldapservers.LdapServersPlugin;
 import org.apache.directory.studio.ldapservers.LdapServersPluginConstants;
+import org.apache.directory.studio.ldapservers.model.LdapServerAdapterExtension;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;
@@ -32,6 +41,7 @@ import org.eclipse.swt.layout.GridLayout
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
 
 
 /**
@@ -44,8 +54,17 @@ public class NewServerWizardPage extends
     /** The servers handler */
     private LdapServersManager ldapServersManager;
 
+    /** The content provider of the TreeViewer */
+    private LdapServerAdapterExtensionsContentProvider contentProvider;
+
+    /** The label provider of the TreeViewer */
+    private LdapServerAdapterExtensionsLabelProvider labelProvider;
+
     // UI fields
-    private Text nameText;
+    private Label filterLabel;
+    private Text filterText;
+    private TreeViewer ldapServerAdaptersTreeViewer;
+    private Text serverNameText;
 
 
     /**
@@ -54,8 +73,8 @@ public class NewServerWizardPage extends
     public NewServerWizardPage()
     {
         super( NewServerWizardPage.class.getCanonicalName() );
-        setTitle( Messages.getString( "NewServerWizardPage.CreateNewServer" ) ); //$NON-NLS-1$
-        setDescription( Messages.getString( "NewServerWizardPage.PleaseSpecifyName" ) );
//$NON-NLS-1$
+        setTitle( "Create an LDAP Server" );
+        setDescription( "Please choose the type of server and specify a name to create a
new server." );
         setImageDescriptor( LdapServersPlugin.getDefault().getImageDescriptor(
             LdapServersPluginConstants.IMG_SERVER_NEW_WIZARD ) );
         setPageComplete( false );
@@ -63,27 +82,179 @@ public class NewServerWizardPage extends
     }
 
 
-    /* (non-Javadoc)
-     * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+    /**
+     * {@inheritDoc}
      */
     public void createControl( Composite parent )
     {
+        // Creating the composite to hold the UI
         Composite composite = new Composite( parent, SWT.NONE );
         composite.setLayout( new GridLayout( 2, false ) );
 
-        Label nameLabel = new Label( composite, SWT.NONE );
-        nameLabel.setText( Messages.getString( "NewServerWizardPage.Name" ) ); //$NON-NLS-1$
-        nameText = new Text( composite, SWT.BORDER );
-        nameText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
-        nameText.addModifyListener( new ModifyListener()
+        // Filter Label
+        filterLabel = new Label( composite, SWT.NONE );
+        filterLabel.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 )
);
+        filterLabel.setText( "Select the server type:" );
+
+        // Filter Text
+        filterText = new Text( composite, SWT.BORDER | SWT.SEARCH | SWT.CANCEL );
+        filterText.setMessage( "Type filter here..." );
+        filterText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
+
+        // LDAP Server Adapters Tree Viewer
+        ldapServerAdaptersTreeViewer = new TreeViewer( new Tree( composite, SWT.SINGLE |
SWT.H_SCROLL | SWT.V_SCROLL
+            | SWT.BORDER ) );
+        GridData gd = new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 );
+        gd.heightHint = 90;
+        ldapServerAdaptersTreeViewer.getTree().setLayoutData( gd );
+        contentProvider = new LdapServerAdapterExtensionsContentProvider();
+        ldapServerAdaptersTreeViewer.setContentProvider( contentProvider );
+        labelProvider = new LdapServerAdapterExtensionsLabelProvider();
+        ldapServerAdaptersTreeViewer.setLabelProvider( labelProvider );
+        ldapServerAdaptersTreeViewer.setInput( "LDAP Server Adapters Tree Viewer Input" );
+        ldapServerAdaptersTreeViewer.expandAll();
+        ldapServerAdaptersTreeViewer.addFilter( new ViewerFilter()
+        {
+            public boolean select( Viewer viewer, Object parentElement, Object element )
+            {
+                // The current element is a Vendor
+                if ( element instanceof String )
+                {
+                    Object[] children = contentProvider.getChildren( element );
+                    for ( Object child : children )
+                    {
+                        String label = labelProvider.getText( child );
+
+                        return getFilterPattern().matcher( label ).matches();
+                    }
+                }
+                // The current element is an LdapServerAdapterExtension
+                else if ( element instanceof LdapServerAdapterExtension )
+                {
+                    String label = labelProvider.getText( element );
+
+                    return getFilterPattern().matcher( label ).matches();
+                }
+
+                return false;
+            }
+
+
+            /**
+             * Gets the filter pattern.
+             *
+             * @return
+             *      the filter pattern
+             */
+            private Pattern getFilterPattern()
+            {
+                String filter = filterText.getText();
+
+                return Pattern.compile( ( ( filter == null ) ? ".*" : ".*" + filter + ".*"
), Pattern.CASE_INSENSITIVE );
+            }
+        } );
+
+        // Filler
+        Label filler = new Label( composite, SWT.NONE );
+        filler.setLayoutData( new GridData( SWT.NONE, SWT.NONE, true, false, 2, 1 ) );
+
+        // Server Name Label
+        Label serverNameLabel = new Label( composite, SWT.NONE );
+        serverNameLabel.setText( "Server Name:" );
+
+        // Server Name Text
+        serverNameText = new Text( composite, SWT.BORDER );
+        serverNameText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Adding listeners
+        addListeners();
+
+        // Setting the control on the composite and setting focus
+        setControl( composite );
+        composite.setFocus();
+    }
+
+
+    /**
+     * Adding listeners to UI elements.
+     */
+    private void addListeners()
+    {
+        // Filter Text
+        filterText.addModifyListener( new ModifyListener()
         {
             public void modifyText( ModifyEvent e )
             {
+                // Refreshing the LDAP Server Adapters Tree Viewer
+                ldapServerAdaptersTreeViewer.refresh();
+                ldapServerAdaptersTreeViewer.expandAll();
+            }
+        } );
+
+        // LDAP Server Adapters Tree Viewer
+        ldapServerAdaptersTreeViewer.addSelectionChangedListener( new ISelectionChangedListener()
+        {
+            public void selectionChanged( SelectionChangedEvent event )
+            {
+                // Assigning an automatic name to the LDAP Server based on the selected LDAP
Server Adapter Extension
+                serverNameText.setText( getServerName( ( StructuredSelection ) ldapServerAdaptersTreeViewer
+                    .getSelection() ) );
+
                 validate();
             }
+
+
+            /**
+             * Get a name for the server based on the current selection.
+             *
+             * @param selection
+             *      the current selection
+             * @return
+             *      a name for the server based on the current selection
+             */
+            private String getServerName( StructuredSelection selection )
+            {
+                if ( !selection.isEmpty() )
+                {
+                    Object selectedObject = selection.getFirstElement();
+                    if ( selectedObject instanceof LdapServerAdapterExtension )
+                    {
+                        // Getting the name of the LDAP Server Adapter Extension
+                        String serverName = labelProvider.getText( selection.getFirstElement()
);
+
+                        // Checking if the name if available
+                        if ( ldapServersManager.isNameAvailable( serverName ) )
+                        {
+                            return serverName;
+                        }
+                        else
+                        {
+                            // The name is not available, looking for another name
+                            String newServerName = serverName;
+
+                            for ( int i = 2; !ldapServersManager.isNameAvailable( newServerName
); i++ )
+                            {
+                                newServerName = serverName + " (" + i + ")";
+                            }
+
+                            return newServerName;
+                        }
+                    }
+                }
+
+                // Returning an empty string if the selection is empty or if the current
selection is a vendor
+                return "";
+            }
         } );
 
-        setControl( composite );
+        // Server Name Text
+        serverNameText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                validate();
+            }
+        } );
     }
 
 
@@ -94,17 +265,35 @@ public class NewServerWizardPage extends
     {
         displayErrorMessage( null );
 
-        String name = nameText.getText();
+        // LDAP Server Adapters Tree Viewer
+        StructuredSelection selection = ( StructuredSelection ) ldapServerAdaptersTreeViewer.getSelection();
+        if ( selection.isEmpty() )
+        {
+            displayErrorMessage( "Choose the type of server to create." );
+            return;
+        }
+        else
+        {
+            Object selectedObject = selection.getFirstElement();
+            if ( selectedObject instanceof String )
+            {
+                displayErrorMessage( "Choose the type of server to create." );
+                return;
+            }
+        }
+
+        // Server Name Text
+        String name = serverNameText.getText();
         if ( ( name != null ) )
         {
             if ( "".equals( name ) ) //$NON-NLS-1$
             {
-                displayErrorMessage( Messages.getString( "NewServerWizardPage.ErrorEnterName"
) ); //$NON-NLS-1$
+                displayErrorMessage( "Enter a name for the LDAP server." );
                 return;
             }
             if ( !ldapServersManager.isNameAvailable( name ) )
             {
-                displayErrorMessage( Messages.getString( "NewServerWizardPage.ErrorNameExists"
) ); //$NON-NLS-1$
+                displayErrorMessage( "An LDAP server with the same name already exists."
);
                 return;
             }
         }
@@ -133,6 +322,28 @@ public class NewServerWizardPage extends
      */
     public String getServerName()
     {
-        return nameText.getText();
+        return serverNameText.getText();
+    }
+
+
+    /**
+     * Gets the Ldap Server Adapter Extension.
+     *
+     * @return
+     *      the Ldap Server Adapter Extension
+     */
+    public LdapServerAdapterExtension getLdapServerAdapterExtension()
+    {
+        StructuredSelection selection = ( StructuredSelection ) ldapServerAdaptersTreeViewer.getSelection();
+        if ( !selection.isEmpty() )
+        {
+            Object selectedObject = selection.getFirstElement();
+            if ( selectedObject instanceof LdapServerAdapterExtension )
+            {
+                return ( LdapServerAdapterExtension ) selectedObject;
+            }
+        }
+
+        return null;
     }
 }

Modified: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/messages.properties?rev=963760&r1=963759&r2=963760&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/messages.properties
(original)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/messages.properties
Tue Jul 13 15:26:23 2010
@@ -15,8 +15,3 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
-NewServerWizardPage.CreateNewServer=Create a Server
-NewServerWizardPage.ErrorEnterName=Enter a name for the server.
-NewServerWizardPage.ErrorNameExists=A server with the same name already exists.
-NewServerWizardPage.Name=Name\:
-NewServerWizardPage.PleaseSpecifyName=Please specify a name to create a new server.

Modified: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/messages_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/messages_de.properties?rev=963760&r1=963759&r2=963760&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/messages_de.properties
(original)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/messages_de.properties
Tue Jul 13 15:26:23 2010
@@ -14,8 +14,3 @@
 #  KIND, either express or implied.  See the License for the
 #  specific language governing permissions and limitations
 #  under the License.
-
-NewServerWizardPage.CreateNewServer=Erstelle einen Server
-NewServerWizardPage.ErrorEnterName=Geben Sie einen Namen f\u00FCr den Server ein.
-NewServerWizardPage.ErrorNameExists=Ein Server mit diesem Namen existiert bereits.
-NewServerWizardPage.PleaseSpecifyName=Bitte geben Sie einen Namen zum Erstellen eines neuen
Servers an.

Modified: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/messages_fr.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/messages_fr.properties?rev=963760&r1=963759&r2=963760&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/messages_fr.properties
(original)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/messages_fr.properties
Tue Jul 13 15:26:23 2010
@@ -14,9 +14,3 @@
 #  KIND, either express or implied.  See the License for the
 #  specific language governing permissions and limitations
 #  under the License.
-
-NewServerWizardPage.CreateNewServer=Cr\u00E9er un nouveau serveur
-NewServerWizardPage.ErrorEnterName=Entrez un nom pour le nouveau serveur
-NewServerWizardPage.ErrorNameExists=Un serveur portant ce nom existe d\u00E9j\u00E0.
-NewServerWizardPage.Name=Nom\:
-NewServerWizardPage.PleaseSpecifyName=Veuillez d'indiquer le nom du serveur \u00E0 cr\u00E9er.



Mime
View raw message