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/07/30 16:55:54 UTC

svn commit: r561002 - in /directory/studio/trunk/studio-apacheds-schemaeditor: ./ META-INF/ resources/icons/ src/main/java/org/apache/directory/studio/apacheds/schemaeditor/ src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/ sr...

Author: pamarcelot
Date: Mon Jul 30 07:55:53 2007
New Revision: 561002

URL: http://svn.apache.org/viewvc?view=rev&rev=561002
Log:
Added a new Wizard : ExportSchemasForADSWizard.

Added:
    directory/studio/trunk/studio-apacheds-schemaeditor/resources/icons/schemas_export_for_ads.gif   (with props)
    directory/studio/trunk/studio-apacheds-schemaeditor/resources/icons/schemas_export_for_ads_wizard.png   (with props)
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/ExportSchemasForADSAction.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/ExportSchemasForADSWizard.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/ExportSchemasForADSWizardPage.java
Modified:
    directory/studio/trunk/studio-apacheds-schemaeditor/.classpath
    directory/studio/trunk/studio-apacheds-schemaeditor/META-INF/MANIFEST.MF
    directory/studio/trunk/studio-apacheds-schemaeditor/build.properties
    directory/studio/trunk/studio-apacheds-schemaeditor/ivy.xml
    directory/studio/trunk/studio-apacheds-schemaeditor/plugin.xml
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/PluginConstants.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaViewController.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/ObjectClassImpl.java

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/.classpath
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/.classpath?view=diff&rev=561002&r1=561001&r2=561002
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/.classpath (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/.classpath Mon Jul 30 07:55:53 2007
@@ -7,5 +7,6 @@
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
 	<classpathentry kind="lib" path="lib/junit-3.8.2.jar"/>
 	<classpathentry kind="lib" path="lib/apacheds-core-plugin-1.5.0-SNAPSHOT.jar"/>
+	<classpathentry kind="lib" path="lib/shared-converter-0.9.7-SNAPSHOT.jar"/>
 	<classpathentry kind="output" path="target/classes"/>
 </classpath>

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/META-INF/MANIFEST.MF?view=diff&rev=561002&r1=561001&r2=561002
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/META-INF/MANIFEST.MF (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/META-INF/MANIFEST.MF Mon Jul 30 07:55:53 2007
@@ -13,4 +13,5 @@
  org.eclipse.ui.forms
 Eclipse-LazyStart: true
 Bundle-ClassPath: .,
- lib/apacheds-core-plugin-1.5.0-SNAPSHOT.jar
+ lib/apacheds-core-plugin-1.5.0-SNAPSHOT.jar,
+ lib/shared-converter-0.9.7-SNAPSHOT.jar

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/build.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/build.properties?view=diff&rev=561002&r1=561001&r2=561002
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/build.properties (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/build.properties Mon Jul 30 07:55:53 2007
@@ -6,5 +6,5 @@
                META-INF/,\
                .,\
                resources/,\
-               lib/,\
-               lib/apacheds-core-plugin-1.5.0-SNAPSHOT.jar
+               lib/apacheds-core-plugin-1.5.0-SNAPSHOT.jar,\
+               lib/shared-converter-0.9.7-SNAPSHOT.jar

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/ivy.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/ivy.xml?view=diff&rev=561002&r1=561001&r2=561002
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/ivy.xml (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/ivy.xml Mon Jul 30 07:55:53 2007
@@ -19,7 +19,14 @@
 <ivy-module version="1.0">
 	<info organisation="org.apache.directory.studio" module="studio-apacheds-schemaeditor"/>
 	<dependencies>
-		<dependency org="junit" name="junit" rev="3.8.2"/>
-		<dependency org="org.apache.directory.server" name="apacheds-core-plugin" rev="1.5.0-SNAPSHOT"/>
+		<dependency org="junit" 
+					name="junit" 
+					rev="3.8.2"/>
+		<dependency org="org.apache.directory.server" 
+					name="apacheds-core-plugin" 
+					rev="1.5.0-SNAPSHOT"/>
+		<dependency org="org.apache.directory.shared" 
+					name="shared-converter" 
+					rev="0.9.7-SNAPSHOT"/>
     </dependencies>
 </ivy-module>

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/plugin.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/plugin.xml?view=diff&rev=561002&r1=561001&r2=561002
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/plugin.xml (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/plugin.xml Mon Jul 30 07:55:53 2007
@@ -139,6 +139,13 @@
     </wizard>
 	<wizard
           category="org.apache.directory.studio.apacheds.schemaeditor.exportWizardCategory"
+          class="org.apache.directory.studio.apacheds.schemaeditor.view.wizards.ExportSchemasForADSWizard"
+          icon="resources/icons/schemas_export_for_ads.gif"
+          id="org.apache.directory.studio.apacheds.schemaeditor.wizards.ExportSchemasForADSWizard"
+          name="Schemas for Apache DS">
+    </wizard>
+	<wizard
+          category="org.apache.directory.studio.apacheds.schemaeditor.exportWizardCategory"
           class="org.apache.directory.studio.apacheds.schemaeditor.view.wizards.ExportProjectsWizard"
           icon="resources/icons/project_export.gif"
           id="org.apache.directory.studio.apacheds.schemaeditor.wizards.ExportProjectsWizard"

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

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

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

Propchange: directory/studio/trunk/studio-apacheds-schemaeditor/resources/icons/schemas_export_for_ads_wizard.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/PluginConstants.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/PluginConstants.java?view=diff&rev=561002&r1=561001&r2=561002
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/PluginConstants.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/PluginConstants.java Mon Jul 30 07:55:53 2007
@@ -86,6 +86,8 @@
     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";
+    public static final String IMG_SCHEMAS_EXPORT_FOR_ADS = "resources/icons/schemas_export_for_ads.gif";
+    public static final String IMG_SCHEMAS_EXPORT_FOR_ADS_WIZARD = "resources/icons/schemas_export_for_ads_wizard.png";
     public static final String IMG_SCHEMAS_EXPORT_WIZARD = "resources/icons/schemas_export_wizard.png";
     public static final String IMG_SCHEMAS_IMPORT = "resources/icons/schemas_import.gif";
     public static final String IMG_SCHEMAS_IMPORT_WIZARD = "resources/icons/schemas_import_wizard.png";
@@ -103,6 +105,7 @@
     public static final String CMD_EXPORT_SCHEMAS_AS_OPENLDAP = Activator.PLUGIN_ID
         + ".commands.exportSchemasAsOpenLDAP";
     public static final String CMD_EXPORT_SCHEMAS_AS_XML = Activator.PLUGIN_ID + ".commands.exportSchemasAsXML";
+    public static final String CMD_EXPORT_SCHEMAS_FOR_ADS = Activator.PLUGIN_ID + ".commands.exportSchemasForADS";
     public static final String CMD_IMPORT_PROJECTS = Activator.PLUGIN_ID + ".commands.importProjects";
     public static final String CMD_IMPORT_SCHEMAS_FROM_OPENLDAP = Activator.PLUGIN_ID
         + ".commands.importSchemasFromOpenLDAP";

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaViewController.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaViewController.java?view=diff&rev=561002&r1=561001&r2=561002
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaViewController.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaViewController.java Mon Jul 30 07:55:53 2007
@@ -30,6 +30,7 @@
 import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.DeleteSchemaElementAction;
 import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.ExportSchemasAsOpenLdapAction;
 import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.ExportSchemasAsXmlAction;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.ExportSchemasForADSAction;
 import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.ImportSchemasFromOpenLdapAction;
 import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.ImportSchemasFromXmlAction;
 import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.LinkWithEditorAction;
@@ -349,6 +350,7 @@
     private ImportSchemasFromXmlAction importSchemasFromXml;
     private ExportSchemasAsOpenLdapAction exportSchemasAsOpenLdap;
     private ExportSchemasAsXmlAction exportSchemasAsXml;
+    private ExportSchemasForADSAction exportSchemasForADS;
     private CollapseAllAction collapseAll;
     private OpenSchemaViewSortingDialogAction openSchemaViewSortingDialog;
     private OpenSchemaViewPreferenceAction openSchemaViewPreference;
@@ -392,6 +394,7 @@
         importSchemasFromXml = new ImportSchemasFromXmlAction();
         exportSchemasAsOpenLdap = new ExportSchemasAsOpenLdapAction( viewer );
         exportSchemasAsXml = new ExportSchemasAsXmlAction( viewer );
+        exportSchemasForADS = new ExportSchemasForADSAction( viewer );
         collapseAll = new CollapseAllAction( viewer );
         openSchemaViewSortingDialog = new OpenSchemaViewSortingDialogAction();
         openSchemaViewPreference = new OpenSchemaViewPreferenceAction();
@@ -458,6 +461,8 @@
                 manager.add( exportManager );
                 exportManager.add( exportSchemasAsOpenLdap );
                 exportManager.add( exportSchemasAsXml );
+                exportManager.add( new Separator() );
+                exportManager.add( exportSchemasForADS );
 
                 manager.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) );
             }

Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/ExportSchemasForADSAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/ExportSchemasForADSAction.java?view=auto&rev=561002
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/ExportSchemasForADSAction.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/ExportSchemasForADSAction.java Mon Jul 30 07:55:53 2007
@@ -0,0 +1,136 @@
+/*
+ *  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.apacheds.schemaeditor.controller.actions;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.studio.apacheds.schemaeditor.Activator;
+import org.apache.directory.studio.apacheds.schemaeditor.PluginConstants;
+import org.apache.directory.studio.apacheds.schemaeditor.model.Schema;
+import org.apache.directory.studio.apacheds.schemaeditor.view.wizards.ExportSchemasForADSWizard;
+import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.SchemaWrapper;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This action launches the ExportSchemasAsXmlWizard.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ExportSchemasForADSAction extends Action implements IWorkbenchWindowActionDelegate
+{
+    /** The associated viewer */
+    private TreeViewer viewer;
+
+
+    /**
+     * Creates a new instance of ExportSchemasAsXmlAction.
+     */
+    public ExportSchemasForADSAction( TreeViewer viewer )
+    {
+        super( "Schemas for Apache DS" );
+        setToolTipText( getText() );
+        setId( PluginConstants.CMD_EXPORT_SCHEMAS_FOR_ADS );
+        setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+            PluginConstants.IMG_SCHEMAS_EXPORT_FOR_ADS ) );
+        setEnabled( true );
+        this.viewer = viewer;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.action.Action#run()
+     */
+    public void run()
+    {
+        List<Schema> selectedSchemas = new ArrayList<Schema>();
+        // Getting the selection
+        StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();
+        if ( ( !selection.isEmpty() ) && ( selection.size() > 0 ) )
+        {
+            for ( Iterator<?> i = selection.iterator(); i.hasNext(); )
+            {
+                Object o = i.next();
+                if ( o instanceof SchemaWrapper )
+                {
+                    selectedSchemas.add( ( ( SchemaWrapper ) o ).getSchema() );
+                }
+            }
+        }
+
+        // Instantiates and initializes the wizard
+        ExportSchemasForADSWizard wizard = new ExportSchemasForADSWizard();
+        wizard.setSelectedSchemas( selectedSchemas.toArray( new Schema[0] ) );
+        wizard.init( PlatformUI.getWorkbench(), StructuredSelection.EMPTY );
+        // Instantiates the wizard container with the wizard and opens it
+        WizardDialog dialog = new WizardDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard );
+        dialog.create();
+        dialog.open();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+     */
+    public void run( IAction action )
+    {
+        run();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
+     */
+    public void dispose()
+    {
+        // Nothing to do
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
+     */
+    public void init( IWorkbenchWindow window )
+    {
+        // Nothing to do
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+     */
+    public void selectionChanged( IAction action, ISelection selection )
+    {
+        // Nothing to do
+    }
+}

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/ObjectClassImpl.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/ObjectClassImpl.java?view=diff&rev=561002&r1=561001&r2=561002
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/ObjectClassImpl.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/ObjectClassImpl.java Mon Jul 30 07:55:53 2007
@@ -46,13 +46,13 @@
     private ObjectClassTypeEnum type;
 
     /** The optional attribute type names list */
-    private String[] mayNamesList;
+    private String[] mayNamesList = new String[0];
 
     /** The mandatory attribute type names list */
-    private String[] mustNamesList;
+    private String[] mustNamesList = new String[0];
 
     /** The super class names list */
-    private String[] superClassesNames;
+    private String[] superClassesNames = new String[0];
 
 
     /**

Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/ExportSchemasForADSWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/ExportSchemasForADSWizard.java?view=auto&rev=561002
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/ExportSchemasForADSWizard.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/ExportSchemasForADSWizard.java Mon Jul 30 07:55:53 2007
@@ -0,0 +1,481 @@
+/*
+ *  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.apacheds.schemaeditor.view.wizards;
+
+
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.text.DateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.naming.NamingException;
+
+import org.apache.directory.shared.converter.schema.AttributeTypeHolder;
+import org.apache.directory.shared.converter.schema.ObjectClassHolder;
+import org.apache.directory.studio.apacheds.schemaeditor.Activator;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandler;
+import org.apache.directory.studio.apacheds.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.model.ObjectClassImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.model.Schema;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IExportWizard;
+import org.eclipse.ui.IWorkbench;
+
+
+/**
+ * This class represents the wizard to export schemas for Apache DS.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ExportSchemasForADSWizard extends Wizard implements IExportWizard
+{
+    public static final String ID = Activator.PLUGIN_ID + ".wizards.ExportSchemasForADSWizard";
+
+    /** The selected schemas */
+    private Schema[] selectedSchemas = new Schema[0];
+
+    // The pages of the wizard
+    private ExportSchemasForADSWizardPage page;
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.wizard.Wizard#addPages()
+     */
+    public void addPages()
+    {
+        // Creating pages
+        page = new ExportSchemasForADSWizardPage();
+        page.setSelectedSchemas( selectedSchemas );
+
+        // Adding pages
+        addPage( page );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.wizard.Wizard#performFinish()
+     */
+    public boolean performFinish()
+    {
+        final Schema[] selectedSchemas = page.getSelectedSchemas();
+
+        int exportType = page.getExportType();
+        if ( exportType == ExportSchemasAsXmlWizardPage.EXPORT_MULTIPLE_FILES )
+        {
+            final String exportDirectory = page.getExportDirectory();
+            try
+            {
+                getContainer().run( true, true, new IRunnableWithProgress()
+                {
+                    public void run( IProgressMonitor monitor )
+                    {
+                        monitor.beginTask( "Exporting schemas: ", selectedSchemas.length );
+                        for ( Schema schema : selectedSchemas )
+                        {
+                            monitor.subTask( schema.getName() );
+
+                            StringBuffer sb = new StringBuffer();
+                            DateFormat format = DateFormat.getDateTimeInstance( DateFormat.LONG, DateFormat.MEDIUM );
+                            Date date = new Date();
+                            sb.append( "# Generated by Apache Directory Studio on " + format.format( date ) + "\n" );
+                            sb.append( "\n" );
+
+                            try
+                            {
+                                toLdif( schema, sb );
+
+                                BufferedWriter buffWriter = new BufferedWriter( new FileWriter( exportDirectory + "/"
+                                    + schema.getName() + ".ldif" ) );
+                                buffWriter.write( sb.toString() );
+                                buffWriter.close();
+                            }
+                            catch ( IOException e )
+                            {
+                                // TODO Auto-generated catch block
+                                e.printStackTrace();
+                            }
+                            catch ( NamingException e )
+                            {
+                                // TODO Auto-generated catch block
+                                e.printStackTrace();
+                            }
+                            monitor.worked( 1 );
+                        }
+                        monitor.done();
+                    }
+                } );
+            }
+            catch ( InvocationTargetException e )
+            {
+                // Nothing to do (it will never occur)
+               e.printStackTrace();
+            }
+            catch ( InterruptedException e )
+            {
+                // Nothing to do.
+            }
+        }
+        else if ( exportType == ExportSchemasAsXmlWizardPage.EXPORT_SINGLE_FILE )
+        {
+            final String exportFile = page.getExportFile();
+            try
+            {
+                getContainer().run( true, true, new IRunnableWithProgress()
+                {
+                    public void run( IProgressMonitor monitor )
+                    {
+                        monitor.beginTask( "Exporting schemas ", 1 );
+
+                        StringBuffer sb = new StringBuffer();
+                        DateFormat format = DateFormat.getDateTimeInstance( DateFormat.LONG, DateFormat.MEDIUM );
+                        Date date = new Date();
+                        sb.append( "# Generated by Apache Directory Studio on " + format.format( date ) + "\n" );
+                        sb.append( "\n" );
+
+                        for ( Schema schema : selectedSchemas )
+                        {
+                            try
+                            {
+                                toLdif( schema, sb );
+                            }
+                            catch ( NamingException e )
+                            {
+                                // TODO Auto-generated catch block
+                                e.printStackTrace();
+                            }
+                        }
+
+                        try
+                        {
+                            BufferedWriter buffWriter = new BufferedWriter( new FileWriter( exportFile ) );
+                            buffWriter.write( sb.toString() );
+                            buffWriter.close();
+                        }
+                        catch ( IOException e )
+                        {
+                            // TODO Auto-generated catch block
+                            e.printStackTrace();
+                        }
+                        monitor.worked( 1 );
+                        monitor.done();
+                    }
+                } );
+            }
+            catch ( InvocationTargetException e )
+            {
+                // Nothing to do (it will never occur)
+            }
+            catch ( InterruptedException e )
+            {
+                // Nothing to do.
+            }
+        }
+
+        return true;
+    }
+
+
+    /**
+     * Converts the given schema as its LDIF for Apache DS representation and stores it into the given StringBuffer.
+     *
+     * @param schema
+     *      the schema
+     * @param sb
+     *      the StringBuffer
+     * @throws NamingException
+     *      if an error occurs during the conversion
+     */
+    private void toLdif( Schema schema, StringBuffer sb ) throws NamingException
+    {
+        sb.append( "# SCHEMA '" + schema.getName().toUpperCase() + "'\n" );
+
+        sb.append( "dn: cn=" + schema.getName() + ", ou=schema\n" );
+        sb.append( "objectclass: metaSchema\n" );
+        sb.append( "objectclass: top\n" );
+        sb.append( "cn: " + schema.getName() + "\n" );
+        String[] schemaDependencies = getSchemaDependencies( schema );
+        for ( String schemaName : schemaDependencies )
+        {
+            sb.append( "m-dependencies: " + schemaName + "\n" );
+        }
+        sb.append( "\n" );
+
+        // Generation the Attribute Types Node
+        sb.append( "dn: ou=attributeTypes, cn=" + schema.getName() + ", ou=schema\n" );
+        sb.append( "objectclass: organizationalUnit\n" );
+        sb.append( "objectclass: top\n" );
+        sb.append( "ou: attributetypes\n" );
+        sb.append( "\n" );
+
+        // Generating LDIF for Attributes Types
+        for ( AttributeTypeImpl at : schema.getAttributeTypes() )
+        {
+            AttributeTypeHolder holder = new AttributeTypeHolder( at.getOid() );
+            holder.setCollective( at.isCollective() );
+            holder.setDescription( at.getDescription() );
+            holder.setEquality( at.getEqualityName() );
+            List<String> names = new ArrayList<String>();
+            for ( String name : at.getNames() )
+            {
+                names.add( name );
+            }
+            holder.setNames( names );
+            holder.setNoUserModification( !at.isCanUserModify() );
+            holder.setObsolete( at.isObsolete() );
+            holder.setOrdering( at.getOrderingName() );
+            holder.setSingleValue( at.isSingleValue() );
+            holder.setSubstr( at.getSubstrName() );
+            holder.setSuperior( at.getSuperiorName() );
+            holder.setSyntax( at.getSyntaxOid() );
+            holder.setOidLen( at.getLength() );
+            holder.setUsage( at.getUsage() );
+
+            sb.append( holder.toLdif( schema.getName() ) + "\n" );
+        }
+
+        // Generation the Comparators Node
+        sb.append( "dn: ou=comparators, cn=" + schema.getName() + ", ou=schema\n" );
+        sb.append( "objectclass: organizationalUnit\n" );
+        sb.append( "objectclass: top\n" );
+        sb.append( "ou: comparators\n" );
+        sb.append( "\n" );
+
+        // Generation the DIT Content Rules Node
+        sb.append( "dn: ou=ditContentRules, cn=" + schema.getName() + ", ou=schema\n" );
+        sb.append( "objectclass: organizationalUnit\n" );
+        sb.append( "objectclass: top\n" );
+        sb.append( "ou: ditcontentrules\n" );
+        sb.append( "\n" );
+
+        // Generation the DIT Structure RulesNode
+        sb.append( "dn: ou=ditStructureRules, cn=" + schema.getName() + ", ou=schema\n" );
+        sb.append( "objectclass: organizationalUnit\n" );
+        sb.append( "objectclass: top\n" );
+        sb.append( "ou: ditstructurerules\n" );
+        sb.append( "\n" );
+
+        // Generation the Matching Rules Node
+        sb.append( "dn: ou=matchingRules, cn=" + schema.getName() + ", ou=schema\n" );
+        sb.append( "objectclass: organizationalUnit\n" );
+        sb.append( "objectclass: top\n" );
+        sb.append( "ou: matchingrules\n" );
+        sb.append( "\n" );
+
+        // Generation the Matching Rule Use Node
+        sb.append( "dn: ou=matchingRuleUse, cn=" + schema.getName() + ", ou=schema\n" );
+        sb.append( "objectclass: organizationalUnit\n" );
+        sb.append( "objectclass: top\n" );
+        sb.append( "ou: matchingruleuse\n" );
+        sb.append( "\n" );
+
+        // Generation the Name Forms Node
+        sb.append( "dn: ou=nameForms, cn=" + schema.getName() + ", ou=schema\n" );
+        sb.append( "objectclass: organizationalUnit\n" );
+        sb.append( "objectclass: top\n" );
+        sb.append( "ou: nameforms\n" );
+        sb.append( "\n" );
+
+        // Generation the Normalizers Node
+        sb.append( "dn: ou=normalizers, cn=" + schema.getName() + ", ou=schema\n" );
+        sb.append( "objectclass: organizationalUnit\n" );
+        sb.append( "objectclass: top\n" );
+        sb.append( "ou: normalizers\n" );
+        sb.append( "\n" );
+
+        // Generation the Object Classes Node
+        sb.append( "dn: ou=objectClasses, cn=" + schema.getName() + ", ou=schema\n" );
+        sb.append( "objectclass: organizationalUnit\n" );
+        sb.append( "objectclass: top\n" );
+        sb.append( "ou: objectClasses\n" );
+        sb.append( "\n" );
+
+        // Generating LDIF for Object Classes
+        for ( ObjectClassImpl oc : schema.getObjectClasses() )
+        {
+            ObjectClassHolder holder = new ObjectClassHolder( oc.getOid() );
+            holder.setClassType( oc.getType() );
+            holder.setDescription( oc.getDescription() );
+            List<String> mayList = new ArrayList<String>();
+            for ( String may : oc.getMayNamesList() )
+            {
+                mayList.add( may );
+            }
+            holder.setMay( mayList );
+            List<String> mustList = new ArrayList<String>();
+            for ( String must : oc.getMustNamesList() )
+            {
+                mustList.add( must );
+            }
+            holder.setMust( mustList );
+            List<String> names = new ArrayList<String>();
+            for ( String name : oc.getNames() )
+            {
+                names.add( name );
+            }
+            holder.setNames( names );
+            List<String> superiorList = new ArrayList<String>();
+            for ( String superior : oc.getSuperClassesNames() )
+            {
+                superiorList.add( superior );
+            }
+            holder.setSuperiors( superiorList );
+            holder.setObsolete( oc.isObsolete() );
+
+            sb.append( holder.toLdif( schema.getName() ) + "\n" );
+        }
+
+        // Generation the Syntax Checkers Node
+        sb.append( "dn: ou=syntaxCheckers, cn=" + schema.getName() + ", ou=schema\n" );
+        sb.append( "objectclass: organizationalUnit\n" );
+        sb.append( "objectclass: top\n" );
+        sb.append( "ou: syntaxcheckers\n" );
+        sb.append( "\n" );
+
+        // Generation the Syntaxes Node
+        sb.append( "dn: ou=syntaxes, cn=" + schema.getName() + ", ou=schema\n" );
+        sb.append( "objectclass: organizationalUnit\n" );
+        sb.append( "objectclass: top\n" );
+        sb.append( "ou: syntaxes\n" );
+        sb.append( "\n" );
+    }
+
+
+    /**
+     * Gets the schema dependencies.
+     *
+     * @param schema
+     *      the schema
+     * @return
+     *      an array containing the names of all the schemas which the given
+     *      schema depends on
+     */
+    private String[] getSchemaDependencies( Schema schema )
+    {
+        Set<String> schemaNames = new HashSet<String>();
+        SchemaHandler schemaHandler = Activator.getDefault().getSchemaHandler();
+
+        // Looping on Attribute Types
+        for ( AttributeTypeImpl at : schema.getAttributeTypes() )
+        {
+            // Superior
+            String supName = at.getSuperiorName();
+            if ( supName != null )
+            {
+                AttributeTypeImpl sup = schemaHandler.getAttributeType( supName );
+                if ( sup != null )
+                {
+                    if ( !schema.getName().toLowerCase().equals( sup.getSchema().toLowerCase() ) )
+                    {
+                        schemaNames.add( sup.getSchema() );
+                    }
+                }
+            }
+        }
+
+        // Looping on Object Classes
+        for ( ObjectClassImpl oc : schema.getObjectClasses() )
+        {
+            // Superiors
+            String[] supNames = oc.getSuperClassesNames();
+            if ( supNames != null )
+            {
+                for ( String supName : oc.getSuperClassesNames() )
+                {
+                    ObjectClassImpl sup = schemaHandler.getObjectClass( supName );
+                    if ( sup != null )
+                    {
+                        if ( !schema.getName().toLowerCase().equals( sup.getSchema().toLowerCase() ) )
+                        {
+                            schemaNames.add( sup.getSchema() );
+                        }
+                    }
+                }
+            }
+
+            // Mays
+            String[] mayNames = oc.getMayNamesList();
+            if ( mayNames != null )
+            {
+                for ( String mayName : mayNames )
+                {
+                    AttributeTypeImpl may = schemaHandler.getAttributeType( mayName );
+                    if ( may != null )
+                    {
+                        if ( !schema.getName().toLowerCase().equals( may.getSchema().toLowerCase() ) )
+                        {
+                            schemaNames.add( may.getSchema() );
+                        }
+                    }
+                }
+
+            }
+
+            // Musts
+            String[] mustNames = oc.getMustNamesList();
+            if ( mustNames != null )
+            {
+                for ( String mustName : oc.getMustNamesList() )
+                {
+                    AttributeTypeImpl must = schemaHandler.getAttributeType( mustName );
+                    if ( must != null )
+                    {
+                        if ( !schema.getName().toLowerCase().equals( must.getSchema().toLowerCase() ) )
+                        {
+                            schemaNames.add( must.getSchema() );
+                        }
+                    }
+                }
+            }
+        }
+
+        return schemaNames.toArray( new String[0] );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+     */
+    public void init( IWorkbench workbench, IStructuredSelection selection )
+    {
+        setNeedsProgressMonitor( true );
+    }
+
+
+    /**
+     * Sets the selected projects.
+     *
+     * @param schemas
+     *      the schemas
+     */
+    public void setSelectedSchemas( Schema[] schemas )
+    {
+        selectedSchemas = schemas;
+    }
+}

Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/ExportSchemasForADSWizardPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/ExportSchemasForADSWizardPage.java?view=auto&rev=561002
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/ExportSchemasForADSWizardPage.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/ExportSchemasForADSWizardPage.java Mon Jul 30 07:55:53 2007
@@ -0,0 +1,542 @@
+/*
+ *  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.apacheds.schemaeditor.view.wizards;
+
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.apache.directory.studio.apacheds.schemaeditor.Activator;
+import org.apache.directory.studio.apacheds.schemaeditor.PluginConstants;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandler;
+import org.apache.directory.studio.apacheds.schemaeditor.model.Schema;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.LabelProvider;
+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.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class represents the WizardPage of the ExportSchemasForADSWizard.
+ * <p>
+ * It is used to let the user enter the informations about the
+ * schemas he wants to export and where to export.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ExportSchemasForADSWizardPage extends WizardPage
+{
+    /** The selected schemas */
+    private Schema[] selectedSchemas = new Schema[0];
+
+    /** The SchemaHandler */
+    private SchemaHandler schemaHandler;
+
+    public static final int EXPORT_MULTIPLE_FILES = 0;
+    public static final int EXPORT_SINGLE_FILE = 1;
+
+    // UI Fields
+    private CheckboxTableViewer schemasTableViewer;
+    private Button schemasTableSelectAllButton;
+    private Button schemasTableDeselectAllButton;
+    private Button exportMultipleFilesRadio;
+    private Label exportMultipleFilesLabel;
+    private Text exportMultipleFilesText;
+    private Button exportMultipleFilesButton;
+    private Button exportSingleFileRadio;
+    private Label exportSingleFileLabel;
+    private Text exportSingleFileText;
+    private Button exportSingleFileButton;
+
+
+    /**
+     * Creates a new instance of ExportSchemasAsXmlWizardPage.
+     */
+    protected ExportSchemasForADSWizardPage()
+    {
+        super( "ExportSchemasForADSWizardPage" );
+        setTitle( "Export schemas for Apache DS" );
+        setDescription( "Please select the schemas to export for Apache DS." );
+        setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+            PluginConstants.IMG_SCHEMAS_EXPORT_FOR_ADS_WIZARD ) );
+        schemaHandler = Activator.getDefault().getSchemaHandler();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+     */
+    public void createControl( Composite parent )
+    {
+        Composite composite = new Composite( parent, SWT.NULL );
+        GridLayout layout = new GridLayout();
+        composite.setLayout( layout );
+
+        // Schemas Group
+        Group schemasGroup = new Group( composite, SWT.NONE );
+        schemasGroup.setText( "Schemas" );
+        schemasGroup.setLayout( new GridLayout( 2, false ) );
+        schemasGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Schemas TableViewer
+        Label schemasLabel = new Label( schemasGroup, SWT.NONE );
+        schemasLabel.setText( "Select the schemas to export:" );
+        schemasLabel.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
+        schemasTableViewer = new CheckboxTableViewer( new Table( schemasGroup, SWT.BORDER | SWT.CHECK
+            | SWT.FULL_SELECTION ) );
+        GridData schemasTableViewerGridData = new GridData( SWT.FILL, SWT.NONE, true, false, 1, 2 );
+        schemasTableViewerGridData.heightHint = 125;
+        schemasTableViewer.getTable().setLayoutData( schemasTableViewerGridData );
+        schemasTableViewer.setContentProvider( new ArrayContentProvider() );
+        schemasTableViewer.setLabelProvider( new LabelProvider()
+        {
+            public String getText( Object element )
+            {
+                if ( element instanceof Schema )
+                {
+                    return ( ( Schema ) element ).getName();
+                }
+
+                // Default
+                return super.getText( element );
+            }
+
+
+            public Image getImage( Object element )
+            {
+                if ( element instanceof Schema )
+                {
+                    return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, PluginConstants.IMG_SCHEMA )
+                        .createImage();
+                }
+
+                // Default
+                return super.getImage( element );
+            }
+        } );
+        schemasTableViewer.addCheckStateListener( new ICheckStateListener()
+        {
+            /**
+             * Notifies of a change to the checked state of an element.
+             *
+             * @param event
+             *      event object describing the change
+             */
+            public void checkStateChanged( CheckStateChangedEvent event )
+            {
+                dialogChanged();
+            }
+        } );
+        schemasTableSelectAllButton = new Button( schemasGroup, SWT.PUSH );
+        schemasTableSelectAllButton.setText( "Select All" );
+        schemasTableSelectAllButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+        schemasTableSelectAllButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                schemasTableViewer.setAllChecked( true );
+                dialogChanged();
+            }
+        } );
+        schemasTableDeselectAllButton = new Button( schemasGroup, SWT.PUSH );
+        schemasTableDeselectAllButton.setText( "Deselect All" );
+        schemasTableDeselectAllButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+        schemasTableDeselectAllButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                schemasTableViewer.setAllChecked( false );
+                dialogChanged();
+            }
+        } );
+
+        // Export Destination Group
+        Group exportDestinationGroup = new Group( composite, SWT.NULL );
+        exportDestinationGroup.setText( "Export Destination" );
+        exportDestinationGroup.setLayout( new GridLayout( 4, false ) );
+        exportDestinationGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Export Multiple Files
+        exportMultipleFilesRadio = new Button( exportDestinationGroup, SWT.RADIO );
+        exportMultipleFilesRadio.setText( "Export each schema as a separate file." );
+        exportMultipleFilesRadio.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 4, 1 ) );
+        exportMultipleFilesRadio.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                exportMultipleFilesSelected();
+                dialogChanged();
+            }
+        } );
+        Label exportMultipleFilesFiller = new Label( exportDestinationGroup, SWT.NONE );
+        exportMultipleFilesFiller.setText( "    " );
+        exportMultipleFilesLabel = new Label( exportDestinationGroup, SWT.NONE );
+        exportMultipleFilesLabel.setText( "Directory:" );
+        exportMultipleFilesText = new Text( exportDestinationGroup, SWT.BORDER );
+        exportMultipleFilesText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+        exportMultipleFilesText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                dialogChanged();
+            }
+        } );
+        exportMultipleFilesButton = new Button( exportDestinationGroup, SWT.PUSH );
+        exportMultipleFilesButton.setText( "Browse..." );
+        exportMultipleFilesButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                chooseExportDirectory();
+                dialogChanged();
+            }
+        } );
+
+        // Export Single File
+        exportSingleFileRadio = new Button( exportDestinationGroup, SWT.RADIO );
+        exportSingleFileRadio.setText( "Export the schemas as a single file." );
+        exportSingleFileRadio.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 4, 1 ) );
+        exportSingleFileRadio.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                exportSingleFileSelected();
+                dialogChanged();
+            }
+        } );
+        Label exportSingleFileFiller = new Label( exportDestinationGroup, SWT.NONE );
+        exportSingleFileFiller.setText( "    " );
+        exportSingleFileLabel = new Label( exportDestinationGroup, SWT.NONE );
+        exportSingleFileLabel.setText( "Export File:" );
+        exportSingleFileText = new Text( exportDestinationGroup, SWT.BORDER );
+        exportSingleFileText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+        exportSingleFileText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                dialogChanged();
+            }
+        } );
+        exportSingleFileButton = new Button( exportDestinationGroup, SWT.PUSH );
+        exportSingleFileButton.setText( "Browse..." );
+        exportSingleFileButton.addSelectionListener( new SelectionAdapter()
+        {
+            /* (non-Javadoc)
+             * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+             */
+            public void widgetSelected( SelectionEvent e )
+            {
+                chooseExportFile();
+                dialogChanged();
+            }
+        } );
+
+        initFields();
+
+        setControl( composite );
+    }
+
+
+    /**
+     * Initializes the UI Fields.
+     */
+    private void initFields()
+    {
+        // Filling the Schemas table
+        if ( schemaHandler != null )
+        {
+            List<Schema> schemas = new ArrayList<Schema>();
+            schemas.addAll( schemaHandler.getSchemas() );
+
+            Collections.sort( schemas, new Comparator<Schema>()
+            {
+                public int compare( Schema o1, Schema o2 )
+                {
+                    return o1.getName().compareToIgnoreCase( o2.getName() );
+                }
+            } );
+
+            schemasTableViewer.setInput( schemas );
+
+            // Setting the selected schemas
+            schemasTableViewer.setCheckedElements( selectedSchemas );
+        }
+
+        // Selecting the Multiple Files choice
+        exportMultipleFilesSelected();
+
+        displayErrorMessage( null );
+        setPageComplete( false );
+    }
+
+
+    /**
+     * This method is called when the exportMultipleFiles radio button is selected.
+     */
+    private void exportMultipleFilesSelected()
+    {
+        exportMultipleFilesRadio.setSelection( true );
+        exportMultipleFilesLabel.setEnabled( true );
+        exportMultipleFilesText.setEnabled( true );
+        exportMultipleFilesButton.setEnabled( true );
+
+        exportSingleFileRadio.setSelection( false );
+        exportSingleFileLabel.setEnabled( false );
+        exportSingleFileText.setEnabled( false );
+        exportSingleFileButton.setEnabled( false );
+    }
+
+
+    /**
+     * This method is called when the exportSingleFile radio button is selected.
+     */
+    private void exportSingleFileSelected()
+    {
+        exportMultipleFilesRadio.setSelection( false );
+        exportMultipleFilesLabel.setEnabled( false );
+        exportMultipleFilesText.setEnabled( false );
+        exportMultipleFilesButton.setEnabled( false );
+
+        exportSingleFileRadio.setSelection( true );
+        exportSingleFileLabel.setEnabled( true );
+        exportSingleFileText.setEnabled( true );
+        exportSingleFileButton.setEnabled( true );
+    }
+
+
+    /**
+     * This method is called when the exportMultipleFiles 'browse' button is selected.
+     */
+    private void chooseExportDirectory()
+    {
+        DirectoryDialog dialog = new DirectoryDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell() );
+        dialog.setText( "Choose Folder" );
+        dialog.setMessage( "Select the folder in which export the files." );
+
+        String selectedDirectory = dialog.open();
+        if ( selectedDirectory != null )
+        {
+            exportMultipleFilesText.setText( selectedDirectory );
+        }
+    }
+
+
+    /**
+     * This method is called when the exportSingleFile 'browse' button is selected.
+     */
+    private void chooseExportFile()
+    {
+        FileDialog dialog = new FileDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.SAVE );
+        dialog.setText( "Select File" );
+        dialog.setFilterExtensions( new String[]
+            { "*.ldif", "*" } );
+        dialog.setFilterNames( new String[]
+            { "LDIF Files", "All Files" } );
+        dialog.setFilterPath( exportSingleFileText.getText() );
+
+        String selectedFile = dialog.open();
+        if ( selectedFile != null )
+        {
+            exportSingleFileText.setText( selectedFile );
+        }
+    }
+
+
+    /**
+     * This method is called when the user modifies something in the UI.
+     */
+    private void dialogChanged()
+    {
+        // Schemas table
+        if ( schemasTableViewer.getCheckedElements().length == 0 )
+        {
+            displayErrorMessage( "One or several schemas must be selected." );
+            return;
+        }
+
+        // Export option
+        if ( exportMultipleFilesRadio.getSelection() )
+        {
+            String directory = exportMultipleFilesText.getText();
+            if ( ( directory == null ) || ( directory.equals( "" ) ) )
+            {
+                displayErrorMessage( "A directory must be selected." );
+                return;
+            }
+            else
+            {
+                File directoryFile = new File( directory );
+                if ( !directoryFile.exists() )
+                {
+                    displayErrorMessage( "The selected directory does not exist." );
+                    return;
+                }
+                else if ( !directoryFile.isDirectory() )
+                {
+                    displayErrorMessage( "The selected directory is not a directory." );
+                    return;
+                }
+                else if ( !directoryFile.canWrite() )
+                {
+                    displayErrorMessage( "The selected directory is not writable." );
+                    return;
+                }
+            }
+        }
+        else if ( exportSingleFileRadio.getSelection() )
+        {
+            String exportFile = exportSingleFileText.getText();
+            if ( ( exportFile == null ) || ( exportFile.equals( "" ) ) )
+            {
+                displayErrorMessage( "A file must be selected." );
+                return;
+            }
+            else
+            {
+                File file = new File( exportFile );
+                if ( !file.getParentFile().canWrite() )
+                {
+                    displayErrorMessage( "The selected file is not writable." );
+                    return;
+                }
+            }
+        }
+
+        displayErrorMessage( null );
+    }
+
+
+    /**
+     * Displays an error message and set the page status as incomplete
+     * if the message is not null.
+     *
+     * @param message
+     *      the message to display
+     */
+    private void displayErrorMessage( String message )
+    {
+        setErrorMessage( message );
+        setPageComplete( message == null );
+    }
+
+
+    /**
+     * Gets the selected schemas.
+     *
+     * @return
+     *      the selected schemas
+     */
+    public Schema[] getSelectedSchemas()
+    {
+        Object[] selectedSchemas = schemasTableViewer.getCheckedElements();
+
+        List<Schema> schemas = new ArrayList<Schema>();
+        for ( Object schema : selectedSchemas )
+        {
+            schemas.add( ( Schema ) schema );
+        }
+
+        return schemas.toArray( new Schema[0] );
+    }
+
+
+    /**
+     * Sets the selected projects.
+     *
+     * @param schemas
+     *      the schemas
+     */
+    public void setSelectedSchemas( Schema[] schemas )
+    {
+        selectedSchemas = schemas;
+    }
+
+
+    /**
+     * Gets the type of export.
+     * <p>
+     * Values can either EXPORT_MULTIPLE_FILES or EXPORT_SINGLE_FILE.
+     * 
+     * @return
+     *      the type of export
+     */
+    public int getExportType()
+    {
+        if ( exportMultipleFilesRadio.getSelection() )
+        {
+            return EXPORT_MULTIPLE_FILES;
+        }
+        else if ( exportSingleFileRadio.getSelection() )
+        {
+            return EXPORT_SINGLE_FILE;
+        }
+
+        // Default 
+        return EXPORT_MULTIPLE_FILES;
+    }
+
+
+    /**
+     * Gets the export directory.
+     *
+     * @return
+     *      the export directory
+     */
+    public String getExportDirectory()
+    {
+        return exportMultipleFilesText.getText();
+    }
+
+
+    /**
+     * Gets the export file.
+     *
+     * @return
+     *      the export file
+     */
+    public String getExportFile()
+    {
+        return exportSingleFileText.getText();
+    }
+}