directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1215244 - in /directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards: MergeSchemasSelectionWizardPage.java MergeSchemasWizard.java
Date Fri, 16 Dec 2011 18:49:18 GMT
Author: pamarcelot
Date: Fri Dec 16 18:49:18 2011
New Revision: 1215244

URL: http://svn.apache.org/viewvc?rev=1215244&view=rev
Log:
Fixed NPEs.

Modified:
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/MergeSchemasSelectionWizardPage.java
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/MergeSchemasWizard.java

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/MergeSchemasSelectionWizardPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/MergeSchemasSelectionWizardPage.java?rev=1215244&r1=1215243&r2=1215244&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/MergeSchemasSelectionWizardPage.java
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/MergeSchemasSelectionWizardPage.java
Fri Dec 16 18:49:18 2011
@@ -144,14 +144,22 @@ public class MergeSchemasSelectionWizard
                 if ( parentElement instanceof AttributeTypeFolder )
                 {
                     AttributeTypeFolder folder = ( AttributeTypeFolder ) parentElement;
-                    List<AttributeType> attributeTypes = folder.schema.getAttributeTypes();
-                    return attributeTypes.toArray();
+                    List<AttributeTypeWrapper> attributeTypeWrappers = new ArrayList<AttributeTypeWrapper>();
+                    for ( AttributeType attributeType : folder.schema.getAttributeTypes()
)
+                    {
+                        attributeTypeWrappers.add( new AttributeTypeWrapper( attributeType,
folder ) );
+                    }
+                    return attributeTypeWrappers.toArray();
                 }
                 if ( parentElement instanceof ObjectClassFolder )
                 {
                     ObjectClassFolder folder = ( ObjectClassFolder ) parentElement;
-                    List<ObjectClass> objectClasses = folder.schema.getObjectClasses();
-                    return objectClasses.toArray();
+                    List<ObjectClassWrapper> objectClassWrappers = new ArrayList<ObjectClassWrapper>();
+                    for ( ObjectClass objectClass : folder.schema.getObjectClasses() )
+                    {
+                        objectClassWrappers.add( new ObjectClassWrapper( objectClass, folder
) );
+                    }
+                    return objectClassWrappers.toArray();
                 }
 
                 return new Object[0];
@@ -177,26 +185,26 @@ public class MergeSchemasSelectionWizard
                 {
                     return Messages.getString( "MergeSchemasSelectionWizardPage.AttributeTypes"
); //$NON-NLS-1$
                 }
-                else if ( element instanceof AttributeType )
+                else if ( element instanceof AttributeTypeWrapper )
                 {
-                    AttributeType at = ( ( AttributeType ) element );
+                    AttributeType at = ( ( AttributeTypeWrapper ) element ).attributeType;
                     List<String> names = at.getNames();
                     if ( ( names != null ) && ( names.size() > 0 ) )
                     {
-                        return names.get(0);
+                        return names.get( 0 );
                     }
                     else
                     {
                         return at.getOid();
                     }
                 }
-                else if ( element instanceof ObjectClass )
+                else if ( element instanceof ObjectClassWrapper )
                 {
-                    ObjectClass oc = ( ( ObjectClass ) element );
+                    ObjectClass oc = ( ( ObjectClassWrapper ) element ).objectClass;
                     List<String> names = oc.getNames();
                     if ( ( names != null ) && ( names.size() > 0 ) )
                     {
-                        return names.get(0);
+                        return names.get( 0 );
                     }
                     else
                     {
@@ -234,11 +242,11 @@ public class MergeSchemasSelectionWizard
                 {
                     return Activator.getDefault().getImage( PluginConstants.IMG_FOLDER_AT
);
                 }
-                else if ( element instanceof AttributeType )
+                else if ( element instanceof AttributeTypeWrapper )
                 {
                     return Activator.getDefault().getImage( PluginConstants.IMG_ATTRIBUTE_TYPE
);
                 }
-                else if ( element instanceof ObjectClass )
+                else if ( element instanceof ObjectClassWrapper )
                 {
                     return Activator.getDefault().getImage( PluginConstants.IMG_OBJECT_CLASS
);
                 }
@@ -355,4 +363,30 @@ public class MergeSchemasSelectionWizard
             this.schema = schema;
         }
     }
