directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r606055 - in /directory/sandbox/felixk: studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/ studio-...
Date Thu, 20 Dec 2007 23:25:03 GMT
Author: felixk
Date: Thu Dec 20 15:24:57 2007
New Revision: 606055

URL: http://svn.apache.org/viewvc?rev=606055&view=rev
Log:
Update from trunk

Modified:
    directory/sandbox/felixk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/AuthenticationParameterPage.java
    directory/sandbox/felixk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
    directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/BrowserParameterPage.java
    directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginUtils.java
    directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/OpenLdapSchemaFileImporter.java
    directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsImporter.java
    directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/XMLSchemaFileImporter.java
    directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/CommitChangesWizard.java
    directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportProjectsWizard.java
    directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportSchemasAsOpenLdapWizard.java
    directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportSchemasAsXmlWizard.java
    directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportSchemasForADSWizard.java
    directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportProjectsWizard.java
    directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromOpenLdapWizard.java
    directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromXmlWizard.java
    directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromXmlWizardPage.java
    directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizard.java

Modified: directory/sandbox/felixk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/AuthenticationParameterPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/AuthenticationParameterPage.java?rev=606055&r1=606054&r2=606055&view=diff
==============================================================================
--- directory/sandbox/felixk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/AuthenticationParameterPage.java (original)
+++ directory/sandbox/felixk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/AuthenticationParameterPage.java Thu Dec 20 15:24:57 2007
@@ -60,7 +60,7 @@
 
     /** The text widget to input bind password */
     private Text bindPasswordText;
-    
+
     /** The text widget to input saslRealm */
     private Combo saslRealmText;
 
@@ -122,7 +122,8 @@
     {
         return isSaveBindPassword() ? bindPasswordText.getText() : null;
     }
-    
+
+
     private String getSaslRealm()
     {
         return saslRealmText.getText();
@@ -167,13 +168,6 @@
         String[] authMethods = new String[]
             { "Anonymous Authentication", "Simple Authentication", "DIGEST-MD5 (SASL)", "CRAM-MD5 (SASL)" };
         authenticationMethodCombo = BaseWidgetUtils.createReadonlyCombo( groupComposite, authMethods, 1, 2 );
-        authenticationMethodCombo.addSelectionListener( new SelectionAdapter()
-        {
-            public void widgetSelected( SelectionEvent event )
-            {
-                connectionPageModified();
-            }
-        } );
 
         Composite composite2 = BaseWidgetUtils.createColumnContainer( parent, 1, 1 );
 
@@ -183,45 +177,17 @@
         BaseWidgetUtils.createLabel( composite, "Bind DN or user:", 1 );
         String[] dnHistory = HistoryUtils.load( ConnectionUIConstants.DIALOGSETTING_KEY_PRINCIPAL_HISTORY );
         bindPrincipalCombo = BaseWidgetUtils.createCombo( composite, dnHistory, -1, 2 );
-        bindPrincipalCombo.addModifyListener( new ModifyListener()
-        {
-            public void modifyText( ModifyEvent event )
-            {
-                connectionPageModified();
-            }
-        } );
 
         BaseWidgetUtils.createLabel( composite, "Bind password:", 1 );
         bindPasswordText = BaseWidgetUtils.createPasswordText( composite, "", 2 );
-        bindPasswordText.addModifyListener( new ModifyListener()
-        {
-            public void modifyText( ModifyEvent event )
-            {
-                connectionPageModified();
-            }
-        } );
 
         BaseWidgetUtils.createLabel( composite, "SASL Realm:", 1 );
         String[] saslHistory = HistoryUtils.load( ConnectionUIConstants.DIALOGSETTING_KEY_REALM_HISTORY );
         saslRealmText = BaseWidgetUtils.createCombo( composite, saslHistory, -1, 2 );
-        saslRealmText.addModifyListener( new ModifyListener()
-        {
-            public void modifyText( ModifyEvent even )
-            {
-                connectionPageModified();
-            }
-        } );
-        
+
         BaseWidgetUtils.createSpacer( composite, 1 );
         saveBindPasswordButton = BaseWidgetUtils.createCheckbox( composite, "Save password", 1 );
         saveBindPasswordButton.setSelection( true );
-        saveBindPasswordButton.addSelectionListener( new SelectionAdapter()
-        {
-            public void widgetSelected( SelectionEvent event )
-            {
-                connectionPageModified();
-            }
-        } );
 
         checkPrincipalPasswordAuthButton = new Button( composite, SWT.PUSH );
         GridData gd = new GridData( GridData.FILL_HORIZONTAL );
@@ -229,22 +195,6 @@
         checkPrincipalPasswordAuthButton.setLayoutData( gd );
         checkPrincipalPasswordAuthButton.setText( "Check Authentication" );
         checkPrincipalPasswordAuthButton.setEnabled( false );
-        checkPrincipalPasswordAuthButton.addSelectionListener( new SelectionAdapter()
-        {
-            public void widgetSelected( SelectionEvent e )
-            {
-                Connection connection = getTestConnection();
-                CheckBindJob job = new CheckBindJob( connection );
-                RunnableContextJobAdapter.execute( job, runnableContext );
-                if ( job.getExternalResult().isOK() )
-                {
-                    MessageDialog.openInformation( Display.getDefault().getActiveShell(), "Check Authentication",
-                        "The authentication was successful." );
-                }
-            }
-        } );
-        
-        validate();
     }
 
 
@@ -253,7 +203,6 @@
      */
     private void connectionPageModified()
     {
-    	
         validate();
         fireConnectionPageModified();
     }
@@ -286,7 +235,7 @@
                 message = "Please enter a bind DN or user.";
             }
         }
