directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r570105 - in /directory/studio/trunk/studio-apacheds-schemaeditor: META-INF/ src/main/java/org/apache/directory/studio/apacheds/schemaeditor/ src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/ src/main/java/org/apac...
Date Mon, 27 Aug 2007 13:29:41 GMT
Author: pamarcelot
Date: Mon Aug 27 06:29:37 2007
New Revision: 570105

URL: http://svn.apache.org/viewvc?rev=570105&view=rev
Log:
Removed ConnectAction.
Added the Connection Plugins as dependencies.
Using the Connections Plugins to select the connection to use in a Apache Directory Studio Online Schema Project.
Updated the OnlineSchemaImporter to use the Connection Plugins.

Added:
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/ProjectType.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/OnlineSchemaImporter.java
Removed:
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/SchemaImporter.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/ConnectAction.java
Modified:
    directory/studio/trunk/studio-apacheds-schemaeditor/META-INF/MANIFEST.MF
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/PluginUtils.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaViewController.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/Project.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/ProjectsExporter.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/ProjectsImporter.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/ProjectsViewLabelProvider.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/ExportProjectsWizardPage.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/ExportSchemasAsXmlWizard.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewProjectWizard.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewProjectWizardConnectionSelectionPage.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewProjectWizardInformationPage.java

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/META-INF/MANIFEST.MF?rev=570105&r1=570104&r2=570105&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/META-INF/MANIFEST.MF (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/META-INF/MANIFEST.MF Mon Aug 27 06:29:37 2007
@@ -6,12 +6,14 @@
 Bundle-Activator: org.apache.directory.studio.apacheds.schemaeditor.Activator
 Bundle-Vendor: Apache Software Foundation
 Bundle-Localization: plugin
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.apache.directory.studio.jars,
+Require-Bundle: org.eclipse.core.runtime,
  org.eclipse.jface.text,
+ org.eclipse.search,
+ org.eclipse.ui,
  org.eclipse.ui.forms,
- org.eclipse.search
+ org.apache.directory.studio.connection.core,
+ org.apache.directory.studio.connection.ui,
+ org.apache.directory.studio.jars
 Eclipse-LazyStart: true
 Bundle-ClassPath: .,
  lib/apacheds-core-plugin-1.5.0-SNAPSHOT.jar,

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/PluginUtils.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/PluginUtils.java?rev=570105&r1=570104&r2=570105&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/PluginUtils.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/PluginUtils.java Mon Aug 27 06:29:37 2007
@@ -25,6 +25,7 @@
 import java.io.FileWriter;
 import java.io.IOException;
 import java.net.URL;
+import java.util.HashMap;
 
 import org.apache.directory.studio.apacheds.schemaeditor.controller.ProjectsHandler;
 import org.apache.directory.studio.apacheds.schemaeditor.model.AttributeTypeImpl;
@@ -37,9 +38,13 @@
 import org.apache.directory.studio.apacheds.schemaeditor.model.io.XMLSchemaFileImportException;
 import org.apache.directory.studio.apacheds.schemaeditor.model.io.XMLSchemaFileImporter;
 import org.apache.directory.studio.apacheds.schemaeditor.view.ViewUtils;
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.core.runtime.Status;
 
+import com.sun.org.apache.bcel.internal.generic.LUSHR;
+
 
 /**
  * This class contains helper methods.
@@ -250,5 +255,27 @@
         }
 
         return schema;
+    }
+
+
+    /**
+     * Gets a Connection from the given name.
+     *
+     * @param name
+     *      the name of the Connection
+     * @return
+     *      the corresponding Connection, or null if no connection was found.
+     */
+    public static Connection getConnection( String name )
+    {
+        Connection[] connectionsArray = ConnectionCorePlugin.getDefault().getConnectionManager().getConnections();
+
+        HashMap<String, Connection> connections = new HashMap<String, Connection>();
+        for ( Connection connection : connectionsArray )
+        {
+            connections.put( connection.getName(), connection );
+        }
+
+        return connections.get( name );
     }
 }

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaViewController.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaViewController.java?rev=570105&r1=570104&r2=570105&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaViewController.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaViewController.java Mon Aug 27 06:29:37 2007
@@ -27,7 +27,6 @@
 import org.apache.directory.studio.apacheds.schemaeditor.PluginConstants;
 import org.apache.directory.studio.apacheds.schemaeditor.PluginUtils;
 import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.CollapseAllAction;
-import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.ConnectAction;
 import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.DeleteSchemaElementAction;
 import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.ExportSchemasAsOpenLdapAction;
 import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.ExportSchemasAsXmlAction;
@@ -58,7 +57,6 @@
 import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.SchemaWrapper;
 import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.TreeNode;
 import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.Folder.FolderType;
-import org.eclipse.jface.action.Action;
 import org.eclipse.jface.action.IMenuListener;
 import org.eclipse.jface.action.IMenuManager;
 import org.eclipse.jface.action.IToolBarManager;
@@ -343,7 +341,6 @@
     };
 
     // The Actions
-    private Action connect;
     private NewSchemaAction newSchema;
     private NewAttributeTypeAction newAttributeType;
     private NewObjectClassAction newObjectClass;
