directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r592094 [25/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/ImportProjectsWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportProjectsWizardPage.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportProjectsWizardPage.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportProjectsWizardPage.java Mon Nov  5 09:14:24 2007
@@ -0,0 +1,334 @@
+/*
+ *  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.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.LabelProvider;
+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.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.DirectoryDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class represents the WizardPage of the ImportProjectsWizard.
+ * <p>
+ * It is used to let the user enter the informations about the
+ * schemas he wants to import.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ImportProjectsWizardPage extends WizardPage
+{
+    // UI Fields
+    private Text fromDirectoryText;
+    private Button fromDirectoryButton;
+    private CheckboxTableViewer projectFilesTableViewer;
+    private Button projectFilesTableSelectAllButton;
+    private Button projectFilesTableDeselectAllButton;
+
+
+    /**
+     * Creates a new instance of ImportSchemasFromOpenLdapWizardPage.
+     */
+    protected ImportProjectsWizardPage()
+    {
+        super( "ImportProjectsWizardPage" );
+        setTitle( "Import schema projects" );
+        setDescription( "Please select the schema project to import." );
+        setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+            PluginConstants.IMG_PROJECT_IMPORT_WIZARD ) );
+    }
+
+
+    /* (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 );
+
+        // From Directory Group
+        Group fromDirectoryGroup = new Group( composite, SWT.NONE );
+        fromDirectoryGroup.setText( "From directory" );
+        fromDirectoryGroup.setLayout( new GridLayout( 3, false ) );
+        fromDirectoryGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // From Directory
+        Label fromDirectoryLabel = new Label( fromDirectoryGroup, SWT.NONE );
+        fromDirectoryLabel.setText( "From directory:" );
+        fromDirectoryText = new Text( fromDirectoryGroup, SWT.BORDER );
+        fromDirectoryText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+        fromDirectoryText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                dialogChanged();
+            }
+        } );
+        fromDirectoryButton = new Button( fromDirectoryGroup, SWT.PUSH );
+        fromDirectoryButton.setText( "Browse..." );
+        fromDirectoryButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                chooseFromDirectory();
+            }
+        } );
+
+        // Schema Files Group
+        Group schemaFilesGroup = new Group( composite, SWT.NONE );
+        schemaFilesGroup.setText( "Schema project files" );
+        schemaFilesGroup.setLayout( new GridLayout( 2, false ) );
+        schemaFilesGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Schema Files
+        projectFilesTableViewer = new CheckboxTableViewer( new Table( schemaFilesGroup, SWT.BORDER | SWT.CHECK
+            | SWT.FULL_SELECTION ) );
+        GridData schemasTableViewerGridData = new GridData( SWT.FILL, SWT.NONE, true, false, 1, 2 );
+        schemasTableViewerGridData.heightHint = 125;
+        projectFilesTableViewer.getTable().setLayoutData( schemasTableViewerGridData );
+        projectFilesTableViewer.setContentProvider( new ArrayContentProvider() );
+        projectFilesTableViewer.setLabelProvider( new LabelProvider()
+        {
+            public String getText( Object element )
+            {
+                if ( element instanceof File )
+                {
+                    return ( ( File ) element ).getName();
+                }
+
+                // Default
+                return super.getText( element );
+            }
+
+
+            public Image getImage( Object element )
+            {
+                if ( element instanceof File )
+                {
+                    return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+                        PluginConstants.IMG_PROJECT_FILE ).createImage();
+                }
+
+                // Default
+                return super.getImage( element );
+            }
+        } );
+        projectFilesTableViewer.addCheckStateListener( new ICheckStateListener()
+        {
+            /**
+             * Notifies of a change to the checked state of an element.
+             *
+             * @param event
+             *      event object describing the change
+             */
+            public void checkStateChanged( CheckStateChangedEvent event )
+            {
+                dialogChanged();
+            }
+        } );
+        projectFilesTableSelectAllButton = new Button( schemaFilesGroup, SWT.PUSH );
+        projectFilesTableSelectAllButton.setText( "Select All" );
+        projectFilesTableSelectAllButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+        projectFilesTableSelectAllButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                projectFilesTableViewer.setAllChecked( true );
+                dialogChanged();
+            }
+        } );
+        projectFilesTableDeselectAllButton = new Button( schemaFilesGroup, SWT.PUSH );
+        projectFilesTableDeselectAllButton.setText( "Deselect All" );
+        projectFilesTableDeselectAllButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+        projectFilesTableDeselectAllButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                projectFilesTableViewer.setAllChecked( false );
+                dialogChanged();
+            }
+        } );
+
+        initFields();
+
+        setControl( composite );
+    }
+
+
+    /**
+     * Initializes the UI Fields.
+     */
+    private void initFields()
+    {
+        displayErrorMessage( null );
+        setPageComplete( false );
+    }
+
+
+    /**
+     * This method is called when the exportMultipleFiles 'browse' button is selected.
+     */
+    private void chooseFromDirectory()
+    {
+        DirectoryDialog dialog = new DirectoryDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell() );
+        dialog.setText( "Choose Folder" );
+        dialog.setMessage( "Select the folder from which import the files." );
+
+        String selectedDirectory = dialog.open();
+        if ( selectedDirectory != null )
+        {
+            fromDirectoryText.setText( selectedDirectory );
+            fillInSchemaFilesTable( selectedDirectory );
+        }
+    }
+
+
+    /**
+     * Fills in the SchemaFilesTable with the schema files found in the given path.
+     *
+     * @param path
+     *      the path to search schema files in
+     */
+    private void fillInSchemaFilesTable( String path )
+    {
+        List<File> schemaFiles = new ArrayList<File>();
+        File selectedDirectory = new File( path );
+        if ( selectedDirectory.exists() )
+        {
+            for ( File file : selectedDirectory.listFiles() )
+            {
+                String fileName = file.getName();
+                if ( fileName.endsWith( ".schemaproject" ) )
+                {
+                    schemaFiles.add( file );
+                }
+            }
+        }
+
+        projectFilesTableViewer.setInput( schemaFiles );
+    }
+
+
+    /**
+     * This method is called when the user modifies something in the UI.
+     */
+    private void dialogChanged()
+    {
+        // Export Directory
+        String directory = fromDirectoryText.getText();
+        if ( ( directory == null ) || ( directory.equals( "" ) ) )
+        {
+            displayErrorMessage( "A directory must be selected." );
+            return;
+        }
+        else
+        {
+            File directoryFile = new File( directory );
+            if ( !directoryFile.exists() )
+            {
+                displayErrorMessage( "The selected directory does not exist." );
+                return;
+            }
+            else if ( !directoryFile.isDirectory() )
+            {
+                displayErrorMessage( "The selected directory is not a directory." );
+                return;
+            }
+            else if ( !directoryFile.canRead() )
+            {
+                displayErrorMessage( "The selected directory is not readable." );
+                return;
+            }
+        }
+
+        // Schemas table
+        if ( projectFilesTableViewer.getCheckedElements().length == 0 )
+        {
+            displayErrorMessage( "One or several schema project files must be selected." );
+            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 )
+    {
+        setErrorMessage( message );
+        setPageComplete( message == null );
+    }
+
+
+    /**
+     * Gets the selected project files.
+     *
+     * @return
+     *      the selected project files
+     */
+    public File[] getSelectedProjectFiles()
+    {
+        Object[] selectedProjectFile = projectFilesTableViewer.getCheckedElements();
+
+        List<File> schemaFiles = new ArrayList<File>();
+        for ( Object projectFile : selectedProjectFile )
+        {
+            schemaFiles.add( ( File ) projectFile );
+        }
+
+        return schemaFiles.toArray( new File[0] );
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromOpenLdapWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromOpenLdapWizard.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromOpenLdapWizard.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromOpenLdapWizard.java Mon Nov  5 09:14:24 2007
@@ -0,0 +1,138 @@
+/*
+ *  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.io.File;
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginUtils;
+import org.apache.directory.studio.schemaeditor.controller.SchemaHandler;
+import org.apache.directory.studio.schemaeditor.model.Schema;
+import org.apache.directory.studio.schemaeditor.model.io.OpenLdapSchemaFileImportException;
+import org.apache.directory.studio.schemaeditor.model.io.OpenLdapSchemaFileImporter;
+import org.apache.directory.studio.schemaeditor.model.schemachecker.SchemaChecker;
+import org.apache.directory.studio.schemaeditor.view.ViewUtils;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbench;
+
+
+/**
+ * This class represents the wizard to import schemas from OpenLdap format.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ImportSchemasFromOpenLdapWizard extends Wizard implements IImportWizard
+{
+    public static final String ID = Activator.PLUGIN_ID + ".wizards.ImportSchemasFromOpenLdapWizard";
+
+    /** The SchemaHandler */
+    private SchemaHandler schemaHandler;
+
+    /** The SchemaChecker */
+    private SchemaChecker schemaChecker;
+
+    // The pages of the wizard
+    private ImportSchemasFromOpenLdapWizardPage page;
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.wizard.Wizard#addPages()
+     */
+    public void addPages()
+    {
+        // Creating pages
+        page = new ImportSchemasFromOpenLdapWizardPage();
+
+        // Adding pages
+        addPage( page );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.wizard.Wizard#performFinish()
+     */
+    public boolean performFinish()
+    {
+        final File[] selectedSchemasFiles = page.getSelectedSchemaFiles();
+
+        schemaChecker.disableModificationsListening();
+
+        try
+        {
+            getContainer().run( true, false, new IRunnableWithProgress()
+            {
+                public void run( IProgressMonitor monitor )
+                {
+                    monitor.beginTask( "Importing schemas: ", selectedSchemasFiles.length );
+
+                    for ( File schemaFile : selectedSchemasFiles )
+                    {
+                        monitor.subTask( schemaFile.getName() );
+                        try
+                        {
+                            Schema schema = OpenLdapSchemaFileImporter.getSchema( schemaFile.getAbsolutePath() );
+                            schemaHandler.addSchema( schema );
+                        }
+                        catch ( OpenLdapSchemaFileImportException e )
+                        {
+                            PluginUtils.logError( "An error occured when importing the schema " + schemaFile.getName()
+                                + ".", e );
+                            ViewUtils.displayErrorMessageBox( "Error", "An error occured when importing the schema "
+                                + schemaFile.getName() + "." );
+                        }
+                        monitor.worked( 1 );
+                    }
+
+                    monitor.done();
+                }
+            } );
+        }
+        catch ( InvocationTargetException e )
+        {
+            // Nothing to do (it will never occur)
+        }
+        catch ( InterruptedException e )
+        {
+            // Nothing to do.
+        }
+
+        schemaChecker.enableModificationsListening();
+
+        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 )
+    {
+        setNeedsProgressMonitor( true );
+        schemaHandler = Activator.getDefault().getSchemaHandler();
+        schemaChecker = Activator.getDefault().getSchemaChecker();
+    }
+}

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

Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromOpenLdapWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromOpenLdapWizardPage.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromOpenLdapWizardPage.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromOpenLdapWizardPage.java Mon Nov  5 09:14:24 2007
@@ -0,0 +1,334 @@
+/*
+ *  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.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.LabelProvider;
+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.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.DirectoryDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class represents the WizardPage of the ImportSchemasFromOpenLdapWizard.
+ * <p>
+ * It is used to let the user enter the informations about the
+ * schemas he wants to import.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ImportSchemasFromOpenLdapWizardPage extends WizardPage
+{
+    // UI Fields
+    private Text fromDirectoryText;
+    private Button fromDirectoryButton;
+    private CheckboxTableViewer schemaFilesTableViewer;
+    private Button schemaFilesTableSelectAllButton;
+    private Button schemaFilesTableDeselectAllButton;
+
+
+    /**
+     * Creates a new instance of ImportSchemasFromOpenLdapWizardPage.
+     */
+    protected ImportSchemasFromOpenLdapWizardPage()
+    {
+        super( "ImportSchemasFromOpenLdapWizardPage" );
+        setTitle( "Import schemas from OpenLdap files" );
+        setDescription( "Please select the OpenLdap schema files to import." );
+        setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+            PluginConstants.IMG_SCHEMAS_IMPORT_WIZARD ) );
+    }
+
+
+    /* (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 );
+
+        // From Directory Group
+        Group fromDirectoryGroup = new Group( composite, SWT.NONE );
+        fromDirectoryGroup.setText( "From directory" );
+        fromDirectoryGroup.setLayout( new GridLayout( 3, false ) );
+        fromDirectoryGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // From Directory
+        Label fromDirectoryLabel = new Label( fromDirectoryGroup, SWT.NONE );
+        fromDirectoryLabel.setText( "From directory:" );
+        fromDirectoryText = new Text( fromDirectoryGroup, SWT.BORDER );
+        fromDirectoryText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+        fromDirectoryText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                dialogChanged();
+            }
+        } );
+        fromDirectoryButton = new Button( fromDirectoryGroup, SWT.PUSH );
+        fromDirectoryButton.setText( "Browse..." );
+        fromDirectoryButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                chooseFromDirectory();
+            }
+        } );
+
+        // Schema Files Group
+        Group schemaFilesGroup = new Group( composite, SWT.NONE );
+        schemaFilesGroup.setText( "Schema files" );
+        schemaFilesGroup.setLayout( new GridLayout( 2, false ) );
+        schemaFilesGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Schema Files
+        schemaFilesTableViewer = new CheckboxTableViewer( new Table( schemaFilesGroup, SWT.BORDER | SWT.CHECK
+            | SWT.FULL_SELECTION ) );
+        GridData schemasTableViewerGridData = new GridData( SWT.FILL, SWT.NONE, true, false, 1, 2 );
+        schemasTableViewerGridData.heightHint = 125;
+        schemaFilesTableViewer.getTable().setLayoutData( schemasTableViewerGridData );
+        schemaFilesTableViewer.setContentProvider( new ArrayContentProvider() );
+        schemaFilesTableViewer.setLabelProvider( new LabelProvider()
+        {
+            public String getText( Object element )
+            {
+                if ( element instanceof File )
+                {
+                    return ( ( File ) element ).getName();
+                }
+
+                // Default
+                return super.getText( element );
+            }
+
+
+            public Image getImage( Object element )
+            {
+                if ( element instanceof File )
+                {
+                    return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, PluginConstants.IMG_SCHEMA )
+                        .createImage();
+                }
+
+                // Default
+                return super.getImage( element );
+            }
+        } );
+        schemaFilesTableViewer.addCheckStateListener( new ICheckStateListener()
+        {
+            /**
+             * Notifies of a change to the checked state of an element.
+             *
+             * @param event
+             *      event object describing the change
+             */
+            public void checkStateChanged( CheckStateChangedEvent event )
+            {
+                dialogChanged();
+            }
+        } );
+        schemaFilesTableSelectAllButton = new Button( schemaFilesGroup, SWT.PUSH );
+        schemaFilesTableSelectAllButton.setText( "Select All" );
+        schemaFilesTableSelectAllButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+        schemaFilesTableSelectAllButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                schemaFilesTableViewer.setAllChecked( true );
+                dialogChanged();
+            }
+        } );
+        schemaFilesTableDeselectAllButton = new Button( schemaFilesGroup, SWT.PUSH );
+        schemaFilesTableDeselectAllButton.setText( "Deselect All" );
+        schemaFilesTableDeselectAllButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+        schemaFilesTableDeselectAllButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                schemaFilesTableViewer.setAllChecked( false );
+                dialogChanged();
+            }
+        } );
+
+        initFields();
+
+        setControl( composite );
+    }
+
+
+    /**
+     * Initializes the UI Fields.
+     */
+    private void initFields()
+    {
+        displayErrorMessage( null );
+        setPageComplete( false );
+    }
+
+
+    /**
+     * This method is called when the exportMultipleFiles 'browse' button is selected.
+     */
+    private void chooseFromDirectory()
+    {
+        DirectoryDialog dialog = new DirectoryDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell() );
+        dialog.setText( "Choose Folder" );
+        dialog.setMessage( "Select the folder from which import the files." );
+
+        String selectedDirectory = dialog.open();
+        if ( selectedDirectory != null )
+        {
+            fromDirectoryText.setText( selectedDirectory );
+            fillInSchemaFilesTable( selectedDirectory );
+        }
+    }
+
+
+    /**
+     * Fills in the SchemaFilesTable with the schema files found in the given path.
+     *
+     * @param path
+     *      the path to search schema files in
+     */
+    private void fillInSchemaFilesTable( String path )
+    {
+        List<File> schemaFiles = new ArrayList<File>();
+        File selectedDirectory = new File( path );
+        if ( selectedDirectory.exists() )
+        {
+            for ( File file : selectedDirectory.listFiles() )
+            {
+                String fileName = file.getName();
+                if ( fileName.endsWith( ".schema" ) )
+                {
+                    schemaFiles.add( file );
+                }
+            }
+        }
+
+        schemaFilesTableViewer.setInput( schemaFiles );
+    }
+
+
+    /**
+     * This method is called when the user modifies something in the UI.
+     */
+    private void dialogChanged()
+    {
+        // Export Directory
+        String directory = fromDirectoryText.getText();
+        if ( ( directory == null ) || ( directory.equals( "" ) ) )
+        {
+            displayErrorMessage( "A directory must be selected." );
+            return;
+        }
+        else
+        {
+            File directoryFile = new File( directory );
+            if ( !directoryFile.exists() )
+            {
+                displayErrorMessage( "The selected directory does not exist." );
+                return;
+            }
+            else if ( !directoryFile.isDirectory() )
+            {
+                displayErrorMessage( "The selected directory is not a directory." );
+                return;
+            }
+            else if ( !directoryFile.canRead() )
+            {
+                displayErrorMessage( "The selected directory is not readable." );
+                return;
+            }
+        }
+
+        // Schemas table
+        if ( schemaFilesTableViewer.getCheckedElements().length == 0 )
+        {
+            displayErrorMessage( "One or several schema files must be selected." );
+            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 )
+    {
+        setErrorMessage( message );
+        setPageComplete( message == null );
+    }
+
+
+    /**
+     * Gets the selected schema files.
+     *
+     * @return
+     *      the selected schema files
+     */
+    public File[] getSelectedSchemaFiles()
+    {
+        Object[] selectedSchemaFile = schemaFilesTableViewer.getCheckedElements();
+
+        List<File> schemaFiles = new ArrayList<File>();
+        for ( Object schemaFile : selectedSchemaFile )
+        {
+            schemaFiles.add( ( File ) schemaFile );
+        }
+
+        return schemaFiles.toArray( new File[0] );
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromXmlWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromXmlWizard.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromXmlWizard.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromXmlWizard.java Mon Nov  5 09:14:24 2007
@@ -0,0 +1,152 @@
+/*
+ *  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.io.File;
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginUtils;
+import org.apache.directory.studio.schemaeditor.controller.SchemaHandler;
+import org.apache.directory.studio.schemaeditor.model.Schema;
+import org.apache.directory.studio.schemaeditor.model.io.XMLSchemaFileImportException;
+import org.apache.directory.studio.schemaeditor.model.io.XMLSchemaFileImporter;
+import org.apache.directory.studio.schemaeditor.model.io.XMLSchemaFileImporter.SchemaFileType;
+import org.apache.directory.studio.schemaeditor.model.schemachecker.SchemaChecker;
+import org.apache.directory.studio.schemaeditor.view.ViewUtils;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbench;
+
+
+/**
+ * This class represents the wizard to import schemas from XML format.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ImportSchemasFromXmlWizard extends Wizard implements IImportWizard
+{
+    public static final String ID = Activator.PLUGIN_ID + ".wizards.ImportSchemasFromXmlWizard";
+
+    /** The SchemaHandler */
+    private SchemaHandler schemaHandler;
+
+    /** The SchemaChecker */
+    private SchemaChecker schemaChecker;
+
+    // The pages of the wizard
+    private ImportSchemasFromXmlWizardPage page;
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.wizard.Wizard#addPages()
+     */
+    public void addPages()
+    {
+        // Creating pages
+        page = new ImportSchemasFromXmlWizardPage();
+
+        // Adding pages
+        addPage( page );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.wizard.Wizard#performFinish()
+     */
+    public boolean performFinish()
+    {
+        final String[] selectedSchemasFiles = page.getSelectedSchemaFiles();
+
+        schemaChecker.disableModificationsListening();
+
+        try
+        {
+            getContainer().run( true, false, new IRunnableWithProgress()
+            {
+                public void run( IProgressMonitor monitor )
+                {
+                    monitor.beginTask( "Importing schemas: ", selectedSchemasFiles.length );
+
+                    for ( String schemaFile : selectedSchemasFiles )
+                    {
+                        monitor.subTask( new File( schemaFile ).getName() );
+                        try
+                        {
+                            SchemaFileType schemaFileType = XMLSchemaFileImporter.getSchemaFileType( schemaFile );
+                            switch ( schemaFileType )
+                            {
+                                case SINGLE:
+                                    Schema importedSchema = XMLSchemaFileImporter.getSchema( schemaFile );
+                                    schemaHandler.addSchema( importedSchema );
+                                    break;
+                                case MULTIPLE:
+                                    Schema[] schemas = XMLSchemaFileImporter.getSchemas( schemaFile );
+                                    for ( Schema schema : schemas )
+                                    {
+                                        schemaHandler.addSchema( schema );
+                                    }
+                                    break;
+                            }
+                        }
+                        catch ( XMLSchemaFileImportException e )
+                        {
+                            PluginUtils.logError( "An error occured when importing  the schema " + schemaFile + ".", e );
+                            ViewUtils.displayErrorMessageBox( "Error", "An error occured when saving the schema "
+                                + schemaFile + "." );
+                        }
+                        monitor.worked( 1 );
+                    }
+
+                    monitor.done();
+                    schemaChecker.enableModificationsListening();
+                }
+            } );
+        }
+        catch ( InvocationTargetException e )
+        {
+            // Nothing to do (it will never occur)
+        }
+        catch ( InterruptedException e )
+        {
+            // Nothing to do.
+        }
+
+        schemaChecker.enableModificationsListening();
+
+        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 )
+    {
+        setNeedsProgressMonitor( true );
+        schemaHandler = Activator.getDefault().getSchemaHandler();
+        schemaChecker = Activator.getDefault().getSchemaChecker();
+    }
+}

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

Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromXmlWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromXmlWizardPage.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromXmlWizardPage.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportSchemasFromXmlWizardPage.java Mon Nov  5 09:14:24 2007
@@ -0,0 +1,334 @@
+/*
+ *  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.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.LabelProvider;
+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.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.DirectoryDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class represents the WizardPage of the ImportSchemasFromOpenLdapWizard.
+ * <p>
+ * It is used to let the user enter the informations about the
+ * schemas he wants to import.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ImportSchemasFromXmlWizardPage extends WizardPage
+{
+    // UI Fields
+    private Text fromDirectoryText;
+    private Button fromDirectoryButton;
+    private CheckboxTableViewer schemaFilesTableViewer;
+    private Button schemaFilesTableSelectAllButton;
+    private Button schemaFilesTableDeselectAllButton;
+
+
+    /**
+     * Creates a new instance of ImportSchemasFromOpenLdapWizardPage.
+     */
+    protected ImportSchemasFromXmlWizardPage()
+    {
+        super( "ImportSchemasFromXmlWizardPage" );
+        setTitle( "Import schemas from XML file(s)" );
+        setDescription( "Please select the XML schema files to import." );
+        setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+            PluginConstants.IMG_SCHEMAS_IMPORT_WIZARD ) );
+    }
+
+
+    /* (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 );
+
+        // From Directory Group
+        Group fromDirectoryGroup = new Group( composite, SWT.NONE );
+        fromDirectoryGroup.setText( "From directory" );
+        fromDirectoryGroup.setLayout( new GridLayout( 3, false ) );
+        fromDirectoryGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // From Directory
+        Label fromDirectoryLabel = new Label( fromDirectoryGroup, SWT.NONE );
+        fromDirectoryLabel.setText( "From directory:" );
+        fromDirectoryText = new Text( fromDirectoryGroup, SWT.BORDER );
+        fromDirectoryText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+        fromDirectoryText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                dialogChanged();
+            }
+        } );
+        fromDirectoryButton = new Button( fromDirectoryGroup, SWT.PUSH );
+        fromDirectoryButton.setText( "Browse..." );
+        fromDirectoryButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                chooseFromDirectory();
+            }
+        } );
+
+        // Schema Files Group
+        Group schemaFilesGroup = new Group( composite, SWT.NONE );
+        schemaFilesGroup.setText( "Schema files" );
+        schemaFilesGroup.setLayout( new GridLayout( 2, false ) );
+        schemaFilesGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Schema Files
+        schemaFilesTableViewer = new CheckboxTableViewer( new Table( schemaFilesGroup, SWT.BORDER | SWT.CHECK
+            | SWT.FULL_SELECTION ) );
+        GridData schemasTableViewerGridData = new GridData( SWT.FILL, SWT.NONE, true, false, 1, 2 );
+        schemasTableViewerGridData.heightHint = 125;
+        schemaFilesTableViewer.getTable().setLayoutData( schemasTableViewerGridData );
+        schemaFilesTableViewer.setContentProvider( new ArrayContentProvider() );
+        schemaFilesTableViewer.setLabelProvider( new LabelProvider()
+        {
+            public String getText( Object element )
+            {
+                if ( element instanceof File )
+                {
+                    return ( ( File ) element ).getName();
+                }
+
+                // Default
+                return super.getText( element );
+            }
+
+
+            public Image getImage( Object element )
+            {
+                if ( element instanceof File )
+                {
+                    return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, PluginConstants.IMG_SCHEMA )
+                        .createImage();
+                }
+
+                // Default
+                return super.getImage( element );
+            }
+        } );
+        schemaFilesTableViewer.addCheckStateListener( new ICheckStateListener()
+        {
+            /**
+             * Notifies of a change to the checked state of an element.
+             *
+             * @param event
+             *      event object describing the change
+             */
+            public void checkStateChanged( CheckStateChangedEvent event )
+            {
+                dialogChanged();
+            }
+        } );
+        schemaFilesTableSelectAllButton = new Button( schemaFilesGroup, SWT.PUSH );
+        schemaFilesTableSelectAllButton.setText( "Select All" );
+        schemaFilesTableSelectAllButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+        schemaFilesTableSelectAllButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                schemaFilesTableViewer.setAllChecked( true );
+                dialogChanged();
+            }
+        } );
+        schemaFilesTableDeselectAllButton = new Button( schemaFilesGroup, SWT.PUSH );
+        schemaFilesTableDeselectAllButton.setText( "Deselect All" );
+        schemaFilesTableDeselectAllButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+        schemaFilesTableDeselectAllButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                schemaFilesTableViewer.setAllChecked( false );
+                dialogChanged();
+            }
+        } );
+
+        initFields();
+
+        setControl( composite );
+    }
+
+
+    /**
+     * Initializes the UI Fields.
+     */
+    private void initFields()
+    {
+        displayErrorMessage( null );
+        setPageComplete( false );
+    }
+
+
+    /**
+     * This method is called when the exportMultipleFiles 'browse' button is selected.
+     */
+    private void chooseFromDirectory()
+    {
+        DirectoryDialog dialog = new DirectoryDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell() );
+        dialog.setText( "Choose Folder" );
+        dialog.setMessage( "Select the folder from which import the files." );
+
+        String selectedDirectory = dialog.open();
+        if ( selectedDirectory != null )
+        {
+            fromDirectoryText.setText( selectedDirectory );
+            fillInSchemaFilesTable( selectedDirectory );
+        }
+    }
+
+
+    /**
+     * Fills in the SchemaFilesTable with the schema files found in the given path.
+     *
+     * @param path
+     *      the path to search schema files in
+     */
+    private void fillInSchemaFilesTable( String path )
+    {
+        List<File> schemaFiles = new ArrayList<File>();
+        File selectedDirectory = new File( path );
+        if ( selectedDirectory.exists() )
+        {
+            for ( File file : selectedDirectory.listFiles() )
+            {
+                String fileName = file.getName();
+                if ( fileName.endsWith( ".xml" ) )
+                {
+                    schemaFiles.add( file );
+                }
+            }
+        }
+
+        schemaFilesTableViewer.setInput( schemaFiles );
+    }
+
+
+    /**
+     * This method is called when the user modifies something in the UI.
+     */
+    private void dialogChanged()
+    {
+        // Export Directory
+        String directory = fromDirectoryText.getText();
+        if ( ( directory == null ) || ( directory.equals( "" ) ) )
+        {
+            displayErrorMessage( "A directory must be selected." );
+            return;
+        }
+        else
+        {
+            File directoryFile = new File( directory );
+            if ( !directoryFile.exists() )
+            {
+                displayErrorMessage( "The selected directory does not exist." );
+                return;
+            }
+            else if ( !directoryFile.isDirectory() )
+            {
+                displayErrorMessage( "The selected directory is not a directory." );
+                return;
+            }
+            else if ( !directoryFile.canRead() )
+            {
+                displayErrorMessage( "The selected directory is not readable." );
+                return;
+            }
+        }
+
+        // Schemas table
+        if ( schemaFilesTableViewer.getCheckedElements().length == 0 )
+        {
+            displayErrorMessage( "One or several schema files must be selected." );
+            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 )
+    {
+        setErrorMessage( message );
+        setPageComplete( message == null );
+    }
+
+
+    /**
+     * Gets the selected schema files.
+     *
+     * @return
+     *      the selected schema files
+     */
+    public String[] getSelectedSchemaFiles()
+    {
+        Object[] selectedSchemaFile = schemaFilesTableViewer.getCheckedElements();
+
+        List<String> schemaFiles = new ArrayList<String>();
+        for ( Object schemaFile : selectedSchemaFile )
+        {
+            schemaFiles.add( ( ( File ) schemaFile ).getAbsolutePath() );
+        }
+
+        return schemaFiles.toArray( new String[0] );
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeContentWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeContentWizardPage.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeContentWizardPage.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeContentWizardPage.java Mon Nov  5 09:14:24 2007
@@ -0,0 +1,478 @@
+/*
+ *  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.UsageEnum;
+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.AttributeTypeImpl;
+import org.apache.directory.studio.schemaeditor.model.SyntaxImpl;
+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.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.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+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.Spinner;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class represents the Content WizardPage of the NewAttributeTypeWizard.
+ * <p>
+ * It is used to let the user enter content information about the
+ * attribute type he wants to create (superior, usage, syntax and properties).
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NewAttributeTypeContentWizardPage extends WizardPage
+{
+    /** The SchemaHandler */
+    private SchemaHandler schemaHandler;
+
+    // The Usage values
+    private static final String DIRECTORY_OPERATION = "Directory Operation";
+    private static final String DISTRIBUTED_OPERATION = "Distributed Operation";
+    private static final String DSA_OPERATION = "DSA Operation";
+    private static final String USER_APPLICATIONS = "User Applications";
+
+    // UI Fields
+    private Text superiorText;
+    private Button superiorButton;
+    private ComboViewer usageComboViewer;
+    private ComboViewer syntaxComboViewer;
+    private Spinner lengthSpinner;
+    private Button obsoleteCheckbox;
+    private Button singleValueCheckbox;
+    private Button collectiveCheckbox;
+    private Button noUserModificationCheckbox;
+
+
+    /**
+     * Creates a new instance of NewAttributeTypeContentWizardPage.
+     */
+    protected NewAttributeTypeContentWizardPage()
+    {
+        super( "NewAttributeTypeContentWizardPage" );
+        setTitle( "Attribute Type Content" );
+        setDescription( "Please enter the superior, usage, syntax and properties 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 );
+
+        // Superior and Usage Group
+        Group superiorUsageGroup = new Group( composite, SWT.NONE );
+        superiorUsageGroup.setText( "Superior and Usage" );
+        superiorUsageGroup.setLayout( new GridLayout( 3, false ) );
+        superiorUsageGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Superior
+        Label superiorLabel = new Label( superiorUsageGroup, SWT.NONE );
+        superiorLabel.setText( "Superior:" );
+        superiorText = new Text( superiorUsageGroup, SWT.BORDER );
+        superiorText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+        superiorText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent arg0 )
+            {
+                verifySuperior();
+            }
+        } );
+        superiorButton = new Button( superiorUsageGroup, SWT.PUSH );
+        superiorButton.setText( "Choose..." );
+        superiorButton.setLayoutData( new GridData( SWT.NONE, SWT.NONE, false, false ) );
+        superiorButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent arg0 )
+            {
+                AttributeTypeSelectionDialog dialog = new AttributeTypeSelectionDialog();
+                if ( dialog.open() == Dialog.OK )
+                {
+                    AttributeTypeImpl selectedAT = dialog.getSelectedAttributeType();
+                    String[] aliases = selectedAT.getNames();
+                    if ( ( aliases != null ) && ( aliases.length > 0 ) )
+                    {
+                        superiorText.setText( aliases[0] );
+                    }
+                    else
+                    {
+                        superiorText.setText( selectedAT.getOid() );
+                    }
+                }
+            }
+        } );
+
+        // Usage
+        Label usageLabel = new Label( superiorUsageGroup, SWT.NONE );
+        usageLabel.setText( "Usage:" );
+        Combo usageCombo = new Combo( superiorUsageGroup, SWT.READ_ONLY );
+        usageCombo.setLayoutData( new GridData( SWT.NONE, SWT.NONE, false, false, 2, 1 ) );
+        usageComboViewer = new ComboViewer( usageCombo );
+        usageComboViewer.setLabelProvider( new LabelProvider() );
+        usageComboViewer.setContentProvider( new ArrayContentProvider() );
+        usageComboViewer.setInput( new String[]
+            { DIRECTORY_OPERATION, DISTRIBUTED_OPERATION, DSA_OPERATION, USER_APPLICATIONS } );
+        usageComboViewer.setSelection( new StructuredSelection( USER_APPLICATIONS ) );
+
+        // Syntax Group
+        Group syntaxGroup = new Group( composite, SWT.NONE );
+        syntaxGroup.setText( "Syntax" );
+        syntaxGroup.setLayout( new GridLayout( 2, false ) );
+        syntaxGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Syntax
+        Label syntaxLabel = new Label( syntaxGroup, SWT.NONE );
+        syntaxLabel.setText( "Syntax:" );
+        Combo syntaxCombo = new Combo( syntaxGroup, SWT.READ_ONLY );
+        syntaxCombo.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+        syntaxComboViewer = new ComboViewer( syntaxCombo );
+        syntaxComboViewer.setContentProvider( new ArrayContentProvider() );
+        syntaxComboViewer.setLabelProvider( new LabelProvider()
+        {
+            public String getText( Object element )
+            {
+                if ( element instanceof SyntaxImpl )
+                {
+                    SyntaxImpl syntax = ( SyntaxImpl ) element;
+
+                    String name = syntax.getName();
+                    if ( name != null )
+                    {
+                        return name + "  -  (" + syntax.getOid() + ")";
+                    }
+                    else
+                    {
+                        return "(None)  -  (" + syntax.getOid() + ")";
+                    }
+                }
+
+                return super.getText( element );
+            }
+        } );
+
+        // Syntax Length
+        Label lengthLabel = new Label( syntaxGroup, SWT.NONE );
+        lengthLabel.setText( "Length:" );
+        lengthSpinner = new Spinner( syntaxGroup, SWT.BORDER );
+        lengthSpinner.setIncrement( 1 );
+        lengthSpinner.setMinimum( 0 );
+        lengthSpinner.setMaximum( Integer.MAX_VALUE );
+        GridData lengthSpinnerGridData = new GridData( SWT.NONE, SWT.NONE, false, false );
+        lengthSpinnerGridData.widthHint = 42;
+        lengthSpinner.setLayoutData( lengthSpinnerGridData );
+
+        // 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
+        new Label( composite, SWT.NONE );
+        obsoleteCheckbox = new Button( propertiesGroup, SWT.CHECK );
+        obsoleteCheckbox.setText( "Obsolete" );
+
+        // Single value
+        new Label( composite, SWT.NONE );
+        singleValueCheckbox = new Button( propertiesGroup, SWT.CHECK );
+        singleValueCheckbox.setText( "Single Value" );
+
+        // Collective
+        new Label( composite, SWT.NONE );
+        collectiveCheckbox = new Button( propertiesGroup, SWT.CHECK );
+        collectiveCheckbox.setText( "Collective" );
+
+        // No User Modification
+        new Label( composite, SWT.NONE );
+        noUserModificationCheckbox = new Button( propertiesGroup, SWT.CHECK );
+        noUserModificationCheckbox.setText( "No User Modification" );
+
+        initFields();
+
+        setControl( composite );
+    }
+
+
+    /**
+     * Initializes the UI fields.
+     */
+    @SuppressWarnings("unchecked")
+    private void initFields()
+    {
+        if ( schemaHandler != null )
+        {
+            // Getting the syntaxes
+            List<Object> syntaxes = new ArrayList( schemaHandler.getSyntaxes() );
+            // Adding the (None) Syntax
+            String none = "(None)";
+            syntaxes.add( none );
+
+            // Sorting the syntaxes
+            Collections.sort( syntaxes, new Comparator<Object>()
+            {
+                public int compare( Object o1, Object o2 )
+                {
+                    if ( ( o1 instanceof SyntaxImpl ) && ( o2 instanceof SyntaxImpl ) )
+                    {
+                        String[] o1Names = ( ( SyntaxImpl ) o1 ).getNames();
+                        String[] o2Names = ( ( SyntaxImpl ) 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 SyntaxImpl ) )
+                    {
+                        return Integer.MIN_VALUE;
+                    }
+                    else if ( ( o1 instanceof SyntaxImpl ) && ( o2 instanceof String ) )
+                    {
+                        return Integer.MAX_VALUE;
+                    }
+
+                    // Default
+                    return o1.toString().compareToIgnoreCase( o2.toString() );
+                }
+            } );
+
+            // Setting the input
+            syntaxComboViewer.setInput( syntaxes );
+            syntaxComboViewer.setSelection( new StructuredSelection( none ) );
+        }
+    }
+
+
+    /**
+     * Verifies if the superior exists and displays an error if not.
+     */
+    private void verifySuperior()
+    {
+        String superior = superiorText.getText();
+        if ( ( superior != null ) && ( !superior.equals( "" ) ) )
+        {
+            if ( schemaHandler.getAttributeType( superiorText.getText() ) == null )
+            {
+                displayErrorMessage( "The superior attribute type does not exist." );
+                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 )
+    {
+        setErrorMessage( message );
+        setPageComplete( message == null );
+    }
+
+
+    /**
+     * Gets the superior value.
+     *
+     * @return
+     *      the superior value
+     */
+    public String getSuperiorValue()
+    {
+        String superior = superiorText.getText();
+        if ( ( superior != null ) && ( !superior.equals( "" ) ) )
+        {
+            return superior;
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    /**
+     * Gets the usage value.
+     *
+     * @return
+     *      the usage value
+     */
+    public UsageEnum getUsageValue()
+    {
+        StructuredSelection selection = ( StructuredSelection ) usageComboViewer.getSelection();
+        if ( !selection.isEmpty() )
+        {
+            String selectedUsage = ( String ) selection.getFirstElement();
+            if ( selectedUsage.equals( DIRECTORY_OPERATION ) )
+            {
+                return UsageEnum.DIRECTORY_OPERATION;
+            }
+            else if ( selectedUsage.equals( DISTRIBUTED_OPERATION ) )
+            {
+                return UsageEnum.DISTRIBUTED_OPERATION;
+            }
+            else if ( selectedUsage.equals( DSA_OPERATION ) )
+            {
+                return UsageEnum.DSA_OPERATION;
+            }
+            else if ( selectedUsage.equals( USER_APPLICATIONS ) )
+            {
+                return UsageEnum.USER_APPLICATIONS;
+            }
+            else
+            {
+                return UsageEnum.USER_APPLICATIONS;
+            }
+        }
+        else
+        {
+            return UsageEnum.USER_APPLICATIONS;
+        }
+    }
+
+
+    /**
+     * Gets the syntax value.
+     *
+     * @return
+     *      the syntax value
+     */
+    public String getSyntax()
+    {
+        Object selection = ( ( StructuredSelection ) syntaxComboViewer.getSelection() ).getFirstElement();
+
+        if ( selection instanceof SyntaxImpl )
+        {
+            return ( ( SyntaxImpl ) selection ).getOid();
+        }
+
+        return null;
+    }
+
+
+    /**
+     * Gets the syntax length value.
+     *
+     * @return
+     *      the syntax length value
+     */
+    public int getSyntaxLengthValue()
+    {
+        return lengthSpinner.getSelection();
+    }
+
+
+    /**
+     * Gets the 'Obsolete' value.
+     *
+     * @return
+     *      the 'Obsolete' value
+     */
+    public boolean getObsoleteValue()
+    {
+        return obsoleteCheckbox.getSelection();
+    }
+
+
+    /**
+     * Gets the 'Single Value' value
+     *
+     * @return
+     *      the 'Single Value' value
+     */
+    public boolean getSingleValueValue()
+    {
+        return singleValueCheckbox.getSelection();
+    }
+
+
+    /**
+     * Gets the 'Collective' value.
+     *
+     * @return
+     *      the 'Collective' value
+     */
+    public boolean getCollectiveValue()
+    {
+        return collectiveCheckbox.getSelection();
+    }
+
+
+    /**
+     * Gets the 'No User Modification' value.
+     *
+     * @return
+     *      the 'No User Modification' value
+     */
+    public boolean getNoUserModificationValue()
+    {
+        return noUserModificationCheckbox.getSelection();
+    }
+}

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

Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeGeneralWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeGeneralWizardPage.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeGeneralWizardPage.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeGeneralWizardPage.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 NewAttributeTypeWizard.
+ * <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 NewAttributeTypeGeneralWizardPage 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 NewAttributeTypeGeneralWizardPage.
+     */
+    protected NewAttributeTypeGeneralWizardPage()
+    {
+        super( "NewAttributeTypeGeneralWizardPage" );
+        setTitle( "Attribute Type" );
+        setDescription( "Create a new attribute type." );
+        setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+            PluginConstants.IMG_ATTRIBUTE_TYPE_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/NewAttributeTypeGeneralWizardPage.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message