-        
+
         if ( isSaslRealmTextEnabled() )
         {
             if ( "".equals( saslRealmText.getText() ) )
@@ -309,15 +258,17 @@
             || ( getAuthenticationMethod() == AuthenticationMethod.SASL_DIGEST_MD5 )
             || ( getAuthenticationMethod() == AuthenticationMethod.SASL_CRAM_MD5 );
     }
-    
-    
-    private boolean isSaslRealmTextEnabled(){
-    	return getAuthenticationMethod() == AuthenticationMethod.SASL_DIGEST_MD5;
-    }
-    
-    
-    private boolean isGssapiEnabled(){
-    	return getAuthenticationMethod() == AuthenticationMethod.SASL_GSSAPI;
+
+
+    private boolean isSaslRealmTextEnabled()
+    {
+        return getAuthenticationMethod() == AuthenticationMethod.SASL_DIGEST_MD5;
+    }
+
+
+    private boolean isGssapiEnabled()
+    {
+        return getAuthenticationMethod() == AuthenticationMethod.SASL_GSSAPI;
     }
 
 
@@ -338,11 +289,75 @@
         saveBindPasswordButton.setSelection( parameter.getBindPassword() != null );
         saslRealmText.setText( parameter.getSaslRealm() != null ? parameter.getSaslRealm() : "" );
 
+        initListeners();
+
         connectionPageModified();
     }
 
 
     /**
+     * Initializes the listeners.
+     */
+    private void initListeners()
+    {
+        authenticationMethodCombo.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent event )
+            {
+                connectionPageModified();
+            }
+        } );
+
+        bindPrincipalCombo.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent event )
+            {
+                connectionPageModified();
+            }
+        } );
+
+        bindPasswordText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent event )
+            {
+                connectionPageModified();
+            }
+        } );
+
+        saslRealmText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent even )
+            {
+                connectionPageModified();
+            }
+        } );
+
+        saveBindPasswordButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent event )
+            {
+                connectionPageModified();
+            }
+        } );
+
+        checkPrincipalPasswordAuthButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                Connection connection = getTestConnection();
+                CheckBindJob job = new CheckBindJob( connection );
+                RunnableContextJobAdapter.execute( job, runnableContext );
+                if ( job.getExternalResult().isOK() )
+                {
+                    MessageDialog.openInformation( Display.getDefault().getActiveShell(), "Check Authentication",
+                        "The authentication was successful." );
+                }
+            }
+        } );
+    }
+
+
+    /**
      * @see org.apache.directory.studio.connection.ui.ConnectionParameterPage#saveParameters(org.apache.directory.studio.connection.core.ConnectionParameter)
      */
     public void saveParameters( ConnectionParameter parameter )
@@ -350,7 +365,7 @@
         parameter.setAuthMethod( getAuthenticationMethod() );
         parameter.setBindPrincipal( getBindPrincipal() );
         parameter.setBindPassword( getBindPassword() );
-        parameter.setSaslRealm(getSaslRealm());
+        parameter.setSaslRealm( getSaslRealm() );
     }
 
 

