directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r514482 - in /directory/ldapstudio/trunk: ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/ ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/events/ ldapstudio-browser-core...
Date Sun, 04 Mar 2007 22:20:11 GMT
Author: seelmann
Date: Sun Mar  4 14:20:10 2007
New Revision: 514482

URL: http://svn.apache.org/viewvc?view=rev&rev=514482
Log:
Fix for DIRSTUDIO-66 (Refresh of the LDAP Browser viewer after import): 
o Improved cache update and initialization flags on LDIF import
o Added BulkModificationEvent that causes a complete refresh of the browser tree

Added:
    directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/events/BulkModificationEvent.java
Modified:
    directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/BrowserCoreMessages.java
    directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/internal/model/ConnectionModifyHandler.java
    directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/jobs/ImportLdifJob.java
    directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/resources/org/apache/directory/ldapstudio/browser/core/browsercoremessages.properties
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserViewUniversalListener.java
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/EntryEditorWidgetUniversalListener.java

Modified: directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/BrowserCoreMessages.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/BrowserCoreMessages.java?view=diff&rev=514482&r1=514481&r2=514482
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/BrowserCoreMessages.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/BrowserCoreMessages.java
Sun Mar  4 14:20:10 2007
@@ -57,6 +57,8 @@
     public static String event__dn_attributes_initialized;
 
     public static String event__dn_children_initialized;
+    
+    public static String event__buld_modification;
 
     public static String event__empty_value_added_to_att_at_dn;
 

