directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r900396 - in /directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio: entryeditors/ ldapbrowser/ui/editors/entry/
Date Mon, 18 Jan 2010 13:56:30 GMT
Author: pamarcelot
Date: Mon Jan 18 13:56:29 2010
New Revision: 900396

URL: http://svn.apache.org/viewvc?rev=900396&view=rev
Log:
Fix for DIRSTUDIO-617 (Tabular and LDIF Entry Single-Tab Editors should warn the user when
modifications are pending (auto-save disabled) and their input is changed).

Modified:
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorUtils.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
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditor.java
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/LdifEntryEditor.java

Modified: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorUtils.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorUtils.java?rev=900396&r1=900395&r2=900396&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorUtils.java
(original)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorUtils.java
Mon Jan 18 13:56:29 2010
@@ -25,7 +25,11 @@
 import org.apache.directory.studio.ldapbrowser.core.jobs.StudioBrowserJob;
 import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
 import org.apache.directory.studio.ldapbrowser.core.model.IRootDSE;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.IEditorInput;
 
 
@@ -50,7 +54,7 @@
             job.execute();
             return job;
         }
-        
+
         return null;
     }
 
@@ -137,4 +141,44 @@
 
         return null;
     }
+
+
+    /**
+     * Asks the user if he wants to save the modifications made to the entry before 
+     * opening the new input.
+     * <p>
+     * If the user answers 'Yes', then the entry's modifications are saved.
+     * <p>
+     * This method returns whether or not the whole operation completed.
+     * <p>Based on this return value, <code>true</code> or <code>false</code>,
the editor
+     * then updates its input or not.
+     *
+     * @param editor
+     *      the editor
+     * @return
+     *      <code>true</code> if the whole operation completed correctly,
+     *      <code>false</code> if not.
+     */
+    public static boolean askSaveSharedWorkingCopyBeforeInputChange( IEntryEditor editor
)
+    {
+        // Asking for saving the modifications
+        MessageDialog dialog = new MessageDialog( Display.getCurrent().getActiveShell(),
Messages
+            .getString( "EntryEditorUtils.SaveChanges" ), null, Messages //$NON-NLS-1$
+            .getString( "EntryEditorUtils.SaveChangesDescription" ), MessageDialog.QUESTION,
new String[] //$NON-NLS-1$
+            { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0 );
+        int result = dialog.open();
+        if ( result == 0 )
+        {
+            // Saving the modifications
+            EntryEditorInput eei = editor.getEntryEditorInput();
+            IStatus status = eei.saveSharedWorkingCopy( true, editor );
+            if ( !status.isOK() )
+            {
+                // If save failed, let's keep the modifications in the editor and return
false
+                return false;
+            }
+        }
+
+        return true;
+    }
 }

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=900396&r1=900395&r2=900396&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
Mon Jan 18 13:56:29 2010
@@ -26,5 +26,7 @@
 EntryEditorNavigationLocation.RootDSE=Root DSE
 EntryEditorNavigationLocation.SearchResult=Search Result {0}
 EntryEditorUtils.NoEntrySelected=No entry selected
+EntryEditorUtils.SaveChanges=Save Changes
+EntryEditorUtils.SaveChangesDescription=Entry has been modified in this entry editor. Save
changes before opening another entry in this editor?
 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=900396&r1=900395&r2=900396&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
Mon Jan 18 13:56:29 2010
@@ -25,5 +25,7 @@
 EntryEditorNavigationLocation.Entry=Eintrag {0}
 EntryEditorNavigationLocation.SearchResult=Suchergebnis {0}
 EntryEditorUtils.NoEntrySelected=Kein Eintrag ausgew\u00E4hlt
+EntryEditorUtils.SaveChanges=\u00c4nderungen Speichern
+EntryEditorUtils.SaveChangesDescription=TODO:Entry has been modified in this entry editor.
Save changes before opening another entry in this editor?
 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=900396&r1=900395&r2=900396&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
Mon Jan 18 13:56:29 2010
@@ -26,5 +26,7 @@
 EntryEditorNavigationLocation.RootDSE=Root DSE
 EntryEditorNavigationLocation.SearchResult=R\u00E9sultat de recherche {0}
 EntryEditorUtils.NoEntrySelected=Aucune entr\u00E9e s\u00E9lectionn\u00E9e
+EntryEditorUtils.SaveChanges=Sauvegarder les modifications
+EntryEditorUtils.SaveChangesDescription=L'entr\u00E9e a \u00E9t\u00E9 modifi\u00E9e dans
cet \u00E9diteur d'entr\u00E9e. Souhaitez-vous sauvegarder les modifications avant d'ouvrir
une autre entrée dans cet \u00E9diteur ?
 OpenEntryEditorRunnable.OpenEntryEditor=Ouvrir l'\u00E9diteur d'entr\u00E9e
 OpenEntryEditorRunnable.OpeningEntryEditor=Ouverture de l'\u00E9diteur d'entr\u00E9e...
\ No newline at end of file

Modified: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditor.java?rev=900396&r1=900395&r2=900396&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditor.java
(original)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditor.java
Mon Jan 18 13:56:29 2010
@@ -433,6 +433,15 @@
     {
         if ( input instanceof EntryEditorInput )
         {
+            // If the editor is dirty, let's ask for a save before changing the input
+            if ( isDirty() )
+            {
+                if ( !EntryEditorUtils.askSaveSharedWorkingCopyBeforeInputChange( this )
)
+                {
+                    return;
+                }
+            }
+
             /*
              * Workaround to make link-with-editor working for the single-tab editor:
              * The call of firePropertyChange is used to inform the link-with-editor action.

Modified: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/LdifEntryEditor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/LdifEntryEditor.java?rev=900396&r1=900395&r2=900396&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/LdifEntryEditor.java
(original)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/LdifEntryEditor.java
Mon Jan 18 13:56:29 2010
@@ -326,6 +326,15 @@
                     return;
                 }
 
+                // If the editor is dirty, let's ask for a save before changing the input
+                if ( isDirty() )
+                {
+                    if ( !EntryEditorUtils.askSaveSharedWorkingCopyBeforeInputChange( this
) )
+                    {
+                        return;
+                    }
+                }
+
                 /*
                  * Workaround to make link-with-editor working for the single-tab editor:
                  * The call of firePropertyChange is used to inform the link-with-editor
action.



Mime
View raw message