Modified: directory/sandbox/felixk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java?rev=606055&r1=606054&r2=606055&view=diff
==============================================================================
--- directory/sandbox/felixk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java (original)
+++ directory/sandbox/felixk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java Thu Dec 20 15:24:57 2007
@@ -151,19 +151,11 @@
      */
     public void createComposite( Composite parent )
     {
-
         Composite composite = BaseWidgetUtils.createColumnContainer( parent, 1, 1 );
 
         Composite nameComposite = BaseWidgetUtils.createColumnContainer( composite, 2, 1 );
         BaseWidgetUtils.createLabel( nameComposite, "Connection name:", 1 );
         nameText = BaseWidgetUtils.createText( nameComposite, "", 1 );
-        nameText.addModifyListener( new ModifyListener()
-        {
-            public void modifyText( ModifyEvent event )
-            {
-                connectionPageModified();
-            }
-        } );
 
         BaseWidgetUtils.createSpacer( composite, 1 );
 
@@ -173,51 +165,16 @@
         BaseWidgetUtils.createLabel( groupComposite, "Hostname:", 1 );
         String[] hostHistory = HistoryUtils.load( ConnectionUIConstants.DIALOGSETTING_KEY_HOST_HISTORY );
         hostCombo = BaseWidgetUtils.createCombo( groupComposite, hostHistory, -1, 2 );
-        hostCombo.addModifyListener( new ModifyListener()
-        {
-            public void modifyText( ModifyEvent event )
-            {
-                connectionPageModified();
-            }
-        } );
 
         BaseWidgetUtils.createLabel( groupComposite, "Port:", 1 );
         String[] portHistory = HistoryUtils.load( ConnectionUIConstants.DIALOGSETTING_KEY_PORT_HISTORY );
         portCombo = BaseWidgetUtils.createCombo( groupComposite, portHistory, -1, 2 );
-        portCombo.addVerifyListener( new VerifyListener()
-        {
-            public void verifyText( VerifyEvent event )
-            {
-                if ( !event.text.matches( "[0-9]*" ) )
-                {
-                    event.doit = false;
-                }
-                if ( portCombo.getText().length() > 4 && event.text.length() > 0 )
-                {
-                    event.doit = false;
-                }
-            }
-        } );
-        portCombo.addModifyListener( new ModifyListener()
-        {
-            public void modifyText( ModifyEvent event )
-            {
-                connectionPageModified();
-            }
-        } );
 
         String[] encMethods = new String[]
             { "No encryption", "Use SSL encryption (ldaps://)", "Use StartTLS extension" };
         int index = 0;
         BaseWidgetUtils.createLabel( groupComposite, "Encryption method:", 1 );
         encryptionMethodCombo = BaseWidgetUtils.createReadonlyCombo( groupComposite, encMethods, index, 2 );
-        encryptionMethodCombo.addSelectionListener( new SelectionAdapter()
-        {
-            public void widgetSelected( SelectionEvent event )
-            {
-                connectionPageModified();
-            }
-        } );
         BaseWidgetUtils.createSpacer( groupComposite, 1 );
         BaseWidgetUtils
             .createLabel(
@@ -232,22 +189,7 @@
         gd.verticalAlignment = SWT.BOTTOM;
         checkConnectionButton.setLayoutData( gd );
         checkConnectionButton.setText( "Check Network Parameter" );
-        checkConnectionButton.addSelectionListener( new SelectionAdapter()
-        {
-            public void widgetSelected( SelectionEvent event )
-            {
-                Connection connection = getTestConnection();
-                CheckNetworkParameterJob job = new CheckNetworkParameterJob( connection );
-                RunnableContextJobAdapter.execute( job, runnableContext );
-                if ( job.getExternalResult().isOK() )
-                {
-                    MessageDialog.openInformation( Display.getDefault().getActiveShell(), "Check Network Parameter",
-                        "The connection was established successfully." );
-                }
-            }
-        } );
 
-        validate();
         nameText.setFocus();
     }
 
@@ -257,10 +199,7 @@
      */
     private void connectionPageModified()
     {
-        // validate()
         validate();
-
-        // fire
         fireConnectionPageModified();
     }
 
@@ -310,7 +249,77 @@
             : parameter.getEncryptionMethod() == EncryptionMethod.START_TLS ? 2 : 0;
         encryptionMethodCombo.select( index );
 
+        initListeners();
+
         connectionPageModified();
+    }
+
+
+    /**
+     * Initializes the listeners.
+     */
+    private void initListeners()
+    {
+        nameText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent event )
+            {
+                connectionPageModified();
+            }
+        } );
+
+        hostCombo.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent event )
+            {
+                connectionPageModified();
+            }
+        } );
+
+        portCombo.addVerifyListener( new VerifyListener()
+        {
+            public void verifyText( VerifyEvent event )
+            {
+                if ( !event.text.matches( "[0-9]*" ) )
+                {
+                    event.doit = false;
+                }
+                if ( portCombo.getText().length() > 4 && event.text.length() > 0 )
+                {
+                    event.doit = false;
+                }
+            }
+        } );
+        portCombo.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent event )
+            {
+                connectionPageModified();
+            }
+        } );
+
+        encryptionMethodCombo.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent event )
+            {
+                connectionPageModified();
+            }
+        } );
+
+        checkConnectionButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent event )
+            {
+                Connection connection = getTestConnection();
+                CheckNetworkParameterJob job = new CheckNetworkParameterJob( connection );
+                RunnableContextJobAdapter.execute( job, runnableContext );
+                if ( job.getExternalResult().isOK() )
+                {
+                    MessageDialog.openInformation( Display.getDefault().getActiveShell(), "Check Network Parameter",
+                        "The connection was established successfully." );
+                }
+            }
+        } );
     }
 
 

Modified: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/BrowserParameterPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/BrowserParameterPage.java?rev=606055&r1=606054&r2=606055&view=diff
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/BrowserParameterPage.java (original)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/BrowserParameterPage.java Thu Dec 20 15:24:57 2007
@@ -174,7 +174,6 @@
     {
         addBaseDNInput( parent );
         addLimitInput( parent );
-        validate();
     }
 
 
@@ -193,13 +192,6 @@
 
         autoFetchBaseDnsButton = BaseWidgetUtils.createCheckbox( groupComposite, "Get base DNs from Root DSE", 2 );
         autoFetchBaseDnsButton.setSelection( true );
-        autoFetchBaseDnsButton.addSelectionListener( new SelectionAdapter()
-        {
-            public void widgetSelected( SelectionEvent arg0 )
-            {
-                connectionPageModified();
-            }
-        } );
 
         fetchBaseDnsButton = new Button( groupComposite, SWT.PUSH );
         fetchBaseDnsButton.setText( "Fetch Base DNs" );
@@ -207,49 +199,9 @@
         gd = new GridData();
         gd.horizontalAlignment = SWT.RIGHT;
         fetchBaseDnsButton.setLayoutData( gd );
-        fetchBaseDnsButton.addSelectionListener( new SelectionAdapter()
-        {
-            public void widgetSelected( SelectionEvent e )
-            {
-                Connection connection = getTestConnection();
-                IBrowserConnection browserConnection = new BrowserConnection( connection );
-
-                FetchBaseDNsJob job = new FetchBaseDNsJob( browserConnection );
-                RunnableContextJobAdapter.execute( job, runnableContext );
-                if ( job.getExternalResult().isOK() )
-                {
-                    if ( job.getBaseDNs().length > 0 )
-                    {
-                        String[] baseDNs = job.getBaseDNs();
-                        baseDNCombo.setItems( baseDNs );
-                        baseDNCombo.select( 0 );
-
-                        String msg = "The server returned the following base DNs:";
-                        for ( int i = 0; i < baseDNs.length; i++ )
-                        {
-                            msg += "\n  - " + baseDNs[i];
-                        }
-                        MessageDialog.openInformation( Display.getDefault().getActiveShell(), "Fetch Base DNs", msg );
-                    }
-                    else
-                    {
-                        MessageDialog.openWarning( Display.getDefault().getActiveShell(), "Fetch Base DNs",
-                            "No base DN returned from server. Please enter the base DN manually." );
-                        autoFetchBaseDnsButton.setSelection( false );
-                    }
-                }
-            }
-        } );
 
         BaseWidgetUtils.createLabel( groupComposite, "Base DN:", 1 );
         baseDNCombo = BaseWidgetUtils.createCombo( groupComposite, new String[0], 0, 2 );