@@ -389,7 +386,6 @@
      */
     private void initActions()
     {
-        connect = new ConnectAction( view );
         newSchema = new NewSchemaAction();
         newAttributeType = new NewAttributeTypeAction( viewer );
         newObjectClass = new NewObjectClassAction( viewer );
@@ -414,7 +410,6 @@
     private void initToolbar()
     {
         IToolBarManager toolbar = view.getViewSite().getActionBars().getToolBarManager();
-        toolbar.add( connect );
         toolbar.add( newSchema );
         toolbar.add( newAttributeType );
         toolbar.add( newObjectClass );

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/Project.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/Project.java?rev=570105&r1=570104&r2=570105&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/Project.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/Project.java Mon Aug 27 06:29:37 2007
@@ -20,8 +20,15 @@
 package org.apache.directory.studio.apacheds.schemaeditor.model;
 
 
+import java.util.List;
+
+import javax.naming.NamingException;
+
 import org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandler;
+import org.apache.directory.studio.apacheds.schemaeditor.model.io.OnlineSchemaImporter;
 import org.apache.directory.studio.apacheds.schemaeditor.model.schemachecker.SchemaChecker;
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.StudioProgressMonitor;
 
 
 /**
@@ -33,20 +40,6 @@
 public class Project
 {
     /**
-     * This enum represents the different types of Project.
-     *
-     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
-     * @version $Rev$, $Date$
-     */
-    public enum ProjectType
-    {
-        /** A schema project not linked to any LDAP Server */
-        OFFLINE,
-        /** A schema project linked to an Apache Directory Server */
-        APACHE_DIRECTORY_SERVER
-    }
-
-    /**
      * This enum represents the different states of Project.
      *
      * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
@@ -66,6 +59,9 @@
     /** The name of the project */
     private String name;
 
+    /** The connection of the project */
+    private Connection connection;
+
     /** The state of the project */
     private ProjectState state;
 
@@ -75,6 +71,12 @@
     /** The SchemaCheker */
     private SchemaChecker schemaChecker;
 
+    /** The backup of the Online Schema */
+    private List<Schema> schemaBackup;
+
+    /** The flag for Online Schema Fetch */
+    private boolean hasOnlineSchemaBeenFetched = false;
+
 
     /**
      * Creates a new instance of Project.
@@ -215,6 +217,74 @@
     public SchemaChecker getSchemaChecker()
     {
         return schemaChecker;
+    }
+
+
+    /**
+     * Gets the Connection.
+     *
+     * @return
+     *      the connection
+     */
+    public Connection getConnection()
+    {
+        return connection;
+    }
+
+
+    /**
+     * Sets the Connection.
+     *
+     * @param connection
+     *      the connection
+     */
+    public void setConnection( Connection connection )
+    {
+        this.connection = connection;
+    }
+
+
+    /**
+     * Fetches the Online Schema.
+     *
+     * @param monitor
+     *      a StudioProgressMonitor
+     */
+    public void fetchOnlineSchema( StudioProgressMonitor monitor )
+    {
+        if ( !hasOnlineSchemaBeenFetched && ( connection != null ) )
+        {
+            try
+            {
+                schemaBackup = OnlineSchemaImporter.getOnlineSchema( connection.getJNDIConnectionWrapper(), monitor );
+            }
+            catch ( NamingException e )
+            {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+
+            monitor.beginTask( "Adding Schema to project", schemaBackup.size() );
+            for ( Schema schema : schemaBackup )
+            {
+                getSchemaHandler().addSchema( schema );
+            }
+
+            monitor.done();
+            hasOnlineSchemaBeenFetched = true;
+        }
+    }
+
+
+    /**
+     * Returns whether the online schema has been fetched.
+     *
+     * @return
+     *      true if the online schema has bee fetched
+     */
+    public boolean hasOnlineSchemaBeenFetched()
+    {
+        return hasOnlineSchemaBeenFetched;
     }
 
 

Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/ProjectType.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/ProjectType.java?rev=570105&view=auto
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/ProjectType.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/ProjectType.java Mon Aug 27 06:29:37 2007
@@ -0,0 +1,35 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.apacheds.schemaeditor.model;
+
+
+/**
+ * This enum represents the different types of Project.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public enum ProjectType
+{
+    /** A schema project not linked to any LDAP Server */
+    OFFLINE,
+    /** A schema project linked to an Apache Directory Server */
+    APACHE_DIRECTORY_SERVER
+}
\ No newline at end of file

Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/OnlineSchemaImporter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/OnlineSchemaImporter.java?rev=570105&view=auto
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/OnlineSchemaImporter.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/OnlineSchemaImporter.java Mon Aug 27 06:29:37 2007
@@ -0,0 +1,822 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.apacheds.schemaeditor.model.io;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+
+import org.apache.directory.shared.ldap.schema.ObjectClassTypeEnum;
+import org.apache.directory.shared.ldap.schema.UsageEnum;
+import org.apache.directory.studio.apacheds.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.model.MatchingRuleImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.model.ObjectClassImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.model.Schema;
+import org.apache.directory.studio.apacheds.schemaeditor.model.SchemaImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.model.SyntaxImpl;
+import org.apache.directory.studio.connection.core.StudioProgressMonitor;
+import org.apache.directory.studio.connection.core.io.jndi.JNDIConnectionWrapper;
+
+
+/**
+ * This class is used to import the schema from Apache Directory Server.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class OnlineSchemaImporter
+{
+    /** The Schema DN */
+    public static final String SCHEMA_DN = "ou=schema";
+
+    /** The name of the metaAttributeType object class */
+    private static final String META_ATTRIBUTE_TYPE = "metaAttributeType";
+    /** The name of the metaObjectClass object class */
+    private static final String META_OBJECT_CLASS = "metaObjectClass";
+    /** The name of the metaMatchingRule object class */
+    private static final String META_MATCHING_RULE = "metaMatchingRule";
+    /** The name of the metaSyntax object class */
+    private static final String META_SYNTAX = "metaSyntax";
+
+    private static final String DEREF_ALIAS_METHOD = "always";
+    private static final String HANDLE_REFERALS_METHOD = "throw";
+
+    /**
+     * This enum represents the different types of nodes that can be found while
+     * reading the schema from the DIT.
+     */
+    private enum SchemaNodeTypes
+    {
+        ATTRIBUTE_TYPE, OBJECT_CLASS, MATCHING_RULE, SYNTAX, UNKNOWN
+    }
+
+
+    /**
+     * Gets the Online Schema of the given Apache Directory Server JNDIConnectionWrapper.
+     * 
+     * @param  wrapper
+     * 		the JNDIConnectionWrapper
+     * @param monitor 
+     * @throws NamingException 
+     */
+    public static List<Schema> getOnlineSchema( JNDIConnectionWrapper wrapper, StudioProgressMonitor monitor )
+        throws NamingException
+    {
+        List<Schema> schemas = new ArrayList<Schema>();
+
+        monitor.beginTask( "Fetching Schema: ", 1 );
+
+        // Looking for all the defined schemas
+        SearchControls constraintSearch = new SearchControls();
+        constraintSearch.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+        NamingEnumeration<SearchResult> answer = wrapper.search( "ou=schema", "(objectclass=metaSchema)",
+            constraintSearch, DEREF_ALIAS_METHOD, HANDLE_REFERALS_METHOD, null, ( StudioProgressMonitor ) monitor );
+        if ( answer != null )
+        {
+            while ( answer.hasMoreElements() )
+            {
+                SearchResult searchResult = ( SearchResult ) answer.nextElement();
+
+                // Getting the 'cn' Attribute
+                Attribute cnAttribute = searchResult.getAttributes().get( "cn" );
+                // Looping on the values
+                NamingEnumeration<?> ne = cnAttribute.getAll();
+                while ( ne.hasMoreElements() )
+                {
+                    String value = ( String ) ne.nextElement();
+                    schemas.add( getSchema( wrapper, value, monitor ) );
+                }
+            }
+        }
+
+        monitor.worked( 1 );
+
+        return schemas;
+    }
+
+
+    private static Schema getSchema( JNDIConnectionWrapper wrapper, String name, StudioProgressMonitor monitor )
+        throws NamingException
+    {
+        monitor.subTask( "Reading schema '" + name + "'" );
+
+        // Creating the schema
+        Schema schema = new SchemaImpl( name );
+
+        // Looking for the nodes of the schema
+        SearchControls constraintSearch = new SearchControls();
+        constraintSearch.setSearchScope( SearchControls.SUBTREE_SCOPE );
+        NamingEnumeration<SearchResult> answer = wrapper.search( "cn=" + name + ", ou=schema", "(objectclass=*)",
+            constraintSearch, DEREF_ALIAS_METHOD, HANDLE_REFERALS_METHOD, null, monitor );
+        if ( answer != null )
+        {
+            while ( answer.hasMoreElements() )
+            {
+                SearchResult searchResult = ( SearchResult ) answer.nextElement();
+                switch ( getNodeType( searchResult ) )
+                {
+                    case ATTRIBUTE_TYPE:
+                        AttributeTypeImpl at = createAttributeType( searchResult );
+                        at.setSchema( name );
+                        schema.addAttributeType( at );
+                        break;
+                    case OBJECT_CLASS:
+                        ObjectClassImpl oc = createObjectClass( searchResult );
+                        oc.setSchema( name );
+                        schema.addObjectClass( oc );
+                        break;
+                    case MATCHING_RULE:
+                        MatchingRuleImpl mr = createMatchingRule( searchResult );
+                        mr.setSchema( name );
+                        schema.addMatchingRule( mr );
+                        break;
+                    case SYNTAX:
+                        SyntaxImpl syntax = createSyntax( searchResult );
+                        syntax.setSchema( name );
+                        schema.addSyntax( syntax );
+                        break;
+                    default:
+                        break;
+                }
+            }
+        }
+
+        return schema;
+    }
+
+
+    /**
+     * Gets the Type of node of the given SearchResult.
+     * 
+     * @param sr
+     * 		the SearchResult to be identified
+     * @return
+     * 		the Type of node
+     * @throws NamingException
+     * 		if an error occurrs when reading the SearchResult
+     */
+    private static SchemaNodeTypes getNodeType( SearchResult sr ) throws NamingException
+    {
+        // Getting the 'ObjectClass' Attribute
+        Attribute objectClassAttribute = sr.getAttributes().get( "objectClass" );
+
+        // Looping on the values
+        NamingEnumeration<?> ne = objectClassAttribute.getAll();
+        while ( ne.hasMore() )
+        {
+            String value = ( String ) ne.next();
+            if ( META_ATTRIBUTE_TYPE.equals( value ) )
+            {
+                return SchemaNodeTypes.ATTRIBUTE_TYPE;
+            }
+            else if ( META_OBJECT_CLASS.equals( value ) )
+            {
+                return SchemaNodeTypes.OBJECT_CLASS;
+            }
+            else if ( META_MATCHING_RULE.equals( value ) )
+            {
+                return SchemaNodeTypes.MATCHING_RULE;
+            }
+            else if ( META_SYNTAX.equals( value ) )
+            {
+                return SchemaNodeTypes.SYNTAX;
+            }
+        }
+
+        return SchemaNodeTypes.UNKNOWN;
+    }
+
+
+    /**
+     * Create the AttributeTypeImpl associated with the given SearchResult.
+     * 
+     * @param sr
+     * 		the SearchResult
+     * @return
+     * 		the AttributeTypeImpl associated with the SearchResult, or null if no 
+     * AttributeTypeImpl could be created
+     * @throws NamingException 
+     */
+    private static AttributeTypeImpl createAttributeType( SearchResult sr ) throws NamingException
+    {
+        AttributeTypeImpl at = new AttributeTypeImpl( getOid( sr ) );
+        at.setNames( getNames( sr ) );
+        at.setDescription( getDescription( sr ) );
+        at.setObsolete( isObsolete( sr ) );
+        at.setSuperiorName( getSuperior( sr ) );
+        at.setUsage( getUsage( sr ) );
+        at.setSyntaxOid( getSyntax( sr ) );
+        at.setLength( getSyntaxLength( sr ) );
+        at.setCollective( isCollective( sr ) );
+        at.setSingleValue( isSingleValue( sr ) );
+        at.setCanUserModify( isCanUserModify( sr ) );
+        at.setEqualityName( getEquality( sr ) );
+        at.setOrderingName( getOrdering( sr ) );
+        at.setSubstrName( getSubstr( sr ) );
+        return at;
+    }
+
+
+    /**
+     * Create the ObjectClassImpl associated with the given SearchResult.
+     * 
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the ObjectClassImpl associated with the SearchResult, or null if no 
+     * ObjectClassImpl could be created
+     * @throws NamingException 
+     */
+    private static ObjectClassImpl createObjectClass( SearchResult sr ) throws NamingException
+    {
+        ObjectClassImpl oc = new ObjectClassImpl( getOid( sr ) );
+        oc.setNames( getNames( sr ) );
+        oc.setDescription( getDescription( sr ) );
+        oc.setObsolete( isObsolete( sr ) );
+        oc.setSuperClassesNames( getSuperiors( sr ) );
+        oc.setType( getType( sr ) );
+        oc.setMayNamesList( getMay( sr ) );
+        oc.setMustNamesList( getMust( sr ) );
+        return oc;
+    }
+
+
+    /**
+     * Create the MatchingRule associated with the given SearchResult.
+     * 
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the MatchingRule associated with the SearchResult, or null if no 
+     * ObjectClass could be created
+     * @throws NamingException 
+     */
+    private static MatchingRuleImpl createMatchingRule( SearchResult sr ) throws NamingException
+    {
+        MatchingRuleImpl mr = new MatchingRuleImpl( getOid( sr ) );
+        mr.setNames( getNames( sr ) );
+        mr.setDescription( getDescription( sr ) );
+        mr.setObsolete( isObsolete( sr ) );
+        mr.setSyntaxOid( getSyntax( sr ) );
+        return mr;
+    }
+
+
+    /**
+     * Create the MatchingRule associated with the given SearchResult.
+     * 
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the MatchingRule associated with the SearchResult, or null if no 
+     * ObjectClass could be created
+     * @throws NamingException 
+     */
+    private static SyntaxImpl createSyntax( SearchResult sr ) throws NamingException
+    {
+        SyntaxImpl syntax = new SyntaxImpl( getOid( sr ) );
+        syntax.setNames( getNames( sr ) );
+        syntax.setDescription( getDescription( sr ) );
+        syntax.setObsolete( isObsolete( sr ) );
+        syntax.setHumanReadible( isHumanReadable( sr ) );
+        return syntax;
+    }
+
+
+    /**
+     * Gets the oid of the schema object contained a SearchResult.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the oid of the schema object, or nullif no oid was found
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static String getOid( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "m-oid" );
+        if ( at == null )
+        {
+            return null;
+        }
+        else
+        {
+            return ( String ) at.get();
+        }
+    }
+
+
+    /**
+     * Gets the names of the schema object contained a SearchResult.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the names of the schema object, or an empty array if no name was found
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static String[] getNames( SearchResult sr ) throws NamingException
+    {
+        List<String> names = new ArrayList<String>();
+
+        Attribute at = sr.getAttributes().get( "m-name" );
+        if ( at != null )
+        {
+            NamingEnumeration<?> ne = at.getAll();
+            while ( ne.hasMore() )
+            {
+                names.add( ( String ) ne.next() );
+            }
+        }
+
+        return names.toArray( new String[0] );
+    }
+
+
+    /**
+     * Gets the description of the schema object contained a SearchResult.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the description of the schema object, or null if no description was found
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static String getDescription( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "m-description" );
+
+        if ( at == null )
+        {
+            return null;
+        }
+        else
+        {
+            return ( String ) at.get();
+        }
+    }
+
+
+    /**
+     * Gets the superior of the attribute type contained a SearchResult.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the superior of the attribute type, or null if no superior was found
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static String getSuperior( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "m-supAttributeType" );
+
+        if ( at == null )
+        {
+            return null;
+        }
+        else
+        {
+            return ( String ) at.get();
+        }
+    }
+
+
+    /**
+     * Gets the usage of the attribute type contained a SearchResult.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the usage of the attribute type
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static UsageEnum getUsage( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "m-usage" );
+
+        if ( at == null )
+        {
+            return UsageEnum.USER_APPLICATIONS;
+        }
+        else
+        {
+            try
+            {
+                return Enum.valueOf( UsageEnum.class, ( String ) at.get() );
+            }
+            catch ( IllegalArgumentException e )
+            {
+                return UsageEnum.USER_APPLICATIONS;
+            }
+            catch ( NullPointerException e )
+            {
+                return UsageEnum.USER_APPLICATIONS;
+            }
+        }
+    }
+
+
+    /**
+     * Gets the syntax of the schema object contained a SearchResult.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the syntax of the schema object, or null if no syntax was found
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static String getSyntax( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "m-syntax" );
+
+        if ( at == null )
+        {
+            return null;
+        }
+        else
+        {
+            return ( String ) at.get();
+        }
+    }
+
+
+    /**
+     * Gets the syntax length of the attribute type contained a SearchResult.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the syntax length of the attribute type, or -1 if no syntax length was found
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static int getSyntaxLength( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "m-length" );
+
+        if ( at == null )
+        {
+            return -1;
+        }
+        else
+        {
+            try
+            {
+                return Integer.parseInt( ( String ) at.get() );
+            }
+            catch ( NumberFormatException e )
+            {
+                return -1;
+            }
+        }
+    }
+
+
+    /**
+     * Gets whether or not the schema object contained a SearchResult is obsolete.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      true if the schema object is obsolete, false if not
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static boolean isObsolete( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "m-obsolete" );
+
+        if ( at == null )
+        {
+            return false;
+        }
+        else
+        {
+            return Boolean.parseBoolean( ( String ) at.get() );
+        }
+    }
+
+
+    /**
+     * Gets whether or not the attribute type contained a SearchResult is collective.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      true if the attribute type is collective, false if not
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static boolean isCollective( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "m-collective" );
+
+        if ( at == null )
+        {
+            return false;
+        }
+        else
+        {
+            return Boolean.parseBoolean( ( String ) at.get() );
+        }
+    }
+
+
+    /**
+     * Gets whether or not the attribute type contained a SearchResult is single value.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      true if the attribute type is single value, false if not
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static boolean isSingleValue( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "m-singleValue" );
+
+        if ( at == null )
+        {
+            return false;
+        }
+        else
+        {
+            return Boolean.parseBoolean( ( String ) at.get() );
+        }
+    }
+
+
+    /**
+     * Gets whether or not the attribute type contained a SearchResult is single value.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      true if the attribute type is single value, false if not
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static boolean isCanUserModify( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "m-noUserModification" );
+
+        if ( at == null )
+        {
+            return true;
+        }
+        else
+        {
+            return !Boolean.parseBoolean( ( String ) at.get() );
+        }
+    }
+
+
+    /**
+     * Gets the name of the equality matching rule of the attribute type contained a SearchResult.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the name of the equality matching rule of the attribute type, or null if no equality matching rule was found
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static String getEquality( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "m-equality" );
+
+        if ( at == null )
+        {
+            return null;
+        }
+        else
+        {
+            return ( String ) at.get();
+        }
+    }
+
+
+    /**
+     * Gets the name of the ordering matching rule of the attribute type contained a SearchResult.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the name of the ordering matching rule of the attribute type, or null if no ordering matching rule was found
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static String getOrdering( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "m-ordering" );
+
+        if ( at == null )
+        {
+            return null;
+        }
+        else
+        {
+            return ( String ) at.get();
+        }
+    }
+
+
+    /**
+     * Gets the name of the substr matching rule of the attribute type contained a SearchResult.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the name of the substr matching rule of the attribute type, or null if no substr matching rule was found
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static String getSubstr( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "m-substr" );
+
+        if ( at == null )
+        {
+            return null;
+        }
+        else
+        {
+            return ( String ) at.get();
+        }
+    }
+
+
+    /**
+     * Gets the superiors of the object class contained a SearchResult.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the superiors of the attribute type, or an empty array if no superior was found
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static String[] getSuperiors( SearchResult sr ) throws NamingException
+    {
+        List<String> names = new ArrayList<String>();
+
+        Attribute at = sr.getAttributes().get( "m-supObjectClass" );
+        if ( at != null )
+        {
+            NamingEnumeration<?> ne = at.getAll();
+            while ( ne.hasMore() )
+            {
+                names.add( ( String ) ne.next() );
+            }
+        }
+
+        return names.toArray( new String[0] );
+    }
+
+
+    /**
+     * Gets the type of the object class contained a SearchResult.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the type of the object class
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static ObjectClassTypeEnum getType( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "m-typeObjectClass" );
+
+        if ( at == null )
+        {
+            return ObjectClassTypeEnum.STRUCTURAL;
+        }
+        else
+        {
+            try
+            {
+                return Enum.valueOf( ObjectClassTypeEnum.class, ( String ) at.get() );
+            }
+            catch ( IllegalArgumentException e )
+            {
+                return ObjectClassTypeEnum.STRUCTURAL;
+            }
+            catch ( NullPointerException e )
+            {
+                return ObjectClassTypeEnum.STRUCTURAL;
+            }
+        }
+    }
+
+
+    /**
+     * Gets the optional attribute types of the object class contained a SearchResult.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the optional attribute types of the attribute type, or an empty array if no optional attribute type was found
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static String[] getMay( SearchResult sr ) throws NamingException
+    {
+        List<String> names = new ArrayList<String>();
+
+        Attribute at = sr.getAttributes().get( "m-may" );
+        if ( at != null )
+        {
+            NamingEnumeration<?> ne = at.getAll();
+            while ( ne.hasMore() )
+            {
+                names.add( ( String ) ne.next() );
+            }
+        }
+
+        return names.toArray( new String[0] );
+    }
+
+
+    /**
+     * Gets the mandatory attribute types of the object class contained a SearchResult.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      the mandatory attribute types of the attribute type, or an empty array if no mandatory attribute type was found
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static String[] getMust( SearchResult sr ) throws NamingException
+    {
+        List<String> names = new ArrayList<String>();
+
+        Attribute at = sr.getAttributes().get( "m-must" );
+        if ( at != null )
+        {
+            NamingEnumeration<?> ne = at.getAll();
+            while ( ne.hasMore() )
+            {
+                names.add( ( String ) ne.next() );
+            }
+        }
+
+        return names.toArray( new String[0] );
+    }
+
+
+    /**
+     * Gets whether or not the schema object contained a SearchResult is obsolete.
+     *
+     * @param sr
+     *      the SearchResult
+     * @return
+     *      true if the schema object is obsolete, false if not
+     * @throws NamingException
+     *      if an error occurrs when searching in the SearchResult
+     */
+    private static boolean isHumanReadable( SearchResult sr ) throws NamingException
+    {
+        Attribute at = sr.getAttributes().get( "x-humanReadable" );
+
+        if ( at == null )
+        {
+            return false;
+        }
+        else
+        {
+            return Boolean.parseBoolean( ( String ) at.get() );
+        }
+    }
+}

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/ProjectsExporter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/ProjectsExporter.java?rev=570105&r1=570104&r2=570105&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/ProjectsExporter.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/ProjectsExporter.java Mon Aug 27 06:29:37 2007
@@ -29,7 +29,7 @@
 import org.apache.directory.studio.apacheds.schemaeditor.Activator;
 import org.apache.directory.studio.apacheds.schemaeditor.model.Project;
 import org.apache.directory.studio.apacheds.schemaeditor.model.Schema;
-import org.apache.directory.studio.apacheds.schemaeditor.model.Project.ProjectType;
+import org.apache.directory.studio.apacheds.schemaeditor.model.ProjectType;
 import org.dom4j.Branch;
 import org.dom4j.Document;
 import org.dom4j.DocumentHelper;
@@ -51,6 +51,7 @@
     private static final String PROJECTS_TAG = "projects";
     private static final String NAME_TAG = "name";
     private static final String TYPE_TAG = "type";
+    private static final String CONNECTION_TAG = "connection";
 
 
     /**
@@ -125,9 +126,15 @@
 
             // Type
             ProjectType type = project.getType();
-            if ( name != null )
+            if ( type != null )
             {
                 element.addAttribute( TYPE_TAG, type.toString() );
+            }
+
+            // Connection Name
+            if ( type.equals( ProjectType.APACHE_DIRECTORY_SERVER ) )
+            {
+                element.addAttribute( CONNECTION_TAG, project.getConnection().getName() );
             }
 
             // Schemas

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/ProjectsImporter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/ProjectsImporter.java?rev=570105&r1=570104&r2=570105&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/ProjectsImporter.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/ProjectsImporter.java Mon Aug 27 06:29:37 2007
@@ -24,9 +24,10 @@
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.directory.studio.apacheds.schemaeditor.PluginUtils;
 import org.apache.directory.studio.apacheds.schemaeditor.model.Project;
 import org.apache.directory.studio.apacheds.schemaeditor.model.Schema;
-import org.apache.directory.studio.apacheds.schemaeditor.model.Project.ProjectType;
+import org.apache.directory.studio.apacheds.schemaeditor.model.ProjectType;
 import org.dom4j.Attribute;
 import org.dom4j.Document;
 import org.dom4j.DocumentException;
@@ -48,6 +49,7 @@
     private static final String NAME_TAG = "name";
     private static final String SCHEMAS_TAG = "schemas";
     private static final String TYPE_TAG = "type";
+    private static final String CONNECTION_TAG = "connection";
 
 
     /**
@@ -162,6 +164,16 @@
             catch ( IllegalArgumentException e )
             {
                 throw new ProjectsImportException( "The parser was not able to convert the type value of the project." );
+            }
+        }
+
+        // Connection
+        if ( project.getType().equals( ProjectType.APACHE_DIRECTORY_SERVER ) )
+        {
+            Attribute connectionAttribute = element.attribute( CONNECTION_TAG );
+            if ( ( connectionAttribute != null ) && ( !connectionAttribute.getValue().equals( "" ) ) )
+            {
+                project.setConnection( PluginUtils.getConnection( connectionAttribute.getText() ) );
             }
         }
 

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/ProjectsViewLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/ProjectsViewLabelProvider.java?rev=570105&r1=570104&r2=570105&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/ProjectsViewLabelProvider.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/ProjectsViewLabelProvider.java Mon Aug 27 06:29:37 2007
@@ -24,7 +24,7 @@
 import org.apache.directory.studio.apacheds.schemaeditor.PluginConstants;
 import org.apache.directory.studio.apacheds.schemaeditor.model.Project;
 import org.apache.directory.studio.apacheds.schemaeditor.model.Project.ProjectState;
-import org.apache.directory.studio.apacheds.schemaeditor.model.Project.ProjectType;
+import org.apache.directory.studio.apacheds.schemaeditor.model.ProjectType;
 import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.ProjectWrapper;
 import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.swt.graphics.Image;

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/ExportProjectsWizardPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/ExportProjectsWizardPage.java?rev=570105&r1=570104&r2=570105&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/ExportProjectsWizardPage.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/ExportProjectsWizardPage.java Mon Aug 27 06:29:37 2007
@@ -29,7 +29,7 @@
 import org.apache.directory.studio.apacheds.schemaeditor.Activator;
 import org.apache.directory.studio.apacheds.schemaeditor.PluginConstants;
 import org.apache.directory.studio.apacheds.schemaeditor.model.Project;
-import org.apache.directory.studio.apacheds.schemaeditor.model.Project.ProjectType;
+import org.apache.directory.studio.apacheds.schemaeditor.model.ProjectType;
 import org.eclipse.jface.viewers.ArrayContentProvider;
 import org.eclipse.jface.viewers.CheckStateChangedEvent;
 import org.eclipse.jface.viewers.CheckboxTableViewer;

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/ExportSchemasAsXmlWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/ExportSchemasAsXmlWizard.java?rev=570105&r1=570104&r2=570105&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/ExportSchemasAsXmlWizard.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/ExportSchemasAsXmlWizard.java Mon Aug 27 06:29:37 2007
@@ -129,7 +129,7 @@
                 {
                     public void run( IProgressMonitor monitor )
                     {
-                        monitor.beginTask( "Exporting schemas ", 1 );
+                        monitor.beginTask( "Exporting schemas", 1 );
                         try
                         {
                             BufferedWriter buffWriter = new BufferedWriter( new FileWriter( exportFile ) );

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewProjectWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewProjectWizard.java?rev=570105&r1=570104&r2=570105&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewProjectWizard.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewProjectWizard.java Mon Aug 27 06:29:37 2007
@@ -20,12 +20,19 @@
 package org.apache.directory.studio.apacheds.schemaeditor.view.wizards;
 
 
+import java.lang.reflect.InvocationTargetException;
+
 import org.apache.directory.studio.apacheds.schemaeditor.Activator;
 import org.apache.directory.studio.apacheds.schemaeditor.PluginUtils;
 import org.apache.directory.studio.apacheds.schemaeditor.controller.ProjectsHandler;
 import org.apache.directory.studio.apacheds.schemaeditor.model.Project;
 import org.apache.directory.studio.apacheds.schemaeditor.model.Schema;
-import org.apache.directory.studio.apacheds.schemaeditor.model.Project.ProjectType;
+import org.apache.directory.studio.apacheds.schemaeditor.model.ProjectType;
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.StudioProgressMonitor;
+import org.apache.directory.studio.connection.core.io.jndi.JNDIConnectionWrapper;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.wizard.IWizardPage;
 import org.eclipse.jface.wizard.Wizard;
@@ -71,10 +78,31 @@
      */
     public boolean performFinish()
     {
-        Project project = new Project( informationPage.getProjectType(), informationPage.getProjectName() );
+        final Project project = new Project( informationPage.getProjectType(), informationPage.getProjectName() );
         if ( informationPage.getProjectType().equals( ProjectType.APACHE_DIRECTORY_SERVER ) )
         {
-            // TODO: Add connection information.
+            Connection connection = connectionSelectionPage.getSelectedConnection();
+            project.setConnection( connection );
+            try
+            {
+                getContainer().run( true, true, new IRunnableWithProgress()
+                {
+                    public void run( IProgressMonitor monitor )
+                    {
+                        project.fetchOnlineSchema( new StudioProgressMonitor( monitor ) );
+                    }
+                } );
+            }
+            catch ( InvocationTargetException e )
+            {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+            catch ( InterruptedException e )
+            {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
         }
         else if ( informationPage.getProjectType().equals( ProjectType.OFFLINE ) )
         {
@@ -145,7 +173,24 @@
      */
     public boolean canFinish()
     {
-        return !getContainer().getCurrentPage().equals( informationPage );
+        IWizardPage currentPage = getContainer().getCurrentPage();
+
+        if ( currentPage.equals( informationPage ) )
+        {
+            return false;
+        }
+        else if ( currentPage.equals( schemasSelectionPage ) )
+        {
+            return true;
+        }
+        else if ( currentPage.equals( connectionSelectionPage ) )
+        {
+            return connectionSelectionPage.isPageComplete();
+        }
+        else
+        {
+            return false;
+        }
     }
 
 
@@ -154,6 +199,6 @@
      */
     public void init( IWorkbench workbench, IStructuredSelection selection )
     {
-        // Nothing to do.
+        setNeedsProgressMonitor( true );
     }
 }

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewProjectWizardConnectionSelectionPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewProjectWizardConnectionSelectionPage.java?rev=570105&r1=570104&r2=570105&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewProjectWizardConnectionSelectionPage.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewProjectWizardConnectionSelectionPage.java Mon Aug 27 06:29:37 2007
@@ -22,6 +22,16 @@
 
 import org.apache.directory.studio.apacheds.schemaeditor.Activator;
 import org.apache.directory.studio.apacheds.schemaeditor.PluginConstants;
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
+import org.apache.directory.studio.connection.ui.widgets.ConnectionActionGroup;
+import org.apache.directory.studio.connection.ui.widgets.ConnectionConfiguration;
+import org.apache.directory.studio.connection.ui.widgets.ConnectionUniversalListener;
+import org.apache.directory.studio.connection.ui.widgets.ConnectionWidget;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.GridData;
@@ -41,7 +51,13 @@
  */
 public class NewProjectWizardConnectionSelectionPage extends WizardPage
 {
+    private ConnectionConfiguration configuration;
+    private ConnectionUniversalListener universalListener;
+
     // UI Fields
+    private ConnectionWidget connectionWidget;
+    private ConnectionActionGroup actionGroup;
+
 
     /**
      * Creates a new instance of NewProjectWizardConnectionSelectionPage.
@@ -65,11 +81,37 @@
         Composite composite = new Composite( parent, SWT.NONE );
         composite.setLayout( new GridLayout() );
 
-        // Connection
+        // Choose A Connection Label
         Label label = new Label( composite, SWT.NONE );
         label.setText( "Choose a connection:" );
         label.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
 
+        // Creating configuration
+        configuration = new ConnectionConfiguration();
+
+        // Creating Connection Widet
+        connectionWidget = new ConnectionWidget( configuration, null );
+        connectionWidget.createWidget( composite );
+        connectionWidget.setInput( ConnectionCorePlugin.getDefault().getConnectionManager() );
+
+        connectionWidget.getViewer().addSelectionChangedListener( new ISelectionChangedListener()
+        {
+            public void selectionChanged( SelectionChangedEvent event )
+            {
+                validatePage();
+            }
+        } );
+
+        // creating the listener
+        universalListener = new ConnectionUniversalListener( connectionWidget.getViewer() );
+
+        // create actions and context menu (and register global actions)
+        actionGroup = new ConnectionActionGroup( connectionWidget, configuration );
+        actionGroup.fillToolBar( connectionWidget.getToolBarManager() );
+        actionGroup.fillMenu( connectionWidget.getMenuManager() );
+        actionGroup.fillContextMenu( connectionWidget.getContextMenuManager() );
+        actionGroup.activateGlobalActionHandlers();
+
         initFields();
 
         setControl( composite );
@@ -87,6 +129,22 @@
 
 
     /**
+     * Validates the page.
+     */
+    private void validatePage()
+    {
+        ISelection selection = connectionWidget.getViewer().getSelection();
+        if ( selection.isEmpty() )
+        {
+            displayErrorMessage( "A connection must be selected." );
+            return;
+        }
+
+        displayErrorMessage( null );
+    }
+
+
+    /**
      * Displays an error message and set the page status as incomplete
      * if the message is not null.
      *
@@ -97,5 +155,38 @@
     {
         setErrorMessage( message );
         setPageComplete( message == null );
+    }
+
+
+    /**
+     * Gets the selected connection.
+     *
+     * @return
+     *      the selection connection
+     */
+    public Connection getSelectedConnection()
+    {
+        return ( Connection ) ( ( StructuredSelection ) connectionWidget.getViewer().getSelection() ).getFirstElement();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.DialogPage#dispose()
+     */
+    public void dispose()
+    {
+        if ( configuration != null )
+        {
+            actionGroup.dispose();
+            actionGroup = null;
+            configuration.dispose();
+            configuration = null;
+            universalListener.dispose();
+            universalListener = null;
+            connectionWidget.dispose();
+            connectionWidget = null;
+        }
+
+        super.dispose();
     }
 }

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewProjectWizardInformationPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewProjectWizardInformationPage.java?rev=570105&r1=570104&r2=570105&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewProjectWizardInformationPage.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewProjectWizardInformationPage.java Mon Aug 27 06:29:37 2007
@@ -23,7 +23,7 @@
 import org.apache.directory.studio.apacheds.schemaeditor.Activator;
 import org.apache.directory.studio.apacheds.schemaeditor.PluginConstants;
 import org.apache.directory.studio.apacheds.schemaeditor.controller.ProjectsHandler;
-import org.apache.directory.studio.apacheds.schemaeditor.model.Project.ProjectType;
+import org.apache.directory.studio.apacheds.schemaeditor.model.ProjectType;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;



Mime
View raw message