directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r823482 - in /directory/studio/trunk: connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/ schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ schemaeditor/src/main/java/org/apache/direct...
Date Fri, 09 Oct 2009 09:46:14 GMT
Author: seelmann
Date: Fri Oct  9 09:46:13 2009
New Revision: 823482

URL: http://svn.apache.org/viewvc?rev=823482&view=rev
Log:
Fix for DIRSTUDIO-429 (Meaningless error message on importing schema):
o use RunnableContextRunner to run runnable, which handles the exception (only one popup error
dialog with details button, log to the eclipse log)
o added exception cause to the ...ImportException classes

Added:
    directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/StudioRunnableWithProgressAdapter.java
Modified:
    directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/OpenLdapSchemaFileImportException.java
    directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/OpenLdapSchemaFileImporter.java
    directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/XMLSchemaFileImportException.java
    directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/XMLSchemaFileImporter.java
    directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromOpenLdapWizard.java
    directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromXmlWizard.java
    directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/messages.properties

Added: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/StudioRunnableWithProgressAdapter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/StudioRunnableWithProgressAdapter.java?rev=823482&view=auto
==============================================================================
--- directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/StudioRunnableWithProgressAdapter.java
(added)
+++ directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/StudioRunnableWithProgressAdapter.java
Fri Oct  9 09:46:13 2009
@@ -0,0 +1,65 @@
+/*
+ *  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.connection.core.jobs;
+
+
+import org.apache.directory.studio.connection.core.Connection;
+
+
+/**
+ * An adapter class for StudioRunnableWithProgress.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class StudioRunnableWithProgressAdapter implements StudioRunnableWithProgress
+{
+
+    private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
+    private static final Connection[] EMPTY_CONNECTION_ARRAY = new Connection[0];
+
+
+    /**
+     * @return an empty array
+     */
+    public Object[] getLockedObjects()
+    {
+        return EMPTY_OBJECT_ARRAY;
+    }
+
+
+    /**
+     * @return empty string
+     */
+    public String getErrorMessage()
+    {
+        return "";
+    }
+
+
+    /**
+     * @return an empty array
+     */
+    public Connection[] getConnections()
+    {
+        return EMPTY_CONNECTION_ARRAY;
+    }
+}

Modified: directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/OpenLdapSchemaFileImportException.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/OpenLdapSchemaFileImportException.java?rev=823482&r1=823481&r2=823482&view=diff
==============================================================================
--- directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/OpenLdapSchemaFileImportException.java
(original)
+++ directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/OpenLdapSchemaFileImportException.java
Fri Oct  9 09:46:13 2009
@@ -36,9 +36,11 @@
      *
      * @param message
      *      the message
+     * @param cause
+     *      the cause
      */
-    public OpenLdapSchemaFileImportException( String message )
+    public OpenLdapSchemaFileImportException( String message, Exception cause )
     {
-        super( message );
+        super( message, cause );
     }
 }

Modified: directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/OpenLdapSchemaFileImporter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/OpenLdapSchemaFileImporter.java?rev=823482&r1=823481&r2=823482&view=diff
==============================================================================
--- directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/OpenLdapSchemaFileImporter.java
(original)
+++ directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/OpenLdapSchemaFileImporter.java
Fri Oct  9 09:46:13 2009
@@ -69,7 +69,7 @@
         catch ( IOException e )
         {
             throw new OpenLdapSchemaFileImportException( NLS.bind( Messages
-                .getString( "OpenLdapSchemaFileImporter.NotReadCorrectly" ), new String[]
{ path } ) ); //$NON-NLS-1$
+                .getString( "OpenLdapSchemaFileImporter.NotReadCorrectly" ), new String[]
{ path } ), e ); //$NON-NLS-1$
         }
 
         try