-        baseDNCombo.addModifyListener( new ModifyListener()
-        {
-            public void modifyText( ModifyEvent event )
-            {
-                connectionPageModified();
-            }
-        } );
     }
 
 
@@ -296,7 +248,7 @@
         errorMessage = null;
         if ( !isAutoFetchBaseDns() )
         {
-            if( !LdapDN.isValid( getBaseDN() ) )
+            if ( !LdapDN.isValid( getBaseDN() ) )
             {
                 message = "Please enter a valid base DN.";
             }
@@ -334,7 +286,66 @@
             .getByOrdinal( aliasesDereferencingMethodOrdinal );
         aliasesDereferencingWidget.setAliasesDereferencingMethod( aliasesDereferencingMethod );
 
+        initListeners();
+
         connectionPageModified();
+    }
+
+
+    /**
+     * Initializes the listeners.
+     */
+    private void initListeners()
+    {
+        autoFetchBaseDnsButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent arg0 )
+            {
+                connectionPageModified();
+            }
+        } );
+
+        fetchBaseDnsButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                Connection connection = getTestConnection();
+                IBrowserConnection browserConnection = new BrowserConnection( connection );
+
+                FetchBaseDNsJob job = new FetchBaseDNsJob( browserConnection );
+                RunnableContextJobAdapter.execute( job, runnableContext );
+                if ( job.getExternalResult().isOK() )
+                {
+                    if ( job.getBaseDNs().length > 0 )
+                    {
+                        String[] baseDNs = job.getBaseDNs();
+                        baseDNCombo.setItems( baseDNs );
+                        baseDNCombo.select( 0 );
+
+                        String msg = "The server returned the following base DNs:";
+                        for ( int i = 0; i < baseDNs.length; i++ )
+                        {
+                            msg += "\n  - " + baseDNs[i];
+                        }
+                        MessageDialog.openInformation( Display.getDefault().getActiveShell(), "Fetch Base DNs", msg );
+                    }
+                    else
+                    {
+                        MessageDialog.openWarning( Display.getDefault().getActiveShell(), "Fetch Base DNs",
+                            "No base DN returned from server. Please enter the base DN manually." );
+                        autoFetchBaseDnsButton.setSelection( false );
+                    }
+                }
+            }
+        } );
+
+        baseDNCombo.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent event )
+            {
+                connectionPageModified();
+            }
+        } );
     }
 
 

Modified: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginUtils.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginUtils.java?rev=606055&r1=606054&r2=606055&view=diff
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginUtils.java (original)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginUtils.java Thu Dec 20 15:24:57 2007
@@ -21,9 +21,13 @@
 
 
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.net.URISyntaxException;
 import java.net.URL;
+import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -154,13 +158,18 @@
             Project[] projects = null;
             try
             {
-                projects = ProjectsImporter.getProjects( projectsFile.getAbsolutePath() );
+                projects = ProjectsImporter.getProjects( new FileInputStream( projectsFile ), projectsFile
+                    .getAbsolutePath() );
             }
             catch ( ProjectsImportException e )
             {
-                PluginUtils.logError( "An error occured when loading the projects.", e );
-                ViewUtils.displayErrorMessageBox( "Projects Loading Error",
-                    "An error occured when loading the projects." );
+                handleErrorWhileLoadingProjects( projectsFile, e );
+                return;
+            }
+            catch ( FileNotFoundException e )
+            {
+                handleErrorWhileLoadingProjects( projectsFile, e );
+                return;
             }
 
             for ( Project project : projects )
@@ -172,6 +181,21 @@
 
 
     /**
+     * This method is called when an exception is raised when trying to load the Projects file.
+     * 
+     * @param projectsFile
+     * 		the Projects file
+     * @param e
+     * 		the exception raised
+     */
+    private static void handleErrorWhileLoadingProjects( File projectsFile, Exception e )
+    {
+        PluginUtils.logError( "An error occured when loading the projects.", e );
+        ViewUtils.displayErrorMessageBox( "Projects Loading Error", "An error occured when loading the projects." );
+    }
+
+
+    /**
      * Saves the projects in the Projects File.
      */
     public static void saveProjects()
