directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r560910 - in /directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor: controller/ view/editors/attributetype/ view/editors/objectclass/
Date Mon, 30 Jul 2007 09:58:40 GMT
Author: pamarcelot
Date: Mon Jul 30 02:58:39 2007
New Revision: 560910

URL: http://svn.apache.org/viewvc?view=rev&rev=560910
Log:
Updated the OC Editor to automatically be closed when the OC or the parent Schema it belongs
to is removed.

Modified:
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaHandler.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditor.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorOverviewPage.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/objectclass/ObjectClassEditor.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/objectclass/ObjectClassEditorOverviewPage.java

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaHandler.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaHandler.java?view=diff&rev=560910&r1=560909&r2=560910
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaHandler.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaHandler.java
Mon Jul 30 02:58:39 2007
@@ -954,7 +954,7 @@
                 ( ( SchemaListener ) object ).attributeTypeRemoved( at );
             }
         }
-        
+
         // Attribute Type Listeners
         List<?> atListeners = ( List<?> ) attributeTypeListeners.get( at );
         if ( atListeners != null )
@@ -1040,6 +1040,16 @@
             for ( Object object : listeners.toArray() )
             {
                 ( ( SchemaListener ) object ).objectClassModified( oc );
+            }
+        }
+
+        // Object Class Listeners
+        List<?> ocListeners = ( List<?> ) objectClassListeners.get( oc );
+        if ( ocListeners != null )
+        {
+            for ( Object object : ocListeners.toArray() )
+            {
+                ( ( ObjectClassListener ) object ).objectClassRemoved();
             }
         }
     }

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditor.java?view=diff&rev=560910&r1=560909&r2=560910
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditor.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditor.java
Mon Jul 30 02:58:39 2007
@@ -55,6 +55,9 @@
 
     /** The ID of the Editor */
     public static final String ID = Activator.PLUGIN_ID + ".view.attributeTypeEditor"; //$NON-NLS-1$
+    
+    /** The editor */
+    private AttributeTypeEditor instance;
 
     /** The dirty state flag */
     private boolean dirty = false;
@@ -100,9 +103,6 @@
         }
     };
 
