directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r553910 - /directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/objectclass/
Date Fri, 06 Jul 2007 14:46:45 GMT
Author: pamarcelot
Date: Fri Jul  6 07:46:44 2007
New Revision: 553910

URL: http://svn.apache.org/viewvc?view=rev&rev=553910
Log:
Added SchemaHandler listener to the ObjectClassEditor.
Fixed a NPE in the Overview Page and in the SuperiorsTableContentProvider.

Modified:
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/objectclass/ObjectClassEditorInput.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/objectclass/ObjectClassEditorOverviewPage.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/objectclass/ObjectClassEditorSuperiorsTableContentProvider.java

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/objectclass/ObjectClassEditorInput.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/objectclass/ObjectClassEditorInput.java?view=diff&rev=553910&r1=553909&r2=553910
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/objectclass/ObjectClassEditorInput.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/objectclass/ObjectClassEditorInput.java
Fri Jul  6 07:46:44 2007
@@ -62,7 +62,6 @@
      */
     public ImageDescriptor getImageDescriptor()
     {
-        // TODO Auto-generated method stub
         return null;
     }
 

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/objectclass/ObjectClassEditorOverviewPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/objectclass/ObjectClassEditorOverviewPage.java?view=diff&rev=553910&r1=553909&r2=553910
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/objectclass/ObjectClassEditorOverviewPage.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/objectclass/ObjectClassEditorOverviewPage.java
Fri Jul  6 07:46:44 2007
@@ -28,8 +28,12 @@
 import org.apache.directory.shared.ldap.schema.ObjectClassTypeEnum;
 import org.apache.directory.studio.apacheds.schemaeditor.Activator;
 import org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandler;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener;
 import org.apache.directory.studio.apacheds.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.model.MatchingRuleImpl;
 import org.apache.directory.studio.apacheds.schemaeditor.model.ObjectClassImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.model.Schema;
+import org.apache.directory.studio.apacheds.schemaeditor.model.SyntaxImpl;
 import org.apache.directory.studio.apacheds.schemaeditor.view.ViewUtils;
 import org.apache.directory.studio.apacheds.schemaeditor.view.dialogs.AttributeTypeSelectionDialog;
 import org.apache.directory.studio.apacheds.schemaeditor.view.dialogs.EditAliasesDialog;
@@ -96,6 +100,135 @@
     /** The SchemaHandler */
     private SchemaHandler schemaHandler;
 
