You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2006/11/16 17:05:29 UTC

svn commit: r475786 [10/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/...

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditorOverviewPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditorOverviewPage.java?view=auto&rev=475786
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditorOverviewPage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditorOverviewPage.java Thu Nov 16 08:05:20 2006
@@ -0,0 +1,845 @@
+/*
+ *  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 java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+
+import org.apache.directory.ldapstudio.schemas.controller.Application;
+import org.apache.directory.ldapstudio.schemas.controller.PoolManagerController;
+import org.apache.directory.ldapstudio.schemas.model.ObjectClass;
+import org.apache.directory.ldapstudio.schemas.model.Schema;
+import org.apache.directory.ldapstudio.schemas.model.SchemaPool;
+import org.apache.directory.ldapstudio.schemas.view.IImageKeys;
+import org.apache.directory.shared.ldap.schema.ObjectClassTypeEnum;
+import org.apache.log4j.Logger;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.events.HyperlinkAdapter;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Hyperlink;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class is the Overview Page of the Object Class Editor
+ */
+public class ObjectClassFormEditorOverviewPage extends FormPage
+{
+
+    private Text name_text;
+    private Text oid_text;
+    private Text description_text;
+    private Hyperlink sup_label;
+    private Combo sup_combo;
+    private Combo classType_combo;
+    private Button obsolete_checkbox;
+    private Table mandatoryAttributes_table;
+    private Table optionnalAttributes_table;
+    private ObjectClass objectClass;
+    private String[] aliasesList;
+    private Button aliases_button;
+
+
+    /**
+     * Default constructor
+     * @param editor
+     * @param id
+     * @param title
+     */
+    public ObjectClassFormEditorOverviewPage( FormEditor editor, String id, String title )
+    {
+        super( editor, id, title );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.forms.editor.FormPage#createFormContent(org.eclipse.ui.forms.IManagedForm)
+     */
+    protected void createFormContent( IManagedForm managedForm )
+    {
+        ScrolledForm form = managedForm.getForm();
+        FormToolkit toolkit = managedForm.getToolkit();
+        GridLayout layout = new GridLayout( 2, true );
+        form.getBody().setLayout( layout );
+
+        // Getting the input and the objectClass
+        ObjectClassFormEditorInput input = ( ObjectClassFormEditorInput ) getEditorInput();
+        objectClass = ( ObjectClass ) input.getObjectClass();
+
+        // General Information Section
+        Section section_general_information = toolkit.createSection( form.getBody(), Section.DESCRIPTION
+            | Section.TITLE_BAR );
+        section_general_information.setDescription( Messages
+            .getString( "ObjectClassFormEditorOverviewPage.General_Information_Section_Description" ) ); //$NON-NLS-1$
+        section_general_information.setText( Messages
+            .getString( "ObjectClassFormEditorOverviewPage.General_Information_Section_Text" ) ); //$NON-NLS-1$
+
+        // Creating the layout of the section
+        Composite client_general_information = toolkit.createComposite( section_general_information );
+        GridLayout layout_general_information = new GridLayout();
+        layout_general_information.numColumns = 2;
+        client_general_information.setLayout( layout_general_information );
+        toolkit.paintBordersFor( client_general_information );
+        section_general_information.setClient( client_general_information );
+        section_general_information.setLayoutData( new GridData( GridData.FILL, GridData.FILL, true, true, 2, 1 ) );
+
+        // Adding elements to the section
+        // NAME Field
+        toolkit
+            .createLabel( client_general_information, Messages.getString( "ObjectClassFormEditorOverviewPage.Name" ) ); //$NON-NLS-1$
+        name_text = toolkit.createText( client_general_information, "" ); //$NON-NLS-1$
+        name_text.setLayoutData( new GridData( GridData.FILL, SWT.NONE, true, false ) );
+
+        // ALIASES Button
+        toolkit.createLabel( client_general_information, Messages
+            .getString( "ObjectClassFormEditorOverviewPage.Aliases" ) ); //$NON-NLS-1$
+        aliases_button = toolkit.createButton( client_general_information, Messages
+            .getString( "ObjectClassFormEditorOverviewPage.Manage_Aliases" ), SWT.PUSH ); //$NON-NLS-1$
+        aliases_button.setLayoutData( new GridData( SWT.NONE, SWT.BEGINNING, false, false ) );
+
+        // OID Field
+        toolkit.createLabel( client_general_information, Messages.getString( "ObjectClassFormEditorOverviewPage.OID" ) ); //$NON-NLS-1$
+        oid_text = toolkit.createText( client_general_information, "" ); //$NON-NLS-1$
+        oid_text.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // DESCRIPTION Field
+        toolkit.createLabel( client_general_information, Messages
+            .getString( "ObjectClassFormEditorOverviewPage.Description" ) ); //$NON-NLS-1$
+        description_text = toolkit.createText( client_general_information, "", SWT.MULTI | SWT.V_SCROLL ); //$NON-NLS-1$
+        GridData descriptionGridData = new GridData( SWT.FILL, SWT.NONE, true, false );
+        descriptionGridData.heightHint = 37;
+        description_text.setLayoutData( descriptionGridData );
+
+        // SUP Combo
+        sup_label = toolkit.createHyperlink( client_general_information, Messages
+            .getString( "ObjectClassFormEditorOverviewPage.Superior_class" ), SWT.WRAP ); //$NON-NLS-1$
+        sup_combo = new Combo( client_general_information, SWT.READ_ONLY | SWT.SINGLE );
+        sup_combo.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // CLASS TYPE Combo
+        toolkit.createLabel( client_general_information, Messages
+            .getString( "ObjectClassFormEditorOverviewPage.Class_type" ) ); //$NON-NLS-1$
+        classType_combo = new Combo( client_general_information, SWT.READ_ONLY | SWT.SINGLE );
+        classType_combo.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // OBSOLETE Checkbox
+        toolkit.createLabel( client_general_information, "" ); //$NON-NLS-1$
+        obsolete_checkbox = toolkit.createButton( client_general_information, Messages
+            .getString( "ObjectClassFormEditorOverviewPage.Obsolete" ), SWT.CHECK ); //$NON-NLS-1$
+        obsolete_checkbox.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Mandatory Attributes Section
+        createMandatoryAttributesSection( form.getBody(), toolkit );
+
+        // Optionnal Attributes Section
+        createOptionnalAttributesSection( form.getBody(), toolkit );
+
+        // Initialization from the "input" object class
+        initFieldsContentFromInput();
+
+        // Listeners initialization
+        initListeners();
+    }
+
+
+    private void createMandatoryAttributesSection( Composite parent, FormToolkit toolkit )
+    {
+        // MANDATORY ATTRIBUTES Section
+        Section section = toolkit.createSection( parent, Section.DESCRIPTION | Section.TITLE_BAR );
+        section.setText( Messages.getString( "ObjectClassFormEditorOverviewPage.Mandatory_Attribute_Section_Text" ) ); //$NON-NLS-1$
+        section.setDescription( Messages
+            .getString( "ObjectClassFormEditorOverviewPage.Mandatory_Attribute_Section_Description" ) ); //$NON-NLS-1$
+        section.setExpanded( true );
+        Composite client = toolkit.createComposite( section );
+        section.setClient( client );
+        GridData gd = new GridData( GridData.FILL, GridData.FILL, true, true );
+        section.setLayoutData( gd );
+        toolkit.paintBordersFor( client );
+
+        GridLayout layout = new GridLayout();
+        layout.numColumns = 2;
+        client.setLayout( layout );
+
+        mandatoryAttributes_table = toolkit.createTable( client, SWT.NULL );
+        gd = new GridData( SWT.FILL, SWT.FILL, true, true );
+        gd.verticalSpan = 2;
+        gd.heightHint = 100;
+        mandatoryAttributes_table.setLayoutData( gd );
+
+        final Button add_button = toolkit.createButton( client, Messages
+            .getString( "ObjectClassFormEditorOverviewPage.Add..." ), SWT.PUSH ); //$NON-NLS-1$
+        final Button remove_button = toolkit.createButton( client, Messages
+            .getString( "ObjectClassFormEditorOverviewPage.Remove" ), SWT.PUSH ); //$NON-NLS-1$
+        gd = new GridData( GridData.VERTICAL_ALIGN_BEGINNING );
+        add_button.setLayoutData( gd );
+        remove_button.setLayoutData( gd );
+        remove_button.setEnabled( false );
+
+        if ( objectClass.getOriginatingSchema().type == Schema.SchemaType.coreSchema )
+        {
+            // If the object class is in a core-schema file, we disable editing
+            add_button.setEnabled( false );
+            remove_button.setEnabled( false );
+        }
+        else
+        {
+            // else we set the listeners
+            add_button.addSelectionListener( new SelectionAdapter()
+            {
+                public void widgetSelected( SelectionEvent e )
+                {
+                    AttributeTypeSelectionDialog selectionDialog = new AttributeTypeSelectionDialog( null );
+                    if ( selectionDialog.open() != Window.OK )
+                    {
+                        return;
+                    }
+                    if ( isAttributeTypeAlreadySpecified( selectionDialog.getSelectedAttributeType(),
+                        optionnalAttributes_table ) )
+                    {
+                        // The selected attribute type is already in the Optionnal Attributes Table
+                        MessageDialog
+                            .openError(
+                                null,
+                                Messages.getString( "ObjectClassFormEditorOverviewPage.Invalid_Selection" ), Messages.getString( "ObjectClassFormEditorOverviewPage.The_selected_attribute_type_is_already_in_the_Optionnal_Attributes_section" ) ); //$NON-NLS-1$ //$NON-NLS-2$
+                    }
+                    else
+                    {
+                        if ( isAttributeTypeAlreadySpecified( selectionDialog.getSelectedAttributeType(),
+                            mandatoryAttributes_table ) )
+                        {
+                            // The selected attribute type is already in the Mandatory Attributes Table
+                            MessageDialog
+                                .openError(
+                                    null,
+                                    Messages.getString( "ObjectClassFormEditorOverviewPage.Invalid_Selection" ), Messages.getString( "ObjectClassFormEditorOverviewPage.The_selected_attribute_type_is_already_in_the_this_section" ) ); //$NON-NLS-1$ //$NON-NLS-2$
+                        }
+                        else
+                        {
+                            // The selected attribute is not in any table, so it can be added
+                            TableItem item = new TableItem( mandatoryAttributes_table, SWT.NONE );
+                            item.setImage( AbstractUIPlugin.imageDescriptorFromPlugin( Application.PLUGIN_ID,
+                                IImageKeys.ATTRIBUTE_TYPE ).createImage() );
+                            item.setText( selectionDialog.getSelectedAttributeType() );
+                            setEditorDirty();
+                        }
+
+                    }
+                }
+            } );
+            remove_button.addSelectionListener( new SelectionAdapter()
+            {
+                public void widgetSelected( SelectionEvent e )
+                {
+                    mandatoryAttributes_table.remove( mandatoryAttributes_table.getSelectionIndex() );
+                    setEditorDirty();
+                    remove_button.setEnabled( mandatoryAttributes_table.getSelection().length != 0 );
+                }
+            } );
+        }
+        // This listener needs to be outside of the 'if' so that attribute type editor can be opened from any object class (in a core or a user schema)
+        mandatoryAttributes_table.addMouseListener( new MouseListener()
+        {
+            public void mouseDoubleClick( MouseEvent e )
+            {
+                SchemaPool pool = SchemaPool.getInstance();
+                IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+
+                AttributeTypeFormEditorInput input = new AttributeTypeFormEditorInput( pool
+                    .getAttributeType( mandatoryAttributes_table.getSelection()[0].getText() ) );
+                String editorId = AttributeTypeFormEditor.ID;
+                try
+                {
+                    page.openEditor( input, editorId );
+                }
+                catch ( PartInitException exception )
+                {
+                    Logger.getLogger( PoolManagerController.class ).debug( "error when opening the editor" ); //$NON-NLS-1$
+                }
+            }
+
+
+            public void mouseDown( MouseEvent e )
+            {
+            }
+
+
+            public void mouseUp( MouseEvent e )
+            {
+                if ( objectClass.getOriginatingSchema().type != Schema.SchemaType.coreSchema )
+                {
+                    remove_button.setEnabled( mandatoryAttributes_table.getSelection().length != 0 );
+                }
+            }
+        } );
+    }
+
+
+    private void createOptionnalAttributesSection( Composite parent, FormToolkit toolkit )
+    {
+        // OPTIONNAL ATTRIBUTES Section
+        Section section = toolkit.createSection( parent, Section.DESCRIPTION | Section.TITLE_BAR );
+        section.setText( Messages.getString( "ObjectClassFormEditorOverviewPage.Optionnal_Attributes_Section_Text" ) ); //$NON-NLS-1$
+        section.setDescription( Messages
+            .getString( "ObjectClassFormEditorOverviewPage.Optionnal_Attributes_Section_Description" ) ); //$NON-NLS-1$
+        section.setExpanded( true );
+        Composite client = toolkit.createComposite( section );
+        section.setClient( client );
+        GridData gd = new GridData( GridData.FILL, GridData.FILL, true, true );
+        section.setLayoutData( gd );
+        toolkit.paintBordersFor( client );
+
+        GridLayout layout = new GridLayout();
+        layout.numColumns = 2;
+        client.setLayout( layout );
+
+        optionnalAttributes_table = toolkit.createTable( client, SWT.SINGLE | SWT.V_SCROLL );
+        gd = new GridData( SWT.FILL, SWT.FILL, true, true );
+        gd.verticalSpan = 2;
+        gd.heightHint = 100;
+        optionnalAttributes_table.setLayoutData( gd );
+
+        final Button add_button = toolkit.createButton( client, Messages
+            .getString( "ObjectClassFormEditorOverviewPage.Add..." ), SWT.PUSH ); //$NON-NLS-1$
+        final Button remove_button = toolkit.createButton( client, Messages
+            .getString( "ObjectClassFormEditorOverviewPage.Remove" ), SWT.PUSH ); //$NON-NLS-1$
+        gd = new GridData( GridData.VERTICAL_ALIGN_BEGINNING );
+        add_button.setLayoutData( gd );
+        remove_button.setLayoutData( gd );
+        remove_button.setEnabled( false );
+
+        if ( objectClass.getOriginatingSchema().type == Schema.SchemaType.coreSchema )
+        {
+            // If the object class is in a core-schema file, we disable editing
+            add_button.setEnabled( false );
+            remove_button.setEnabled( false );
+        }
+        else
+        {
+            // else we set the listeners
+            add_button.addSelectionListener( new SelectionAdapter()
+            {
+                public void widgetSelected( SelectionEvent e )
+                {
+                    AttributeTypeSelectionDialog selectionDialog = new AttributeTypeSelectionDialog( null );
+                    if ( selectionDialog.open() != Window.OK )
+                    {
+                        return;
+                    }
+                    if ( isAttributeTypeAlreadySpecified( selectionDialog.getSelectedAttributeType(),
+                        mandatoryAttributes_table ) )
+                    {
+                        // The selected attribute type is already in the Mandatory Attributes Table
+                        MessageDialog
+                            .openError(
+                                null,
+                                Messages.getString( "ObjectClassFormEditorOverviewPage.Invalid_Selection" ), Messages.getString( "ObjectClassFormEditorOverviewPage.The_selected_attribute_type_is_already_in_the_Mandatory_Attributes_section" ) ); //$NON-NLS-1$ //$NON-NLS-2$
+                    }
+                    else
+                    {
+                        if ( isAttributeTypeAlreadySpecified( selectionDialog.getSelectedAttributeType(),
+                            optionnalAttributes_table ) )
+                        {
+                            // The selected attribute type is already in the Optionnal Attributes Table
+                            MessageDialog
+                                .openError(
+                                    null,
+                                    Messages.getString( "ObjectClassFormEditorOverviewPage.Invalid_Selection" ), Messages.getString( "ObjectClassFormEditorOverviewPage.The_selected_attribute_type_is_already_in_the_this_section" ) ); //$NON-NLS-1$ //$NON-NLS-2$
+                        }
+                        else
+                        {
+                            // The selected attribute is not in any table, so it can be added
+                            TableItem item = new TableItem( optionnalAttributes_table, SWT.NONE );
+                            item.setImage( AbstractUIPlugin.imageDescriptorFromPlugin( Application.PLUGIN_ID,
+                                IImageKeys.ATTRIBUTE_TYPE ).createImage() );
+                            item.setText( selectionDialog.getSelectedAttributeType() );
+                            setEditorDirty();
+                        }
+
+                    }
+                }
+            } );
+            remove_button.addSelectionListener( new SelectionAdapter()
+            {
+                public void widgetSelected( SelectionEvent e )
+                {
+                    optionnalAttributes_table.remove( optionnalAttributes_table.getSelectionIndex() );
+                    setEditorDirty();
+                    remove_button.setEnabled( optionnalAttributes_table.getSelection().length != 0 );
+                }
+            } );
+        }
+        // This listener needs to be outside of the 'if' so that attribute type editor can be opened from any object class (in a core or a user schema)
+        optionnalAttributes_table.addMouseListener( new MouseListener()
+        {
+            public void mouseDoubleClick( MouseEvent e )
+            {
+                SchemaPool pool = SchemaPool.getInstance();
+                IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+
+                AttributeTypeFormEditorInput input = new AttributeTypeFormEditorInput( pool
+                    .getAttributeType( optionnalAttributes_table.getSelection()[0].getText() ) );
+                String editorId = AttributeTypeFormEditor.ID;
+                try
+                {
+                    page.openEditor( input, editorId );
+                }
+                catch ( PartInitException exception )
+                {
+                    Logger.getLogger( PoolManagerController.class ).debug( "error when opening the editor" ); //$NON-NLS-1$
+                }
+            }
+
+
+            public void mouseDown( MouseEvent e )
+            {
+            }
+
+
+            public void mouseUp( MouseEvent e )
+            {
+                if ( objectClass.getOriginatingSchema().type != Schema.SchemaType.coreSchema )
+                {
+                    remove_button.setEnabled( optionnalAttributes_table.getSelection().length != 0 );
+                }
+            }
+        } );
+    }
+
+
+    private boolean isAttributeTypeAlreadySpecified( String name, Table table )
+    {
+        for ( int i = 0; i < table.getItemCount(); i++ )
+        {
+            if ( table.getItem( i ).getText().equals( name ) )
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+
+    private void initFieldsContentFromInput()
+    {
+        // NAME Field
+        if ( objectClass.getNames()[0] != null )
+        {
+            this.name_text.setText( objectClass.getNames()[0] );
+        }
+
+        // ALIASES
+        String[] names = objectClass.getNames();
+        ArrayList<String> aliases = new ArrayList<String>();
+        for ( int i = 1; i < names.length; i++ )
+        {
+            String name = names[i];
+            aliases.add( name );
+        }
+        this.aliasesList = aliases.toArray( new String[0] );
+
+        // OID Field
+        if ( objectClass.getOid() != null )
+        {
+            this.oid_text.setText( objectClass.getOid() );
+        }
+
+        // DESCRIPTION Field
+        if ( objectClass.getDescription() != null )
+        {
+            this.description_text.setText( objectClass.getDescription() );
+        }
+
+        // SUP Combo
+        initSup_combo();
+
+        // CLASSTYPE Combo
+        initClassType_combo();
+
+        // OBSOLETE Checkbox
+        if ( objectClass.isObsolete() )
+        {
+            this.obsolete_checkbox.setSelection( true );
+        }
+
+        // MANDATORY ATTRIBUTES Table
+        initMandatoryAttributes_table();
+
+        // OPTIONNAL ATTRIBUTES Table
+        initOptionnalAttributes_table();
+    }
+
+
+    private void initSup_combo()
+    {
+        SchemaPool pool = SchemaPool.getInstance();
+        ArrayList<ObjectClass> ocList = new ArrayList<ObjectClass>( pool.getObjectClassesAsHashTableByName().values() );
+
+        //remove duplicate entries
+        HashSet<ObjectClass> set = new HashSet<ObjectClass>( ocList );
+        ocList = new ArrayList<ObjectClass>( set );
+
+        // Sorting the list
+        Collections.sort( ocList, new Comparator<ObjectClass>()
+        {
+            public int compare( ObjectClass arg0, ObjectClass arg1 )
+            {
+                String oneName = arg0.getNames()[0];
+                String twoName = arg1.getNames()[0];
+                return oneName.compareTo( twoName );
+            }
+        } );
+
+        // Creating the UI
+        sup_combo.add( Messages.getString( "ObjectClassFormEditorOverviewPage.(None)" ) ); //$NON-NLS-1$
+        sup_combo.select( 0 );
+        int counter = 1;
+        for ( ObjectClass oc : ocList )
+        {
+            // TODO : Ajouter une verification pour qu'on ne puisse pas ajouter en sup l'objectclass lui meme et ses alias
+            sup_combo.add( oc.getNames()[0], counter );
+            if ( ( objectClass.getSuperiors().length != 0 )
+                && ( oc.getNames()[0].equals( objectClass.getSuperiors()[0] ) ) )
+            {
+                // We select the right superior
+                sup_combo.select( counter );
+            }
+            counter++;
+        }
+    }
+
+
+    private void initClassType_combo()
+    {
+        classType_combo.add( Messages.getString( "ObjectClassFormEditorOverviewPage.Abstract" ), 0 ); //$NON-NLS-1$
+        classType_combo.add( Messages.getString( "ObjectClassFormEditorOverviewPage.Auxiliary" ), 1 ); //$NON-NLS-1$
+        classType_combo.add( Messages.getString( "ObjectClassFormEditorOverviewPage.Structural" ), 2 ); //$NON-NLS-1$
+        if ( objectClass.getClassType() == ObjectClassTypeEnum.ABSTRACT )
+        {
+            classType_combo.select( 0 );
+        }
+        else if ( objectClass.getClassType() == ObjectClassTypeEnum.AUXILIARY )
+        {
+            classType_combo.select( 1 );
+        }
+        else if ( objectClass.getClassType() == ObjectClassTypeEnum.STRUCTURAL )
+        {
+            classType_combo.select( 2 );
+        }
+    }
+
+
+    private void initMandatoryAttributes_table()
+    {
+        String[] mustArray = objectClass.getMust();
+        for ( int i = 0; i < mustArray.length; i++ )
+        {
+            TableItem item = new TableItem( mandatoryAttributes_table, SWT.NONE );
+            item.setImage( AbstractUIPlugin
+                .imageDescriptorFromPlugin( Application.PLUGIN_ID, IImageKeys.ATTRIBUTE_TYPE ).createImage() );
+            item.setText( mustArray[i] );
+        }
+    }
+
+
+    private void initOptionnalAttributes_table()
+    {
+        String[] mayArray = objectClass.getMay();
+        for ( int i = 0; i < mayArray.length; i++ )
+        {
+            TableItem item = new TableItem( optionnalAttributes_table, SWT.NONE );
+            item.setImage( AbstractUIPlugin
+                .imageDescriptorFromPlugin( Application.PLUGIN_ID, IImageKeys.ATTRIBUTE_TYPE ).createImage() );
+            item.setText( mayArray[i] );
+        }
+    }
+
+
+    private void initListeners()
+    {
+        // NAME Field
+        if ( objectClass.getOriginatingSchema().type == Schema.SchemaType.coreSchema )
+        {
+            // If the object class is in a core-schema file, we disable editing
+            name_text.setEditable( false );
+        }
+        else
+        {
+            // else we set the listener
+            name_text.addModifyListener( new ModifyListener()
+            {
+                public void modifyText( ModifyEvent e )
+                {
+                    setEditorDirty();
+                }
+            } );
+        }
+
+        // ALIASES Button
+        // The user can always access to the Manage Aliases Window, but if the object class is in a core-schema file editing will be disabled
+        aliases_button.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                ManageAliasesDialog manageDialog = new ManageAliasesDialog( null, aliasesList, ( objectClass
+                    .getOriginatingSchema().type == Schema.SchemaType.coreSchema ) );
+                if ( manageDialog.open() != Window.OK )
+                {
+                    return;
+                }
+                if ( manageDialog.isDirty() )
+                {
+                    aliasesList = manageDialog.getAliasesList();
+                    setEditorDirty();
+                }
+            }
+        } );
+
+        // OID Field
+        if ( objectClass.getOriginatingSchema().type == Schema.SchemaType.coreSchema )
+        {
+            // If the object class is in a core-schema file, we disable editing
+            oid_text.setEditable( false );
+        }
+        else
+        {
+            // else we set the listener
+            oid_text.addModifyListener( new ModifyListener()
+            {
+                public void modifyText( ModifyEvent e )
+                {
+                    setEditorDirty();
+                }
+            } );
+        }
+
+        // DESCRIPTION Field
+        if ( objectClass.getOriginatingSchema().type == Schema.SchemaType.coreSchema )
+        {
+            // If the object class is in a core-schema file, we disable editing
+            description_text.setEditable( false );
+        }
+        else
+        {
+            // else we set the listener
+            description_text.addModifyListener( new ModifyListener()
+            {
+                public void modifyText( ModifyEvent e )
+                {
+                    setEditorDirty();
+                }
+            } );
+        }
+
+        // SUP Combo
+        sup_label.addHyperlinkListener( new HyperlinkAdapter()
+        {
+            public void linkActivated( HyperlinkEvent e )
+            {
+                if ( !sup_combo.getItem( sup_combo.getSelectionIndex() ).equals(
+                    Messages.getString( "ObjectClassFormEditorOverviewPage.(None)" ) ) ) { //$NON-NLS-1$
+                    SchemaPool pool = SchemaPool.getInstance();
+                    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+
+                    ObjectClassFormEditorInput input = new ObjectClassFormEditorInput( pool.getObjectClass( sup_combo
+                        .getItem( sup_combo.getSelectionIndex() ) ) );
+                    String editorId = ObjectClassFormEditor.ID;
+                    try
+                    {
+                        page.openEditor( input, editorId );
+                    }
+                    catch ( PartInitException exception )
+                    {
+                        Logger.getLogger( ObjectClassFormEditorOverviewPage.class ).debug(
+                            "error when opening the editor" ); //$NON-NLS-1$
+                    }
+                }
+            }
+        } );
+        if ( objectClass.getOriginatingSchema().type == Schema.SchemaType.coreSchema )
+        {
+            // If the object class is in a core-schema file, we disable editing
+            sup_combo.setEnabled( false );
+        }
+        else
+        {
+            // else we set the listener
+            sup_combo.addModifyListener( new ModifyListener()
+            {
+                public void modifyText( ModifyEvent e )
+                {
+                    setEditorDirty();
+                }
+            } );
+        }
+
+        // CLASS TYPE Combo
+        if ( objectClass.getOriginatingSchema().type == Schema.SchemaType.coreSchema )
+        {
+            // If the object class is in a core-schema file, we disable editing
+            classType_combo.setEnabled( false );
+        }
+        else
+        {
+            // else we set the listener
+            classType_combo.addModifyListener( new ModifyListener()
+            {
+                public void modifyText( ModifyEvent e )
+                {
+                    setEditorDirty();
+                }
+            } );
+        }
+
+        // OBSOLETE Checkbox
+        if ( objectClass.getOriginatingSchema().type == Schema.SchemaType.coreSchema )
+        {
+            // If the object class is in a core-schema file, we disable editing
+            obsolete_checkbox.setEnabled( false );
+        }
+        else
+        {
+            // else we set the listener
+            obsolete_checkbox.addSelectionListener( new SelectionListener()
+            {
+                public void widgetDefaultSelected( SelectionEvent e )
+                {
+                }
+
+
+                public void widgetSelected( SelectionEvent e )
+                {
+                    setEditorDirty();
+                }
+            } );
+        }
+    }
+
+
+    private void setEditorDirty()
+    {
+        ( ( ObjectClassFormEditor ) getEditor() ).setDirty( true );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.forms.editor.FormPage#doSave(org.eclipse.core.runtime.IProgressMonitor)
+     */
+    @Override
+    public void doSave( IProgressMonitor monitor )
+    {
+        // NAME
+        //		if ( name_text.getText().equals("") ){
+        //			MessageBox messageBox = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.OK|SWT.ICON_ERROR);
+        //			messageBox.setMessage("You must to provide a name to the object class to be able to save it.");
+        //			messageBox.open();
+        //			monitor.setCanceled(true);
+        //			monitor.done();
+        //			return;
+        //		}
+        ArrayList<String> names = new ArrayList<String>();
+        names.add( name_text.getText() );
+        for ( int i = 0; i < this.aliasesList.length; i++ )
+        {
+            names.add( this.aliasesList[i] );
+        }
+        objectClass.setNames( names.toArray( new String[0] ) );
+
+        // OID
+        objectClass.setOid( oid_text.getText() );
+
+        // DESCRIPTION
+        objectClass.setDescription( description_text.getText() );
+
+        // SUP
+        if ( sup_combo.getItem( sup_combo.getSelectionIndex() ).equals(
+            Messages.getString( "ObjectClassFormEditorOverviewPage.(None)" ) ) ) { //$NON-NLS-1$
+            objectClass.setSuperiors( new String[0] );
+        }
+        else
+        {
+            objectClass.setSuperiors( new String[]
+                { sup_combo.getItem( sup_combo.getSelectionIndex() ) } );
+        }
+
+        // CLASS TYPE
+        if ( classType_combo.getSelectionIndex() == 0 )
+        {
+            objectClass.setClassType( ObjectClassTypeEnum.ABSTRACT );
+        }
+        else if ( classType_combo.getSelectionIndex() == 1 )
+        {
+            objectClass.setClassType( ObjectClassTypeEnum.AUXILIARY );
+        }
+        else if ( classType_combo.getSelectionIndex() == 2 )
+        {
+            objectClass.setClassType( ObjectClassTypeEnum.STRUCTURAL );
+        }
+
+        // OBSOLETE
+        objectClass.setObsolete( obsolete_checkbox.getSelection() );
+
+        // MANDATORY ATTRIBUTES
+        ArrayList<String> mustList = new ArrayList<String>();
+        for ( int i = 0; i < mandatoryAttributes_table.getItemCount(); i++ )
+        {
+            mustList.add( mandatoryAttributes_table.getItem( i ).getText() );
+        }
+        objectClass.setMust( mustList.toArray( new String[0] ) );
+
+        // OPTIONNAL ATTRIBUTES
+        ArrayList<String> mayList = new ArrayList<String>();
+        for ( int i = 0; i < optionnalAttributes_table.getItemCount(); i++ )
+        {
+            mayList.add( optionnalAttributes_table.getItem( i ).getText() );
+        }
+        objectClass.setMay( mayList.toArray( new String[0] ) );
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditorSourceCodePage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditorSourceCodePage.java?view=auto&rev=475786
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditorSourceCodePage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditorSourceCodePage.java Thu Nov 16 08:05:20 2006
@@ -0,0 +1,99 @@
+/*
+ *  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.ObjectClass;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+
+
+/**
+ * This class is the Source Code Page of the Object Class Editor
+ */
+public class ObjectClassFormEditorSourceCodePage extends FormPage
+{
+    private ObjectClass objectClass;
+    private Text sourceCode_text;
+
+
+    /**
+     * Default constructor
+     * @param editor
+     * @param id
+     * @param title
+     */
+    public ObjectClassFormEditorSourceCodePage( FormEditor editor, String id, String title )
+    {
+        super( editor, id, title );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.forms.editor.FormPage#createFormContent(org.eclipse.ui.forms.IManagedForm)
+     */
+    protected void createFormContent( IManagedForm managedForm )
+    {
+        ScrolledForm form = managedForm.getForm();
+        FormToolkit toolkit = managedForm.getToolkit();
+        GridLayout layout = new GridLayout();
+        form.getBody().setLayout( layout );
+        toolkit.paintBordersFor( form.getBody() );
+
+        // Getting the input and the objectClass
+        ObjectClassFormEditorInput input = ( ObjectClassFormEditorInput ) getEditorInput();
+        objectClass = ( ObjectClass ) input.getObjectClass();
+
+        // SOURCE CODE Field
+        sourceCode_text = toolkit.createText( form.getBody(), "", SWT.MULTI ); //$NON-NLS-1$
+        sourceCode_text.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
+        sourceCode_text.setEditable( false );
+
+        // Initialization from the "input" object class
+        initFieldsContentFromInput();
+    }
+
+
+    private void initFieldsContentFromInput()
+    {
+        // SOURCE CODE Field
+        sourceCode_text.setText( objectClass.write() );
+    }
+
+
+    /**
+     * Refreshes the source code field
+     */
+    public void refresh()
+    {
+        if ( sourceCode_text != null )
+        {
+            initFieldsContentFromInput();
+        }
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/SchemaFormEditor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/SchemaFormEditor.java?view=auto&rev=475786
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/SchemaFormEditor.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/SchemaFormEditor.java Thu Nov 16 08:05:20 2006
@@ -0,0 +1,111 @@
+/*
+ *  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.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 Schema Editor main class
+ */
+public class SchemaFormEditor extends FormEditor
+{
+    private static Logger logger = Logger.getLogger( SchemaFormEditor.class );
+    public static final String ID = Application.PLUGIN_ID + ".view.schemaformeditor"; //$NON-NLS-1$
+    private SchemaFormEditorSourceCodePage sourceCode;
+
+
+    /**
+     * Default constructor
+     */
+    public SchemaFormEditor()
+    {
+        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() );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
+     */
+    @Override
+    protected void addPages()
+    {
+        try
+        {
+            sourceCode = new SchemaFormEditorSourceCodePage( this,
+                "sourceCode", Messages.getString( "SchemaFormEditor.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 )
+    {
+        // There's nothing to save
+    }
+
+
+    /* (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;
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/SchemaFormEditorInput.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/SchemaFormEditorInput.java?view=auto&rev=475786
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/SchemaFormEditorInput.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/SchemaFormEditorInput.java Thu Nov 16 08:05:20 2006
@@ -0,0 +1,125 @@
+/*
+ *  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.Schema;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPersistableElement;
+
+
+/**
+ * This class is the Input class for the Schema Editor
+ */
+public class SchemaFormEditorInput implements IEditorInput
+{
+    private Schema schema;
+
+
+    /**
+     * Default constructor
+     * @param schema
+     */
+    public SchemaFormEditorInput( Schema schema )
+    {
+        super();
+        this.schema = schema;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IEditorInput#exists()
+     */
+    public boolean exists()
+    {
+        return ( this.schema == null );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        return null;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IEditorInput#getName()
+     */
+    public String getName()
+    {
+        return this.schema.getName();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IEditorInput#getPersistable()
+     */
+    public IPersistableElement getPersistable()
+    {
+        return null;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IEditorInput#getToolTipText()
+     */
+    public String getToolTipText()
+    {
+        return Messages.getString( "SchemaFormEditorInput.Source_code_of" ) + this.schema.getName(); //$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 SchemaFormEditorInput ) )
+            return false;
+        SchemaFormEditorInput other = ( SchemaFormEditorInput ) obj;
+        return other.getSchema().getName().equals( this.schema.getName() );
+    }
+
+
+    /**
+     * Returns the input schema
+     * @return the input schema
+     */
+    public Schema getSchema()
+    {
+        return this.schema;
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/SchemaFormEditorSourceCodePage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/SchemaFormEditorSourceCodePage.java?view=auto&rev=475786
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/SchemaFormEditorSourceCodePage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/SchemaFormEditorSourceCodePage.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.view.editors;
+
+
+import org.apache.directory.ldapstudio.schemas.model.AttributeType;
+import org.apache.directory.ldapstudio.schemas.model.ObjectClass;
+import org.apache.directory.ldapstudio.schemas.model.Schema;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+
+
+/**
+ * This class is the Source Code Page of the Schema Editor
+ */
+public class SchemaFormEditorSourceCodePage extends FormPage
+{
+    private Schema schema;
+    private Text sourceCode_text;
+
+
+    /**
+     * Default constructor
+     * @param editor
+     * @param id
+     * @param title
+     */
+    public SchemaFormEditorSourceCodePage( FormEditor editor, String id, String title )
+    {
+        super( editor, id, title );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.forms.editor.FormPage#createFormContent(org.eclipse.ui.forms.IManagedForm)
+     */
+    protected void createFormContent( IManagedForm managedForm )
+    {
+        ScrolledForm form = managedForm.getForm();
+        FormToolkit toolkit = managedForm.getToolkit();
+        GridLayout layout = new GridLayout();
+        form.getBody().setLayout( layout );
+        toolkit.paintBordersFor( form.getBody() );
+
+        // Getting the input and the objectClass
+        SchemaFormEditorInput input = ( SchemaFormEditorInput ) getEditorInput();
+        schema = ( Schema ) input.getSchema();
+
+        // SOURCE CODE Field
+        sourceCode_text = toolkit.createText( form.getBody(), "", SWT.MULTI ); //$NON-NLS-1$
+        sourceCode_text.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
+        sourceCode_text.setEditable( false );
+
+        // Initialization from the "input" object class
+        initFieldsContentFromInput();
+    }
+
+
+    private void initFieldsContentFromInput()
+    {
+        // SOURCE CODE Field
+        AttributeType[] attributeTypes = schema.getAttributeTypesAsArray();
+        ObjectClass[] objectClasses = schema.getObjectClassesAsArray();
+
+        StringBuffer sb = new StringBuffer();
+
+        if ( attributeTypes.length != 0 )
+        {
+            for ( int i = 0; i < attributeTypes.length; i++ )
+            {
+                AttributeType attributeType = attributeTypes[i];
+                sb.append( attributeType.write() );
+                sb.append( "\n" ); //$NON-NLS-1$
+            }
+        }
+        if ( objectClasses.length != 0 )
+        {
+            for ( int i = 0; i < objectClasses.length; i++ )
+            {
+                ObjectClass objectClass = objectClasses[i];
+                sb.append( objectClass.write() );
+                sb.append( "\n" ); //$NON-NLS-1$
+            }
+        }
+        sourceCode_text.setText( sb.toString() );
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/perspectives/StandardPerspective.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/perspectives/StandardPerspective.java?view=auto&rev=475786
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/perspectives/StandardPerspective.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/perspectives/StandardPerspective.java Thu Nov 16 08:05:20 2006
@@ -0,0 +1,59 @@
+/*
+ *  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.perspectives;
+
+
+import org.apache.directory.ldapstudio.schemas.controller.Application;
+import org.apache.directory.ldapstudio.schemas.view.viewers.HierarchicalViewer;
+import org.apache.directory.ldapstudio.schemas.view.viewers.PoolManager;
+import org.apache.directory.ldapstudio.schemas.view.viewers.SearchViewer;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+
+
+/**
+ * This is the standard perspective with hierarchical viewer on the top left, pool manager on bottom left,
+ * editor in top right, search field on bottom right.
+ *
+ */
+public class StandardPerspective implements IPerspectiveFactory
+{
+    public static final String ID = Application.PLUGIN_ID + ".perspective"; //$NON-NLS-1$
+
+
+    public void createInitialLayout( IPageLayout layout )
+    {
+        String editorArea = layout.getEditorArea();
+        layout.setEditorAreaVisible( true );
+
+        layout.addStandaloneView( HierarchicalViewer.ID, true, IPageLayout.LEFT, 0.3f, editorArea );
+        layout.getViewLayout( HierarchicalViewer.ID ).setCloseable( false );
+
+        layout.addStandaloneView( PoolManager.ID, true, IPageLayout.BOTTOM, 0.5f, HierarchicalViewer.ID );
+        layout.getViewLayout( PoolManager.ID ).setCloseable( false );
+
+        layout.addStandaloneView( SearchViewer.ID, true, IPageLayout.BOTTOM, 0.7f, editorArea );
+        layout.getViewLayout( SearchViewer.ID ).setCloseable( false );
+
+        layout.addPerspectiveShortcut( StandardPerspective.ID );
+        //layout.addPerspectiveShortcut(TreePerspective.ID);	
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/perspectives/TreePerspective.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/perspectives/TreePerspective.java?view=auto&rev=475786
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/perspectives/TreePerspective.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/perspectives/TreePerspective.java Thu Nov 16 08:05:20 2006
@@ -0,0 +1,49 @@
+/*
+ *  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.perspectives;
+
+
+import org.apache.directory.ldapstudio.schemas.controller.Application;
+import org.apache.directory.ldapstudio.schemas.view.viewers.HierarchicalViewer;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+
+
+/**
+ * Shows only the tree view
+ * WARNING: This is a test perspective
+ *
+ */
+public class TreePerspective implements IPerspectiveFactory
+{
+
+    public static final String ID = Application.PLUGIN_ID + ".treeperspective"; //$NON-NLS-1$
+
+
+    public void createInitialLayout( IPageLayout layout )
+    {
+        String editorArea = layout.getEditorArea();
+        layout.setEditorAreaVisible( false );
+
+        layout.addStandaloneView( HierarchicalViewer.ID, true, IPageLayout.LEFT, 1f, editorArea );
+        layout.getViewLayout( HierarchicalViewer.ID ).setCloseable( false );
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/preferences/GeneralPreferencePage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/preferences/GeneralPreferencePage.java?view=auto&rev=475786
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/preferences/GeneralPreferencePage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/preferences/GeneralPreferencePage.java Thu Nov 16 08:05:20 2006
@@ -0,0 +1,93 @@
+/*
+ *  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.preferences;
+
+
+import java.io.IOException;
+
+import org.apache.directory.ldapstudio.schemas.controller.Application;
+import org.eclipse.core.runtime.preferences.ConfigurationScope;
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
+
+
+/**
+ * General Preference Page (actually contains everything related to object classes
+ * and attribute types).
+ * From there you can configure the company OID and auto-prefix settings.
+ *
+ */
+public class GeneralPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage
+{
+
+    public static final String COMPANY_OID = "prefs_company_oid"; //$NON-NLS-1$
+    public static final String AUTO_OID = "prefs_auto_oid"; //$NON-NLS-1$
+
+    private ScopedPreferenceStore preferences;
+
+
+    public GeneralPreferencePage()
+    {
+        super( GRID );
+        preferences = new ScopedPreferenceStore( new ConfigurationScope(), Application.PLUGIN_ID );
+        setPreferenceStore( preferences );
+    }
+
+
+    public void init( IWorkbench workbench )
+    {
+    }
+
+
+    @Override
+    protected void createFieldEditors()
+    {
+
+        StringFieldEditor oidEditor = new StringFieldEditor( COMPANY_OID, Messages
+            .getString( "GeneralPreferencePage.Your_organizations_default_OID" ), //$NON-NLS-1$
+            getFieldEditorParent() );
+
+        addField( oidEditor );
+
+        BooleanFieldEditor autoOidEditor = new BooleanFieldEditor( AUTO_OID, Messages
+            .getString( "GeneralPreferencePage.Automatically_prefix_new_elements_with_this_OID" ), //$NON-NLS-1$
+            getFieldEditorParent() );
+
+        addField( autoOidEditor );
+    }
+
+
+    public boolean performOk()
+    {
+        try
+        {
+            preferences.save();
+        }
+        catch ( IOException e )
+        {
+        }
+        return super.performOk();
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/preferences/Messages.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/preferences/Messages.java?view=auto&rev=475786
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/preferences/Messages.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/preferences/Messages.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.preferences;
+
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+
+public class Messages
+{
+    private static final String BUNDLE_NAME = "org.apache.directory.ldapstudio.schemas.view.preferences.messages"; //$NON-NLS-1$
+
+    private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
+
+
+    private Messages()
+    {
+    }
+
+
+    public static String getString( String key )
+    {
+        try
+        {
+            return RESOURCE_BUNDLE.getString( key );
+        }
+        catch ( MissingResourceException e )
+        {
+            return '!' + key + '!';
+        }
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/preferences/SchemaPreferencePage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/preferences/SchemaPreferencePage.java?view=auto&rev=475786
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/preferences/SchemaPreferencePage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/preferences/SchemaPreferencePage.java Thu Nov 16 08:05:20 2006
@@ -0,0 +1,108 @@
+/*
+ *  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.preferences;
+
+
+import java.io.IOException;
+
+import org.apache.directory.ldapstudio.schemas.controller.Application;
+import org.eclipse.core.runtime.preferences.ConfigurationScope;
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.DirectoryFieldEditor;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
+
+
+/**
+ * Schema Preference Page.
+ * From there you can access schema related preferences.
+ *
+ */
+public class SchemaPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage
+{
+
+    public static final String DEFAULT_DIRECTORY = "prefs_default_directory"; //$NON-NLS-1$
+    public static final String SAVE_WORKSPACE = "prefs_save_workspace"; //$NON-NLS-1$
+    public static final String SPECIFIC_CORE = "prefs_specific_core"; //$NON-NLS-1$
+    public static final String SPECIFIC_CORE_DIRECTORY = "prefs_specific_core_directory"; //$NON-NLS-1$
+
+    private ScopedPreferenceStore preferences;
+
+
+    public SchemaPreferencePage()
+    {
+        super( GRID );
+        preferences = new ScopedPreferenceStore( new ConfigurationScope(), Application.PLUGIN_ID );
+        setPreferenceStore( preferences );
+    }
+
+
+    public void init( IWorkbench workbench )
+    {
+        // TODO Auto-generated method stub
+
+    }
+
+
+    @Override
+    protected void createFieldEditors()
+    {
+
+        DirectoryFieldEditor directoryEditor = new DirectoryFieldEditor( DEFAULT_DIRECTORY, Messages
+            .getString( "SchemaPreferencePage.Default_save-load_dialogs_directory" ), //$NON-NLS-1$
+            getFieldEditorParent() );
+
+        addField( directoryEditor );
+
+        BooleanFieldEditor saveWorkspaceEditor = new BooleanFieldEditor( SAVE_WORKSPACE, Messages
+            .getString( "SchemaPreferencePage.Save_schemas_configuration_when_exiting_LDAP_Studio" ), //$NON-NLS-1$
+            getFieldEditorParent() );
+
+        addField( saveWorkspaceEditor );
+
+        BooleanFieldEditor specificCore = new BooleanFieldEditor( SPECIFIC_CORE, Messages
+            .getString( "SchemaPreferencePage.Use_specific_core_files" ), //$NON-NLS-1$
+            getFieldEditorParent() );
+
+        addField( specificCore );
+
+        DirectoryFieldEditor coreDirectoryEditor = new DirectoryFieldEditor( SPECIFIC_CORE_DIRECTORY, Messages
+            .getString( "SchemaPreferencePage.Core_schemas_directory" ), //$NON-NLS-1$
+            getFieldEditorParent() );
+
+        addField( coreDirectoryEditor );
+    }
+
+
+    public boolean performOk()
+    {
+        try
+        {
+            preferences.save();
+        }
+        catch ( IOException e )
+        {
+        }
+        return super.performOk();
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchicalContentProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchicalContentProvider.java?view=auto&rev=475786
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchicalContentProvider.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchicalContentProvider.java Thu Nov 16 08:05:20 2006
@@ -0,0 +1,327 @@
+/*
+ *  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.viewers;
+
+
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.Hashtable;
+import java.util.Iterator;
+
+import org.apache.directory.ldapstudio.schemas.model.AttributeType;
+import org.apache.directory.ldapstudio.schemas.model.ObjectClass;
+import org.apache.directory.ldapstudio.schemas.model.SchemaPool;
+import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.AlphabeticalOrderComparator;
+import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.AttributeTypeWrapper;
+import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.IntermediateNode;
+import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.ObjectClassWrapper;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+
+
+public class HierarchicalContentProvider implements SortableContentProvider, IStructuredContentProvider,
+    ITreeContentProvider
+{
+    private SchemaPool schemaPool;
+    private Hashtable<String, ObjectClass> objectClassTable;
+    private Hashtable<String, AttributeType> attributeTypeTable;
+    private Comparator order = new AlphabeticalOrderComparator();
+
+
+    public HierarchicalContentProvider( SchemaPool schemaPool )
+    {
+        this.schemaPool = schemaPool;
+
+        objectClassTable = schemaPool.getObjectClassesAsHashTableByName();
+
+        attributeTypeTable = schemaPool.getAttributeTypesAsHashTableByName();
+    }
+
+
+    /******************************************
+     *       Interfaces Implementation        *
+     ******************************************/
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+     */
+    public Object[] getElements( Object inputElement )
+    {
+        return getChildren( inputElement );
+    }
+
+
+    /**
+     * Disposes of this content provider. This is called by the viewer when it is disposed.
+     */
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+     */
+    public void dispose()
+    {
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+     */
+    public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
+    {
+    }
+
+
+    /******************************************
+     *       ITreeContentProvider Impl        *
+     ******************************************/
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
+     */
+    public Object[] getChildren( Object parentElement )
+    {
+
+        if ( parentElement instanceof ObjectClassWrapper )
+        {
+            //we are looking for the childrens of the contained objectClass
+            ObjectClass objectClass = ( ObjectClass ) ( ( ( ObjectClassWrapper ) parentElement ).getMyObjectClass() );
+
+            IntermediateNode sub = new IntermediateNode( "Sub-types", ( ObjectClassWrapper ) parentElement, this ); //$NON-NLS-1$
+            IntermediateNode may = new IntermediateNode(
+                "Optionnal Attributes", ( ObjectClassWrapper ) parentElement, this ); //$NON-NLS-1$
+            IntermediateNode must = new IntermediateNode(
+                "Mandatory Attributes", ( ObjectClassWrapper ) parentElement, this ); //$NON-NLS-1$
+
+            //-> we need to compare each and every other objectClass's sup against them 
+            //-> we also need to find a better way to do this (complexity wise)
+
+            Collection<ObjectClass> objectClasses = objectClassTable.values();
+            for ( Iterator iter = objectClasses.iterator(); iter.hasNext(); )
+            {
+                ObjectClass oClass = ( ObjectClass ) iter.next();
+
+                //not this object class
+                if ( oClass.getOid() != objectClass.getOid() )
+                {
+                    String[] sups = oClass.getSuperiors();
+                    for ( String sup : sups )
+                    {
+                        ObjectClass oClassSup = objectClassTable.get( sup );
+                        if ( oClassSup != null )
+                        {
+                            //the current object class is a sup of oClass
+                            if ( oClassSup.equals( objectClass ) )
+                            {
+                                //we use an objectClass wrapper
+                                sub.addElement( new ObjectClassWrapper( oClass, sub ) );
+                                break; //break only the inner for
+                            }
+                        }
+                    }
+                }
+            }
+
+            //complete optionnal attributes
+            String[] optAttributes = objectClass.getMay();
+            for ( String name : optAttributes )
+            {
+                AttributeType attr = attributeTypeTable.get( name );
+                //A CHANGER, ON FAIT SAUTER LES ATTR QUI NE SONT PAS DEFINIS
+                //DANS LE SCHEMA COURANT (ATTRS PAR DEFAUT)
+                if ( attr == null )
+                    continue;
+                //we use an attribute-type wrapper
+                may.addElement( new AttributeTypeWrapper( attr, may ) );
+            }
+
+            //complete mandatory attributes
+            String[] mandAttributes = objectClass.getMust();
+            for ( String name : mandAttributes )
+            {
+                AttributeType attr = attributeTypeTable.get( name );
+                //A CHANGER, ON FAIT SAUTER LES ATTR QUI NE SONT PAS DEFINIS
+                //DANS LE SCHEMA COURANT (ATTRS PAR DEFAUT)
+                if ( attr == null )
+                    continue;
+
+                //we use an attribute-type wrapper
+                must.addElement( new AttributeTypeWrapper( attr, must ) );
+            }
+
+            return new Object[]
+                { sub, may, must };
+        }
+
+        else if ( parentElement instanceof IntermediateNode )
+        {
+            IntermediateNode intermediate = ( IntermediateNode ) parentElement;
+
+            if ( intermediate.getName().equals( "**Primary Node**" ) ) { //$NON-NLS-1$
+                //if we are asked for the primary node it's because the whole viewer
+                //is beeing refreshed 
+                // -> the pool has been modified or it's the first display
+                // -> we need to regenerate the hashmaps containing the schemas elements
+                refresh();
+
+                //clear the primary node (because it's always the same instance we need to
+                //refresh it manually)
+                intermediate.clearChildrens();
+
+                //bootstrap the tree exploring process by adding the top node into the tree
+                ObjectClass top = schemaPool.getObjectClass( "top" ); //$NON-NLS-1$
+                if ( top != null )
+                {
+                    ObjectClassWrapper topWrapper = new ObjectClassWrapper( top, intermediate );
+                    intermediate.addElement( topWrapper );
+                }
+
+                //add the unresolved object-classes to the top of the hierarchy
+                Collection<ObjectClass> objectClasses = objectClassTable.values();
+                for ( Iterator iter = objectClasses.iterator(); iter.hasNext(); )
+                {
+                    ObjectClass oClass = ( ObjectClass ) iter.next();
+                    String[] sups = oClass.getSuperiors();
+                    //if no supperiors had been set
+                    if ( sups.length == 0 )
+                    {
+                        ObjectClassWrapper wrapper = new ObjectClassWrapper( oClass, intermediate );
+                        wrapper.setState( ObjectClassWrapper.State.unResolved );
+                        intermediate.addElement( wrapper );
+                    }
+                    else
+                    {
+                        for ( String sup : sups )
+                        {
+                            ObjectClass oClassSup = objectClassTable.get( sup );
+                            if ( oClassSup == null )
+                            {
+                                ObjectClassWrapper wrapper = new ObjectClassWrapper( oClass, intermediate );
+                                wrapper.setState( ObjectClassWrapper.State.unResolved );
+                                intermediate.addElement( wrapper );
+                            }
+                        }
+                    }
+                }
+            }
+
+            return intermediate.getChildren();
+        }
+        return new Object[0];
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
+     */
+    public Object getParent( Object element )
+    {
+        if ( element instanceof ObjectClassWrapper )
+        {
+            return ( ( ObjectClassWrapper ) element ).getParent();
+        }
+        else if ( element instanceof AttributeTypeWrapper )
+        {
+            return ( ( AttributeTypeWrapper ) element ).getParent();
+        }
+        else if ( element instanceof IntermediateNode )
+        {
+            return ( ( IntermediateNode ) element ).getParent();
+        }
+
+        return null;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
+     */
+    public boolean hasChildren( Object element )
+    {
+        if ( element instanceof ObjectClassWrapper )
+        {
+            return true;
+        }
+        else if ( element instanceof AttributeTypeWrapper )
+        {
+            return false;
+        }
+        else if ( element instanceof IntermediateNode )
+        {
+            if ( ( ( IntermediateNode ) element ).getChildren().length > 0 )
+                return true;
+        }
+
+        return false;
+    }
+
+
+    /******************************************
+     *             Internal Logic             *
+     ******************************************/
+
+    private void refresh()
+    {
+        objectClassTable = schemaPool.getObjectClassesAsHashTableByName();
+
+        attributeTypeTable = schemaPool.getAttributeTypesAsHashTableByName();
+    }
+
+
+    /******************************************
+     *                 Logic                  *
+     ******************************************/
+
+    /**
+     * Specify the comparator that will be used to sort the elements in the view
+     * @param order the comparator
+     */
+    public void setOrder( Comparator order )
+    {
+        this.order = order;
+    }
+
+
+    /**
+     * Returns the comparator used to sort the elements in the view
+     * @return
+     */
+    public Comparator getOrder()
+    {
+        return order;
+    }
+
+
+    /**
+     * Initialize a tree viewer to display the information provided by the specified content
+     * provider
+     * @param viewer the tree viewer
+     */
+    public void bindToTreeViewer( TreeViewer viewer )
+    {
+        viewer.setContentProvider( this );
+        viewer.setLabelProvider( new HierarchicalLabelProvider() );
+
+        IntermediateNode invisibleNode = new IntermediateNode( "**Primary Node**", null, this ); //$NON-NLS-1$
+        viewer.setInput( invisibleNode );
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchicalLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchicalLabelProvider.java?view=auto&rev=475786
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchicalLabelProvider.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchicalLabelProvider.java Thu Nov 16 08:05:20 2006
@@ -0,0 +1,63 @@
+/*
+ *  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.viewers;
+
+
+import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.DisplayableTreeElement;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * Eclipse RPC programming pattern for tree-viewers
+ *
+ */
+public class HierarchicalLabelProvider extends LabelProvider
+{
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
+     */
+    public String getText( Object obj )
+    {
+        if ( obj instanceof DisplayableTreeElement )
+            return ( ( DisplayableTreeElement ) obj ).getDisplayName();
+
+        //default
+        return obj.toString();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
+     */
+    public Image getImage( Object obj )
+    {
+        if ( obj instanceof DisplayableTreeElement )
+            return ( ( DisplayableTreeElement ) obj ).getDisplayImage();
+
+        //default
+        return PlatformUI.getWorkbench().getSharedImages().getImage( ISharedImages.IMG_OBJS_WARN_TSK );
+
+    }
+}