directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r517021 - in /directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui: actions/proxy/ editors/entry/ widgets/entryeditor/ wizards/
Date Sun, 11 Mar 2007 21:35:50 GMT
Author: seelmann
Date: Sun Mar 11 14:35:49 2007
New Revision: 517021

URL: http://svn.apache.org/viewvc?view=rev&rev=517021
Log:
Refactored the open value editor actions within the entry editor widget.

Modified:
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/actions/proxy/BrowserActionProxy.java
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorActionGroup.java
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/AbstractOpenEditorAction.java
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/EditAttributeDescriptionAction.java
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/EntryEditorWidgetActionGroup.java
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/OpenBestEditorAction.java
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/OpenDefaultEditorAction.java
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/OpenEditorAction.java
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryAttributesWizardPageActionGroup.java

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/actions/proxy/BrowserActionProxy.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/actions/proxy/BrowserActionProxy.java?view=diff&rev=517021&r1=517020&r2=517021
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/actions/proxy/BrowserActionProxy.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/actions/proxy/BrowserActionProxy.java Sun Mar 11 14:35:49 2007
@@ -34,6 +34,7 @@
 import org.apache.directory.ldapstudio.browser.ui.actions.SelectionUtils;
 
 import org.eclipse.jface.action.Action;
+import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
 import org.eclipse.jface.viewers.ISelectionProvider;
@@ -181,6 +182,7 @@
             this.setText( this.action.getText() );
             this.setToolTipText( this.action.getText() );
             this.setEnabled( this.action.isEnabled() );
+            this.setImageDescriptor( this.action.getImageDescriptor() );
         }
     }
 

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorActionGroup.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorActionGroup.java?view=diff&rev=517021&r1=517020&r2=517021
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorActionGroup.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/entry/EntryEditorActionGroup.java Sun Mar 11 14:35:49 2007
@@ -43,6 +43,7 @@
 import org.apache.directory.ldapstudio.browser.ui.actions.proxy.EntryEditorActionProxy;
 import org.apache.directory.ldapstudio.browser.ui.widgets.entryeditor.EditAttributeDescriptionAction;
 import org.apache.directory.ldapstudio.browser.ui.widgets.entryeditor.EntryEditorWidgetActionGroup;
+import org.apache.directory.ldapstudio.browser.ui.widgets.entryeditor.OpenDefaultEditorAction;
 
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.action.IMenuListener;
@@ -70,8 +71,8 @@
 
     private ExpandAllAction expandAllAction;
 
-    private EditAttributeDescriptionAction editAttributeDescriptionAction;
-
+    private static final String editAttributeDescriptionAction = "editAttributeDescriptionAction";
+    
     private static final String refreshAttributesAction = "refreshAttributesAction";
 
     private static final String newAttributeAction = "newAttributeAction";
@@ -124,14 +125,17 @@
         super( entryEditor.getMainWidget(), entryEditor.getConfiguration() );
         TreeViewer viewer = entryEditor.getMainWidget().getViewer();
 
-        this.openDefaultEditorAction.enableRenameEntryAction();
+        openDefaultValueEditorActionProxy.dispose();
+        openDefaultValueEditorActionProxy = new EntryEditorActionProxy( viewer , new OpenDefaultEditorAction( viewer, openBestValueEditorActionProxy, true ) );
 
         this.showOperationalAttributesAction = new ShowOperationalAttributesAction();
         this.openEntryEditorPreferencePage = new OpenEntryEditorPreferencePageAction();
         this.collapseAllAction = new CollapseAllAction( viewer );
         this.expandAllAction = new ExpandAllAction( viewer );
-        this.editAttributeDescriptionAction = new EditAttributeDescriptionAction( viewer );
-
+        
+        this.entryEditorActionMap.put( editAttributeDescriptionAction,
+            new EntryEditorActionProxy( viewer, new EditAttributeDescriptionAction( viewer ) ) );
+        
         this.entryEditorActionMap.put( refreshAttributesAction,
             new EntryEditorActionProxy( viewer, new RefreshAction() ) );
 
@@ -198,8 +202,6 @@
             this.expandAllAction = null;
             this.collapseAllAction.dispose();
             this.collapseAllAction = null;
-            this.editAttributeDescriptionAction.dispose();
-            this.editAttributeDescriptionAction = null;
         }
 
         super.dispose();
@@ -301,7 +303,7 @@
         menuManager.add( new Separator() );
 
         // edit
-        menuManager.add( this.editAttributeDescriptionAction );
+        menuManager.add( ( IAction ) this.entryEditorActionMap.get( editAttributeDescriptionAction ) );
         super.addEditMenu( menuManager );
         menuManager.add( new Separator() );
 
@@ -336,8 +338,9 @@
             commandService.getCommand( naa.getActionDefinitionId() ).setHandler( new ActionHandler( naa ) );
             IAction lid = ( IAction ) this.entryEditorActionMap.get( locateDnInDitAction );
             commandService.getCommand( lid.getActionDefinitionId() ).setHandler( new ActionHandler( lid ) );
-            commandService.getCommand( editAttributeDescriptionAction.getActionDefinitionId() ).setHandler(
-                new ActionHandler( editAttributeDescriptionAction ) );
+            IAction eada = ( IAction ) this.entryEditorActionMap.get( editAttributeDescriptionAction );
+            commandService.getCommand( eada.getActionDefinitionId() ).setHandler(
+                new ActionHandler( eada ) );
         }
     }
 
@@ -360,7 +363,8 @@
             commandService.getCommand( naa.getActionDefinitionId() ).setHandler( null );
             IAction lid = ( IAction ) this.entryEditorActionMap.get( locateDnInDitAction );
             commandService.getCommand( lid.getActionDefinitionId() ).setHandler( null );
-            commandService.getCommand( editAttributeDescriptionAction.getActionDefinitionId() ).setHandler( null );
+            IAction eada = ( IAction ) this.entryEditorActionMap.get( editAttributeDescriptionAction );
+            commandService.getCommand( eada.getActionDefinitionId() ).setHandler( null );
         }
     }
 

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/AbstractOpenEditorAction.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/AbstractOpenEditorAction.java?view=diff&rev=517021&r1=517020&r2=517021
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/AbstractOpenEditorAction.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/AbstractOpenEditorAction.java Sun Mar 11 14:35:49 2007
@@ -21,6 +21,7 @@
 package org.apache.directory.ldapstudio.browser.ui.widgets.entryeditor;
 
 
+import org.apache.directory.ldapstudio.browser.ui.actions.BrowserAction;
 import org.apache.directory.ldapstudio.browser.ui.valueeditors.internal.ValueEditorManager;
 import org.eclipse.jface.viewers.CellEditor;
 import org.eclipse.jface.viewers.TreeViewer;
@@ -31,129 +32,174 @@
 import org.eclipse.swt.events.KeyListener;
 
 
-public abstract class AbstractOpenEditorAction extends AbstractEntryEditorListenerAction implements FocusListener,
-    KeyListener
+/**
+ * The base class for all value editor actions of the entry editor widget.
+ * It manages activation and closing of value editors. 
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class AbstractOpenEditorAction extends BrowserAction implements FocusListener, KeyListener
 {
 
+    /** The action group. */
     protected EntryEditorWidgetActionGroup actionGroup;
 