@@ -79,7 +79,7 @@
         catch ( IOException e )
         {
             throw new OpenLdapSchemaFileImportException( NLS.bind( Messages
-                .getString( "OpenLdapSchemaFileImporter.NotReadCorrectly" ), new String[]
{ path } ) ); //$NON-NLS-1$
+                .getString( "OpenLdapSchemaFileImporter.NotReadCorrectly" ), new String[]
{ path } ), e ); //$NON-NLS-1$
         }
         catch ( ParseException e )
         {
@@ -89,7 +89,7 @@
                 { path } ) //$NON-NLS-1$
                 + ( exceptionMessage == null ? "" : NLS.bind( Messages
                     .getString( "OpenLdapSchemaFileImporter.ErrorMessage" ), new String[]
-                    { exceptionMessage.lineNumber, exceptionMessage.columnNumber, exceptionMessage.cause
} ) ) ); //$NON-NLS-1$
+                    { exceptionMessage.lineNumber, exceptionMessage.columnNumber, exceptionMessage.cause
} ) ), e ); //$NON-NLS-1$
         }
 
         String schemaName = getNameFromPath( path );

Modified: directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/XMLSchemaFileImportException.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/XMLSchemaFileImportException.java?rev=823482&r1=823481&r2=823482&view=diff
==============================================================================
--- directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/XMLSchemaFileImportException.java
(original)
+++ directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/XMLSchemaFileImportException.java
Fri Oct  9 09:46:13 2009
@@ -41,4 +41,18 @@
     {
         super( message );
     }
+
+
+    /**
+     * Creates a new instance of XMLSchemaFileImportException.
+     *
+     * @param message
+     *      the message
+     * @param cause
+     *      the cause
+     */
+    public XMLSchemaFileImportException( String message, Exception cause )
+    {
+        super( message, cause );
+    }
 }

Modified: directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/XMLSchemaFileImporter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/XMLSchemaFileImporter.java?rev=823482&r1=823481&r2=823482&view=diff
==============================================================================
--- directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/XMLSchemaFileImporter.java
(original)
+++ directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/XMLSchemaFileImporter.java
Fri Oct  9 09:46:13 2009
@@ -109,7 +109,7 @@
         catch ( DocumentException e )
         {
             throw new XMLSchemaFileImportException( NLS.bind( Messages
-                .getString( "XMLSchemaFileImporter.NotReadCorrectly" ), new String[] { path
} ) ); //$NON-NLS-1$
+                .getString( "XMLSchemaFileImporter.NotReadCorrectly" ), new String[] { path
} ), e ); //$NON-NLS-1$
         }
 
         Element rootElement = document.getRootElement();
@@ -146,7 +146,7 @@
         catch ( DocumentException e )
         {
             throw new XMLSchemaFileImportException( NLS.bind( Messages
-                .getString( "XMLSchemaFileImporter.NotReadCorrectly" ), new String[] { path
} ) ); //$NON-NLS-1$
+                .getString( "XMLSchemaFileImporter.NotReadCorrectly" ), new String[] { path
} ), e ); //$NON-NLS-1$
         }
 
         Element rootElement = document.getRootElement();
@@ -367,7 +367,7 @@
             catch ( IllegalArgumentException e )
             {
                 throw new XMLSchemaFileImportException( Messages
-                    .getString( "XMLSchemaFileImporter.UnceonvertableAttribute" ) );
+                    .getString( "XMLSchemaFileImporter.UnceonvertableAttribute" ), e );
             }
         }
 
@@ -389,7 +389,7 @@
             catch ( NumberFormatException e )
             {
                 throw new XMLSchemaFileImportException( Messages
-                    .getString( "XMLSchemaFileImporter.UnconvertableInteger" ) );
+                    .getString( "XMLSchemaFileImporter.UnconvertableInteger" ), e );
             }
         }
 
@@ -546,7 +546,7 @@
             }
             catch ( IllegalArgumentException e )
             {
-                throw new XMLSchemaFileImportException( Messages.getString( "XMLSchemaFileImporter.UnconvertableValue"
) ); //$NON-NLS-1$
+                throw new XMLSchemaFileImportException( Messages.getString( "XMLSchemaFileImporter.UnconvertableValue"
), e ); //$NON-NLS-1$
             }
         }
 