+    /** The SchemaHandler Listener */
+    private SchemaHandlerListener schemaHandlerListener = new SchemaHandlerListener()
+    {
+        /* (non-Javadoc)
+         * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener#attributeTypeAdded(org.apache.directory.studio.apacheds.schemaeditor.model.AttributeTypeImpl)
+         */
+        public void attributeTypeAdded( AttributeTypeImpl at )
+        {
+            refreshUI();
+        }
+
+
+        /* (non-Javadoc)
+         * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener#attributeTypeModified(org.apache.directory.studio.apacheds.schemaeditor.model.AttributeTypeImpl)
+         */
+        public void attributeTypeModified( AttributeTypeImpl at )
+        {
+            refreshUI();
+        }
+
+
+        /* (non-Javadoc)
+         * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener#attributeTypeRemoved(org.apache.directory.studio.apacheds.schemaeditor.model.AttributeTypeImpl)
+         */
+        public void attributeTypeRemoved( AttributeTypeImpl at )
+        {
+            refreshUI();
+        }
+
+
+        /* (non-Javadoc)
+         * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener#matchingRuleAdded(org.apache.directory.studio.apacheds.schemaeditor.model.MatchingRuleImpl)
+         */
+        public void matchingRuleAdded( MatchingRuleImpl mr )
+        {
+            refreshUI();
+        }
+
+
+        /* (non-Javadoc)
+         * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener#matchingRuleModified(org.apache.directory.studio.apacheds.schemaeditor.model.MatchingRuleImpl)
+         */
+        public void matchingRuleModified( MatchingRuleImpl mr )
+        {
+            refreshUI();
+        }
+
+
+        /* (non-Javadoc)
+         * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener#matchingRuleRemoved(org.apache.directory.studio.apacheds.schemaeditor.model.MatchingRuleImpl)
+         */
+        public void matchingRuleRemoved( MatchingRuleImpl mr )
+        {
+            refreshUI();
+        }
+
+
+        /* (non-Javadoc)
+         * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener#objectClassAdded(org.apache.directory.studio.apacheds.schemaeditor.model.ObjectClassImpl)
+         */
+        public void objectClassAdded( ObjectClassImpl oc )
+        {
+            refreshUI();
+        }
+
+
+        /* (non-Javadoc)
+         * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener#objectClassModified(org.apache.directory.studio.apacheds.schemaeditor.model.ObjectClassImpl)
+         */
+        public void objectClassModified( ObjectClassImpl oc )
+        {
+            refreshUI();
+        }
+
+
+        /* (non-Javadoc)
+         * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener#objectClassRemoved(org.apache.directory.studio.apacheds.schemaeditor.model.ObjectClassImpl)
+         */
+        public void objectClassRemoved( ObjectClassImpl oc )
+        {
+            refreshUI();
+        }
+
+
+        /* (non-Javadoc)
+         * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener#schemaAdded(org.apache.directory.studio.apacheds.schemaeditor.model.Schema)
+         */
+        public void schemaAdded( Schema schema )
+        {
+            refreshUI();
+        }
+
+
+        /* (non-Javadoc)
+         * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener#schemaRemoved(org.apache.directory.studio.apacheds.schemaeditor.model.Schema)
+         */
+        public void schemaRemoved( Schema schema )
+        {
+            refreshUI();
+        }
+
+
+        /* (non-Javadoc)
+         * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener#syntaxAdded(org.apache.directory.studio.apacheds.schemaeditor.model.SyntaxImpl)
+         */
+        public void syntaxAdded( SyntaxImpl syntax )
+        {
+            refreshUI();
+        }
+
+
+        /* (non-Javadoc)
+         * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener#syntaxModified(org.apache.directory.studio.apacheds.schemaeditor.model.SyntaxImpl)
+         */
+        public void syntaxModified( SyntaxImpl syntax )
+        {
+            refreshUI();
+        }
+
+
+        /* (non-Javadoc)
+         * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener#syntaxRemoved(org.apache.directory.studio.apacheds.schemaeditor.model.SyntaxImpl)
+         */
+        public void syntaxRemoved( SyntaxImpl syntax )
+        {
+            refreshUI();
+        }
+    };
+
     // UI fields
     private Label aliasesLabel;
     private Button aliasesButton;
