directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r823122 - in /directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor: dialogs/ editor/actions/
Date Thu, 08 Oct 2009 11:00:20 GMT
Author: seelmann
Date: Thu Oct  8 11:00:19 2009
New Revision: 823122

URL: http://svn.apache.org/viewvc?rev=823122&view=rev
Log:
Fix for DIRSTUDIO-557 (Edit value and edit entry are not working if DN is invalid):
o always use empty DN for 'edit value' action
o display a message in the entry editor dialog if DN is not parseable

Modified:
    directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/dialogs/LdifEntryEditorDialog.java
    directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/dialogs/messages.properties
    directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/dialogs/messages_de.properties
    directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/dialogs/messages_fr.properties
    directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/actions/AbstractOpenValueEditorAction.java

Modified: directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/dialogs/LdifEntryEditorDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/dialogs/LdifEntryEditorDialog.java?rev=823122&r1=823121&r2=823122&view=diff
==============================================================================
--- directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/dialogs/LdifEntryEditorDialog.java
(original)
+++ directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/dialogs/LdifEntryEditorDialog.java
Thu Oct  8 11:00:19 2009
@@ -23,6 +23,7 @@
 
 import javax.naming.InvalidNameException;
 
+import org.apache.directory.studio.connection.ui.widgets.BaseWidgetUtils;
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
 import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EntryEditorWidget;
 import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EntryEditorWidgetActionGroup;
@@ -55,7 +56,7 @@
 public class LdifEntryEditorDialog extends Dialog
 {
 
-    public static final String DIALOG_TITLE = Messages.getString("LdifEntryEditorDialog.LDIFRecordEditor");
//$NON-NLS-1$
+    public static final String DIALOG_TITLE = Messages.getString( "LdifEntryEditorDialog.LDIFRecordEditor"
); //$NON-NLS-1$
 
     public static final int MAX_WIDTH = 450;
 
@@ -103,6 +104,24 @@
 
         this.browserConnection = browserConnection != null ? browserConnection : new DummyConnection(
             Schema.DEFAULT_SCHEMA );
+
+        try
+        {
+            if ( ldifRecord instanceof LdifContentRecord )
+            {
+                entry = ModelConverter.ldifContentRecordToEntry( ( LdifContentRecord ) ldifRecord,
browserConnection );
+            }
+            else if ( ldifRecord instanceof LdifChangeAddRecord )
+            {
+                entry = ModelConverter.ldifChangeAddRecordToEntry( ( LdifChangeAddRecord
) ldifRecord,
+                    browserConnection );
+            }
+
+        }
+        catch ( InvalidNameException e )
+        {
+            entry = null;
+        }
     }
 
 
@@ -117,7 +136,10 @@
     protected void createButtonsForButtonBar( Composite parent )
     {
         createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false );
-        createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL,
false );
+        if ( entry != null )
+        {
+            createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL,
false );
+        }
 
         getShell().update();
         getShell().layout( true, true );