@@ -837,7 +837,7 @@
         catch ( DocumentException e )
         {
             throw new XMLSchemaFileImportException( NLS.bind( Messages
-                .getString( "XMLSchemaFileImporter.NotReadCorrectly" ), new String[] { path
} ) ); //$NON-NLS-1$
+                .getString( "XMLSchemaFileImporter.NotReadCorrectly" ), new String[] { path
} ), e ); //$NON-NLS-1$
         }
 
         Element rootElement = document.getRootElement();

Modified: directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromOpenLdapWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromOpenLdapWizard.java?rev=823482&r1=823481&r2=823482&view=diff
==============================================================================
--- directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromOpenLdapWizard.java
(original)
+++ directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromOpenLdapWizard.java
Fri Oct  9 09:46:13 2009
@@ -23,18 +23,17 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
-import java.lang.reflect.InvocationTargetException;
 
+import org.apache.directory.studio.connection.core.jobs.StudioProgressMonitor;
+import org.apache.directory.studio.connection.core.jobs.StudioRunnableWithProgress;
+import org.apache.directory.studio.connection.core.jobs.StudioRunnableWithProgressAdapter;
+import org.apache.directory.studio.connection.ui.RunnableContextRunner;
 import org.apache.directory.studio.schemaeditor.Activator;
-import org.apache.directory.studio.schemaeditor.PluginUtils;
 import org.apache.directory.studio.schemaeditor.controller.SchemaHandler;
 import org.apache.directory.studio.schemaeditor.model.Schema;
 import org.apache.directory.studio.schemaeditor.model.io.OpenLdapSchemaFileImportException;
 import org.apache.directory.studio.schemaeditor.model.io.OpenLdapSchemaFileImporter;
 import org.apache.directory.studio.schemaeditor.model.schemachecker.SchemaChecker;
-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.Wizard;
 import org.eclipse.osgi.util.NLS;
@@ -85,73 +84,62 @@
         final File[] selectedSchemasFiles = page.getSelectedSchemaFiles();
         schemaChecker.disableModificationsListening();
 
