directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r742052 - in /directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions: NewValueAction.java messages.properties messages_de.properties
Date Sun, 08 Feb 2009 11:05:16 GMT
Author: seelmann
Date: Sun Feb  8 11:05:16 2009
New Revision: 742052

URL: http://svn.apache.org/viewvc?rev=742052&view=rev
Log:
DIRSTUDIO-241, DIRSTUDIO-234, DIRSTUDIO-457, DIRSTUDIO-115: Enabled new value action for all
attributes. Added confirm message if attribute is read-only or single-valued.

Modified:
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/NewValueAction.java
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/messages.properties
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/messages_de.properties

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/NewValueAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/NewValueAction.java?rev=742052&r1=742051&r2=742052&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/NewValueAction.java
(original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/NewValueAction.java
Sun Feb  8 11:05:16 2009
@@ -23,8 +23,12 @@
 
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
+import org.apache.directory.studio.ldapbrowser.core.BrowserCoreConstants;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
 import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils;
+import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.osgi.util.NLS;
 
 
 /**
@@ -58,22 +62,46 @@
      */
     public void run()
     {
+        IAttribute attribute = null;
         if ( getSelectedValues().length == 1 )
         {
-            getSelectedValues()[0].getAttribute().addEmptyValue();
+            attribute = getSelectedValues()[0].getAttribute();
         }
         else if ( getSelectedAttributes().length == 1 )
         {
-            getSelectedAttributes()[0].addEmptyValue();
+            attribute = getSelectedAttributes()[0];
         }
         else if ( getSelectedAttributeHierarchies().length == 1 )
         {
-            getSelectedAttributeHierarchies()[0].getAttribute().addEmptyValue();
+            attribute = getSelectedAttributeHierarchies()[0].getAttribute();
         }
 
-        if ( getSelectedSearchResults().length > 0 )
+        // validate non-modifiable and single-valued attributes
+        StringBuffer message = new StringBuffer();
+        if ( !SchemaUtils.isModifyable( attribute.getAttributeTypeDescription() ) )
         {
+            message.append( NLS.bind( Messages.getString( "NewValueAction.NewValueNotModifyable"
), attribute //$NON-NLS-1$
+                .getDescription() ) );
+            message.append( BrowserCoreConstants.LINE_SEPARATOR );
+            message.append( BrowserCoreConstants.LINE_SEPARATOR );
+        }
+        if ( attribute.getAttributeTypeDescription().isSingleValued() )
+        {
+            message.append( NLS.bind( Messages.getString( "NewValueAction.NewValueSingleValued"
), attribute //$NON-NLS-1$
+                .getDescription() ) );
+            message.append( BrowserCoreConstants.LINE_SEPARATOR );
+            message.append( BrowserCoreConstants.LINE_SEPARATOR );
+        }
 
+        boolean ok = true;
+        if ( message.length() > 0 )
+        {
+            message.append( Messages.getString( "NewValueAction.NewValueQuestion" ) ); //$NON-NLS-1$
+            ok = MessageDialog.openConfirm( getShell(), getText(), message.toString() );
+        }
+        if ( ok )
+        {
+            attribute.addEmptyValue();
         }
     }
 
@@ -83,7 +111,7 @@
      */
     public String getText()
     {
-        return Messages.getString("NewValueAction.NewValue"); //$NON-NLS-1$
+        return Messages.getString( "NewValueAction.NewValue" ); //$NON-NLS-1$
     }
 
 
@@ -110,27 +138,11 @@
      */
     public boolean isEnabled()
     {
-        // System.out.println(getSelectedAttributeArrays());
-        // System.out.print("==> ");
-        // IAttribute[][] attArr = getSelectedAttributeArrays();
-        // for (int i = 0; i < attArr.length; i++) {
-        // for (int j = 0; j < attArr[i].length; j++) {
-        // IAttribute att = attArr[i][j];
-        // System.out.print(att + "|");
-        // }
-        // }
-        // System.out.println();
-
-        return ( getSelectedSearchResults().length == 0 && getSelectedAttributes().length
== 0
-            && getSelectedValues().length == 1 && SchemaUtils.isModifyable(
getSelectedValues()[0].getAttribute()
-            .getAttributeTypeDescription() ) )
-
-            || ( getSelectedSearchResults().length == 0 && getSelectedValues().length
== 0
-                && getSelectedAttributes().length == 1 && SchemaUtils.isModifyable(
getSelectedAttributes()[0]
-                .getAttributeTypeDescription() ) )
+        return ( getSelectedSearchResults().length == 0 && getSelectedAttributes().length
== 0 && getSelectedValues().length == 1 )
+
+            || ( getSelectedSearchResults().length == 0 && getSelectedValues().length
== 0 && getSelectedAttributes().length == 1 )
 
             || ( getSelectedSearchResults().length == 1 && getSelectedValues().length
== 0
-                && getSelectedAttributes().length == 0 && getSelectedAttributeHierarchies().length
== 1 && SchemaUtils
-                .isModifyable( getSelectedAttributeHierarchies()[0].getAttribute().getAttributeTypeDescription()
) );
+                && getSelectedAttributes().length == 0 && getSelectedAttributeHierarchies().length
== 1 );
     }
 }

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/messages.properties?rev=742052&r1=742051&r2=742052&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/messages.properties
(original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/messages.properties
Sun Feb  8 11:05:16 2009
@@ -59,6 +59,9 @@
 NewAttributeAction.NewAttribute=New Attribute
 NewAttributeAction.NewAttributeLabel=New Attribute...
 NewValueAction.NewValue=New Value
+NewValueAction.NewValueNotModifyable=Warning\! According to the schema attribute {0} is not
modifyable\!
+NewValueAction.NewValueQuestion=Do you still want to add a new value?
+NewValueAction.NewValueSingleValued=Warning\! According to the schema attribute {0} is single-valued\!
 PasteAction.Paste=Paste
 PasteAction.PasteEntries=Paste Entries
 PasteAction.PasteEntry=Paste Entry

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/messages_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/messages_de.properties?rev=742052&r1=742051&r2=742052&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/messages_de.properties
(original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/messages_de.properties
Sun Feb  8 11:05:16 2009
@@ -59,6 +59,9 @@
 NewAttributeAction.NewAttribute=Neues Attribut
 NewAttributeAction.NewAttributeLabel=Neues Attribut...
 NewValueAction.NewValue=Neuer Wert
+NewValueAction.NewValueNotModifyable=Warnung\! Gemäß dem Schema ist das Attribut {0} nicht
änderbar\!
+NewValueAction.NewValueQuestion=Wollen Sie trotzem einen neuen Wert hinzufügen?
+NewValueAction.NewValueSingleValued=Warnung\! Gemäß dem Schema ist das Attribut {0} einwertig\!
 PasteAction.Paste=Einfügen
 PasteAction.PasteEntries=Einträge einfügen
 PasteAction.PasteEntry=Eintrag einfügen



Mime
View raw message