directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r531018 - in /directory/ldapstudio/trunk/ldapstudio-valueeditors/src/main/java/org/apache/directory/ldapstudio/valueeditors/dn: DnDialog.java DnValueEditor.java
Date Sat, 21 Apr 2007 11:11:12 GMT
Author: seelmann
Date: Sat Apr 21 04:11:11 2007
New Revision: 531018

URL: http://svn.apache.org/viewvc?view=rev&rev=531018
Log:
Fixed a bug. a non-parsable DN wasn't displayed

Modified:
    directory/ldapstudio/trunk/ldapstudio-valueeditors/src/main/java/org/apache/directory/ldapstudio/valueeditors/dn/DnDialog.java
    directory/ldapstudio/trunk/ldapstudio-valueeditors/src/main/java/org/apache/directory/ldapstudio/valueeditors/dn/DnValueEditor.java

Modified: directory/ldapstudio/trunk/ldapstudio-valueeditors/src/main/java/org/apache/directory/ldapstudio/valueeditors/dn/DnDialog.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-valueeditors/src/main/java/org/apache/directory/ldapstudio/valueeditors/dn/DnDialog.java?view=diff&rev=531018&r1=531017&r2=531018
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-valueeditors/src/main/java/org/apache/directory/ldapstudio/valueeditors/dn/DnDialog.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-valueeditors/src/main/java/org/apache/directory/ldapstudio/valueeditors/dn/DnDialog.java
Sat Apr 21 04:11:11 2007
@@ -6,16 +6,16 @@
  *  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. 
- *  
+ *  under the License.
+ *
  */
 
 package org.apache.directory.ldapstudio.valueeditors.dn;
@@ -82,6 +82,14 @@
     }
 
 