+
+    class ObjectClassWrapper
+    {
+        ObjectClass objectClass;
+        ObjectClassFolder folder;
+
+
+        public ObjectClassWrapper( ObjectClass objectClass, ObjectClassFolder folder )
+        {
+            this.objectClass = objectClass;
+            this.folder = folder;
+        }
+    }
+
+    class AttributeTypeWrapper
+    {
+        AttributeType attributeType;
+        AttributeTypeFolder folder;
+
+
+        public AttributeTypeWrapper( AttributeType attributeType, AttributeTypeFolder folder
)
+        {
+            this.attributeType = attributeType;
+            this.folder = folder;
+        }
+    }
 }

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/MergeSchemasWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/MergeSchemasWizard.java?rev=1215244&r1=1215243&r2=1215244&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/MergeSchemasWizard.java
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/MergeSchemasWizard.java
Fri Dec 16 18:49:18 2011
@@ -35,7 +35,9 @@ import org.apache.directory.studio.schem
 import org.apache.directory.studio.schemaeditor.model.Schema;
 import org.apache.directory.studio.schemaeditor.view.dialogs.MessageDialogWithTextarea;
 import org.apache.directory.studio.schemaeditor.view.wizards.MergeSchemasSelectionWizardPage.AttributeTypeFolder;
+import org.apache.directory.studio.schemaeditor.view.wizards.MergeSchemasSelectionWizardPage.AttributeTypeWrapper;
 import org.apache.directory.studio.schemaeditor.view.wizards.MergeSchemasSelectionWizardPage.ObjectClassFolder;
+import org.apache.directory.studio.schemaeditor.view.wizards.MergeSchemasSelectionWizardPage.ObjectClassWrapper;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.osgi.util.NLS;
@@ -156,22 +158,18 @@ public class MergeSchemasWizard extends 
                         replaceUnknownSyntax, mergeDependencies, pullUpAttributes );
                 }
             }
-            if ( sourceObject instanceof AttributeType )
+            if ( sourceObject instanceof AttributeTypeWrapper )
             {
-                AttributeType at = ( AttributeType ) sourceObject;
-                Schema targetSchema = getTargetSchema(
-                    Activator.getDefault().getSchemaHandler().getSchema( at.getSchemaName()
).getProject(),
-                    targetProject, targetSchemas );
-                mergeAttributeType( at, targetProject, targetSchema, processedObjects, errorMessages,
+                AttributeTypeWrapper atw = ( AttributeTypeWrapper ) sourceObject;
+                Schema targetSchema = getTargetSchema( atw.folder.schema.getProject(), targetProject,
targetSchemas );
+                mergeAttributeType( atw.attributeType, targetProject, targetSchema, processedObjects,
errorMessages,
                     replaceUnknownSyntax, mergeDependencies, pullUpAttributes );
             }
-            if ( sourceObject instanceof ObjectClass )
+            if ( sourceObject instanceof ObjectClassWrapper )
             {
-                ObjectClass oc = ( ObjectClass ) sourceObject;
-                Schema targetSchema = getTargetSchema(
-                    Activator.getDefault().getSchemaHandler().getSchema( oc.getSchemaName()
).getProject(),
-                    targetProject, targetSchemas );
-                mergeObjectClass( oc, targetProject, targetSchema, processedObjects, errorMessages,
+                ObjectClassWrapper ocw = ( ObjectClassWrapper ) sourceObject;
+                Schema targetSchema = getTargetSchema( ocw.folder.schema.getProject(), targetProject,
targetSchemas );
+                mergeObjectClass( ocw.objectClass, targetProject, targetSchema, processedObjects,
errorMessages,
                     replaceUnknownSyntax, mergeDependencies, pullUpAttributes );
             }
         }



Mime
View raw message