directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r825786 - in /directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/integer: IntegerDialog.java IntegerValueEditor.java
Date Fri, 16 Oct 2009 07:19:12 GMT
Author: pamarcelot
Date: Fri Oct 16 07:19:12 2009
New Revision: 825786

URL: http://svn.apache.org/viewvc?rev=825786&view=rev
Log:
Fix for DIRSTUDIO-570 (Integer Value Editor does not accept negative numbers).

Modified:
    directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/integer/IntegerDialog.java
    directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/integer/IntegerValueEditor.java

Modified: directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/integer/IntegerDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/integer/IntegerDialog.java?rev=825786&r1=825785&r2=825786&view=diff
==============================================================================
--- directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/integer/IntegerDialog.java
(original)
+++ directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/integer/IntegerDialog.java
Fri Oct 16 07:19:12 2009
@@ -74,7 +74,7 @@
     protected void configureShell( Shell shell )
     {
         super.configureShell( shell );
-        shell.setText( Messages.getString("IntegerDialog.IntegerEditor") ); //$NON-NLS-1$
+        shell.setText( Messages.getString( "IntegerDialog.IntegerEditor" ) ); //$NON-NLS-1$
         shell.setImage( ValueEditorsActivator.getDefault().getImage( ValueEditorsConstants.IMG_INTEGEREDITOR
) );
     }
 
@@ -111,7 +111,7 @@
         composite.setLayoutData( gd );
 
         spinner = new Spinner( composite, SWT.BORDER );
-        spinner.setMinimum( 0 );
+        spinner.setMinimum( Integer.MIN_VALUE );
         spinner.setMaximum( Integer.MAX_VALUE );
         spinner.setDigits( 0 );
         spinner.setIncrement( 1 );
@@ -133,4 +133,17 @@
     {
         return returnValue;
     }
+
+
+    /**
+     * Indicates if the dialog is dirty.
+     *
+     * @return
+     *      <code>true</code> if the dialog is dirty,
+     *      <code>false</code> if not.
+     */
+    public boolean isDirty()
+    {
+        return initialValue != returnValue;
+    }
 }

Modified: directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/integer/IntegerValueEditor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/integer/IntegerValueEditor.java?rev=825786&r1=825785&r2=825786&view=diff
==============================================================================
--- directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/integer/IntegerValueEditor.java
(original)
+++ directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/integer/IntegerValueEditor.java
Fri Oct 16 07:19:12 2009
@@ -46,6 +46,7 @@
         {
             String stringValue = ( String ) value;
             int intValue;
+            boolean isNewOrMalformedValue = false;
             try
             {
                 intValue = Integer.valueOf( stringValue );
@@ -53,9 +54,10 @@
             catch ( NumberFormatException e )
             {
                 intValue = 0;
+                isNewOrMalformedValue = true;
             }
             IntegerDialog dialog = new IntegerDialog( shell, intValue );
-            if ( dialog.open() == IntegerDialog.OK && dialog.getInteger() != -1 )
+            if ( dialog.open() == IntegerDialog.OK && ( dialog.isDirty() || isNewOrMalformedValue
) )
             {
                 setValue( Integer.toString( dialog.getInteger() ) );
                 return true;
@@ -63,5 +65,4 @@
         }
         return false;
     }
-
 }



Mime
View raw message