directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r814009 [1/3] - in /directory/studio/trunk: ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/ ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/ ldapbr...
Date Fri, 11 Sep 2009 20:12:00 GMT
Author: seelmann
Date: Fri Sep 11 20:11:30 2009
New Revision: 814009

URL: http://svn.apache.org/viewvc?rev=814009&view=rev
Log:
Modifications for DIRSTUDIO-515, DIRSTUDIO-517, DIRSTUDIO-518, DIRSTUDIO-519
o Removed value modification jobs
o EntryEditorManager listens for changes of the entry editors
o EntryEditorManager calculates a diff of modification and sends them to the directory
o EntryEditorManager syncronizes state between editors
o Refactored entry editors
o Added missing hashCode() and equals()
o Changed the way how edit entry wizard merge changes to the entry editor

Added:
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/utils/CompoundModification.java
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/MultiTabEntryEditorMatchingStrategy.java
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/LdifEntryEditor.java
Removed:
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/AbstractAttributeModificationJob.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/CreateValuesJob.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/DeleteAttributesValueJob.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ModifyValueJob.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameValuesJob.java
Modified:
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/DeleteAction.java
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/FetchOperationalAttributesAction.java
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/PasteAction.java
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/RefreshAction.java
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/EditAttributeDescriptionAction.java
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/EntryEditorWidgetCellModifier.java
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/EntryEditorWidgetConfiguration.java
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/EntryEditorWidgetUniversalListener.java
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/EditEntryWizard.java
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/valueeditors/EntryValueEditor.java
    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/model/impl/AbstractEntry.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DelegateEntry.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DummyEntry.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/Search.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/SearchResult.java
    directory/studio/trunk/ldapbrowser-ui/plugin.xml
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorInput.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/entryeditors/EntryEditorUtils.java
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/IEntryEditor.java
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/BrowserUIPlugin.java
    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/EntryEditorConfiguration.java
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/LdifEntryEditorDocumentProvider.java
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/MultiTabEntryEditor.java
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/MultiTabLdifEntryEditor.java
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/SingleTabEntryEditor.java
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/SingleTabLdifEntryEditor.java
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditor.java
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorCellModifier.java
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorConfiguration.java
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorPasteAction.java
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewUniversalListener.java
    directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/LdifEditor.java
    directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/actions/EditLdifAttributeAction.java

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/DeleteAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/DeleteAction.java?rev=814009&r1=814008&r2=814009&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/DeleteAction.java (original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/DeleteAction.java Fri Sep 11 20:11:30 2009
@@ -21,14 +21,12 @@
 package org.apache.directory.studio.ldapbrowser.common.actions;
 
 
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedHashSet;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -36,7 +34,6 @@
 import org.apache.directory.shared.ldap.schema.parsers.ObjectClassDescription;
 import org.apache.directory.studio.ldapbrowser.common.dialogs.DeleteDialog;
 import org.apache.directory.studio.ldapbrowser.core.BrowserCoreConstants;
-import org.apache.directory.studio.ldapbrowser.core.jobs.DeleteAttributesValueJob;
 import org.apache.directory.studio.ldapbrowser.core.jobs.DeleteEntriesJob;
 import org.apache.directory.studio.ldapbrowser.core.model.AttributeHierarchy;
 import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
@@ -49,6 +46,7 @@
 import org.apache.directory.studio.ldapbrowser.core.model.StudioControl;
 import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema;
 import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils;
+import org.apache.directory.studio.ldapbrowser.core.utils.CompoundModification;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.ui.ISharedImages;
@@ -188,23 +186,7 @@
                 }
                 if ( values.size() > 0 )
                 {
-                    List<IValue> valueList = new ArrayList<IValue>( values );
-
-                    // filter empty attributes and values
-                    for ( Iterator<IValue> it = valueList.iterator(); it.hasNext(); )
-                    {
-                        IValue value = it.next();
-                        if ( value.isEmpty() )
-                        {
-                            value.getAttribute().deleteEmptyValue();
-                            it.remove();
-                        }
-                    }
-
-                    if ( !valueList.isEmpty() )
-                    {
-                        deleteValues( valueList.toArray( new IValue[valueList.size()] ) );
-                    }
+                    deleteValues( values );
                 }
             }
         }
@@ -591,43 +573,9 @@
      * @param values
      *      the Values to delete
      */
-    protected void deleteValues( IValue[] values )
+    protected void deleteValues( Collection<IValue> values )
     {
-        // check if all values of an attribute should be removed
-        List<IAttribute> attributeList = new ArrayList<IAttribute>();
-        Map<String, Integer> attributeDescriptionToSelectedValuesCountMap = new HashMap<String, Integer>();
-        for ( IValue value : values )
-        {
-            if ( !attributeDescriptionToSelectedValuesCountMap.containsKey( value.getAttribute().getDescription() ) )
-            {
-                attributeDescriptionToSelectedValuesCountMap.put( value.getAttribute().getDescription(),
-                    new Integer( 0 ) );
-            }
-            int count = ( ( Integer ) attributeDescriptionToSelectedValuesCountMap.get( value.getAttribute()
-                .getDescription() ) ).intValue() + 1;
-            attributeDescriptionToSelectedValuesCountMap.put( value.getAttribute().getDescription(),
-                new Integer( count ) );
-            if ( count >= value.getAttribute().getValueSize() )
-            {
-                IAttribute attribute = value.getAttribute();
-                if ( attribute != null && !attributeList.contains( attribute ) )
-                {
-                    attributeList.add( attribute );
-                }
-            }
-        }
-
-        // add selected values, but not if there attributes are also selected
-        List<IValue> valueList = new ArrayList<IValue>();
-        for ( IValue value : values )
-        {
-            if ( !attributeList.contains( value.getAttribute() ) )
-            {
-                valueList.add( value );
-            }
-        }
-
-        new DeleteAttributesValueJob( attributeList.toArray( new IAttribute[attributeList.size()] ), valueList
-            .toArray( new IValue[valueList.size()] ) ).execute();
+        new CompoundModification().deleteValues( values );
     }