-        try
+        StudioRunnableWithProgress runnable = new StudioRunnableWithProgressAdapter()
         {
-            getContainer().run( false, false, new IRunnableWithProgress()
+            public void run( StudioProgressMonitor monitor )
             {
-                public void run( IProgressMonitor monitor )
-                {
-                    monitor
-                        .beginTask(
-                            Messages.getString( "ImportSchemasFromOpenLdapWizard.ImportingSchemas"
), selectedSchemasFiles.length ); //$NON-NLS-1$
+                monitor
+                    .beginTask(
+                        Messages.getString( "ImportSchemasFromOpenLdapWizard.ImportingSchemas"
), selectedSchemasFiles.length ); //$NON-NLS-1$
 
-                    for ( File schemaFile : selectedSchemasFiles )
+                for ( File schemaFile : selectedSchemasFiles )
+                {
+                    monitor.subTask( schemaFile.getName() );
+                    try
                     {
-                        monitor.subTask( schemaFile.getName() );
-                        try
-                        {
-                            Schema schema = OpenLdapSchemaFileImporter.getSchema( new FileInputStream(
schemaFile ),
-                                schemaFile.getAbsolutePath() );
-                            schema.setProject( Activator.getDefault().getProjectsHandler().getOpenProject()
);
-                            schemaHandler.addSchema( schema );
-                        }
-                        catch ( OpenLdapSchemaFileImportException e )
-                        {
-                            reportError( e, schemaFile );
-                        }
-                        catch ( FileNotFoundException e )
-                        {
-                            reportError( e, schemaFile );
-                        }
-                        monitor.worked( 1 );
+                        Schema schema = OpenLdapSchemaFileImporter.getSchema( new FileInputStream(
schemaFile ),
+                            schemaFile.getAbsolutePath() );
+                        schema.setProject( Activator.getDefault().getProjectsHandler().getOpenProject()
);
+                        schemaHandler.addSchema( schema );
                     }
-
-                    monitor.done();
+                    catch ( OpenLdapSchemaFileImportException e )
+                    {
+                        reportError( e, schemaFile, monitor );
+                    }
+                    catch ( FileNotFoundException e )
+                    {
+                        reportError( e, schemaFile, monitor );
+                    }
+                    monitor.worked( 1 );
                 }
+            }
 
 
-                /**
-                 * Reports the error raised.
-                 *
-                 * @param e
-                 *      the exception
-                 * @param schemaFile
-                 *      the schema file
-                 */
-                private void reportError( Exception e, File schemaFile )
-                {
-                    PluginUtils
-                        .logError(
-                            NLS
-                                .bind(
-                                    Messages.getString( "ImportSchemasFromOpenLdapWizard.ErrorImportingSchema"
), new String[] { schemaFile.getName() } ), e ); //$NON-NLS-1$
-                    ViewUtils
-                        .displayErrorMessageBox(
-                            Messages.getString( "ImportSchemasFromOpenLdapWizard.Error" ),
//$NON-NLS-1$
-                            NLS
-                                .bind(
-                                    Messages.getString( "ImportSchemasFromOpenLdapWizard.ErrorImportingSchemaPlus"
), new String[] { schemaFile.getName(), e.getMessage() } ) ); //$NON-NLS-1$
-                }
-            } );
-        }
-        catch ( InvocationTargetException e )
-        {
-            // Nothing to do (it will never occur)
-        }
-        catch ( InterruptedException e )
-        {
-            // Nothing to do.
-        }
+            /**
+             * Reports the error raised.
+             *
+             * @param e
+             *      the exception
+             * @param schemaFile
+             *      the schema file
+             * @param monitor
+             *      the monitor the error is reported to
+             * 
+             */
+            private void reportError( Exception e, File schemaFile, StudioProgressMonitor
monitor )
+            {
+                String message = NLS.bind( Messages
+                    .getString( "ImportSchemasFromOpenLdapWizard.ErrorImportingSchema" ),
schemaFile.getName() ); //$NON-NLS-1$
+                monitor.reportError( message, e );
+            }
+
+            public String getName()
+            {
+                return Messages.getString( "ImportSchemasFromOpenLdapWizard.ImportingSchemas"
); //$NON-NLS-1$
+            }
+
+        };
+        RunnableContextRunner.execute( runnable, getContainer(), true );
 
         schemaChecker.enableModificationsListening();
 

Modified: directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromXmlWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromXmlWizard.java?rev=823482&r1=823481&r2=823482&view=diff
==============================================================================
--- directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromXmlWizard.java
(original)
+++ directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromXmlWizard.java
Fri Oct  9 09:46:13 2009
@@ -23,19 +23,18 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
-import java.lang.reflect.InvocationTargetException;
 
+import org.apache.directory.studio.connection.core.jobs.StudioProgressMonitor;
+import org.apache.directory.studio.connection.core.jobs.StudioRunnableWithProgress;
+import org.apache.directory.studio.connection.core.jobs.StudioRunnableWithProgressAdapter;
+import org.apache.directory.studio.connection.ui.RunnableContextRunner;
 import org.apache.directory.studio.schemaeditor.Activator;
-import org.apache.directory.studio.schemaeditor.PluginUtils;
 import org.apache.directory.studio.schemaeditor.controller.SchemaHandler;
 import org.apache.directory.studio.schemaeditor.model.Schema;
 import org.apache.directory.studio.schemaeditor.model.io.XMLSchemaFileImportException;
 import org.apache.directory.studio.schemaeditor.model.io.XMLSchemaFileImporter;
 import org.apache.directory.studio.schemaeditor.model.io.XMLSchemaFileImporter.SchemaFileType;
 import org.apache.directory.studio.schemaeditor.model.schemachecker.SchemaChecker;