@@ -301,20 +434,28 @@
         {
             AttributeTypeSelectionDialog dialog = new AttributeTypeSelectionDialog();
             List<AttributeTypeImpl> hiddenATs = new ArrayList<AttributeTypeImpl>();
-            for ( String must : modifiedObjectClass.getMustNamesList() )
+            String[] mustsHidden = modifiedObjectClass.getMustNamesList();
+            if ( mustsHidden != null )
             {
-                AttributeTypeImpl at = schemaHandler.getAttributeType( must );
-                if ( at != null )
+                for ( String must : mustsHidden )
                 {
-                    hiddenATs.add( at );
+                    AttributeTypeImpl at = schemaHandler.getAttributeType( must );
+                    if ( at != null )
+                    {
+                        hiddenATs.add( at );
+                    }
                 }
             }
-            for ( String may : modifiedObjectClass.getMayNamesList() )
+            String[] maysHidden = modifiedObjectClass.getMayNamesList();
+            if ( maysHidden != null )
             {
-                AttributeTypeImpl at = schemaHandler.getAttributeType( may );
-                if ( at != null )
+                for ( String may : maysHidden )
                 {
-                    hiddenATs.add( at );
+                    AttributeTypeImpl at = schemaHandler.getAttributeType( may );
+                    if ( at != null )
+                    {
+                        hiddenATs.add( at );
+                    }
                 }
             }
             dialog.setHiddenAttributeTypes( hiddenATs.toArray( new AttributeTypeImpl[0] )
);
@@ -332,9 +473,12 @@
 
             List<String> newMusts = new ArrayList<String>();
             String[] musts = modifiedObjectClass.getMustNamesList();
-            for ( String must : musts )
+            if ( musts != null )
             {
-                newMusts.add( must );
+                for ( String must : musts )
+                {
+                    newMusts.add( must );
+                }
             }
             newMusts.add( at.getNames()[0] );
             modifiedObjectClass.setMustNamesList( newMusts.toArray( new String[0] ) );
@@ -431,20 +575,28 @@
         {
             AttributeTypeSelectionDialog dialog = new AttributeTypeSelectionDialog();
             List<AttributeTypeImpl> hiddenATs = new ArrayList<AttributeTypeImpl>();
-            for ( String must : modifiedObjectClass.getMustNamesList() )
+            String[] mustsHidden = modifiedObjectClass.getMustNamesList();
+            if ( mustsHidden != null )
             {
-                AttributeTypeImpl at = schemaHandler.getAttributeType( must );
-                if ( at != null )
+                for ( String must : mustsHidden )
                 {
-                    hiddenATs.add( at );
+                    AttributeTypeImpl at = schemaHandler.getAttributeType( must );
+                    if ( at != null )
+                    {
+                        hiddenATs.add( at );
+                    }
                 }
             }
-            for ( String may : modifiedObjectClass.getMayNamesList() )
+            String[] maysHidden = modifiedObjectClass.getMayNamesList();
+            if ( maysHidden != null )
             {
-                AttributeTypeImpl at = schemaHandler.getAttributeType( may );
-                if ( at != null )
+                for ( String may : maysHidden )
                 {
-                    hiddenATs.add( at );
+                    AttributeTypeImpl at = schemaHandler.getAttributeType( may );
+                    if ( at != null )
+                    {
+                        hiddenATs.add( at );
+                    }
                 }
             }
             dialog.setHiddenAttributeTypes( hiddenATs.toArray( new AttributeTypeImpl[0] )
);
@@ -462,9 +614,12 @@
 
             List<String> newMays = new ArrayList<String>();
             String[] mays = modifiedObjectClass.getMayNamesList();
-            for ( String may : mays )
+            if ( mays != null )
             {
-                newMays.add( may );
+                for ( String may : mays )
+                {
+                    newMays.add( may );
+                }
             }
             newMays.add( at.getNames()[0] );
             modifiedObjectClass.setMayNamesList( newMays.toArray( new String[0] ) );
@@ -650,7 +805,7 @@
     {
         super( editor, ID, TITLE );
         schemaHandler = Activator.getDefault().getSchemaHandler();
-        //        schemaHandler.addListener( this ); // TODO
+        schemaHandler.addListener( schemaHandlerListener );
     }
 
 
@@ -963,34 +1118,6 @@
     }
 
 
-    //    /**
-    //     * Enalbes/Disables the UI fields
-    //     */
-    //    private void setFieldsEditableState()
-    //    {
-    //        if ( modifiedObjectClass.getOriginatingSchema().type == Schema.SchemaType.coreSchema
)
-    //        {
-    //            // If the object class is in a core-schema file, we disable editing
-    //            aliasesButton.setEnabled( false );
-    //            oidText.setEditable( false );
-    //            descriptionText.setEditable( false );
-    //            addButtonSuperiorsTable.setEnabled( false );
-    //            removeButtonSuperiorsTable.setEnabled( false );
-    //            classTypeCombo.setEnabled( false );
-    //            obsoleteCheckbox.setEnabled( false );
-    //            addButtonMandatoryTable.setEnabled( false );
-    //            removeButtonMandatoryTable.setEnabled( false );
-    //            addButtonOptionalTable.setEnabled( false );
-    //            removeButtonOptionalTable.setEnabled( false );
-    //        }
-    //        else
-    //        {
-    //            removeButtonSuperiorsTable.setEnabled( superiorsTable.getSelectionIndex()
!= -1 );
-    //            removeButtonMandatoryTable.setEnabled( mandatoryAttributesTable.getSelectionIndex()
!= -1 );
-    //            removeButtonOptionalTable.setEnabled( optionalAttributesTable.getSelectionIndex()
!= -1 );
-    //        }
-    //    }
-
     /**
      * Adds listeners to UI fields
      */