+
 }

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/FetchOperationalAttributesAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/FetchOperationalAttributesAction.java?rev=814009&r1=814008&r2=814009&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/FetchOperationalAttributesAction.java (original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/FetchOperationalAttributesAction.java Fri Sep 11 20:11:30 2009
@@ -144,7 +144,13 @@
         }
         if ( getInput() != null && getInput() instanceof IEntry )
         {
-            entriesList.add( ( IEntry ) getInput() );
+            // the entry input is usually a cloned entry, lookup the real entry from connection
+            IEntry input = ( IEntry ) getInput();
+            IEntry entry = input.getBrowserConnection().getEntryFromCache( input.getDn() );
+            if ( entry != null )
+            {
+                entriesList.add( entry );
+            }
         }
         return entriesList;
     }

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/PasteAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/PasteAction.java?rev=814009&r1=814008&r2=814009&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/PasteAction.java (original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/PasteAction.java Fri Sep 11 20:11:30 2009
@@ -29,7 +29,6 @@
 import org.apache.directory.studio.ldapbrowser.common.dnd.SearchTransfer;
 import org.apache.directory.studio.ldapbrowser.common.dnd.ValuesTransfer;
 import org.apache.directory.studio.ldapbrowser.core.jobs.CopyEntriesJob;
-import org.apache.directory.studio.ldapbrowser.core.jobs.CreateValuesJob;
 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;
@@ -37,6 +36,7 @@
 import org.apache.directory.studio.ldapbrowser.core.model.SearchParameter;
 import org.apache.directory.studio.ldapbrowser.core.model.ISearch.SearchScope;
 import org.apache.directory.studio.ldapbrowser.core.model.impl.Search;
+import org.apache.directory.studio.ldapbrowser.core.utils.CompoundModification;
 import org.eclipse.core.runtime.IAdaptable;
 import org.eclipse.jface.preference.PreferenceDialog;
 import org.eclipse.jface.resource.ImageDescriptor;
@@ -281,7 +281,7 @@
 
         if ( entry != null )
         {
-            new CreateValuesJob( entry, values ).execute();
+            new CompoundModification().createValues( entry, values );
         }
     }
 

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/RefreshAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/RefreshAction.java?rev=814009&r1=814008&r2=814009&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/RefreshAction.java (original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/RefreshAction.java Fri Sep 11 20:11:30 2009
@@ -149,10 +149,12 @@
 
         if ( entryInput != null )
         {
-            boolean foa = entryInput.getBrowserConnection().isFetchOperationalAttributes()
-                || entryInput.isOperationalAttributesInitialized();
+            // the entry input is usually a cloned entry, lookup the real entry from connection
+            IEntry entry = entryInput.getBrowserConnection().getEntryFromCache( entryInput.getDn() );
+            boolean foa = entry.getBrowserConnection().isFetchOperationalAttributes()
+                || entry.isOperationalAttributesInitialized();
             new StudioBrowserJob( new InitializeAttributesRunnable( new IEntry[]
-                { entryInput }, foa ) ).execute();
+                { entry }, foa ) ).execute();
         }
         if ( searchInput != null )
         {

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/EditAttributeDescriptionAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/EditAttributeDescriptionAction.java?rev=814009&r1=814008&r2=814009&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/EditAttributeDescriptionAction.java (original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/EditAttributeDescriptionAction.java Fri Sep 11 20:11:30 2009
@@ -26,8 +26,8 @@
 import org.apache.directory.studio.ldapbrowser.common.actions.DeleteAction;
 import org.apache.directory.studio.ldapbrowser.common.actions.proxy.EntryEditorActionProxy;
 import org.apache.directory.studio.ldapbrowser.common.wizards.AttributeWizard;
-import org.apache.directory.studio.ldapbrowser.core.jobs.RenameValuesJob;
 import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.ldapbrowser.core.utils.CompoundModification;
 import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.viewers.Viewer;
@@ -123,19 +123,16 @@
      */
     private void renameValues( final IValue[] values )
     {
-        AttributeWizard wizard = new AttributeWizard( Messages.getString("EditAttributeDescriptionAction.EditAttributeDescription"), true, false, values[0] //$NON-NLS-1$
-            .getAttribute().getDescription(), values[0].getAttribute().getEntry() );
+        AttributeWizard wizard = new AttributeWizard( Messages
+            .getString( "EditAttributeDescriptionAction.EditAttributeDescription" ), true, false, //$NON-NLS-1$
+            values[0].getAttribute().getDescription(), values[0].getAttribute().getEntry() );
         WizardDialog dialog = new WizardDialog( Display.getDefault().getActiveShell(), wizard );
         dialog.setBlockOnOpen( true );
         dialog.create();
         if ( dialog.open() == Dialog.OK )
         {
-            String newAttributeName = wizard.getAttributeDescription();
-            if ( newAttributeName != null && !"".equals( newAttributeName ) //$NON-NLS-1$
-                && !newAttributeName.equals( values[0].getAttribute().getDescription() ) )
-            {
-                new RenameValuesJob( values[0].getAttribute().getEntry(), values, newAttributeName ).execute();
-            }
+            String newAttributeDescription = wizard.getAttributeDescription();
+            new CompoundModification().renameValues( values, newAttributeDescription );
         }
     }
 

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/EntryEditorWidgetCellModifier.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/EntryEditorWidgetCellModifier.java?rev=814009&r1=814008&r2=814009&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/EntryEditorWidgetCellModifier.java (original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/EntryEditorWidgetCellModifier.java Fri Sep 11 20:11:30 2009
@@ -22,6 +22,7 @@
 
 
 import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.ldapbrowser.core.utils.CompoundModification;
 import org.apache.directory.studio.valueeditors.ValueEditorManager;
 import org.eclipse.jface.viewers.ICellModifier;
 import org.eclipse.swt.widgets.Item;
@@ -125,13 +126,13 @@
             element = ( ( Item ) element ).getData();
         }
 
-        if ( element != null && element instanceof IValue && valueEditorManager != null )
+        if ( newRawValue != null && element != null && element instanceof IValue && valueEditorManager != null )
         {
             IValue oldValue = ( IValue ) element;
 
             if ( EntryEditorWidgetTableMetadata.VALUE_COLUMN_NAME.equals( property ) )
             {
-                valueEditorManager.modifyValue( oldValue, newRawValue );
+                new CompoundModification().modifyValue( oldValue, newRawValue );
             }
         }
     }

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/EntryEditorWidgetConfiguration.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/EntryEditorWidgetConfiguration.java?rev=814009&r1=814008&r2=814009&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/EntryEditorWidgetConfiguration.java (original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/EntryEditorWidgetConfiguration.java Fri Sep 11 20:11:30 2009
@@ -188,7 +188,7 @@
     {
         if ( valueEditorManager == null )
         {
-            valueEditorManager = new ValueEditorManager( viewer.getTree() );
+            valueEditorManager = new ValueEditorManager( viewer.getTree(), false );
         }
 
         return valueEditorManager;

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/EntryEditorWidgetUniversalListener.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/EntryEditorWidgetUniversalListener.java?rev=814009&r1=814008&r2=814009&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/EntryEditorWidgetUniversalListener.java (original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/EntryEditorWidgetUniversalListener.java Fri Sep 11 20:11:30 2009
@@ -265,7 +265,7 @@
 
             // select the added value and start editing
             viewer.setSelection( new StructuredSelection( evaEvent.getAddedValue() ), true );
-            if ( startEditAction.isEnabled() )
+            if ( startEditAction.isEnabled() && viewer.getControl().isFocusControl() )
             {
                 startEditAction.run();
             }
@@ -302,13 +302,12 @@
      */
     public void setInput( IEntry entry )
     {
-        if ( entry != viewer.getInput() )
+        // if ( entry != viewer.getInput() )
         {
             viewer.setInput( entry );
             actionGroup.setInput( entry );
             expandFoldedAttributes();
         }
-
     }
 
 

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/EditEntryWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/EditEntryWizard.java?rev=814009&r1=814008&r2=814009&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/EditEntryWizard.java (original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/EditEntryWizard.java Fri Sep 11 20:11:30 2009
@@ -21,21 +21,13 @@
 package org.apache.directory.studio.ldapbrowser.common.wizards;
 
 
-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.core.events.EventRegistry;
-import org.apache.directory.studio.ldapbrowser.core.jobs.ExecuteLdifRunnable;
-import org.apache.directory.studio.ldapbrowser.core.jobs.InitializeAttributesRunnable;
 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.impl.DummyEntry;
+import org.apache.directory.studio.ldapbrowser.core.utils.CompoundModification;
 import org.apache.directory.studio.ldapbrowser.core.utils.ModelConverter;
-import org.apache.directory.studio.ldapbrowser.core.utils.Utils;
-import org.apache.directory.studio.ldifparser.LdifFormatParameters;
-import org.apache.directory.studio.ldifparser.model.container.LdifChangeModifyRecord;
 import org.apache.directory.studio.ldifparser.model.container.LdifContentRecord;
-import org.eclipse.core.runtime.IStatus;
 
 
 /**
@@ -56,22 +48,11 @@
      */
     public EditEntryWizard( IEntry entry )
     {
-        setWindowTitle( Messages.getString("EditEntryWizard.EditEntry") ); //$NON-NLS-1$
+        setWindowTitle( Messages.getString( "EditEntryWizard.EditEntry" ) ); //$NON-NLS-1$
         setNeedsProgressMonitor( true );
 
         selectedEntry = entry;
         selectedConnection = entry.getBrowserConnection();
-        if ( selectedConnection.getConnection() != null )
-        {
-            originalReadOnlyFlag = selectedConnection.getConnection().isReadOnly();
-            selectedConnection.getConnection().setReadOnly( true );
-        }
-
-        // ensure the attributes of the entry are initialized
-        if ( !selectedEntry.isAttributesInitialized() )
-        {
-            initAttributes();
-        }
 
         try
         {
@@ -81,7 +62,7 @@
         }
         catch ( Exception e )
         {
-            e.printStackTrace();
+            throw new RuntimeException( e );
         }
         finally
         {
@@ -90,15 +71,6 @@
     }
 
 
-    private void initAttributes()
-    {
-        boolean foa = selectedEntry.getBrowserConnection().isFetchOperationalAttributes();
-        InitializeAttributesRunnable iar = new InitializeAttributesRunnable( new IEntry[]
-            { selectedEntry }, foa );
-        RunnableContextRunner.execute( iar, getContainer(), true );
-    }
-
-
     /**
      * {@inheritDoc}
      */
@@ -117,11 +89,6 @@
      */
     public boolean performCancel()
     {
-        if ( selectedConnection.getConnection() != null )
-        {
-            selectedConnection.getConnection().setReadOnly( originalReadOnlyFlag );
-        }
-
         return true;
     }
 
@@ -131,45 +98,8 @@
      */
     public boolean performFinish()
     {
-        try
-        {
-            if ( selectedConnection.getConnection() != null )
-            {
-                selectedConnection.getConnection().setReadOnly( originalReadOnlyFlag );
-
-                LdifChangeModifyRecord record = Utils.computeDiff( selectedEntry, prototypeEntry );
-                if ( record != null )
-                {
-                    ExecuteLdifRunnable runnable = new ExecuteLdifRunnable( selectedConnection, record
-                        .toFormattedString( LdifFormatParameters.DEFAULT ), false, false );
-                    IStatus status = RunnableContextRunner.execute( runnable, getContainer(), true );
-                    if ( !status.isOK() )
-                    {
-                        selectedConnection.getConnection().setReadOnly( true );
-                        return false;
-                    }
-                    else
-                    {
-                        initAttributes();
-                        return true;
-                    }
-                }
-                else
-                {
-                    // no changes
-                    return true;
-                }
-            }
-            else
-            {
-                return true;
-            }
-        }
-        catch ( Throwable t )
-        {
-            t.printStackTrace();
-            return false;
-        }
+        new CompoundModification().replaceAttributes( prototypeEntry, selectedEntry );
+        return true;
     }
 
 

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/valueeditors/EntryValueEditor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/valueeditors/EntryValueEditor.java?rev=814009&r1=814008&r2=814009&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/valueeditors/EntryValueEditor.java (original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/valueeditors/EntryValueEditor.java Fri Sep 11 20:11:30 2009
@@ -229,7 +229,7 @@
      */
     public Object getRawValue( AttributeHierarchy attributeHierarchy )
     {
-        return attributeHierarchy.getEntry().isDirectoryEntry() ? attributeHierarchy.getEntry() : null;
+        return attributeHierarchy.getEntry();
     }
 
 
@@ -240,7 +240,7 @@
      */
     public Object getRawValue( IValue value )
     {
-        return value.getAttribute().getEntry().isDirectoryEntry() ? value.getAttribute().getEntry() : null;
+        return value.getAttribute().getEntry();
     }
 
 

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=814009&r1=814008&r2=814009&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 Fri Sep 11 20:11:30 2009
@@ -33,19 +33,12 @@
 import org.apache.directory.shared.ldap.schema.parsers.LdapSyntaxDescription;
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
-import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
-import org.apache.directory.studio.ldapbrowser.core.jobs.CreateValuesJob;
-import org.apache.directory.studio.ldapbrowser.core.jobs.DeleteAttributesValueJob;
-import org.apache.directory.studio.ldapbrowser.core.jobs.ModifyValueJob;
 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.model.schema.Schema;
 import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils;
-import org.apache.directory.studio.ldapbrowser.core.utils.Utils;
-import org.apache.directory.studio.ldifparser.LdifUtils;
 import org.eclipse.core.runtime.IConfigurationElement;
 import org.eclipse.core.runtime.IExtension;
 import org.eclipse.core.runtime.IExtensionPoint;
@@ -116,7 +109,7 @@
     /** The default binary editor */
     private IValueEditor defaultBinaryValueEditor;
 
-    /** A Map wich all available value editors. */
+    /** A map containing all available value editors. */
     private Map<String, IValueEditor> class2ValueEditors;
 
 
@@ -125,7 +118,7 @@
      *
      * @param parent the composite used to create the value editors
      */
-    public ValueEditorManager( Composite parent )
+    public ValueEditorManager( Composite parent, boolean useEntryValueEditor )
     {
         this.parent = parent;
         userSelectedValueEditor = null;
@@ -145,10 +138,13 @@
             BrowserCommonConstants.IMG_MULTIVALUEDEDITOR ) );
 
         // special case: entry editor
-        entryValueEditor = new EntryValueEditor( this.parent, this );
-        entryValueEditor.setValueEditorName( Messages.getString( "ValueEditorManager.EntryEditor" ) ); //$NON-NLS-1$
-        entryValueEditor.setValueEditorImageDescriptor( BrowserCommonActivator.getDefault().getImageDescriptor(
-            BrowserCommonConstants.IMG_ENTRY ) );
+        if ( useEntryValueEditor )
+        {
+            entryValueEditor = new EntryValueEditor( this.parent, this );
+            entryValueEditor.setValueEditorName( Messages.getString( "ValueEditorManager.EntryEditor" ) ); //$NON-NLS-1$
+            entryValueEditor.setValueEditorImageDescriptor( BrowserCommonActivator.getDefault().getImageDescriptor(
+                BrowserCommonConstants.IMG_ENTRY ) );
+        }
 
         // special case: rename editor
         renameValueEditor = new RenameValueEditor( this.parent, this );
@@ -172,7 +168,10 @@
         {
             userSelectedValueEditor = null;
             multiValuedValueEditor.dispose();
-            entryValueEditor.dispose();
+            if ( entryValueEditor != null )
+            {
+                entryValueEditor.dispose();
+            }
             renameValueEditor.dispose();
             defaultStringSingleLineValueEditor.dispose();
             defaultStringMultiLineValueEditor.dispose();
@@ -305,7 +304,7 @@
 
         // special case objectClass: always return entry editor
         if ( userSelectedValueEditor == null && value.getAttribute().isObjectClassAttribute()
-            && value.getAttribute().getEntry().isDirectoryEntry() )
+            && entryValueEditor != null )
         {
             return entryValueEditor;
         }
@@ -347,12 +346,12 @@
             return null;
         }
         else if ( userSelectedValueEditor == null && attributeHierarchy.getAttribute().isObjectClassAttribute()
-            && attributeHierarchy.getEntry().isDirectoryEntry() )
+            && entryValueEditor != null )
         {
             // special case objectClass: always return entry editor
             return entryValueEditor;
         }
-        else if ( userSelectedValueEditor == entryValueEditor )
+        else if ( userSelectedValueEditor == entryValueEditor && entryValueEditor != null )
         {
             // special case objectClass: always return entry editor
             return entryValueEditor;
@@ -480,14 +479,17 @@
 
         // special case RDN: no alternative to the MV editor, except the entry editor
         // perhaps this should be moved somewhere else
-        for ( IAttribute attribute : ah )
+        if ( entryValueEditor != null )
         {
-            for ( IValue value : attribute.getValues() )
+            for ( IAttribute attribute : ah )
             {
-                if ( value.isRdnPart() )
+                for ( IValue value : attribute.getValues() )
                 {
-                    return new IValueEditor[]
-                        { entryValueEditor };
+                    if ( value.isRdnPart() )
+                    {
+                        return new IValueEditor[]
+                            { entryValueEditor };
+                    }
                 }
             }
         }
@@ -537,7 +539,10 @@
         list.addAll( class2ValueEditors.values() );
 
         list.add( multiValuedValueEditor );
-        list.add( entryValueEditor );
+        if ( entryValueEditor != null )
+        {
+            list.add( entryValueEditor );
+        }
         list.add( renameValueEditor );
 
         return list.toArray( new IValueEditor[list.size()] );
@@ -589,139 +594,6 @@
 
 
     /**
-     * Creates the attribute with the given value at the entry.
-     * 
-     * It is called from a ICellModifier if no attribute of value exists and
-     * the raw value returned by the CellEditor isn't null.
-     * 
-     * @param newRawValue the new raw value
-     * @param entry the entry
-     * @param attributeDescription the attribute description
-     * 
-     * @throws ModelModificationException the model modification exception
-     */
-    public void createValue( IEntry entry, String attributeDescription, Object newRawValue )
-    {
-        if ( entry != null && attributeDescription != null && newRawValue != null
-            && ( newRawValue instanceof byte[] || newRawValue instanceof String ) )
-        {
-            if ( entry.getAttribute( attributeDescription ) != null )
-            {
-                IAttribute attribute = entry.getAttribute( attributeDescription );
-                if ( attribute != null )
-                {
-                    if ( attribute.getValueSize() == 0 )
-                    {
-                        new CreateValuesJob( attribute, newRawValue ).execute();
-                    }
-                    else if ( attribute.getValueSize() == 1 )
-                    {
-                        this.modifyValue( attribute.getValues()[0], newRawValue );
-                    }
-                }
-            }
-            else
-            {
-                EventRegistry.suspendEventFiringInCurrentThread();
-                IAttribute attribute = new Attribute( entry, attributeDescription );
-                entry.addAttribute( attribute );
-                EventRegistry.resumeEventFiringInCurrentThread();
-
-                Object newValue;
-                if ( SchemaUtils.isString( entry.getBrowserConnection().getSchema().getAttributeTypeDescription(
-                    attributeDescription ), entry.getBrowserConnection().getSchema() ) )
-                {
-                    if ( newRawValue instanceof String )
-                    {
-                        newValue = ( String ) newRawValue;
-                    }
-                    else
-                    {
-                        newValue = LdifUtils.utf8decode( ( byte[] ) newRawValue );
-                    }
-                }
-                else
-                {
-                    if ( newRawValue instanceof String )
-                    {
-                        newValue = LdifUtils.utf8encode( ( String ) newRawValue );
-                    }
-                    else
-                    {
-                        newValue = ( byte[] ) newRawValue;
-                    }
-                }
-
-                new CreateValuesJob( attribute, newValue ).execute();
-            }
-        }
-    }
-
-
-    /**
-     * Modifies the value and sets the given raw value
-     * 
-     * It is called from a ICellModfier if the value exists and the raw
-     * value returned by the CellEditor isn't null.
-     * 
-     * @param oldValue the old value
-     * @param newRawValue the new raw value
-     */
-    public void modifyValue( IValue oldValue, Object newRawValue )
-    {
-        IAttribute attribute = oldValue.getAttribute();
-
-        boolean modify = false;
-        if ( oldValue != null && newRawValue != null && newRawValue instanceof byte[] )
-        {
-            byte[] newValue = ( byte[] ) newRawValue;
-            if ( !Utils.equals( oldValue.getBinaryValue(), newValue ) )
-            {
-                modify = true;
-            }
-        }
-        else if ( oldValue != null && newRawValue != null && newRawValue instanceof String )
-        {
-
-            String newValue = ( String ) newRawValue;
-            if ( !oldValue.getStringValue().equals( newValue ) )
-            {
-                modify = true;
-            }
-        }
-
-        if ( modify )
-        {
-            if ( oldValue.isEmpty() )
-            {
-                EventRegistry.suspendEventFiringInCurrentThread();
-                attribute.deleteEmptyValue();
-                EventRegistry.resumeEventFiringInCurrentThread();
-                new CreateValuesJob( attribute, newRawValue ).execute();
-            }
-            else
-            {
-                new ModifyValueJob( oldValue, newRawValue ).execute();
-            }
-        }
-    }
-
-
-    /**
-     * Deletes the attributes.
-     * 
-     * It is called from a ICellModfier if the attribute exists and the raw
-     * value returned by the CellEditor is null.
-     * 
-     * @param ah the attribute hierarchy
-     */
-    public void deleteAttribute( AttributeHierarchy ah )
-    {
-        new DeleteAttributesValueJob( ah ).execute();
-    }
-
-
-    /**
      * 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/model/impl/AbstractEntry.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/AbstractEntry.java?rev=814009&r1=814008&r2=814009&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/AbstractEntry.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/AbstractEntry.java Fri Sep 11 20:11:30 2009
@@ -67,6 +67,8 @@
 public abstract class AbstractEntry implements IEntry
 {
 
+    private static final long serialVersionUID = -2431637532526418774L;
+
     private static final int HAS_CHILDREN_HINT_FLAG = 1;
 
     private static final int IS_DIRECTORY_ENTRY_FLAG = 2;
@@ -792,6 +794,15 @@
     /**
      * {@inheritDoc}
      */
+    public int hashCode()
+    {
+        return getDn().hashCode();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
     public boolean equals( Object o )
     {
         // check argument

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DelegateEntry.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DelegateEntry.java?rev=814009&r1=814008&r2=814009&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DelegateEntry.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DelegateEntry.java Fri Sep 11 20:11:30 2009
@@ -889,6 +889,15 @@
     /**
      * {@inheritDoc}
      */
+    public int hashCode()
+    {
+        return getDn().hashCode();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
     public boolean equals( Object o )
     {
         // check argument

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DummyEntry.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DummyEntry.java?rev=814009&r1=814008&r2=814009&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DummyEntry.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DummyEntry.java Fri Sep 11 20:11:30 2009
@@ -499,4 +499,27 @@
         return ocds;
     }
 
+
+    @Override
+    public int hashCode()
+    {
+        return getDn().hashCode();
+    }
+
+
+    @Override
+    public boolean equals( Object o )
+    {
+        // check argument
+        if ( o == null || !( o instanceof IEntry ) )
+        {
+            return false;
+        }
+        IEntry e = ( IEntry ) o;
+
+        // compare dn and connection
+        return getDn() == null ? e.getDn() == null : ( getDn().equals( e.getDn() ) && getBrowserConnection().equals(
+            e.getBrowserConnection() ) );
+    }
+
 }

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/Search.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/Search.java?rev=814009&r1=814008&r2=814009&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/Search.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/Search.java Fri Sep 11 20:11:30 2009
@@ -34,11 +34,11 @@
 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.internal.search.LdapSearchPageScoreComputer;
-import org.apache.directory.studio.ldapbrowser.core.model.StudioControl;
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
 import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
 import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
 import org.apache.directory.studio.ldapbrowser.core.model.SearchParameter;
+import org.apache.directory.studio.ldapbrowser.core.model.StudioControl;
 import org.apache.directory.studio.ldapbrowser.core.utils.Utils;
 import org.eclipse.search.ui.ISearchPageScoreComputer;
 
@@ -411,7 +411,7 @@
     public void setSearchResults( ISearchResult[] searchResults )
     {
         this.searchResults = searchResults;
-        if ( searchResults != null )
+        if ( searchResults != null && getName() != null )
         {
             fireSearchUpdated( SearchUpdateEvent.EventDetail.SEARCH_PERFORMED );
         }
@@ -561,4 +561,57 @@
         return null;
     }
 
+
+    @Override
+    public int hashCode()
+    {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ( ( connection == null ) ? 0 : connection.hashCode() );
+        result = prime * result + ( ( searchParameter == null ) ? 0 : searchParameter.getName().hashCode() );
+        return result;
+    }
+
+
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+        {
+            return true;
+        }
+        if ( obj == null )
+        {
+            return false;
+        }
+        if ( !( obj instanceof Search ) )
+        {
+            return false;
+        }
+        Search other = ( Search ) obj;
+        if ( connection == null )
+        {
+            if ( other.connection != null )
+            {
+                return false;
+            }
+        }
+        else if ( !connection.equals( other.connection ) )
+        {
+            return false;
+        }
+        if ( searchParameter == null )
+        {
+            if ( other.searchParameter != null )
+            {
+                return false;
+            }
+        }
+        else if ( !searchParameter.getName().equals( other.searchParameter.getName() ) )
+        {
+            return false;
+        }
+        return true;
+    }
+
 }

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/SearchResult.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/SearchResult.java?rev=814009&r1=814008&r2=814009&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/SearchResult.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/SearchResult.java Fri Sep 11 20:11:30 2009
@@ -168,4 +168,57 @@
         this.search = search;
     }
 
+
+    @Override
+    public int hashCode()
+    {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ( ( entry == null ) ? 0 : entry.getDn().hashCode() );
+        result = prime * result + ( ( search == null ) ? 0 : search.hashCode() );
+        return result;
+    }
+
+
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+        {
+            return true;
+        }
+        if ( obj == null )
+        {
+            return false;
+        }
+        if ( !( obj instanceof SearchResult ) )
+        {
+            return false;
+        }
+        SearchResult other = ( SearchResult ) obj;
+        if ( entry == null )
+        {
+            if ( other.entry != null )
+            {
+                return false;
+            }
+        }
+        else if ( !entry.getDn().equals( other.entry.getDn() ) )
+        {
+            return false;
+        }
+        if ( search == null )
+        {
+            if ( other.search != null )
+            {
+                return false;
+            }
+        }
+        else if ( !search.equals( other.search ) )
+        {
+            return false;
+        }
+        return true;
+    }
+
 }

Added: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/utils/CompoundModification.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/utils/CompoundModification.java?rev=814009&view=auto
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/utils/CompoundModification.java (added)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/utils/CompoundModification.java Fri Sep 11 20:11:30 2009
@@ -0,0 +1,370 @@
+/*
+ *  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.utils;
+
+
+import java.util.Collection;
+
+import javax.naming.InvalidNameException;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.directory.studio.ldapbrowser.core.events.AttributesInitializedEvent;
+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.events.ValueRenamedEvent;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+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.IValue;
+import org.apache.directory.studio.ldapbrowser.core.model.impl.Attribute;
+import org.apache.directory.studio.ldapbrowser.core.model.impl.Value;
+import org.apache.directory.studio.ldifparser.model.container.LdifContentRecord;
+
+
+/**
+ * Performs compound operations to model classes.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class CompoundModification
+{
+
+    /**
+     * Rename the values by removing the old attribute from the entry and adding 
+     * a new attribute to the entry. Only one event (an {@link ValueRenamedEvent}) is fired.
+     * 
+     * @param oldValues the old values
+     * @param newAttributeDescription the new attribute description
+     */
+    public void renameValues( IValue[] oldValues, String newAttributeDescription )
+    {
+        if ( ArrayUtils.isEmpty( oldValues ) )
+        {
+            throw new IllegalArgumentException( "Expected non-null and non-empty values array." ); //$NON-NLS-1$
+        }
+        if ( StringUtils.isEmpty( newAttributeDescription ) )
+        {
+            throw new IllegalArgumentException( "Expected non-null and non-empty attribute description." ); //$NON-NLS-1$
+        }
+
+        if ( newAttributeDescription != null && !"".equals( newAttributeDescription ) //$NON-NLS-1$
+            && !newAttributeDescription.equals( oldValues[0].getAttribute().getDescription() ) )
+        {
+            ValueRenamedEvent event = null;
+            try
+            {
+                EventRegistry.suspendEventFiringInCurrentThread();
+                for ( IValue oldValue : oldValues )
+                {
+                    if ( !newAttributeDescription.equals( oldValue.getAttribute().getDescription() ) )
+                    {
+                        IAttribute oldAttribute = oldValue.getAttribute();
+                        IEntry entry = oldAttribute.getEntry();
+                        IValue newValue = null;
+
+                        // delete old value
+                        oldAttribute.deleteValue( oldValue );
+                        if ( oldAttribute.getValueSize() == 0 )
+                        {
+                            entry.deleteAttribute( oldAttribute );
+                        }
+
+                        // add new value
+                        IAttribute attribute = entry.getAttribute( newAttributeDescription );
+                        if ( attribute == null )
+                        {
+                            attribute = new Attribute( entry, newAttributeDescription );
+                            entry.addAttribute( attribute );
+                        }
+                        newValue = new Value( attribute, oldValue.getRawValue() );
+                        attribute.addValue( newValue );
+
+                        // prepare event
+                        if ( event == null )
+                        {
+                            event = new ValueRenamedEvent( entry.getBrowserConnection(), entry, oldValue, newValue );
+                        }
+                    }
+                }
+            }
+            finally
+            {
+                EventRegistry.resumeEventFiringInCurrentThread();
+            }
+
+            // fire events
+            EventRegistry.fireEntryUpdated( event, this );
+        }
+    }
+
+
+    /**
+     * Deletes the values and the attribute if no values remain.
+     * Only one event (an {@link ValueDeletedEvent}) is fired.
+     *
+     * @param values
+     *      the Values to delete
+     */
+    public void deleteValues( Collection<IValue> values )
+    {
+        if ( CollectionUtils.isEmpty( values ) )
+        {
+            throw new IllegalArgumentException( "Expected non-null and non-empty values collection." ); //$NON-NLS-1$
+        }
+
+        ValueDeletedEvent event = null;
+        try
+        {
+            EventRegistry.suspendEventFiringInCurrentThread();
+            for ( IValue value : values )
+            {
+                IAttribute attribute = value.getAttribute();
+                IEntry entry = attribute.getEntry();
+
+                attribute.deleteValue( value );
+                if ( event == null )
+                {
+                    event = new ValueDeletedEvent( entry.getBrowserConnection(), entry, attribute, value );
+                }
+
+                if ( attribute.getValueSize() == 0 )
+                {
+                    attribute.getEntry().deleteAttribute( attribute );
+                }
+            }
+        }
+        finally
+        {
+            EventRegistry.resumeEventFiringInCurrentThread();
+        }
+
+        // fire event
+        EventRegistry.fireEntryUpdated( event, this );
+    }
+
+
+    /**
+     * Modifies the value and sets the given raw value.
+     * Only one event (an {@link ValueAddEvent} or an {@link ValueModifiedEvent}) is fired.
+     * 
+     * @param oldValue the old value
+     * @param newRawValue the new raw value
+     */
+    public void modifyValue( IValue oldValue, Object newRawValue )
+    {
+        if ( oldValue == null || newRawValue == null )
+        {
+            throw new IllegalArgumentException( "Expected non-null value." ); //$NON-NLS-1$
+        }
+
+        IAttribute attribute = oldValue.getAttribute();
+
+        boolean modify = false;
+        if ( oldValue != null && newRawValue != null && newRawValue instanceof byte[] )
+        {
+            byte[] newValue = ( byte[] ) newRawValue;
+            if ( !Utils.equals( oldValue.getBinaryValue(), newValue ) )
+            {
+                modify = true;
+            }
+        }
+        else if ( oldValue != null && newRawValue != null && newRawValue instanceof String )
+        {
+
+            String newValue = ( String ) newRawValue;
+            if ( !oldValue.getStringValue().equals( newValue ) )
+            {
+                modify = true;
+            }
+        }
+
+        if ( modify )
+        {
+            if ( oldValue.isEmpty() )
+            {
+                EventRegistry.suspendEventFiringInCurrentThread();
+                attribute.deleteEmptyValue();
+                EventRegistry.resumeEventFiringInCurrentThread();
+
+                Value value = new Value( attribute, newRawValue );
+                attribute.addValue( value );
+            }
+            else
+            {
+                IValue newValue = new Value( attribute, newRawValue );
+                attribute.modifyValue( oldValue, newValue );
+            }
+        }
+    }
+
+
+    /**
+     * Creates the attribute with the given value in the entry.
+     * Only one event (an {@link ValueAddedEvent}) is fired.
+     * 
+     * @param entry the entry
+     * @param attributeDescription the attribute description
+     * @param newRawValue the new raw value
+     * 
+     * @throws ModelModificationException the model modification exception
+     */
+    public void createValue( IEntry entry, String attributeDescription, Object newRawValue )
+    {
+        if ( entry == null )
+        {
+            throw new IllegalArgumentException( "Expected non-null entry." ); //$NON-NLS-1$
+        }
+        if ( StringUtils.isEmpty( attributeDescription ) )
+        {
+            throw new IllegalArgumentException( "Expected non-null and non-empty attribute description." ); //$NON-NLS-1$
+        }
+        if ( newRawValue == null )
+        {
+            throw new IllegalArgumentException( "Expected non-null value." ); //$NON-NLS-1$
+        }
+
+        IAttribute attribute = entry.getAttribute( attributeDescription );
+        if ( attribute == null )
+        {
+            EventRegistry.suspendEventFiringInCurrentThread();
+            attribute = new Attribute( entry, attributeDescription );
+            entry.addAttribute( attribute );
+            EventRegistry.resumeEventFiringInCurrentThread();
+        }
+
+        Value value = new Value( attribute, newRawValue );
+        attribute.addValue( value );
+    }
+
+
+    /**
+     * Creates the attribute with the given value in the entry.
+     * Only one event (an {@link ValueAddedEvent}) is fired.
+     * 
+     * @param entry the entry
+     * @param values the values
+     * 
+     * @throws ModelModificationException the model modification exception
+     */
+    public void createValues( IEntry entry, IValue... values )
+    {
+        if ( entry == null )
+        {
+            throw new IllegalArgumentException( "Expected non-null entry." ); //$NON-NLS-1$
+        }
+        if ( ArrayUtils.isEmpty( values ) )
+        {
+            throw new IllegalArgumentException( "Expected non-null and non-empty values array." ); //$NON-NLS-1$
+        }
+
+        ValueAddedEvent event = null;
+        EventRegistry.suspendEventFiringInCurrentThread();
+        for ( IValue value : values )
+        {
+            String attributeDescription = value.getAttribute().getDescription();
+            IAttribute attribute = entry.getAttribute( attributeDescription );
+            if ( attribute == null )
+            {
+                attribute = new Attribute( entry, attributeDescription );
+                entry.addAttribute( attribute );
+            }
+            Value newValue = new Value( attribute, value.getRawValue() );
+            attribute.addValue( newValue );
+            if ( event == null )
+            {
+                event = new ValueAddedEvent( entry.getBrowserConnection(), entry, attribute, newValue );
+            }
+        }
+        EventRegistry.resumeEventFiringInCurrentThread();
+
+        // fire event
+        EventRegistry.fireEntryUpdated( event, this );
+    }
+
+
+    /**
+     * Copies all attributes and values from the 1st entry to the second entry.
+     * Clears all existing attributes from the 2nd entry.
+     * Only one event (an {@link AttributesInitializedEvent}) is fired.
+     *
+     * @param fromEntry
+     * @param toEntry
+     */
+    public void replaceAttributes( IEntry fromEntry, IEntry toEntry )
+    {
+        EventRegistry.suspendEventFiringInCurrentThread();
+        for ( IAttribute attribute : toEntry.getAttributes() )
+        {
+            toEntry.deleteAttribute( attribute );
+        }
+
+        // create new attributes
+        for ( IAttribute attribute : fromEntry.getAttributes() )
+        {
+            IAttribute newAttribute = new Attribute( toEntry, attribute.getDescription() );
+            for ( IValue value : attribute.getValues() )
+            {
+                IValue newValue = new Value( newAttribute, value.getRawValue() );
+                newAttribute.addValue( newValue );
+            }
+            toEntry.addAttribute( newAttribute );
+        }
+        EventRegistry.resumeEventFiringInCurrentThread();
+
+        EntryModificationEvent event = new AttributesInitializedEvent( toEntry );
+        EventRegistry.fireEntryUpdated( event, this );
+    }
+
+
+    /**
+     * Clones an entry, no event is fired.
+     * 
+     * @param entry the entry
+     * 
+     * @return the cloned entry
+     */
+    public IEntry cloneEntry( IEntry entry )
+    {
+        try
+        {
+            EventRegistry.suspendEventFiringInCurrentThread();
+            IBrowserConnection browserConnection = entry.getBrowserConnection();
+            LdifContentRecord record = ModelConverter.entryToLdifContentRecord( entry );
+            IEntry clonedEntry = ModelConverter.ldifContentRecordToEntry( record, browserConnection );
+            return clonedEntry;
+        }
+        catch ( InvalidNameException e )
+        {
+            throw new RuntimeException( e );
+        }
+        finally
+        {
+            EventRegistry.resumeEventFiringInCurrentThread();
+        }
+    }
+
+}

Modified: directory/studio/trunk/ldapbrowser-ui/plugin.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/plugin.xml?rev=814009&r1=814008&r2=814009&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/plugin.xml (original)
+++ directory/studio/trunk/ldapbrowser-ui/plugin.xml Fri Sep 11 20:11:30 2009
@@ -50,6 +50,7 @@
        default="true"
        icon="resources/icons/browser_entryeditor.gif"
        id="%Editor_MultiTabEntryEditor_id"
+       matchingStrategy="org.apache.directory.studio.entryeditors.MultiTabEntryEditorMatchingStrategy"
        name="%Editor_MultiTabEntryEditor_shortname">
  </editor>
  <editor
@@ -65,6 +66,7 @@
        default="true"
        icon="resources/icons/ldifeditor_new.gif"
        id="%Editor_MultiTabLdifEntryEditor_id"
+       matchingStrategy="org.apache.directory.studio.entryeditors.MultiTabEntryEditorMatchingStrategy"
        name="%Editor_MultiTabLdifEntryEditor_shortname">
  </editor>
  <editor

Modified: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorInput.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorInput.java?rev=814009&r1=814008&r2=814009&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorInput.java (original)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorInput.java Fri Sep 11 20:11:30 2009
@@ -24,6 +24,8 @@
 import org.apache.directory.studio.ldapbrowser.core.model.IBookmark;
 import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
 import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.eclipse.core.runtime.IStatus;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IPersistableElement;
@@ -31,6 +33,10 @@
 
 /**
  * The input for the entry editor.
+ * 
+ * This class also manages the shared reference copy and the shared working copy
+ * of the original entry. Each manual-save editor <b>must</b> use these entry 
+ * copies!
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
@@ -197,6 +203,50 @@
 
 
     /**
+     * Gets the shared working copy of the shared reference entry.
+     * This is used by all manual-save entry editors.
+     *
+     * @return the shared working copy of the shared reference entry 
+     */
+    public IEntry getSharedWorkingCopy( IEntryEditor editor )
+    {
+        IEntry workingCopy = BrowserUIPlugin.getDefault().getEntryEditorManager().getSharedWorkingCopy(
+            getResolvedEntry(), editor );
+        return workingCopy;
+    }
+
+
+    /**
+     * Checks if the shared working copy is dirty.
+     * @param entryEditor 
+     * 
+     * @return true, if the shared working copy is dirty
+     */
+    public boolean isSharedWorkingCopyDirty( IEntryEditor editor )
+    {
+        boolean dirty = BrowserUIPlugin.getDefault().getEntryEditorManager().isSharedWorkingCopyDirty(
+            getResolvedEntry(), editor );
+        return dirty;
+    }
+
+
+    /**
+     * Save the difference between the shared reference copy and the shared working copy
+     * to the directory server.
+     * 
+     * @param handleError the handle error
+     * 
+     * @return the status or null if there was nothing to save
+     */
+    public IStatus saveSharedWorkingCopy( boolean handleError, IEntryEditor editor )
+    {
+        IStatus status = BrowserUIPlugin.getDefault().getEntryEditorManager().saveSharedWorkingCopyDirty(
+            getResolvedEntry(), handleError, editor );
+        return status;
+    }
+
+
+    /**
      * Gets the entry input, may be null.
      *
      * @return the entry input or null



Mime
View raw message