-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.Wizard;
 import org.eclipse.osgi.util.NLS;
@@ -85,88 +84,83 @@
         // Getting the schemas to be imported
         final File[] selectedSchemasFiles = page.getSelectedSchemaFiles();
         schemaChecker.disableModificationsListening();
-        try
+
+        StudioRunnableWithProgress runnable = new StudioRunnableWithProgressAdapter()
         {
-            getContainer().run( false, false, new IRunnableWithProgress()
+            public void run( StudioProgressMonitor monitor )
             {
-                public void run( IProgressMonitor monitor )
-                {
-                    monitor
-                        .beginTask(
-                            Messages.getString( "ImportSchemasFromXmlWizard.ImportingSchemas"
), selectedSchemasFiles.length ); //$NON-NLS-1$
+                monitor.beginTask(
+                    Messages.getString( "ImportSchemasFromXmlWizard.ImportingSchemas" ),
selectedSchemasFiles.length ); //$NON-NLS-1$
 
-                    for ( File schemaFile : selectedSchemasFiles )
+                for ( File schemaFile : selectedSchemasFiles )
+                {
+                    monitor.subTask( schemaFile.getName() );
+                    try
                     {
-                        monitor.subTask( schemaFile.getName() );
-                        try
-                        {
-                            SchemaFileType schemaFileType = XMLSchemaFileImporter.getSchemaFileType(
-                                new FileInputStream( schemaFile ), schemaFile.getAbsolutePath()
);
-                            switch ( schemaFileType )
-                            {
-                                case SINGLE:
-                                    Schema importedSchema = XMLSchemaFileImporter.getSchema(
new FileInputStream(
-                                        schemaFile ), schemaFile.getAbsolutePath() );
-                                    importedSchema.setProject( Activator.getDefault().getProjectsHandler()
-                                        .getOpenProject() );
-                                    schemaHandler.addSchema( importedSchema );
-                                    break;
-                                case MULTIPLE:
-                                    Schema[] schemas = XMLSchemaFileImporter.getSchemas(
new FileInputStream(
-                                        schemaFile ), schemaFile.getAbsolutePath() );
-                                    for ( Schema schema : schemas )
-                                    {
-                                        schema.setProject( Activator.getDefault().getProjectsHandler().getOpenProject()
);
-                                        schemaHandler.addSchema( schema );
-                                    }
-                                    break;
-                            }
-                        }
-                        catch ( XMLSchemaFileImportException e )
+                        SchemaFileType schemaFileType = XMLSchemaFileImporter.getSchemaFileType(
new FileInputStream(
+                            schemaFile ), schemaFile.getAbsolutePath() );
+                        switch ( schemaFileType )
                         {
-                            PluginUtils
-                                .logError(
-                                    NLS
-                                        .bind(
-                                            Messages.getString( "ImportSchemasFromXmlWizard.ErrorImportingSchema"
), new File[] { schemaFile } ), e ); //$NON-NLS-1$
-                            ViewUtils
-                                .displayErrorMessageBox(
-                                    Messages.getString( "ImportSchemasFromXmlWizard.Error"
), //$NON-NLS-1$
-                                    NLS
-                                        .bind(
-                                            Messages.getString( "ImportSchemasFromXmlWizard.ErrorImportingSchema"
), new File[] { schemaFile } ) ); //$NON-NLS-1$
+                            case SINGLE:
+                                Schema importedSchema = XMLSchemaFileImporter.getSchema(
new FileInputStream(
+                                    schemaFile ), schemaFile.getAbsolutePath() );
+                                importedSchema
+                                    .setProject( Activator.getDefault().getProjectsHandler().getOpenProject()
);
+                                schemaHandler.addSchema( importedSchema );
+                                break;
+                            case MULTIPLE:
+                                Schema[] schemas = XMLSchemaFileImporter.getSchemas( new
FileInputStream( schemaFile ),
+                                    schemaFile.getAbsolutePath() );
+                                for ( Schema schema : schemas )
+                                {
+                                    schema.setProject( Activator.getDefault().getProjectsHandler().getOpenProject()
);
+                                    schemaHandler.addSchema( schema );
+                                }
+                                break;
                         }
-                        catch ( FileNotFoundException e )
-                        {
-                            PluginUtils
-                                .logError(
-                                    NLS
-                                        .bind(
-                                            Messages.getString( "ImportSchemasFromXmlWizard.ErrorImportingSchema"
), new File[] { schemaFile } ), e ); //$NON-NLS-1$
-                            ViewUtils
-                                .displayErrorMessageBox(
-                                    Messages.getString( "ImportSchemasFromXmlWizard.Error"
), //$NON-NLS-1$
-                                    NLS
-                                        .bind(
-                                            Messages.getString( "ImportSchemasFromXmlWizard.ErrorImportingSchema"
), new File[] { schemaFile } ) ); //$NON-NLS-1$
-                        }
-                        monitor.worked( 1 );
                     }
-
-                    monitor.done();
-                    schemaChecker.enableModificationsListening();
+                    catch ( XMLSchemaFileImportException e )
+                    {
+                        reportError( e, schemaFile, monitor );
+                    }
+                    catch ( FileNotFoundException e )
+                    {
+                        reportError( e, schemaFile, monitor );
+                    }
+                    monitor.worked( 1 );
                 }
-            } );
-        }
-        catch ( InvocationTargetException e )
-        {
-            // Nothing to do (it will never occur)
-        }
-        catch ( InterruptedException e )
-        {
-            // Nothing to do.
-        }
 
+                monitor.done();
+                schemaChecker.enableModificationsListening();
+            }
+
+
+            /**
+             * Reports the error raised.
+             *
+             * @param e
+             *      the exception
+             * @param schemaFile
+             *      the schema file
+             * @param monitor
+             *      the monitor the error is reported to
+             * 
+             */
+            private void reportError( Exception e, File schemaFile, StudioProgressMonitor
monitor )
+            {
+                String message = NLS.bind(
+                    Messages.getString( "ImportSchemasFromXmlWizard.ErrorImportingSchema"
), schemaFile.getName() ); //$NON-NLS-1$
+                monitor.reportError( message, e );
+            }
+
+
+            public String getName()
+            {
+                return Messages.getString( "ImportSchemasFromXmlWizard.ImportingSchemas"
); //$NON-NLS-1$
+            }
+
+        };
+        RunnableContextRunner.execute( runnable, getContainer(), true );
         schemaChecker.enableModificationsListening();
 
         return true;

