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

svn commit: r575592 [1/2] - in /directory/studio/trunk/studio-schemaeditor: ./ META-INF/ resources/icons/ src/main/java/org/apache/directory/studio/schemaeditor/ src/main/java/org/apache/directory/studio/schemaeditor/model/ src/main/java/org/apache/dir...

Author: pamarcelot
Date: Fri Sep 14 02:01:01 2007
New Revision: 575592

URL: http://svn.apache.org/viewvc?rev=575592&view=rev
Log:
Fixed DIRSTUDIO-192 (Add an extension point in the Schema Editor for SchemaConnectors)
Added the list of SchemaConnectors in the Schema Editor Preference Page.

Added:
    directory/studio/trunk/studio-schemaeditor/resources/icons/project_online.gif
      - copied unchanged from r574167, directory/studio/trunk/studio-schemaeditor/resources/icons/project_ads.gif
    directory/studio/trunk/studio-schemaeditor/resources/icons/project_online_closed.gif
      - copied unchanged from r574167, directory/studio/trunk/studio-schemaeditor/resources/icons/project_ads_closed.gif
    directory/studio/trunk/studio-schemaeditor/resources/icons/schema_connector.gif   (with props)
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/AbstractSchemaConnector.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ApacheDsSchemaConnector.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/SchemaConnector.java
    directory/studio/trunk/studio-schemaeditor/src/main/resources/org.apache.directory.studio.schemaeditor.schemaConnectors.exsd
Removed:
    directory/studio/trunk/studio-schemaeditor/resources/icons/project_ads.gif
    directory/studio/trunk/studio-schemaeditor/resources/icons/project_ads_closed.gif
Modified:
    directory/studio/trunk/studio-schemaeditor/META-INF/MANIFEST.MF
    directory/studio/trunk/studio-schemaeditor/plugin.xml
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginConstants.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginUtils.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/Project.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/ProjectType.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsExporter.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsImporter.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/preferences/PluginPreferencePage.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/ProjectsViewLabelProvider.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportProjectsWizardPage.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizard.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizardInformationPage.java

Modified: directory/studio/trunk/studio-schemaeditor/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/META-INF/MANIFEST.MF?rev=575592&r1=575591&r2=575592&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/META-INF/MANIFEST.MF (original)
+++ directory/studio/trunk/studio-schemaeditor/META-INF/MANIFEST.MF Fri Sep 14 02:01:01 2007
@@ -18,3 +18,5 @@
 Bundle-ClassPath: .,
  lib/apacheds-core-plugin-1.5.1-SNAPSHOT.jar,
  lib/shared-converter-0.9.7-SNAPSHOT.jar
+Export-Package: org.apache.directory.studio.schemaeditor.model,
+ org.apache.directory.studio.schemaeditor.model.io

Modified: directory/studio/trunk/studio-schemaeditor/plugin.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/plugin.xml?rev=575592&r1=575591&r2=575592&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/plugin.xml (original)
+++ directory/studio/trunk/studio-schemaeditor/plugin.xml Fri Sep 14 02:01:01 2007
@@ -19,6 +19,7 @@
   under the License.
 -->
 <plugin>
+   <extension-point id="org.apache.directory.studio.schemaeditor.schemaConnectors" name="Schema Editor Schema Connectors" schema="src/main/resources/org.apache.directory.studio.schemaeditor.schemaConnectors.exsd"/>
 	<extension
          point="org.eclipse.ui.perspectives">
       <perspective
@@ -286,4 +287,12 @@
             showScopeSection="false"
             sizeHint="450,300"/>
 	</extension>
