directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r475786 [8/13] - in /directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin: ./ META-INF/ icons/ ressources/ ressources/help/ ressources/help/html/ ressources/help/html/concepts/ ressources/help/html/concepts/images/ ressources/h...
Date Thu, 16 Nov 2006 16:05:29 GMT
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/Schema.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/Schema.java?view=auto&rev=475786
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/Schema.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/Schema.java Thu Nov 16 08:05:20 2006
@@ -0,0 +1,725 @@
+/*
+ *  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.ldapstudio.schemas.model;
+
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Hashtable;
+
+import org.apache.directory.ldapstudio.schemas.controller.Application;
+import org.apache.directory.ldapstudio.schemas.io.SchemaParser;
+import org.apache.directory.ldapstudio.schemas.io.SchemaWriter;
+import org.apache.directory.ldapstudio.schemas.view.preferences.SchemaPreferencePage;
+import org.apache.directory.server.core.tools.schema.AttributeTypeLiteral;
+import org.apache.directory.server.core.tools.schema.ObjectClassLiteral;
+import org.apache.log4j.Logger;
+import org.eclipse.core.runtime.preferences.ConfigurationScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+
+
+public class Schema implements SchemaElementListener
+{
+    private static Logger logger = Logger.getLogger( Schema.class );
+
+    private String name;
+    private URL url;
+    //the schema elements stored in highly optimised and strongly typed
+    //hash tables (stored by name).
+    private Hashtable<String, ObjectClass> objectClassTable;
+    private Hashtable<String, AttributeType> attributeTypeTable;
+    private ArrayList<SchemaListener> listeners;
+    //we change this to true if the schema has been modified since last save
+    private boolean hasBeenModified = false;
+
+    /**
+     * coreSchema = a schema that can't be deleted, it's a core schema of the ApacheDS server
+     * userSchema = any other schema
+     */
+    public enum SchemaType
+    {
+        userSchema, coreSchema
+    };
+
+    /**
+     * The type of this schema
+     */
+    public SchemaType type;
+
+
+    /******************************************
+     *                 Utility                *
+     ******************************************/
+
+    /**
+     * Gets the filename WITHOUT EXTENSION of the schema designated by this url
+     * @param url url pointing to a .schema file
+     * @return the filename or null if bad url
+     */
+    public static String URLtoFileName( URL url )
+    {
+        try
+        {
+            //It's time for sun to provide a standard method to access a file's name !
+            String separator = "/"; //$NON-NLS-1$
+            //if it's a ressource located in a bundle, we use slashes
+            if ( url.getProtocol().equals( "bundleresource" ) ) //$NON-NLS-1$
+                separator = "/"; //$NON-NLS-1$
+            else
+            {
+                //if not, let's find this platform specific separator !
+                separator = File.separator;
+
+                //no wait ! If it's a backslash, the regex motor will explode. We
+                //have to put not 2, not 3 but 4 backslashes !! That's right !
+                if ( separator.equals( "\\" ) ) { //$NON-NLS-1$
+                    separator = "\\\\"; //$NON-NLS-1$
+                }
+            }
+
+            String path = url.getPath();
+            String[] splFileName = path.split( separator );
+            String fileNoPath = splFileName[splFileName.length - 1];
+
+            if ( fileNoPath.endsWith( ".schema" ) ) //$NON-NLS-1$
+            {
+                String[] fileName = fileNoPath.split( "\\." ); //$NON-NLS-1$
+                return fileName[0];
+            }
+        }
+        catch ( Exception e )
+        {
+            logger.debug( "error when converting " + url + " to filename" ); //$NON-NLS-1$ //$NON-NLS-2$
+        }
+        return null;
+    }
+
+
+    /**
+     * Converts a local path in a URL object
+     * @param path the local path
+     * @return the url corresponding to the path
+     * @throws SchemaCreationException if error with the given path
+     */
+    public static URL localPathToURL( String path ) throws SchemaCreationException
+    {
+        URL tempURL = null;
+        try
+        {
+            tempURL = new URL( "file", "localhost", -1, path ); //$NON-NLS-1$ //$NON-NLS-2$
+        }
+        catch ( MalformedURLException e )
+        {
+            throw new SchemaCreationException( "malformed path:" + path, e ); //$NON-NLS-1$
+        }
+        return tempURL;
+
+    }
+
+
+    /**
+     * Tests if a given file is a schema file, it does not read the content of the schema
+     * but rather tries to determine the extension of the file
+     * @param url the input file
+     * @return returns true if its a .schema file, if not it returns false
+     */
+    private static boolean isASchemaFile( URL url )
+    {
+        return URLtoFileName( url ) != null;
+    }
+
+
+    /******************************************
+     *              Constructors              *
+     ******************************************/
+
+    /**
+     * Creates a new user schema of the specified name
+     * @param name the name of the schema
+     */
+    public Schema( String name )
+    {
+        this( name, null, SchemaType.userSchema );
+    }
+
+
+    /**
+     * Creates a new schema of the specified name and type
+     * @param type the type of the schema
+     * @param name the name of the schema
+     */
+    public Schema( SchemaType type, String name )
+    {
+        this( name, null, type );
+    }
+
+
+    /**
+     * Creates a new schema object loaded from a .schema file
+     * @param path the path to the .schema file
+     * @param type the type of the schema
+     * @throws SchemaCreationException if error during parsing of the .schema file
+     */
+    public Schema( String path, SchemaType type ) throws SchemaCreationException
+    {
+        this( localPathToURL( path ), type );
+    }
+
+
+    /**
+     * Creates a new schema object loaded from a .schema file
+     * @param url the URL to the .schema file
+     * @param type the type of the schema
+     * @throws SchemaCreationException if error during parsing of the .schema file
+     */
+    public Schema( URL url, SchemaType type ) throws SchemaCreationException
+    {
+        this( URLtoFileName( url ), url, type );
+
+        //we only load .schema files
+        if ( !isASchemaFile( url ) )
+            throw new SchemaCreationException( "not a .schema file: " + url, null ); //$NON-NLS-1$
+
+        //launch parsing of the .schema file right now
+        try
+        {
+            read();
+        }
+        catch ( IOException e )
+        {
+            throw new SchemaCreationException( "error opening " + url.toString(), e ); //$NON-NLS-1$
+        }
+        catch ( ParseException e )
+        {
+            throw new SchemaCreationException( "error during parsing of " + url.toString(), e ); //$NON-NLS-1$
+        }
+    }
+
+
+    /**
+     * General constructor (called by all the other constructors, ensure correct 
+     * initialization of all the instance variables)
+     * @param name the name of the schema
+     * @param url the url of the schema
+     * @param type the type of the schema
+     */
+    private Schema( String name, URL url, SchemaType type )
+    {
+        this.name = name;
+        this.url = url;
+        this.type = type;
+
+        objectClassTable = new Hashtable<String, ObjectClass>();
+        attributeTypeTable = new Hashtable<String, AttributeType>();
+        listeners = new ArrayList<SchemaListener>();
+
+        //we created a new schema, so it has to be saved later on
+        this.modified();
+    }
+
+
+    /******************************************
+     *               Accessors                *
+     ******************************************/
+
+    /**
+     * @return the name of the schema
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+
+    /**
+     * @return the url of the schema if it has been specified
+     */
+    public URL getURL()
+    {
+        return url;
+    }
+
+
+    /**
+     * Accessor to the objectClasses defined by this schema
+     * @return as an (name, objectClass) hashtable 
+     */
+    public Hashtable<String, ObjectClass> getObjectClassesAsHashTable()
+    {
+        return objectClassTable;
+    }
+
+
+    /**
+     * Accessor to the attributeTypes defined by this schema
+     * @return as an (name, attributeType) hashtable
+     */
+    public Hashtable<String, AttributeType> getAttributeTypesAsHashTable()
+    {
+        return attributeTypeTable;
+    }
+
+
+    /**
+     * Accessor to the objectClasses defined by this schema
+     * @return as an array
+     */
+    public ObjectClass[] getObjectClassesAsArray()
+    {
+        return objectClassTable.values().toArray( new ObjectClass[]
+            {} );
+    }
+
+
+    /**
+     * Accessor to the attributeTypes defined by this schema
+     * @return as an array
+     */
+    public AttributeType[] getAttributeTypesAsArray()
+    {
+        return attributeTypeTable.values().toArray( new AttributeType[]
+            {} );
+    }
+
+
+    /******************************************
+     *                  Logic                 *
+     ******************************************/
+
+    /**
+     * Checks if the schema has been modified since last save
+     * @return true if modified
+     */
+    public boolean hasBeenModified()
+    {
+        return hasBeenModified;
+    }
+
+
+    /**
+     * Checks if the schema has pending modifications in editors that have not
+     * been already applied
+     * @return true if the schema has pending modifications
+     */
+    public boolean hasPendingModification()
+    {
+        ObjectClass[] OCs = getObjectClassesAsArray();
+        for ( ObjectClass objectClass : OCs )
+        {
+            if ( objectClass.hasPendingModifications() )
+            {
+                return true;
+            }
+        }
+
+        AttributeType[] ATs = getAttributeTypesAsArray();
+        for ( AttributeType attributeType : ATs )
+        {
+            if ( attributeType.hasPendingModifications() )
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+
+    /**
+     * Apply the pending modifications to the model (this instance)
+     */
+    public void applyPendingModifications()
+    {
+        ObjectClass[] OCs = getObjectClassesAsArray();
+        for ( ObjectClass objectClass : OCs )
+        {
+            if ( objectClass.hasPendingModifications() )
+            {
+                objectClass.applyPendingModifications();
+            }
+        }
+
+        AttributeType[] ATs = getAttributeTypesAsArray();
+        for ( AttributeType attributeType : ATs )
+        {
+            if ( attributeType.hasPendingModifications() )
+            {
+                attributeType.applyPendingModifications();
+            }
+        }
+    }
+
+
+    /**
+     * Close the editors associated to this schema WITHOUT applying the
+     * modifications
+     */
+    public void closeAssociatedEditors()
+    {
+        ObjectClass[] OCs = getObjectClassesAsArray();
+        for ( ObjectClass objectClass : OCs )
+        {
+            objectClass.closeAssociatedEditor();
+        }
+
+        AttributeType[] ATs = getAttributeTypesAsArray();
+        for ( AttributeType attributeType : ATs )
+        {
+            attributeType.closeAssociatedEditor();
+        }
+    }
+
+
+    /**
+     * Use this method to indicate that the schema has been modified.
+     * Surgeons warning: internal use only
+     */
+    private void modified()
+    {
+        this.hasBeenModified = true;
+    }
+
+
+    /**
+     * Use this method to indicate that the schema has been saved.
+     * Surgeons warning: internal use only
+     */
+    private void saved()
+    {
+        this.hasBeenModified = false;
+    }
+
+
+    /**
+     * Adds the specified objectClass to the schema (overwriting the previous associations)
+     * @param oc the objectClass
+     */
+    public void addObjectClass( ObjectClass oc )
+    {
+        for ( String alias : oc.getNames() )
+            objectClassTable.put( alias, oc );
+        oc.addListener( this );
+        this.modified();
+        notifyChanged( LDAPModelEvent.Reason.OCAdded, oc );
+    }
+
+
+    /**
+     * Adds the specified attributeType to the schema (overwriting the previous associations)
+     * @param at the attributeType
+     */
+    public void addAttributeType( AttributeType at )
+    {
+        for ( String alias : at.getNames() )
+            attributeTypeTable.put( alias, at );
+        at.addListener( this );
+        this.modified();
+        notifyChanged( LDAPModelEvent.Reason.ATAdded, at );
+    }
+
+
+    /**
+     * Removes the specified objectClass from the schema
+     * @param oc the objectClass
+     */
+    public void removeObjectClass( ObjectClass oc )
+    {
+        for ( String alias : oc.getNames() )
+            objectClassTable.remove( alias );
+        oc.removeListener( this );
+        this.modified();
+        notifyChanged( LDAPModelEvent.Reason.OCRemoved, oc );
+    }
+
+
+    /**
+     * Removes the specified attributeType from the schema
+     * @param at the attributeType
+     */
+    public void removeAttributeType( AttributeType at )
+    {
+        for ( String alias : at.getNames() )
+            attributeTypeTable.remove( alias );
+        at.removeListener( this );
+        this.modified();
+        notifyChanged( LDAPModelEvent.Reason.ATRemoved, at );
+    }
+
+
+    /******************************************
+     *                  I/O                   *
+     ******************************************/
+
+    /**
+     * Read the schema from the already specified .schema file
+     * @throws ParseException if error during parsing of the .schema file
+     * @throws IOException if error opening the .schema file
+     *
+     */
+    public void read() throws IOException, ParseException
+    {
+        SchemaParser parser = null;
+        parser = SchemaParser.parserFromURL( url );
+
+        if ( parser == null )
+            throw new FileNotFoundException( "Schema model object: no path or url specified !" ); //$NON-NLS-1$
+
+        parser.parse();
+
+        ObjectClassLiteral[] objectClasses = parser.getObjectClasses();
+        AttributeTypeLiteral[] attributeTypes = parser.getAttributeTypes();
+
+        for ( AttributeTypeLiteral literal : attributeTypes )
+        {
+            AttributeType AT = new AttributeType( literal, this );
+            AT.addListener( this );
+            for ( String alias : literal.getNames() )
+                attributeTypeTable.put( alias, AT );
+        }
+
+        for ( ObjectClassLiteral literal : objectClasses )
+        {
+            ObjectClass OC = new ObjectClass( literal, this );
+            OC.addListener( this );
+            for ( String alias : literal.getNames() )
+                objectClassTable.put( alias, OC );
+        }
+
+        //this schema has been loaded from a file, so we can consider we are
+        //synchronised with the filesystem
+        this.saved();
+    }
+
+
+    /**
+     * Save the schema on disk, do not ask for confirmation
+     * @throws Exception if error during writting of the file
+     */
+    public void save() throws Exception
+    {
+        save( false );
+    }
+
+
+    /**
+     * Save the schema on disk
+     * @param askForConfirmation if true, will ask form confirmation before saving
+     * @throws Exception if error during writting of the file
+     */
+    public void save( boolean askForConfirmation ) throws Exception
+    {
+        if ( this.type == SchemaType.coreSchema )
+            return;
+
+        if ( this.hasPendingModification() )
+        {
+            MessageBox messageBox = new MessageBox( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+                SWT.YES | SWT.NO | SWT.ICON_QUESTION );
+            messageBox
+                .setMessage( Messages.getString( "Schema.The_schema" ) + this.getName() + Messages.getString( "Schema.Has_pending_modifications_in_editors_Do_you_want_to_apply_them" ) ); //$NON-NLS-1$ //$NON-NLS-2$
+            if ( messageBox.open() == SWT.YES )
+            {
+                this.applyPendingModifications();
+            }
+            else
+            {
+                this.closeAssociatedEditors();
+            }
+        }
+
+        if ( !this.hasBeenModified() )
+            return;
+
+        if ( askForConfirmation )
+        {
+            MessageBox messageBox = new MessageBox( new Shell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION );
+            messageBox
+                .setMessage( Messages.getString( "Schema.The_schema" ) + this.getName() + Messages.getString( "Schema.Has_been_modified_Do_you_want_to_save_it" ) ); //$NON-NLS-1$ //$NON-NLS-2$
+            if ( messageBox.open() != SWT.YES )
+            {
+                return;
+            }
+        }
+
+        String savePath = null;
+
+        if ( this.url == null )
+        {
+            FileDialog fd = new FileDialog( new Shell(), SWT.SAVE );
+            fd.setText( Messages.getString( "Schema.Save_this_schema" ) + this.getName() ); //$NON-NLS-1$
+            IEclipsePreferences prefs = new ConfigurationScope().getNode( Application.PLUGIN_ID );
+            String defaultPath = prefs.get( SchemaPreferencePage.DEFAULT_DIRECTORY, System.getProperty( "user.home" ) ); //$NON-NLS-1$
+            fd.setFilterPath( defaultPath );
+            fd.setFileName( this.name + ".schema" ); //$NON-NLS-1$
+            fd.setFilterExtensions( new String[]
+                { "*.schema", "*.*" } ); //$NON-NLS-1$ //$NON-NLS-2$
+            fd.setFilterNames( new String[]
+                { Messages.getString( "Schema.Schema_files" ), Messages.getString( "Schema.All_files" ) } ); //$NON-NLS-1$ //$NON-NLS-2$
+            savePath = fd.open();
+            //we now have a specific location to save this schema in the future
+            if ( savePath != null )
+                this.url = localPathToURL( savePath );
+        }
+        else
+            savePath = url.getPath();
+
+        if ( savePath != null )
+        {
+            write( savePath );
+            //when we have been written, we are synchronised with the filesystem
+            this.saved();
+            notifyChanged( LDAPModelEvent.Reason.SchemaSaved, null );
+        }
+    }
+
+
+    /**
+     * Save the schema on disk to a specific file 
+     * @throws Exception if error during writting of the file
+     */
+    public void saveas() throws Exception
+    {
+        if ( this.hasPendingModification() )
+        {
+            MessageBox messageBox = new MessageBox( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+                SWT.YES | SWT.NO | SWT.ICON_QUESTION );
+            messageBox
+                .setMessage( Messages.getString( "Schema.The_schema" ) + this.getName() + Messages.getString( "Schema.Has_pending_modifications_in_editors_Do_you_want_to_apply_them" ) ); //$NON-NLS-1$ //$NON-NLS-2$
+            if ( messageBox.open() == SWT.YES )
+            {
+                this.applyPendingModifications();
+            }
+        }
+
+        FileDialog fd = new FileDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.SAVE );
+        fd.setText( Messages.getString( "Schema.Save_this_schema" ) + this.getName() ); //$NON-NLS-1$
+        IEclipsePreferences prefs = new ConfigurationScope().getNode( Application.PLUGIN_ID );
+        String defaultPath = prefs.get( SchemaPreferencePage.DEFAULT_DIRECTORY, System.getProperty( "user.home" ) ); //$NON-NLS-1$
+        fd.setFilterPath( defaultPath );
+        fd.setFileName( this.name + ".schema" ); //$NON-NLS-1$
+        fd.setFilterExtensions( new String[]
+            { "*.schema", "*.*" } ); //$NON-NLS-1$ //$NON-NLS-2$
+        fd.setFilterNames( new String[]
+            { Messages.getString( "Schema.Schema_files" ), Messages.getString( "Schema.All_files" ) } ); //$NON-NLS-1$ //$NON-NLS-2$
+        String savePath = fd.open();
+        //check if cancel has been pressed
+        if ( savePath != null )
+        {
+            URL newURL = localPathToURL( savePath );
+            String newName = URLtoFileName( newURL );
+            //if it's a bad url (no .schema, bad path) newName will be null
+            if ( newName != null )
+            {
+
+                if ( SchemaPool.getInstance().getSchema( newName ) != null )
+                {
+                    MessageBox messageBox = new MessageBox( PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+                        .getShell(), SWT.OK | SWT.ICON_ERROR );
+                    messageBox.setMessage( Messages
+                        .getString( "Schema.A_schema_of_the_same_name_is_already_loaded_in_the_pool" ) ); //$NON-NLS-1$
+                    messageBox.open();
+                    return;
+                }
+                //if everything is ok, we update the current instance
+                this.name = newName;
+                this.url = newURL;
+
+                write( savePath );
+                //when we have been written, we are synchronised with the filesystem
+                this.saved();
+                notifyChanged( LDAPModelEvent.Reason.SchemaSaved, null );
+            }
+        }
+    }
+
+
+    private void write( String path ) throws Exception
+    {
+        if ( path != null && path != "" ) { //$NON-NLS-1$
+            SchemaWriter writer = new SchemaWriter();
+            writer.write( this, path );
+        }
+    }
+
+
+    /******************************************
+     *            Events emmiting             *
+     ******************************************/
+
+    public void addListener( SchemaListener listener )
+    {
+        if ( !listeners.contains( listener ) )
+            listeners.add( listener );
+    }
+
+
+    public void removeListener( SchemaListener listener )
+    {
+        listeners.remove( listener );
+    }
+
+
+    private void notifyChanged( LDAPModelEvent.Reason reason, Object o )
+    {
+        for ( SchemaListener listener : listeners )
+        {
+            try
+            {
+                if ( o instanceof ObjectClass )
+                    listener.schemaChanged( this, new LDAPModelEvent( reason, ( ObjectClass ) o ) );
+                else if ( o instanceof AttributeType )
+                    listener.schemaChanged( this, new LDAPModelEvent( reason, ( AttributeType ) o ) );
+                else
+                    listener.schemaChanged( this, new LDAPModelEvent( reason ) );
+            }
+            catch ( Exception e )
+            {
+                logger.debug( "error when notifying listener: " + listener ); //$NON-NLS-1$
+            }
+        }
+    }
+
+
+    /******************************************
+     *     Schema Element Listener Impl       *
+     ******************************************/
+
+    public void schemaElementChanged( SchemaElement originatingSchemaElement, LDAPModelEvent e )
+    {
+        //if a binded element has been modified we consider that we have been modified
+        this.modified();
+
+        //then we notify our listeners that we have been modified
+        for ( SchemaListener listener : listeners )
+        {
+            listener.schemaChanged( this, e );
+        }
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaCreationException.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaCreationException.java?view=auto&rev=475786
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaCreationException.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaCreationException.java Thu Nov 16 08:05:20 2006
@@ -0,0 +1,54 @@
+/*
+ *  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.ldapstudio.schemas.model;
+
+
+/**
+ * Umbrella for all the schema i/o related exceptions
+ *
+ */
+public class SchemaCreationException extends Exception
+{
+    private static final long serialVersionUID = 1L;
+    private Exception originatingException;
+
+
+    /**
+     * Creates a new schema i/o related exception
+     * @param message the exception's message
+     * @param originatingException the originating exception
+     */
+    public SchemaCreationException( String message, Exception originatingException )
+    {
+        super( message );
+        this.originatingException = originatingException;
+    }
+
+
+    /**
+     * @return the originating exception
+     */
+    public Exception getOriginatingException()
+    {
+        return originatingException;
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaElement.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaElement.java?view=auto&rev=475786
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaElement.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaElement.java Thu Nov 16 08:05:20 2006
@@ -0,0 +1,53 @@
+/*
+ *  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.ldapstudio.schemas.model;
+
+
+/**
+ * This class is the model for all LDAP schema elements
+ *
+ */
+public interface SchemaElement
+{
+
+    /**
+     * @return the various aliases of the element
+     */
+    public String[] getNames();
+
+
+    /**
+     * @return the oid of the element
+     */
+    public String getOid();
+
+
+    /**
+     * @return the schema model instance defining this element
+     */
+    public Schema getOriginatingSchema();
+
+
+    /**
+     * @return the description of the element
+     */
+    public String getDescription();
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaElementListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaElementListener.java?view=auto&rev=475786
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaElementListener.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaElementListener.java Thu Nov 16 08:05:20 2006
@@ -0,0 +1,36 @@
+/*
+ *  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.ldapstudio.schemas.model;
+
+
+/**
+ * Listener to SchemaElement instances must implement this interface
+ */
+public interface SchemaElementListener
+{
+    /**
+     * Called if a property of the schema element was modified
+     *
+     * @param originatingSchema the schema that has been modified
+     * @param e the type of event that has been fired
+     */
+    public void schemaElementChanged( SchemaElement originatingSchemaElement, LDAPModelEvent e );
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaListener.java?view=auto&rev=475786
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaListener.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaListener.java Thu Nov 16 08:05:20 2006
@@ -0,0 +1,36 @@
+/*
+ *  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.ldapstudio.schemas.model;
+
+
+/**
+ * Listener to schema instances must implement this interface
+ */
+public interface SchemaListener
+{
+    /**
+     * Called if the schema was changed (if an element has been added or removed from a schema)
+     *
+     * @param originatingSchema the schema that has been modified
+     * @param e the type of event that has been fired
+     */
+    public void schemaChanged( Schema originatingSchema, LDAPModelEvent e );
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaPool.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaPool.java?view=auto&rev=475786
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaPool.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaPool.java Thu Nov 16 08:05:20 2006
@@ -0,0 +1,791 @@
+/*
+ *  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.ldapstudio.schemas.model;
+
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Hashtable;
+
+import org.apache.directory.ldapstudio.schemas.controller.Application;
+import org.apache.directory.ldapstudio.schemas.view.preferences.SchemaPreferencePage;
+import org.apache.log4j.Logger;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.ConfigurationScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.osgi.service.prefs.BackingStoreException;
+import org.osgi.service.prefs.Preferences;
+
+
+/**
+ * A pool of schema is a common repository for all the currently loaded
+ * schemas in LDAP Studio.
+ * -> You can add or remove schema from the pool.
+ * -> You can obtain a complete list of all the objectClasses and attribute
+ * Type currently loaded (even if they are squattered in various schema files).
+ * -> the pool of schema can be seen as ONE big schema containing all the 
+ * definitions of the currently loaded schemas.
+ *
+ * NOW USING A SINGLETON DESIGN PATTERN
+ * -> use the getPool() static method to get the schema pool
+ *
+ */
+public class SchemaPool implements SchemaListener
+{
+    private static Logger logger = Logger.getLogger( SchemaPool.class );
+    private static final String SCHEMA_URL = "schema_url"; //$NON-NLS-1$
+    private static final String SAVED_WORKSPACE = "prefs_saved_workspace"; //$NON-NLS-1$
+
+    private static SchemaPool instance_;
+    private static Object syncObject_ = new Object();
+
+    private ArrayList<Schema> schemaList;
+    private ArrayList<PoolListener> listeners;
+
+
+    /**
+     * Write the pool configuration to the LDAPStudio preferences backing store.
+     * It consists of all the non-core schemas that have been added by the user.
+     */
+    public void savePool()
+    {
+        try
+        {
+            Preferences prefs = new ConfigurationScope().getNode( Application.PLUGIN_ID );
+            Preferences saved_workspace = prefs.node( SAVED_WORKSPACE );
+
+            //we only store the references to schemas that have ALREADY
+            //been saved. -> url != null
+            for ( Schema schema : schemaList )
+            {
+                if ( ( schema.type == Schema.SchemaType.userSchema ) && ( schema.getURL() != null ) )
+                {
+                    Preferences schemaPref = saved_workspace.node( schema.getName() );
+                    String url = schema.getURL().getPath();
+                    schemaPref.put( SCHEMA_URL, url );
+                }
+            }
+
+            saved_workspace.flush();
+        }
+        catch ( BackingStoreException e )
+        {
+            logger.debug( "error when accessing the preferences backing store" ); //$NON-NLS-1$
+        }
+    }
+
+
+    /**
+     * Read the pool configuration from the LDAPStudio preferences backing store.
+     * It consists of all the non-core schemas that have been added by the user.
+     */
+    public void loadPool()
+    {
+        try
+        {
+            Preferences prefs = new ConfigurationScope().getNode( Application.PLUGIN_ID );
+            Preferences saved_workspace = prefs.node( SAVED_WORKSPACE );
+            String[] schemaNames = saved_workspace.childrenNames();
+            for ( String name : schemaNames )
+            {
+                Preferences node = saved_workspace.node( name );
+                try
+                {
+                    addAlreadyExistingSchema( Schema.localPathToURL( node.get( SCHEMA_URL, "" ) ), //$NON-NLS-1$
+                        Schema.SchemaType.userSchema );
+                }
+                catch ( SchemaCreationException e )
+                {
+                    logger.debug( "error loading schema " + node.get( SCHEMA_URL, "" ) + " in the pool" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                }
+                finally
+                {
+                    node.removeNode();
+                }
+            }
+            saved_workspace.flush();
+        }
+        catch ( BackingStoreException e )
+        {
+            logger.debug( "error when accessing the preferences backing store" ); //$NON-NLS-1$
+        }
+
+    }
+
+
+    private static void initializeWithBundled( SchemaPool pool )
+    {
+        URL urlcore = Platform.getBundle( Application.PLUGIN_ID ).getResource( "ressources/schemas/core.schema" ); //$NON-NLS-1$
+        URL urljava = Platform.getBundle( Application.PLUGIN_ID ).getResource( "ressources/schemas/java.schema" ); //$NON-NLS-1$
+        URL urlnis = Platform.getBundle( Application.PLUGIN_ID ).getResource( "ressources/schemas/nis.schema" ); //$NON-NLS-1$
+        URL urlsystem = Platform.getBundle( Application.PLUGIN_ID ).getResource( "ressources/schemas/system.schema" ); //$NON-NLS-1$
+        URL urlautofs = Platform.getBundle( Application.PLUGIN_ID ).getResource( "ressources/schemas/autofs.schema" ); //$NON-NLS-1$
+        URL urlcorba = Platform.getBundle( Application.PLUGIN_ID ).getResource( "ressources/schemas/corba.schema" ); //$NON-NLS-1$
+        URL urlcosine = Platform.getBundle( Application.PLUGIN_ID ).getResource( "ressources/schemas/cosine.schema" ); //$NON-NLS-1$
+        URL urlinetorgperson = Platform.getBundle( Application.PLUGIN_ID ).getResource(
+            "ressources/schemas/inetorgperson.schema" ); //$NON-NLS-1$
+
+        try
+        {
+            pool.addAlreadyExistingSchema( urlcore, Schema.SchemaType.coreSchema );
+            pool.addAlreadyExistingSchema( urljava, Schema.SchemaType.coreSchema );
+            pool.addAlreadyExistingSchema( urlnis, Schema.SchemaType.coreSchema );
+            pool.addAlreadyExistingSchema( urlsystem, Schema.SchemaType.coreSchema );
+            pool.addAlreadyExistingSchema( urlautofs, Schema.SchemaType.coreSchema );
+            pool.addAlreadyExistingSchema( urlcorba, Schema.SchemaType.coreSchema );
+            pool.addAlreadyExistingSchema( urlcosine, Schema.SchemaType.coreSchema );
+            pool.addAlreadyExistingSchema( urlinetorgperson, Schema.SchemaType.coreSchema );
+        }
+        catch ( SchemaCreationException e )
+        {
+            logger
+                .debug( "error when inializing the schema pool with bundled schemas. One of the core schemas is not accessible:" + e ); //$NON-NLS-1$
+        }
+    }
+
+
+    private static void initializeWithSpecified( SchemaPool pool )
+    {
+        IEclipsePreferences prefs = new ConfigurationScope().getNode( Application.PLUGIN_ID );
+        String specificPath = prefs
+            .get( SchemaPreferencePage.SPECIFIC_CORE_DIRECTORY, System.getProperty( "user.home" ) ); //$NON-NLS-1$
+
+        File dir = new File( specificPath );
+        String sCurPath = dir.getAbsolutePath() + File.separator;
+        // Get the directorie entries
+        String[] safiles = dir.list();
+        if ( safiles != null )
+        {
+            for ( int i = 0; i < safiles.length; i++ )
+            {
+                File curFile = new File( sCurPath + safiles[i] );
+                if ( !curFile.isDirectory() )
+                {
+                    try
+                    {
+                        URL fileURL = curFile.toURL();
+                        if ( Schema.URLtoFileName( fileURL ) != null )
+                        {
+                            pool.addAlreadyExistingSchema( fileURL, Schema.SchemaType.coreSchema );
+                        }
+                    }
+                    catch ( MalformedURLException e )
+                    {
+                        logger.debug( "error whith the content of the specified core schema directory" ); //$NON-NLS-1$
+                    }
+                    catch ( SchemaCreationException e )
+                    {
+                        logger
+                            .debug( "error when inializing the schema pool with specified schemas. One of the core schemas is not accessible:" //$NON-NLS-1$
+                                + e );
+                    }
+                }
+            }
+        }
+    }
+
+
+    /**
+     * Returns the unique initialized pool with all the core schemas pre-loaded
+     * @return the pool
+     */
+    public static SchemaPool getInstance()
+    {
+        //thread-safe version but not as good as with the static bloc method. Here it would have
+        //made a too big static block.
+        if ( instance_ == null )
+        {
+            synchronized ( syncObject_ )
+            {
+                if ( instance_ == null )
+                {
+                    //1) create the pool instance
+                    SchemaPool pool = new SchemaPool();
+
+                    IEclipsePreferences prefs = new ConfigurationScope().getNode( Application.PLUGIN_ID );
+
+                    //2) initialize the pool
+                    boolean initialize_with_specified = prefs.getBoolean( SchemaPreferencePage.SPECIFIC_CORE, false );
+                    if ( initialize_with_specified )
+                    {
+                        //2a) with user-specified core schemas
+                        initializeWithSpecified( pool );
+                    }
+                    else
+                    {
+                        //2b) or with bundled core schemas
+                        initializeWithBundled( pool );
+                    }
+
+                    //3) the unique instance is this initialized pool
+                    instance_ = pool;
+
+                    //4) load the pool with all the schemas that the user did select the last time
+                    //LDAPStudio was launched
+                    boolean save_workspace = prefs.getBoolean( SchemaPreferencePage.SAVE_WORKSPACE, true );
+                    if ( save_workspace )
+                        instance_.loadPool();
+                }
+            }
+        }
+
+        //1) or 5) returns the unique pool instance
+        return instance_;
+    }
+
+
+    /**
+     * Default constructor, no pre-loaded schemas. Despite the fact that we are using a
+     * singleton design pattern, it's a public constructor. It allows you to create
+     * temporary unitialized pools (for testing purposes for example). 
+     */
+    public SchemaPool()
+    {
+        schemaList = new ArrayList<Schema>();
+        listeners = new ArrayList<PoolListener>();
+    }
+
+
+    /**
+     * @return the number of schemas in the pool
+     */
+    public int count()
+    {
+        return schemaList.size();
+    }
+
+
+    /**
+     * Returns all the schemas contained in the pool
+     * @return the schemas stored in a Schema array 
+     */
+    public Schema[] getSchemas()
+    {
+        return schemaList.toArray( new Schema[]
+            {} );
+    }
+
+
+    /**
+     * Returns the schema specified by the following name.
+     * @param name the name of the schema to find
+     * @return
+     */
+    public Schema getSchema( String name )
+    {
+        for ( Schema schema : schemaList )
+        {
+            if ( schema.getName().equals( name ) )
+                return schema;
+        }
+        return null;
+    }
+
+
+    /**
+     * Tests if a schema OF THE FOLLOWING NAME is inside the pool, it does NOT test
+     * against the schema instances.
+     * @param name the name of the schema 
+     * @return true if inside
+     * @see containsSchema(Schema schema) if you want to test instances
+     */
+    public boolean containsSchema( String name )
+    {
+        return ( getSchema( name ) != null );
+    }
+
+
+    /**
+     * Tests if the following schema is inside the pool
+     * @param schema the name of the schema to test
+     * @return true if inside, false if not
+     */
+    public boolean containsSchema( Schema schema )
+    {
+        return schemaList.contains( schema );
+    }
+
+
+    /**
+     * Tests if the following objectClass is inside the pool
+     * 	@param name the name of the object class to test
+     * @return true if inside, false if not
+     */
+    public boolean containsObjectClass( String name )
+    {
+        return getObjectClass( name ) != null;
+    }
+
+
+    /**
+     * Tests if the following attribute type is inside the pool
+     * @param name the name of the attribute type to test
+     * @return true if inside, false if not
+     */
+    public boolean containsAttributeType( String name )
+    {
+        return getAttributeType( name ) != null;
+    }
+
+
+    /**
+     * Tests if an objectClass of the following name(s) exists inside the pool
+     * -> test each alias of the following objectClass against the content of the pool
+     * @param objectClass the objectClass to test
+     * @return if inside the pool, false if not
+     */
+    public boolean containsObjectClass( ObjectClass objectClass )
+    {
+        String[] names = objectClass.getNames();
+        for ( String name : names )
+        {
+            if ( getObjectClass( name ) != null )
+                return true;
+        }
+        return false;
+    }
+
+
+    /**
+     * Tests if an attributeType of the following name(s) exists inside the pool
+     * -> test each alias of the following attributeType against the content of the pool
+     * @param attributeType the attributeType to test
+     * @return if inside the pool, false if not
+     */
+    public boolean containsAttributeType( AttributeType attributeType )
+    {
+        String[] names = attributeType.getNames();
+        for ( String name : names )
+        {
+            if ( getAttributeType( name ) != null )
+                return true;
+        }
+        return false;
+    }
+
+
+    /**
+     * Returns a specific object class
+     * @param name the name of the object class to return
+     * @return null if the name is not mapped
+     */
+    public ObjectClass getObjectClass( String name )
+    {
+        Hashtable<String, ObjectClass> objectClassTable = getObjectClassesAsHashTableByName();
+
+        return objectClassTable.get( name );
+    }
+
+
+    /**
+     * Returns a specific attribute type
+     * @param name the name of the attriute type to return
+     * @return null if the name is not mapped
+     */
+    public AttributeType getAttributeType( String name )
+    {
+        Hashtable<String, AttributeType> attributeTypeTable = getAttributeTypesAsHashTableByName();
+
+        return attributeTypeTable.get( name );
+    }
+
+
+    /**
+     * Accessor to all the objectClasses defined by the schemas stored in the pool
+     * @return as an (name, objectClass) hashtable 
+     */
+    public Hashtable<String, ObjectClass> getObjectClassesAsHashTableByName()
+    {
+        Hashtable<String, ObjectClass> objectClassTable = new Hashtable<String, ObjectClass>();
+
+        for ( Schema schema : schemaList )
+        {
+            Hashtable<String, ObjectClass> temp = schema.getObjectClassesAsHashTable();
+            if ( temp != null )
+                objectClassTable.putAll( temp );
+        }
+        return objectClassTable;
+    }
+
+
+    /**
+     * Accessor to all the objectClasses defined by the schemas stored in the pool
+     * @return as an (oid, ObjectClass) hashtable
+     */
+    public Hashtable<String, ObjectClass> getObjectClassesAsHashTableByOID()
+    {
+        Hashtable<String, ObjectClass> classesTable = new Hashtable<String, ObjectClass>();
+
+        ObjectClass[] ObjectClasses = getObjectClassesAsArray();
+        for ( ObjectClass class1 : ObjectClasses )
+        {
+            classesTable.put( class1.getOid(), class1 );
+        }
+
+        return classesTable;
+    }
+
+
+    /**
+     * Accessor to all the attributeType defined by the schemas stored in the pool
+     * @return as an (name, attributeType) hashtable
+     */
+    public Hashtable<String, AttributeType> getAttributeTypesAsHashTableByName()
+    {
+        Hashtable<String, AttributeType> attributeTypeTable = new Hashtable<String, AttributeType>();
+
+        for ( Schema schema : schemaList )
+        {
+            Hashtable<String, AttributeType> temp = schema.getAttributeTypesAsHashTable();
+            if ( temp != null )
+                attributeTypeTable.putAll( temp );
+        }
+        return attributeTypeTable;
+    }
+
+
+    /**
+     * Accessor to all the attributeType defined by the schemas stored in the pool
+     * @return as an (oid, attributeType) hashtable
+     */
+    public Hashtable<String, AttributeType> getAttributeTypesAsHashTableByOID()
+    {
+        Hashtable<String, AttributeType> attributeTypeTable = new Hashtable<String, AttributeType>();
+
+        AttributeType[] attributeTypes = getAttributeTypesAsArray();
+        for ( AttributeType type : attributeTypes )
+        {
+            attributeTypeTable.put( type.getOid(), type );
+        }
+
+        return attributeTypeTable;
+    }
+
+
+    /**
+     * Accessor to all the schema elements (attribute types and object classes) defined by 
+     * the schemas stored in the pool
+     * @return as an (oid, SchemaElement) hashtable
+     */
+    public Hashtable<String, SchemaElement> getSchemaElementsAsHashTableByOID()
+    {
+        Hashtable<String, SchemaElement> elementsTable = new Hashtable<String, SchemaElement>();
+
+        AttributeType[] attributeTypes = getAttributeTypesAsArray();
+        ObjectClass[] objectClasses = getObjectClassesAsArray();
+
+        for ( ObjectClass class1 : objectClasses )
+        {
+            elementsTable.put( class1.getOid(), class1 );
+        }
+
+        for ( AttributeType type : attributeTypes )
+        {
+            elementsTable.put( type.getOid(), type );
+        }
+
+        return elementsTable;
+    }
+
+
+    /**
+     * Accessor to all the objectClasses defined by the schemas stored in the pool
+     * @return as an array
+     */
+    public ObjectClass[] getObjectClassesAsArray()
+    {
+        return getObjectClassesAsHashTableByName().values().toArray( new ObjectClass[]
+            {} );
+    }
+
+
+    /**
+     * Accessor to all the attributeType defined by the schemas stored in the pool
+     * @return as an array
+     */
+    public AttributeType[] getAttributeTypesAsArray()
+    {
+        return getAttributeTypesAsHashTableByName().values().toArray( new AttributeType[]
+            {} );
+    }
+
+
+    /**
+     * Adds a bunch of already initialized schemas into the pool
+     * @param schemaArray the schema array
+     */
+    public void addSchemas( Schema[] schemaArray )
+    {
+        for ( int i = 0; i < schemaArray.length; i++ )
+            addSchema( schemaArray[i] );
+
+        //notify of the changement
+        //notifyChanged(LDAPModelEvent.Reason.multipleSchemaAdded,null);
+    }
+
+
+    /**
+     * Adds an already initialized schema into the pool
+     * @param s the schema to be added
+     * @return true if the schema has been added
+     */
+    public boolean addSchema( Schema s )
+    {
+        if ( s != null )
+        {
+            if ( !containsSchema( s.getName() ) )
+            {
+                schemaList.add( s );
+                //we register as a listener of the schema
+                s.addListener( this );
+                //we notify our listeners that a schema has been added
+                notifyChanged( LDAPModelEvent.Reason.SchemaAdded, s );
+                return true;
+            }
+        }
+        return false;
+    }
+
+
+    /**
+     * Adds a new schema into the pool (not loaded from file)
+     * @param name the name of the new schema
+     * @param type the schema type
+     * @return the schema that has been added to the pool, null if not added or already in the pool
+     */
+    public Schema addSchema( String name, Schema.SchemaType type )
+    {
+        Schema temp = new Schema( type, name );
+
+        if ( addSchema( temp ) )
+            return temp;
+
+        return null;
+    }
+
+
+    /**
+     * Adds an already existing schema into the pool (load the schema from a file)
+     * @param path the path to the .schema file
+     * @param type the schema type
+     * @return the schema that has been added to the pool, null if not added or already in the pool
+     * @throws SchemaCreationException if no schema was found at the specified
+     * path or if any error occurs during its initialization.
+     */
+    public Schema addAlreadyExistingSchema( String path, Schema.SchemaType type ) throws SchemaCreationException
+    {
+        try
+        {
+            return addAlreadyExistingSchema( new URL( "file", "localhost", -1, path ), type ); //$NON-NLS-1$ //$NON-NLS-2$
+        }
+        catch ( MalformedURLException e )
+        {
+            throw new SchemaCreationException( "error opening " + path, e ); //$NON-NLS-1$
+        }
+    }
+
+
+    /**
+     * Adds an already existing schema into the pool (load the schema from a file)
+     * @param url the URL to the .schema file
+     * @param type the schema type
+     * @return the schema that has been added to the pool, null if not added or already in the pool
+     * @throws SchemaCreationException if no schema was found at the specified
+     * URL or if any error occurs during its initialization.
+     */
+    public Schema addAlreadyExistingSchema( URL url, Schema.SchemaType type ) throws SchemaCreationException
+    {
+        Schema temp;
+        temp = new Schema( url, type );
+
+        if ( addSchema( temp ) )
+            return temp;
+
+        return null;
+    }
+
+
+    /**
+     * Removes a bunch of schemas from the pool
+     * @param schemaArray the schemas to remove
+     */
+    public void removeSchemas( Schema[] schemaArray )
+    {
+        for ( int i = 0; i < schemaArray.length; i++ )
+        {
+            removeSchema( schemaArray[i] );
+            schemaArray[i].removeListener( this );
+        }
+
+        if ( schemaArray.length > 0 )
+        {
+            //notify of the changement
+            notifyChanged( LDAPModelEvent.Reason.multipleSchemaRemoved, null );
+        }
+    }
+
+
+    /**
+     * Removes a schema from the pool
+     * @param s the schema to be removed
+     */
+    public void removeSchema( Schema s )
+    {
+        if ( s != null )
+        {
+            schemaList.remove( s );
+            s.removeListener( this );
+            s.closeAssociatedEditors();
+            //notify of the changement
+            notifyChanged( LDAPModelEvent.Reason.SchemaRemoved, s );
+        }
+    }
+
+
+    /**
+     * Removes a schema from the pool
+     * @param name the name of the schema to be removed
+     */
+    public void removeSchema( String name )
+    {
+        for ( Schema schema : schemaList )
+        {
+            if ( schema.getName().equals( name ) )
+            {
+                removeSchema( schema );
+                return;
+            }
+        }
+    }
+
+
+    /**
+     * Saves all the schemas contained in the pool
+     * @throws Exception if error during the writting process
+     */
+    public void saveAll() throws Exception
+    {
+        saveAll( false );
+    }
+
+
+    /**
+     * Saves all the schemas contained in the pool
+     * @param askForConfirmation if true, will ask form confirmation before saving	
+     * @throws Exception if error during the writting process
+     */
+    public void saveAll( boolean askForConfirmation ) throws Exception
+    {
+        for ( Schema schema : schemaList )
+        {
+            schema.save( askForConfirmation );
+        }
+    }
+
+
+    /**
+     * Clears the pool from all the stored schemas
+     * @param saveBefore if true, all the schemas are saved before the pool
+     * is cleared
+     */
+    public void clearPool( boolean saveBefore )
+    {
+        //save the pool
+        if ( saveBefore )
+        {
+            try
+            {
+                saveAll();
+            }
+            catch ( Exception e )
+            {
+                logger.debug( "error when clearing the pool" ); //$NON-NLS-1$
+            }
+        }
+
+        //remove all the associations (listeners,...)
+        for ( Schema schema : schemaList )
+        {
+            removeSchema( schema );
+        }
+
+        //make sure we have an empty list
+        schemaList = new ArrayList<Schema>();
+
+        //notify of the changement
+        notifyChanged( LDAPModelEvent.Reason.poolCleared, null );
+    }
+
+
+    /******************************************
+     *            Events emmiting             *
+     ******************************************/
+
+    public void addListener( PoolListener listener )
+    {
+        if ( !listeners.contains( listener ) )
+            listeners.add( listener );
+    }
+
+
+    public void removeListener( PoolListener listener )
+    {
+        listeners.remove( listener );
+    }
+
+
+    private void notifyChanged( LDAPModelEvent.Reason reason, Schema sc )
+    {
+        for ( PoolListener listener : listeners )
+        {
+            try
+            {
+                listener.poolChanged( this, new LDAPModelEvent( reason, sc ) );
+            }
+            catch ( Exception e )
+            {
+                logger.debug( "error when notifying " + listener + " of pool modification" ); //$NON-NLS-1$ //$NON-NLS-2$
+            }
+        }
+    }
+
+
+    /******************************************
+     *           Schema Listener Impl         *
+     ******************************************/
+
+    public void schemaChanged( Schema originatingSchema, LDAPModelEvent e )
+    {
+        for ( PoolListener listener : listeners )
+        {
+            try
+            {
+                listener.poolChanged( this, e );
+            }
+            catch ( Exception e1 )
+            {
+                logger.debug( "error when notifying " + listener + " of pool modification" ); //$NON-NLS-1$ //$NON-NLS-2$
+            }
+        }
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/Syntax.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/Syntax.java?view=auto&rev=475786
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/Syntax.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/Syntax.java Thu Nov 16 08:05:20 2006
@@ -0,0 +1,84 @@
+/*
+ *  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.ldapstudio.schemas.model;
+
+
+/**
+ * This class is the model for 'Syntax' LDAP schema
+ * elements. It is modeled after the RFC 2252 recommandation.
+ *
+ */
+public class Syntax
+{
+    private String name;
+    private String oid;
+    private boolean humanReadable;
+
+
+    /**
+     * Default constructor
+     * @param name the name of the syntax
+     * @param oid the oid of the syntax
+     * @param humanReadable a boolean specifying if the syntax is human readabe
+     */
+    public Syntax( String name, String oid, boolean humanReadable )
+    {
+        this.name = name;
+        this.oid = oid;
+        this.humanReadable = humanReadable;
+    }
+
+
+    public boolean isHumanReadable()
+    {
+        return humanReadable;
+    }
+
+
+    public void setHumanReadable( boolean humanReadable )
+    {
+        this.humanReadable = humanReadable;
+    }
+
+
+    public String getName()
+    {
+        return name;
+    }
+
+
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+
+    public String getOid()
+    {
+        return oid;
+    }
+
+
+    public void setOid( String oid )
+    {
+        this.oid = oid;
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/Syntaxes.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/Syntaxes.java?view=auto&rev=475786
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/Syntaxes.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/Syntaxes.java Thu Nov 16 08:05:20 2006
@@ -0,0 +1,112 @@
+/*
+ *  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.ldapstudio.schemas.model;
+
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.apache.commons.configuration.XMLConfiguration;
+import org.apache.directory.ldapstudio.schemas.controller.Application;
+import org.eclipse.core.runtime.Platform;
+
+
+/**
+ * This class allows to get the list of all syntaxes
+ * (which is initialized once parsing a XML file)
+ * 
+ */
+public class Syntaxes
+{
+    private static final ArrayList<Syntax> syntaxes;
+
+    static
+    {
+        try
+        {
+            syntaxes = new ArrayList<Syntax>();
+            URL url = Platform.getBundle( Application.PLUGIN_ID ).getResource( "ressources/utils/syntaxes.xml" ); //$NON-NLS-1$
+            XMLConfiguration config = new XMLConfiguration( url );
+
+            // We get the number of syntaxes to parse
+            Object syntaxesList = config.getProperty( "syntax.name" ); //$NON-NLS-1$
+            if ( syntaxesList instanceof Collection )
+            {
+                for ( int i = 0; i < ( ( Collection ) syntaxesList ).size(); i++ )
+                {
+                    // We parse each syntax and get its properties
+                    String name = config.getString( "syntax(" + i + ").name" ); //$NON-NLS-1$ //$NON-NLS-2$
+                    String oid = config.getString( "syntax(" + i + ").oid" ); //$NON-NLS-1$ //$NON-NLS-2$
+                    String hr = config.getString( "syntax(" + i + ").hr" ); //$NON-NLS-1$ //$NON-NLS-2$
+
+                    // We create the corresponding syntax object
+                    Syntax syntax = null;
+                    if ( hr.equals( "Y" ) ) { //$NON-NLS-1$
+                        syntax = new Syntax( name, oid, true );
+                    }
+                    else if ( hr.equals( "N" ) ) { //$NON-NLS-1$
+                        syntax = new Syntax( name, oid, true );
+                    }
+
+                    if ( syntax != null )
+                        syntaxes.add( syntax );
+                }
+            }
+
+        }
+        catch ( Throwable e )
+        {
+            throw new RuntimeException( e.getMessage() );
+        }
+    }
+
+
+    /**
+     * Return the unique initialized ArrayList containing all syntaxes
+     * @return the syntaxes ArrayList
+     */
+    public static ArrayList<Syntax> getSyntaxes()
+    {
+        return syntaxes;
+    }
+
+
+    /**
+     * Return the syntax object corresponding to the name given in parameter
+     * If no syntax is corresponding, it returns null
+     * @param name the name of the syntax
+     * @return the coreesponding Syntax object
+     */
+    public static Syntax getSyntax( String name )
+    {
+        for ( Iterator iter = syntaxes.iterator(); iter.hasNext(); )
+        {
+            Syntax syntax = ( Syntax ) iter.next();
+            if ( syntax.getName().equals( name ) )
+            {
+                return syntax;
+            }
+        }
+        return null;
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/IImageKeys.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/IImageKeys.java?view=auto&rev=475786
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/IImageKeys.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/IImageKeys.java Thu Nov 16 08:05:20 2006
@@ -0,0 +1,51 @@
+/*
+ *  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.ldapstudio.schemas.view;
+
+
+/**
+ * This class is used to define path for images
+ */
+public interface IImageKeys
+{
+    // Images for Actions
+    public static final String ABOUT = "ressources/icons/flag_blue.png"; //$NON-NLS-1$
+    public static final String CREATE_A_NEW_SCHEMA = "ressources/icons/schema_new.png"; //$NON-NLS-1$
+    public static final String REMOVE_SCHEMA = "ressources/icons/schema_remove.png"; //$NON-NLS-1$
+    public static final String CREATE_A_NEW_OBJECTCLASS = "ressources/icons/object_class_new.gif"; //$NON-NLS-1$
+    public static final String CREATE_A_NEW_ATTRIBUTETYPE = "ressources/icons/attribute_type_new.gif"; //$NON-NLS-1$
+    public static final String DELETE = "ressources/icons/delete.gif"; //$NON-NLS-1$
+    public static final String EXIT = "ressources/icons/stop.png"; //$NON-NLS-1$
+    public static final String OPEN_LOCAL = "ressources/icons/open.png"; //$NON-NLS-1$
+    public static final String SAVE = "ressources/icons/save.gif"; //$NON-NLS-1$
+    public static final String SAVE_AS = "ressources/icons/save_as.png"; //$NON-NLS-1$
+    public static final String SAVE_ALL = "ressources/icons/save_all.png"; //$NON-NLS-1$
+    public static final String SORT_ALPHABETICAL = "ressources/icons/sort_alphabetical.gif"; //$NON-NLS-1$
+    public static final String SORT_UNALPHABETICAL = "ressources/icons/sort_unalphabetical.gif"; //$NON-NLS-1$
+    public static final String SHOW_PREFERENCES = "ressources/icons/preferences.png"; //$NON-NLS-1$
+
+    // Images for Views
+    public static final String ATTRIBUTE_TYPE = "ressources/icons/attribute_type.gif"; //$NON-NLS-1$
+    public static final String OBJECT_CLASS = "ressources/icons/object_class.gif"; //$NON-NLS-1$
+    public static final String OBJECT_CLASS_WARNING = "ressources/icons/object_class_warning.gif"; //$NON-NLS-1$
+    public static final String SCHEMA = "ressources/icons/schema.gif"; //$NON-NLS-1$
+    public static final String SCHEMA_CORE = "ressources/icons/schema_core.gif"; //$NON-NLS-1$
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeFormEditor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeFormEditor.java?view=auto&rev=475786
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeFormEditor.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeFormEditor.java Thu Nov 16 08:05:20 2006
@@ -0,0 +1,178 @@
+/*
+ *  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.ldapstudio.schemas.view.editors;
+
+
+import org.apache.directory.ldapstudio.schemas.controller.Application;
+import org.apache.directory.ldapstudio.schemas.model.AttributeType;
+import org.apache.log4j.Logger;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.forms.editor.FormEditor;
+
+
+/**
+ * This class is the Attribute Type Editor main class
+ */
+public class AttributeTypeFormEditor extends FormEditor
+{
+    private static Logger logger = Logger.getLogger( AttributeTypeFormEditor.class );
+
+    public static final String ID = Application.PLUGIN_ID + ".view.attributetypeformeditor"; //$NON-NLS-1$
+
+    private AttributeTypeFormEditorOverviewPage overview;
+
+    private AttributeTypeFormEditorSourceCodePage sourceCode;
+
+    private boolean dirty = false;
+
+    private AttributeType attributeType;
+
+
+    /**
+     * Default constructor
+     */
+    public AttributeTypeFormEditor()
+    {
+        super();
+    }
+
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.ui.forms.editor.FormEditor#init(org.eclipse.ui.IEditorSite,
+     *      org.eclipse.ui.IEditorInput)
+     */
+    @Override
+    public void init( IEditorSite site, IEditorInput input ) throws PartInitException
+    {
+        setSite( site );
+        setInput( input );
+        setPartName( input.getName() );
+
+        attributeType = ( ( AttributeTypeFormEditorInput ) getEditorInput() ).getAttributeType();
+        attributeType.setEditor( this );
+    }
+
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.ui.forms.editor.FormEditor#dispose()
+     */
+    @Override
+    public void dispose()
+    {
+        attributeType.removeEditor( this );
+    }
+
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
+     */
+    @Override
+    protected void addPages()
+    {
+        try
+        {
+            overview = new AttributeTypeFormEditorOverviewPage( this,
+                "overview", Messages.getString( "AttributeTypeFormEditor.Overview" ) ); //$NON-NLS-1$ //$NON-NLS-2$
+            addPage( overview );
+            sourceCode = new AttributeTypeFormEditorSourceCodePage( this,
+                "sourceCode", Messages.getString( "AttributeTypeFormEditor.Source_Code" ) ); //$NON-NLS-1$ //$NON-NLS-2$
+            addPage( sourceCode );
+        }
+        catch ( PartInitException e )
+        {
+            logger.debug( "error when adding pages" ); //$NON-NLS-1$
+        }
+    }
+
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
+     */
+    @Override
+    public void doSave( IProgressMonitor monitor )
+    {
+        // Save is delegate to the page (that holds the object class itself)
+        overview.doSave( monitor );
+        // We reload the name in case of it has changed
+        setPartName( getEditorInput().getName() );
+        sourceCode.refresh();
+        setDirty( false );
+    }
+
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.ui.part.EditorPart#doSaveAs()
+     */
+    @Override
+    public void doSaveAs()
+    {
+    }
+
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
+     */
+    @Override
+    public boolean isSaveAsAllowed()
+    {
+        return false;
+    }
+
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.ui.forms.editor.FormEditor#isDirty()
+     */
+    @Override
+    public boolean isDirty()
+    {
+        return this.dirty;
+    }
+
+
+    /**
+     * Sets the dirty state of the editor
+     * 
+     * @param dirty
+     *            the dirty state
+     */
+    public void setDirty( boolean dirty )
+    {
+        this.dirty = dirty;
+        editorDirtyStateChanged();
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeFormEditorInput.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeFormEditorInput.java?view=auto&rev=475786
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeFormEditorInput.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeFormEditorInput.java Thu Nov 16 08:05:20 2006
@@ -0,0 +1,147 @@
+/*
+ *  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.ldapstudio.schemas.view.editors;
+
+
+import org.apache.directory.ldapstudio.schemas.model.AttributeType;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPersistableElement;
+
+
+/**
+ * This class is the Input class for the Attribute Type Editor
+ */
+public class AttributeTypeFormEditorInput implements IEditorInput
+{
+    private AttributeType attributeType = null;
+
+
+    /**
+     * Default constructor
+     * 
+     * @param at
+     *            the input attribute type
+     */
+    public AttributeTypeFormEditorInput( AttributeType at )
+    {
+        super();
+        this.attributeType = at;
+    }
+
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.ui.IEditorInput#exists()
+     */
+    public boolean exists()
+    {
+        return ( this.attributeType == null );
+    }
+
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.ui.IEditorInput#getName()
+     */
+    public String getName()
+    {
+        return this.attributeType.getNames()[0];
+    }
+
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.ui.IEditorInput#getPersistable()
+     */
+    public IPersistableElement getPersistable()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.ui.IEditorInput#getToolTipText()
+     */
+    public String getToolTipText()
+    {
+        return this.attributeType.getNames()[0]
+            + Messages.getString( "AttributeTypeFormEditorInput.In_the" ) //$NON-NLS-1$
+            + this.attributeType.getOriginatingSchema().getName()
+            + Messages.getString( "AttributeTypeFormEditorInput.Schema" ); //$NON-NLS-1$
+    }
+
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+     */
+    public Object getAdapter( Class adapter )
+    {
+        return null;
+    }
+
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+            return true;
+        if ( !( obj instanceof AttributeTypeFormEditorInput ) )
+            return false;
+        AttributeTypeFormEditorInput other = ( AttributeTypeFormEditorInput ) obj;
+        return other.getAttributeType().getOid().equals( this.attributeType.getOid() );
+    }
+
+
+    /**
+     * Returns the input Attribute Type
+     * 
+     * @return the input Attribute Type
+     */
+    public AttributeType getAttributeType()
+    {
+        return this.attributeType;
+    }
+}



Mime
View raw message