directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r821751 - in /directory/studio/trunk: ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/ ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/ ldapbrowser-...
Date Mon, 05 Oct 2009 10:51:47 GMT
Author: seelmann
Date: Mon Oct  5 10:51:47 2009
New Revision: 821751

URL: http://svn.apache.org/viewvc?rev=821751&view=rev
Log:
DIRSTUDIO-515: Fixed Multi-Valued editor

Added:
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/UpdateEntryRunnable.java
Modified:
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/MultivaluedDialog.java
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/OpenBestEditorAction.java
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/messages.properties
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/messages_de.properties
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/messages_fr.properties
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/valueeditors/ValueEditorManager.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/events/EntryModificationEvent.java
    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/ldapbrowser/ui/editors/searchresult/SearchResultEditor.java

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/MultivaluedDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/MultivaluedDialog.java?rev=821751&r1=821750&r2=821751&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/MultivaluedDialog.java
(original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/MultivaluedDialog.java
Mon Oct  5 10:51:47 2009
@@ -23,6 +23,7 @@
 
 import java.util.Iterator;
 
+import org.apache.directory.studio.connection.ui.RunnableContextRunner;
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
 import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EntryEditorWidget;
@@ -34,17 +35,21 @@
 import org.apache.directory.studio.ldapbrowser.core.events.EmptyValueAddedEvent;
 import org.apache.directory.studio.ldapbrowser.core.events.EmptyValueDeletedEvent;
 import org.apache.directory.studio.ldapbrowser.core.events.EntryModificationEvent;
-import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
 import org.apache.directory.studio.ldapbrowser.core.events.ValueAddedEvent;
 import org.apache.directory.studio.ldapbrowser.core.events.ValueDeletedEvent;
 import org.apache.directory.studio.ldapbrowser.core.events.ValueModifiedEvent;
+import org.apache.directory.studio.ldapbrowser.core.jobs.UpdateEntryRunnable;
 import org.apache.directory.studio.ldapbrowser.core.model.AttributeHierarchy;
 import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
 import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
 import org.apache.directory.studio.ldapbrowser.core.model.IValue;
-import org.apache.directory.studio.ldapbrowser.core.model.impl.Attribute;
+import org.apache.directory.studio.ldapbrowser.core.utils.CompoundModification;
+import org.apache.directory.studio.ldapbrowser.core.utils.Utils;
+import org.apache.directory.studio.ldifparser.LdifFormatParameters;
+import org.apache.directory.studio.ldifparser.model.LdifFile;
+import org.apache.directory.studio.valueeditors.ValueEditorManager;
+import org.eclipse.core.runtime.IStatus;
 import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.swt.SWT;
@@ -66,13 +71,13 @@
 {
 
     /** The dialog title. */
-    private static final String DIALOG_TITLE = Messages.getString("MultivaluedDialog.MultivaluedEditor");
//$NON-NLS-1$
+    private static final String DIALOG_TITLE = Messages.getString( "MultivaluedDialog.MultivaluedEditor"
); //$NON-NLS-1$
 
-    /** The attribute hierarchie to edit. */
-    private AttributeHierarchy attributeHierarchie;
+    /** The attribute hierarchy to edit. */
+    private AttributeHierarchy attributeHierarchy;
 
     /** The entry editor widget configuration. */
-    private EntryEditorWidgetConfiguration configuration;
+    private MultiValuedEntryEditorConfiguration configuration;
 
     /** The entry edtior widget action group. */
     private EntryEditorWidgetActionGroup actionGroup;
@@ -91,13 +96,18 @@
      * Creates a new instance of MultivaluedDialog.
      * 
      * @param parentShell the parent shell
-     * @param attributeHierarchie the attribute hierarchie
+     * @param attributeHierarchy the attribute hierarchy
      */
-    public MultivaluedDialog( Shell parentShell, AttributeHierarchy attributeHierarchie )
+    public MultivaluedDialog( Shell parentShell, AttributeHierarchy attributeHierarchy )
     {
         super( parentShell );
         setShellStyle( getShellStyle() | SWT.RESIZE );
-        this.attributeHierarchie = attributeHierarchie;
+
+        // clone the entry and attribute hierarchy
+        IEntry entry = attributeHierarchy.getEntry();
+        String attributeDescription = attributeHierarchy.getAttributeDescription();
+        IEntry clone = new CompoundModification().cloneEntry( entry );
+        this.attributeHierarchy = clone.getAttributeWithSubtypes( attributeDescription );
     }
 
 
@@ -112,29 +122,26 @@
     }
 
 
-    /**
-     * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
-     */
-    protected void createButtonsForButtonBar( Composite parent )
+    @Override
+    protected void okPressed()
     {
-        createButton( parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, false
);
-        getShell().update();
-        getShell().layout( true, true );
-    }
-
-
-    /**
-     * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
-     */
-    protected void buttonPressed( int buttonId )
-    {
-        if ( IDialogConstants.CLOSE_ID == buttonId )
+        IEntry modifiedEntry = attributeHierarchy.getEntry();
+        IEntry originalEntry = modifiedEntry.getBrowserConnection().getEntryFromCache( modifiedEntry.getDn()
);
+        LdifFile diff = Utils.computeDiff( originalEntry, modifiedEntry );
+        if ( diff != null )
         {
-            close();
+            // save
+            UpdateEntryRunnable runnable = new UpdateEntryRunnable( originalEntry, diff
+                .toFormattedString( LdifFormatParameters.DEFAULT ) );
+            IStatus status = RunnableContextRunner.execute( runnable, null, true );
+            if ( status.isOK() )
+            {
+                super.okPressed();
+            }
         }
         else
         {
-            super.buttonPressed( buttonId );
+            super.okPressed();
         }
     }
 
@@ -144,9 +151,9 @@
      */
     public int open()
     {
-        if ( attributeHierarchie.getAttribute().getValueSize() == 0 )
+        if ( attributeHierarchy.getAttribute().getValueSize() == 0 )
         {
-            attributeHierarchie.getAttribute().addEmptyValue();
+            attributeHierarchy.getAttribute().addEmptyValue();
         }
 
         return super.open();
@@ -164,7 +171,7 @@
             dispose();
 
             // cleanup attribute hierarchy after editing
-            for ( Iterator<IAttribute> it = attributeHierarchie.iterator(); it.hasNext();
)
+            for ( Iterator<IAttribute> it = attributeHierarchy.iterator(); it.hasNext();
)
             {
                 IAttribute attribute = it.next();
                 if ( attribute != null )
@@ -227,7 +234,7 @@
         Composite composite = ( Composite ) super.createDialogArea( parent );
 
         // create configuration
-        configuration = new EntryEditorWidgetConfiguration();
+        configuration = new MultiValuedEntryEditorConfiguration();
 
         // create main widget
         mainWidget = new EntryEditorWidget( configuration );
@@ -247,10 +254,10 @@
         // create the listener
         universalListener = new MultiValuedEntryEditorUniversalListener( mainWidget.getViewer(),
configuration,
             actionGroup, actionGroup.getOpenDefaultEditorAction() );
-        universalListener.setInput( attributeHierarchie );
+        universalListener.setInput( attributeHierarchy );
 
         // start edit mode if an empty value exists
-        for ( Iterator<IAttribute> it = attributeHierarchie.iterator(); it.hasNext();
)
+        for ( Iterator<IAttribute> it = attributeHierarchy.iterator(); it.hasNext();
)
         {
             IAttribute attribute = it.next();
             IValue[] values = attribute.getValues();
@@ -310,21 +317,6 @@
                 viewer.cancelEditing();
             }
 
-            // set new input because attributes are newly created after a
-            // modification
-            IEntry entry = attributeHierarchie.getEntry();
-            String attributeDescription = attributeHierarchie.getAttributeDescription();
-            attributeHierarchie = entry.getAttributeWithSubtypes( attributeDescription );
-            if ( attributeHierarchie == null )
-            {
-                EventRegistry.suspendEventFiringInCurrentThread();
-                IAttribute attribute = new Attribute( entry, attributeDescription );
-                entry.addAttribute( attribute );
-                attribute.addEmptyValue();
-                EventRegistry.resumeEventFiringInCurrentThread();
-                attributeHierarchie = entry.getAttributeWithSubtypes( attributeDescription
);
-            }
-            viewer.setInput( attributeHierarchie );
             viewer.refresh();
 
             // select added/modified value
@@ -369,4 +361,20 @@
         }
     }
 
+    /**
+     * A special configuration for the {@link MultivaluedDialog}.
+     */
+    class MultiValuedEntryEditorConfiguration extends EntryEditorWidgetConfiguration
+    {
+        @Override
+        public ValueEditorManager getValueEditorManager( TreeViewer viewer )
+        {
+            if ( valueEditorManager == null )
+            {
+                valueEditorManager = new ValueEditorManager( viewer.getTree(), false, false
);
+            }
+
+            return valueEditorManager;
+        }
+    }
 }

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/OpenBestEditorAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/OpenBestEditorAction.java?rev=821751&r1=821750&r2=821751&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/OpenBestEditorAction.java
(original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/OpenBestEditorAction.java
Mon Oct  5 10:51:47 2009
@@ -172,10 +172,17 @@
             // validate non-modifiable attributes
             if ( !SchemaUtils.isModifiable( value.getAttribute().getAttributeTypeDescription()
) )
             {
-                message
-                    .append( NLS
-                        .bind(
-                            Messages.getString( "OpenBestEditorAction.ValueNotModifiable"
), value.getAttribute().getDescription() ) ); //$NON-NLS-1$
+                message.append( NLS.bind( Messages.getString( "OpenBestEditorAction.ValueNotModifiable"
), //$NON-NLS-1$ 
+                    value.getAttribute().getDescription() ) );
+                message.append( BrowserCoreConstants.LINE_SEPARATOR );
+                message.append( BrowserCoreConstants.LINE_SEPARATOR );
+            }
+
+            // validate modification of RDN
+            if ( value.isRdnPart() && cellEditor != valueEditorManager.getRenameValueEditor()
)
+            {
+                message.append( NLS.bind( Messages.getString( "OpenBestEditorAction.ValueIsRdnPart"
), //$NON-NLS-1$ 
+                    value.getAttribute().getDescription() ) );
                 message.append( BrowserCoreConstants.LINE_SEPARATOR );
                 message.append( BrowserCoreConstants.LINE_SEPARATOR );
             }

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/messages.properties?rev=821751&r1=821750&r2=821751&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/messages.properties
(original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/messages.properties
Mon Oct  5 10:51:47 2009
@@ -35,6 +35,7 @@
 EntryEditorWidgetSorterDialog.Value=Value
 EntryEditorWidgetTableMetadata.AttributeDescription=Attribute Description
 EntryEditorWidgetTableMetadata.Value=Value
+OpenBestEditorAction.ValueIsRdnPart=Warning\! This value is part of the RDN. In order to
modify this value please rename the entry.
 OpenBestEditorAction.ValueNotModifiable=Warning\! According to the schema attribute {0} is
not modifiable\!
 OpenBestEditorAction.ValueSingleValued=Warning\! According to the schema attribute {0} is
single-valued\!
 OpenBestEditorAction.AttributeNotInSubSchema=Warning\! According to the schema attribute
{0} is not allowed\!

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/messages_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/messages_de.properties?rev=821751&r1=821750&r2=821751&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/messages_de.properties
(original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/messages_de.properties
Mon Oct  5 10:51:47 2009
@@ -31,10 +31,11 @@
 EntryEditorWidgetSorterDialog.OperationalAttributesLast=Operationale Attribute zuletzt
 EntryEditorWidgetSorterDialog.SortAttributes=Attribute sortieren
 EntryEditorWidgetSorterDialog.SortBy=Sortieren nach
-EntryEditorWidgetSorterDialog.SortTableHint=Bitte zum sortieren auf die Tabellen\u00FCberschriften
klicken.
+EntryEditorWidgetSorterDialog.SortTableHint=Bitte zum Sortieren auf die Tabellen\u00FCberschriften
klicken.
 EntryEditorWidgetSorterDialog.Value=Wert
 EntryEditorWidgetTableMetadata.AttributeDescription=Attributbeschreibung
 EntryEditorWidgetTableMetadata.Value=Wert
+OpenBestEditorAction.ValueIsRdnPart=Warnung\! Dieser Wert ist Teil des RDN\! Zum \u00c4ndern
des Wertes bitte den Eintrag umbenennen. 
 OpenBestEditorAction.ValueNotModifiable=Warnung\! Gem\u00E4\u00DF Schema ist das Attribut
{0} nicht \u00E4nderbar\!
 OpenBestEditorAction.ValueSingleValued=Warnung\! Gem\u00E4\u00DF Schema ist das Attribut
{0} einwertig\!
 OpenBestEditorAction.AttributeNotInSubSchema=Warnung\! Gem\u00E4\u00DF Schema ist das Attribut
{0} nicht erlaubt\!

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/messages_fr.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/messages_fr.properties?rev=821751&r1=821750&r2=821751&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/messages_fr.properties
(original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/messages_fr.properties
Mon Oct  5 10:51:47 2009
@@ -35,6 +35,7 @@
 EntryEditorWidgetSorterDialog.Value=Valeur
 EntryEditorWidgetTableMetadata.AttributeDescription=Description d'attribut
 EntryEditorWidgetTableMetadata.Value=Valeur
+OpenBestEditorAction.ValueIsRdnPart=TODO:Warning\! This value is part of the RDN. In order
to modify this value please rename the entry.
 OpenBestEditorAction.ValueNotModifiable=Attention \! Selon le sch\u00E9ma, l''attribut {0}
n''est pas modifiable \!
 OpenBestEditorAction.ValueSingleValued=Attention \! Selon le sch\u00E9ma, l''attribut {0}
est mono-valu\u00E9 \!
 OpenBestEditorAction.AttributeNotInSubSchema=Attention \! Selon le sch\u00E9ma, l''attribut
{0} n''est pas autoris\u00E9 \!

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/valueeditors/ValueEditorManager.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/valueeditors/ValueEditorManager.java?rev=821751&r1=821750&r2=821751&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/valueeditors/ValueEditorManager.java
(original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/valueeditors/ValueEditorManager.java
Mon Oct  5 10:51:47 2009
@@ -373,9 +373,16 @@
                 attributeHierarchy.getAttribute().getValues()[0].getAttribute().getDescription()
) )
         {
             // special case RDN: always return MV-editor
-            if ( attributeHierarchy.getAttribute().getValues()[0].isRdnPart() )
+            if ( userSelectedValueEditor == null && attributeHierarchy.getAttribute().getValues()[0].isRdnPart()
)
             {
-                return multiValuedValueEditor;
+                if ( renameValueEditor != null )
+                {
+                    return renameValueEditor;
+                }
+                else
+                {
+                    return multiValuedValueEditor;
+                }
             }
 
             return getCurrentValueEditor( attributeHierarchy.getAttribute().getValues()[0]
);
@@ -483,9 +490,9 @@
             return new IValueEditor[0];
         }
 
-        // special case RDN: no alternative to the MV editor, except the entry editor
+        // special case RDN: no alternative to the rename editor, except the MV editor
         // perhaps this should be moved somewhere else
-        if ( entryValueEditor != null )
+        if ( multiValuedValueEditor != null )
         {
             for ( IAttribute attribute : ah )
             {
@@ -494,7 +501,7 @@
                     if ( value.isRdnPart() )
                     {
                         return new IValueEditor[]
-                            { entryValueEditor };
+                            { multiValuedValueEditor };
                     }
                 }
             }
@@ -603,6 +610,17 @@
 
 
     /**
+     * Returns the rename value editor.
+     *
+     * @return the rename value editor
+     */
+    public RenameValueEditor getRenameValueEditor()
+    {
+        return renameValueEditor;
+    }
+
+
+    /**
      * Creates and returns the value editors specified by value editors extensions.
      *
      * @param parent the parent composite

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/events/EntryModificationEvent.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/events/EntryModificationEvent.java?rev=821751&r1=821750&r2=821751&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/events/EntryModificationEvent.java
(original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/events/EntryModificationEvent.java
Mon Oct  5 10:51:47 2009
@@ -31,7 +31,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public abstract class EntryModificationEvent
+public class EntryModificationEvent
 {
     /** The event source */
     protected Object source;

Added: 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=821751&view=auto
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/UpdateEntryRunnable.java
(added)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/UpdateEntryRunnable.java
Mon Oct  5 10:51:47 2009
@@ -0,0 +1,71 @@
+/*
+ *  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.studio.ldapbrowser.core.jobs;
+
+
+import org.apache.directory.studio.connection.core.jobs.StudioProgressMonitor;
+import org.apache.directory.studio.ldapbrowser.core.events.EntryModificationEvent;
+import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+
+
+/**
+ * Runnable to update an entry using an LDIF fragment.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class UpdateEntryRunnable extends ExecuteLdifRunnable
+{
+
+    private IEntry entry;
+
+
+    /**
+     * Creates a new instance of UpdateEntryRunnable.
+     * 
+     * @param entry the entry
+     * @param ldif the LDIF to execute
+     */
+    public UpdateEntryRunnable( IEntry entry, String ldif )
+    {
+        super( entry.getBrowserConnection(), ldif, false, false );
+        this.entry = entry;
+    }
+
+
+    @Override
+    public void run( StudioProgressMonitor monitor )
+    {
+        super.run( monitor );
+        InitializeAttributesRunnable.initializeAttributes( entry, monitor );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    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=821751&r1=821750&r2=821751&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 10:51:47 2009
@@ -38,7 +38,7 @@
 import org.apache.directory.studio.ldapbrowser.core.events.EntryRenamedEvent;
 import org.apache.directory.studio.ldapbrowser.core.events.EntryUpdateListener;
 import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
-import org.apache.directory.studio.ldapbrowser.core.jobs.ExecuteLdifRunnable;
+import org.apache.directory.studio.ldapbrowser.core.jobs.UpdateEntryRunnable;
 import org.apache.directory.studio.ldapbrowser.core.model.IBookmark;
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
 import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
@@ -581,8 +581,8 @@
                 if ( diff != null )
                 {
                     // save by executing the LDIF
-                    ExecuteLdifRunnable runnable = new ExecuteLdifRunnable( originalEntry.getBrowserConnection(),
diff
-                        .toFormattedString( LdifFormatParameters.DEFAULT ), false, false
);
+                    UpdateEntryRunnable runnable = new UpdateEntryRunnable( originalEntry,
diff
+                        .toFormattedString( LdifFormatParameters.DEFAULT ) );
                     IStatus status = RunnableContextRunner.execute( runnable, null, handleError
);
                     if ( status.isOK() )
                     {
@@ -913,8 +913,8 @@
                 LdifFile diff = Utils.computeDiff( autoSaveSharedReferenceCopy, autoSaveSharedWorkingCopy
);
                 if ( diff != null )
                 {
-                    ExecuteLdifRunnable runnable = new ExecuteLdifRunnable( browserConnection,
diff
-                        .toFormattedString( LdifFormatParameters.DEFAULT ), false, false
);
+                    UpdateEntryRunnable runnable = new UpdateEntryRunnable( originalEntry,
diff
+                        .toFormattedString( LdifFormatParameters.DEFAULT ) );
                     RunnableContextRunner.execute( runnable, null, true );
                     // don't care if status is ok or not: always update
                     updateAutoSaveSharedReferenceCopy( originalEntry );

Modified: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditor.java?rev=821751&r1=821750&r2=821751&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditor.java
(original)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditor.java
Mon Oct  5 10:51:47 2009
@@ -27,7 +27,7 @@
 import org.apache.directory.studio.ldapbrowser.core.events.EntryModificationEvent;
 import org.apache.directory.studio.ldapbrowser.core.events.EntryUpdateListener;
 import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
-import org.apache.directory.studio.ldapbrowser.core.jobs.ExecuteLdifRunnable;
+import org.apache.directory.studio.ldapbrowser.core.jobs.UpdateEntryRunnable;
 import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
 import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
 import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
@@ -111,9 +111,8 @@
                         if ( diff != null )
                         {
                             // save
-                            ExecuteLdifRunnable runnable = new ExecuteLdifRunnable( originalEntry
-                                .getBrowserConnection(), diff.toFormattedString( LdifFormatParameters.DEFAULT
), false,
-                                false );
+                            UpdateEntryRunnable runnable = new UpdateEntryRunnable( originalEntry,
diff
+                                .toFormattedString( LdifFormatParameters.DEFAULT ) );
                             IStatus status = RunnableContextRunner.execute( runnable, null,
true );
                             if ( status.isOK() )
                             {



Mime
View raw message