if ( exportType == ExportSchemasAsXmlWizardPage.EXPORT_MULTIPLE_FILES )
{
final String exportDirectory = page.getExportDirectory();
try
{
getContainer().run( false, true, new IRunnableWithProgress()
{
public void run( IProgressMonitor monitor )
{
monitor.beginTask(
Messages.getString( "ExportSchemasForADSWizard.ExportingSchemas" ), selectedSchemas.length ); //$NON-NLS-1$
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( NLS
.bind(
Messages.getString( "ExportSchemasForADSWizard.GeneratedByApacheComment" ), new String[] { format.format( date ) } ) ); //$NON-NLS-1$
try
{
toLdif( schema, sb );
BufferedWriter buffWriter = new BufferedWriter( new FileWriter( exportDirectory + "/" //$NON-NLS-1$
+ schema.getName() + ".ldif" ) ); //$NON-NLS-1$
buffWriter.write( sb.toString() );
buffWriter.close();
}
catch ( IOException e )
{
PluginUtils
.logError(
NLS
.bind(
Messages.getString( "ExportSchemasForADSWizard.ErrorSavingSchema" ), new String[] { schema.getName() } ), e ); //$NON-NLS-1$
ViewUtils
.displayErrorMessageBox(
Messages.getString( "ExportSchemasForADSWizard.Error" ), NLS.bind( Messages.getString( "ExportSchemasForADSWizard.ErrorSavingSchema" ), new String[] { schema.getName() } ) ); //$NON-NLS-1$ //$NON-NLS-2$
}
catch ( NamingException e )
{
PluginUtils
.logError(
NLS
.bind(
Messages.getString( "ExportSchemasForADSWizard.ErrorSavingSchema" ), new String[] { schema.getName() } ), e ); //$NON-NLS-1$
ViewUtils
.displayErrorMessageBox(
Messages.getString( "ExportSchemasForADSWizard.Error" ), NLS.bind( Messages.getString( "ExportSchemasForADSWizard.ErrorSavingSchema" ), new String[] { schema.getName() } ) ); //$NON-NLS-1$ //$NON-NLS-2$
}
monitor.worked( 1 );
}
monitor.done();
}
} );
}
catch ( InvocationTargetException e )
{
// Nothing to do (it will never occur)
}
catch ( InterruptedException e )
{
// Nothing to do.
}
}
else if ( exportType == ExportSchemasAsXmlWizardPage.EXPORT_SINGLE_FILE )
{
final String exportFile = page.getExportFile();
try
{
getContainer().run( false, true, new IRunnableWithProgress()
{
public void run( IProgressMonitor monitor )
{
monitor.beginTask( Messages.getString( "ExportSchemasForADSWizard.ExportingSchemas" ), 1 ); //$NON-NLS-1$