@@ -210,6 +234,24 @@
 
 
     /**
+     * Logs the given message and exception with the ERROR status level.
+     * 
+     * @param message
+     *      the message
+     * @param exception
+     *      the exception
+     */
+    public static void logInfo( Throwable exception, String message, Object... args )
+    {
+        String msg = MessageFormat.format( message, args );
+        Activator.getDefault().getLog()
+            .log(
+                new Status( Status.ERROR, Activator.getDefault().getBundle().getSymbolicName(), Status.OK, msg,
+                    exception ) );
+    }
+
+
+    /**
      * Logs the given message and exception with the WARNING status level.
      * 
      * @param message
@@ -250,10 +292,23 @@
             }
             else
             {
-                schema = XMLSchemaFileImporter.getSchema( url.toString() );
+                schema = XMLSchemaFileImporter.getSchema( new FileInputStream( new File( url.toURI() ) ), url
+                    .toString() );
             }
         }
         catch ( XMLSchemaFileImportException e )
+        {
+            PluginUtils.logError( "An error occured when loading the schema " + schemaName + ".", e );
+            ViewUtils.displayErrorMessageBox( "Projects Saving Error", "An error occured when loading the schema "
+                + schemaName + "." );
+        }
+        catch ( FileNotFoundException e )
+        {
+            PluginUtils.logError( "An error occured when loading the schema " + schemaName + ".", e );
+            ViewUtils.displayErrorMessageBox( "Projects Saving Error", "An error occured when loading the schema "
+                + schemaName + "." );
+        }
+        catch ( URISyntaxException e )
         {
             PluginUtils.logError( "An error occured when loading the schema " + schemaName + ".", e );
             ViewUtils.displayErrorMessageBox( "Projects Saving Error", "An error occured when loading the schema "

Modified: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/OpenLdapSchemaFileImporter.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/OpenLdapSchemaFileImporter.java?rev=606055&r1=606054&r2=606055&view=diff
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/OpenLdapSchemaFileImporter.java (original)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/OpenLdapSchemaFileImporter.java Thu Dec 20 15:24:57 2007
@@ -20,12 +20,14 @@
 package org.apache.directory.studio.schemaeditor.model.io;
 
 
+import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.MalformedURLException;
 import java.text.ParseException;
 import java.util.List;
+import java.util.Scanner;
+import java.util.regex.MatchResult;
 
 import org.apache.directory.server.core.tools.schema.AttributeTypeLiteral;
 import org.apache.directory.server.core.tools.schema.ObjectClassLiteral;
@@ -47,6 +49,8 @@
     /**
      * Extracts the Schema from the given path.
      *
+     * @param inputStream
+     *      the {@link InputStream} of the file.
      * @param path
      *      the path of the file.
      * @return
@@ -54,34 +58,8 @@
      * @throws OpenLdapSchemaFileImportException
      *      if an error occurrs when importing the schema
      */
-    public static Schema getSchema( String path ) throws OpenLdapSchemaFileImportException
+    public static Schema getSchema( InputStream inputStream, String path ) throws OpenLdapSchemaFileImportException
     {
-        File file = new File( path );
-
-        // Checking the file properties
-        if ( !file.exists() )
-        {
-            throw new OpenLdapSchemaFileImportException( "The file '" + path + "' does not exist." );
-        }
-        else if ( !file.canRead() )
-        {
-            throw new OpenLdapSchemaFileImportException( "The file '" + path + "' can not be read." );
-        }
-
-        InputStream in = null;
-        try
-        {
-            in = file.toURL().openStream();
-        }
-        catch ( MalformedURLException e )
-        {
-            throw new OpenLdapSchemaFileImportException( "The file '" + path + "' can not be read correctly." );
-        }
-        catch ( IOException e )
-        {
-            throw new OpenLdapSchemaFileImportException( "The file '" + path + "' can not be read correctly." );
-        }
-
         OpenLdapSchemaParser parser = null;
         try
         {
@@ -94,7 +72,7 @@
 
         try
         {
-            parser.parse( in );
+            parser.parse( inputStream );
         }
         catch ( IOException e )
         {
@@ -102,7 +80,12 @@
         }
         catch ( ParseException e )
         {
-            throw new OpenLdapSchemaFileImportException( "The file '" + path + "' can not be read correctly." );
+            ExceptionMessage exceptionMessage = parseExceptionMessage( e.getMessage() );
+            throw new OpenLdapSchemaFileImportException( "The file '"
+                + path
+                + "' can not be read correctly."
+                + ( exceptionMessage == null ? "" : "\nLine: " + exceptionMessage.lineNumber + ", Column: "
+                    + exceptionMessage.columnNumber + ", Cause: " + exceptionMessage.cause ) );
         }
 
         String schemaName = getNameFromPath( path );
@@ -200,5 +183,45 @@
         newOC.setMayNamesList( oc.getMay() );
 
         return newOC;
+    }
+
+
+    /**
+     * Parses the exception message and fills an {@link ExceptionMessage}.
+     *
+     * @param message
+     *      the exception message to parse
+     * @return
+     *      the corresponding {@link ExceptionMessage}, or <code>null</code>
+     */
+    private static ExceptionMessage parseExceptionMessage( String message )
+    {
+        Scanner scanner = new Scanner( new ByteArrayInputStream( message.getBytes() ) );
+        String foundString = scanner.findWithinHorizon( ".*line (\\d+):(\\d+): *([^\\n]*).*", message.length() );
+        if ( foundString != null )
+        {
+            MatchResult result = scanner.match();
+            if ( result.groupCount() == 3 )
+            {
+                ExceptionMessage exceptionMessage = new ExceptionMessage();
+                exceptionMessage.lineNumber = result.group( 1 );
+                exceptionMessage.columnNumber = result.group( 2 );
+                exceptionMessage.cause = result.group( 3 );
+
+                scanner.close();
+                return exceptionMessage;
+            }
+
+        }
+
+        scanner.close();
+        return null;
+    }
+
+    private static class ExceptionMessage
+    {
+        String lineNumber;
+        String columnNumber;
+        String cause;
     }
 }

Modified: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsImporter.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsImporter.java?rev=606055&r1=606054&r2=606055&view=diff
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsImporter.java (original)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsImporter.java Thu Dec 20 15:24:57 2007
@@ -20,6 +20,7 @@
 package org.apache.directory.studio.schemaeditor.model.io;
 
 
+import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
@@ -58,6 +59,8 @@
     /**
      * Extract the project from the given path
      *
+     * @param inputStream
+     *      the {@link InputStream} of the file
      * @param path
      *      the path of the file
      * @return
@@ -65,7 +68,7 @@
      * @throws ProjectsImportException 
      *      if an error occurs when importing the project
      */