-    /** The editor */
-    private AttributeTypeEditor instance;
-
     /** The attribute type listener */
     private AttributeTypeListener attributeTypeListener = new AttributeTypeAdapter()
     {
@@ -117,7 +117,7 @@
     {
         public void schemaRemoved( Schema schema )
         {
-            if ( schema.equals( originalSchema )  )
+            if ( schema.equals( originalSchema ) )
             {
                 getEditorSite().getPage().closeEditor( instance, false );
             }
@@ -137,7 +137,7 @@
         setPartName( input.getName() );
 
         originalAttributeType = ( ( AttributeTypeEditorInput ) getEditorInput() ).getAttributeType();
-        modifiedAttributeType = ( AttributeTypeImpl ) PluginUtils.getClone( originalAttributeType
);
+        modifiedAttributeType = PluginUtils.getClone( originalAttributeType );
 
         SchemaHandler schemaHandler = Activator.getDefault().getSchemaHandler();
         originalSchema = schemaHandler.getSchema( originalAttributeType.getSchema() );

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorOverviewPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorOverviewPage.java?view=diff&rev=560910&r1=560909&r2=560910
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorOverviewPage.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorOverviewPage.java
Mon Jul 30 02:58:39 2007
@@ -87,6 +87,7 @@
     /** The modified object class */
     private AttributeTypeImpl modifiedAttributeType;
 
+    /** The original schema */
     private Schema originalSchema;
 
     /** The SchemaHandler */

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/objectclass/ObjectClassEditor.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/ObjectClassEditor.java?view=diff&rev=560910&r1=560909&r2=560910
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/objectclass/ObjectClassEditor.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/objectclass/ObjectClassEditor.java
Mon Jul 30 02:58:39 2007
@@ -23,7 +23,13 @@
 
 import org.apache.directory.studio.apacheds.schemaeditor.Activator;
 import org.apache.directory.studio.apacheds.schemaeditor.PluginUtils;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.ObjectClassAdapter;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.ObjectClassListener;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandler;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerAdapter;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener;
 import org.apache.directory.studio.apacheds.schemaeditor.model.ObjectClassImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.model.Schema;
 import org.apache.log4j.Logger;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.jface.dialogs.IPageChangedListener;
@@ -48,6 +54,9 @@
     /** The ID of the Editor */
     public static final String ID = Activator.PLUGIN_ID + ".view.objectClassEditor"; //$NON-NLS-1$
 
+    /** The editor */
+    private ObjectClassEditor instance;
+
     /** The Overview page */
     private ObjectClassEditorOverviewPage overview;
 
@@ -63,6 +72,9 @@
     /** The object class used to save modifications */
     private ObjectClassImpl modifiedObjectClass;
 
+    /** The originalSchema */
+    private Schema originalSchema;
+
     /** The listener for page changed */
     private IPageChangedListener pageChangedListener = new IPageChangedListener()
     {
@@ -90,14 +102,26 @@
         }
     };
 
+    /** The object class listener */
+    private ObjectClassListener objectClassListener = new ObjectClassAdapter()
+    {
+        public void objectClassRemoved()
+        {
+            getEditorSite().getPage().closeEditor( instance, false );
+        }
+    };
 
-    /**
-     * Default constructor
-     */
-    public ObjectClassEditor()
+    /** The SchemaHandler listener */
+    private SchemaHandlerListener schemaHandlerListener = new SchemaHandlerAdapter()
     {
-        super();
-    }
+        public void schemaRemoved( Schema schema )
+        {
+            if ( schema.equals( originalSchema ) )
+            {
+                getEditorSite().getPage().closeEditor( instance, false );
+            }
+        }
+    };
 
 
     /* (non-Javadoc)
@@ -105,16 +129,34 @@
      */
     public void init( IEditorSite site, IEditorInput input ) throws PartInitException
     {
+        instance = this;
+
         setSite( site );
         setInput( input );
         setPartName( input.getName() );
 
         originalObjectClass = ( ( ObjectClassEditorInput ) getEditorInput() ).getObjectClass();
-        //        originalObjectClass.setEditor( this );
-
         modifiedObjectClass = PluginUtils.getClone( originalObjectClass );
 
+        SchemaHandler schemaHandler = Activator.getDefault().getSchemaHandler();
+        originalSchema = schemaHandler.getSchema( originalObjectClass.getSchema() );
+        schemaHandler.addListener( originalObjectClass, objectClassListener );
+        schemaHandler.addListener( schemaHandlerListener );
+
         addPageChangedListener( pageChangedListener );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.forms.editor.FormEditor#dispose()
+     */
+    public void dispose()
+    {
+        SchemaHandler schemaHandler = Activator.getDefault().getSchemaHandler();
+        schemaHandler.removeListener( originalObjectClass, objectClassListener );
+        schemaHandler.removeListener( schemaHandlerListener );
+
+        super.dispose();
     }
 
 

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=560910&r1=560909&r2=560910
==============================================================================
--- 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
Mon Jul 30 02:58:39 2007
@@ -97,6 +97,9 @@
     /** The modified object class */
     private ObjectClassImpl modifiedObjectClass;
 
+    /** The original schema */
+    private Schema originalSchema;
+
     /** The SchemaHandler */
     private SchemaHandler schemaHandler;
 
@@ -180,7 +183,10 @@
          */
         public void objectClassRemoved( ObjectClassImpl oc )
         {
-            refreshUI();
+            if ( !oc.equals( originalObjectClass ) )
+            {
+                refreshUI();
+            }
         }
 
 
@@ -198,7 +204,10 @@
          */
         public void schemaRemoved( Schema schema )
         {
-            refreshUI();
+            if ( !schema.equals( originalSchema ) )
+            {
+                refreshUI();
+            }
         }
 
 
@@ -841,6 +850,7 @@
         // Getting the original and modified object classes
         modifiedObjectClass = ( ( ObjectClassEditor ) getEditor() ).getModifiedObjectClass();
         originalObjectClass = ( ( ObjectClassEditor ) getEditor() ).getOriginalObjectClass();
+        originalSchema = schemaHandler.getSchema( originalObjectClass.getSchema() );
 
         // Creating the base UI
         ScrolledForm form = managedForm.getForm();
@@ -1219,7 +1229,6 @@
     public void dispose()
     {
         schemaHandler.removeListener( schemaHandlerListener );
-        removeListeners();
 
         super.dispose();
     }



Mime
View raw message