+    protected Control createButtonBar( Composite parent )
+    {
+        Control control = super.createButtonBar( parent );
+        widgetModified( null );
+        return control;
+    }
+
+
     protected Control createDialogArea( Composite parent )
     {
 
@@ -104,7 +112,8 @@
     {
         if ( getButton( IDialogConstants.OK_ID ) != null )
         {
-            getButton( IDialogConstants.OK_ID ).setEnabled( this.entryWidget.getDn() != null
);
+            getButton( IDialogConstants.OK_ID ).setEnabled(
+                this.entryWidget.getDn() != null && !"".equals( this.entryWidget.getDn().toString()
) );
         }
     }
 

Modified: directory/ldapstudio/trunk/ldapstudio-valueeditors/src/main/java/org/apache/directory/ldapstudio/valueeditors/dn/DnValueEditor.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-valueeditors/src/main/java/org/apache/directory/ldapstudio/valueeditors/dn/DnValueEditor.java?view=diff&rev=531018&r1=531017&r2=531018
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-valueeditors/src/main/java/org/apache/directory/ldapstudio/valueeditors/dn/DnValueEditor.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-valueeditors/src/main/java/org/apache/directory/ldapstudio/valueeditors/dn/DnValueEditor.java
Sat Apr 21 04:11:11 2007
@@ -6,16 +6,16 @@
  *  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. 
- *  
+ *  under the License.
+ *
  */
 
 package org.apache.directory.ldapstudio.valueeditors.dn;
@@ -32,8 +32,8 @@
 
 
 /**
- * Implementation of IValueEditor for syntax 1.3.6.1.4.1.1466.115.121.1.12 
- * (Distinguished Name). 
+ * Implementation of IValueEditor for syntax 1.3.6.1.4.1.1466.115.121.1.12
+ * (Distinguished Name).
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
@@ -43,7 +43,7 @@
 
     /**
      * {@inheritDoc}
-     * 
+     *
      * This implementation opens the DnDialog.
      */
     protected boolean openDialog( Shell shell )
@@ -52,7 +52,16 @@
         if ( value != null && value instanceof DnValueEditorRawValueWrapper )
         {
             DnValueEditorRawValueWrapper wrapper = ( DnValueEditorRawValueWrapper ) value;
-            DnDialog dialog = new DnDialog( shell, wrapper.connection, wrapper.dn );
+            DN dn;
+            try
+            {
+                dn = new DN( wrapper.dn );
+            }
+            catch ( NameException e )
+            {
+                dn = null;
+            }
+            DnDialog dialog = new DnDialog( shell, wrapper.connection, dn );
             if ( dialog.open() == TextDialog.OK && dialog.getDn() != null )
             {
                 setValue( dialog.getDn().toString() );
@@ -65,12 +74,12 @@
 
     /**
      * {@inheritDoc}
-     * 
-     * Returns a DnValueEditorRawValueWrapper with the connection of 
+     *
+     * Returns a DnValueEditorRawValueWrapper with the connection of
      * the attribute hierarchy and a null DN if there are no values
      * in attributeHierarchy.
-     * 
-     * Returns a DnValueEditorRawValueWrapper with the connection of 
+     *
+     * Returns a DnValueEditorRawValueWrapper with the connection of
      * the attribute hierarchy and a DN if there is one value
      * in attributeHierarchy.
      */
@@ -83,21 +92,12 @@
         else if ( attributeHierarchy.size() == 1 && attributeHierarchy.getAttribute().getValueSize()
== 0 )
         {
             IConnection connection = attributeHierarchy.getAttribute().getEntry().getConnection();
-            DN dn = null;
-            return new DnValueEditorRawValueWrapper( connection, dn );
+            return new DnValueEditorRawValueWrapper( connection, null );
         }
         else if ( attributeHierarchy.size() == 1 && attributeHierarchy.getAttribute().getValueSize()
== 1 )
         {
             IConnection connection = attributeHierarchy.getAttribute().getEntry().getConnection();
-            try
-            {
-                DN dn = new DN( getDisplayValue( attributeHierarchy ) );
-                return new DnValueEditorRawValueWrapper( connection, dn );
-            }
-            catch ( NameException e )
-            {
-                return new DnValueEditorRawValueWrapper( connection, null );
-            }
+            return new DnValueEditorRawValueWrapper( connection, getDisplayValue( attributeHierarchy
) );
         }
         else
         {
@@ -108,12 +108,9 @@
 
     /**
      * {@inheritDoc}
-     * 
-     * Returns a DnValueEditorRawValueWrapper with the connection of 
-     * the value and a DN build from the given value. 
-     * 
-     * If the value doesn't contain a valid DN a DnValueEditorRawValueWrapper
-     * with a null DN is returned.
+     *
+     * Returns a DnValueEditorRawValueWrapper with the connection of
+     * the value and a DN build from the given value.
      */
     public Object getRawValue( IValue value )
     {
@@ -121,15 +118,7 @@
         if ( o != null && o instanceof String )
         {
             IConnection connection = value.getAttribute().getEntry().getConnection();
-            try
-            {
-                DN dn = new DN( ( String ) o );
-                return new DnValueEditorRawValueWrapper( connection, dn );
-            }
-            catch ( NameException e )
-            {
-                return new DnValueEditorRawValueWrapper( connection, null );
-            }
+            return new DnValueEditorRawValueWrapper( connection, ( String ) o );
         }
 
         return null;
@@ -138,35 +127,23 @@
 
     /**
      * {@inheritDoc}
-     * 
-     * Returns a DnValueEditorRawValueWrapper with the given 
+     *
+     * Returns a DnValueEditorRawValueWrapper with the given
      * connection and a DN build from the given value.
-     * 
-     * If the value doesn't contain a valid DN a DnValueEditorRawValueWrapper
-     * with a null DN is returned.
      */
     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 new DnValueEditorRawValueWrapper( connection, null );
-            }
+            return new DnValueEditorRawValueWrapper( connection, ( String ) o );
         }
 
         return null;
     }
 
-    
     /**
-     * The DnValueEditorRawValueWrapper is used to pass contextual 
+     * The DnValueEditorRawValueWrapper is used to pass contextual
      * information to the opened DnDialog.
      *
      * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
@@ -178,7 +155,7 @@
         private IConnection connection;
 
         /** The DN, used as initial value in DnDialog */
-        private DN dn;
+        private String dn;
 
 
         /**
@@ -187,20 +164,21 @@
          * @param connection the connection
          * @param dn the DN
          */
-        private DnValueEditorRawValueWrapper( IConnection connection, DN dn )
+        private DnValueEditorRawValueWrapper( IConnection connection, String dn )
         {
             this.connection = connection;
             this.dn = dn;
         }
-        
+
+
         /**
          * {@inheritDoc}
          */
         public String toString()
         {
-            return dn == null ? "" : dn.toString();
+            return dn == null ? "" : dn;
         }
-        
+
     }
 
 }



Mime
View raw message