Added: directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/events/BulkModificationEvent.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/events/BulkModificationEvent.java?view=auto&rev=514482
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/events/BulkModificationEvent.java
(added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/events/BulkModificationEvent.java
Sun Mar  4 14:20:10 2007
@@ -0,0 +1,43 @@
+/*
+ *  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.ldapstudio.browser.core.events;
+
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreMessages;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+
+
+public class BulkModificationEvent extends EntryModificationEvent
+{
+
+    public BulkModificationEvent( IConnection connection )
+    {
+        super( connection, connection.getRootDSE() );
+    }
+
+
+    public String toString()
+    {
+        return BrowserCoreMessages.event__buld_modification;
+    }
+
+}

Modified: directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/internal/model/ConnectionModifyHandler.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/internal/model/ConnectionModifyHandler.java?view=diff&rev=514482&r1=514481&r2=514482
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/internal/model/ConnectionModifyHandler.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/internal/model/ConnectionModifyHandler.java
Sun Mar  4 14:20:10 2007
@@ -46,6 +46,7 @@
 import org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifChangeModDnRecord;
 import org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifChangeModifyRecord;
 import org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifContainer;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifContentRecord;
 import org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifModSpec;
 import org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifRecord;
 import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifAttrValLine;
@@ -383,15 +384,56 @@
                     {
                         this.applyModificationAndLog( record, monitor );
 
-                        String dn = record.getDnLine().getValueAsString();
-                        IEntry entry = connection.getEntryFromCache( new DN( dn ) );
-                        if ( entry != null )
+                        // update cache and adjust attribute/children initialization flags
+                        DN dn = new DN( record.getDnLine().getValueAsString() );
+                        IEntry entry = connection.getEntryFromCache( dn );
+                        DN parentDn = dn.getParentDn();
+                        IEntry parentEntry = parentDn != null ? connection.getEntryFromCache(
dn.getParentDn() ) : null;
+
+                        if ( record instanceof LdifChangeDeleteRecord )
+                        {
+                            if ( entry != null )
+                            {
+                                entry.setAttributesInitialized( false );
+                                connection.uncacheEntry( entry );
+                            }
+                            if ( parentEntry != null )
+                            {
+                                parentEntry.setChildrenInitialized( false );
+                            }
+                        }
+                        else if ( record instanceof LdifChangeModDnRecord )
                         {
-                            if ( record instanceof LdifChangeDeleteRecord )
+                            if ( entry != null )
                             {
+                                entry.setAttributesInitialized( false );
                                 connection.uncacheEntry( entry );
                             }
-                            else
+                            if ( parentEntry != null )
+                            {
+                                parentEntry.setChildrenInitialized( false );
+                            }
+                            LdifChangeModDnRecord modDnRecord = ( LdifChangeModDnRecord )
record;
+                            if ( modDnRecord.getNewsuperiorLine() != null )
+                            {
+                                DN newSuperiorDn = new DN( modDnRecord.getNewsuperiorLine().getValueAsString()
);
+                                IEntry newSuperiorEntry = connection.getEntryFromCache( newSuperiorDn
);
+                                if ( newSuperiorEntry != null )
+                                {
+                                    newSuperiorEntry.setChildrenInitialized( false );
+                                }
+                            }
+                        }
+                        else if ( record instanceof LdifChangeAddRecord || record instanceof
LdifContentRecord )
+                        {
+                            if ( parentEntry != null )
+                            {
+                                parentEntry.setChildrenInitialized( false );
+                            }
+                        }
+                        else
+                        {
+                            if ( entry != null )
                             {
                                 entry.setAttributesInitialized( false );
                             }

Modified: directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/jobs/ImportLdifJob.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/jobs/ImportLdifJob.java?view=diff&rev=514482&r1=514481&r2=514482
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/jobs/ImportLdifJob.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/jobs/ImportLdifJob.java
Sun Mar  4 14:20:10 2007
@@ -34,12 +34,17 @@
 
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.directory.ldapstudio.browser.core.BrowserCoreMessages;
+import org.apache.directory.ldapstudio.browser.core.events.AttributesInitializedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.BulkModificationEvent;
+import org.apache.directory.ldapstudio.browser.core.events.ChildrenInitializedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.EventRegistry;
 import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException;
 import org.apache.directory.ldapstudio.browser.core.model.ldif.LdifEnumeration;
 import org.apache.directory.ldapstudio.browser.core.model.ldif.parser.LdifParser;
 
 
-public class ImportLdifJob extends AbstractEclipseJob
+public class ImportLdifJob extends AbstractAsyncBulkJob
 {
 
     private IConnection connection;
@@ -83,7 +88,7 @@
     }
 
 
-    protected void executeAsyncJob( ExtendedProgressMonitor monitor )
+    protected void executeBulkJob( ExtendedProgressMonitor monitor ) throws ModelModificationException
     {
 
         monitor.beginTask( BrowserCoreMessages.jobs__import_ldif_task, 2 );
@@ -136,6 +141,12 @@
     protected String getErrorMessage()
     {
         return BrowserCoreMessages.jobs__import_ldif_error;
+    }
+
+
+    protected void runNotification()
+    {
+        EventRegistry.fireEntryUpdated( new BulkModificationEvent( connection ), this );
     }
 
 }

Modified: directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/resources/org/apache/directory/ldapstudio/browser/core/browsercoremessages.properties
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/resources/org/apache/directory/ldapstudio/browser/core/browsercoremessages.properties?view=diff&rev=514482&r1=514481&r2=514482
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/resources/org/apache/directory/ldapstudio/browser/core/browsercoremessages.properties
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/resources/org/apache/directory/ldapstudio/browser/core/browsercoremessages.properties
Sun Mar  4 14:20:10 2007
@@ -5,6 +5,7 @@
 event__deleted_att_from_dn=Deleted {0} from {1}
 event__dn_attributes_initialized={0}: attributes initialized
 event__dn_children_initialized={0}: children initialized
+event__buld_modification=Bulk modification
 event__empty_value_added_to_att_at_dn=Empty value added to {0} at {1}
 event__empty_value_deleted_from_att_at_dn=Empty value deleted from {0} at {1}
 event__added_dn=Added {0}

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserViewUniversalListener.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserViewUniversalListener.java?view=diff&rev=514482&r1=514481&r2=514482
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserViewUniversalListener.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserViewUniversalListener.java
Sun Mar  4 14:20:10 2007
@@ -28,6 +28,7 @@
 import org.apache.directory.ldapstudio.browser.core.events.AttributesInitializedEvent;
 import org.apache.directory.ldapstudio.browser.core.events.BookmarkUpdateEvent;
 import org.apache.directory.ldapstudio.browser.core.events.BookmarkUpdateListener;
+import org.apache.directory.ldapstudio.browser.core.events.BulkModificationEvent;
 import org.apache.directory.ldapstudio.browser.core.events.ConnectionUpdateEvent;
 import org.apache.directory.ldapstudio.browser.core.events.EntryAddedEvent;
 import org.apache.directory.ldapstudio.browser.core.events.EntryModificationEvent;
@@ -502,6 +503,18 @@
             viewer.refresh( eme.getNewEntry().getParententry(), true );
             viewer.refresh( eme.getNewEntry(), true );
             viewer.setSelection( new StructuredSelection( eme.getNewEntry() ), true );
+        }
+        else if ( event instanceof EntryMovedEvent )
+        {
+            EntryMovedEvent eme = ( EntryMovedEvent ) event;
+            viewer.refresh( eme.getOldEntry().getParententry(), true );
+            viewer.refresh( eme.getNewEntry().getParententry(), true );
+            viewer.refresh( eme.getNewEntry(), true );
+            viewer.setSelection( new StructuredSelection( eme.getNewEntry() ), true );
+        }
+        else if ( event instanceof BulkModificationEvent )
+        {
+            viewer.refresh();
         }
 
         viewer.refresh( event.getModifiedEntry(), true );

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/EntryEditorWidgetUniversalListener.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/EntryEditorWidgetUniversalListener.java?view=diff&rev=514482&r1=514481&r2=514482
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/EntryEditorWidgetUniversalListener.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/EntryEditorWidgetUniversalListener.java
Sun Mar  4 14:20:10 2007
@@ -21,6 +21,7 @@
 package org.apache.directory.ldapstudio.browser.ui.widgets.entryeditor;
 
 
+import org.apache.directory.ldapstudio.browser.core.events.BulkModificationEvent;
 import org.apache.directory.ldapstudio.browser.core.events.EmptyValueAddedEvent;
 import org.apache.directory.ldapstudio.browser.core.events.EmptyValueDeletedEvent;
 import org.apache.directory.ldapstudio.browser.core.events.EntryModificationEvent;
@@ -169,8 +170,8 @@
     public void entryUpdated( EntryModificationEvent event )
     {
 
-        if ( viewer == null || viewer.getTree() == null || viewer.getTree().isDisposed()
-            || viewer.getInput() == null || event.getModifiedEntry() != viewer.getInput()
)
+        if ( viewer == null || viewer.getTree() == null || viewer.getTree().isDisposed()
|| viewer.getInput() == null
+            || ( event.getModifiedEntry() != viewer.getInput() && !( event instanceof
BulkModificationEvent ) ) )
         {
             return;
         }



Mime
View raw message