Modified: directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/messages.properties?rev=823482&r1=823481&r2=823482&view=diff
==============================================================================
--- directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/messages.properties
(original)
+++ directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/messages.properties
Fri Oct  9 09:46:13 2009
@@ -142,8 +142,8 @@
 ImportProjectsWizardPage.SelectAll=Select All
 ImportProjectsWizardPage.SelectFoldertoImportFrom=Select the folder from which import the
files.
 ImportSchemasFromOpenLdapWizard.Error=Error
-ImportSchemasFromOpenLdapWizard.ErrorImportingSchema=An error occured when importing the
schema "{0}".
-ImportSchemasFromOpenLdapWizard.ErrorImportingSchemaPlus=An error occured when importing
the schema "{0}".\n\n{1}
+ImportSchemasFromOpenLdapWizard.ErrorImportingSchema=An error occurred when importing the
schema "{0}".
+ImportSchemasFromOpenLdapWizard.ErrorImportingSchemaPlus=An error occurred when importing
the schema "{0}".\n\n{1}
 ImportSchemasFromOpenLdapWizard.ImportingSchemas=Importing schemas\: 
 ImportSchemasFromOpenLdapWizardPage.Browse=Browse...
 ImportSchemasFromOpenLdapWizardPage.ChooseFolder=Choose Folder



Mime
View raw message