+    /** The value editor manager. */
     protected ValueEditorManager valueEditorManager;
 
+    /** The viewer. */
     protected TreeViewer viewer;
 
+    /** The cell editor. */
     protected CellEditor cellEditor;
 
 
+    /**
+     * Creates a new instance of AbstractOpenEditorAction.
+     * 
+     * @param viewer the viewer
+     * @param actionGroup the action group
+     * @param valueEditorManager the value editor manager
+     */
     protected AbstractOpenEditorAction( TreeViewer viewer, EntryEditorWidgetActionGroup actionGroup,
         ValueEditorManager valueEditorManager )
     {
-        super( viewer, "Editor", null, null );
         this.viewer = viewer;
         this.actionGroup = actionGroup;
         this.valueEditorManager = valueEditorManager;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void dispose()
     {
-        this.valueEditorManager = null;
-        this.actionGroup = null;
-        this.viewer = null;
-        this.cellEditor = null;
+        valueEditorManager = null;
+        actionGroup = null;
+        viewer = null;
+        cellEditor = null;
         super.dispose();
     }
 
 
+    /**
+     * Gets the cell editor.
+     * 
+     * @return the cell editor
+     */
     public CellEditor getCellEditor()
     {
-        return this.cellEditor;
+        return cellEditor;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void run()
     {
-        this.activateEditor();
+        activateEditor();
     }
 
 
+    /**
+     * Activates the editor.
+     */
     private void activateEditor()
     {
 
-        if ( !this.viewer.isCellEditorActive()
-            && this.selectedValues.length == 1
-            && this.selectedAttributes.length == 0
-            && viewer.getCellModifier().canModify( this.selectedValues[0],
+        if ( !viewer.isCellEditorActive()
+            && getSelectedValues().length == 1
+            && getSelectedAttributes().length == 0
+            && viewer.getCellModifier().canModify( getSelectedValues()[0],
                 EntryEditorWidgetTableMetadata.VALUE_COLUMN_NAME ) )
         {
 
             // set cell editor to viewer
-            this.viewer.getCellEditors()[EntryEditorWidgetTableMetadata.VALUE_COLUMN_INDEX] = this.cellEditor;
+            viewer.getCellEditors()[EntryEditorWidgetTableMetadata.VALUE_COLUMN_INDEX] = cellEditor;
 
             // add listener for end of editing
-            if ( this.cellEditor.getControl() != null )
+            if ( cellEditor.getControl() != null )
             {
-                this.cellEditor.getControl().addFocusListener( this );
-                this.cellEditor.getControl().addKeyListener( this );
+                cellEditor.getControl().addFocusListener( this );
+                cellEditor.getControl().addKeyListener( this );
             }
 
             // deactivate global actions
-            if ( this.actionGroup != null )
-                this.actionGroup.deactivateGlobalActionHandlers();
+            if ( actionGroup != null )
+            {
+                actionGroup.deactivateGlobalActionHandlers();
+            }
 
             // start editing
-            this.viewer.editElement( this.selectedValues[0], EntryEditorWidgetTableMetadata.VALUE_COLUMN_INDEX );
+            viewer.editElement( getSelectedValues()[0], EntryEditorWidgetTableMetadata.VALUE_COLUMN_INDEX );
 
-            if ( !this.viewer.isCellEditorActive() )
+            if ( !viewer.isCellEditorActive() )
             {
-                this.editorClosed();
+                editorClosed();
             }
         }
         else
         {
-            this.valueEditorManager.setUserSelectedValueEditor( null );
+            valueEditorManager.setUserSelectedValueEditor( null );
         }
     }
 
 
+    /**
+     * Editor closed.
+     */
     private void editorClosed()
     {
 
         // remove cell editors from viewer to prevend auto-editing
-        for ( int i = 0; i < this.viewer.getCellEditors().length; i++ )
+        for ( int i = 0; i < viewer.getCellEditors().length; i++ )
         {
-            this.viewer.getCellEditors()[i] = null;
+            viewer.getCellEditors()[i] = null;
         }
 
         // remove listener
-        if ( this.cellEditor.getControl() != null )
+        if ( cellEditor.getControl() != null )
         {
-            this.cellEditor.getControl().removeFocusListener( this );
-            this.cellEditor.getControl().removeKeyListener( this );
+            cellEditor.getControl().removeFocusListener( this );
+            cellEditor.getControl().removeKeyListener( this );
         }
 
         // activate global actions
-        if ( this.actionGroup != null )
-            this.actionGroup.activateGlobalActionHandlers();
+        if ( actionGroup != null )
+        {
+            actionGroup.activateGlobalActionHandlers();
+        }
 
         // reset custom value editor and set selection to notify all
-        // openeditoractions to update their
-        // enabled state.
-        this.valueEditorManager.setUserSelectedValueEditor( null );
-        this.viewer.setSelection( this.viewer.getSelection() );
+        // openeditoractions to update their enabled state.
+        valueEditorManager.setUserSelectedValueEditor( null );
+        viewer.setSelection( viewer.getSelection() );
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void focusGained( FocusEvent e )
     {
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void focusLost( FocusEvent e )
     {
-        this.editorClosed();
+        editorClosed();
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void keyPressed( KeyEvent e )
     {
         if ( e.character == SWT.ESC && e.stateMask == SWT.NONE )
@@ -163,6 +209,9 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void keyReleased( KeyEvent e )
     {
     }

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/EditAttributeDescriptionAction.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/EditAttributeDescriptionAction.java?view=diff&rev=517021&r1=517020&r2=517021
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/EditAttributeDescriptionAction.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/EditAttributeDescriptionAction.java Sun Mar 11 14:35:49 2007
@@ -24,49 +24,103 @@
 import org.apache.directory.ldapstudio.browser.core.jobs.RenameValuesJob;
 import org.apache.directory.ldapstudio.browser.core.model.IValue;
 import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.actions.BrowserAction;
 import org.apache.directory.ldapstudio.browser.ui.actions.DeleteAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.proxy.EntryEditorActionProxy;
 import org.apache.directory.ldapstudio.browser.ui.wizards.AttributeWizard;
 import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.swt.widgets.Display;
 
 
-public class EditAttributeDescriptionAction extends AbstractEntryEditorListenerAction
+/**
+ * This Action is used to edit an attribute description within the entry edtitor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class EditAttributeDescriptionAction extends BrowserAction
 {
 
-    private DeleteAction deleteAction;
+    /** To avoid duplicate implementations of the isEnabled() code we use a delete action */
+    private EntryEditorActionProxy deleteActionProxy;
 
 
-    public EditAttributeDescriptionAction( ISelectionProvider selectionProvider )
+    /**
+     * Creates a new instance of EditAttributeDescriptionAction.
+     * 
+     * @param viewer the viewer
+     */
+    public EditAttributeDescriptionAction( Viewer viewer )
     {
-        super( selectionProvider, "Edit Attribute Description", null,
-            BrowserUIConstants.ACTION_ID_EDIT_ATTRIBUTE_DESCRIPTION );
-        this.deleteAction = new DeleteAction();
+        deleteActionProxy = new EntryEditorActionProxy( viewer, new DeleteAction() );
     }
 
 
-    public void dispose()
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getCommandId()
     {
-        super.dispose();
-        this.deleteAction.dispose();
-        this.deleteAction = null;
+        return BrowserUIConstants.ACTION_ID_EDIT_ATTRIBUTE_DESCRIPTION;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public ImageDescriptor getImageDescriptor()
+    {
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getText()
+    {
+        return "Edit Attribute Description";
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isEnabled()
+    {
+        return deleteActionProxy.getAction().isEnabled();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
     public void run()
     {
-        if ( this.selectedAttributes.length == 1 )
+        if ( getSelectedAttributes().length == 1 )
         {
-            this.renameValues( this.selectedAttributes[0].getValues() );
+            renameValues( getSelectedAttributes()[0].getValues() );
         }
-        else if ( this.selectedValues.length > 0 )
+        else if ( getSelectedValues().length > 0 )
         {
-            this.renameValues( this.selectedValues );
+            renameValues( getSelectedValues() );
         }
     }
 
 
+    /**
+     * Rename the given values.
+     * 
+     * @param values the values
+     */
     private void renameValues( final IValue[] values )
     {
         AttributeWizard wizard = new AttributeWizard( "Edit Attribute Description", true, false, values[0]
@@ -80,24 +134,8 @@
             if ( newAttributeName != null && !"".equals( newAttributeName )
                 && !newAttributeName.equals( values[0].getAttribute().getDescription() ) )
             {
-                new RenameValuesJob( this.selectedEntry, values, newAttributeName ).execute();
+                new RenameValuesJob( values[0].getAttribute().getEntry(), values, newAttributeName ).execute();
             }
-        }
-    }
-
-
-    protected void updateEnabledState()
-    {
-
-        if ( this.deleteAction != null )
-        {
-            deleteAction.setSelectedAttributes( this.selectedAttributes );
-            deleteAction.setSelectedValues( this.selectedValues );
-            super.setEnabled( deleteAction.isEnabled() );
-        }
-        else
-        {
-            super.setEnabled( false );
         }
     }
 

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/EntryEditorWidgetActionGroup.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/EntryEditorWidgetActionGroup.java?view=diff&rev=517021&r1=517020&r2=517021
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/EntryEditorWidgetActionGroup.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/EntryEditorWidgetActionGroup.java Sun Mar 11 14:35:49 2007
@@ -53,143 +53,185 @@
 import org.eclipse.ui.commands.ICommandService;
 
 
+/**
+ * The EntryEditorWidgetActionGroup manages all actions of the entry editor widget.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class EntryEditorWidgetActionGroup implements IMenuListener
 {
 
+    /** The open sort dialog action. */
     protected OpenSortDialogAction openSortDialogAction;
 
+    /** The show raw values action. */
     protected ShowRawValuesAction showRawValuesAction;
 
+    /** The show quick filter action. */
     protected ShowQuickFilterAction showQuickFilterAction;
 
-    protected OpenDefaultEditorAction openDefaultEditorAction;
+    /** The open default editor action. */
+    protected EntryEditorActionProxy openDefaultValueEditorActionProxy;
 
-    protected OpenBestEditorAction openBestEditorAction;
+    /** The open best editor action. */
+    protected EntryEditorActionProxy openBestValueEditorActionProxy;
 
-    protected OpenEditorAction[] openEditorActions;
+    /** The open editor actions. */
+    protected EntryEditorActionProxy[] openValueEditorActionProxies;
 
+    /** The open value editor preferences action. */
     protected ValueEditorPreferencesAction openValueEditorPreferencesAction;
 
+    /** The Constant newValueAction. */
     protected final static String newValueAction = "newValueAction";
 
+    /** The Constant copyAction. */
     protected final static String copyAction = "copyAction";
 
+    /** The Constant pasteAction. */
     protected final static String pasteAction = "pasteAction";
 
+    /** The Constant deleteAction. */
     protected final static String deleteAction = "deleteAction";
 
+    /** The Constant selectAllAction. */
     protected final static String selectAllAction = "selectAllAction";
 
+    /** The Constant propertyDialogAction. */
     protected final static String propertyDialogAction = "propertyDialogAction";
 
-    protected Map entryEditorActionMap;
+    /** The entry editor action map. */
+    protected Map<String, EntryEditorActionProxy> entryEditorActionMap;
 
+    /** The action bars. */
     protected IActionBars actionBars;
 
+    /** The main widget. */
     private EntryEditorWidget mainWidget;
 
 
+    /**
+     * Creates a new instance of EntryEditorWidgetActionGroup.
+     * 
+     * @param mainWidget the main widget
+     * @param configuration the configuration
+     */
     public EntryEditorWidgetActionGroup( EntryEditorWidget mainWidget, EntryEditorWidgetConfiguration configuration )
     {
-
         this.mainWidget = mainWidget;
-        this.entryEditorActionMap = new HashMap();
+
+        entryEditorActionMap = new HashMap<String, EntryEditorActionProxy>();
         TreeViewer viewer = mainWidget.getViewer();
 
-        this.openSortDialogAction = new OpenSortDialogAction( configuration.getPreferences() );
-        this.showRawValuesAction = new ShowRawValuesAction();
-        this.showQuickFilterAction = new ShowQuickFilterAction( mainWidget.getQuickFilterWidget() );
-
-        this.openBestEditorAction = new OpenBestEditorAction( viewer, this, configuration
-            .getValueEditorManager( viewer ) );
-        this.openDefaultEditorAction = new OpenDefaultEditorAction( viewer, this.openBestEditorAction );
+        openSortDialogAction = new OpenSortDialogAction( configuration.getPreferences() );
+        showRawValuesAction = new ShowRawValuesAction();
+        showQuickFilterAction = new ShowQuickFilterAction( mainWidget.getQuickFilterWidget() );
+
+        openBestValueEditorActionProxy = new EntryEditorActionProxy( viewer, new OpenBestEditorAction( viewer, this,
+            configuration.getValueEditorManager( viewer ) ) );
+        openDefaultValueEditorActionProxy = new EntryEditorActionProxy( viewer, new OpenDefaultEditorAction( viewer,
+            openBestValueEditorActionProxy, false ) );
         IValueEditor[] valueEditors = configuration.getValueEditorManager( viewer ).getAllValueEditors();
-        this.openEditorActions = new OpenEditorAction[valueEditors.length];
-        for ( int i = 0; i < this.openEditorActions.length; i++ )
+        openValueEditorActionProxies = new EntryEditorActionProxy[valueEditors.length];
+        for ( int i = 0; i < openValueEditorActionProxies.length; i++ )
         {
-            this.openEditorActions[i] = new OpenEditorAction( viewer, this, configuration
-                .getValueEditorManager( viewer ), valueEditors[i] );
+            openValueEditorActionProxies[i] = new EntryEditorActionProxy( viewer, new OpenEditorAction( viewer, this,
+                configuration.getValueEditorManager( viewer ), valueEditors[i] ) );
         }
-        this.openValueEditorPreferencesAction = new ValueEditorPreferencesAction();
-
-        this.entryEditorActionMap.put( newValueAction, new EntryEditorActionProxy( viewer, new NewValueAction() ) );
+        openValueEditorPreferencesAction = new ValueEditorPreferencesAction();
 
-        this.entryEditorActionMap.put( pasteAction, new EntryEditorActionProxy( viewer, new PasteAction() ) );
-        this.entryEditorActionMap.put( copyAction, new EntryEditorActionProxy( viewer, new CopyAction(
-            ( BrowserActionProxy ) this.entryEditorActionMap.get( pasteAction ) ) ) );
-        this.entryEditorActionMap.put( deleteAction, new EntryEditorActionProxy( viewer, new DeleteAction() ) );
-        this.entryEditorActionMap.put( selectAllAction, new EntryEditorActionProxy( viewer,
-            new SelectAllAction( viewer ) ) );
+        entryEditorActionMap.put( newValueAction, new EntryEditorActionProxy( viewer, new NewValueAction() ) );
 
-        this.entryEditorActionMap.put( propertyDialogAction,
-            new EntryEditorActionProxy( viewer, new PropertiesAction() ) );
+        entryEditorActionMap.put( pasteAction, new EntryEditorActionProxy( viewer, new PasteAction() ) );
+        entryEditorActionMap.put( copyAction, new EntryEditorActionProxy( viewer, new CopyAction(
+            ( BrowserActionProxy ) entryEditorActionMap.get( pasteAction ) ) ) );
+        entryEditorActionMap.put( deleteAction, new EntryEditorActionProxy( viewer, new DeleteAction() ) );
+        entryEditorActionMap.put( selectAllAction, new EntryEditorActionProxy( viewer, new SelectAllAction( viewer ) ) );
 
+        entryEditorActionMap.put( propertyDialogAction, new EntryEditorActionProxy( viewer, new PropertiesAction() ) );
     }
 
 
+    /**
+     * Disposes this action group.
+     */
     public void dispose()
     {
-        if ( this.mainWidget != null )
+        if ( mainWidget != null )
         {
-
-            this.openSortDialogAction = null;
-            this.showQuickFilterAction.dispose();
-            this.showQuickFilterAction = null;
-            this.showRawValuesAction = null;
-
-            this.openDefaultEditorAction.dispose();
-            this.openDefaultEditorAction = null;
-            this.openBestEditorAction.dispose();
-            this.openBestEditorAction = null;
-            for ( int i = 0; i < this.openEditorActions.length; i++ )
+            openSortDialogAction = null;
+            showQuickFilterAction.dispose();
+            showQuickFilterAction = null;
+            showRawValuesAction = null;
+
+            openDefaultValueEditorActionProxy.dispose();
+            openDefaultValueEditorActionProxy = null;
+            openBestValueEditorActionProxy.dispose();
+            openBestValueEditorActionProxy = null;
+            for ( int i = 0; i < openValueEditorActionProxies.length; i++ )
             {
-                this.openEditorActions[i].dispose();
-                this.openEditorActions[i] = null;
+                openValueEditorActionProxies[i].dispose();
+                openValueEditorActionProxies[i] = null;
             }
-            this.openValueEditorPreferencesAction = null;
+            openValueEditorPreferencesAction = null;
 
-            for ( Iterator it = this.entryEditorActionMap.keySet().iterator(); it.hasNext(); )
+            for ( Iterator it = entryEditorActionMap.keySet().iterator(); it.hasNext(); )
             {
                 String key = ( String ) it.next();
-                EntryEditorActionProxy action = ( EntryEditorActionProxy ) this.entryEditorActionMap.get( key );
+                EntryEditorActionProxy action = ( EntryEditorActionProxy ) entryEditorActionMap.get( key );
                 action.dispose();
                 action = null;
                 it.remove();
             }
-            this.entryEditorActionMap.clear();
-            this.entryEditorActionMap = null;
+            entryEditorActionMap.clear();
+            entryEditorActionMap = null;
 
-            this.actionBars = null;
-            this.mainWidget = null;
+            actionBars = null;
+            mainWidget = null;
         }
-
     }
 
 
+    /**
+     * Enables global action handlers.
+     * 
+     * @param actionBars the action bars
+     */
     public void enableGlobalActionHandlers( IActionBars actionBars )
     {
         this.actionBars = actionBars;
-        this.activateGlobalActionHandlers();
+        activateGlobalActionHandlers();
     }
 
 
+    /**
+     * Fill the tool bar.
+     * 
+     * @param toolBarManager the tool bar manager
+     */
     public void fillToolBar( IToolBarManager toolBarManager )
     {
 
-        toolBarManager.add( ( IAction ) this.entryEditorActionMap.get( newValueAction ) );
+        toolBarManager.add( ( IAction ) entryEditorActionMap.get( newValueAction ) );
         toolBarManager.add( new Separator() );
-        toolBarManager.add( ( IAction ) this.entryEditorActionMap.get( deleteAction ) );
+        toolBarManager.add( ( IAction ) entryEditorActionMap.get( deleteAction ) );
         toolBarManager.add( new Separator() );
-        toolBarManager.add( this.showQuickFilterAction );
+        toolBarManager.add( showQuickFilterAction );
         toolBarManager.update( true );
 
     }
 
 
+    /**
+     * Fills the menu.
+     * 
+     * @param menuManager the menu manager
+     */
     public void fillMenu( IMenuManager menuManager )
     {
-        menuManager.add( this.openSortDialogAction );
-        menuManager.add( this.showRawValuesAction );
+        menuManager.add( openSortDialogAction );
+        menuManager.add( showRawValuesAction );
         menuManager.addMenuListener( new IMenuListener()
         {
             public void menuAboutToShow( IMenuManager manager )
@@ -201,6 +243,11 @@
     }
 
 
+    /**
+     * Fills the context menu.
+     * 
+     * @param menuManager the menu manager
+     */
     public void fillContextMenu( IMenuManager menuManager )
     {
         menuManager.setRemoveAllWhenShown( true );
@@ -208,18 +255,23 @@
     }
 
 
+    /**
+     * {@inheritDoc}.
+     * 
+     * @param menuManager the menu manager
+     */
     public void menuAboutToShow( IMenuManager menuManager )
     {
 
         // new
-        menuManager.add( ( IAction ) this.entryEditorActionMap.get( newValueAction ) );
+        menuManager.add( ( IAction ) entryEditorActionMap.get( newValueAction ) );
         menuManager.add( new Separator() );
 
         // copy, paste, delete
-        menuManager.add( ( IAction ) this.entryEditorActionMap.get( copyAction ) );
-        menuManager.add( ( IAction ) this.entryEditorActionMap.get( pasteAction ) );
-        menuManager.add( ( IAction ) this.entryEditorActionMap.get( deleteAction ) );
-        menuManager.add( ( IAction ) this.entryEditorActionMap.get( selectAllAction ) );
+        menuManager.add( ( IAction ) entryEditorActionMap.get( copyAction ) );
+        menuManager.add( ( IAction ) entryEditorActionMap.get( pasteAction ) );
+        menuManager.add( ( IAction ) entryEditorActionMap.get( deleteAction ) );
+        menuManager.add( ( IAction ) entryEditorActionMap.get( selectAllAction ) );
         menuManager.add( new Separator() );
 
         // edit
@@ -227,54 +279,61 @@
         menuManager.add( new Separator() );
 
         // properties
-        menuManager.add( ( IAction ) this.entryEditorActionMap.get( propertyDialogAction ) );
+        menuManager.add( ( IAction ) entryEditorActionMap.get( propertyDialogAction ) );
     }
 
 
+    /**
+     * Adds the value editors to the menu.
+     * 
+     * @param menuManager the menu manager
+     */
     protected void addEditMenu( IMenuManager menuManager )
     {
-        // edit
-        menuManager.add( this.openDefaultEditorAction );
+        menuManager.add( openDefaultValueEditorActionProxy );
         MenuManager editorMenuManager = new MenuManager( "Edit Value With" );
-        if ( this.openBestEditorAction.isEnabled() )
+        if ( openBestValueEditorActionProxy.isEnabled() )
         {
-            editorMenuManager.add( this.openBestEditorAction );
+            editorMenuManager.add( openBestValueEditorActionProxy );
             editorMenuManager.add( new Separator() );
         }
-        for ( int i = 0; i < this.openEditorActions.length; i++ )
+        for ( int i = 0; i < openValueEditorActionProxies.length; i++ )
         {
-            if ( this.openEditorActions[i].isEnabled()
-                && this.openEditorActions[i].getValueEditor().getClass() != this.openBestEditorAction
-                    .getBestValueEditor().getClass() )
+            if ( openValueEditorActionProxies[i].isEnabled()
+                && ( ( OpenEditorAction ) openValueEditorActionProxies[i].getAction() ).getValueEditor().getClass() != ( ( OpenBestEditorAction ) openBestValueEditorActionProxy
+                    .getAction() ).getBestValueEditor().getClass() )
             {
-                editorMenuManager.add( this.openEditorActions[i] );
+                editorMenuManager.add( openValueEditorActionProxies[i] );
             }
         }
         editorMenuManager.add( new Separator() );
-        editorMenuManager.add( this.openValueEditorPreferencesAction );
+        editorMenuManager.add( openValueEditorPreferencesAction );
         menuManager.add( editorMenuManager );
     }
 
 
+    /**
+     * Activates global action handlers.
+     */
     public void activateGlobalActionHandlers()
     {
 
         ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
             ICommandService.class );
 
-        if ( this.actionBars != null )
+        if ( actionBars != null )
         {
-            actionBars.setGlobalActionHandler( ActionFactory.COPY.getId(), ( IAction ) this.entryEditorActionMap
+            actionBars.setGlobalActionHandler( ActionFactory.COPY.getId(), ( IAction ) entryEditorActionMap
                 .get( copyAction ) );
-            actionBars.setGlobalActionHandler( ActionFactory.PASTE.getId(), ( IAction ) this.entryEditorActionMap
+            actionBars.setGlobalActionHandler( ActionFactory.PASTE.getId(), ( IAction ) entryEditorActionMap
                 .get( pasteAction ) );
-            actionBars.setGlobalActionHandler( ActionFactory.DELETE.getId(), ( IAction ) this.entryEditorActionMap
+            actionBars.setGlobalActionHandler( ActionFactory.DELETE.getId(), ( IAction ) entryEditorActionMap
                 .get( deleteAction ) );
-            actionBars.setGlobalActionHandler( ActionFactory.SELECT_ALL.getId(), ( IAction ) this.entryEditorActionMap
+            actionBars.setGlobalActionHandler( ActionFactory.SELECT_ALL.getId(), ( IAction ) entryEditorActionMap
                 .get( selectAllAction ) );
-            actionBars.setGlobalActionHandler( ActionFactory.PROPERTIES.getId(), ( IAction ) this.entryEditorActionMap
+            actionBars.setGlobalActionHandler( ActionFactory.PROPERTIES.getId(), ( IAction ) entryEditorActionMap
                 .get( propertyDialogAction ) );
-            actionBars.setGlobalActionHandler( ActionFactory.FIND.getId(), this.showQuickFilterAction ); // IWorkbenchActionDefinitionIds.FIND_REPLACE
+            actionBars.setGlobalActionHandler( ActionFactory.FIND.getId(), showQuickFilterAction ); // IWorkbenchActionDefinitionIds.FIND_REPLACE
 
             actionBars.updateActionBars();
         }
@@ -282,15 +341,15 @@
         {
             if ( commandService != null )
             {
-                IAction da = ( IAction ) this.entryEditorActionMap.get( deleteAction );
+                IAction da = ( IAction ) entryEditorActionMap.get( deleteAction );
                 da.setActionDefinitionId( "org.apache.directory.ldapstudio.browser.action.delete" );
                 commandService.getCommand( da.getActionDefinitionId() ).setHandler( new ActionHandler( da ) );
 
-                IAction ca = ( IAction ) this.entryEditorActionMap.get( copyAction );
+                IAction ca = ( IAction ) entryEditorActionMap.get( copyAction );
                 ca.setActionDefinitionId( "org.apache.directory.ldapstudio.browser.action.copy" );
                 commandService.getCommand( ca.getActionDefinitionId() ).setHandler( new ActionHandler( ca ) );
 
-                IAction pa = ( IAction ) this.entryEditorActionMap.get( pasteAction );
+                IAction pa = ( IAction ) entryEditorActionMap.get( pasteAction );
                 pa.setActionDefinitionId( "org.apache.directory.ldapstudio.browser.action.paste" );
                 commandService.getCommand( pa.getActionDefinitionId() ).setHandler( new ActionHandler( pa ) );
 
@@ -298,7 +357,7 @@
                 commandService.getCommand( showQuickFilterAction.getActionDefinitionId() ).setHandler(
                     new ActionHandler( showQuickFilterAction ) );
 
-                IAction pda = ( IAction ) this.entryEditorActionMap.get( propertyDialogAction );
+                IAction pda = ( IAction ) entryEditorActionMap.get( propertyDialogAction );
                 pda.setActionDefinitionId( "org.apache.directory.ldapstudio.browser.action.properties" );
                 commandService.getCommand( pda.getActionDefinitionId() ).setHandler( new ActionHandler( pda ) );
             }
@@ -306,22 +365,25 @@
 
         if ( commandService != null )
         {
-            IAction nva = ( IAction ) this.entryEditorActionMap.get( newValueAction );
+            IAction nva = ( IAction ) entryEditorActionMap.get( newValueAction );
             commandService.getCommand( nva.getActionDefinitionId() ).setHandler( new ActionHandler( nva ) );
-            commandService.getCommand( openDefaultEditorAction.getActionDefinitionId() ).setHandler(
-                new ActionHandler( openDefaultEditorAction ) );
+            commandService.getCommand( openDefaultValueEditorActionProxy.getActionDefinitionId() ).setHandler(
+                new ActionHandler( openDefaultValueEditorActionProxy ) );
         }
 
     }
 
 
+    /**
+     * Deactivates global action handlers.
+     */
     public void deactivateGlobalActionHandlers()
     {
 
         ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
             ICommandService.class );
 
-        if ( this.actionBars != null )
+        if ( actionBars != null )
         {
             actionBars.setGlobalActionHandler( ActionFactory.COPY.getId(), null );
             actionBars.setGlobalActionHandler( ActionFactory.PASTE.getId(), null );
@@ -336,41 +398,40 @@
         {
             if ( commandService != null )
             {
-                IAction da = ( IAction ) this.entryEditorActionMap.get( deleteAction );
+                IAction da = ( IAction ) entryEditorActionMap.get( deleteAction );
                 commandService.getCommand( da.getActionDefinitionId() ).setHandler( null );
 
-                IAction ca = ( IAction ) this.entryEditorActionMap.get( copyAction );
+                IAction ca = ( IAction ) entryEditorActionMap.get( copyAction );
                 commandService.getCommand( ca.getActionDefinitionId() ).setHandler( null );
 
-                IAction pa = ( IAction ) this.entryEditorActionMap.get( pasteAction );
+                IAction pa = ( IAction ) entryEditorActionMap.get( pasteAction );
                 commandService.getCommand( pa.getActionDefinitionId() ).setHandler( null );
 
                 commandService.getCommand( showQuickFilterAction.getActionDefinitionId() ).setHandler( null );
 
-                IAction pda = ( IAction ) this.entryEditorActionMap.get( propertyDialogAction );
+                IAction pda = ( IAction ) entryEditorActionMap.get( propertyDialogAction );
                 commandService.getCommand( pda.getActionDefinitionId() ).setHandler( null );
             }
         }
 
         if ( commandService != null )
         {
-            IAction nva = ( IAction ) this.entryEditorActionMap.get( newValueAction );
+            IAction nva = ( IAction ) entryEditorActionMap.get( newValueAction );
             commandService.getCommand( nva.getActionDefinitionId() ).setHandler( null );
-            commandService.getCommand( openDefaultEditorAction.getActionDefinitionId() ).setHandler( null );
+            commandService.getCommand( openDefaultValueEditorActionProxy.getActionDefinitionId() ).setHandler( null );
         }
 
     }
 
 
-    public OpenBestEditorAction getOpenBestEditorAction()
-    {
-        return openBestEditorAction;
-    }
-
-
+    /**
+     * Gets the open default editor action.
+     * 
+     * @return the open default editor action
+     */
     public OpenDefaultEditorAction getOpenDefaultEditorAction()
     {
-        return openDefaultEditorAction;
+        return ( OpenDefaultEditorAction ) openDefaultValueEditorActionProxy.getAction();
     }
 
 }

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/OpenBestEditorAction.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/OpenBestEditorAction.java?view=diff&rev=517021&r1=517020&r2=517021
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/OpenBestEditorAction.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/OpenBestEditorAction.java Sun Mar 11 14:35:49 2007
@@ -23,15 +23,31 @@
 
 import org.apache.directory.ldapstudio.browser.ui.valueeditors.IValueEditor;
 import org.apache.directory.ldapstudio.browser.ui.valueeditors.internal.ValueEditorManager;
+import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.viewers.TreeViewer;
 
 
+/**
+ * 
+ * The OpenBestEditorAction is used to edit a value with the best value editor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class OpenBestEditorAction extends AbstractOpenEditorAction
 {
 
+    /** The best value editor. */
     private IValueEditor bestValueEditor;
 
 
+    /**
+     * Creates a new instance of OpenBestEditorAction.
+     * 
+     * @param viewer the viewer
+     * @param actionGroup the action group
+     * @param valueEditorManager the value editor manager
+     */
     public OpenBestEditorAction( TreeViewer viewer, EntryEditorWidgetActionGroup actionGroup,
         ValueEditorManager valueEditorManager )
     {
@@ -39,42 +55,78 @@
     }
 
 
+    /**
+     * Gets the best value editor.
+     * 
+     * @return the best value editor
+     */
     public IValueEditor getBestValueEditor()
     {
         return this.bestValueEditor;
     }
 
 
-    protected void updateEnabledState()
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose()
+    {
+        bestValueEditor = null;
+        super.dispose();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getCommandId()
+    {
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public ImageDescriptor getImageDescriptor()
+    {
+        return isEnabled() ? bestValueEditor.getValueEditorImageDescriptor() : null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getText()
     {
+        return isEnabled() ? bestValueEditor.getValueEditorName() : null;
+    }
 
-        if ( this.selectedValues.length == 1
-            && this.selectedAttributes.length == 0
-            && this.viewer.getCellModifier().canModify( this.selectedValues[0],
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isEnabled()
+    {
+        if ( getSelectedValues().length == 1
+            && getSelectedAttributes().length == 0
+            && viewer.getCellModifier().canModify( getSelectedValues()[0],
                 EntryEditorWidgetTableMetadata.VALUE_COLUMN_NAME ) )
         {
-            this.bestValueEditor = this.valueEditorManager.getCurrentValueEditor( this.selectedValues[0] );
-            super.cellEditor = this.bestValueEditor.getCellEditor();
-            this.setEnabled( true );
-            this.setText( "" + this.bestValueEditor.getValueEditorName() );
-            this.setToolTipText( "" + this.bestValueEditor.getValueEditorName() );
-            this.setImageDescriptor( this.bestValueEditor.getValueEditorImageDescriptor() );
+            // update value editor
+            bestValueEditor = valueEditorManager.getCurrentValueEditor( getSelectedValues()[0] );
+            super.cellEditor = bestValueEditor.getCellEditor();
+
+            return true;
         }
         else
         {
-            // super.cellEditor = null;
-            this.setEnabled( false );
-            this.setText( "Best Editor" );
-            this.setToolTipText( "Best Editor" );
-            this.setImageDescriptor( null );
+            return false;
         }
-    }
-
-
-    public void dispose()
-    {
-        this.bestValueEditor = null;
-        super.dispose();
     }
 
 }

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/OpenDefaultEditorAction.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/OpenDefaultEditorAction.java?view=diff&rev=517021&r1=517020&r2=517021
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/OpenDefaultEditorAction.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/OpenDefaultEditorAction.java Sun Mar 11 14:35:49 2007
@@ -22,104 +22,157 @@
 
 
 import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.actions.BrowserAction;
 import org.apache.directory.ldapstudio.browser.ui.actions.RenameAction;
 import org.apache.directory.ldapstudio.browser.ui.actions.proxy.EntryEditorActionProxy;
+import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.viewers.TreeViewer;
 
 
-public class OpenDefaultEditorAction extends AbstractEntryEditorListenerAction
+/**
+ * 
+ * The OpenBestEditorAction is used to edit a value with the default value editor.
+ * This is either the best value editor or in case of an RDN attribute the rename
+ * action is invoked.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class OpenDefaultEditorAction extends BrowserAction
 {
 
-    private OpenBestEditorAction valueEditorProxy;
+    /** The best value editor proxy. */
+    private EntryEditorActionProxy bestValueEditorProxy;
 
+    /** The rename proxy. */
     private EntryEditorActionProxy renameProxy;
+    
 
-
-    public OpenDefaultEditorAction( TreeViewer viewer, OpenBestEditorAction proxy )
+    /**
+     * Creates a new instance of OpenDefaultEditorAction.
+     * 
+     * @param viewer the viewer
+     * @param bestValueEditorProxy the best value editor proxy
+     * @param enableRenameAction true to enable rename action
+     */
+    public OpenDefaultEditorAction( TreeViewer viewer, EntryEditorActionProxy bestValueEditorProxy, boolean enableRenameAction )
     {
-        super( viewer, "Edit Value", null, BrowserUIConstants.ACTION_ID_EDIT_VALUE );
-
-        this.valueEditorProxy = proxy;
-        this.renameProxy = null;
+        this.bestValueEditorProxy = bestValueEditorProxy;
+        this.renameProxy = enableRenameAction ? new EntryEditorActionProxy( viewer, new RenameAction() ) : null;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void dispose()
     {
-        this.valueEditorProxy = null;
-        this.renameProxy = null;
+        bestValueEditorProxy = null;
+        renameProxy = null;
 
         super.dispose();
     }
-
-
-    public void run()
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getCommandId()
     {
-        if ( this.valueEditorProxy != null && this.valueEditorProxy.isEnabled() )
-        {
-            this.valueEditorProxy.run();
-        }
-        else if ( this.renameProxy != null && this.renameProxy.isEnabled() )
-        {
-            this.renameProxy.run();
-        }
+        return BrowserUIConstants.ACTION_ID_EDIT_VALUE;
     }
-
-
-    protected void updateEnabledState()
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public ImageDescriptor getImageDescriptor()
     {
-
-        // update proxy selections
-        if ( this.valueEditorProxy != null )
-        {
-            if ( this.currentSelectionChangedEvent != null )
-            {
-                this.valueEditorProxy.selectionChanged( currentSelectionChangedEvent );
-            }
-            this.valueEditorProxy.updateEnabledState();
-        }
-        if ( this.renameProxy != null )
-        {
-            if ( this.currentSelectionChangedEvent != null )
-            {
-                this.renameProxy.selectionChanged( currentSelectionChangedEvent );
-            }
-            this.renameProxy.updateAction();
-        }
-
-        // update my state
-        if ( this.valueEditorProxy != null && this.renameProxy != null )
-        {
-            this.setEnabled( this.valueEditorProxy.isEnabled() || this.renameProxy.isEnabled() );
-        }
-        else if ( this.renameProxy != null )
+        if ( bestValueEditorProxy != null )
         {
-            this.setEnabled( this.renameProxy.isEnabled() );
+            return bestValueEditorProxy.getImageDescriptor();
         }
-        else if ( this.valueEditorProxy != null )
+        else if ( renameProxy != null )
         {
-            this.setEnabled( this.valueEditorProxy.isEnabled() );
+            return renameProxy.getImageDescriptor();
         }
         else
         {
-            this.setEnabled( false );
-        }
-
-        if ( this.valueEditorProxy != null )
-        {
-            this.setImageDescriptor( this.valueEditorProxy.getImageDescriptor() );
-        }
-        else if ( this.renameProxy != null )
-        {
-            this.setImageDescriptor( this.renameProxy.getImageDescriptor() );
+            return null;
         }
-
     }
-
-
-    public void enableRenameEntryAction()
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getText()
+    {
+        return "Edit Value";
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isEnabled()
+    {
+//      // update proxy selections
+//      if ( bestValueEditorProxy != null )
+//      {
+//          if ( this.currentSelectionChangedEvent != null )
+//          {
+//              this.valueEditorProxy.selectionChanged( currentSelectionChangedEvent );
+//          }
+//          this.valueEditorProxy.updateEnabledState();
+//      }
+//      if ( this.renameProxy != null )
+//      {
+//          if ( this.currentSelectionChangedEvent != null )
+//          {
+//              this.renameProxy.selectionChanged( currentSelectionChangedEvent );
+//          }
+//          this.renameProxy.updateAction();
+//      }
+
+      if ( bestValueEditorProxy != null && renameProxy != null )
+      {
+          return bestValueEditorProxy.isEnabled() || renameProxy.isEnabled();
+      }
+      else if ( renameProxy != null )
+      {
+          return renameProxy.isEnabled();
+      }
+      else if ( bestValueEditorProxy != null )
+      {
+          return bestValueEditorProxy.isEnabled();
+      }
+      else
+      {
+          return false;
+      }
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void run()
     {
-        this.renameProxy = new EntryEditorActionProxy( valueEditorProxy.viewer, new RenameAction() );
+      if ( bestValueEditorProxy != null && bestValueEditorProxy.isEnabled() )
+      {
+          bestValueEditorProxy.run();
+      }
+      else if ( renameProxy != null && renameProxy.isEnabled() )
+      {
+          renameProxy.run();
+      }
+        
     }
 
 }

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/OpenEditorAction.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/OpenEditorAction.java?view=diff&rev=517021&r1=517020&r2=517021
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/OpenEditorAction.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/entryeditor/OpenEditorAction.java Sun Mar 11 14:35:49 2007
@@ -25,65 +25,122 @@
 
 import org.apache.directory.ldapstudio.browser.ui.valueeditors.IValueEditor;
 import org.apache.directory.ldapstudio.browser.ui.valueeditors.internal.ValueEditorManager;
+import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.viewers.TreeViewer;
 
 
+/**
+ * The OpenEditorAction is used to edit a value with a specific value editor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class OpenEditorAction extends AbstractOpenEditorAction
 {
 
+    /** The specific value editor. */
     private IValueEditor valueEditor;
 
 
+    /**
+     * Creates a new instance of OpenEditorAction.
+     * 
+     * @param viewer the viewer
+     * @param actionGroup the action group
+     * @param valueEditorManager the value editor manager
+     * @param valueEditor the specific value editor
+     */
     public OpenEditorAction( TreeViewer viewer, EntryEditorWidgetActionGroup actionGroup,
         ValueEditorManager valueEditorManager, IValueEditor valueEditor )
     {
         super( viewer, actionGroup, valueEditorManager );
         super.cellEditor = valueEditor.getCellEditor();
         this.valueEditor = valueEditor;
-
-        this.setText( "" + this.valueEditor.getValueEditorName() );
-        this.setToolTipText( "" + this.valueEditor.getValueEditorName() );
-        this.setImageDescriptor( this.valueEditor.getValueEditorImageDescriptor() );
     }
 
 
+    /**
+     * Gets the value editor.
+     * 
+     * @return the value editor
+     */
     public IValueEditor getValueEditor()
     {
-        return this.valueEditor;
-    }
-
-
-    protected void updateEnabledState()
-    {
-        if ( this.selectedValues.length == 1
-            && this.selectedAttributes.length == 0
-            && this.viewer.getCellModifier().canModify( this.selectedValues[0],
-                EntryEditorWidgetTableMetadata.VALUE_COLUMN_NAME ) )
-        {
-            IValueEditor[] alternativeVps = this.valueEditorManager
-                .getAlternativeValueEditors( this.selectedValues[0] );
-            this.setEnabled( Arrays.asList( alternativeVps ).contains( this.valueEditor )
-                && this.valueEditor.getRawValue( this.selectedValues[0] ) != null );
-        }
-        else
-        {
-            this.setEnabled( false );
-        }
-
+        return valueEditor;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void run()
     {
-        this.valueEditorManager.setUserSelectedValueEditor( this.valueEditor );
+        // ensure that the specific value editor is activated 
+        valueEditorManager.setUserSelectedValueEditor( valueEditor );
+
         super.run();
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void dispose()
     {
         this.valueEditor = null;
         super.dispose();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getCommandId()
+    {
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public ImageDescriptor getImageDescriptor()
+    {
+        return valueEditor.getValueEditorImageDescriptor();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getText()
+    {
+        return valueEditor.getValueEditorName();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isEnabled()
+    {
+        if ( getSelectedValues().length == 1
+            && getSelectedAttributes().length == 0
+            && viewer.getCellModifier().canModify( getSelectedValues()[0],
+                EntryEditorWidgetTableMetadata.VALUE_COLUMN_NAME ) )
+        {
+            IValueEditor[] alternativeVps = valueEditorManager.getAlternativeValueEditors( getSelectedValues()[0] );
+            return Arrays.asList( alternativeVps ).contains( valueEditor )
+                && valueEditor.getRawValue( getSelectedValues()[0] ) != null;
+        }
+        else
+        {
+            return false;
+        }
     }
 
 }

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryAttributesWizardPageActionGroup.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryAttributesWizardPageActionGroup.java?view=diff&rev=517021&r1=517020&r2=517021
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryAttributesWizardPageActionGroup.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryAttributesWizardPageActionGroup.java Sun Mar 11 14:35:49 2007
@@ -39,48 +39,54 @@
 import org.eclipse.ui.commands.ICommandService;
 
 
+/**
+ * This class manages all the actions of the attribute page of the new entry wizard.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class NewEntryAttributesWizardPageActionGroup extends EntryEditorWidgetActionGroup
 {
 
-    private EditAttributeDescriptionAction editAttributeDescriptionAction;
+    /** The Constant editAttributeDescriptionAction. */
+    private static final String editAttributeDescriptionAction = "editAttributeDescriptionAction";
 
+    /** The Constant newAttributeAction. */
     private static final String newAttributeAction = "newAttributeAction";
 
+    /** The Constant deleteAllValuesAction. */
     private static final String deleteAllValuesAction = "deleteAllValuesAction";
 
 
+    /**
+     * 
+     * Creates a new instance of NewEntryAttributesWizardPageActionGroup.
+     *
+     * @param mainWidget
+     * @param configuration
+     */
     public NewEntryAttributesWizardPageActionGroup( EntryEditorWidget mainWidget,
         EntryEditorWidgetConfiguration configuration )
     {
         super( mainWidget, configuration );
         TreeViewer viewer = mainWidget.getViewer();
 
-        this.editAttributeDescriptionAction = new EditAttributeDescriptionAction( viewer );
-
-        this.entryEditorActionMap.put( newAttributeAction,
-            new EntryEditorActionProxy( viewer, new NewAttributeAction() ) );
-        this.entryEditorActionMap.put( deleteAllValuesAction, new EntryEditorActionProxy( viewer,
+        entryEditorActionMap.put( editAttributeDescriptionAction, new EntryEditorActionProxy( viewer,
+            new EditAttributeDescriptionAction( viewer ) ) );
+        entryEditorActionMap.put( newAttributeAction, new EntryEditorActionProxy( viewer, new NewAttributeAction() ) );
+        entryEditorActionMap.put( deleteAllValuesAction, new EntryEditorActionProxy( viewer,
             new DeleteAllValuesAction() ) );
 
     }
 
 
-    public void dispose()
-    {
-        if ( this.editAttributeDescriptionAction != null )
-        {
-
-            this.editAttributeDescriptionAction.dispose();
-            this.editAttributeDescriptionAction = null;
-        }
-        super.dispose();
-    }
-
-
+    /**
+     * {@inheritDoc}
+     */
     public void fillToolBar( IToolBarManager toolBarManager )
     {
-        toolBarManager.add( ( IAction ) this.entryEditorActionMap.get( newValueAction ) );
-        toolBarManager.add( ( IAction ) this.entryEditorActionMap.get( newAttributeAction ) );
+        toolBarManager.add( ( IAction ) entryEditorActionMap.get( newValueAction ) );
+        toolBarManager.add( ( IAction ) entryEditorActionMap.get( newAttributeAction ) );
         toolBarManager.add( new Separator() );
         toolBarManager.add( ( IAction ) this.entryEditorActionMap.get( deleteAction ) );
         toolBarManager.add( ( IAction ) this.entryEditorActionMap.get( deleteAllValuesAction ) );
@@ -90,63 +96,70 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void menuAboutToShow( IMenuManager menuManager )
     {
-
         // new
-        menuManager.add( ( IAction ) this.entryEditorActionMap.get( newAttributeAction ) );
-        menuManager.add( ( IAction ) this.entryEditorActionMap.get( newValueAction ) );
+        menuManager.add( ( IAction ) entryEditorActionMap.get( newAttributeAction ) );
+        menuManager.add( ( IAction ) entryEditorActionMap.get( newValueAction ) );
         menuManager.add( new Separator() );
 
         // copy, paste, delete
-        menuManager.add( ( IAction ) this.entryEditorActionMap.get( copyAction ) );
-        menuManager.add( ( IAction ) this.entryEditorActionMap.get( pasteAction ) );
-        menuManager.add( ( IAction ) this.entryEditorActionMap.get( deleteAction ) );
-        menuManager.add( ( IAction ) this.entryEditorActionMap.get( selectAllAction ) );
+        menuManager.add( ( IAction ) entryEditorActionMap.get( copyAction ) );
+        menuManager.add( ( IAction ) entryEditorActionMap.get( pasteAction ) );
+        menuManager.add( ( IAction ) entryEditorActionMap.get( deleteAction ) );
+        menuManager.add( ( IAction ) entryEditorActionMap.get( selectAllAction ) );
         MenuManager copyMenuManager = new MenuManager( "Advanced" );
-        copyMenuManager.add( ( IAction ) this.entryEditorActionMap.get( deleteAllValuesAction ) );
+        copyMenuManager.add( ( IAction ) entryEditorActionMap.get( deleteAllValuesAction ) );
         menuManager.add( copyMenuManager );
         menuManager.add( new Separator() );
 
         // edit
-        menuManager.add( this.editAttributeDescriptionAction );
+        menuManager.add( ( IAction ) entryEditorActionMap.get( editAttributeDescriptionAction ) );
         super.addEditMenu( menuManager );
         menuManager.add( new Separator() );
 
         // properties
-        menuManager.add( ( IAction ) this.entryEditorActionMap.get( propertyDialogAction ) );
+        menuManager.add( ( IAction ) entryEditorActionMap.get( propertyDialogAction ) );
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void activateGlobalActionHandlers()
     {
-
         super.activateGlobalActionHandlers();
 
         ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
             ICommandService.class );
         if ( commandService != null )
         {
-            IAction naa = ( IAction ) this.entryEditorActionMap.get( newAttributeAction );
+            IAction naa = ( IAction ) entryEditorActionMap.get( newAttributeAction );
             commandService.getCommand( naa.getActionDefinitionId() ).setHandler( new ActionHandler( naa ) );
-            commandService.getCommand( editAttributeDescriptionAction.getActionDefinitionId() ).setHandler(
-                new ActionHandler( editAttributeDescriptionAction ) );
+            IAction eada = ( IAction ) entryEditorActionMap.get( editAttributeDescriptionAction );
+            commandService.getCommand( eada.getActionDefinitionId() ).setHandler( new ActionHandler( eada ) );
         }
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void deactivateGlobalActionHandlers()
     {
-
         super.deactivateGlobalActionHandlers();
 
         ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
             ICommandService.class );
         if ( commandService != null )
         {
-            IAction naa = ( IAction ) this.entryEditorActionMap.get( newAttributeAction );
+            IAction naa = ( IAction ) entryEditorActionMap.get( newAttributeAction );
             commandService.getCommand( naa.getActionDefinitionId() ).setHandler( null );
-            commandService.getCommand( editAttributeDescriptionAction.getActionDefinitionId() ).setHandler( null );
+            IAction eada = ( IAction ) entryEditorActionMap.get( editAttributeDescriptionAction );
+            commandService.getCommand( eada.getActionDefinitionId() ).setHandler( null );
         }
     }
 



Mime
View raw message