directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r691800 - in /directory/studio/trunk: ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/MoveEntriesJob.java ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/MoveAction.java
Date Wed, 03 Sep 2008 21:45:41 GMT
Author: seelmann
Date: Wed Sep  3 14:45:40 2008
New Revision: 691800

URL: http://svn.apache.org/viewvc?rev=691800&view=rev
Log:
Partial fix for DIRSTUDIO-208: Fire less events when moving multiple entries

Modified:
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/MoveEntriesJob.java
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/MoveAction.java

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/MoveEntriesJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/MoveEntriesJob.java?rev=691800&r1=691799&r2=691800&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/MoveEntriesJob.java
(original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/MoveEntriesJob.java
Wed Sep  3 14:45:40 2008
@@ -35,9 +35,9 @@
 import org.apache.directory.studio.connection.core.DnUtils;
 import org.apache.directory.studio.connection.core.jobs.StudioProgressMonitor;
 import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
+import org.apache.directory.studio.ldapbrowser.core.events.BulkModificationEvent;
 import org.apache.directory.studio.ldapbrowser.core.events.EntryMovedEvent;
 import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
-import org.apache.directory.studio.ldapbrowser.core.events.SearchUpdateEvent;
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
 import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
 import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
@@ -239,17 +239,28 @@
      */
     protected void runNotification()
     {
-        for ( int i = 0; i < newEntries.length; i++ )
+        // notify the entries and their parents
+        if ( newEntries.length < 2 )
         {
-            if ( oldEntries[i] != null && newEntries[i] != null )
+            // notify fore each moved entry
+            for ( int i = 0; i < newEntries.length; i++ )
             {
-                EventRegistry.fireEntryUpdated( new EntryMovedEvent( oldEntries[i], newEntries[i]
), this );
+                if ( oldEntries[i] != null && newEntries[i] != null )
+                {
+                    EventRegistry.fireEntryUpdated( new EntryMovedEvent( oldEntries[i], newEntries[i]
), this );
+                }
             }
         }
-        for ( ISearch search : searchesToUpdateSet )
+        else
         {
-            EventRegistry.fireSearchUpdated( new SearchUpdateEvent( search,
-                SearchUpdateEvent.EventDetail.SEARCH_PERFORMED ), this );
+            // reset the old and new parents and send only a bulk update event
+            // notifying for each moved entry would cause lot of UI updates...
+            for ( IEntry oldEntry : oldEntries )
+            {
+                oldEntry.getParententry().setChildrenInitialized( false );
+            }
+            newParent.setChildrenInitialized( false );
+            EventRegistry.fireEntryUpdated( new BulkModificationEvent( browserConnection
), this );
         }
     }
 

Modified: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/MoveAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/MoveAction.java?rev=691800&r1=691799&r2=691800&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/MoveAction.java
(original)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/MoveAction.java
Wed Sep  3 14:45:40 2008
@@ -40,7 +40,7 @@
 
 
 /**
- * This Action moves Entries from on node of the Tree to another.
+ * This Action moves entries from one node of the tree to another.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
@@ -61,7 +61,6 @@
      */
     public String getText()
     {
-
         IEntry[] entries = getEntries();
         ISearch[] searches = getSearches();
         IBookmark[] bookmarks = getBookmarks();
@@ -70,15 +69,6 @@
         {
             return entries.length == 1 ? "Move Entry..." : "Move Entries...";
         }
-        // else if(searches.length > 0 && entries.length==0 &&
-        // bookmarks.length==0) {
-        // return entries.length == 1 ? "Move Search..." : "Move Searches...";
-        // }
-        // else if(bookmarks.length > 0 && entries.length==0 &&
-        // searches.length==0) {
-        // return entries.length == 1 ? "Move Bookmark..." : "Move
-        // Bookmarks...";
-        // }
         else
         {
             return "Move...";
@@ -109,7 +99,6 @@
      */
     public void run()
     {
-
         IEntry[] entries = getEntries();
         ISearch[] searches = getSearches();
         IBookmark[] bookmarks = getBookmarks();
@@ -118,14 +107,6 @@
         {
             moveEntries( entries );
         }
-        else if ( searches.length > 0 && entries.length == 0 && bookmarks.length
== 0 )
-        {
-            // tbd
-        }
-        else if ( bookmarks.length > 0 && entries.length == 0 && searches.length
== 0 )
-        {
-            // tbd
-        }
     }
 
 
@@ -134,7 +115,6 @@
      */
     public boolean isEnabled()
     {
-
         try
         {
             IEntry[] entries = getEntries();
@@ -142,7 +122,6 @@
             IBookmark[] bookmarks = getBookmarks();
 
             return entries.length > 0 && searches.length == 0 && bookmarks.length
== 0;
-
         }
         catch ( Exception e )
         {
@@ -159,8 +138,8 @@
      */
     protected IEntry[] getEntries()
     {
-        if ( getSelectedBookmarks().length + getSelectedSearches().length
-            + getSelectedAttributes().length + getSelectedValues().length == 0
+        if ( getSelectedBookmarks().length + getSelectedSearches().length + getSelectedAttributes().length
+            + getSelectedValues().length == 0
             && getSelectedEntries().length + getSelectedSearchResults().length >
0 )
         {
             LinkedHashSet<IEntry> entriesSet = new LinkedHashSet<IEntry>();
@@ -190,7 +169,7 @@
 
 
     /**
-     * Opens a Move Entries Dialog and lauches the Move Entries Jobs.
+     * Opens a Move Entries Dialog and launches the Move Entries Jobs.
      *
      * @param entries
      *      the entries to move
@@ -204,7 +183,7 @@
             if ( newParentDn != null /* && !newRdn.equals(entry.getRdn()) */)
             {
                 IEntry newParentEntry = entries[0].getBrowserConnection().getEntryFromCache(
newParentDn );
-                if( newParentEntry == null )
+                if ( newParentEntry == null )
                 {
                     ReadEntryRunnable runnable = new ReadEntryRunnable( entries[0].getBrowserConnection(),
newParentDn );
                     RunnableContextRunner.execute( runnable, null, true );
@@ -255,4 +234,5 @@
             return new IBookmark[0];
         }
     }
+
 }



Mime
View raw message