-    public static Project getProject( String path ) throws ProjectsImportException
+    public static Project getProject( InputStream inputStream, String path ) throws ProjectsImportException
     {
         Project project = new Project();
 
@@ -73,7 +76,7 @@
         Document document = null;
         try
         {
-            document = reader.read( path );
+            document = reader.read( inputStream );
         }
         catch ( DocumentException e )
         {
@@ -93,8 +96,10 @@
 
 
     /**
-     * Extract the projects from the given path
+     * Extract the projects from the given input stream
      *
+     * @param inputStream
+     *      the {@link InputStream} of the file
      * @param path
      *      the path of the file
      * @return
@@ -102,7 +107,7 @@
      * @throws ProjectsImportException 
      *      if an error occurs when importing the project
      */
-    public static Project[] getProjects( String path ) throws ProjectsImportException
+    public static Project[] getProjects( InputStream inputStream, String path ) throws ProjectsImportException
     {
         List<Project> projects = new ArrayList<Project>();
 
@@ -110,10 +115,11 @@
         Document document = null;
         try
         {
-            document = reader.read( path );
+            document = reader.read( inputStream );
         }
         catch ( DocumentException e )
         {
+        	PluginUtils.logError("The file '" + path + "' can not be read correctly.", e);
             throw new ProjectsImportException( "The file '" + path + "' can not be read correctly." );
         }
 
@@ -263,19 +269,21 @@
     /**
      * Gets the type of file.
      *
+     * @param inputStream
+     *      the {@link InputStream} of the file
      * @param path
      *      the path of the file
      * @return
      *      the type of the file
      * @throws ProjectsImportException
      */
-    public static ProjectFileType getProjectFileType( String path ) throws ProjectsImportException
+    public static ProjectFileType getProjectFileType( InputStream inputStream, String path ) throws ProjectsImportException
     {
         SAXReader reader = new SAXReader();
         Document document = null;
         try
         {
-            document = reader.read( path );
+            document = reader.read( inputStream );
         }
         catch ( DocumentException e )
         {

Modified: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/XMLSchemaFileImporter.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/XMLSchemaFileImporter.java?rev=606055&r1=606054&r2=606055&view=diff
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/XMLSchemaFileImporter.java (original)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/XMLSchemaFileImporter.java Thu Dec 20 15:24:57 2007
@@ -21,6 +21,7 @@
 
 
 import java.io.File;
+import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -87,6 +88,8 @@
     /**
      * Extracts the Schemas from the given path.
      *
+     * @param inputStream
+     *      the {@link InputStream} of the file
      * @param path
      *      the path of the file.
      * @return
@@ -94,13 +97,13 @@
      * @throws XMLSchemaFileImportException
      *      if an error occurs when importing the schema
      */
-    public static Schema[] getSchemas( String path ) throws XMLSchemaFileImportException
+    public static Schema[] getSchemas(InputStream inputStream, String path ) throws XMLSchemaFileImportException
     {
         SAXReader reader = new SAXReader();
         Document document = null;
         try
         {
-            document = reader.read( path );
+            document = reader.read( inputStream );
         }
         catch ( DocumentException e )
         {
@@ -120,6 +123,8 @@
     /**
      * Extracts the Schema from the given path.
      *
+     * @param inputStream
+     *      the {@link InputStream} of the file
      * @param path
      *      the path of the file.
      * @return
@@ -127,13 +132,13 @@
      * @throws XMLSchemaFileImportException
      *      if an error occurs when importing the schema
      */
-    public static Schema getSchema( String path ) throws XMLSchemaFileImportException
+    public static Schema getSchema(InputStream inputStream, String path ) throws XMLSchemaFileImportException
     {
         SAXReader reader = new SAXReader();
         Document document = null;
         try
         {
-            document = reader.read( path );
+            document = reader.read( inputStream );
         }
         catch ( DocumentException e )
         {
@@ -812,13 +817,13 @@
      *      the type of the file
      * @throws XMLSchemaFileImportException
      */
-    public static SchemaFileType getSchemaFileType( String path ) throws XMLSchemaFileImportException
+    public static SchemaFileType getSchemaFileType( InputStream inputStream, String path ) throws XMLSchemaFileImportException
     {
         SAXReader reader = new SAXReader();
         Document document = null;
         try
         {
-            document = reader.read( path );
+            document = reader.read( inputStream );
         }
         catch ( DocumentException e )
         {

Modified: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/CommitChangesWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/CommitChangesWizard.java?rev=606055&r1=606054&r2=606055&view=diff
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/CommitChangesWizard.java (original)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/CommitChangesWizard.java Thu Dec 20 15:24:57 2007
@@ -85,23 +85,21 @@
 
         try
         {
-            getContainer().run( true, true, new IRunnableWithProgress()
+            getContainer().run( false, false, new IRunnableWithProgress()
             {
                 public void run( IProgressMonitor monitor )
                 {
-                    //TODO
+                    //TODO implement
                 }
             } );
         }
         catch ( InvocationTargetException e )
         {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
+            // Nothing to do (it will never occur)
         }
         catch ( InterruptedException e )
         {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
+            // Nothing to do.
         }
 
         return true;

Modified: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportProjectsWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportProjectsWizard.java?rev=606055&r1=606054&r2=606055&view=diff
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportProjectsWizard.java (original)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportProjectsWizard.java Thu Dec 20 15:24:57 2007
@@ -85,7 +85,7 @@
         final String exportDirectory = page.getExportDirectory();
         try
         {
-            getContainer().run( true, true, new IRunnableWithProgress()
+            getContainer().run( false, false, new IRunnableWithProgress()
             {
                 public void run( IProgressMonitor monitor )
                 {

Modified: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportSchemasAsOpenLdapWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportSchemasAsOpenLdapWizard.java?rev=606055&r1=606054&r2=606055&view=diff
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportSchemasAsOpenLdapWizard.java (original)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportSchemasAsOpenLdapWizard.java Thu Dec 20 15:24:57 2007
@@ -82,7 +82,7 @@
         final String exportDirectory = page.getExportDirectory();
         try
         {
-            getContainer().run( true, true, new IRunnableWithProgress()
+            getContainer().run( false, false, new IRunnableWithProgress()
             {
                 public void run( IProgressMonitor monitor )
                 {

Modified: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportSchemasAsXmlWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportSchemasAsXmlWizard.java?rev=606055&r1=606054&r2=606055&view=diff
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportSchemasAsXmlWizard.java (original)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportSchemasAsXmlWizard.java Thu Dec 20 15:24:57 2007
@@ -85,7 +85,7 @@
             final String exportDirectory = page.getExportDirectory();
             try
             {
-                getContainer().run( true, true, new IRunnableWithProgress()
+                getContainer().run( false, false, new IRunnableWithProgress()
                 {
                     public void run( IProgressMonitor monitor )
                     {
@@ -128,7 +128,7 @@
             final String exportFile = page.getExportFile();
             try
             {
-                getContainer().run( true, true, new IRunnableWithProgress()
+                getContainer().run( false, false, new IRunnableWithProgress()
                 {
                     public void run( IProgressMonitor monitor )
                     {

Modified: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportSchemasForADSWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportSchemasForADSWizard.java?rev=606055&r1=606054&r2=606055&view=diff
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportSchemasForADSWizard.java (original)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportSchemasForADSWizard.java Thu Dec 20 15:24:57 2007
@@ -97,7 +97,7 @@
             final String exportDirectory = page.getExportDirectory();
             try
             {
-                getContainer().run( true, true, new IRunnableWithProgress()
+                getContainer().run( false, true, new IRunnableWithProgress()
                 {
                     public void run( IProgressMonitor monitor )
                     {
@@ -144,7 +144,6 @@
             catch ( InvocationTargetException e )
             {
                 // Nothing to do (it will never occur)
-                e.printStackTrace();
             }
             catch ( InterruptedException e )
             {
@@ -156,7 +155,7 @@
             final String exportFile = page.getExportFile();
             try
             {
-                getContainer().run( true, true, new IRunnableWithProgress()
+                getContainer().run( false, true, new IRunnableWithProgress()
                 {
                     public void run( IProgressMonitor monitor )
                     {

Modified: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportProjectsWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportProjectsWizard.java?rev=606055&r1=606054&r2=606055&view=diff
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportProjectsWizard.java (original)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportProjectsWizard.java Thu Dec 20 15:24:57 2007
@@ -21,6 +21,8 @@
 
 
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.lang.reflect.InvocationTargetException;
 
 import org.apache.directory.studio.schemaeditor.Activator;
@@ -80,7 +82,7 @@
         final File[] selectedProjectFiles = page.getSelectedProjectFiles();
         try
         {
-            getContainer().run( true, false, new IRunnableWithProgress()
+            getContainer().run( false, false, new IRunnableWithProgress()
             {
                 public void run( IProgressMonitor monitor )
                 {
@@ -91,7 +93,8 @@
                         monitor.subTask( projectFile.getName() );
                         try
                         {
-                            Project project = ProjectsImporter.getProject( projectFile.getAbsolutePath() );
+                            Project project = ProjectsImporter.getProject( new FileInputStream( projectFile ),
+                                projectFile.getAbsolutePath() );
                             projectsHandler.addProject( project );
                         }
                         catch ( ProjectsImportException e )
@@ -101,6 +104,13 @@
                             ViewUtils.displayErrorMessageBox( "Import Error",
                                 "An error occured when importing project " + projectFile.getName() + "." );
                         }
+                        catch ( FileNotFoundException e )
+                        {
+                            PluginUtils.logError( "An error occured when importing project " + projectFile.getName()
+                                + ".", e );
+                            ViewUtils.displayErrorMessageBox( "Import Error",
+                                "An error occured when importing project " + projectFile.getName() + "." );
+                        }
                         monitor.worked( 1 );
                     }
 
@@ -111,7 +121,6 @@
         catch ( InvocationTargetException e )
         {
             // Nothing to do (it will never occur)
-            e.printStackTrace();
         }
         catch ( InterruptedException e )
         {

Modified: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromOpenLdapWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromOpenLdapWizard.java?rev=606055&r1=606054&r2=606055&view=diff
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromOpenLdapWizard.java (original)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromOpenLdapWizard.java Thu Dec 20 15:24:57 2007
@@ -21,6 +21,8 @@
 
 
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.lang.reflect.InvocationTargetException;
 
 import org.apache.directory.studio.schemaeditor.Activator;
@@ -86,7 +88,7 @@
 
         try
         {
-            getContainer().run( true, false, new IRunnableWithProgress()
+            getContainer().run( false, false, new IRunnableWithProgress()
             {
                 public void run( IProgressMonitor monitor )
                 {
@@ -97,20 +99,39 @@
                         monitor.subTask( schemaFile.getName() );
                         try
                         {
-                            Schema schema = OpenLdapSchemaFileImporter.getSchema( schemaFile.getAbsolutePath() );
+                            Schema schema = OpenLdapSchemaFileImporter.getSchema( new FileInputStream( schemaFile ),
+                                schemaFile.getAbsolutePath() );
                             schemaHandler.addSchema( schema );
                         }
                         catch ( OpenLdapSchemaFileImportException e )
                         {
-                            PluginUtils.logError( "An error occured when importing the schema " + schemaFile.getName()
-                                + ".", e );
-                            ViewUtils.displayErrorMessageBox( "Error", "An error occured when importing the schema "
-                                + schemaFile.getName() + "." );
+                            reportError( e, schemaFile );
+                        }
+                        catch ( FileNotFoundException e )
+                        {
+                            reportError( e, schemaFile );
                         }
                         monitor.worked( 1 );
                     }
 
                     monitor.done();
+                }
+
+
+                /**
+                 * Reports the error raised.
+                 *
+                 * @param e
+                 *      the exception
+                 * @param schemaFile
+                 *      the schema file
+                 */
+                private void reportError( Exception e, File schemaFile )
+                {
+                    PluginUtils
+                        .logError( "An error occured when importing the schema " + schemaFile.getName() + ".", e );
+                    ViewUtils.displayErrorMessageBox( "Error", "An error occured when importing the schema "
+                        + schemaFile.getName() + "." + "\n\n" + e.getMessage() );
                 }
             } );
         }

Modified: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromXmlWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromXmlWizard.java?rev=606055&r1=606054&r2=606055&view=diff
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromXmlWizard.java (original)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromXmlWizard.java Thu Dec 20 15:24:57 2007
@@ -21,6 +21,8 @@
 
 
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.lang.reflect.InvocationTargetException;
 
 import org.apache.directory.studio.schemaeditor.Activator;
@@ -82,30 +84,33 @@
         page.saveDialogSettings();
 
         // Getting the schemas to be imported
-        final String[] selectedSchemasFiles = page.getSelectedSchemaFiles();
+        final File[] selectedSchemasFiles = page.getSelectedSchemaFiles();
         schemaChecker.disableModificationsListening();
         try
         {
-            getContainer().run( true, false, new IRunnableWithProgress()
+            getContainer().run( false, false, new IRunnableWithProgress()
             {
                 public void run( IProgressMonitor monitor )
                 {
                     monitor.beginTask( "Importing schemas: ", selectedSchemasFiles.length );
 
-                    for ( String schemaFile : selectedSchemasFiles )
+                    for ( File schemaFile : selectedSchemasFiles )
                     {
-                        monitor.subTask( new File( schemaFile ).getName() );
+                        monitor.subTask( schemaFile.getName() );
                         try
                         {
-                            SchemaFileType schemaFileType = XMLSchemaFileImporter.getSchemaFileType( schemaFile );
+                            SchemaFileType schemaFileType = XMLSchemaFileImporter.getSchemaFileType( new FileInputStream( schemaFile ),
+                                schemaFile.getAbsolutePath() );
                             switch ( schemaFileType )
                             {
                                 case SINGLE:
-                                    Schema importedSchema = XMLSchemaFileImporter.getSchema( schemaFile );
+                                    Schema importedSchema = XMLSchemaFileImporter.getSchema( new FileInputStream( schemaFile ),
+                                        schemaFile.getAbsolutePath() );
                                     schemaHandler.addSchema( importedSchema );
                                     break;
                                 case MULTIPLE:
-                                    Schema[] schemas = XMLSchemaFileImporter.getSchemas( schemaFile );
+                                    Schema[] schemas = XMLSchemaFileImporter.getSchemas( new FileInputStream( schemaFile ), schemaFile
+                                        .getAbsolutePath() );
                                     for ( Schema schema : schemas )
                                     {
                                         schemaHandler.addSchema( schema );
@@ -114,6 +119,12 @@
                             }
                         }
                         catch ( XMLSchemaFileImportException e )
+                        {
+                            PluginUtils.logError( "An error occured when importing  the schema " + schemaFile + ".", e );
+                            ViewUtils.displayErrorMessageBox( "Error", "An error occured when saving the schema "
+                                + schemaFile + "." );
+                        }
+                        catch ( FileNotFoundException e )
                         {
                             PluginUtils.logError( "An error occured when importing  the schema " + schemaFile + ".", e );
                             ViewUtils.displayErrorMessageBox( "Error", "An error occured when saving the schema "

Modified: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromXmlWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromXmlWizardPage.java?rev=606055&r1=606054&r2=606055&view=diff
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromXmlWizardPage.java (original)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromXmlWizardPage.java Thu Dec 20 15:24:57 2007
@@ -327,17 +327,17 @@
      * @return
      *      the selected schema files
      */
-    public String[] getSelectedSchemaFiles()
+    public File[] getSelectedSchemaFiles()
     {
         Object[] selectedSchemaFile = schemaFilesTableViewer.getCheckedElements();
 
-        List<String> schemaFiles = new ArrayList<String>();
+        List<File> schemaFiles = new ArrayList<File>();
         for ( Object schemaFile : selectedSchemaFile )
         {
-            schemaFiles.add( ( ( File ) schemaFile ).getAbsolutePath() );
+            schemaFiles.add( ( File ) schemaFile );
         }
 
-        return schemaFiles.toArray( new String[0] );
+        return schemaFiles.toArray( new File[0] );
     }
 
 

Modified: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizard.java?rev=606055&r1=606054&r2=606055&view=diff
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizard.java (original)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizard.java Thu Dec 20 15:24:57 2007
@@ -101,7 +101,7 @@
 
             try
             {
-                getContainer().run( true, false, new IRunnableWithProgress()
+                getContainer().run( false, false, new IRunnableWithProgress()
                 {
                     public void run( IProgressMonitor monitor )
                     {
@@ -148,8 +148,7 @@
             }
             catch ( InvocationTargetException e )
             {
-                PluginUtils.logError( "An error occured when creating the project.", e );
-                ViewUtils.displayErrorMessageBox( "Error", "An error occured when creating the project." );
+                // Nothing to do (it will never occur)
             }
             catch ( InterruptedException e )
             {



Mime
View raw message