@@ -127,7 +149,7 @@
     protected void buttonPressed( int buttonId )
     {
 
-        if ( IDialogConstants.OK_ID == buttonId )
+        if ( IDialogConstants.OK_ID == buttonId && entry != null )
         {
             if ( this.ldifRecord instanceof LdifContentRecord )
             {
@@ -199,60 +221,46 @@
     protected Control createDialogArea( Composite parent )
     {
         Composite composite = ( Composite ) super.createDialogArea( parent );
-
-        // create configuration
-        configuration = new EntryEditorWidgetConfiguration();
-
-        // create main widget
-        mainWidget = new EntryEditorWidget( configuration );
-        mainWidget.createWidget( composite );
-        mainWidget.getViewer().getTree().setFocus();
-
-        // create actions
-        actionGroup = new EntryEditorWidgetActionGroupWithAttribute( mainWidget, configuration
);
-        actionGroup.fillToolBar( mainWidget.getToolBarManager() );
-        actionGroup.fillMenu( mainWidget.getMenuManager() );
-        actionGroup.fillContextMenu( mainWidget.getContextMenuManager() );
-        IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter(
-            IContextService.class );
-        contextActivation = contextService.activateContext( BrowserCommonConstants.CONTEXT_DIALOGS
);
-        actionGroup.activateGlobalActionHandlers();
-
-        // hack to activate the action handlers when changing the selection 
-        mainWidget.getViewer().addSelectionChangedListener( new ISelectionChangedListener()
-        {
-            public void selectionChanged( SelectionChangedEvent event )
-            {
-                actionGroup.deactivateGlobalActionHandlers();
-                actionGroup.activateGlobalActionHandlers();
-            }
-        } );
-
-        // create the listener
-        universalListener = new EntryEditorWidgetUniversalListener( mainWidget.getViewer(),
configuration, actionGroup,
-            actionGroup.getOpenDefaultEditorAction() );
-
-        try
+        if ( entry == null )
         {
-            if ( ldifRecord instanceof LdifContentRecord )
-            {
-                entry = ModelConverter.ldifContentRecordToEntry( ( LdifContentRecord ) ldifRecord,
browserConnection );
-            }
-            else if ( ldifRecord instanceof LdifChangeAddRecord )
-            {
-                entry = ModelConverter.ldifChangeAddRecordToEntry( ( LdifChangeAddRecord
) ldifRecord,
-                    browserConnection );
-            }
-
-            if ( entry != null )
-            {
-                universalListener.setInput( entry );
-            }
-
+            String message = Messages.getString( "LdifEntryEditorDialog.InvalidDnCantEditEntry"
); //$NON-NLS-1$
+            BaseWidgetUtils.createLabel( composite, message, 1 );
         }
-        catch ( InvalidNameException e )
+        else
         {
-            e.printStackTrace();
+            // create configuration
+            configuration = new EntryEditorWidgetConfiguration();
+
+            // create main widget
+            mainWidget = new EntryEditorWidget( configuration );
+            mainWidget.createWidget( composite );
+            mainWidget.getViewer().getTree().setFocus();
+
+            // create actions
+            actionGroup = new EntryEditorWidgetActionGroupWithAttribute( mainWidget, configuration
);
+            actionGroup.fillToolBar( mainWidget.getToolBarManager() );
+            actionGroup.fillMenu( mainWidget.getMenuManager() );
+            actionGroup.fillContextMenu( mainWidget.getContextMenuManager() );
+            IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter(
+                IContextService.class );
+            contextActivation = contextService.activateContext( BrowserCommonConstants.CONTEXT_DIALOGS
);
+            actionGroup.activateGlobalActionHandlers();
+
+            // hack to activate the action handlers when changing the selection 
+            mainWidget.getViewer().addSelectionChangedListener( new ISelectionChangedListener()
+            {
+                public void selectionChanged( SelectionChangedEvent event )
+                {
+                    actionGroup.deactivateGlobalActionHandlers();
+                    actionGroup.activateGlobalActionHandlers();
+                }
+            } );
+
+            // create the listener
+            universalListener = new EntryEditorWidgetUniversalListener( mainWidget.getViewer(),
configuration,
+                actionGroup, actionGroup.getOpenDefaultEditorAction() );
+
+            universalListener.setInput( entry );
         }
 
         applyDialogFont( composite );

Modified: directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/dialogs/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/dialogs/messages.properties?rev=823122&r1=823121&r2=823122&view=diff
==============================================================================
--- directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/dialogs/messages.properties
(original)
+++ directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/dialogs/messages.properties
Thu Oct  8 11:00:19 2009
@@ -15,4 +15,5 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
+LdifEntryEditorDialog.InvalidDnCantEditEntry=Invalid Distinguished Name, entry can't be edited
 LdifEntryEditorDialog.LDIFRecordEditor=LDIF Record Editor

Modified: directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/dialogs/messages_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/dialogs/messages_de.properties?rev=823122&r1=823121&r2=823122&view=diff
==============================================================================
--- directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/dialogs/messages_de.properties
(original)
+++ directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/dialogs/messages_de.properties
Thu Oct  8 11:00:19 2009
@@ -15,4 +15,5 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
+LdifEntryEditorDialog.InvalidDnCantEditEntry=Ung\u00fcltiger Distinguished Name, Eintrag
kann nicht bearbeitet werden
 LdifEntryEditorDialog.LDIFRecordEditor=LDIF Eintrag Editor

Modified: directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/dialogs/messages_fr.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/dialogs/messages_fr.properties?rev=823122&r1=823121&r2=823122&view=diff
==============================================================================
--- directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/dialogs/messages_fr.properties
(original)
+++ directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/dialogs/messages_fr.properties
Thu Oct  8 11:00:19 2009
@@ -15,4 +15,5 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
+LdifEntryEditorDialog.InvalidDnCantEditEntry=TODO:Invalid Distinguished Name, entry can't
be edited
 LdifEntryEditorDialog.LDIFRecordEditor=Editeur d'enregistrement LDIF

Modified: directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/actions/AbstractOpenValueEditorAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/actions/AbstractOpenValueEditorAction.java?rev=823122&r1=823121&r2=823122&view=diff
==============================================================================
--- directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/actions/AbstractOpenValueEditorAction.java
(original)
+++ directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/actions/AbstractOpenValueEditorAction.java
Thu Oct  8 11:00:19 2009
@@ -21,8 +21,6 @@
 package org.apache.directory.studio.ldifeditor.editor.actions;
 
 
-import javax.naming.InvalidNameException;
-
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
 import org.apache.directory.studio.ldapbrowser.core.model.impl.Attribute;
@@ -144,25 +142,16 @@
     protected Object getValueEditorRawValue()
     {
         IBrowserConnection connection = getConnection();
-        String dn = getDn();
         String description = getAttributeDescription();
         Object value = getValue();
 
         Object rawValue = null;
         if ( value != null )
         {
-            try
-            {
-                DummyEntry dummyEntry = new DummyEntry( new LdapDN( dn ), connection );
-                Attribute dummyAttribute = new Attribute( dummyEntry, description );
-                Value dummyValue = new Value( dummyAttribute, value );
-
-                rawValue = valueEditor.getRawValue( dummyValue );
-            }
-            catch ( InvalidNameException e )
-            {
-                e.printStackTrace();
-            }
+            DummyEntry dummyEntry = new DummyEntry( new LdapDN(), connection );
+            Attribute dummyAttribute = new Attribute( dummyEntry, description );
+            Value dummyValue = new Value( dummyAttribute, value );
+            rawValue = valueEditor.getRawValue( dummyValue );
         }
 
         return rawValue;



Mime
View raw message