+	<extension
+		point="org.apache.directory.studio.schemaeditor.schemaConnectors">
+		<schemaConnector
+			name="Apache Directory Server"
+			id="org.apache.directory.studio.schemaeditor.schemaConnectors.apacheDirectoryServer"
+			description="A SchemaConnector for Apache Directory Server."
+			class="org.apache.directory.studio.schemaeditor.model.io.ApacheDsSchemaConnector"/>
+	 </extension>     
 </plugin>

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

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

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginConstants.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginConstants.java?rev=575592&r1=575591&r2=575592&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginConstants.java (original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginConstants.java Fri Sep 14 02:01:01 2007
@@ -72,8 +72,6 @@
     public static final String IMG_PROBLEMS_ERROR = "resources/icons/problems_error.gif";
     public static final String IMG_PROBLEMS_GROUP = "resources/icons/problems_group.gif";
     public static final String IMG_PROBLEMS_WARNING = "resources/icons/problems_warning.gif";
-    public static final String IMG_PROJECT_ADS = "resources/icons/project_ads.gif";
-    public static final String IMG_PROJECT_ADS_CLOSED = "resources/icons/project_ads_closed.gif";
     public static final String IMG_PROJECT_EXPORT = "resources/icons/project_export.gif";
     public static final String IMG_PROJECT_EXPORT_WIZARD = "resources/icons/project_export_wizard.png";
     public static final String IMG_PROJECT_FILE = "resources/icons/project_file.gif";
@@ -83,9 +81,12 @@
     public static final String IMG_PROJECT_NEW_WIZARD = "resources/icons/project_new_wizard.png";
     public static final String IMG_PROJECT_OFFLINE = "resources/icons/project_offline.gif";
     public static final String IMG_PROJECT_OFFLINE_CLOSED = "resources/icons/project_offline_closed.gif";
+    public static final String IMG_PROJECT_ONLINE = "resources/icons/project_online.gif";
+    public static final String IMG_PROJECT_ONLINE_CLOSED = "resources/icons/project_online_closed.gif";
     public static final String IMG_RENAME = "resources/icons/rename.gif";
     public static final String IMG_RUN_CURRENT_SEARCH_AGAIN = "resources/icons/run_current_search_again.gif";
     public static final String IMG_SCHEMA = "resources/icons/schema.gif";
+    public static final String IMG_SCHEMA_CONNECTOR = "resources/icons/schema_connector.gif";
     public static final String IMG_SCHEMA_NEW = "resources/icons/schema_new.gif";
     public static final String IMG_SCHEMA_NEW_WIZARD = "resources/icons/schema_new_wizard.png";
     public static final String IMG_SCHEMAS_EXPORT = "resources/icons/schemas_export.gif";

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginUtils.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginUtils.java?rev=575592&r1=575591&r2=575592&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginUtils.java (original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginUtils.java Fri Sep 14 02:01:01 2007
@@ -25,7 +25,9 @@
 import java.io.FileWriter;
 import java.io.IOException;
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 
 import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
@@ -37,9 +39,13 @@
 import org.apache.directory.studio.schemaeditor.model.io.ProjectsExporter;
 import org.apache.directory.studio.schemaeditor.model.io.ProjectsImportException;
 import org.apache.directory.studio.schemaeditor.model.io.ProjectsImporter;
+import org.apache.directory.studio.schemaeditor.model.io.SchemaConnector;
 import org.apache.directory.studio.schemaeditor.model.io.XMLSchemaFileImportException;
 import org.apache.directory.studio.schemaeditor.model.io.XMLSchemaFileImporter;
 import org.apache.directory.studio.schemaeditor.view.ViewUtils;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.core.runtime.Status;
 
@@ -257,23 +263,63 @@
 
 
     /**
-     * Gets a Connection from the given name.
+     * Gets a Connection from the given id.
      *
-     * @param name
-     *      the name of the Connection
+     * @param id
+     *      the id of the Connection
      * @return
      *      the corresponding Connection, or null if no connection was found.
      */
-    public static Connection getConnection( String name )
+    public static Connection getConnection( String id )
     {
         Connection[] connectionsArray = ConnectionCorePlugin.getDefault().getConnectionManager().getConnections();
 
         HashMap<String, Connection> connections = new HashMap<String, Connection>();
         for ( Connection connection : connectionsArray )
         {
-            connections.put( connection.getName(), connection );
+            connections.put( connection.getId(), connection );
+        }
+
+        return connections.get( id );
+    }
+
+
+    /**
+     * Gets the List of SchemaConnectors defined using the ExtensionPoint.
+     *
+     * @return
+     *      the List of SchemaConnectors defined using the ExtensionPoint
+     */
+    public static List<SchemaConnector> getSchemaConnectors()
+    {
+        List<SchemaConnector> schemaConnectors = new ArrayList<SchemaConnector>();
+
+        IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(
+            "org.apache.directory.studio.schemaeditor.schemaConnectors" );
+        IConfigurationElement[] members = extensionPoint.getConfigurationElements();
+
+        if ( members != null )
+        {
+            // Creating each SchemaConnector
+            for ( IConfigurationElement member : members )
+            {
+                try
+                {
+                    SchemaConnector schemaConnector = ( SchemaConnector ) member.createExecutableExtension( "class" );
+                    schemaConnector.setName( member.getAttribute( "name" ) );
+                    schemaConnector.setId( member.getAttribute( "id" ) );
+                    schemaConnector.setDescription( member.getAttribute( "description" ) );
+
+                    schemaConnectors.add( schemaConnector );
+                }
+                catch ( CoreException e )
+                {
+                    PluginUtils.logError( "An error occured when loading the schema connectors.", e );
+                    ViewUtils.displayErrorMessageBox( "Error", "An error occured when loading the schema connectors." );
+                }
+            }
         }
 
-        return connections.get( name );
+        return schemaConnectors;
     }
 }

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/Project.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/Project.java?rev=575592&r1=575591&r2=575592&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/Project.java (original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/Project.java Fri Sep 14 02:01:01 2007
@@ -22,12 +22,10 @@
 
 import java.util.List;
 
-import javax.naming.NamingException;
-
 import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.connection.core.StudioProgressMonitor;
 import org.apache.directory.studio.schemaeditor.controller.SchemaHandler;
-import org.apache.directory.studio.schemaeditor.model.io.ApacheDSSchemaImporter;
+import org.apache.directory.studio.schemaeditor.model.io.SchemaConnector;
 import org.apache.directory.studio.schemaeditor.model.schemachecker.SchemaChecker;
 
 
@@ -65,6 +63,9 @@
     /** The state of the project */
     private ProjectState state;
 
+    /** The SchemaConnector of the project */
+    private SchemaConnector schemaConnector;
+
     /** The SchemaHandler */
     private SchemaHandler schemaHandler;
 
@@ -252,22 +253,17 @@
      */
     public void fetchOnlineSchema( StudioProgressMonitor monitor )
     {
-        if ( !hasOnlineSchemaBeenFetched && ( connection != null ) )
+        if ( ( !hasOnlineSchemaBeenFetched ) && ( connection != null ) && ( schemaConnector != null ) )
         {
-            try
-            {
-                schemaBackup = ApacheDSSchemaImporter.importSchema( connection.getJNDIConnectionWrapper(), monitor );
-            }
-            catch ( NamingException e )
-            {
-                // TODO Auto-generated catch block
-                e.printStackTrace();
-            }
+            schemaBackup = schemaConnector.importSchema( connection, monitor );
 
-            monitor.beginTask( "Adding Schema to project", schemaBackup.size() );
-            for ( Schema schema : schemaBackup )
+            if ( schemaBackup != null )
             {
-                getSchemaHandler().addSchema( schema );
+                monitor.beginTask( "Adding Schema to project", schemaBackup.size() );
+                for ( Schema schema : schemaBackup )
+                {
+                    getSchemaHandler().addSchema( schema );
+                }
             }
 
             // TODO Add error Handling
@@ -310,6 +306,30 @@
     public void setSchemaBackup( List<Schema> schemaBackup )
     {
         this.schemaBackup = schemaBackup;
+    }
+
+
+    /**
+     * Gets the SchemaConnector.
+     *
+     * @return
+     *      the SchemaConnector
+     */
+    public SchemaConnector getSchemaConnector()
+    {
+        return schemaConnector;
+    }
+
+
+    /**
+     * Sets the SchemaConnector.
+     *
+     * @param schemaConnector
+     *      the SchemaConnector
+     */
+    public void setSchemaConnector( SchemaConnector schemaConnector )
+    {
+        this.schemaConnector = schemaConnector;
     }
 
 

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/ProjectType.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/ProjectType.java?rev=575592&r1=575591&r2=575592&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/ProjectType.java (original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/ProjectType.java Fri Sep 14 02:01:01 2007
@@ -30,6 +30,6 @@
 {
     /** A schema project not linked to any LDAP Server */
     OFFLINE,
-    /** A schema project linked to an Apache Directory Server */
-    APACHE_DIRECTORY_SERVER
+    /** A schema project linked to a Directory Server */
+    ONLINE
 }

Added: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/AbstractSchemaConnector.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/AbstractSchemaConnector.java?rev=575592&view=auto
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/AbstractSchemaConnector.java (added)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/AbstractSchemaConnector.java Fri Sep 14 02:01:01 2007
@@ -0,0 +1,106 @@
+/*
+ *  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.schemaeditor.model.io;
+
+
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.StudioProgressMonitor;
+
+
+/**
+ * This class represents an AbstractSchemaConnector and implements SchemaConnector.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class AbstractSchemaConnector implements SchemaConnector
+{
+    /** The name */
+    private String name;
+
+    /** The ID */
+    private String id;
+
+    /** The description */
+    private String description;
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.studio.schemaeditor.model.io.SchemaConnector#getDecription()
+     */
+    public String getDescription()
+    {
+        return description;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.studio.schemaeditor.model.io.SchemaConnector#getId()
+     */
+    public String getId()
+    {
+        return id;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.studio.schemaeditor.model.io.SchemaConnector#getName()
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.studio.schemaeditor.model.io.SchemaConnector#isSuitableConnector(org.apache.directory.studio.connection.core.Connection, org.apache.directory.studio.connection.core.StudioProgressMonitor)
+     */
+    public boolean isSuitableConnector( Connection connection, StudioProgressMonitor monitor )
+    {
+        return false;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.studio.schemaeditor.model.io.SchemaConnector#setDescription(java.lang.String)
+     */
+    public void setDescription( String description )
+    {
+        this.description = description;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.studio.schemaeditor.model.io.SchemaConnector#setId(java.lang.String)
+     */
+    public void setId( String id )
+    {
+        this.id = id;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.studio.schemaeditor.model.io.SchemaConnector#setName(java.lang.String)
+     */
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+}

Added: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ApacheDsSchemaConnector.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ApacheDsSchemaConnector.java?rev=575592&view=auto
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ApacheDsSchemaConnector.java (added)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ApacheDsSchemaConnector.java Fri Sep 14 02:01:01 2007
@@ -0,0 +1,897 @@
+/*
+ *  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.schemaeditor.model.io;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+
+import org.apache.directory.shared.ldap.schema.ObjectClassTypeEnum;
+import org.apache.directory.shared.ldap.schema.UsageEnum;
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.StudioProgressMonitor;
+import org.apache.directory.studio.connection.core.io.jndi.JNDIConnectionWrapper;
+import org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.schemaeditor.model.MatchingRuleImpl;
+import org.apache.directory.studio.schemaeditor.model.ObjectClassImpl;
+import org.apache.directory.studio.schemaeditor.model.Schema;
+import org.apache.directory.studio.schemaeditor.model.SchemaImpl;
+import org.apache.directory.studio.schemaeditor.model.SyntaxImpl;
+
+
+/**
+ * A Schema Connector for Apache DS.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ApacheDsSchemaConnector extends AbstractSchemaConnector implements SchemaConnector
+{
+
+    /** The Schema DN */
+    public static final String SCHEMA_DN = "ou=schema";
+
+    /** The name of the metaAttributeType object class */
+    private static final String META_ATTRIBUTE_TYPE = "metaAttributeType";
+    /** The name of the metaObjectClass object class */
+    private static final String META_OBJECT_CLASS = "metaObjectClass";
+    /** The name of the metaMatchingRule object class */
+    private static final String META_MATCHING_RULE = "metaMatchingRule";
+    /** The name of the metaSyntax object class */
+    private static final String META_SYNTAX = "metaSyntax";
+
+    private static final String DEREF_ALIAS_METHOD = "always";
+    private static final String HANDLE_REFERALS_METHOD = "throw";
+
+    /**
+     * This enum represents the different types of nodes that can be found while
+     * reading the schema from the DIT.
+     */
+    private enum SchemaNodeTypes
+    {
+        ATTRIBUTE_TYPE, OBJECT_CLASS, MATCHING_RULE, SYNTAX, UNKNOWN
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.studio.schemaeditor.model.io.SchemaConnector#exportSchema(org.apache.directory.studio.connection.core.Connection, org.apache.directory.studio.connection.core.StudioProgressMonitor)
+     */
+    public void exportSchema( Connection connection, StudioProgressMonitor monitor )
+    {
+        // TODO Auto-generated method stub
+
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.studio.schemaeditor.model.io.SchemaConnector#importSchema(org.apache.directory.studio.connection.core.Connection, org.apache.directory.studio.connection.core.StudioProgressMonitor)
+     */
+    public List<Schema> importSchema( Connection connection, StudioProgressMonitor monitor )
+    {
+        List<Schema> schemas = new ArrayList<Schema>();
+
+        JNDIConnectionWrapper wrapper = connection.getJNDIConnectionWrapper();
+
+        monitor.beginTask( "Fetching Schema: ", 1 );
+
+        // Looking for all the defined schemas
+        SearchControls constraintSearch = new SearchControls();
+        constraintSearch.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+
+        @SuppressWarnings("unchecked")
+        NamingEnumeration<SearchResult> answer = wrapper.search( "ou=schema", "(objectclass=metaSchema)",
+            constraintSearch, DEREF_ALIAS_METHOD, HANDLE_REFERALS_METHOD, null, ( StudioProgressMonitor ) monitor );
+        if ( answer != null )
+        {
+            while ( answer.hasMoreElements() )
+            {
+                SearchResult searchResult = ( SearchResult ) answer.nextElement();
+
+                // Getting the 'cn' Attribute
+                Attribute cnAttribute = searchResult.getAttributes().get( "cn" );
+
+                // Looping on the values
+                NamingEnumeration<?> ne = null;
+                try
+                {
+                    ne = cnAttribute.getAll();
+                    if ( ne != null )
+                    {
+                        while ( ne.hasMoreElements() )
+                        {
+                            String value = ( String ) ne.nextElement();
+                            schemas.add( getSchema( wrapper, value, monitor ) );
+                        }
+                    }
+                }
+                catch ( NamingException e )
+                {
+                    monitor.reportError( e );
+                }
+            }
+        }
+
+        monitor.worked( 1 );
+
+        return schemas;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.studio.schemaeditor.model.io.AbstractSchemaConnector#isSuitableConnector(org.apache.directory.studio.connection.core.Connection, org.apache.directory.studio.connection.core.StudioProgressMonitor)
+     */
+    public boolean isSuitableConnector( Connection connection, StudioProgressMonitor monitor )
+    {
+        JNDIConnectionWrapper wrapper = connection.getJNDIConnectionWrapper();
+
+        SearchControls constraintSearch = new SearchControls();
+        constraintSearch.setSearchScope( SearchControls.OBJECT_SCOPE );
+        constraintSearch.setReturningAttributes( new String[]
+            { "+" } );
+
+        @SuppressWarnings("unchecked")
+        NamingEnumeration<SearchResult> answer = wrapper.search( "", "(objectclass=*)", constraintSearch,
+            DEREF_ALIAS_METHOD, HANDLE_REFERALS_METHOD, null, monitor );
+
+        if ( answer != null )
+        {
+            if ( answer.hasMoreElements() )
+            {
+                SearchResult searchResult = ( SearchResult ) answer.nextElement();
+
+                Attribute vendorNameAttribute = searchResult.getAttributes().get( "vendorName" );
+                if ( vendorNameAttribute == null )
+                {
+                    return false;
+                }
+
+                if ( vendorNameAttribute.size() != 1 )
+                {
+                    return false;
+                }
+
+                String vendorName = null;
+                try
+                {
+                    vendorName = ( String ) vendorNameAttribute.get();
+                }
+                catch ( NamingException e )
+                {
+                    return false;
+                }
+
+                return ( ( vendorName != null ) && vendorName.equalsIgnoreCase( "Apache Software Foundation" ) );
+            }
+        }
+
+        return false;
+    }
+
+
+    private static Schema getSchema( JNDIConnectionWrapper wrapper, String name, StudioProgressMonitor monitor )
+        throws NamingException
+    {
+        monitor.subTask( "Reading schema '" + name + "'" );
+
+        // Creating the schema
+        Schema schema = new SchemaImpl( name );
+
+        // Looking for the nodes of the schema
+        SearchControls constraintSearch = new SearchControls();
+        constraintSearch.setSearchScope( SearchControls.SUBTREE_SCOPE );
+
+        @SuppressWarnings("unchecked")
+        NamingEnumeration<SearchResult> answer = wrapper.search( "cn=" + name + ", ou=schema", "(objectclass=*)",
+            constraintSearch, DEREF_ALIAS_METHOD, HANDLE_REFERALS_METHOD, null, monitor );
+        if ( answer != null )
+        {
+            while ( answer.hasMoreElements() )
+            {
+                SearchResult searchResult = ( SearchResult ) answer.nextElement();
+                switch ( getNodeType( searchResult ) )
+                {
+                    case ATTRIBUTE_TYPE:
+                        AttributeTypeImpl at = createAttributeType( searchResult );
+                        at.setSchema( name );
+                        schema.addAttributeType( at );
+                        break;
+                    case OBJECT_CLASS:
+                        ObjectClassImpl oc = createObjectClass( searchResult );
+                        oc.setSchema( name );
+                        schema.addObjectClass( oc );
+                        break;
+                    case MATCHING_RULE:
+                        MatchingRuleImpl mr = createMatchingRule( searchResult );
+                        mr.setSchema( name );
+                        schema.addMatchingRule( mr );
+                        break;
+                    case SYNTAX:
+                        SyntaxImpl syntax = createSyntax( searchResult );
+                        syntax.setSchema( name );
+                        schema.addSyntax( syntax );
+                        break;
+                    default:
+                        break;
+                }
+            }
+        }
+
+        return schema;
+    }
+
+
+    /**
+     * Gets the Type of node of the given SearchResult.
+     * 
+     * @param sr
+     *      the SearchResult to be identified
+     * @return
+     *      the Type of node
+     * @throws NamingException
+     *      if an error occurrs when reading the SearchResult
+     */
+    private static SchemaNodeTypes getNodeType( SearchResult sr ) throws NamingException
+    {
+        // Getting the 'ObjectClass' Attribute
+        Attribute objectClassAttribute = sr.getAttributes().get( "objectClass" );
+
+        // Looping on the values
+        NamingEnumeration<?> ne = objectClassAttribute.getAll();
+        while ( ne.hasMore() )
+        {
+            String value = ( String ) ne.next();
+            if ( META_ATTRIBUTE_TYPE.equals( value ) )
+            {
+                return SchemaNodeTypes.ATTRIBUTE_TYPE;
+            }
+            else if ( META_OBJECT_CLASS.equals( value ) )
+            {
+                return SchemaNodeTypes.OBJECT_CLASS;
+            }
+            else if ( META_MATCHING_RULE.equals( value ) )
+            {
+                return SchemaNodeTypes.MATCHING_RULE;
+            }
+            else if ( META_SYNTAX.equals( value ) )
+            {
+                return SchemaNodeTypes.SYNTAX;
+            }
+        }
+
+        return SchemaNodeTypes.UNKNOWN;
+    }
+
+
+    /**
+     * Create the AttributeTypeImpl associated with the given SearchResult.
+     * 
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the AttributeTypeImpl associated with the SearchResult, or null if no 
+     * AttributeTypeImpl could be created
+     * @throws NamingException 
+     */
+    private static AttributeTypeImpl createAttributeType( SearchResult sr ) throws NamingException
+    {
+        AttributeTypeImpl at = new AttributeTypeImpl( getOid( sr ) );
+        at.setNames( getNames( sr ) );
+        at.setDescription( getDescription( sr ) );
+        at.setObsolete( isObsolete( sr ) );
+        at.setSuperiorName( getSuperior( sr ) );
+        at.setUsage( getUsage( sr ) );
+        at.setSyntaxOid( getSyntax( sr ) );
+        at.setLength( getSyntaxLength( sr ) );
+        at.setCollective( isCollective( sr ) );
+        at.setSingleValue( isSingleValue( sr ) );
+        at.setCanUserModify( isCanUserModify( sr ) );
+        at.setEqualityName( getEquality( sr ) );
+        at.setOrderingName( getOrdering( sr ) );
+        at.setSubstrName( getSubstr( sr ) );
+        return at;
+    }
+
+
+    /**
+     * Create the ObjectClassImpl associated with the given SearchResult.
+     * 
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the ObjectClassImpl associated with the SearchResult, or null if no 
+     * ObjectClassImpl could be created
+     * @throws NamingException 
+     */
+    private static ObjectClassImpl createObjectClass( SearchResult sr ) throws NamingException
+    {
+        ObjectClassImpl oc = new ObjectClassImpl( getOid( sr ) );
+        oc.setNames( getNames( sr ) );
+        oc.setDescription( getDescription( sr ) );
+        oc.setObsolete( isObsolete( sr ) );
+        oc.setSuperClassesNames( getSuperiors( sr ) );
+        oc.setType( getType( sr ) );
+        oc.setMayNamesList( getMay( sr ) );
+        oc.setMustNamesList( getMust( sr ) );
+        return oc;
+    }
+
+
+    /**
+     * Create the MatchingRule associated with the given SearchResult.
+     * 
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the MatchingRule associated with the SearchResult, or null if no 
+     * ObjectClass could be created
+     * @throws NamingException 
+     */
+    private static MatchingRuleImpl createMatchingRule( SearchResult sr ) throws NamingException
+    {
+        MatchingRuleImpl mr = new MatchingRuleImpl( getOid( sr ) );
+        mr.setNames( getNames( sr ) );
+        mr.setDescription( getDescription( sr ) );
+        mr.setObsolete( isObsolete( sr ) );
+        mr.setSyntaxOid( getSyntax( sr ) );
+        return mr;
+    }
+
+
+    /**
+     * Create the MatchingRule associated with the given SearchResult.
+     * 
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the MatchingRule associated with the SearchResult, or null if no 
+     * ObjectClass could be created
+     * @throws NamingException 
+     */
+    private static SyntaxImpl createSyntax( SearchResult sr ) throws NamingException
+    {
+        SyntaxImpl syntax = new SyntaxImpl( getOid( sr ) );
+        syntax.setNames( getNames( sr ) );
+        syntax.setDescription( getDescription( sr ) );
+        syntax.setObsolete( isObsolete( sr ) );
+        syntax.setHumanReadable( isHumanReadable( sr ) );
+        return syntax;
+    }
+
+
+    /**
+     * Gets the oid of the schema object contained a SearchResult.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the oid of the schema object, or nullif no oid was found
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static String getOid( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "m-oid" );
+        if ( at == null )
+        {
+            return null;
+        }
+        else
+        {
+            return ( String ) at.get();
+        }
+    }
+
+
+    /**
+     * Gets the names of the schema object contained a SearchResult.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the names of the schema object, or an empty array if no name was found
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static String[] getNames( SearchResult sr ) throws NamingException
+    {
+        List<String> names = new ArrayList<String>();
+
+        Attribute at = sr.getAttributes().get( "m-name" );
+        if ( at != null )
+        {
+            NamingEnumeration<?> ne = at.getAll();
+            while ( ne.hasMore() )
+            {
+                names.add( ( String ) ne.next() );
+            }
+        }
+
+        return names.toArray( new String[0] );
+    }
+
+
+    /**
+     * Gets the description of the schema object contained a SearchResult.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the description of the schema object, or null if no description was found
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static String getDescription( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "m-description" );
+
+        if ( at == null )
+        {
+            return null;
+        }
+        else
+        {
+            return ( String ) at.get();
+        }
+    }
+
+
+    /**
+     * Gets the superior of the attribute type contained a SearchResult.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the superior of the attribute type, or null if no superior was found
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static String getSuperior( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "m-supAttributeType" );
+
+        if ( at == null )
+        {
+            return null;
+        }
+        else
+        {
+            return ( String ) at.get();
+        }
+    }
+
+
+    /**
+     * Gets the usage of the attribute type contained a SearchResult.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the usage of the attribute type
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static UsageEnum getUsage( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "m-usage" );
+
+        if ( at == null )
+        {
+            return UsageEnum.USER_APPLICATIONS;
+        }
+        else
+        {
+            try
+            {
+                return Enum.valueOf( UsageEnum.class, ( String ) at.get() );
+            }
+            catch ( IllegalArgumentException e )
+            {
+                return UsageEnum.USER_APPLICATIONS;
+            }
+            catch ( NullPointerException e )
+            {
+                return UsageEnum.USER_APPLICATIONS;
+            }
+        }
+    }
+
+
+    /**
+     * Gets the syntax of the schema object contained a SearchResult.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the syntax of the schema object, or null if no syntax was found
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static String getSyntax( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "m-syntax" );
+
+        if ( at == null )
+        {
+            return null;
+        }
+        else
+        {
+            return ( String ) at.get();
+        }
+    }
+
+
+    /**
+     * Gets the syntax length of the attribute type contained a SearchResult.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the syntax length of the attribute type, or -1 if no syntax length was found
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static int getSyntaxLength( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "m-length" );
+
+        if ( at == null )
+        {
+            return -1;
+        }
+        else
+        {
+            try
+            {
+                return Integer.parseInt( ( String ) at.get() );
+            }
+            catch ( NumberFormatException e )
+            {
+                return -1;
+            }
+        }
+    }
+
+
+    /**
+     * Gets whether or not the schema object contained a SearchResult is obsolete.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      true if the schema object is obsolete, false if not
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static boolean isObsolete( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "m-obsolete" );
+
+        if ( at == null )
+        {
+            return false;
+        }
+        else
+        {
+            return Boolean.parseBoolean( ( String ) at.get() );
+        }
+    }
+
+
+    /**
+     * Gets whether or not the attribute type contained a SearchResult is collective.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      true if the attribute type is collective, false if not
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static boolean isCollective( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "m-collective" );
+
+        if ( at == null )
+        {
+            return false;
+        }
+        else
+        {
+            return Boolean.parseBoolean( ( String ) at.get() );
+        }
+    }
+
+
+    /**
+     * Gets whether or not the attribute type contained a SearchResult is single value.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      true if the attribute type is single value, false if not
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static boolean isSingleValue( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "m-singleValue" );
+
+        if ( at == null )
+        {
+            return false;
+        }
+        else
+        {
+            return Boolean.parseBoolean( ( String ) at.get() );
+        }
+    }
+
+
+    /**
+     * Gets whether or not the attribute type contained a SearchResult is single value.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      true if the attribute type is single value, false if not
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static boolean isCanUserModify( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "m-noUserModification" );
+
+        if ( at == null )
+        {
+            return true;
+        }
+        else
+        {
+            return !Boolean.parseBoolean( ( String ) at.get() );
+        }
+    }
+
+
+    /**
+     * Gets the name of the equality matching rule of the attribute type contained a SearchResult.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the name of the equality matching rule of the attribute type, or null if no equality matching rule was found
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static String getEquality( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "m-equality" );
+
+        if ( at == null )
+        {
+            return null;
+        }
+        else
+        {
+            return ( String ) at.get();
+        }
+    }
+
+
+    /**
+     * Gets the name of the ordering matching rule of the attribute type contained a SearchResult.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the name of the ordering matching rule of the attribute type, or null if no ordering matching rule was found
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static String getOrdering( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "m-ordering" );
+
+        if ( at == null )
+        {
+            return null;
+        }
+        else
+        {
+            return ( String ) at.get();
+        }
+    }
+
+
+    /**
+     * Gets the name of the substr matching rule of the attribute type contained a SearchResult.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the name of the substr matching rule of the attribute type, or null if no substr matching rule was found
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static String getSubstr( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "m-substr" );
+
+        if ( at == null )
+        {
+            return null;
+        }
+        else
+        {
+            return ( String ) at.get();
+        }
+    }
+
+
+    /**
+     * Gets the superiors of the object class contained a SearchResult.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the superiors of the attribute type, or an empty array if no superior was found
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static String[] getSuperiors( SearchResult sr ) throws NamingException
+    {
+        List<String> names = new ArrayList<String>();
+
+        Attribute at = sr.getAttributes().get( "m-supObjectClass" );
+        if ( at != null )
+        {
+            NamingEnumeration<?> ne = at.getAll();
+            while ( ne.hasMore() )
+            {
+                names.add( ( String ) ne.next() );
+            }
+        }
+
+        return names.toArray( new String[0] );
+    }
+
+
+    /**
+     * Gets the type of the object class contained a SearchResult.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the type of the object class
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static ObjectClassTypeEnum getType( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "m-typeObjectClass" );
+
+        if ( at == null )
+        {
+            return ObjectClassTypeEnum.STRUCTURAL;
+        }
+        else
+        {
+            try
+            {
+                return Enum.valueOf( ObjectClassTypeEnum.class, ( String ) at.get() );
+            }
+            catch ( IllegalArgumentException e )
+            {
+                return ObjectClassTypeEnum.STRUCTURAL;
+            }
+            catch ( NullPointerException e )
+            {
+                return ObjectClassTypeEnum.STRUCTURAL;
+            }
+        }
+    }
+
+
+    /**
+     * Gets the optional attribute types of the object class contained a SearchResult.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the optional attribute types of the attribute type, or an empty array if no optional attribute type was found
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static String[] getMay( SearchResult sr ) throws NamingException
+    {
+        List<String> names = new ArrayList<String>();
+
+        Attribute at = sr.getAttributes().get( "m-may" );
+        if ( at != null )
+        {
+            NamingEnumeration<?> ne = at.getAll();
+            while ( ne.hasMore() )
+            {
+                names.add( ( String ) ne.next() );
+            }
+        }
+
+        return names.toArray( new String[0] );
+    }
+
+
+    /**
+     * Gets the mandatory attribute types of the object class contained a SearchResult.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the mandatory attribute types of the attribute type, or an empty array if no mandatory attribute type was found
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static String[] getMust( SearchResult sr ) throws NamingException
+    {
+        List<String> names = new ArrayList<String>();
+
+        Attribute at = sr.getAttributes().get( "m-must" );
+        if ( at != null )
+        {
+            NamingEnumeration<?> ne = at.getAll();
+            while ( ne.hasMore() )
+            {
+                names.add( ( String ) ne.next() );
+            }
+        }
+
+        return names.toArray( new String[0] );
+    }
+
+
+    /**
+     * Gets whether or not the schema object contained a SearchResult is obsolete.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      true if the schema object is obsolete, false if not
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static boolean isHumanReadable( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "x-humanReadable" );
+
+        if ( at == null )
+        {
+            return false;
+        }
+        else
+        {
+            return Boolean.parseBoolean( ( String ) at.get() );
+        }
+    }
+}

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsExporter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsExporter.java?rev=575592&r1=575591&r2=575592&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsExporter.java (original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsExporter.java Fri Sep 14 02:01:01 2007
@@ -54,6 +54,7 @@
     private static final String NAME_TAG = "name";
     private static final String TYPE_TAG = "type";
     private static final String CONNECTION_TAG = "connection";
+    private static final String SCHEMA_CONNECTOR_TAG = "schemaConnector";
     private static final String SCHEMA_BACKUP_TAG = "schemaBackup";
 
 
@@ -134,11 +135,14 @@
                 element.addAttribute( TYPE_TAG, type.toString() );
             }
 
-            // If project is an Apache Directory Server Online Schema Project
-            if ( type.equals( ProjectType.APACHE_DIRECTORY_SERVER ) )
+            // If project is an Online Schema Project
+            if ( type.equals( ProjectType.ONLINE ) )
             {
                 // Connection Name
-                element.addAttribute( CONNECTION_TAG, project.getConnection().getName() );
+                element.addAttribute( CONNECTION_TAG, project.getConnection().getId() );
+
+                // Connection Name
+                element.addAttribute( SCHEMA_CONNECTOR_TAG, project.getSchemaConnector().getId() );
 
                 // Schema Backup
                 Element schemaBackupElement = element.addElement( SCHEMA_BACKUP_TAG );

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsImporter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsImporter.java?rev=575592&r1=575591&r2=575592&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsImporter.java (original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsImporter.java Fri Sep 14 02:01:01 2007
@@ -51,6 +51,7 @@
     private static final String SCHEMAS_TAG = "schemas";
     private static final String TYPE_TAG = "type";
     private static final String CONNECTION_TAG = "connection";
+    private static final String SCHEMA_CONNECTOR_TAG = "schemaConnector";
     private static final String SCHEMA_BACKUP_TAG = "schemaBackup";
 
 
@@ -161,7 +162,7 @@
         {
             try
             {
-                project.setType( ProjectType.valueOf( typeAttribute.getText() ) );
+                project.setType( ProjectType.valueOf( typeAttribute.getValue() ) );
             }
             catch ( IllegalArgumentException e )
             {
@@ -169,14 +170,40 @@
             }
         }
 
-        // If project is an Apache Directory Server Online Schema Project
-        if ( project.getType().equals( ProjectType.APACHE_DIRECTORY_SERVER ) )
+        // If project is an Online Schema Project
+        if ( project.getType().equals( ProjectType.ONLINE ) )
         {
             // Connection
             Attribute connectionAttribute = element.attribute( CONNECTION_TAG );
             if ( ( connectionAttribute != null ) && ( !connectionAttribute.getValue().equals( "" ) ) )
             {
-                project.setConnection( PluginUtils.getConnection( connectionAttribute.getText() ) );
+                project.setConnection( PluginUtils.getConnection( connectionAttribute.getValue() ) );
+            }
+
+            // Schema Connector
+            Attribute schemaConnectorAttribute = element.attribute( SCHEMA_CONNECTOR_TAG );
+            if ( ( schemaConnectorAttribute != null ) && ( !schemaConnectorAttribute.getValue().equals( "" ) ) )
+            {
+                String schemaConnectorId = schemaConnectorAttribute.getValue();
+
+                SchemaConnector schemaConnector = null;
+                List<SchemaConnector> schemaConnectors = PluginUtils.getSchemaConnectors();
+                for ( SchemaConnector sc : schemaConnectors )
+                {
+                    if ( sc.getId().equalsIgnoreCase( schemaConnectorId ) )
+                        ;
+                    {
+                        schemaConnector = sc;
+                    }
+                }
+
+                if ( schemaConnector == null )
+                {
+                    throw new ProjectsImportException( "The parser was not able to find the SchemaConnector with ID :"
+                        + schemaConnectorId + "." );
+                }
+
+                project.setSchemaConnector( schemaConnector );
             }
 
             // SchemaBackup

Added: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/SchemaConnector.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/SchemaConnector.java?rev=575592&view=auto
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/SchemaConnector.java (added)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/SchemaConnector.java Fri Sep 14 02:01:01 2007
@@ -0,0 +1,138 @@
+/*
+ *  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.schemaeditor.model.io;
+
+
+import java.util.List;
+
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.StudioProgressMonitor;
+import org.apache.directory.studio.schemaeditor.model.Schema;
+
+
+/**
+ * This interface defines a SchemaConnector.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface SchemaConnector
+{
+    /**
+     * Indicates whether the SchemaConnector is suitable for use with the
+     * given connection.
+     *
+     * @param connection
+     *      the connection
+     * @param monitor
+     *      the progress monitor
+     * @return
+     *      true if the SchemaConnector is suitable for the given connection,
+     *      false if not
+     */
+    /**
+     * TODO isSuitableConnector.
+     *
+     * @param connection
+     * @param monitor
+     * @return
+     */
+    public boolean isSuitableConnector( Connection connection, StudioProgressMonitor monitor );
+
+
+    /**
+     * Imports the Schema of the LDAP Server using the given connection and
+     * progress monitor.
+     *
+     * @param connection
+     *      the connection
+     * @param monitor
+     *      the progress monitor
+     * @return
+     *      the list of schemas of the LDAP Server
+     */
+    public List<Schema> importSchema( Connection connection, StudioProgressMonitor monitor );
+
+
+    /**
+     * Exports the Schema to the LDAP Server using the given connection and
+     * progress monitor.
+     *
+     * @param connection
+     *      the connection
+     * @param monitor
+     *      the progress monitor
+     */
+    public void exportSchema( Connection connection, StudioProgressMonitor monitor );
+
+
+    /**
+     * Gets the name.
+     *
+     * @return
+     *      the name
+     */
+    public String getName();
+
+
+    /**
+     * Sets the name.
+     *
+     * @param name
+     *      the name
+     */
+    public void setName( String name );
+
+
+    /**
+     * Gets the ID.
+     *
+     * @return
+     *      the ID
+     */
+    public String getId();
+
+
+    /**
+     * Sets the ID.
+     *
+     * @param id
+     *      the ID
+     */
+    public void setId( String id );
+
+
+    /**
+     * Gets the description.
+     *
+     * @return
+     *      the description
+     */
+    public String getDescription();
+
+
+    /**
+     * Sets the description.
+     *
+     * @param description
+     *      the description
+     */
+    public void setDescription( String description );
+}

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/preferences/PluginPreferencePage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/preferences/PluginPreferencePage.java?rev=575592&r1=575591&r2=575592&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/preferences/PluginPreferencePage.java (original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/preferences/PluginPreferencePage.java Fri Sep 14 02:01:01 2007
@@ -20,15 +20,32 @@
 package org.apache.directory.studio.schemaeditor.view.preferences;
 
 
+import java.util.Comparator;
+
 import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.apache.directory.studio.schemaeditor.PluginUtils;
+import org.apache.directory.studio.schemaeditor.model.io.SchemaConnector;
 import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.ViewerComparator;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
 
 
 /**
@@ -47,7 +64,7 @@
     {
         super();
         setPreferenceStore( Activator.getDefault().getPreferenceStore() );
-        setDescription( "Please select a preference page below \"Schema Editor\"." );
+        setDescription( "General settings for the Schema Editor Plugin" );
     }
 
 
@@ -59,6 +76,91 @@
         Composite composite = new Composite( parent, SWT.NONE );
         composite.setLayout( new GridLayout() );
         composite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
+
+        // SchemaConnectors Group
+        Group schemaConnectorsGroup = new Group( composite, SWT.NONE );
+        schemaConnectorsGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+        schemaConnectorsGroup.setLayout( new GridLayout( 2, true ) );
+        schemaConnectorsGroup.setText( "Schema Connectors" );
+
+        // Available Schema Connectors Label
+        Label availableSchemaConnectorsLabel = new Label( schemaConnectorsGroup, SWT.NONE );
+        availableSchemaConnectorsLabel.setText( "Available Connectors:" );
+
+        // Description Label
+        Label descriptionLabel = new Label( schemaConnectorsGroup, SWT.NONE );
+        descriptionLabel.setText( "Description:" );
+        // SchemaConnectors TableViewer
+        final TableViewer schemaConnectorsTableViewer = new TableViewer( schemaConnectorsGroup, SWT.BORDER | SWT.SINGLE
+            | SWT.FULL_SELECTION );
+        GridData gridData = new GridData( SWT.FILL, SWT.NONE, true, false );
+        gridData.heightHint = 125;
+        schemaConnectorsTableViewer.getTable().setLayoutData( gridData );
+        schemaConnectorsTableViewer.setContentProvider( new ArrayContentProvider() );
+        schemaConnectorsTableViewer.setLabelProvider( new LabelProvider()
+        {
+            public String getText( Object element )
+            {
+                return ( ( SchemaConnector ) element ).getName();
+            }
+
+
+            public Image getImage( Object element )
+            {
+                return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+                    PluginConstants.IMG_SCHEMA_CONNECTOR ).createImage();
+            }
+        } );
+        
+        schemaConnectorsTableViewer.setComparator( new ViewerComparator( new Comparator<String>()
+        {
+            public int compare( String o1, String o2 )
+            {
+                if ( ( o1 != null ) && ( o2 != null ) )
+                {
+                    return o1.compareToIgnoreCase( o2 );
+                }
+
+                // Default
+                return 0;
+            }
+        } ) );
+       
+//      schemaConnectorsTableViewer.setComparator( new ViewerComparator( new Comparator<SchemaConnector>()
+//      {
+//          public int compare( SchemaConnector o1, SchemaConnector o2 )
+//          {
+//              String name1 = o1.getName();
+//              String name2 = o2.getName();
+//
+//              if ( ( name1 != null ) && ( name2 != null ) )
+//              {
+//                  return name1.compareToIgnoreCase( name2 );
+//              }
+//
+//              // Default
+//              return 0;
+//          }
+//      } ) );
+        schemaConnectorsTableViewer.setInput( PluginUtils.getSchemaConnectors() );
+
+        // Description Text
+        final Text descriptionText = new Text( schemaConnectorsGroup, SWT.BORDER | SWT.MULTI | SWT.READ_ONLY );
+        descriptionText.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
+
+        schemaConnectorsTableViewer.addSelectionChangedListener( new ISelectionChangedListener()
+        {
+            public void selectionChanged( SelectionChangedEvent event )
+            {
+                SchemaConnector schemaConnector = ( SchemaConnector ) ( ( StructuredSelection ) schemaConnectorsTableViewer
+                    .getSelection() ).getFirstElement();
+
+                if ( schemaConnector != null )
+                {
+                    descriptionText.setText( schemaConnector.getDescription() );
+                }
+            }
+        } );
 
         return parent;
     }

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/ProjectsViewLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/ProjectsViewLabelProvider.java?rev=575592&r1=575591&r2=575592&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/ProjectsViewLabelProvider.java (original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/ProjectsViewLabelProvider.java Fri Sep 14 02:01:01 2007
@@ -61,16 +61,16 @@
                             return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
                                 PluginConstants.IMG_PROJECT_OFFLINE_CLOSED ).createImage();
                     }
-                case APACHE_DIRECTORY_SERVER:
+                case ONLINE:
                     ProjectState state2 = project.getState();
                     switch ( state2 )
                     {
                         case OPEN:
                             return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
-                                PluginConstants.IMG_PROJECT_ADS ).createImage();
+                                PluginConstants.IMG_PROJECT_ONLINE ).createImage();
                         case CLOSED:
                             return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
-                                PluginConstants.IMG_PROJECT_ADS_CLOSED ).createImage();
+                                PluginConstants.IMG_PROJECT_ONLINE_CLOSED ).createImage();
                     }
             }
         }

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportProjectsWizardPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportProjectsWizardPage.java?rev=575592&r1=575591&r2=575592&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportProjectsWizardPage.java (original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportProjectsWizardPage.java Fri Sep 14 02:01:01 2007
@@ -140,9 +140,9 @@
                         case OFFLINE:
                             return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
                                 PluginConstants.IMG_PROJECT_OFFLINE_CLOSED ).createImage();
-                        case APACHE_DIRECTORY_SERVER:
+                        case ONLINE:
                             return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
-                                PluginConstants.IMG_PROJECT_ADS_CLOSED ).createImage();
+                                PluginConstants.IMG_PROJECT_ONLINE_CLOSED ).createImage();
                     }
                 }
 

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizard.java?rev=575592&r1=575591&r2=575592&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizard.java (original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizard.java Fri Sep 14 02:01:01 2007
@@ -20,12 +20,22 @@
 package org.apache.directory.studio.schemaeditor.view.wizards;
 
 
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.StudioProgressMonitor;
 import org.apache.directory.studio.schemaeditor.Activator;
 import org.apache.directory.studio.schemaeditor.PluginUtils;
 import org.apache.directory.studio.schemaeditor.controller.ProjectsHandler;
 import org.apache.directory.studio.schemaeditor.model.Project;
 import org.apache.directory.studio.schemaeditor.model.ProjectType;
 import org.apache.directory.studio.schemaeditor.model.Schema;
+import org.apache.directory.studio.schemaeditor.model.io.SchemaConnector;
+import org.apache.directory.studio.schemaeditor.view.ViewUtils;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.wizard.IWizardPage;
 import org.eclipse.jface.wizard.Wizard;
@@ -45,9 +55,11 @@
 
     // The pages of the wizard
     private NewProjectWizardInformationPage informationPage;
-//    private NewProjectWizardConnectionSelectionPage connectionSelectionPage;
+    private NewProjectWizardConnectionSelectionPage connectionSelectionPage;
     private NewProjectWizardSchemasSelectionPage schemasSelectionPage;
 
+    private Throwable exceptionThrown = null;
+
 
     /* (non-Javadoc)
      * @see org.eclipse.jface.wizard.Wizard#addPages()
@@ -56,12 +68,12 @@
     {
         // Creating pages
         informationPage = new NewProjectWizardInformationPage();
-//        connectionSelectionPage = new NewProjectWizardConnectionSelectionPage();
+        connectionSelectionPage = new NewProjectWizardConnectionSelectionPage();
         schemasSelectionPage = new NewProjectWizardSchemasSelectionPage();
 
         // Adding pages
         addPage( informationPage );
-//        addPage( connectionSelectionPage );
+        addPage( connectionSelectionPage );
         addPage( schemasSelectionPage );
     }
 
@@ -71,35 +83,89 @@
      */
     public boolean performFinish()
     {
-        Project project = new Project( ProjectType.OFFLINE, informationPage.getProjectName() );
-//        final Project project = new Project( informationPage.getProjectType(), informationPage.getProjectName() );
-//        if ( informationPage.getProjectType().equals( ProjectType.APACHE_DIRECTORY_SERVER ) )
-//        {
-//            Connection connection = connectionSelectionPage.getSelectedConnection();
-//            project.setConnection( connection );
-//            try
-//            {
-//                getContainer().run( true, true, new IRunnableWithProgress()
-//                {
-//                    public void run( IProgressMonitor monitor )
-//                    {
-//                        project.fetchOnlineSchema( new StudioProgressMonitor( monitor ) );
-//                    }
-//                } );
-//            }
-//            catch ( InvocationTargetException e )
-//            {
-//                // TODO Auto-generated catch block
-//                e.printStackTrace();
-//            }
-//            catch ( InterruptedException e )
-//            {
-//                // TODO Auto-generated catch block
-//                e.printStackTrace();
-//            }
-//        }
-//        else if ( informationPage.getProjectType().equals( ProjectType.OFFLINE ) )
-//        {
+        String projectName = informationPage.getProjectName();
+        ProjectType projectType = informationPage.getProjectType();
+
+        // Creating the project
+        final Project project = new Project( projectType, projectName );
+
+        if ( projectType.equals( ProjectType.ONLINE ) )
+        // Project is an "Online Project"
+        {
+            // Setting the connection to use
+            project.setConnection( connectionSelectionPage.getSelectedConnection() );
+
+            // Reseting the Exception Thrown
+            exceptionThrown = null;
+            
+            try
+            {
+                getContainer().run( true, false, new IRunnableWithProgress()
+                {
+                    public void run( IProgressMonitor monitor )
+                    {
+                        StudioProgressMonitor studioProgressMonitor = new StudioProgressMonitor( monitor );
+
+                        // Getting the correct SchemaConnector for this connection
+                        List<SchemaConnector> correctSchemaConnectors = getCorrectSchemaConnectors( project
+                            .getConnection(), studioProgressMonitor );
+
+                        // If no suitable SchemaConnector has been found, we display an
+                        // error message and return false;
+                        if ( correctSchemaConnectors.size() == 0 )
+                        {
+                            studioProgressMonitor.reportError(
+                                "No suitable SchemaConnector has been found for the choosen Directory Server.",
+                                new RuntimeException(
+                                    "No suitable SchemaConnector has been found for the choosen Directory Server." ) );
+                        }
+
+                        // Getting the correct SchemaConnector
+                        SchemaConnector correctSchemaConnector = null;
+                        if ( correctSchemaConnectors.size() == 1 )
+                        {
+                            correctSchemaConnector = correctSchemaConnectors.get( 0 );
+                        }
+                        else
+                        {
+                            // TODO display a dialog in which the user can select the correct schema connector
+                        }
+
+                        project.setSchemaConnector( correctSchemaConnector );
+
+                        // Fetching the Online Schema
+                        project.fetchOnlineSchema( new StudioProgressMonitor( monitor ) );
+
+                        // Checking if an error has occured
+                        if ( studioProgressMonitor.errorsReported() )
+                        {
+                            exceptionThrown = studioProgressMonitor.getException();
+                            return;
+                        }
+                    }
+                } );
+            }
+            catch ( InvocationTargetException e )
+            {
+                PluginUtils.logError( "An error occured when creating the project.", e );
+                ViewUtils.displayErrorMessageBox( "Error", "An error occured when creating the project." );
+            }
+            catch ( InterruptedException e )
+            {
+                // Nothing to do.
+            }
+
+            if ( exceptionThrown != null )
+            {
+                PluginUtils.logError( "An error occured when creating the project.", exceptionThrown );
+                ViewUtils.displayErrorMessageBox( "Error", "An error occured when creating the project." );
+                return false;
+            }
+        }
+        else if ( projectType.equals( ProjectType.OFFLINE ) )
+        // Project is an "Online Project"
+        {
+            // Getting the selected 'core' schemas
             String[] selectedSchemas = schemasSelectionPage.getSelectedSchemas();
             if ( selectedSchemas != null )
             {
@@ -112,7 +178,7 @@
                     }
                 }
             }
-//        }
+        }
 
         ProjectsHandler projectsHandler = Activator.getDefault().getProjectsHandler();
         projectsHandler.addProject( project );
@@ -122,44 +188,71 @@
     }
 
 
-//    /* (non-Javadoc)
-//     * @see org.eclipse.jface.wizard.Wizard#getNextPage(org.eclipse.jface.wizard.IWizardPage)
-//     */
-//    public IWizardPage getNextPage( IWizardPage page )
-//    {
-//        if ( page.equals( informationPage ) )
-//        {
-//            if ( informationPage.getProjectType().equals( ProjectType.APACHE_DIRECTORY_SERVER ) )
-//            {
-//                return connectionSelectionPage;
-//            }
-//            else if ( informationPage.getProjectType().equals( ProjectType.OFFLINE ) )
-//            {
-//                return schemasSelectionPage;
-//            }
-//
-//            // Default
-//            return null;
-//        }
-//
-//        // Default
-//        return null;
-//    }
-
-
-//    /* (non-Javadoc)
-//     * @see org.eclipse.jface.wizard.Wizard#getPreviousPage(org.eclipse.jface.wizard.IWizardPage)
-//     */
-//    public IWizardPage getPreviousPage( IWizardPage page )
-//    {
-//        if ( ( page.equals( connectionSelectionPage ) ) || ( page.equals( schemasSelectionPage ) ) )
-//        {
-//            return informationPage;
-//        }
-//
-//        // Default
-//        return null;
-//    }
+    /**
+     * Gets the List of suitable SchemaConnectors
+     *
+     * @param connection
+     *      the connection to test the SchemaConnectors with
+     * @return
+     *      the List of suitable SchemaConnectors
+     */
+    private List<SchemaConnector> getCorrectSchemaConnectors( Connection connection, StudioProgressMonitor monitor )
+    {
+        List<SchemaConnector> suitableSchemaConnectors = new ArrayList<SchemaConnector>();
+
+        // Looping on the SchemaConnectors
+        List<SchemaConnector> schemaConectors = PluginUtils.getSchemaConnectors();
+        for ( SchemaConnector schemaConnector : schemaConectors )
+        {
+            // Testing if the SchemaConnector is suitable for this connection
+            if ( schemaConnector.isSuitableConnector( connection, monitor ) )
+            {
+                suitableSchemaConnectors.add( schemaConnector );
+            }
+        }
+
+        return suitableSchemaConnectors;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.wizard.Wizard#getNextPage(org.eclipse.jface.wizard.IWizardPage)
+     */
+    public IWizardPage getNextPage( IWizardPage page )
+    {
+        if ( page.equals( informationPage ) )
+        {
+            if ( informationPage.getProjectType().equals( ProjectType.ONLINE ) )
+            {
+                return connectionSelectionPage;
+            }
+            else if ( informationPage.getProjectType().equals( ProjectType.OFFLINE ) )
+            {
+                return schemasSelectionPage;
+            }
+
+            // Default
+            return null;
+        }
+
+        // Default
+        return null;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.wizard.Wizard#getPreviousPage(org.eclipse.jface.wizard.IWizardPage)
+     */
+    public IWizardPage getPreviousPage( IWizardPage page )
+    {
+        if ( ( page.equals( connectionSelectionPage ) ) || ( page.equals( schemasSelectionPage ) ) )
+        {
+            return informationPage;
+        }
+
+        // Default
+        return null;
+    }
 
 
     /* (non-Javadoc)
@@ -177,10 +270,10 @@
         {
             return true;
         }
-//        else if ( currentPage.equals( connectionSelectionPage ) )
-//        {
-//            return connectionSelectionPage.isPageComplete();
-//        }
+        else if ( currentPage.equals( connectionSelectionPage ) )
+        {
+            return connectionSelectionPage.isPageComplete();
+        }
         else
         {
             return false;
@@ -193,6 +286,6 @@
      */
     public void init( IWorkbench workbench, IStructuredSelection selection )
     {
-//        setNeedsProgressMonitor( true );
+        setNeedsProgressMonitor( true );
     }
 }

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizardInformationPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizardInformationPage.java?rev=575592&r1=575591&r2=575592&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizardInformationPage.java (original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizardInformationPage.java Fri Sep 14 02:01:01 2007
@@ -22,14 +22,18 @@
 
 import org.apache.directory.studio.schemaeditor.Activator;
 import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.apache.directory.studio.schemaeditor.PluginUtils;
 import org.apache.directory.studio.schemaeditor.controller.ProjectsHandler;
+import org.apache.directory.studio.schemaeditor.model.ProjectType;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
@@ -50,8 +54,8 @@
 
     // UI Fields
     private Text nameText;
-//    private Button typeAdsRadio;
-//    private Button typeOfflineRadio;
+    private Button typeOnlineRadio;
+    private Button typeOfflineRadio;
 
 
     /**
@@ -60,9 +64,8 @@
     protected NewProjectWizardInformationPage()
     {
         super( "NewProjectWizardInformationPage" );
-        setTitle( "Create a Schema project." );
-//        setDescription( "Please specify a name and a type to create a new Schema project." );
-      setDescription( "Please specify a name to create a new Schema project." );
+        setDescription( "Please specify a name and a type to create a new Schema project." );
+        setDescription( "Please specify a name to create a new Schema project." );
         setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
             PluginConstants.IMG_PROJECT_NEW_WIZARD ) );
         projectsHandler = Activator.getDefault().getProjectsHandler();
@@ -90,19 +93,22 @@
                 dialogChanged();
             }
         } );
-//
-//        // Type Group
-//        Group typeGroup = new Group( composite, SWT.NONE );
-//        typeGroup.setText( "Type" );
-//        typeGroup.setLayout( new GridLayout() );
-//        typeGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
-//
-//        typeAdsRadio = new Button( typeGroup, SWT.RADIO );
-//        typeAdsRadio.setText( "Online Apache Directory Server Schema" );
-//        typeAdsRadio.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
-//        typeOfflineRadio = new Button( typeGroup, SWT.RADIO );
-//        typeOfflineRadio.setText( "Offline Schema" );
-//        typeOfflineRadio.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        if ( PluginUtils.getSchemaConnectors().size() > 0 )
+        {
+            // Type Group
+            Group typeGroup = new Group( composite, SWT.NONE );
+            typeGroup.setText( "Type" );
+            typeGroup.setLayout( new GridLayout() );
+            typeGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
+
+            typeOnlineRadio = new Button( typeGroup, SWT.RADIO );
+            typeOnlineRadio.setText( "Online Schema from a Directory Server" );
+            typeOnlineRadio.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+            typeOfflineRadio = new Button( typeGroup, SWT.RADIO );
+            typeOfflineRadio.setText( "Offline Schema" );
+            typeOfflineRadio.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+        }
 
         initFields();
 
@@ -115,7 +121,10 @@
      */
     private void initFields()
     {
-//        typeAdsRadio.setSelection( true );
+        if ( typeOnlineRadio != null )
+        {
+            typeOnlineRadio.setSelection( true );
+        }
 
         displayErrorMessage( null );
         setPageComplete( false );
@@ -168,22 +177,28 @@
         return nameText.getText();
     }
 
-//
-//    /**
-//     * Gets the type of the project.
-//     *
-//     * @return
-//     *      the type of the project
-//     */
-//    public ProjectType getProjectType()
-//    {
-//        if ( typeAdsRadio.getSelection() )
-//        {
-//            return ProjectType.APACHE_DIRECTORY_SERVER;
-//        }
-//        else
-//        {
-//            return ProjectType.OFFLINE;
-//        }
-//    }
+
+    /**
+     * Gets the type of the project.
+     *
+     * @return
+     *      the type of the project
+     */
+    public ProjectType getProjectType()
+    {
+        if ( typeOnlineRadio != null )
+        {
+            if ( typeOnlineRadio.getSelection() )
+            {
+                return ProjectType.ONLINE;
+            }
+            else
+            {
+                return ProjectType.OFFLINE;
+            }
+        }
+        
+        // Default
+        return ProjectType.OFFLINE;
+    }
 }