directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r899607 - /directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/
Date Fri, 15 Jan 2010 12:21:19 GMT
Author: pamarcelot
Date: Fri Jan 15 12:21:19 2010
New Revision: 899607

URL: http://svn.apache.org/viewvc?rev=899607&view=rev
Log:
Fix for DIRSTUDIO-616 (Entry Editor Manager does not ensure that the entry's attributes are
initialized (loaded) before testing and opening editors).

Yet another fix.

This time, we're only creating a single Eclipse Job (instead of 2 in the previous implementation)
for both the opening of an entry editor and the entry's attributes initialization.

Thanks seelmann! ;)

Added:
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/OpenEntryEditorRunnable.java
      - copied, changed from r899219, directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/OpenEntryEditorJob.java
Removed:
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/OpenEntryEditorJob.java
Modified:
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorManager.java
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/messages.properties
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/messages_de.properties
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/messages_fr.properties

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=899607&r1=899606&r2=899607&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
Fri Jan 15 12:21:19 2010
@@ -47,6 +47,7 @@
 import org.apache.directory.studio.ldapbrowser.core.events.ValueModifiedEvent;
 import org.apache.directory.studio.ldapbrowser.core.events.ValueMultiModificationEvent;
 import org.apache.directory.studio.ldapbrowser.core.events.ValueRenamedEvent;
+import org.apache.directory.studio.ldapbrowser.core.jobs.StudioBrowserJob;
 import org.apache.directory.studio.ldapbrowser.core.jobs.UpdateEntryRunnable;
 import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
 import org.apache.directory.studio.ldapbrowser.core.model.IBookmark;
@@ -67,6 +68,7 @@
 import org.eclipse.core.runtime.IExtensionRegistry;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.resource.ImageDescriptor;
@@ -726,8 +728,10 @@
     public void openEntryEditor( EntryEditorExtension extension, IEntry[] entries, ISearchResult[]
searchResults,
         IBookmark[] bookmarks )
     {
-        OpenEntryEditorJob runnable = new OpenEntryEditorJob( extension, entries, searchResults,
bookmarks );
-        runnable.schedule();
+        OpenEntryEditorRunnable runnable = new OpenEntryEditorRunnable( extension, entries,
searchResults, bookmarks );
+        StudioBrowserJob job = new StudioBrowserJob( runnable );
+        job.setPriority( Job.INTERACTIVE ); // Highest priority (just in case)
+        job.execute();
     }
 
 
@@ -745,8 +749,10 @@
      */
     public void openEntryEditor( IEntry[] entries, ISearchResult[] searchResults, IBookmark[]
bookmarks )
     {
-        OpenEntryEditorJob runnable = new OpenEntryEditorJob( entries, searchResults, bookmarks
);
-        runnable.schedule();
+        OpenEntryEditorRunnable runnable = new OpenEntryEditorRunnable( entries, searchResults,
bookmarks );
+        StudioBrowserJob job = new StudioBrowserJob( runnable );
+        job.setPriority( Job.INTERACTIVE ); // Highest priority (just in case)
+        job.execute();
     }
 
 

Copied: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/OpenEntryEditorRunnable.java
(from r899219, directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/OpenEntryEditorJob.java)
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/OpenEntryEditorRunnable.java?p2=directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/OpenEntryEditorRunnable.java&p1=directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/OpenEntryEditorJob.java&r1=899219&r2=899607&rev=899607&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/OpenEntryEditorJob.java
(original)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/OpenEntryEditorRunnable.java
Fri Jan 15 12:21:19 2010
@@ -21,29 +21,30 @@
 package org.apache.directory.studio.entryeditors;
 
 
-import org.apache.directory.studio.ldapbrowser.core.jobs.StudioBrowserJob;
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.jobs.StudioBulkRunnableWithProgress;
+import org.apache.directory.studio.connection.core.jobs.StudioProgressMonitor;
+import org.apache.directory.studio.connection.core.jobs.StudioRunnableWithProgressAdapter;
+import org.apache.directory.studio.ldapbrowser.core.jobs.InitializeAttributesRunnable;
 import org.apache.directory.studio.ldapbrowser.core.model.IBookmark;
 import org.apache.directory.studio.ldapbrowser.core.model.IContinuation;
 import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
 import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
 import org.apache.directory.studio.ldapbrowser.core.model.IContinuation.State;
 import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.PlatformUI;
 
 
 /**
- * Job to open an entry editor. 
+ * Runnable to open an entry editor. 
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class OpenEntryEditorJob extends Job
+public class OpenEntryEditorRunnable extends StudioRunnableWithProgressAdapter implements
+    StudioBulkRunnableWithProgress
 {
     private IEntry[] entries;
     private ISearchResult[] searchResults;
@@ -52,7 +53,7 @@
 
 
     /**
-     * Creates a new instance of OpenEntryEditorJob.
+     * Creates a new instance of OpenEntryEditorRunnable.
      * <p>
      * Opens an entry editor from one of the given entries, 
      * search results or bookmarks.
@@ -64,20 +65,17 @@
      * @param bookmarks
      *      an arrays of bookmarks
      */
-    public OpenEntryEditorJob( IEntry[] entries, ISearchResult[] searchResults, IBookmark[]
bookmarks )
+    public OpenEntryEditorRunnable( IEntry[] entries, ISearchResult[] searchResults, IBookmark[]
bookmarks )
     {
-        super( "" ); //$NON-NLS-1$
+        super();
         this.entries = entries;
         this.searchResults = searchResults;
         this.bookmarks = bookmarks;
-
-        // Using a high priority for this job
-        setPriority( Job.INTERACTIVE );
     }
 
 
     /**
-     * Creates a new instance of OpenEntryEditorJob.
+     * Creates a new instance of OpenEntryEditorRunnable.
      * <p>
      * Opens an entry editor with the given entry editor extension and one of 
      * the given entries, search results or bookmarks.
@@ -91,25 +89,87 @@
      * @param bookmarks
      *      an arrays of bookmarks
      */
