directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r592094 [26/35] - in /directory/sandbox/felixk/studio-schemaeditor: ./ META-INF/ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/directory/ src/main/java/org/apache/directory/studio/ src/m...
Date Mon, 05 Nov 2007 17:15:02 GMT
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeMatchingRulesWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeMatchingRulesWizardPage.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeMatchingRulesWizardPage.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeMatchingRulesWizardPage.java Mon Nov  5 09:14:24 2007
@@ -0,0 +1,311 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.schemaeditor.view.wizards;
+
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.apache.directory.studio.schemaeditor.controller.SchemaHandler;
+import org.apache.directory.studio.schemaeditor.model.MatchingRuleImpl;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class represents the Matching Rules WizardPage of the NewAttributeTypeWizard.
+ * <p>
+ * It is used to let the user enter matching rules information about the
+ * attribute type he wants to create (equality, ordering, substring).
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NewAttributeTypeMatchingRulesWizardPage extends WizardPage
+{
+    /** The SchemaHandler */
+    private SchemaHandler schemaHandler;
+
+    /** The LabelProvider */
+    private LabelProvider labelProvider = new LabelProvider()
+    {
+        /* (non-Javadoc)
+         * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
+         */
+        public String getText( Object element )
+        {
+            if ( element instanceof MatchingRuleImpl )
+            {
+                MatchingRuleImpl mr = ( MatchingRuleImpl ) element;
+
+                String name = mr.getName();
+                if ( name != null )
+                {
+                    return name + "  -  (" + mr.getOid() + ")";
+                }
+                else
+                {
+                    return "(None)  -  (" + mr.getOid() + ")";
+                }
+            }
+
+            return super.getText( element );
+        }
+    };
+
+    // UI fields
+    private ComboViewer equalityComboViewer;
+    private ComboViewer orderingComboViewer;
+    private ComboViewer substringComboViewer;
+
+
+    /**
+     * Creates a new instance of NewAttributeTypeMatchingRulesWizardPage.
+     */
+    public NewAttributeTypeMatchingRulesWizardPage()
+    {
+        super( "NewAttributeTypeMatchingRulesWizardPage" );
+        setTitle( "Matching Rules" );
+        setDescription( "Please specify the matching rules (equality, ordering and substring) to use for the attribute type." );
+        setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+            PluginConstants.IMG_ATTRIBUTE_TYPE_NEW_WIZARD ) );
+
+        schemaHandler = Activator.getDefault().getSchemaHandler();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+     */
+    public void createControl( Composite parent )
+    {
+        Composite composite = new Composite( parent, SWT.NULL );
+        GridLayout layout = new GridLayout();
+        composite.setLayout( layout );
+
+        // Matching Rules Group
+        Group matchingRulesGroup = new Group( composite, SWT.NONE );
+        matchingRulesGroup.setText( "Matching Rules" );
+        matchingRulesGroup.setLayout( new GridLayout( 2, false ) );
+        matchingRulesGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 3, 1 ) );
+
+        // Equality
+        Label equalityLabel = new Label( matchingRulesGroup, SWT.NONE );
+        equalityLabel.setText( "Equality:" );
+        Combo equalityCombo = new Combo( matchingRulesGroup, SWT.READ_ONLY );
+        equalityCombo.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+        equalityComboViewer = new ComboViewer( equalityCombo );
+        equalityComboViewer.setContentProvider( new ArrayContentProvider() );
+        equalityComboViewer.setLabelProvider( labelProvider );
+
+        // Ordering
+        Label orderingLabel = new Label( matchingRulesGroup, SWT.NONE );
+        orderingLabel.setText( "Ordering:" );
+        Combo orderingCombo = new Combo( matchingRulesGroup, SWT.READ_ONLY );
+        orderingCombo.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+        orderingComboViewer = new ComboViewer( orderingCombo );
+        orderingComboViewer.setContentProvider( new ArrayContentProvider() );
+        orderingComboViewer.setLabelProvider( labelProvider );
+
+        // Substring
+        Label substringLabel = new Label( matchingRulesGroup, SWT.NONE );
+        substringLabel.setText( "Substring:" );
+        Combo substringCombo = new Combo( matchingRulesGroup, SWT.READ_ONLY );
+        substringCombo.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+        substringComboViewer = new ComboViewer( substringCombo );
+        substringComboViewer.setContentProvider( new ArrayContentProvider() );
+        substringComboViewer.setLabelProvider( labelProvider );
+
+        initFields();
+
+        setControl( composite );
+    }
+
+
+    /**
+     * Initializes the UI fields.
+     */
+    @SuppressWarnings("unchecked")
+    private void initFields()
+    {
+        if ( schemaHandler != null )
+        {
+            // Getting the matching rules
+            List<Object> matchingRules = new ArrayList( schemaHandler.getMatchingRules() );
+            // Adding the (None) matching rule
+            String none = "(None)";
+            matchingRules.add( none );
+
+            // Sorting the matching rules
+            Collections.sort( matchingRules, new Comparator<Object>()
+            {
+
+                public int compare( Object o1, Object o2 )
+                {
+                    if ( ( o1 instanceof MatchingRuleImpl ) && ( o2 instanceof MatchingRuleImpl ) )
+                    {
+                        String[] o1Names = ( ( MatchingRuleImpl ) o1 ).getNames();
+                        String[] o2Names = ( ( MatchingRuleImpl ) o2 ).getNames();
+
+                        // Comparing the First Name
+                        if ( ( o1Names != null ) && ( o2Names != null ) )
+                        {
+                            if ( ( o1Names.length > 0 ) && ( o2Names.length > 0 ) )
+                            {
+                                return o1Names[0].compareToIgnoreCase( o2Names[0] );
+                            }
+                            else if ( ( o1Names.length == 0 ) && ( o2Names.length > 0 ) )
+                            {
+                                return "".compareToIgnoreCase( o2Names[0] );
+                            }
+                            else if ( ( o1Names.length > 0 ) && ( o2Names.length == 0 ) )
+                            {
+                                return o1Names[0].compareToIgnoreCase( "" );
+                            }
+                        }
+                        else if ( ( o1 instanceof String ) && ( o2 instanceof MatchingRuleImpl ) )
+                        {
+                            return Integer.MIN_VALUE;
+                        }
+                        else if ( ( o1 instanceof MatchingRuleImpl ) && ( o2 instanceof String ) )
+                        {
+                            return Integer.MAX_VALUE;
+                        }
+                    }
+
+                    // Default
+                    return o1.toString().compareToIgnoreCase( o2.toString() );
+                }
+            } );
+
+            // Setting the input
+            equalityComboViewer.setInput( matchingRules );
+            orderingComboViewer.setInput( matchingRules );
+            substringComboViewer.setInput( matchingRules );
+
+            // Selecting the None matching rules
+            equalityComboViewer.setSelection( new StructuredSelection( none ) );
+            orderingComboViewer.setSelection( new StructuredSelection( none ) );
+            substringComboViewer.setSelection( new StructuredSelection( none ) );
+        }
+    }
+
+
+    /**
+     * Gets the value of the equality matching rule.
+     *
+     * @return
+     *      the value of the equality matching rule
+     */
+    public String getEqualityMatchingRuleValue()
+    {
+        Object selection = ( ( StructuredSelection ) equalityComboViewer.getSelection() ).getFirstElement();
+
+        if ( selection instanceof MatchingRuleImpl )
+        {
+            MatchingRuleImpl mr = ( ( MatchingRuleImpl ) selection );
+
+            String[] names = mr.getNames();
+            if ( ( names != null ) && ( names.length > 0 ) )
+            {
+                return mr.getName();
+            }
+            else
+            {
+                return mr.getOid();
+            }
+        }
+
+        return null;
+    }
+
+
+    /**
+     * Gets the value of the ordering matching rule.
+     *
+     * @return
+     *      the value of the ordering matching rule
+     */
+    public String getOrderingMatchingRuleValue()
+    {
+        Object selection = ( ( StructuredSelection ) orderingComboViewer.getSelection() ).getFirstElement();
+
+        if ( selection instanceof MatchingRuleImpl )
+        {
+            MatchingRuleImpl mr = ( ( MatchingRuleImpl ) selection );
+
+            String[] names = mr.getNames();
+            if ( ( names != null ) && ( names.length > 0 ) )
+            {
+                return mr.getName();
+            }
+            else
+            {
+                return mr.getOid();
+            }
+        }
+
+        return null;
+    }
+
+
+    /**
+     * Gets the value of the substring matching rule.
+     *
+     * @return
+     *      the value of the substring matching rule
+     */
+    public String getSubstringMatchingRuleValue()
+    {
+        Object selection = ( ( StructuredSelection ) substringComboViewer.getSelection() ).getFirstElement();
+
+        if ( selection instanceof MatchingRuleImpl )
+        {
+            MatchingRuleImpl mr = ( ( MatchingRuleImpl ) selection );
+
+            String[] names = mr.getNames();
+            if ( ( names != null ) && ( names.length > 0 ) )
+            {
+                return mr.getName();
+            }
+            else
+            {
+                return mr.getOid();
+            }
+        }
+
+        return null;
+    }
+}

Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeMatchingRulesWizardPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeWizard.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeWizard.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeWizard.java Mon Nov  5 09:14:24 2007
@@ -0,0 +1,115 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.schemaeditor.view.wizards;
+
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.schemaeditor.model.Schema;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+
+/**
+ * This class represents the wizard to create a new AttributeType.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NewAttributeTypeWizard extends Wizard implements INewWizard
+{
+    public static final String ID = Activator.PLUGIN_ID + ".wizards.NewAttributeTypeWizard";
+
+    /** The selected schema */
+    private Schema selectedSchema;
+
+    // The pages of the wizards
+    private NewAttributeTypeGeneralWizardPage generalPage;
+    private NewAttributeTypeContentWizardPage contentPage;
+    private NewAttributeTypeMatchingRulesWizardPage matchingRulesPage;
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.wizard.Wizard#addPages()
+     */
+    public void addPages()
+    {
+        // Creating pages
+        generalPage = new NewAttributeTypeGeneralWizardPage();
+        generalPage.setSelectedSchema( selectedSchema );
+        contentPage = new NewAttributeTypeContentWizardPage();
+        matchingRulesPage = new NewAttributeTypeMatchingRulesWizardPage();
+
+        // Adding pages
+        addPage( generalPage );
+        addPage( contentPage );
+        addPage( matchingRulesPage );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.wizard.Wizard#performFinish()
+     */
+    public boolean performFinish()
+    {
+        AttributeTypeImpl newAT = new AttributeTypeImpl( generalPage.getOidValue() );
+        newAT.setSchema( generalPage.getSchemaValue() );
+        newAT.setNames( generalPage.getAliasesValue() );
+        newAT.setDescription( generalPage.getDescriptionValue() );
+        newAT.setSuperiorName( contentPage.getSuperiorValue() );
+        newAT.setUsage( contentPage.getUsageValue() );
+        newAT.setSyntaxOid( contentPage.getSyntax() );
+        newAT.setLength( contentPage.getSyntaxLengthValue() );
+        newAT.setObsolete( contentPage.getObsoleteValue() );
+        newAT.setSingleValue( contentPage.getSingleValueValue() );
+        newAT.setCollective( contentPage.getCollectiveValue() );
+        newAT.setCanUserModify( !contentPage.getNoUserModificationValue() );
+        newAT.setEqualityName( matchingRulesPage.getEqualityMatchingRuleValue() );
+        newAT.setOrderingName( matchingRulesPage.getOrderingMatchingRuleValue() );
+        newAT.setSubstrName( matchingRulesPage.getSubstringMatchingRuleValue() );
+
+        Activator.getDefault().getSchemaHandler().addAttributeType( newAT );
+
+        return true;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+     */
+    public void init( IWorkbench workbench, IStructuredSelection selection )
+    {
+        // Nothing to do.
+    }
+
+
+    /**
+     * Sets the selected schema.
+     *
+     * @param schema
+     *      the selected schema
+     */
+    public void setSelectedSchema( Schema schema )
+    {
+        selectedSchema = schema;
+    }
+}

Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeWizard.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassContentWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassContentWizardPage.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassContentWizardPage.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassContentWizardPage.java Mon Nov  5 09:14:24 2007
@@ -0,0 +1,352 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.schemaeditor.view.wizards;
+
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.apache.directory.shared.ldap.schema.ObjectClassTypeEnum;
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.apache.directory.studio.schemaeditor.model.ObjectClassImpl;
+import org.apache.directory.studio.schemaeditor.view.ViewUtils;
+import org.apache.directory.studio.schemaeditor.view.dialogs.ObjectClassSelectionDialog;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class represents the Content WizardPage of the ObjectClassWizard.
+ * <p>
+ * It is used to let the user enter content information about the
+ * attribute type he wants to create (superiors, class type, and properties).
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NewObjectClassContentWizardPage extends WizardPage
+{
+    /** The superiors object classes */
+    private List<ObjectClassImpl> superiorsList;
+
+    /** The type of the object class */
+    private ObjectClassTypeEnum type = ObjectClassTypeEnum.STRUCTURAL;
+
+    // UI Fields
+    private TableViewer superiorsTableViewer;
+    private Button superiorsAddButton;
+    private Button superiorsRemoveButton;
+    private Button structuralRadio;
+    private Button abstractRadio;
+    private Button auxiliaryRadio;
+    private Button obsoleteCheckbox;
+
+
+    /**
+     * Creates a new instance of NewAttributeTypeContentWizardPage.
+     */
+    protected NewObjectClassContentWizardPage()
+    {
+        super( "NewObjectClassContentWizardPage" );
+        setTitle( "Object Class Content" );
+        setDescription( "Please enter the superiors, class type  and properties for the object class." );
+        setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+            PluginConstants.IMG_OBJECT_CLASS_NEW_WIZARD ) );
+        superiorsList = new ArrayList<ObjectClassImpl>();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+     */
+    public void createControl( Composite parent )
+    {
+        Composite composite = new Composite( parent, SWT.NULL );
+        GridLayout layout = new GridLayout();
+        composite.setLayout( layout );
+
+        // Superiors
+        Group superiorsGroup = new Group( composite, SWT.NONE );
+        superiorsGroup.setText( "Superiors" );
+        superiorsGroup.setLayout( new GridLayout( 2, false ) );
+        superiorsGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Superiors
+        Table superiorsTable = new Table( superiorsGroup, SWT.BORDER );
+        GridData superiorsTableGridData = new GridData( SWT.FILL, SWT.FILL, true, true, 1, 2 );
+        superiorsTableGridData.heightHint = 100;
+        superiorsTable.setLayoutData( superiorsTableGridData );
+        superiorsTableViewer = new TableViewer( superiorsTable );
+        superiorsTableViewer.setLabelProvider( new LabelProvider()
+        {
+            public Image getImage( Object element )
+            {
+                if ( element instanceof ObjectClassImpl )
+                {
+                    return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+                        PluginConstants.IMG_OBJECT_CLASS ).createImage();
+                }
+
+                // Default
+                return super.getImage( element );
+            }
+
+
+            public String getText( Object element )
+            {
+                if ( element instanceof ObjectClassImpl )
+                {
+                    ObjectClassImpl oc = ( ObjectClassImpl ) element;
+
+                    String[] names = oc.getNames();
+                    if ( ( names != null ) && ( names.length > 0 ) )
+                    {
+                        return ViewUtils.concateAliases( names ) + "  -  (" + oc.getOid() + ")";
+                    }
+                    else
+                    {
+                        return "(None)  -  (" + oc.getOid() + ")";
+                    }
+                }
+                // Default
+                return super.getText( element );
+            }
+        } );
+        superiorsTableViewer.setContentProvider( new ArrayContentProvider() );
+        superiorsTableViewer.setInput( superiorsList );
+        superiorsTableViewer.addSelectionChangedListener( new ISelectionChangedListener()
+        {
+            public void selectionChanged( SelectionChangedEvent event )
+            {
+                superiorsRemoveButton.setEnabled( !event.getSelection().isEmpty() );
+            }
+        } );
+        superiorsAddButton = new Button( superiorsGroup, SWT.PUSH );
+        superiorsAddButton.setText( "Add..." );
+        superiorsAddButton.setLayoutData( new GridData( SWT.FILL, SWT.NONE, false, false ) );
+        superiorsAddButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent arg0 )
+            {
+                addSuperiorObjectClass();
+            }
+        } );
+        superiorsRemoveButton = new Button( superiorsGroup, SWT.PUSH );
+        superiorsRemoveButton.setText( "Remove" );
+        superiorsRemoveButton.setLayoutData( new GridData( SWT.FILL, SWT.NONE, false, false ) );
+        superiorsRemoveButton.setEnabled( false );
+        superiorsRemoveButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent arg0 )
+            {
+                removeSuperiorObjectClass();
+            }
+        } );
+
+        // Class Type Group
+        Group classTypeGroup = new Group( composite, SWT.NONE );
+        classTypeGroup.setText( "Class Type" );
+        classTypeGroup.setLayout( new GridLayout( 5, false ) );
+        classTypeGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Class Type
+        Label classTypeLable = new Label( classTypeGroup, SWT.NONE );
+        classTypeLable.setText( "Class Type:" );
+        new Label( classTypeGroup, SWT.NONE ).setText( "          " );
+        structuralRadio = new Button( classTypeGroup, SWT.RADIO );
+        structuralRadio.setText( "Structural" );
+        GridData structuralRadioGridData = new GridData( SWT.LEFT, SWT.NONE, false, false );
+        structuralRadioGridData.widthHint = 115;
+        structuralRadio.setLayoutData( structuralRadioGridData );
+        structuralRadio.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent arg0 )
+            {
+                type = ObjectClassTypeEnum.STRUCTURAL;
+            }
+        } );
+        structuralRadio.setSelection( true );
+        abstractRadio = new Button( classTypeGroup, SWT.RADIO );
+        abstractRadio.setText( "Abstract" );
+        GridData abstractRadioGridData = new GridData( SWT.LEFT, SWT.NONE, false, false );
+        abstractRadioGridData.widthHint = 115;
+        abstractRadio.setLayoutData( structuralRadioGridData );
+        abstractRadio.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent arg0 )
+            {
+                type = ObjectClassTypeEnum.ABSTRACT;
+            }
+        } );
+        auxiliaryRadio = new Button( classTypeGroup, SWT.RADIO );
+        auxiliaryRadio.setText( "Auxiliary" );
+        GridData auxiliaryRadioGridData = new GridData( SWT.LEFT, SWT.NONE, false, false );
+        auxiliaryRadioGridData.widthHint = 115;
+        auxiliaryRadio.setLayoutData( structuralRadioGridData );
+        auxiliaryRadio.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent arg0 )
+            {
+                type = ObjectClassTypeEnum.AUXILIARY;
+            }
+        } );
+
+        // Properties Group
+        Group propertiesGroup = new Group( composite, SWT.NONE );
+        propertiesGroup.setText( "Properties" );
+        propertiesGroup.setLayout( new GridLayout() );
+        propertiesGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Obsolete
+        obsoleteCheckbox = new Button( propertiesGroup, SWT.CHECK );
+        obsoleteCheckbox.setText( "Obsolete" );
+
+        setControl( composite );
+    }
+
+
+    /**
+     * This method is called when the "Add" button of the superiors 
+     * table is selected.
+     */
+    private void addSuperiorObjectClass()
+    {
+        ObjectClassSelectionDialog dialog = new ObjectClassSelectionDialog();
+        dialog.setHiddenObjectClasses( superiorsList );
+        if ( dialog.open() == Dialog.OK )
+        {
+            superiorsList.add( dialog.getSelectedObjectClass() );
+            updateSuperiorsTable();
+        }
+    }
+
+
+    /**
+     * This method is called when the "Remove" button of the superiors 
+     * table is selected.
+     */
+    private void removeSuperiorObjectClass()
+    {
+        StructuredSelection selection = ( StructuredSelection ) superiorsTableViewer.getSelection();
+        if ( !selection.isEmpty() )
+        {
+            superiorsList.remove( selection.getFirstElement() );
+            updateSuperiorsTable();
+        }
+    }
+
+
+    /**
+     * Updates the superiors table
+     */
+    private void updateSuperiorsTable()
+    {
+        Collections.sort( superiorsList, new Comparator<ObjectClassImpl>()
+        {
+            public int compare( ObjectClassImpl o1, ObjectClassImpl o2 )
+            {
+                String[] at1Names = o1.getNames();
+                String[] at2Names = o2.getNames();
+
+                if ( ( at1Names != null ) && ( at2Names != null ) && ( at1Names.length > 0 ) && ( at2Names.length > 0 ) )
+                {
+                    return at1Names[0].compareToIgnoreCase( at2Names[0] );
+                }
+
+                // Default
+                return 0;
+            }
+        } );
+
+        superiorsTableViewer.refresh();
+    }
+
+
+    /**
+     * Gets the value of the superiors.
+     *
+     * @return
+     *      the value of the superiors
+     */
+    public String[] getSuperiorsNameValue()
+    {
+        List<String> names = new ArrayList<String>();
+        for ( ObjectClassImpl oc : superiorsList )
+        {
+            String[] aliases = oc.getNames();
+
+            if ( ( aliases != null ) && ( aliases.length > 0 ) )
+            {
+                names.add( aliases[0] );
+            }
+            else
+            {
+                names.add( oc.getOid() );
+            }
+        }
+
+        return names.toArray( new String[0] );
+    }
+
+
+    /**
+     * Gets the class type value.
+     *
+     * @return
+     *      the class type value
+     */
+    public ObjectClassTypeEnum getClassTypeValue()
+    {
+        return type;
+    }
+
+
+    /**
+     * Gets the 'Obsolete' value.
+     *
+     * @return
+     *      the 'Obsolete' value
+     */
+    public boolean getObsoleteValue()
+    {
+        return obsoleteCheckbox.getSelection();
+    }
+}

Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassContentWizardPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassGeneralPageWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassGeneralPageWizardPage.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassGeneralPageWizardPage.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassGeneralPageWizardPage.java Mon Nov  5 09:14:24 2007
@@ -0,0 +1,424 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.schemaeditor.view.wizards;
+
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.apache.directory.shared.asn1.primitives.OID;
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.apache.directory.studio.schemaeditor.controller.SchemaHandler;
+import org.apache.directory.studio.schemaeditor.model.Schema;
+import org.apache.directory.studio.schemaeditor.view.dialogs.EditAliasesDialog;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+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.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class represents the General WizardPage of the NewObjectClassWizard.
+ * <p>
+ * It is used to let the user enter general information about the
+ * attribute type he wants to create (schema, OID, aliases an description).
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NewObjectClassGeneralPageWizardPage extends WizardPage
+{
+    /** The SchemaHandler */
+    private SchemaHandler schemaHandler;
+
+    /** The aliases */
+    private String[] aliases;
+
+    /** The selected schema */
+    private Schema selectedSchema;
+
+    // UI fields
+    private ComboViewer schemaComboViewer;
+    private Text oidText;
+    private Text aliasesText;
+    private Button aliasesButton;
+    private Text descriptionText;
+
+
+    /**
+     * Creates a new instance of NewObjectClassGeneralPageWizardPage.
+     */
+    protected NewObjectClassGeneralPageWizardPage()
+    {
+        super( "NewObjectClassGeneralPageWizardPage" );
+        setTitle( "Object Class" );
+        setDescription( "Create a new object class." );
+        setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+            PluginConstants.IMG_OBJECT_CLASS_NEW_WIZARD ) );
+
+        schemaHandler = Activator.getDefault().getSchemaHandler();
+        aliases = new String[0];
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+     */
+    public void createControl( Composite parent )
+    {
+        Composite composite = new Composite( parent, SWT.NULL );
+        GridLayout layout = new GridLayout();
+        composite.setLayout( layout );
+
+        // Schema Group
+        Group schemaGroup = new Group( composite, SWT.NONE );
+        schemaGroup.setText( "Schema" );
+        schemaGroup.setLayout( new GridLayout( 2, false ) );
+        schemaGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Schema
+        Label schemaLabel = new Label( schemaGroup, SWT.NONE );
+        schemaLabel.setText( "Schema:" );
+        Combo schemaCombo = new Combo( schemaGroup, SWT.READ_ONLY );
+        schemaCombo.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+        schemaComboViewer = new ComboViewer( schemaCombo );
+        schemaComboViewer.setContentProvider( new ArrayContentProvider() );
+        schemaComboViewer.setLabelProvider( new LabelProvider()
+        {
+            /* (non-Javadoc)
+             * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
+             */
+            public String getText( Object element )
+            {
+                if ( element instanceof Schema )
+                {
+                    return ( ( Schema ) element ).getName();
+                }
+
+                // Default
+                return super.getText( element );
+            }
+        } );
+        schemaComboViewer.addSelectionChangedListener( new ISelectionChangedListener()
+        {
+            /* (non-Javadoc)
+             * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+             */
+            public void selectionChanged( SelectionChangedEvent event )
+            {
+                dialogChanged();
+            }
+        } );
+
+        // Naming and Description Group
+        Group namingDescriptionGroup = new Group( composite, SWT.NONE );
+        namingDescriptionGroup.setText( "Naming and Description" );
+        namingDescriptionGroup.setLayout( new GridLayout( 3, false ) );
+        namingDescriptionGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // OID
+        Label oidLabel = new Label( namingDescriptionGroup, SWT.NONE );
+        oidLabel.setText( "OID:" );
+        oidText = new Text( namingDescriptionGroup, SWT.BORDER );
+        oidText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
+        oidText.addModifyListener( new ModifyListener()
+        {
+            /* (non-Javadoc)
+             * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+             */
+            public void modifyText( ModifyEvent arg0 )
+            {
+                dialogChanged();
+            }
+        } );
+        oidText.addVerifyListener( new VerifyListener()
+        {
+            /* (non-Javadoc)
+             * @see org.eclipse.swt.events.VerifyListener#verifyText(org.eclipse.swt.events.VerifyEvent)
+             */
+            public void verifyText( VerifyEvent e )
+            {
+                if ( !e.text.matches( "([0-9]*\\.?)*" ) ) //$NON-NLS-1$
+                {
+                    e.doit = false;
+                }
+            }
+        } );
+
+        // Aliases
+        Label aliasesLabel = new Label( namingDescriptionGroup, SWT.NONE );
+        aliasesLabel.setText( "Aliases:" );
+        aliasesText = new Text( namingDescriptionGroup, SWT.BORDER );
+        aliasesText.setEnabled( false );
+        aliasesText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+        aliasesButton = new Button( namingDescriptionGroup, SWT.PUSH );
+        aliasesButton.setText( "Edit..." );
+        aliasesButton.addSelectionListener( new SelectionAdapter()
+        {
+            /* (non-Javadoc)
+             * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+             */
+            public void widgetSelected( SelectionEvent arg0 )
+            {
+                EditAliasesDialog dialog = new EditAliasesDialog( aliases );
+
+                if ( ( dialog.open() == Dialog.OK ) && ( dialog.isDirty() ) )
+                {
+                    aliases = dialog.getAliases();
+                    fillInAliasesLabel();
+                    dialogChanged();
+                }
+            }
+        } );
+
+        // Description
+        Label descriptionLabel = new Label( namingDescriptionGroup, SWT.NONE );
+        descriptionLabel.setText( "Description:" );
+        descriptionText = new Text( namingDescriptionGroup, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL );
+        GridData descriptionGridData = new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 );
+        descriptionGridData.heightHint = 67;
+        descriptionText.setLayoutData( descriptionGridData );
+        descriptionText.addModifyListener( new ModifyListener()
+        {
+            /* (non-Javadoc)
+             * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+             */
+            public void modifyText( ModifyEvent arg0 )
+            {
+                dialogChanged();
+            }
+        } );
+
+        initFields();
+
+        setControl( composite );
+
+        displayErrorMessage( null );
+        setPageComplete( false );
+    }
+
+
+    /**
+     * Initializes the UI fields.
+     */
+    private void initFields()
+    {
+        // Filling the Schemas table
+        if ( schemaHandler != null )
+        {
+            List<Schema> schemas = new ArrayList<Schema>();
+            schemas.addAll( schemaHandler.getSchemas() );
+
+            Collections.sort( schemas, new Comparator<Schema>()
+            {
+                public int compare( Schema o1, Schema o2 )
+                {
+                    return o1.getName().compareToIgnoreCase( o2.getName() );
+                }
+            } );
+
+            schemaComboViewer.setInput( schemas );
+
+            if ( selectedSchema != null )
+            {
+                schemaComboViewer.setSelection( new StructuredSelection( selectedSchema ) );
+            }
+        }
+    }
+
+
+    /**
+     * This method is called when the user modifies something in the UI.
+     */
+    private void dialogChanged()
+    {
+        if ( schemaComboViewer.getSelection().isEmpty() )
+        {
+            displayErrorMessage( "A Schema must be specified." );
+            return;
+        }
+        else if ( oidText.getText().equals( "" ) )
+        {
+            displayErrorMessage( "An OID must be specified." );
+            return;
+        }
+        else if ( ( !oidText.getText().equals( "" ) ) && ( !OID.isOID( oidText.getText() ) ) )
+        {
+            displayErrorMessage( "Incorrect OID." );
+            return;
+        }
+        else if ( ( !oidText.getText().equals( "" ) ) && ( OID.isOID( oidText.getText() ) )
+            && ( schemaHandler.isAliasOrOidAlreadyTaken( oidText.getText() ) ) )
+        {
+            displayErrorMessage( "An object with this OID already exists." );
+            return;
+        }
+        else if ( aliases.length == 0 )
+        {
+            displayWarningMessage( "The attribute type does not have any name. It is recommanded to add at least one name." );
+            return;
+        }
+
+        displayErrorMessage( null );
+    }
+
+
+    /**
+     * Displays an error message and set the page status as incomplete
+     * if the message is not null.
+     *
+     * @param message
+     *      the message to display
+     */
+    private void displayErrorMessage( String message )
+    {
+        setMessage( null, DialogPage.WARNING );
+        setErrorMessage( message );
+        setPageComplete( message == null );
+    }
+
+
+    /**
+     * Displays a warning message and set the page status as complete.
+     *
+     * @param message
+     *      the message to display
+     */
+    private void displayWarningMessage( String message )
+    {
+        setErrorMessage( null );
+        setMessage( message, DialogPage.WARNING );
+        setPageComplete( true );
+    }
+
+
+    /**
+     * Fills in the Aliases Label.
+     */
+    private void fillInAliasesLabel()
+    {
+        StringBuffer sb = new StringBuffer();
+        if ( aliases.length != 0 )
+        {
+            for ( String name : aliases )
+            {
+                sb.append( name );
+                sb.append( ", " );
+            }
+            sb.deleteCharAt( sb.length() - 1 );
+            sb.deleteCharAt( sb.length() - 1 );
+        }
+        aliasesText.setText( sb.toString() );
+    }
+
+
+    /**
+     * Get the name of the schema.
+     *
+     * @return
+     *      the name of the schema
+     */
+    public String getSchemaValue()
+    {
+        StructuredSelection selection = ( StructuredSelection ) schemaComboViewer.getSelection();
+        if ( !selection.isEmpty() )
+        {
+            Schema schema = ( Schema ) selection.getFirstElement();
+
+            return schema.getName();
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    /**
+     * Gets the value of the OID.
+     *
+     * @return
+     *      the value of the OID
+     */
+    public String getOidValue()
+    {
+        return oidText.getText();
+    }
+
+
+    /**
+     * Gets the value of the aliases.
+     *
+     * @return
+     *      the value of the aliases
+     */
+    public String[] getAliasesValue()
+    {
+        return aliases;
+    }
+
+
+    /**
+     * Gets the value of the description.
+     *
+     * @return
+     *      the value of the description
+     */
+    public String getDescriptionValue()
+    {
+        return descriptionText.getText();
+    }
+
+
+    /**
+     * Sets the selected schema.
+     *
+     * @param schema
+     *      the selected schema
+     */
+    public void setSelectedSchema( Schema schema )
+    {
+        selectedSchema = schema;
+    }
+}

Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassGeneralPageWizardPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassMandatoryAttributesPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassMandatoryAttributesPage.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassMandatoryAttributesPage.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassMandatoryAttributesPage.java Mon Nov  5 09:14:24 2007
@@ -0,0 +1,264 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.schemaeditor.view.wizards;
+
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.schemaeditor.view.ViewUtils;
+import org.apache.directory.studio.schemaeditor.view.dialogs.AttributeTypeSelectionDialog;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class represents the Mandatory Attribute Types WizardPage of the NewObjectClassWizard.
+ * <p>
+ * It is used to let the user specify the mandatory attribute types for the object class.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NewObjectClassMandatoryAttributesPage extends WizardPage
+{
+    /** The mandatory attribute types list */
+    private List<AttributeTypeImpl> mandatoryAttributeTypesList;
+
+    // UI Fields
+    private TableViewer mandatoryAttributeTypesTableViewer;
+    private Button mandatoryAttributeTypesAddButton;
+    private Button mandatoryAttributeTypesRemoveButton;
+
+
+    /**
+     * Creates a new instance of NewObjectClassMandatoryAttributesPage.
+     */
+    protected NewObjectClassMandatoryAttributesPage()
+    {
+        super( "NewObjectClassMandatoryAttributesPage" );
+        setTitle( "Mandatory Attribute Types" );
+        setDescription( "Please specify the mandatory attribute types for the object class." );
+        setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+            PluginConstants.IMG_OBJECT_CLASS_NEW_WIZARD ) );
+        mandatoryAttributeTypesList = new ArrayList<AttributeTypeImpl>();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+     */
+    public void createControl( Composite parent )
+    {
+        Composite composite = new Composite( parent, SWT.NULL );
+        GridLayout layout = new GridLayout();
+        composite.setLayout( layout );
+
+        // Mandatory Attribute Types Group
+        Group mandatoryAttributeTypesGroup = new Group( composite, SWT.NONE );
+        mandatoryAttributeTypesGroup.setText( "Mandatory Attribute Types" );
+        mandatoryAttributeTypesGroup.setLayout( new GridLayout( 2, false ) );
+        mandatoryAttributeTypesGroup.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
+
+        // Mandatory Attribute Types
+        Table mandatoryAttributeTypesTable = new Table( mandatoryAttributeTypesGroup, SWT.BORDER );
+        GridData mandatoryAttributeTypesTableGridData = new GridData( SWT.FILL, SWT.FILL, true, true, 1, 2 );
+        mandatoryAttributeTypesTableGridData.heightHint = 100;
+        mandatoryAttributeTypesTable.setLayoutData( mandatoryAttributeTypesTableGridData );
+        mandatoryAttributeTypesTableViewer = new TableViewer( mandatoryAttributeTypesTable );
+        mandatoryAttributeTypesTableViewer.setContentProvider( new ArrayContentProvider() );
+        mandatoryAttributeTypesTableViewer.setLabelProvider( new LabelProvider()
+        {
+            public Image getImage( Object element )
+            {
+                if ( element instanceof AttributeTypeImpl )
+                {
+                    return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+                        PluginConstants.IMG_ATTRIBUTE_TYPE ).createImage();
+                }
+
+                // Default
+                return super.getImage( element );
+            }
+
+
+            public String getText( Object element )
+            {
+                if ( element instanceof AttributeTypeImpl )
+                {
+                    AttributeTypeImpl at = ( AttributeTypeImpl ) element;
+
+                    String[] names = at.getNames();
+                    if ( ( names != null ) && ( names.length > 0 ) )
+                    {
+                        return ViewUtils.concateAliases( names ) + "  -  (" + at.getOid() + ")";
+                    }
+                    else
+                    {
+                        return "(None)  -  (" + at.getOid() + ")";
+                    }
+                }
+                // Default
+                return super.getText( element );
+            }
+        } );
+        mandatoryAttributeTypesTableViewer.setInput( mandatoryAttributeTypesList );
+        mandatoryAttributeTypesTableViewer.addSelectionChangedListener( new ISelectionChangedListener()
+        {
+            public void selectionChanged( SelectionChangedEvent event )
+            {
+                mandatoryAttributeTypesRemoveButton.setEnabled( !event.getSelection().isEmpty() );
+            }
+        } );
+        mandatoryAttributeTypesAddButton = new Button( mandatoryAttributeTypesGroup, SWT.PUSH );
+        mandatoryAttributeTypesAddButton.setText( "Add..." );
+        mandatoryAttributeTypesAddButton.setLayoutData( new GridData( SWT.FILL, SWT.NONE, false, false ) );
+        mandatoryAttributeTypesAddButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent arg0 )
+            {
+                addMandatoryAttributeType();
+            }
+        } );
+        mandatoryAttributeTypesRemoveButton = new Button( mandatoryAttributeTypesGroup, SWT.PUSH );
+        mandatoryAttributeTypesRemoveButton.setText( "Remove" );
+        mandatoryAttributeTypesRemoveButton.setLayoutData( new GridData( SWT.FILL, SWT.NONE, false, false ) );
+        mandatoryAttributeTypesRemoveButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent arg0 )
+            {
+                removeMandatoryAttributeType();
+            }
+        } );
+        mandatoryAttributeTypesRemoveButton.setEnabled( false );
+
+        setControl( composite );
+    }
+
+
+    /**
+     * This method is called when the "Add" button of the mandatory 
+     * attribute types table is selected.
+     */
+    private void addMandatoryAttributeType()
+    {
+        AttributeTypeSelectionDialog dialog = new AttributeTypeSelectionDialog();
+        List<AttributeTypeImpl> hiddenAttributes = new ArrayList<AttributeTypeImpl>();
+        hiddenAttributes.addAll( mandatoryAttributeTypesList );
+        dialog.setHiddenAttributeTypes( hiddenAttributes );
+        if ( dialog.open() == Dialog.OK )
+        {
+            mandatoryAttributeTypesList.add( dialog.getSelectedAttributeType() );
+            updateMandatoryAttributeTypesTableTable();
+        }
+    }
+
+
+    /**
+     * This method is called when the "Remove" button of the mandatory 
+     * attribute types table is selected.
+     */
+    private void removeMandatoryAttributeType()
+    {
+        StructuredSelection selection = ( StructuredSelection ) mandatoryAttributeTypesTableViewer.getSelection();
+        if ( !selection.isEmpty() )
+        {
+            mandatoryAttributeTypesList.remove( selection.getFirstElement() );
+            updateMandatoryAttributeTypesTableTable();
+        }
+    }
+
+
+    /**
+     * Updates the mandatory attribute types table.
+     */
+    private void updateMandatoryAttributeTypesTableTable()
+    {
+        Collections.sort( mandatoryAttributeTypesList, new Comparator<AttributeTypeImpl>()
+        {
+            public int compare( AttributeTypeImpl o1, AttributeTypeImpl o2 )
+            {
+                String[] at1Names = o1.getNames();
+                String[] at2Names = o2.getNames();
+
+                if ( ( at1Names != null ) && ( at2Names != null ) && ( at1Names.length > 0 ) && ( at2Names.length > 0 ) )
+                {
+                    return at1Names[0].compareToIgnoreCase( at2Names[0] );
+                }
+
+                // Default
+                return 0;
+            }
+        } );
+
+        mandatoryAttributeTypesTableViewer.refresh();
+    }
+
+
+    /**
+     * Gets the mandatory attribute types.
+     *
+     * @return
+     *      the mandatory attributes types
+     */
+    public List<AttributeTypeImpl> getMandatoryAttributeTypes()
+    {
+        return mandatoryAttributeTypesList;
+    }
+
+
+    /**
+     * Gets the names of the mandatory attribute types.
+     *
+     * @return
+     *      the names of the mandatory attributes types
+     */
+    public String[] getMandatoryAttributeTypesNames()
+    {
+        List<String> names = new ArrayList<String>();
+        for ( AttributeTypeImpl at : mandatoryAttributeTypesList )
+        {
+            names.add( at.getName() );
+        }
+        return names.toArray( new String[0] );
+    }
+}

Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassMandatoryAttributesPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassOptionalAttributesPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassOptionalAttributesPage.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassOptionalAttributesPage.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassOptionalAttributesPage.java Mon Nov  5 09:14:24 2007
@@ -0,0 +1,264 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.schemaeditor.view.wizards;
+
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.schemaeditor.view.ViewUtils;
+import org.apache.directory.studio.schemaeditor.view.dialogs.AttributeTypeSelectionDialog;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class represents the Optional Attribute Types WizardPage of the NewObjectClassWizard.
+ * <p>
+ * It is used to let the user specify the optional attribute types for the object class.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NewObjectClassOptionalAttributesPage extends WizardPage
+{
+    /** The optional attribute types list */
+    private List<AttributeTypeImpl> optionalAttributeTypesList;
+
+    // UI Fields
+    private TableViewer optionalAttributeTypesTableViewer;
+    private Button optionalAttributeTypesAddButton;
+    private Button optionalAttributeTypesRemoveButton;
+
+
+    /**
+     * Creates a new instance of NewObjectClassOptionalAttributesPage.
+     */
+    protected NewObjectClassOptionalAttributesPage()
+    {
+        super( "NewObjectClassOptionalAttributesPage" );
+        setTitle( "Optional Attribute Types" );
+        setDescription( "Please specify the optional attribute types for the object class." );
+        setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+            PluginConstants.IMG_OBJECT_CLASS_NEW_WIZARD ) );
+        optionalAttributeTypesList = new ArrayList<AttributeTypeImpl>();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+     */
+    public void createControl( Composite parent )
+    {
+        Composite composite = new Composite( parent, SWT.NULL );
+        GridLayout layout = new GridLayout();
+        composite.setLayout( layout );
+
+        // Optional Attribute Types Group
+        Group optionalAttributeTypesGroup = new Group( composite, SWT.NONE );
+        optionalAttributeTypesGroup.setText( "Optional Attribute Types" );
+        optionalAttributeTypesGroup.setLayout( new GridLayout( 2, false ) );
+        optionalAttributeTypesGroup.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
+
+        // Optional Attribute Types
+        Table optionalAttributeTypesTable = new Table( optionalAttributeTypesGroup, SWT.BORDER );
+        GridData optionalAttributeTypesTableGridData = new GridData( SWT.FILL, SWT.FILL, true, true, 1, 2 );
+        optionalAttributeTypesTableGridData.heightHint = 100;
+        optionalAttributeTypesTable.setLayoutData( optionalAttributeTypesTableGridData );
+        optionalAttributeTypesTableViewer = new TableViewer( optionalAttributeTypesTable );
+        optionalAttributeTypesTableViewer.setContentProvider( new ArrayContentProvider() );
+        optionalAttributeTypesTableViewer.setLabelProvider( new LabelProvider()
+        {
+            public Image getImage( Object element )
+            {
+                if ( element instanceof AttributeTypeImpl )
+                {
+                    return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+                        PluginConstants.IMG_ATTRIBUTE_TYPE ).createImage();
+                }
+
+                // Default
+                return super.getImage( element );
+            }
+
+
+            public String getText( Object element )
+            {
+                if ( element instanceof AttributeTypeImpl )
+                {
+                    AttributeTypeImpl at = ( AttributeTypeImpl ) element;
+
+                    String[] names = at.getNames();
+                    if ( ( names != null ) && ( names.length > 0 ) )
+                    {
+                        return ViewUtils.concateAliases( names ) + "  -  (" + at.getOid() + ")";
+                    }
+                    else
+                    {
+                        return "(None)  -  (" + at.getOid() + ")";
+                    }
+                }
+                // Default
+                return super.getText( element );
+            }
+        } );
+        optionalAttributeTypesTableViewer.setInput( optionalAttributeTypesList );
+        optionalAttributeTypesTableViewer.addSelectionChangedListener( new ISelectionChangedListener()
+        {
+            public void selectionChanged( SelectionChangedEvent event )
+            {
+                optionalAttributeTypesRemoveButton.setEnabled( !event.getSelection().isEmpty() );
+            }
+        } );
+        optionalAttributeTypesAddButton = new Button( optionalAttributeTypesGroup, SWT.PUSH );
+        optionalAttributeTypesAddButton.setText( "Add..." );
+        optionalAttributeTypesAddButton.setLayoutData( new GridData( SWT.FILL, SWT.NONE, false, false ) );
+        optionalAttributeTypesAddButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent arg0 )
+            {
+                addOptionalAttributeType();
+            }
+        } );
+        optionalAttributeTypesRemoveButton = new Button( optionalAttributeTypesGroup, SWT.PUSH );
+        optionalAttributeTypesRemoveButton.setText( "Remove" );
+        optionalAttributeTypesRemoveButton.setLayoutData( new GridData( SWT.FILL, SWT.NONE, false, false ) );
+        optionalAttributeTypesRemoveButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent arg0 )
+            {
+                removeOptionalAttributeType();
+            }
+        } );
+        optionalAttributeTypesRemoveButton.setEnabled( false );
+
+        setControl( composite );
+    }
+
+
+    /**
+     * This method is called when the "Add" button of the optional 
+     * attribute types table is selected.
+     */
+    private void addOptionalAttributeType()
+    {
+        AttributeTypeSelectionDialog dialog = new AttributeTypeSelectionDialog();
+        List<AttributeTypeImpl> hiddenAttributes = new ArrayList<AttributeTypeImpl>();
+        hiddenAttributes.addAll( optionalAttributeTypesList );
+        dialog.setHiddenAttributeTypes( hiddenAttributes );
+        if ( dialog.open() == Dialog.OK )
+        {
+            optionalAttributeTypesList.add( dialog.getSelectedAttributeType() );
+            updateOptionalAttributeTypesTableTable();
+        }
+    }
+
+
+    /**
+     * This method is called when the "Remove" button of the optional 
+     * attribute types table is selected.
+     */
+    private void removeOptionalAttributeType()
+    {
+        StructuredSelection selection = ( StructuredSelection ) optionalAttributeTypesTableViewer.getSelection();
+        if ( !selection.isEmpty() )
+        {
+            optionalAttributeTypesList.remove( selection.getFirstElement() );
+            updateOptionalAttributeTypesTableTable();
+        }
+    }
+
+
+    /**
+     * Updates the optional attribute types table.
+     */
+    private void updateOptionalAttributeTypesTableTable()
+    {
+        Collections.sort( optionalAttributeTypesList, new Comparator<AttributeTypeImpl>()
+        {
+            public int compare( AttributeTypeImpl o1, AttributeTypeImpl o2 )
+            {
+                String[] at1Names = o1.getNames();
+                String[] at2Names = o2.getNames();
+
+                if ( ( at1Names != null ) && ( at2Names != null ) && ( at1Names.length > 0 ) && ( at2Names.length > 0 ) )
+                {
+                    return at1Names[0].compareToIgnoreCase( at2Names[0] );
+                }
+
+                // Default
+                return 0;
+            }
+        } );
+
+        optionalAttributeTypesTableViewer.refresh();
+    }
+
+
+    /**
+     * Gets the optional attribute types.
+     *
+     * @return
+     *      the optional attributes types
+     */
+    public List<AttributeTypeImpl> getOptionalAttributeTypes()
+    {
+        return optionalAttributeTypesList;
+    }
+
+
+    /**
+     * Gets the names of the optional attribute types.
+     *
+     * @return
+     *      the names of the optional attributes types
+     */
+    public String[] getOptionalAttributeTypesNames()
+    {
+        List<String> names = new ArrayList<String>();
+        for ( AttributeTypeImpl at : optionalAttributeTypesList )
+        {
+            names.add( at.getName() );
+        }
+        return names.toArray( new String[0] );
+    }
+}

Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassOptionalAttributesPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassWizard.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassWizard.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassWizard.java Mon Nov  5 09:14:24 2007
@@ -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.studio.schemaeditor.view.wizards;
+
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.model.ObjectClassImpl;
+import org.apache.directory.studio.schemaeditor.model.Schema;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+
+/**
+ * This class represents the wizard to create a new ObjectClass.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NewObjectClassWizard extends Wizard implements INewWizard
+{
+    public static final String ID = Activator.PLUGIN_ID + ".wizards.NewObjectClassWizard";
+
+    /** The selected schema */
+    private Schema selectedSchema;
+
+    // The pages of the wizards
+    private NewObjectClassGeneralPageWizardPage generalPage;
+    private NewObjectClassContentWizardPage contentPage;
+    private NewObjectClassMandatoryAttributesPage mandatoryAttributesPage;
+    private NewObjectClassOptionalAttributesPage optionalAttributesPage;
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.wizard.Wizard#addPages()
+     */
+    public void addPages()
+    {
+        // Creating pages
+        generalPage = new NewObjectClassGeneralPageWizardPage();
+        generalPage.setSelectedSchema( selectedSchema );
+        contentPage = new NewObjectClassContentWizardPage();
+        mandatoryAttributesPage = new NewObjectClassMandatoryAttributesPage();
+        optionalAttributesPage = new NewObjectClassOptionalAttributesPage();
+
+        // Adding pages
+        addPage( generalPage );
+        addPage( contentPage );
+        addPage( mandatoryAttributesPage );
+        addPage( optionalAttributesPage );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.wizard.Wizard#performFinish()
+     */
+    public boolean performFinish()
+    {
+        ObjectClassImpl newOC = new ObjectClassImpl( generalPage.getOidValue() );
+        newOC.setSchema( generalPage.getSchemaValue() );
+        newOC.setNames( generalPage.getAliasesValue() );
+        newOC.setDescription( generalPage.getDescriptionValue() );
+        newOC.setSuperClassesNames( contentPage.getSuperiorsNameValue() );
+        newOC.setType( contentPage.getClassTypeValue() );
+        newOC.setObsolete( contentPage.getObsoleteValue() );
+        newOC.setMustNamesList( mandatoryAttributesPage.getMandatoryAttributeTypesNames() );
+        newOC.setMayNamesList( optionalAttributesPage.getOptionalAttributeTypesNames() );
+
+        Activator.getDefault().getSchemaHandler().addObjectClass( newOC );
+
+        return true;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+     */
+    public void init( IWorkbench workbench, IStructuredSelection selection )
+    {
+        // Nothing to do.
+    }
+
+
+    /**
+     * Sets the selected schema.
+     *
+     * @param schema
+     *      the selected schema
+     */
+    public void setSelectedSchema( Schema schema )
+    {
+        selectedSchema = schema;
+    }
+}

Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassWizard.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizard.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizard.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizard.java Mon Nov  5 09:14:24 2007
@@ -0,0 +1,290 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.schemaeditor.view.wizards;
+
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.StudioProgressMonitor;
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginUtils;
+import org.apache.directory.studio.schemaeditor.controller.ProjectsHandler;
+import org.apache.directory.studio.schemaeditor.model.Project;
+import org.apache.directory.studio.schemaeditor.model.ProjectType;
+import org.apache.directory.studio.schemaeditor.model.Schema;
+import org.apache.directory.studio.schemaeditor.model.io.SchemaConnector;
+import org.apache.directory.studio.schemaeditor.view.ViewUtils;
+import org.apache.directory.studio.schemaeditor.view.wizards.NewProjectWizardSchemasSelectionPage.ServerTypeEnum;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+
+/**
+ * This class represents the wizard to create a new Project.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NewProjectWizard extends Wizard implements INewWizard
+{
+    public static final String ID = Activator.PLUGIN_ID + ".wizards.NewProjectWizard";
+
+    // The pages of the wizard
+    private NewProjectWizardInformationPage informationPage;
+    private NewProjectWizardConnectionSelectionPage connectionSelectionPage;
+    private NewProjectWizardSchemasSelectionPage schemasSelectionPage;
+
+    private Throwable exceptionThrown = null;
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.wizard.Wizard#addPages()
+     */
+    public void addPages()
+    {
+        // Creating pages
+        informationPage = new NewProjectWizardInformationPage();
+        connectionSelectionPage = new NewProjectWizardConnectionSelectionPage();
+        schemasSelectionPage = new NewProjectWizardSchemasSelectionPage();
+
+        // Adding pages
+        addPage( informationPage );
+        addPage( connectionSelectionPage );
+        addPage( schemasSelectionPage );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.wizard.Wizard#performFinish()
+     */
+    public boolean performFinish()
+    {
+        String projectName = informationPage.getProjectName();
+        ProjectType projectType = informationPage.getProjectType();
+
+        // Creating the project
+        final Project project = new Project( projectType, projectName );
+
+        if ( projectType.equals( ProjectType.ONLINE ) )
+        // Project is an "Online Project"
+        {
+            // Setting the connection to use
+            project.setConnection( connectionSelectionPage.getSelectedConnection() );
+
+            // Reseting the Exception Thrown
+            exceptionThrown = null;
+
+            try
+            {
+                getContainer().run( true, false, new IRunnableWithProgress()
+                {
+                    public void run( IProgressMonitor monitor )
+                    {
+                        StudioProgressMonitor studioProgressMonitor = new StudioProgressMonitor( monitor );
+
+                        // Getting the correct SchemaConnector for this connection
+                        List<SchemaConnector> correctSchemaConnectors = getCorrectSchemaConnectors( project
+                            .getConnection(), studioProgressMonitor );
+
+                        // If no suitable SchemaConnector has been found, we display an
+                        // error message and return false;
+                        if ( correctSchemaConnectors.size() == 0 )
+                        {
+                            studioProgressMonitor.reportError(
+                                "No suitable SchemaConnector has been found for the choosen Directory Server.",
+                                new RuntimeException(
+                                    "No suitable SchemaConnector has been found for the choosen Directory Server." ) );
+                        }
+
+                        // Getting the correct SchemaConnector
+                        SchemaConnector correctSchemaConnector = null;
+                        if ( correctSchemaConnectors.size() == 1 )
+                        {
+                            correctSchemaConnector = correctSchemaConnectors.get( 0 );
+                        }
+                        else
+                        {
+                            // TODO display a dialog in which the user can select the correct schema connector
+                        }
+
+                        project.setSchemaConnector( correctSchemaConnector );
+
+                        // Fetching the Online Schema
+                        project.fetchOnlineSchema( new StudioProgressMonitor( monitor ) );
+
+                        // Checking if an error has occured
+                        if ( studioProgressMonitor.errorsReported() )
+                        {
+                            exceptionThrown = studioProgressMonitor.getException();
+                            return;
+                        }
+                    }
+                } );
+            }
+            catch ( InvocationTargetException e )
+            {
+                PluginUtils.logError( "An error occured when creating the project.", e );
+                ViewUtils.displayErrorMessageBox( "Error", "An error occured when creating the project." );
+            }
+            catch ( InterruptedException e )
+            {
+                // Nothing to do.
+            }
+
+            if ( exceptionThrown != null )
+            {
+                PluginUtils.logError( "An error occured when creating the project.", exceptionThrown );
+                ViewUtils.displayErrorMessageBox( "Error", "An error occured when creating the project." );
+                return false;
+            }
+        }
+        else if ( projectType.equals( ProjectType.OFFLINE ) )
+        // Project is an "Online Project"
+        {
+            // Getting the selected 'core' schemas
+            String[] selectedSchemas = schemasSelectionPage.getSelectedSchemas();
+            ServerTypeEnum serverType = schemasSelectionPage.getServerType();
+            if ( ( selectedSchemas != null ) && ( serverType != null ) )
+            {
+                for ( String selectedSchema : selectedSchemas )
+                {
+                    Schema schema = PluginUtils.loadCoreSchema( serverType, selectedSchema );
+                    if ( schema != null )
+                    {
+                        project.getSchemaHandler().addSchema( schema );
+                    }
+                }
+            }
+        }
+
+        ProjectsHandler projectsHandler = Activator.getDefault().getProjectsHandler();
+        projectsHandler.addProject( project );
+        projectsHandler.openProject( project );
+
+        return true;
+    }
+
+
+    /**
+     * Gets the List of suitable SchemaConnectors
+     *
+     * @param connection
+     *      the connection to test the SchemaConnectors with
+     * @return
+     *      the List of suitable SchemaConnectors
+     */
+    private List<SchemaConnector> getCorrectSchemaConnectors( Connection connection, StudioProgressMonitor monitor )
+    {
+        List<SchemaConnector> suitableSchemaConnectors = new ArrayList<SchemaConnector>();
+
+        // Looping on the SchemaConnectors
+        List<SchemaConnector> schemaConectors = PluginUtils.getSchemaConnectors();
+        for ( SchemaConnector schemaConnector : schemaConectors )
+        {
+            // Testing if the SchemaConnector is suitable for this connection
+            if ( schemaConnector.isSuitableConnector( connection, monitor ) )
+            {
+                suitableSchemaConnectors.add( schemaConnector );
+            }
+        }
+
+        return suitableSchemaConnectors;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.wizard.Wizard#getNextPage(org.eclipse.jface.wizard.IWizardPage)
+     */
+    public IWizardPage getNextPage( IWizardPage page )
+    {
+        if ( page.equals( informationPage ) )
+        {
+            if ( informationPage.getProjectType().equals( ProjectType.ONLINE ) )
+            {
+                return connectionSelectionPage;
+            }
+            else if ( informationPage.getProjectType().equals( ProjectType.OFFLINE ) )
+            {
+                return schemasSelectionPage;
+            }
+        }
+
+        // Default
+        return null;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.wizard.Wizard#getPreviousPage(org.eclipse.jface.wizard.IWizardPage)
+     */
+    public IWizardPage getPreviousPage( IWizardPage page )
+    {
+        if ( ( page.equals( connectionSelectionPage ) ) || ( page.equals( schemasSelectionPage ) ) )
+        {
+            return informationPage;
+        }
+
+        // Default
+        return null;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.wizard.Wizard#canFinish()
+     */
+    public boolean canFinish()
+    {
+        IWizardPage currentPage = getContainer().getCurrentPage();
+
+        if ( currentPage.equals( informationPage ) )
+        {
+            return false;
+        }
+        else if ( currentPage.equals( schemasSelectionPage ) )
+        {
+            return true;
+        }
+        else if ( currentPage.equals( connectionSelectionPage ) )
+        {
+            return connectionSelectionPage.isPageComplete();
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+     */
+    public void init( IWorkbench workbench, IStructuredSelection selection )
+    {
+        setNeedsProgressMonitor( true );
+    }
+}

Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizard.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message