directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r821766 - in /directory/studio/trunk: ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/UpdateEntryRunnable.java ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorManager.java
Date Mon, 05 Oct 2009 12:24:50 GMT
Author: seelmann
Date: Mon Oct  5 12:24:50 2009
New Revision: 821766

URL: http://svn.apache.org/viewvc?rev=821766&view=rev
Log:
DIRSTUDIO-515:
- Reduced number of fired events
- Fixed refresh action

Modified:
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/UpdateEntryRunnable.java
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorManager.java

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/UpdateEntryRunnable.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/UpdateEntryRunnable.java?rev=821766&r1=821765&r2=821766&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/UpdateEntryRunnable.java
(original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/UpdateEntryRunnable.java
Mon Oct  5 12:24:50 2009
@@ -65,7 +65,6 @@
      */
     public void runNotification()
     {
-        super.runNotification();
         EventRegistry.fireEntryUpdated( new EntryModificationEvent( entry.getBrowserConnection(),
entry ), this );
     }
 }

Modified: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorManager.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorManager.java?rev=821766&r1=821765&r2=821766&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorManager.java
(original)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorManager.java
Mon Oct  5 12:24:50 2009
@@ -516,6 +516,22 @@
     }
 
 
+    private IWorkbenchPartReference getActivePartRef( List<IEntryEditor> editors )
+    {
+        for ( IEntryEditor editor : editors )
+        {
+            IWorkbenchPart part = ( IWorkbenchPart ) editor;
+            IEditorPart activeEditor = part.getSite().getPage().getActiveEditor();
+            if ( part == activeEditor )
+            {
+                IWorkbenchPartReference reference = part.getSite().getPage().getReference(
part );
+                return reference;
+            }
+        }
+        return null;
+    }
+
+
     IEntry getSharedWorkingCopy( IEntry originalEntry, IEntryEditor editor )
     {
         EntryEditorUtils.ensureAttributesInitialized( originalEntry );
@@ -580,10 +596,16 @@
                 LdifFile diff = Utils.computeDiff( referenceCopy, workingCopy );
                 if ( diff != null )
                 {
+                    // remove entry from map, reduces number of fired events
+                    oscSharedReferenceCopies.remove( originalEntry );
+                    oscSharedWorkingCopies.remove( originalEntry );
                     // save by executing the LDIF
                     UpdateEntryRunnable runnable = new UpdateEntryRunnable( originalEntry,
diff
                         .toFormattedString( LdifFormatParameters.DEFAULT ) );
                     IStatus status = RunnableContextRunner.execute( runnable, null, handleError
);
+                    // put entry back to map
+                    oscSharedReferenceCopies.put( originalEntry, referenceCopy );
+                    oscSharedWorkingCopies.put( originalEntry, workingCopy );
                     if ( status.isOK() )
                     {
                         updateOscSharedReferenceCopy( originalEntry );
@@ -840,17 +862,27 @@
                         }
                         else
                         {
-                            List<IEntryEditor> oscEditors = getOscEditors( oscSharedWorkingCopy
);
-                            for ( IEntryEditor entryEditor : oscEditors )
+                            // changes on working copy, ask before update
+                            IWorkbenchPartReference reference = getActivePartRef( getOscEditors(
oscSharedWorkingCopy ) );
+                            if ( reference != null )
+                            {
+                                askUpdateSharedWorkingCopy( reference, originalEntry, oscSharedWorkingCopy,
event
+                                    .getSource() );
+                            }
+                        }
+                    }
+                    else
+                    {
+                        // no diff betweeen original entry and reference copy, check if editor
is dirty
+                        LdifFile workDiff = Utils.computeDiff( oscSharedReferenceCopy, oscSharedWorkingCopy
);
+                        if ( workDiff != null )
+                        {
+                            // changes on working copy, ask before update
+                            IWorkbenchPartReference reference = getActivePartRef( getOscEditors(
oscSharedWorkingCopy ) );
+                            if ( reference != null )
                             {
-                                IWorkbenchPart part = ( IWorkbenchPart ) entryEditor;
-                                IEditorPart activeEditor = part.getSite().getPage().getActiveEditor();
-                                if ( part == activeEditor )
-                                {
-                                    IWorkbenchPartReference reference = part.getSite().getPage().getReference(
part );
-                                    askUpdateSharedWorkingCopy( reference, originalEntry,
oscSharedWorkingCopy, event
-                                        .getSource() );
-                                }
+                                askUpdateSharedWorkingCopy( reference, originalEntry, oscSharedWorkingCopy,
event
+                                    .getSource() );
                             }
                         }
                     }
@@ -913,9 +945,15 @@
                 LdifFile diff = Utils.computeDiff( autoSaveSharedReferenceCopy, autoSaveSharedWorkingCopy
);
                 if ( diff != null )
                 {
+                    // remove entry from map, reduces number of fired events
+                    autoSaveSharedReferenceCopies.remove( originalEntry );
+                    autoSaveSharedWorkingCopies.remove( originalEntry );
                     UpdateEntryRunnable runnable = new UpdateEntryRunnable( originalEntry,
diff
                         .toFormattedString( LdifFormatParameters.DEFAULT ) );
                     RunnableContextRunner.execute( runnable, null, true );
+                    // put entry back to map
+                    autoSaveSharedReferenceCopies.put( originalEntry, autoSaveSharedReferenceCopy
);
+                    autoSaveSharedWorkingCopies.put( originalEntry, autoSaveSharedWorkingCopy
);
                     // don't care if status is ok or not: always update
                     updateAutoSaveSharedReferenceCopy( originalEntry );
                     updateAutoSaveSharedWorkingCopy( originalEntry );



Mime
View raw message