directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r491104 [2/3] - in /directory/trunks/ldapstudio/ldapstudio-browser-ui: ./ META-INF/ src/main/java/org/apache/directory/ldapstudio/browser/ui/ src/main/java/org/apache/directory/ldapstudio/browser/ui/actions/ src/main/java/org/apache/directo...
Date Fri, 29 Dec 2006 21:15:50 GMT
Modified: directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorActionGroup.java
URL: http://svn.apache.org/viewvc/directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorActionGroup.java?view=diff&rev=491104&r1=491103&r2=491104
==============================================================================
--- directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorActionGroup.java (original)
+++ directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorActionGroup.java Fri Dec 29 13:15:47 2006
@@ -47,7 +47,7 @@
 import org.apache.directory.ldapstudio.browser.ui.actions.ValueEditorPreferencesAction;
 import org.apache.directory.ldapstudio.browser.ui.actions.proxy.BrowserActionProxy;
 import org.apache.directory.ldapstudio.browser.ui.actions.proxy.SearchResultEditorActionProxy;
-import org.apache.directory.ldapstudio.browser.ui.valueproviders.ValueProvider;
+import org.apache.directory.ldapstudio.browser.ui.valueeditors.IValueEditor;
 
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.action.IMenuListener;
@@ -165,16 +165,16 @@
             .getQuickFilterWidget() );
 
         this.openBestEditorAction = new OpenBestEditorAction( viewer, searchResultEditor.getConfiguration().getCursor(
-            viewer ), this, searchResultEditor.getConfiguration().getValueProviderManager( viewer ) );
+            viewer ), this, searchResultEditor.getConfiguration().getValueEditorManager( viewer ) );
         this.openDefaultEditorAction = new OpenDefaultEditorAction( this.openBestEditorAction );
-        ValueProvider[] valueProviders = searchResultEditor.getConfiguration().getValueProviderManager( viewer )
-            .getAllValueProviders();
-        this.openEditorActions = new OpenEditorAction[valueProviders.length];
+        IValueEditor[] valueEditors = searchResultEditor.getConfiguration().getValueEditorManager( viewer )
+            .getAllValueEditors();
+        this.openEditorActions = new OpenEditorAction[valueEditors.length];
         for ( int i = 0; i < this.openEditorActions.length; i++ )
         {
             this.openEditorActions[i] = new OpenEditorAction( viewer, searchResultEditor.getConfiguration().getCursor(
-                viewer ), this, searchResultEditor.getConfiguration().getValueProviderManager( viewer ),
-                valueProviders[i] );
+                viewer ), this, searchResultEditor.getConfiguration().getValueEditorManager( viewer ),
+                valueEditors[i] );
         }
         this.openValueEditorPreferencesAction = new ValueEditorPreferencesAction();
 
@@ -400,8 +400,8 @@
         for ( int i = 0; i < this.openEditorActions.length; i++ )
         {
             if ( this.openEditorActions[i].isEnabled()
-                && this.openEditorActions[i].getValueProvider().getClass() != this.openBestEditorAction
-                    .getBestValueProvider().getClass() )
+                && this.openEditorActions[i].getValueEditor().getClass() != this.openBestEditorAction
+                    .getBestValueEditor().getClass() )
             {
                 editorMenuManager.add( this.openEditorActions[i] );
             }

Modified: directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorCellModifier.java
URL: http://svn.apache.org/viewvc/directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorCellModifier.java?view=diff&rev=491104&r1=491103&r2=491104
==============================================================================
--- directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorCellModifier.java (original)
+++ directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorCellModifier.java Fri Dec 29 13:15:47 2006
@@ -25,13 +25,13 @@
 
 import org.apache.directory.ldapstudio.browser.core.events.ModelModifier;
 import org.apache.directory.ldapstudio.browser.core.internal.model.Attribute;
-import org.apache.directory.ldapstudio.browser.core.model.AttributeHierachie;
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierarchy;
 import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
 import org.apache.directory.ldapstudio.browser.core.model.ISearchResult;
 import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException;
 import org.apache.directory.ldapstudio.browser.core.model.schema.SchemaUtils;
 import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
-import org.apache.directory.ldapstudio.browser.ui.valueproviders.ValueProviderManager;
+import org.apache.directory.ldapstudio.browser.ui.valueeditors.internal.ValueEditorManager;
 
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.viewers.ICellModifier;
@@ -44,20 +44,20 @@
 
     private TableViewer viewer;
 
-    private ValueProviderManager valueProviderManager;
+    private ValueEditorManager valueEditorManager;
 
 
-    public SearchResultEditorCellModifier( TableViewer viewer, ValueProviderManager valueProviderManager )
+    public SearchResultEditorCellModifier( TableViewer viewer, ValueEditorManager valueEditorManager )
     {
         this.viewer = viewer;
-        this.valueProviderManager = valueProviderManager;
+        this.valueEditorManager = valueEditorManager;
     }
 
 
     public void dispose()
     {
         this.viewer = null;
-        this.valueProviderManager = null;
+        this.valueEditorManager = null;
     }
 
 
