directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r555295 - /directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/ExportSchemasAsXmlWizard.java
Date Wed, 11 Jul 2007 15:05:40 GMT
Author: pamarcelot
Date: Wed Jul 11 08:05:37 2007
New Revision: 555295

URL: http://svn.apache.org/viewvc?view=rev&rev=555295
Log:
Added a progress monitor to report the progress of the export within the wizard.

Modified:
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/ExportSchemasAsXmlWizard.java

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/ExportSchemasAsXmlWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/ExportSchemasAsXmlWizard.java?view=diff&rev=555295&r1=555294&r2=555295
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/ExportSchemasAsXmlWizard.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/ExportSchemasAsXmlWizard.java
Wed Jul 11 08:05:37 2007
@@ -23,9 +23,12 @@
 import java.io.BufferedWriter;
 import java.io.FileWriter;
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 
 import org.apache.directory.studio.apacheds.schemaeditor.model.Schema;
 import org.apache.directory.studio.apacheds.schemaeditor.model.io.XMLSchemaFileExporter;
+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;
@@ -62,27 +65,48 @@
      */
     public boolean performFinish()
     {
-        Schema[] selectedSchemas = page.getSelectedSchemas();
+        final Schema[] selectedSchemas = page.getSelectedSchemas();
 
         int exportType = page.getExportType();
         if ( exportType == ExportSchemasAsXmlWizardPage.EXPORT_MULTIPLE_FILES )
         {
-            String exportDirectory = page.getExportDirectory();
-
-            for ( Schema schema : selectedSchemas )
+            final String exportDirectory = page.getExportDirectory();
+            try
             {
-                try
-                {
-                    BufferedWriter buffWriter = new BufferedWriter( new FileWriter( exportDirectory
+ "/"
-                        + schema.getName() + ".xml" ) );
-                    buffWriter.write( XMLSchemaFileExporter.toSourceCode( schema ) );
-                    buffWriter.close();
-                }
-                catch ( IOException e )
+                getContainer().run( true, true, new IRunnableWithProgress()
                 {
-                    // TODO Auto-generated catch block
-                    e.printStackTrace();
-                }
+                    public void run( IProgressMonitor monitor )
+                    {
+                        monitor.beginTask( "Exporting schemas: ", selectedSchemas.length
);
+                        for ( Schema schema : selectedSchemas )
+                        {
+                            monitor.subTask( schema.getName() );
+
+                            try
+                            {
+                                BufferedWriter buffWriter = new BufferedWriter( new FileWriter(
exportDirectory + "/"
+                                    + schema.getName() + ".xml" ) );
+                                buffWriter.write( XMLSchemaFileExporter.toSourceCode( schema
) );
+                                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.
             }
         }
         else if ( exportType == ExportSchemasAsXmlWizardPage.EXPORT_SINGLE_FILE )
@@ -99,6 +123,6 @@
      */
     public void init( IWorkbench workbench, IStructuredSelection selection )
     {
-        // Nothing to do
+        setNeedsProgressMonitor( true );
     }
 }



Mime
View raw message