directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r612496 - in /directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor: ./ controller/ controller/actions/ view/widget/ view/wizards/
Date Wed, 16 Jan 2008 16:14:55 GMT
Author: pamarcelot
Date: Wed Jan 16 08:14:52 2008
New Revision: 612496

URL: http://svn.apache.org/viewvc?rev=612496&view=rev
Log:
Fix for DIRSTUDIO-237 (It would be good to be able to import 'core' schemas into an existing
project).

Added:
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ImportCoreSchemasAction.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/CoreSchemasSelectionWidget.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportCoreSchemasWizard.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportCoreSchemasWizardPage.java
Modified:
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginConstants.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginUtils.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SchemaViewController.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/DifferencesWidget.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizard.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizardSchemasSelectionPage.java

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginConstants.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginConstants.java?rev=612496&r1=612495&r2=612496&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginConstants.java
(original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginConstants.java
Wed Jan 16 08:14:52 2008
@@ -121,6 +121,7 @@
         + ".commands.exportSchemasAsOpenLDAP";
     public static final String CMD_EXPORT_SCHEMAS_AS_XML = Activator.PLUGIN_ID + ".commands.exportSchemasAsXML";
     public static final String CMD_EXPORT_SCHEMAS_FOR_ADS = Activator.PLUGIN_ID + ".commands.exportSchemasForADS";
+    public static final String CMD_IMPORT_CORE_SCHEMAS = Activator.PLUGIN_ID + ".commands.importCoreSchemas";
     public static final String CMD_IMPORT_PROJECTS = Activator.PLUGIN_ID + ".commands.importProjects";
     public static final String CMD_IMPORT_SCHEMAS_FROM_OPENLDAP = Activator.PLUGIN_ID
         + ".commands.importSchemasFromOpenLDAP";

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginUtils.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginUtils.java?rev=612496&r1=612495&r2=612496&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginUtils.java
(original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginUtils.java
Wed Jan 16 08:14:52 2008
@@ -46,7 +46,7 @@
 import org.apache.directory.studio.schemaeditor.model.io.XMLSchemaFileImportException;
 import org.apache.directory.studio.schemaeditor.model.io.XMLSchemaFileImporter;
 import org.apache.directory.studio.schemaeditor.view.ViewUtils;
-import org.apache.directory.studio.schemaeditor.view.wizards.NewProjectWizardSchemasSelectionPage.ServerTypeEnum;
+import org.apache.directory.studio.schemaeditor.view.widget.CoreSchemasSelectionWidget.ServerTypeEnum;
 import org.dom4j.io.OutputFormat;
 import org.dom4j.io.XMLWriter;
 import org.eclipse.core.runtime.CoreException;

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SchemaViewController.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SchemaViewController.java?rev=612496&r1=612495&r2=612496&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SchemaViewController.java
(original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SchemaViewController.java
Wed Jan 16 08:14:52 2008
@@ -31,6 +31,7 @@
 import org.apache.directory.studio.schemaeditor.controller.actions.ExportSchemasAsOpenLdapAction;
 import org.apache.directory.studio.schemaeditor.controller.actions.ExportSchemasAsXmlAction;
 import org.apache.directory.studio.schemaeditor.controller.actions.ExportSchemasForADSAction;
+import org.apache.directory.studio.schemaeditor.controller.actions.ImportCoreSchemasAction;
 import org.apache.directory.studio.schemaeditor.controller.actions.ImportSchemasFromOpenLdapAction;
 import org.apache.directory.studio.schemaeditor.controller.actions.ImportSchemasFromXmlAction;
 import org.apache.directory.studio.schemaeditor.controller.actions.LinkWithEditorSchemaViewAction;
@@ -226,6 +227,7 @@
     private OpenElementAction openElement;
     private OpenTypeHierarchyAction openTypeHierarchy;
     private DeleteSchemaElementAction deleteSchemaElement;
+    private ImportCoreSchemasAction importCoreSchemas;
     private ImportSchemasFromOpenLdapAction importSchemasFromOpenLdap;
     private ImportSchemasFromXmlAction importSchemasFromXml;
     private ExportSchemasAsOpenLdapAction exportSchemasAsOpenLdap;
@@ -276,6 +278,7 @@
         openElement = new OpenElementAction( viewer );
         openTypeHierarchy = new OpenTypeHierarchyAction( viewer );
         deleteSchemaElement = new DeleteSchemaElementAction( viewer );
+        importCoreSchemas = new ImportCoreSchemasAction();
         importSchemasFromOpenLdap = new ImportSchemasFromOpenLdapAction();
         importSchemasFromXml = new ImportSchemasFromXmlAction();
         exportSchemasAsOpenLdap = new ExportSchemasAsOpenLdapAction( viewer );
@@ -352,6 +355,8 @@
                 manager.add( deleteSchemaElement );
                 manager.add( new Separator() );
                 manager.add( importManager );
+                importManager.add( importCoreSchemas );
+                importManager.add( new Separator() );
                 importManager.add( importSchemasFromOpenLdap );
                 importManager.add( importSchemasFromXml );
                 manager.add( exportManager );

Added: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ImportCoreSchemasAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ImportCoreSchemasAction.java?rev=612496&view=auto
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ImportCoreSchemasAction.java
(added)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/ImportCoreSchemasAction.java
Wed Jan 16 08:14:52 2008
@@ -0,0 +1,108 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.schemaeditor.controller.actions;
+
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.apache.directory.studio.schemaeditor.view.wizards.ImportCoreSchemasWizard;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This action launches the {@link ImportCoreSchemasWizard}.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ImportCoreSchemasAction extends Action implements IWorkbenchWindowActionDelegate
+{
+    /**
+     * Creates a new instance of ImportCoreSchemasAction.
+     */
+    public ImportCoreSchemasAction()
+    {
+        super( "Core schemas files" );
+        setToolTipText( getText() );
+        setId( PluginConstants.CMD_IMPORT_CORE_SCHEMAS );
+        setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+            PluginConstants.IMG_SCHEMAS_IMPORT ) );
+        setEnabled( true );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.action.Action#run()
+     */
+    public void run()
+    {
+        // Instantiates and initializes the wizard
+        ImportCoreSchemasWizard wizard = new ImportCoreSchemasWizard();
+        wizard.init( PlatformUI.getWorkbench(), StructuredSelection.EMPTY );
+        // Instantiates the wizard container with the wizard and opens it
+        WizardDialog dialog = new WizardDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
wizard );
+        dialog.create();
+        dialog.open();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+     */
+    public void run( IAction action )
+    {
+        run();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
+     */
+    public void dispose()
+    {
+        // Nothing to do
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
+     */
+    public void init( IWorkbenchWindow window )
+    {
+        // Nothing to do
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
org.eclipse.jface.viewers.ISelection)
+     */
+    public void selectionChanged( IAction action, ISelection selection )
+    {
+        // Nothing to do
+    }
+}

Added: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/CoreSchemasSelectionWidget.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/CoreSchemasSelectionWidget.java?rev=612496&view=auto
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/CoreSchemasSelectionWidget.java
(added)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/CoreSchemasSelectionWidget.java
Wed Jan 16 08:14:52 2008
@@ -0,0 +1,305 @@
+/*
+ *  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.widget;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+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.CheckboxTableViewer;
+import org.eclipse.jface.viewers.LabelProvider;
+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 implements a CoreSchemasSelectionWidget.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class CoreSchemasSelectionWidget
+{
+    /**
+     * This enum represents the different server types.
+     *
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     * @version $Rev$, $Date$
+     */
+    public enum ServerTypeEnum
+    {
+        APACHE_DS, OPENLDAP
+    }
+
+    /** The array containing the 'core' from Apache DS */
+    private static final String[] coreSchemasFromApacheDS = new String[]
+        { "apache", "apachedns", "apachemeta", "autofs", "collective", "corba", "core", "cosine",
"dhcp",
+            "inetorgperson", "java", "krb5kdc", "mozilla", "nis", "samba", "system" };
+
+    /** The array containing the 'core' from OpenLDAP */
+    private static final String[] coreSchemasFromOpenLdap = new String[]
+        { "corba", "core", "cosine", "dyngroup", "inetorgperson", "java", "misc", "nis",
"openldap", "ppolicy",
+            "system" };
+
+    // UI Fields
+    private Button typeApacheDSButton;
+    private Button typeOpenLDAPButton;
+    private CheckboxTableViewer coreSchemasTableViewer;
+
+
+    /**
+     * Creates the widget.
+     * 
+     * @param parent
+     *            the parent Composite
+     * @return
+     *      the associated composite
+     */
+    public Composite createWidget( Composite parent )
+    {
+        Composite composite = new Composite( parent, SWT.NONE );
+        composite.setLayout( new GridLayout( 2, false ) );
+        composite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
+
+        // Server Type Group
+        Group serverTypeGroup = new Group( composite, SWT.NONE );
+        serverTypeGroup.setText( "Server Type" );
+        serverTypeGroup.setLayout( new GridLayout( 2, false ) );
+        serverTypeGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2,
1 ) );
+
+        // Type Apache DS Button
+        typeApacheDSButton = new Button( serverTypeGroup, SWT.RADIO );
+        typeApacheDSButton.setText( "Apache DS" );
+        typeApacheDSButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                resetTableViewerWithCoreSchemasFromApacheDS();
+            }
+        } );
+
+        // Type OpenLDAP Button
+        typeOpenLDAPButton = new Button( serverTypeGroup, SWT.RADIO );
+        typeOpenLDAPButton.setText( "OpenLDAP" );
+        typeOpenLDAPButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                resetTableViewerWithCoreSchemasFromOpenLdap();
+            }
+        } );
+
+        // Core Schemas Label
+        Label coreSchemaslabel = new Label( composite, SWT.NONE );
+        coreSchemaslabel.setText( "Choose the 'core' schemas to include:" );
+        coreSchemaslabel.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2,
1 ) );
+
+        // Core Schemas TableViewer
+        coreSchemasTableViewer = new CheckboxTableViewer( new Table( composite, SWT.BORDER
| SWT.CHECK
+            | SWT.FULL_SELECTION ) );
+        GridData gridData = new GridData( SWT.FILL, SWT.FILL, true, true, 1, 2 );
+        gridData.heightHint = 127;
+        coreSchemasTableViewer.getTable().setLayoutData( gridData );
+        coreSchemasTableViewer.setContentProvider( new ArrayContentProvider() );
+        coreSchemasTableViewer.setLabelProvider( new LabelProvider()
+        {
+            public Image getImage( Object element )
+            {
+                return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, PluginConstants.IMG_SCHEMA
)
+                    .createImage();
+            }
+        } );
+
+        Button coreSchemasTableSelectAllButton = new Button( composite, SWT.PUSH );
+        coreSchemasTableSelectAllButton.setText( "Select All" );
+        coreSchemasTableSelectAllButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING,
false, false ) );
+        coreSchemasTableSelectAllButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                coreSchemasTableViewer.setAllChecked( true );
+            }
+        } );
+
+        Button coreSchemasTableDeselectAllButton = new Button( composite, SWT.PUSH );
+        coreSchemasTableDeselectAllButton.setText( "Deselect All" );
+        coreSchemasTableDeselectAllButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING,
false, false ) );
+        coreSchemasTableDeselectAllButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                coreSchemasTableViewer.setAllChecked( false );
+            }
+        } );
+
+        return composite;
+    }
+
+
+    /**
+     * Gets the checked 'core' schemas.
+     *
+     * @return
+     *      the checked 'core' schemas.
+     */
+    public String[] getCheckedCoreSchemas()
+    {
+        return Arrays.asList( coreSchemasTableViewer.getCheckedElements() ).toArray( new
String[0] );
+    }
+
+
+    /**
+     * Gets the grayed 'core' schemas.
+     *
+     * @return
+     *      the grayed 'core' schemas
+     */
+    public String[] getGrayedCoreSchemas()
+    {
+        return Arrays.asList( coreSchemasTableViewer.getGrayedElements() ).toArray( new String[0]
);
+    }
+
+
+    /**
+     * Gets the selected 'core' schemas.
+     *
+     * @return
+     *      the selected 'core' schemas
+     */
+    public String[] getSelectedCoreSchemas()
+    {
+        List<String> selectedSchemas = new ArrayList<String>();
+
+        selectedSchemas.addAll( Arrays.asList( getCheckedCoreSchemas() ) );
+        selectedSchemas.removeAll( Arrays.asList( getGrayedCoreSchemas() ) );
+
+        return selectedSchemas.toArray( new String[0] );
+    }
+
+
+    /**
+     * Gets the Server Type
+     *
+     * @return
+     *      the Server Type
+     */
+    public ServerTypeEnum getServerType()
+    {
+        if ( typeApacheDSButton.getSelection() )
+        {
+            return ServerTypeEnum.APACHE_DS;
+        }
+        else if ( typeOpenLDAPButton.getSelection() )
+        {
+            return ServerTypeEnum.OPENLDAP;
+        }
+        else
+        {
+            // Default
+            return null;
+        }
+    }
+
+
+    /**
+     * Initializes the widget.
+     *
+     * @param selectedButton
+     *      the selected button:
+     *      <ul>
+     *      <li>{@link ServerTypeEnum}.APACHE_DS for the "Apache DS" button</li>
+     *      <li>{@link ServerTypeEnum}.OPENLDAP for the "OpenLDAP" button</li>
+     *      </ul>
+     */
+    public void init( ServerTypeEnum selectedButton )
+    {
+        // Setting the selected button
+        if ( selectedButton != null )
+        {
+            switch ( selectedButton )
+            {
+                case APACHE_DS:
+                    typeApacheDSButton.setSelection( true );
+                    resetTableViewerWithCoreSchemasFromApacheDS();
+                    break;
+                case OPENLDAP:
+                    typeOpenLDAPButton.setSelection( true );
+                    resetTableViewerWithCoreSchemasFromOpenLdap();
+                    break;
+            }
+        }
+    }
+
+
+    /**
+     * Re-initializes the Table Viewer with the 'core' schemas from Apache DS.
+     */
+    private void resetTableViewerWithCoreSchemasFromApacheDS()
+    {
+        coreSchemasTableViewer.setAllChecked( false );
+        coreSchemasTableViewer.setInput( coreSchemasFromApacheDS );
+    }
+
+
+    /**
+     * Re-initializes the Table Viewer with the 'core' schemas from OpenLDAP.
+     */
+    private void resetTableViewerWithCoreSchemasFromOpenLdap()
+    {
+        coreSchemasTableViewer.setAllChecked( false );
+        coreSchemasTableViewer.setInput( coreSchemasFromOpenLdap );
+    }
+
+
+    /**
+     * Sets the checked 'core' schemas.
+     *
+     * @param checkedCoreSchemas
+     */
+    public void setCheckedCoreSchemas( String[] checkedCoreSchemas )
+    {
+        coreSchemasTableViewer.setCheckedElements( checkedCoreSchemas );
+    }
+
+
+    /**
+     * Sets the grayed 'core' schemas.
+     *
+     * @param grayedCoreSchemas
+     */
+    public void setGrayedCoreSchemas( String[] grayedCoreSchemas )
+    {
+        coreSchemasTableViewer.setGrayedElements( grayedCoreSchemas );
+    }
+}

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/DifferencesWidget.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/DifferencesWidget.java?rev=612496&r1=612495&r2=612496&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/DifferencesWidget.java
(original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/DifferencesWidget.java
Wed Jan 16 08:14:52 2008
@@ -381,7 +381,7 @@
 
 
     /**
-     * Disposes the SWT resources allocated by this dialog page.
+     * Disposes the SWT resources allocated by this widget.
      */
     public void dispose()
     {

Added: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportCoreSchemasWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportCoreSchemasWizard.java?rev=612496&view=auto
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportCoreSchemasWizard.java
(added)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportCoreSchemasWizard.java
Wed Jan 16 08:14:52 2008
@@ -0,0 +1,97 @@
+/*
+ *  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.PluginUtils;
+import org.apache.directory.studio.schemaeditor.controller.SchemaHandler;
+import org.apache.directory.studio.schemaeditor.model.Project;
+import org.apache.directory.studio.schemaeditor.model.Schema;
+import org.apache.directory.studio.schemaeditor.view.widget.CoreSchemasSelectionWidget.ServerTypeEnum;
+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 'core' schemas into a project.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ImportCoreSchemasWizard extends Wizard implements IImportWizard
+{
+    public static final String ID = Activator.PLUGIN_ID + ".wizards.ImportCoreSchemasWizard";
+
+    // The pages of the wizard
+    private ImportCoreSchemasWizardPage page;
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.wizard.Wizard#addPages()
+     */
+    public void addPages()
+    {
+        // Creating pages
+        page = new ImportCoreSchemasWizardPage();
+
+        // Adding pages
+        addPage( page );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.wizard.Wizard#performFinish()
+     */
+    public boolean performFinish()
+    {
+        String[] selectedSchemas = page.getSelectedSchemas();;
+        ServerTypeEnum serverType = page.getServerType();
+
+        Project project = Activator.getDefault().getProjectsHandler().getOpenProject();
+        if ( project != null )
+        {
+            if ( ( selectedSchemas != null ) && ( serverType != null ) )
+            {
+                SchemaHandler schemaHandler = project.getSchemaHandler();
+                for ( String selectedSchema : selectedSchemas )
+                {
+                    Schema schema = PluginUtils.loadCoreSchema( serverType, selectedSchema
);
+                    if ( schema != null )
+                    {
+                        schemaHandler.addSchema( schema );
+                    }
+                }
+            }
+        }
+
+        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 )
+    {
+    }
+}

Added: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportCoreSchemasWizardPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportCoreSchemasWizardPage.java?rev=612496&view=auto
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportCoreSchemasWizardPage.java
(added)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ImportCoreSchemasWizardPage.java
Wed Jan 16 08:14:52 2008
@@ -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 java.util.ArrayList;
+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.Project;
+import org.apache.directory.studio.schemaeditor.model.Schema;
+import org.apache.directory.studio.schemaeditor.view.widget.CoreSchemasSelectionWidget;
+import org.apache.directory.studio.schemaeditor.view.widget.CoreSchemasSelectionWidget.ServerTypeEnum;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class represents the {@link WizardPage} of the {@link ImportCoreSchemasWizard}.
+ * <p>
+ * It is used to let the user choose the 'core' schemas to import.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ImportCoreSchemasWizardPage extends WizardPage
+{
+    // UI Fields    
+    private CoreSchemasSelectionWidget coreSchemaSelectionWidget;
+
+
+    /**
+     * Creates a new instance of ImportCoreSchemasWizardPage.
+     */
+    protected ImportCoreSchemasWizardPage()
+    {
+        super( "ImportCoreSchemasWizardPage" );
+        setTitle( "Import core schemas" );
+        setDescription( "Please select the 'core' schemas 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 )
+    {
+        coreSchemaSelectionWidget = new CoreSchemasSelectionWidget();
+        Composite composite = coreSchemaSelectionWidget.createWidget( parent );
+        coreSchemaSelectionWidget.init( ServerTypeEnum.APACHE_DS );
+
+        Project project = Activator.getDefault().getProjectsHandler().getOpenProject();
+        if ( project != null )
+        {
+            List<Schema> schemas = project.getSchemaHandler().getSchemas();
+            List<String> schemaNames = new ArrayList<String>();
+            for ( Schema schema : schemas )
+            {
+                schemaNames.add( schema.getName() );
+            }
+
+            coreSchemaSelectionWidget.setGrayedCoreSchemas( schemaNames.toArray( new String[0]
) );
+        }
+
+        setControl( composite );
+    }
+
+
+    /**
+     * Gets the schemas selected by the User.
+     *
+     * @return
+     *      the selected schemas
+     */
+    public String[] getSelectedSchemas()
+    {
+        return coreSchemaSelectionWidget.getSelectedCoreSchemas();
+    }
+
+
+    /**
+     * Gets the Server Type
+     *
+     * @return
+     *      the Server Type
+     */
+    public ServerTypeEnum getServerType()
+    {
+        return coreSchemaSelectionWidget.getServerType();
+    }
+}

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizard.java?rev=612496&r1=612495&r2=612496&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizard.java
(original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizard.java
Wed Jan 16 08:14:52 2008
@@ -29,12 +29,13 @@
 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.controller.SchemaHandler;
 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.apache.directory.studio.schemaeditor.view.widget.CoreSchemasSelectionWidget.ServerTypeEnum;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.viewers.IStructuredSelection;
@@ -170,12 +171,13 @@
             ServerTypeEnum serverType = schemasSelectionPage.getServerType();
             if ( ( selectedSchemas != null ) && ( serverType != null ) )
             {
+                SchemaHandler schemaHandler = project.getSchemaHandler();
                 for ( String selectedSchema : selectedSchemas )
                 {
                     Schema schema = PluginUtils.loadCoreSchema( serverType, selectedSchema
);
                     if ( schema != null )
                     {
-                        project.getSchemaHandler().addSchema( schema );
+                        schemaHandler.addSchema( schema );
                     }
                 }
             }

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizardSchemasSelectionPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizardSchemasSelectionPage.java?rev=612496&r1=612495&r2=612496&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizardSchemasSelectionPage.java
(original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizardSchemasSelectionPage.java
Wed Jan 16 08:14:52 2008
@@ -20,25 +20,12 @@
 package org.apache.directory.studio.schemaeditor.view.wizards;
 
 
-import java.util.Arrays;
-
 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.CheckboxTableViewer;
-import org.eclipse.jface.viewers.LabelProvider;
+import org.apache.directory.studio.schemaeditor.view.widget.CoreSchemasSelectionWidget;
+import org.apache.directory.studio.schemaeditor.view.widget.CoreSchemasSelectionWidget.ServerTypeEnum;
 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;
 
 
@@ -52,10 +39,8 @@
  */
 public class NewProjectWizardSchemasSelectionPage extends WizardPage
 {
-    // UI Fields
-    private Button typeApacheDSButton;
-    private Button typeOpenLDAPButton;
-    private CheckboxTableViewer coreSchemasTableViewer;
+    // UI Fields    
+    private CoreSchemasSelectionWidget coreSchemaSelectionWidget;
 
 
     /**
@@ -65,7 +50,7 @@
     {
         super( "NewProjectWizardSchemasSelectionPage" );
         setTitle( "Create a Schema project." );
-        setDescription( "Please select the core schemas to include in the project." );
+        setDescription( "Please select the 'core' schemas to include in the project." );
         setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
             PluginConstants.IMG_PROJECT_NEW_WIZARD ) );
     }
@@ -76,123 +61,15 @@
      */
     public void createControl( Composite parent )
     {
-        Composite composite = new Composite( parent, SWT.NONE );
-        composite.setLayout( new GridLayout( 2, false ) );
-        composite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
-
-        // Server Type Group
-        Group serverTypeGroup = new Group( composite, SWT.NONE );
-        serverTypeGroup.setText( "Server Type" );
-        serverTypeGroup.setLayout( new GridLayout( 2, false ) );
-        serverTypeGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2,
1 ) );
-
-        // Type Apache DS Button
-        typeApacheDSButton = new Button( serverTypeGroup, SWT.RADIO );
-        typeApacheDSButton.setText( "Apache DS" );
-        typeApacheDSButton.addSelectionListener( new SelectionAdapter()
-        {
-            public void widgetSelected( SelectionEvent e )
-            {
-                initCoreSchemasTableViewerApacheDS();
-            }
-        } );
-
-        // Type OpenLDAP Button
-        typeOpenLDAPButton = new Button( serverTypeGroup, SWT.RADIO );
-        typeOpenLDAPButton.setText( "OpenLDAP" );
-        typeOpenLDAPButton.addSelectionListener( new SelectionAdapter()
-        {
-            public void widgetSelected( SelectionEvent e )
-            {
-                initCoreSchemasTableViewerOpenLDAP();
-            }
-        } );
-
-        // Core Schemas Label
-        Label coreSchemaslabel = new Label( composite, SWT.NONE );
-        coreSchemaslabel.setText( "Choose the 'core' schemas to include:" );
-        coreSchemaslabel.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2,
1 ) );
-
-        // Core Schemas TableViewer
-        coreSchemasTableViewer = new CheckboxTableViewer( new Table( composite, SWT.BORDER
| SWT.CHECK
-            | SWT.FULL_SELECTION ) );
-        GridData gridData = new GridData( SWT.FILL, SWT.FILL, true, true, 1, 2 );
-        gridData.heightHint = 127;
-        coreSchemasTableViewer.getTable().setLayoutData( gridData );
-        coreSchemasTableViewer.setContentProvider( new ArrayContentProvider() );
-        coreSchemasTableViewer.setLabelProvider( new LabelProvider()
-        {
-            public Image getImage( Object element )
-            {
-                return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, PluginConstants.IMG_SCHEMA
)
-                    .createImage();
-            }
-        } );
-
-        Button coreSchemasTableSelectAllButton = new Button( composite, SWT.PUSH );
-        coreSchemasTableSelectAllButton.setText( "Select All" );
-        coreSchemasTableSelectAllButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING,
false, false ) );
-        coreSchemasTableSelectAllButton.addSelectionListener( new SelectionAdapter()
-        {
-            public void widgetSelected( SelectionEvent e )
-            {
-                coreSchemasTableViewer.setAllChecked( true );
-            }
-        } );
-
-        Button coreSchemasTableDeselectAllButton = new Button( composite, SWT.PUSH );
-        coreSchemasTableDeselectAllButton.setText( "Deselect All" );
-        coreSchemasTableDeselectAllButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING,
false, false ) );
-        coreSchemasTableDeselectAllButton.addSelectionListener( new SelectionAdapter()
-        {
-            public void widgetSelected( SelectionEvent e )
-            {
-                coreSchemasTableViewer.setAllChecked( false );
-            }
-        } );
-
-        initFields();
+        coreSchemaSelectionWidget = new CoreSchemasSelectionWidget();
+        Composite composite = coreSchemaSelectionWidget.createWidget( parent );
+        coreSchemaSelectionWidget.init( ServerTypeEnum.APACHE_DS );
 
         setControl( composite );
     }
 
 
     /**
-     * Initializes the UI Fields.
-     */
-    private void initFields()
-    {
-        typeApacheDSButton.setSelection( true );
-
-        initCoreSchemasTableViewerApacheDS();
-    }
-
-
-    /**
-     * Initializes the Core Schemas Table with Apache DS Schemas
-     */
-    private void initCoreSchemasTableViewerApacheDS()
-    {
-        coreSchemasTableViewer.setAllChecked( false );
-        coreSchemasTableViewer.setInput( new String[]
-            { "apache", "apachedns", "apachemeta", "autofs", "collective", "corba", "core",
"cosine", "dhcp",
-                "inetorgperson", "java", "krb5kdc", "mozilla", "nis", "samba", "system" }
);
-    }
-
-
-    /**
-     * Initializes the Core Schemas Table with Apache DS Schemas
-     */
-    private void initCoreSchemasTableViewerOpenLDAP()
-    {
-        coreSchemasTableViewer.setAllChecked( false );
-        coreSchemasTableViewer.setInput( new String[]
-            { "corba", "core", "cosine", "dyngroup", "inetorgperson", "java", "misc", "nis",
"openldap", "ppolicy",
-                "system" } );
-    }
-
-
-    /**
      * Gets the schemas selected by the User.
      *
      * @return
@@ -200,7 +77,7 @@
      */
     public String[] getSelectedSchemas()
     {
-        return Arrays.asList( coreSchemasTableViewer.getCheckedElements() ).toArray( new
String[0] );
+        return coreSchemaSelectionWidget.getCheckedCoreSchemas();
     }
 
 
@@ -212,29 +89,6 @@
      */
     public ServerTypeEnum getServerType()
     {
-        if ( typeApacheDSButton.getSelection() )
-        {
-            return ServerTypeEnum.APACHE_DS;
-        }
-        else if ( typeOpenLDAPButton.getSelection() )
-        {
-            return ServerTypeEnum.OPENLDAP;
-        }
-        else
-        {
-            // Default
-            return null;
-        }
-    }
-
-    /**
-     * This enum represents the different server types.
-     *
-     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
-     * @version $Rev$, $Date$
-     */
-    public enum ServerTypeEnum
-    {
-        APACHE_DS, OPENLDAP
+        return coreSchemaSelectionWidget.getServerType();
     }
 }



Mime
View raw message