@@ -67,7 +67,7 @@
         if ( element != null && element instanceof ISearchResult && property != null )
         {
             ISearchResult result = ( ISearchResult ) element;
-            AttributeHierachie ah = result.getAttributeWithSubtypes( property );
+            AttributeHierarchy ah = result.getAttributeWithSubtypes( property );
 
             // check DN
             if ( BrowserUIConstants.DN.equals( property ) )
@@ -80,7 +80,7 @@
             {
                 try
                 {
-                    ah = new AttributeHierachie( result.getEntry(), property, new IAttribute[]
+                    ah = new AttributeHierarchy( result.getEntry(), property, new IAttribute[]
                         { new Attribute( result.getEntry(), property ) } );
                 }
                 catch ( ModelModificationException e )
@@ -122,8 +122,8 @@
                 return false;
             }
 
-            // call value provider
-            return this.valueProviderManager.getCurrentValueProvider( ah ).getRawValue( ah ) != null;
+            // call value editor
+            return this.valueEditorManager.getCurrentValueEditor( ah ).getRawValue( ah ) != null;
         }
         else
         {
@@ -138,7 +138,7 @@
         if ( element != null && element instanceof ISearchResult && property != null )
         {
             ISearchResult result = ( ISearchResult ) element;
-            AttributeHierachie ah = result.getAttributeWithSubtypes( property );
+            AttributeHierarchy ah = result.getAttributeWithSubtypes( property );
 
             if ( !this.canModify( element, property ) )
             {
@@ -149,7 +149,7 @@
             {
                 try
                 {
-                    ah = new AttributeHierachie( result.getEntry(), property, new IAttribute[]
+                    ah = new AttributeHierarchy( result.getEntry(), property, new IAttribute[]
                         { new Attribute( result.getEntry(), property ) } );
                 }
                 catch ( ModelModificationException e )
@@ -159,7 +159,7 @@
                 }
             }
 
-            return this.valueProviderManager.getCurrentValueProvider( ah ).getRawValue( ah );
+            return this.valueEditorManager.getCurrentValueEditor( ah ).getRawValue( ah );
         }
         else
         {
@@ -179,23 +179,23 @@
         if ( element != null && element instanceof ISearchResult && property != null )
         {
             ISearchResult result = ( ISearchResult ) element;
-            AttributeHierachie ah = result.getAttributeWithSubtypes( property );
+            AttributeHierarchy ah = result.getAttributeWithSubtypes( property );
 
             try
             {
                 // switch operation:
                 if ( ah == null && newRawValue != null )
                 {
-                    this.valueProviderManager.getCurrentValueProvider( result.getEntry(), property ).create(
+                    this.valueEditorManager.getCurrentValueEditor( result.getEntry(), property ).createValue(
                         result.getEntry(), property, newRawValue );
                 }
                 else if ( ah != null && newRawValue == null )
                 {
-                    this.valueProviderManager.getCurrentValueProvider( ah ).delete( ah );
+                    this.valueEditorManager.getCurrentValueEditor( ah ).deleteAttribute( ah );
                 }
                 else if ( ah != null && ah.size() == 1 && ah.getAttribute().getValueSize() == 1 && newRawValue != null )
                 {
-                    this.valueProviderManager.getCurrentValueProvider( ah ).modify( ah.getAttribute().getValues()[0],
+                    this.valueEditorManager.getCurrentValueEditor( ah ).modifyValue( ah.getAttribute().getValues()[0],
                         newRawValue );
                 }
             }

Modified: directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorConfiguration.java
URL: http://svn.apache.org/viewvc/directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorConfiguration.java?view=diff&rev=491104&r1=491103&r2=491104
==============================================================================
--- directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorConfiguration.java (original)
+++ directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorConfiguration.java Fri Dec 29 13:15:47 2006
@@ -21,7 +21,7 @@
 package org.apache.directory.ldapstudio.browser.ui.editors.searchresult;
 
 
-import org.apache.directory.ldapstudio.browser.ui.valueproviders.ValueProviderManager;
+import org.apache.directory.ldapstudio.browser.ui.valueeditors.internal.ValueEditorManager;
 import org.eclipse.jface.action.IMenuManager;
 import org.eclipse.jface.action.MenuManager;
 import org.eclipse.jface.viewers.TableViewer;
@@ -46,7 +46,7 @@
 
     protected SearchResultEditorCellModifier cellModifier;
 
-    protected ValueProviderManager valueProviderManager;
+    protected ValueEditorManager valueEditorManager;
 
     protected MenuManager contextMenuManager;
 
@@ -74,9 +74,9 @@
                 this.cellModifier.dispose();
             this.cellModifier = null;
 
-            if ( this.valueProviderManager != null )
-                this.valueProviderManager.dispose();
-            this.valueProviderManager = null;
+            if ( this.valueEditorManager != null )
+                this.valueEditorManager.dispose();
+            this.valueEditorManager = null;
 
             if ( this.contextMenuManager != null )
                 this.contextMenuManager.dispose();
@@ -133,7 +133,7 @@
     public SearchResultEditorLabelProvider getLabelProvider( TableViewer viewer )
     {
         if ( this.labelProvider == null )
-            this.labelProvider = new SearchResultEditorLabelProvider( viewer, this.getValueProviderManager( viewer ) );
+            this.labelProvider = new SearchResultEditorLabelProvider( viewer, this.getValueEditorManager( viewer ) );
 
         return labelProvider;
     }
@@ -142,7 +142,7 @@
     public SearchResultEditorCellModifier getCellModifier( TableViewer viewer )
     {
         if ( this.cellModifier == null )
-            this.cellModifier = new SearchResultEditorCellModifier( viewer, this.getValueProviderManager( viewer ) );
+            this.cellModifier = new SearchResultEditorCellModifier( viewer, this.getValueEditorManager( viewer ) );
 
         return cellModifier;
     }
@@ -157,12 +157,12 @@
     }
 
 
-    public ValueProviderManager getValueProviderManager( TableViewer viewer )
+    public ValueEditorManager getValueEditorManager( TableViewer viewer )
     {
-        if ( this.valueProviderManager == null )
-            this.valueProviderManager = new ValueProviderManager( viewer.getTable() );
+        if ( this.valueEditorManager == null )
+            this.valueEditorManager = new ValueEditorManager( viewer.getTable() );
 
-        return valueProviderManager;
+        return valueEditorManager;
     }
 
 }

Modified: directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorCursor.java
URL: http://svn.apache.org/viewvc/directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorCursor.java?view=diff&rev=491104&r1=491103&r2=491104
==============================================================================
--- directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorCursor.java (original)
+++ directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorCursor.java Fri Dec 29 13:15:47 2006
@@ -29,7 +29,7 @@
 import org.apache.directory.ldapstudio.browser.core.events.EntryUpdateListener;
 import org.apache.directory.ldapstudio.browser.core.events.EventRegistry;
 import org.apache.directory.ldapstudio.browser.core.internal.model.Attribute;
-import org.apache.directory.ldapstudio.browser.core.model.AttributeHierachie;
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierarchy;
 import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
 import org.apache.directory.ldapstudio.browser.core.model.ISearchResult;
 import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException;
@@ -148,7 +148,7 @@
     }
 
 
-    public AttributeHierachie getSelectedAttributeHierarchie()
+    public AttributeHierarchy getSelectedAttributeHierarchie()
     {
         if ( !this.isDisposed() && this.getRow() != null && this.viewer != null
             && this.viewer.getColumnProperties() != null
@@ -159,13 +159,13 @@
             if ( o instanceof ISearchResult && !BrowserUIConstants.DN.equals( property ) )
             {
                 ISearchResult sr = ( ISearchResult ) o;
-                AttributeHierachie ah = sr.getAttributeWithSubtypes( property );
+                AttributeHierarchy ah = sr.getAttributeWithSubtypes( property );
 
                 if ( ah == null )
                 {
                     try
                     {
-                        ah = new AttributeHierachie( sr.getEntry(), property, new IAttribute[]
+                        ah = new AttributeHierarchy( sr.getEntry(), property, new IAttribute[]
                             { new Attribute( sr.getEntry(), property ) } );
                     }
                     catch ( ModelModificationException e )
@@ -209,7 +209,7 @@
     public ISelection getSelection()
     {
         ISearchResult searchResult = this.getSelectedSearchResult();
-        AttributeHierachie ah = this.getSelectedAttributeHierarchie();
+        AttributeHierarchy ah = this.getSelectedAttributeHierarchie();
         String property = this.getSelectedProperty();
         // String attributeName = this.getSelectedAttributeName();
 

Modified: directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorFilter.java
URL: http://svn.apache.org/viewvc/directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorFilter.java?view=diff&rev=491104&r1=491103&r2=491104
==============================================================================
--- directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorFilter.java (original)
+++ directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorFilter.java Fri Dec 29 13:15:47 2006
@@ -23,7 +23,7 @@
 
 import java.util.ArrayList;
 
-import org.apache.directory.ldapstudio.browser.core.model.AttributeHierachie;
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierarchy;
 import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
 import org.apache.directory.ldapstudio.browser.core.model.ISearch;
 import org.apache.directory.ldapstudio.browser.core.model.ISearchResult;
@@ -102,7 +102,7 @@
             for ( int r = 0; r < returningAttributes.length; r++ )
             {
                 String ra = returningAttributes[r];
-                AttributeHierachie ah = searchResult.getAttributeWithSubtypes( ra );
+                AttributeHierarchy ah = searchResult.getAttributeWithSubtypes( ra );
                 if ( ah != null )
                 {
                     IAttribute[] attributes = ah.getAttributes();

Modified: directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorLabelProvider.java?view=diff&rev=491104&r1=491103&r2=491104
==============================================================================
--- directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorLabelProvider.java (original)
+++ directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorLabelProvider.java Fri Dec 29 13:15:47 2006
@@ -21,14 +21,14 @@
 package org.apache.directory.ldapstudio.browser.ui.editors.searchresult;
 
 
-import org.apache.directory.ldapstudio.browser.core.model.AttributeHierachie;
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierarchy;
 import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
 import org.apache.directory.ldapstudio.browser.core.model.ISearch;
 import org.apache.directory.ldapstudio.browser.core.model.ISearchResult;
 import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
 import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
-import org.apache.directory.ldapstudio.browser.ui.valueproviders.ValueProvider;
-import org.apache.directory.ldapstudio.browser.ui.valueproviders.ValueProviderManager;
+import org.apache.directory.ldapstudio.browser.ui.valueeditors.IValueEditor;
+import org.apache.directory.ldapstudio.browser.ui.valueeditors.internal.ValueEditorManager;
 
 import org.eclipse.jface.preference.PreferenceConverter;
 import org.eclipse.jface.viewers.ITableColorProvider;
@@ -46,16 +46,16 @@
     ITableColorProvider
 {
 
-    private ValueProviderManager valueProviderManager;
+    private ValueEditorManager valueEditorManager;
 
     private ISearch search;
 
     private boolean showDn;
 
 
-    public SearchResultEditorLabelProvider( TableViewer viewer, ValueProviderManager valueProviderManager )
+    public SearchResultEditorLabelProvider( TableViewer viewer, ValueEditorManager valueEditorManager )
     {
-        this.valueProviderManager = valueProviderManager;
+        this.valueEditorManager = valueEditorManager;
     }
 
 
@@ -95,7 +95,7 @@
                 }
                 else
                 {
-                    AttributeHierachie ah = result.getAttributeWithSubtypes( property );
+                    AttributeHierarchy ah = result.getAttributeWithSubtypes( property );
                     return getDisplayValue( ah );
                 }
 
@@ -124,10 +124,10 @@
     }
 
 
-    private String getDisplayValue( AttributeHierachie ah )
+    private String getDisplayValue( AttributeHierarchy ah )
     {
 
-        ValueProvider vp = this.valueProviderManager.getCurrentValueProvider( ah );
+        IValueEditor vp = this.valueEditorManager.getCurrentValueEditor( ah );
         if ( vp == null )
         {
             return "";
@@ -169,7 +169,7 @@
             }
             else if ( property != null )
             {
-                AttributeHierachie ah = result.getAttributeWithSubtypes( property );
+                AttributeHierarchy ah = result.getAttributeWithSubtypes( property );
                 if ( ah != null )
                 {
                     for ( int i = 0; i < ah.getAttributes().length; i++ )

Modified: directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorSorter.java
URL: http://svn.apache.org/viewvc/directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorSorter.java?view=diff&rev=491104&r1=491103&r2=491104
==============================================================================
--- directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorSorter.java (original)
+++ directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorSorter.java Fri Dec 29 13:15:47 2006
@@ -25,7 +25,7 @@
 import java.util.Comparator;
 
 import org.apache.directory.ldapstudio.browser.core.BrowserCoreConstants;
-import org.apache.directory.ldapstudio.browser.core.model.AttributeHierachie;
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierarchy;
 import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
 import org.apache.directory.ldapstudio.browser.core.model.IEntry;
 import org.apache.directory.ldapstudio.browser.core.model.ISearch;
@@ -267,8 +267,8 @@
         }
         else
         {
-            AttributeHierachie ah1 = entry1.getAttributeWithSubtypes( attributeName );
-            AttributeHierachie ah2 = entry2.getAttributeWithSubtypes( attributeName );
+            AttributeHierarchy ah1 = entry1.getAttributeWithSubtypes( attributeName );
+            AttributeHierarchy ah2 = entry2.getAttributeWithSubtypes( attributeName );
             if ( ah1 == null && ah2 == null )
             {
                 return this.equal();

Modified: directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorUniversalListener.java
URL: http://svn.apache.org/viewvc/directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorUniversalListener.java?view=diff&rev=491104&r1=491103&r2=491104
==============================================================================
--- directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorUniversalListener.java (original)
+++ directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorUniversalListener.java Fri Dec 29 13:15:47 2006
@@ -27,7 +27,7 @@
 import org.apache.directory.ldapstudio.browser.core.events.EventRegistry;
 import org.apache.directory.ldapstudio.browser.core.events.SearchUpdateEvent;
 import org.apache.directory.ldapstudio.browser.core.events.SearchUpdateListener;
-import org.apache.directory.ldapstudio.browser.core.model.AttributeHierachie;
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierarchy;
 import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
 import org.apache.directory.ldapstudio.browser.core.model.ISearch;
 import org.apache.directory.ldapstudio.browser.core.model.ISearchResult;
@@ -248,7 +248,7 @@
                 {
 
                     if ( startEditAction.isEnabled()
-                        && startEditAction.getBestValueProvider().getCellEditor() instanceof TextCellEditor )
+                        && startEditAction.getBestValueEditor().getCellEditor() instanceof TextCellEditor )
                     {
                         startEditAction.run();
                         CellEditor editor = viewer.getCellEditors()[cursor.getColumn()];
@@ -304,7 +304,7 @@
         {
             EmptyValueAddedEvent evae = ( EmptyValueAddedEvent ) event;
             IAttribute att = evae.getAddedValue().getAttribute();
-            AttributeHierachie ah = cursor.getSelectedAttributeHierarchie();
+            AttributeHierarchy ah = cursor.getSelectedAttributeHierarchie();
             if ( ah != null && ah.contains( att ) )
             {
                 viewer.setSelection( null, true );

Added: directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/AbstractDialogBinaryValueEditor.java
URL: http://svn.apache.org/viewvc/directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/AbstractDialogBinaryValueEditor.java?view=auto&rev=491104
==============================================================================
--- directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/AbstractDialogBinaryValueEditor.java (added)
+++ directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/AbstractDialogBinaryValueEditor.java Fri Dec 29 13:15:47 2006
@@ -0,0 +1,315 @@
+/*
+ *  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.ldapstudio.browser.ui.valueeditors;
+
+
+import org.apache.directory.ldapstudio.browser.core.events.EventRegistry;
+import org.apache.directory.ldapstudio.browser.core.events.ModelModifier;
+import org.apache.directory.ldapstudio.browser.core.internal.model.Attribute;
+import org.apache.directory.ldapstudio.browser.core.jobs.CreateValuesJob;
+import org.apache.directory.ldapstudio.browser.core.jobs.DeleteAttributesValueJob;
+import org.apache.directory.ldapstudio.browser.core.jobs.ModifyValueJob;
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierarchy;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException;
+import org.apache.directory.ldapstudio.browser.core.utils.LdifUtils;
+import org.apache.directory.ldapstudio.browser.core.utils.Utils;
+
+
+/**
+ * 
+ * Abstract base class for value editors that handle binary values
+ * in a dialog. 
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class AbstractDialogBinaryValueEditor extends AbstractDialogValueEditor implements ModelModifier
+{
+
+    protected AbstractDialogBinaryValueEditor()
+    {
+        super();
+    }
+
+
+    /**
+     * This implementation of getDisplayValue just returns a note,
+     * that the value is binary and the size of the data.
+     */
+    public String getDisplayValue( IValue value )
+    {
+        if ( showRawValues() )
+        {
+            return getPrintableString( value );
+        }
+        else
+        {
+            if ( value == null )
+            {
+                return "NULL";
+            }
+            else if ( value.isBinary() )
+            {
+                byte[] data = value.getBinaryValue();
+                return "Binary Data (" + data.length + " Bytes)";
+            }
+            else
+            {
+                return "Invalid Data";
+            }
+        }
+    }
+
+
+    /**
+     * Help method, returns a printable string if the value 
+     * is binary.
+     */
+    public static String getPrintableString( IValue value )
+    {
+        if ( value == null )
+        {
+            return "NULL";
+        }
+        else if ( value.isBinary() )
+        {
+            byte[] data = value.getBinaryValue();
+            StringBuffer sb = new StringBuffer();
+            for ( int i = 0; data != null && i < data.length && i < 128; i++ )
+            {
+                if ( data[i] > 32 && data[i] < 127 )
+                    sb.append( ( char ) data[i] );
+                else
+                    sb.append( '.' );
+            }
+            return sb.toString();
+        }
+        else if ( value.isString() )
+        {
+            return value.getStringValue();
+        }
+        else
+        {
+            return "NULL";
+        }
+    }
+
+
+    /**
+     * This implementation returns IValue.EMPTY_BINARY_VALUE if
+     * the attribute is binary.
+     */
+    protected Object getEmptyRawValue( IAttribute attribute )
+    {
+        if ( attribute.isBinary() )
+        {
+            return IValue.EMPTY_BINARY_VALUE;
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    /**
+     * This implementation returns the binary (byte[]) value 
+     * of the given value. 
+     */
+    public Object getRawValue( IValue value )
+    {
+        if ( value == null )
+        {
+            return null;
+        }
+        else if ( value.isString() )
+        {
+            return value.getBinaryValue();
+        }
+        else if ( value.isBinary() )
+        {
+            return value.getBinaryValue();
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    /**
+     * This implementation returns the value itself if it is
+     * of type byte[] or a byte[] with the UTF-8 encoded string 
+     * value if it is of type String.  
+     */
+    public Object getRawValue( IConnection connection, Object value )
+    {
+        if ( value == null )
+        {
+            return null;
+        }
+        else if ( value instanceof String )
+        {
+            return LdifUtils.utf8encode( ( String ) value );
+        }
+        else if ( value instanceof byte[] )
+        {
+            return value;
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    /**
+     * This implementation always return the binary value
+     * as byte[].
+     */
+    public Object getStringOrBinaryValue( Object rawValue )
+    {
+        if ( rawValue == null )
+        {
+            return null;
+        }
+        else if ( rawValue instanceof byte[] )
+        {
+            return rawValue;
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public final void createValue( IEntry entry, String attributeDescription, Object newRawValue )
+        throws ModelModificationException
+    {
+        if ( entry != null && attributeDescription != null && newRawValue != null && newRawValue instanceof byte[] )
+        {
+            if ( entry.getAttribute( attributeDescription ) != null )
+            {
+                this.modify( entry.getAttribute( attributeDescription ), newRawValue );
+            }
+            else
+            {
+                EventRegistry.suspendEventFireingInCurrentThread();
+                IAttribute attribute = new Attribute( entry, attributeDescription );
+                entry.addAttribute( attribute, this );
+                EventRegistry.resumeEventFireingInCurrentThread();
+
+                Object newValue;
+                if ( entry.getConnection().getSchema().getAttributeTypeDescription( attributeDescription )
+                    .getSyntaxDescription().isString() )
+                {
+                    newValue = LdifUtils.utf8decode( ( byte[] ) newRawValue );
+                }
+                else
+                {
+                    newValue = ( byte[] ) newRawValue;
+                }
+
+                new CreateValuesJob( attribute, newValue ).execute();
+            }
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    private final void modify( IAttribute attribute, Object newRawValue ) throws ModelModificationException
+    {
+        if ( attribute != null && newRawValue != null && newRawValue instanceof byte[] )
+        {
+            if ( attribute.getValueSize() == 0 )
+            {
+                byte[] newValue = ( byte[] ) newRawValue;
+                new CreateValuesJob( attribute, newValue ).execute();
+            }
+            else if ( attribute.getValueSize() == 1 )
+            {
+                this.modifyValue( attribute.getValues()[0], newRawValue );
+            }
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public final void modifyValue( IValue oldValue, Object newRawValue ) throws ModelModificationException
+    {
+        if ( oldValue != null && newRawValue != null && newRawValue instanceof byte[] )
+        {
+            byte[] newValue = ( byte[] ) newRawValue;
+            IAttribute attribute = oldValue.getAttribute();
+            if ( !Utils.equals( oldValue.getBinaryValue(), newValue ) )
+            {
+                if ( oldValue.isEmpty() )
+                {
+                    EventRegistry.suspendEventFireingInCurrentThread();
+                    attribute.deleteEmptyValue( this );
+                    EventRegistry.resumeEventFireingInCurrentThread();
+                    new CreateValuesJob( attribute, newValue ).execute();
+                }
+                else
+                {
+                    new ModifyValueJob( attribute, oldValue, newValue ).execute();
+                }
+            }
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public final void deleteAttribute( AttributeHierarchy ah ) throws ModelModificationException
+    {
+        if ( ah != null )
+        {
+            new DeleteAttributesValueJob( ah ).execute();
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public final void deleteValue( IValue oldValue ) throws ModelModificationException
+    {
+        if ( oldValue != null )
+        {
+            new DeleteAttributesValueJob( oldValue ).execute();
+        }
+    }
+
+}

Added: directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/AbstractDialogStringValueEditor.java
URL: http://svn.apache.org/viewvc/directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/AbstractDialogStringValueEditor.java?view=auto&rev=491104
==============================================================================
--- directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/AbstractDialogStringValueEditor.java (added)
+++ directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/AbstractDialogStringValueEditor.java Fri Dec 29 13:15:47 2006
@@ -0,0 +1,292 @@
+/*
+ *  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.ldapstudio.browser.ui.valueeditors;
+
+
+import org.apache.directory.ldapstudio.browser.core.events.EventRegistry;
+import org.apache.directory.ldapstudio.browser.core.events.ModelModifier;
+import org.apache.directory.ldapstudio.browser.core.internal.model.Attribute;
+import org.apache.directory.ldapstudio.browser.core.jobs.CreateValuesJob;
+import org.apache.directory.ldapstudio.browser.core.jobs.DeleteAttributesValueJob;
+import org.apache.directory.ldapstudio.browser.core.jobs.ModifyValueJob;
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierarchy;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException;
+import org.apache.directory.ldapstudio.browser.core.utils.LdifUtils;
+
+
+/**
+ * 
+ * Abstract base class for value editors that handle string values
+ * in a dialog. 
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class AbstractDialogStringValueEditor extends AbstractDialogValueEditor implements ModelModifier
+{
+
+    protected AbstractDialogStringValueEditor()
+    {
+        super();
+    }
+
+
+    /**
+     * This implementation just returns the raw value
+     */
+    public String getDisplayValue( IValue value )
+    {
+        Object obj = this.getRawValue( value );
+        return obj == null ? "NULL" : obj.toString();
+    }
+
+
+    /**
+     * This implementation returns IValue.EMPTY_STRING_VALUE if
+     * the attribute is string.
+     */
+    protected Object getEmptyRawValue( IAttribute attribute )
+    {
+        if ( attribute.isString() )
+        {
+            return IValue.EMPTY_STRING_VALUE;
+        }
+        else
+        {
+            return IValue.EMPTY_BINARY_VALUE;
+        }
+    }
+
+
+    /**
+     * This implementation returns the string value 
+     * of the given value. 
+     */
+    public Object getRawValue( IValue value )
+    {
+        if ( value == null )
+        {
+            return null;
+        }
+        else if ( value.isString() )
+        {
+            return value.getStringValue();
+        }
+        else if ( value.isBinary() )
+        {
+            return isEditable( value.getBinaryValue() ) ? value.getStringValue() : null;
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    /**
+     * This implementation returns the value itself if it is
+     * of type byte[] or a byte[] with the UTF-8 encoded string
+     * value if it is of type String.  
+     */
+    public Object getRawValue( IConnection connection, Object value )
+    {
+        if ( value == null )
+        {
+            return null;
+        }
+        else if ( value instanceof String )
+        {
+            return value;
+        }
+        else if ( value instanceof byte[] )
+        {
+            String s = LdifUtils.utf8decode( ( byte[] ) value );
+            for ( int i = 0; i < s.length(); i++ )
+            {
+                if ( Character.isISOControl( s.charAt( i ) ) && s.charAt( i ) != '\n' && s.charAt( i ) != '\r' )
+                {
+                    return null;
+                }
+            }
+            return s;
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    /**
+     * Small helper.
+     */
+    private boolean isEditable( byte[] b )
+    {
+        if ( b == null )
+        {
+            return false;
+        }
+
+        for ( int i = 0; i < b.length; i++ )
+        {
+            if ( !( b[i] == '\n' || b[i] == '\r' || ( b[i] >= '\u0020' && b[i] <= '\u007F' ) ) )
+            {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+
+    /**
+     * This implementation always return the string value
+     * as String.
+     */
+    public Object getStringOrBinaryValue( Object rawValue )
+    {
+        if ( rawValue == null )
+        {
+            return null;
+        }
+        else if ( rawValue instanceof String )
+        {
+            return rawValue;
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public final void createValue( IEntry entry, String attributeDescription, Object newRawValue )
+        throws ModelModificationException
+    {
+        if ( entry != null && attributeDescription != null && newRawValue != null && newRawValue instanceof String )
+        {
+            if ( entry.getAttribute( attributeDescription ) != null )
+            {
+                this.modify( entry.getAttribute( attributeDescription ), newRawValue );
+            }
+            else
+            {
+                EventRegistry.suspendEventFireingInCurrentThread();
+                IAttribute attribute = new Attribute( entry, attributeDescription );
+                entry.addAttribute( attribute, this );
+                EventRegistry.resumeEventFireingInCurrentThread();
+
+                Object newValue;
+                if ( entry.getConnection().getSchema().getAttributeTypeDescription( attributeDescription )
+                    .getSyntaxDescription().isString() )
+                {
+                    newValue = ( String ) newRawValue;
+                }
+                else
+                {
+                    newValue = LdifUtils.utf8encode( ( String ) newRawValue );
+                }
+
+                new CreateValuesJob( attribute, newValue ).execute();
+            }
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    private final void modify( IAttribute attribute, Object newRawValue ) throws ModelModificationException
+    {
+        if ( attribute != null && newRawValue != null && newRawValue instanceof String )
+        {
+            if ( attribute.getValueSize() == 0 )
+            {
+                String newValue = ( String ) newRawValue;
+                new CreateValuesJob( attribute, newValue ).execute();
+            }
+            else if ( attribute.getValueSize() == 1 )
+            {
+                this.modifyValue( attribute.getValues()[0], newRawValue );
+            }
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public final void modifyValue( IValue oldValue, Object newRawValue ) throws ModelModificationException
+    {
+        if ( oldValue != null && newRawValue != null && newRawValue instanceof String )
+        {
+
+            String newValue = ( String ) newRawValue;
+            IAttribute attribute = oldValue.getAttribute();
+            if ( !oldValue.getStringValue().equals( newValue ) )
+            {
+                if ( oldValue.isEmpty() )
+                {
+                    EventRegistry.suspendEventFireingInCurrentThread();
+                    attribute.deleteEmptyValue( this );
+                    EventRegistry.resumeEventFireingInCurrentThread();
+                    new CreateValuesJob( attribute, newValue ).execute();
+                }
+                else
+                {
+                    new ModifyValueJob( attribute, oldValue, newValue ).execute();
+                }
+            }
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public final void deleteAttribute( AttributeHierarchy ah ) throws ModelModificationException
+    {
+        if ( ah != null )
+        {
+            new DeleteAttributesValueJob( ah ).execute();
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public final void deleteValue( IValue oldValue ) throws ModelModificationException
+    {
+        if ( oldValue != null )
+        {
+            new DeleteAttributesValueJob( oldValue ).execute();
+        }
+    }
+
+}

Added: directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/AbstractDialogValueEditor.java
URL: http://svn.apache.org/viewvc/directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/AbstractDialogValueEditor.java?view=auto&rev=491104
==============================================================================
--- directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/AbstractDialogValueEditor.java (added)
+++ directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/AbstractDialogValueEditor.java Fri Dec 29 13:15:47 2006
@@ -0,0 +1,275 @@
+/*
+ *  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.ldapstudio.browser.ui.valueeditors;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierarchy;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * Abstract base class for value editors that handle values
+ * in a dialog. 
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class AbstractDialogValueEditor extends CellEditor implements IValueEditor
+{
+
+    /** The value to handle */
+    private Object value;
+
+    /** The shell, used to open the editor */
+    private Shell shell;
+
+    /** The name of this value editor */
+    private String name;
+
+    /** The image of this value editor */
+    private ImageDescriptor imageDescriptor;
+
+
+    /**
+     * 
+     * Creates a new instance of AbstractDialogEditor.
+     *
+     * @param parent The parent composite, used to open the dialog.
+     */
+    protected AbstractDialogValueEditor()
+    {
+    }
+
+
+    /**
+     * Returns true if the user wishes to show raw values rather than
+     * user-friendly values. If true the getDisplayValue() methods 
+     * shouldnot modify the value.
+     *
+     * @return true if raw values should be displayed
+     */
+    protected boolean showRawValues()
+    {
+        return BrowserUIPlugin.getDefault().getPreferenceStore().getBoolean(
+            BrowserUIConstants.PREFERENCE_SHOW_RAW_VALUES );
+    }
+
+
+    /**
+     * This implementation simple returns itself.
+     * 
+     * @see IValueEditor.getCellEditor()
+     */
+    public CellEditor getCellEditor()
+    {
+        return this;
+    }
+
+
+    /**
+     * This is a dialog editor, it doesn't create a control. 
+     * It just extracts and saves the shell reference from parent.
+     */
+    protected final Control createControl( Composite parent )
+    {
+        this.shell = parent.getShell();
+        return null;
+    }
+
+
+    /**
+     * This is a dialog editor, doesn't set focus. 
+     */
+    protected final void doSetFocus()
+    {
+    }
+
+
+    /**
+     * Returns the value object stored in a member.
+     */
+    protected final Object doGetValue()
+    {
+        return this.value;
+    }
+
+
+    /**
+     * Stores the value object in a member.
+     */
+    protected final void doSetValue( Object value )
+    {
+        if ( value != null && value instanceof IValue.EmptyValue )
+        {
+            IValue.EmptyValue emptyValue = ( IValue.EmptyValue ) value;
+            if ( emptyValue.isBinary() )
+                value = emptyValue.getBinaryValue();
+            else
+                value = emptyValue.getStringValue();
+        }
+        this.value = value;
+    }
+
+
+    /**
+     * The activate method is called from the JFace framework
+     * to start editing. 
+     * 
+     */
+    public final void activate()
+    {
+        boolean save = this.openDialog( shell );
+        //doSetValue( newValue );
+        if ( !save || this.value == null )
+        {
+            fireCancelEditor();
+        }
+        else
+        {
+            fireApplyEditorValue();
+            deactivate();
+        }
+    }
+
+
+    /**
+     * Opens the edit dialog. 
+     * Call getValue() to get the current value to edit. 
+     * Call setValue() to set the new value after editing. 
+     *
+     * @param shell The shell to use to open the dialog
+     * @return true if the new value should be stored, false
+     *         to cancel the editor.
+     */
+    protected abstract boolean openDialog( Shell shell );
+
+
+    /**
+     * Returns a raw value that represents an empty value.
+     * 
+     * @param attribute the attribute
+     * @return 
+     */
+    protected abstract Object getEmptyRawValue( IAttribute attribute );
+
+
+    /**
+     * This implementation of getDisplayValue() returns a 
+     * comma-separated list of all values. 
+     */
+    public String getDisplayValue( AttributeHierarchy attributeHierarchy )
+    {
+        if ( attributeHierarchy == null )
+        {
+            return "NULL";
+        }
+
+        List<IValue> valueList = new ArrayList<IValue>();
+        for ( Iterator it = attributeHierarchy.iterator(); it.hasNext(); )
+        {
+            IAttribute attribute = ( IAttribute ) it.next();
+            valueList.addAll( Arrays.asList( attribute.getValues() ) );
+        }
+
+        StringBuffer sb = new StringBuffer();
+        for ( Iterator<IValue> it = valueList.iterator(); it.hasNext(); )
+        {
+            IValue value = it.next();
+            sb.append( getDisplayValue( value ) );
+            if ( it.hasNext() )
+                sb.append( ", " );
+        }
+        return sb.toString();
+    }
+
+
+    /**
+     * This implementation calls getEmptyRawValue(IAttribute) if there are no values
+     * in attributeHierarchy and getRawValue(IValue) if attributeHierarchy
+     * contains exactly one value. Otherwise null is returned.
+     */
+    public Object getRawValue( AttributeHierarchy attributeHierarchy )
+    {
+        if ( attributeHierarchy == null )
+        {
+            return null;
+        }
+        else if ( attributeHierarchy.size() == 1 && attributeHierarchy.getAttribute().getValueSize() == 0 )
+        {
+            return getEmptyRawValue( attributeHierarchy.getAttribute() );
+        }
+        else if ( attributeHierarchy.size() == 1 && attributeHierarchy.getAttribute().getValueSize() == 1 )
+        {
+            return getRawValue( attributeHierarchy.getAttribute().getValues()[0] );
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setValueEditorName( String name )
+    {
+        this.name = name;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getValueEditorName()
+    {
+        return name;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setValueEditorImageDescriptor( ImageDescriptor imageDescriptor )
+    {
+        this.imageDescriptor = imageDescriptor;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getValueEditorImageDescriptor()
+    {
+        return imageDescriptor;
+    }
+
+}

Added: directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/AbstractInPlaceStringValueEditor.java
URL: http://svn.apache.org/viewvc/directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/AbstractInPlaceStringValueEditor.java?view=auto&rev=491104
==============================================================================
--- directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/AbstractInPlaceStringValueEditor.java (added)
+++ directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/AbstractInPlaceStringValueEditor.java Fri Dec 29 13:15:47 2006
@@ -0,0 +1,353 @@
+/*
+ *  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.ldapstudio.browser.ui.valueeditors;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.core.events.ModelModifier;
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierarchy;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException;
+import org.apache.directory.ldapstudio.browser.core.utils.LdifUtils;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.valueeditors.internal.TextValueEditor;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.TextCellEditor;
+
+
+/**
+ * 
+ * Abstract base class for value editors that handle string values
+ * withing the table or tree control. 
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class AbstractInPlaceStringValueEditor extends TextCellEditor implements IValueEditor, ModelModifier
+{
+
+    /** 
+     * @deprecated will be removed soon. Just used to delegate
+     *             createValue(), deleteValue() and modifyValue().
+     */
+    private TextValueEditor delegate;
+    
+    /** The name of this value editor */
+    private String name;
+
+    /** The image of this value editor */
+    private ImageDescriptor imageDescriptor;
+
+    protected AbstractInPlaceStringValueEditor()
+    {
+        super();
+        this.delegate = new TextValueEditor();
+    }
+
+
+    /**
+     * Returns true if the user wishes to show raw values rather than
+     * user-friendly values. If true the getDisplayValue() methods 
+     * shouldnot modify the value.
+     *
+     * @return true if raw values should be displayed
+     */
+    protected boolean showRawValues()
+    {
+        return BrowserUIPlugin.getDefault().getPreferenceStore().getBoolean(
+            BrowserUIConstants.PREFERENCE_SHOW_RAW_VALUES );
+    }
+
+
+    /**
+     * This implementation of getDisplayValue() returns a 
+     * comma-separated list of all values. 
+     */
+    public String getDisplayValue( AttributeHierarchy attributeHierarchy )
+    {
+        if ( attributeHierarchy == null )
+        {
+            return "NULL";
+        }
+
+        List<IValue> valueList = new ArrayList<IValue>();
+        for ( Iterator it = attributeHierarchy.iterator(); it.hasNext(); )
+        {
+            IAttribute attribute = ( IAttribute ) it.next();
+            valueList.addAll( Arrays.asList( attribute.getValues() ) );
+        }
+
+        StringBuffer sb = new StringBuffer();
+        for ( Iterator<IValue> it = valueList.iterator(); it.hasNext(); )
+        {
+            IValue value = it.next();
+            sb.append( getDisplayValue( value ) );
+            if ( it.hasNext() )
+                sb.append( ", " );
+        }
+        return sb.toString();
+    }
+
+
+    /**
+     * This implementation just returns the raw value
+     */
+    public String getDisplayValue( IValue value )
+    {
+        Object obj = this.getRawValue( value );
+        return obj == null ? "NULL" : obj.toString();
+    }
+
+
+    /**
+     * This implementation returns IValue.EMPTY_xx_VALUE if there are no values
+     * in attributeHierarchy or calls getRawValue(IValue) if attributeHierarchy
+     * contains exactly one value. Otherwise null is returned.
+     */
+    public Object getRawValue( AttributeHierarchy attributeHierarchy )
+    {
+        if ( attributeHierarchy == null )
+        {
+            return null;
+        }
+        else if ( attributeHierarchy.size() == 1 && attributeHierarchy.getAttribute().getValueSize() == 0 )
+        {
+            if ( attributeHierarchy.getAttribute().isString() )
+            {
+                return IValue.EMPTY_STRING_VALUE;
+            }
+            else
+            {
+                return IValue.EMPTY_BINARY_VALUE;
+            }
+        }
+        else if ( attributeHierarchy.size() == 1 && attributeHierarchy.getAttribute().getValueSize() == 1 )
+        {
+            return getRawValue( attributeHierarchy.getAttribute().getValues()[0] );
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    /**
+     * This implementation returns the string value 
+     * of the given value. 
+     */
+    public Object getRawValue( IValue value )
+    {
+        if ( value == null )
+        {
+            return null;
+        }
+        else if ( value.isString() )
+        {
+            return value.getStringValue();
+        }
+        else if ( value.isBinary() )
+        {
+            return isEditable( value.getBinaryValue() ) ? value.getStringValue() : null;
+        }
+        else
+        {
+            return null;
+        }
+    }
+    
+    
+    /**
+     * Small helper.
+     */
+    private boolean isEditable( byte[] b )
+    {
+        if ( b == null )
+        {
+            return false;
+        }
+
+        for ( int i = 0; i < b.length; i++ )
+        {
+            if ( !( b[i] == '\n' || b[i] == '\r' || ( b[i] >= '\u0020' && b[i] <= '\u007F' ) ) )
+            {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+
+    /**
+     * This implementation returns the value itself if it is
+     * of type byte[] or a byte[] with the UTF-8 encoded string
+     * value if it is of type String.  
+     */
+    public Object getRawValue( IConnection connection, Object value )
+    {
+        if ( value == null )
+        {
+            return null;
+        }
+        else if ( value instanceof String )
+        {
+            return value;
+        }
+        else if ( value instanceof byte[] )
+        {
+            String s = LdifUtils.utf8decode( ( byte[] ) value );
+            for ( int i = 0; i < s.length(); i++ )
+            {
+                if ( Character.isISOControl( s.charAt( i ) ) && s.charAt( i ) != '\n' && s.charAt( i ) != '\r' )
+                {
+                    return null;
+                }
+            }
+            return s;
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+    
+    /**
+     * This implementation always return the string value
+     * as String.
+     */
+    public Object getStringOrBinaryValue( Object rawValue )
+    {
+        if ( rawValue == null )
+        {
+            return null;
+        }
+        else if ( rawValue instanceof String )
+        {
+            return rawValue;
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+    public CellEditor getCellEditor()
+    {
+        return this;
+    }
+
+
+    protected Object doGetValue()
+    {
+        return "".equals( text.getText() ) ? null : text.getText();
+    }
+
+
+    protected void doSetValue( Object value )
+    {
+        if ( value != null && value instanceof IValue.EmptyValue )
+        {
+            value = ( ( IValue.EmptyValue ) value ).getStringValue();
+        }
+        super.doSetValue( value );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setValueEditorName( String name )
+    {
+        this.name = name;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getValueEditorName()
+    {
+        return name;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setValueEditorImageDescriptor( ImageDescriptor imageDescriptor )
+    {
+        this.imageDescriptor = imageDescriptor;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getValueEditorImageDescriptor()
+    {
+        return imageDescriptor;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public final void createValue( IEntry entry, String attributeDescription, Object newRawValue )
+        throws ModelModificationException
+    {
+        delegate.createValue( entry, attributeDescription, newRawValue );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public final void deleteAttribute( AttributeHierarchy ah ) throws ModelModificationException
+    {
+        delegate.deleteAttribute( ah );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public final void deleteValue( IValue oldValue ) throws ModelModificationException
+    {
+        delegate.deleteValue( oldValue );
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public final void modifyValue( IValue oldValue, Object newRawValue ) throws ModelModificationException
+    {
+        delegate.modifyValue( oldValue, newRawValue );
+    }
+    
+}

Added: directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/IValueEditor.java
URL: http://svn.apache.org/viewvc/directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/IValueEditor.java?view=auto&rev=491104
==============================================================================
--- directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/IValueEditor.java (added)
+++ directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/IValueEditor.java Fri Dec 29 13:15:47 2006
@@ -0,0 +1,265 @@
+/*
+ *  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.ldapstudio.browser.ui.valueeditors;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierarchy;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.swt.widgets.Composite;
+
+
+/**
+ * A ValueEditor knows how to display and edit values of a LDAP attribute.
+ * ValueEditors are used from the entry editor or search result editor 
+ * to display values to edit values in a user-friendly way.  
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface IValueEditor
+{
+
+    /**
+     * Returns the string representation of the given attribute hierarchy 
+     * presented to the user.
+     * <p>
+     * This method is called from the search result editor. A attribute hierarchy may
+     * contain multiple attributes each with multiple values. It is common that
+     * a ValueEditor returns a comma-separated list.
+     * 
+     * @param attributeHierarchy the attribute hierarchy
+     * @return the string representation of the attribute hierarchy
+     */
+    public abstract String getDisplayValue( AttributeHierarchy attributeHierarchy );
+
+
+    /**
+     * Returns the string representation of the given value 
+     * presented to the user.
+     * <p>
+     * This method is called from the entry editor.
+     * 
+     * @param value the value
+     * @return the string representation of the value
+     */
+    public abstract String getDisplayValue( IValue value );
+
+
+    /**
+     * Returns the raw value if this value editor can handle the given 
+     * attribute hierarchy. The returned value is used as input for 
+     * the CellEditor returned by getCellEditor().
+     * <p>
+     * If this value editor can't handle the given attribute hierarchy
+     * it must return null. 
+     * <p>
+     * Note: It is also possilbe that the attribute hierarchy doesn't contain
+     * a value. This means the value is up to be created.
+     * <p>
+     * This method is called from the search result editor. It is common
+     * to return null if the attribute hierarchy contains more than 
+     * one value.
+     * 
+     * @param attributeHierarchy the attribute hierarchy
+     * @return the raw value of the attribute hierarchy or null
+     */
+    public abstract Object getRawValue( AttributeHierarchy attributeHierarchy );
+
+
+    /**
+     * Returns the raw value if this value editor can handle the given 
+     * value. The returned value is used as input for the CellEditor 
+     * returned by getCellEditor().
+     * <p>
+     * If this value editor can't handle the given value it must 
+     * return null. 
+     * <p>
+     * Note: It is also possible that the value is empty!
+     * <p>
+     * This method is called from the entry editor. 
+     * 
+     * @param value the value
+     * @return the raw value of the value or null
+     */
+    public abstract Object getRawValue( IValue value );
+
+
+    /**
+     * Returns the raw value if this value editor can handle the given 
+     * value. The returned value is used as input for the CellEditor 
+     * returned by getCellEditor().
+     * <p>
+     * If this value editor can't handle the given value it must 
+     * return null. 
+     * <p>
+     * This method is called from the LDIF editor. The connection object
+     * could be used for editors handling connection-dependent values. 
+     * 
+     * @param connection the connection
+     * @param value the value either String or byte[]
+     * @return the raw value of the value or null
+     */
+    public abstract Object getRawValue( IConnection connecton, Object stringOrBinaryValue );
+
+    
+    /**
+     * Returns the String or binary byte[] value of the given raw value. 
+     * The return value is used to create or modify the value
+     * in directory.
+     * <p>
+     * This method is called after editing has been finished. The 
+     * given rawValue is the one returned by the CellEditor. 
+     * 
+     * @param rawValue the raw value return from cell editor
+     * @return the String or byte[] value
+     */
+    public abstract Object getStringOrBinaryValue( Object rawValue );
+
+
+    /**
+     * Returns the editors name, previously set with
+     * setValueEditorName().
+     * 
+     * @return the editors name
+     */
+    public abstract String getValueEditorName();
+    
+    
+    /**
+     * Sets the editors name. 
+     * 
+     * This method is called during initialization of the 
+     * value editor, the name specified in value editor
+     * extension is assigned. 
+     *
+     * @param name the editors name
+     */
+    public abstract void setValueEditorName( String name );
+
+
+    /**
+     * Returns the editors image, previously set with
+     * setValueEditorImageDescriptor().
+     * 
+     * @return the editors image
+     */
+    public abstract ImageDescriptor getValueEditorImageDescriptor();
+    
+    
+    /**
+     * Sets the editors image.
+     * 
+     * This method is called during initialization of the 
+     * value editor, the icon specified in value editor
+     * extension is assigned. 
+     *
+     * @param imageDescriptor the editors image
+     */
+    public abstract void setValueEditorImageDescriptor( ImageDescriptor imageDescriptor );
+
+    
+    /**
+     * 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 entry
+     * @param attributeDescription
+     * @param newRawValue
+     * @throws ModelModificationException
+     * @deprecated This functionality will be removed from IValueEditor soon.
+     */
+    public abstract void createValue( IEntry entry, String attributeDescription, Object newRawValue ) throws ModelModificationException;
+
+
+    /**
+     * 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 value
+     * @param newRawValue
+     * @throws ModelModificationException
+     * @deprecated This functionality will be removed from IValueEditor soon.
+     */
+    public abstract void modifyValue( IValue value, Object newRawValue ) throws ModelModificationException;
+
+
+    /**
+     * Deletes the attributes
+     * 
+     * It is called from a ICellModfier if the attribute exists and the raw
+     * value returned by the CellEditor is null.
+     * 
+     * @param attributes
+     * @throws ModelModificationException
+     * @deprecated This functionality will be removed from IValueEditor soon.
+     */
+    public abstract void deleteAttribute( AttributeHierarchy ah ) throws ModelModificationException;
+
+
+    /**
+     * Deletes the value
+     * 
+     * It is called from a ICellModfier if the value exists and the raw
+     * value returned by the CellEditor is null.
+     * 
+     * @param oldValue
+     * @throws ModelModificationException
+     * @deprecated This functionality will be removed from IValueEditor soon.
+     */
+    public abstract void deleteValue( IValue oldValue ) throws ModelModificationException;
+
+
+    /**
+     * Creates the control for this value editor under the given parent control.
+     * 
+     * @param parent the parent control
+     */
+    public abstract void create( Composite parent );
+    
+    
+    /**
+     * Disposes of this value editor and frees any associated SWT resources.
+     */
+    public abstract void dispose();
+
+
+    /**
+     * Returns the JFace CellEditor that is able to handle values returned by
+     * one of the getRawValue() or the getEmptyRawValue() methods.
+     * 
+     * The object returned by the CellEditor's getValue() method is
+     * then sent to the getStringOrBinary() method to get the 
+     * directory value.
+     * 
+     * @return the JFace CellEditor
+     * 
+     */
+    public abstract CellEditor getCellEditor();
+}

Added: directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/internal/AddressValueEditor.java
URL: http://svn.apache.org/viewvc/directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/internal/AddressValueEditor.java?view=auto&rev=491104
==============================================================================
--- directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/internal/AddressValueEditor.java (added)
+++ directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/internal/AddressValueEditor.java Fri Dec 29 13:15:47 2006
@@ -0,0 +1,68 @@
+/*
+ *  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.ldapstudio.browser.ui.valueeditors.internal;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.ui.dialogs.AddressDialog;
+import org.apache.directory.ldapstudio.browser.ui.dialogs.TextDialog;
+import org.apache.directory.ldapstudio.browser.ui.valueeditors.AbstractDialogStringValueEditor;
+import org.eclipse.swt.widgets.Shell;
+
+
+public class AddressValueEditor extends AbstractDialogStringValueEditor
+{
+
+    public AddressValueEditor()
+    {
+        super();
+    }
+
+
+    protected boolean openDialog( Shell shell )
+    {
+        Object value = getValue();
+        if ( value != null && value instanceof String )
+        {
+            AddressDialog dialog = new AddressDialog( shell, ( String ) value );
+            if ( dialog.open() == TextDialog.OK && !"".equals( dialog.getText() ) )
+            {
+                setValue( dialog.getText() );
+                return true;
+            }
+        }
+        return false;
+    }
+
+
+    public String getDisplayValue( IValue value )
+    {
+        String displayValue = super.getDisplayValue( value );
+
+        if ( !showRawValues() )
+        {
+            displayValue = displayValue.replaceAll( "\\$", ", " );
+        }
+
+        return displayValue;
+    }
+
+}

Added: directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/internal/DnValueEditor.java
URL: http://svn.apache.org/viewvc/directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/internal/DnValueEditor.java?view=auto&rev=491104
==============================================================================
--- directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/internal/DnValueEditor.java (added)
+++ directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/internal/DnValueEditor.java Fri Dec 29 13:15:47 2006
@@ -0,0 +1,161 @@
+/*
+ *  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.ldapstudio.browser.ui.valueeditors.internal;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierarchy;
+import org.apache.directory.ldapstudio.browser.core.model.DN;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.core.model.NameException;
+import org.apache.directory.ldapstudio.browser.ui.dialogs.DnDialog;
+import org.apache.directory.ldapstudio.browser.ui.dialogs.TextDialog;
+import org.apache.directory.ldapstudio.browser.ui.valueeditors.AbstractDialogStringValueEditor;
+import org.eclipse.swt.widgets.Shell;
+
+
+public class DnValueEditor extends AbstractDialogStringValueEditor
+{
+
+    public DnValueEditor()
+    {
+        super();
+    }
+
+
+    protected boolean openDialog( Shell shell )
+    {
+        Object value = getValue();
+        if ( value != null && value instanceof DnValueEditorRawValueWrapper )
+        {
+            DnValueEditorRawValueWrapper wrapper = ( DnValueEditorRawValueWrapper ) value;
+            DnDialog dialog = new DnDialog( shell, wrapper.connection, wrapper.dn );
+            if ( dialog.open() == TextDialog.OK && dialog.getDn() != null )
+            {
+                setValue( dialog.getDn().toString() );
+                return true;
+            }
+        }
+        return false;
+    }
+
+
+    public Object getRawValue( AttributeHierarchy ah )
+    {
+        if ( ah == null )
+        {
+            return null;
+        }
+        else if ( ah.size() == 1 && ah.getAttribute().getValueSize() == 0 )
+        {
+            IConnection connection = ah.getAttribute().getEntry().getConnection();
+            DN dn = null;
+            return new DnValueEditorRawValueWrapper( connection, dn );
+        }
+        else if ( ah.size() == 1 && ah.getAttribute().getValueSize() == 1 )
+        {
+            IConnection connection = ah.getAttribute().getEntry().getConnection();
+            DN dn = null;
+            try
+            {
+                dn = new DN( getDisplayValue( ah ) );
+            }
+            catch ( NameException e )
+            {
+            }
+            return new DnValueEditorRawValueWrapper( connection, dn );
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    public Object getRawValue( IValue value )
+    {
+        IConnection connection = value.getAttribute().getEntry().getConnection();
+
+        DN dn = null;
+        if ( value.isEmpty() )
+        {
+            dn = null;
+        }
+        else
+        {
+            try
+            {
+                dn = new DN( getDisplayValue( value ) );
+            }
+            catch ( NameException e )
+            {
+            }
+        }
+
+        return new DnValueEditorRawValueWrapper( connection, dn );
+    }
+
+
+    public Object getRawValue( IConnection connection, Object value )
+    {
+        Object o = super.getRawValue( connection, value );
+        if ( o != null && o instanceof String )
+        {
+            try
+            {
+                DN dn = new DN( ( String ) o );
+                return new DnValueEditorRawValueWrapper( connection, dn );
+            }
+            catch ( NameException e )
+            {
+            }
+        }
+
+        return null;
+    }
+
+
+    public String getDisplayValue( IValue value )
+    {
+        if ( value == null )
+        {
+            return "NULL";
+        }
+
+        String displayValue = value.getStringValue();
+        return displayValue;
+    }
+
+    class DnValueEditorRawValueWrapper
+    {
+        IConnection connection;
+
+        DN dn;
+
+
+        public DnValueEditorRawValueWrapper( IConnection connection, DN dn )
+        {
+            this.connection = connection;
+            this.dn = dn;
+        }
+    }
+
+}

Added: directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/internal/HexValueEditor.java
URL: http://svn.apache.org/viewvc/directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/internal/HexValueEditor.java?view=auto&rev=491104
==============================================================================
--- directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/internal/HexValueEditor.java (added)
+++ directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/internal/HexValueEditor.java Fri Dec 29 13:15:47 2006
@@ -0,0 +1,40 @@
+package org.apache.directory.ldapstudio.browser.ui.valueeditors.internal;
+
+
+import org.apache.directory.ldapstudio.browser.ui.dialogs.HexDialog;
+import org.apache.directory.ldapstudio.browser.ui.valueeditors.AbstractDialogBinaryValueEditor;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * The default editor for binary values. Uses the HexDialog.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class HexValueEditor extends AbstractDialogBinaryValueEditor
+{
+
+    public HexValueEditor()
+    {
+        super();
+    }
+
+
+    protected boolean openDialog( Shell shell )
+    {
+        Object value = getValue();
+        if ( value != null && value instanceof byte[] )
+        {
+            byte[] initialData = ( byte[] ) value;
+            HexDialog dialog = new HexDialog( shell, initialData );
+            if ( dialog.open() == HexDialog.OK && dialog.getData() != null )
+            {
+                setValue( dialog.getData() );
+                return true;
+            }
+        }
+        return false;
+    }
+
+}

Added: directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/internal/ImageValueEditor.java
URL: http://svn.apache.org/viewvc/directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/internal/ImageValueEditor.java?view=auto&rev=491104
==============================================================================
--- directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/internal/ImageValueEditor.java (added)
+++ directory/trunks/ldapstudio/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/valueeditors/internal/ImageValueEditor.java Fri Dec 29 13:15:47 2006
@@ -0,0 +1,85 @@
+/*
+ *  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.ldapstudio.browser.ui.valueeditors.internal;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.ui.dialogs.ImageDialog;
+import org.apache.directory.ldapstudio.browser.ui.dialogs.TextDialog;
+import org.apache.directory.ldapstudio.browser.ui.valueeditors.AbstractDialogBinaryValueEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Shell;
+
+
+public class ImageValueEditor extends AbstractDialogBinaryValueEditor
+{
+
+    public ImageValueEditor()
+    {
+        super();
+    }
+
+
+    protected boolean openDialog( Shell shell )
+    {
+        Object value = getValue();
+
+        if ( value != null && value instanceof byte[] )
+        {
+            byte[] currentImageData = ( byte[] ) value;
+
+            ImageDialog dialog = new ImageDialog( shell, currentImageData, SWT.IMAGE_JPEG );
+            if ( dialog.open() == TextDialog.OK && dialog.getNewImageRawData() != null )
+            {
+                setValue( dialog.getNewImageRawData() );
+                return true;
+            }
+        }
+        return false;
+    }
+
+
+    public String getDisplayValue( IValue value )
+    {
+        if ( showRawValues() )
+        {
+            return getPrintableString( value );
+        }
+        else
+        {
+            if ( value == null )
+            {
+                return "NULL";
+            }
+            if ( value.isBinary() )
+            {
+                byte[] data = value.getBinaryValue();
+                String text = ImageDialog.getImageInfo( data );
+                return text;
+            }
+            else
+            {
+                return "Invalid Image Data";
+            }
+        }
+    }
+
+}



Mime
View raw message