-    public OpenEntryEditorJob( EntryEditorExtension extension, IEntry[] entries, ISearchResult[]
searchResults,
+    public OpenEntryEditorRunnable( EntryEditorExtension extension, IEntry[] entries, ISearchResult[]
searchResults,
         IBookmark[] bookmarks )
     {
-        super( "" ); //$NON-NLS-1$
+        super();
         this.extension = extension;
         this.entries = entries;
         this.searchResults = searchResults;
         this.bookmarks = bookmarks;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getName()
+    {
+        return Messages.getString( "OpenEntryEditorRunnable.OpenEntryEditor" ); //$NON-NLS-1$
+    }
 
-        // Using a high priority for this job
-        setPriority( Job.INTERACTIVE );
+
+    /**
+     * {@inheritDoc}
+     */
+    public Object[] getLockedObjects()
+    {
+        if ( entries.length == 1 )
+        {
+            return new Object[]
+                { entries[0] };
+        }
+        else if ( searchResults.length == 1 )
+        {
+            return new Object[]
+                { searchResults[0].getEntry() };
+        }
+        else if ( bookmarks.length == 1 )
+        {
+            return new Object[]
+                { bookmarks[0].getEntry() };
+        }
+        else
+        {
+            return new Object[0];
+        }
     }
 
 
     /**
      * {@inheritDoc}
      */
-    protected IStatus run( IProgressMonitor monitor )
+    public Connection[] getConnections()
     {
+        if ( entries.length == 1 )
+        {
+            return new Connection[]
+                { entries[0].getBrowserConnection().getConnection() };
+        }
+        else if ( searchResults.length == 1 )
+        {
+            return new Connection[]
+                { searchResults[0].getEntry().getBrowserConnection().getConnection() };
+        }
+        else if ( bookmarks.length == 1 )
+        {
+            return new Connection[]
+                { bookmarks[0].getEntry().getBrowserConnection().getConnection() };
+        }
+        else
+        {
+            return new Connection[0];
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run( StudioProgressMonitor monitor )
+    {
+        monitor.setTaskName( Messages.getString( "OpenEntryEditorRunnable.OpeningEntryEditor"
) ); //$NON-NLS-1$
+
         // Getting the entry to open
         IEntry entry = null;
 
@@ -138,19 +198,10 @@
             }
             else
             {
-                try
-                {
-                    // Making sure attributes are initialized
-                    StudioBrowserJob job = EntryEditorUtils.ensureAttributesInitialized(
entry );
-                    if ( job != null )
-                    {
-                        // Waiting for the entry's attributes to be initialized
-                        job.join();
-                    }
-                }
-                catch ( InterruptedException e )
+                // Making sure attributes are initialized
+                if ( !entry.isAttributesInitialized() )
                 {
-                    // Nothing to do
+                    InitializeAttributesRunnable.initializeAttributes( entry, monitor );
                 }
             }
         }
@@ -208,7 +259,14 @@
                 }
             }
         } );
+    }
+
 
-        return Status.OK_STATUS;
+    /**
+     * {@inheritDoc}
+     */
+    public void runNotification( StudioProgressMonitor monitor )
+    {
+        // Nothing to notify
     }
 }

Modified: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/messages.properties?rev=899607&r1=899606&r2=899607&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/messages.properties
(original)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/messages.properties
Fri Jan 15 12:21:19 2010
@@ -26,3 +26,5 @@
 EntryEditorNavigationLocation.RootDSE=Root DSE
 EntryEditorNavigationLocation.SearchResult=Search Result {0}
 EntryEditorUtils.NoEntrySelected=No entry selected
+OpenEntryEditorRunnable.OpenEntryEditor=Open Entry Editor
+OpenEntryEditorRunnable.OpeningEntryEditor=Opening Entry Editor...

Modified: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/messages_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/messages_de.properties?rev=899607&r1=899606&r2=899607&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/messages_de.properties
(original)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/messages_de.properties
Fri Jan 15 12:21:19 2010
@@ -25,3 +25,5 @@
 EntryEditorNavigationLocation.Entry=Eintrag {0}
 EntryEditorNavigationLocation.SearchResult=Suchergebnis {0}
 EntryEditorUtils.NoEntrySelected=Kein Eintrag ausgew\u00E4hlt
+OpenEntryEditorRunnable.OpenEntryEditor=Eintragseditor \u00F6ffnen
+OpenEntryEditorRunnable.OpeningEntryEditor=\u00D6ffne Eintragseditor...

Modified: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/messages_fr.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/messages_fr.properties?rev=899607&r1=899606&r2=899607&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/messages_fr.properties
(original)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/messages_fr.properties
Fri Jan 15 12:21:19 2010
@@ -26,3 +26,5 @@
 EntryEditorNavigationLocation.RootDSE=Root DSE
 EntryEditorNavigationLocation.SearchResult=R\u00E9sultat de recherche {0}
 EntryEditorUtils.NoEntrySelected=Aucune entr\u00E9e s\u00E9lectionn\u00E9e
+OpenEntryEditorRunnable.OpenEntryEditor=Ouvrir l'\u00E9diteur d'entr\u00E9e
+OpenEntryEditorRunnable.OpeningEntryEditor=Ouverture de l'\u00E9diteur d'entr\u00E9e...
\ No newline at end of file



Mime
View raw message