@@ -1056,30 +1183,15 @@
         removeListeners();
         fillInUiFields();
         addListeners();
-//        setFieldsEditableState();
     }
 
 
-//    /* (non-Javadoc)
-//     * @see org.apache.directory.studio.schemas.model.PoolListener#poolChanged(org.apache.directory.studio.schemas.model.SchemaPool,
org.apache.directory.studio.schemas.model.LDAPModelEvent)
-//     */
-//    public void poolChanged( SchemaPool p, LDAPModelEvent e )
-//    {
-//        removeListeners();
-//        fillInSuperiorsTable();
-//        fillInMandatoryAttributesTable();
-//        fillInOptionalAttributesTable();
-//        addListeners();
-//        setFieldsEditableState();
-//    }
-
-
     /* (non-Javadoc)
      * @see org.eclipse.ui.forms.editor.FormPage#dispose()
      */
     public void dispose()
     {
-//        schemaPool.removeListener( this );
+        schemaHandler.removeListener( schemaHandlerListener );
         removeListeners();
 
         super.dispose();

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/objectclass/ObjectClassEditorSuperiorsTableContentProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/objectclass/ObjectClassEditorSuperiorsTableContentProvider.java?view=diff&rev=553910&r1=553909&r2=553910
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/objectclass/ObjectClassEditorSuperiorsTableContentProvider.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/objectclass/ObjectClassEditorSuperiorsTableContentProvider.java
Fri Jul  6 07:46:44 2007
@@ -19,7 +19,6 @@
  */
 package org.apache.directory.studio.apacheds.schemaeditor.view.editors.objectclass;
 
-
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
@@ -32,101 +31,96 @@
 import org.eclipse.jface.viewers.IStructuredContentProvider;
 import org.eclipse.jface.viewers.Viewer;
 
-
 /**
- * This class is the Content Provider for the Superiors Table of the Object Class Editor.
- *
+ * This class is the Content Provider for the Superiors Table of the Object
+ * Class Editor.
+ * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class ObjectClassEditorSuperiorsTableContentProvider implements IStructuredContentProvider
-{
-    /** The SchemaHandler */
-    private SchemaHandler schemaHandler;
-
-
-    /**
-     * Creates a new instance of ObjectClassFormEditorSuperiorsTableContentProvider.
-     */
-    public ObjectClassEditorSuperiorsTableContentProvider()
-    {
-        schemaHandler = Activator.getDefault().getSchemaHandler();
-    }
-
-
-    /* (non-Javadoc)
-     * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
-     */
-    public Object[] getElements( Object inputElement )
-    {
-        if ( inputElement instanceof String[] )
-        {
-            List<Object> results = new ArrayList<Object>();
-
-            String[] superiors = ( String[] ) inputElement;
-            for ( String superior : superiors )
-            {
-                ObjectClassImpl oc = schemaHandler.getObjectClass( superior );
-                if ( oc != null )
-                {
-                    results.add( oc );
-                }
-                else
-                {
-                    results.add( new NonExistingObjectClass( superior ) );
-                }
-            }
-
-            // Sorting Elements
-            Collections.sort( results, new Comparator<Object>()
-            {
-                public int compare( Object o1, Object o2 )
-                {
-                    if ( o1 instanceof ObjectClassImpl && o2 instanceof ObjectClassImpl
)
-                    {
-                        return ( ( ObjectClassImpl ) o1 ).getNames()[0].compareToIgnoreCase(
( ( ObjectClassImpl ) o2 )
-                            .getNames()[0] );
-                    }
-                    else if ( o1 instanceof ObjectClassImpl && o2 instanceof NonExistingObjectClass
)
-                    {
-                        return ( ( ObjectClassImpl ) o1 ).getNames()[0]
-                            .compareToIgnoreCase( ( ( NonExistingObjectClass ) o2 ).getName()
);
-                    }
-                    else if ( o1 instanceof NonExistingObjectClass && o2 instanceof
ObjectClassImpl )
-                    {
-                        return ( ( NonExistingObjectClass ) o1 ).getName().compareToIgnoreCase(
-                            ( ( ObjectClassImpl ) o2 ).getNames()[0] );
-                    }
-                    else if ( o1 instanceof NonExistingObjectClass && o2 instanceof
NonExistingObjectClass )
-                    {
-                        return ( ( NonExistingObjectClass ) o1 ).getName().compareToIgnoreCase(
-                            ( ( NonExistingObjectClass ) o2 ).getName() );
-                    }
-
-                    return 0;
-                }
-            } );
-
-            return results.toArray();
-        }
-
-        // Default
-        return null;
-    }
-
-
-    /* (non-Javadoc)
-     * @see org.eclipse.jface.viewers.IContentProvider#dispose()
-     */
-    public void dispose()
-    {
-    }
-
-
-    /* (non-Javadoc)
-     * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
java.lang.Object, java.lang.Object)
-     */
-    public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
-    {
-    }
+public class ObjectClassEditorSuperiorsTableContentProvider implements
+		IStructuredContentProvider {
+	/** The SchemaHandler */
+	private SchemaHandler schemaHandler;
+
+	/**
+	 * Creates a new instance of
+	 * ObjectClassFormEditorSuperiorsTableContentProvider.
+	 */
+	public ObjectClassEditorSuperiorsTableContentProvider() {
+		schemaHandler = Activator.getDefault().getSchemaHandler();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+	 */
+	public Object[] getElements(Object inputElement) {
+		if (inputElement instanceof String[]) {
+			List<Object> results = new ArrayList<Object>();
+
+			String[] superiors = (String[]) inputElement;
+			for (String superior : superiors) {
+				ObjectClassImpl oc = schemaHandler.getObjectClass(superior);
+				if (oc != null) {
+					results.add(oc);
+				} else {
+					results.add(new NonExistingObjectClass(superior));
+				}
+			}
+
+			// Sorting Elements
+			Collections.sort(results, new Comparator<Object>() {
+				public int compare(Object o1, Object o2) {
+					if (o1 instanceof ObjectClassImpl
+							&& o2 instanceof ObjectClassImpl) {
+						return ((ObjectClassImpl) o1).getNames()[0]
+								.compareToIgnoreCase(((ObjectClassImpl) o2)
+										.getNames()[0]);
+					} else if (o1 instanceof ObjectClassImpl
+							&& o2 instanceof NonExistingObjectClass) {
+						return ((ObjectClassImpl) o1).getNames()[0]
+								.compareToIgnoreCase(((NonExistingObjectClass) o2)
+										.getName());
+					} else if (o1 instanceof NonExistingObjectClass
+							&& o2 instanceof ObjectClassImpl) {
+						return ((NonExistingObjectClass) o1).getName()
+								.compareToIgnoreCase(
+										((ObjectClassImpl) o2).getNames()[0]);
+					} else if (o1 instanceof NonExistingObjectClass
+							&& o2 instanceof NonExistingObjectClass) {
+						return ((NonExistingObjectClass) o1)
+								.getName()
+								.compareToIgnoreCase(
+										((NonExistingObjectClass) o2).getName());
+					}
+
+					return 0;
+				}
+			});
+
+			return results.toArray();
+		}
+
+		// Default
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+	 */
+	public void dispose() {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
+	 *      java.lang.Object, java.lang.Object)
+	 */
+	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+	}
 }



Mime
View raw message