directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1493795 - in /directory/studio/trunk/plugins/valueeditors/src/main/java/org/apache/directory/studio/valueeditors: ValueEditorsConstants.java time/GeneralizedTimeValueDialog.java time/GeneralizedTimeValueEditor.java
Date Mon, 17 Jun 2013 14:50:31 GMT
Author: pamarcelot
Date: Mon Jun 17 14:50:31 2013
New Revision: 1493795

URL: http://svn.apache.org/r1493795
Log:
Fix for DIRSTUDIO-788 (Date and Time editor incorrect time format for eDirectory).

Modified:
    directory/studio/trunk/plugins/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/ValueEditorsConstants.java
    directory/studio/trunk/plugins/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/time/GeneralizedTimeValueDialog.java
    directory/studio/trunk/plugins/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/time/GeneralizedTimeValueEditor.java

Modified: directory/studio/trunk/plugins/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/ValueEditorsConstants.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/ValueEditorsConstants.java?rev=1493795&r1=1493794&r2=1493795&view=diff
==============================================================================
--- directory/studio/trunk/plugins/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/ValueEditorsConstants.java
(original)
+++ directory/studio/trunk/plugins/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/ValueEditorsConstants.java
Mon Jun 17 14:50:31 2013
@@ -74,4 +74,6 @@ public final class ValueEditorsConstants
     /** The relative path to the text field ok icon */
     public static final String IMG_TEXTFIELD_OK = "resources/icons/textfield_ok.png"; //$NON-NLS-1$
 
+    /** The dialogs settings for the Date Editor "Discard fraction" checkbox */
+    public static final String DIALOGSETTING_KEY_DATE_EDITOR_DISCARD_FRACTION = "dateEditorDiscardFraction";
//$NON-NLS-1$
 }

Modified: directory/studio/trunk/plugins/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/time/GeneralizedTimeValueDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/time/GeneralizedTimeValueDialog.java?rev=1493795&r1=1493794&r2=1493795&view=diff
==============================================================================
--- directory/studio/trunk/plugins/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/time/GeneralizedTimeValueDialog.java
(original)
+++ directory/studio/trunk/plugins/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/time/GeneralizedTimeValueDialog.java
Mon Jun 17 14:50:31 2013
@@ -97,6 +97,9 @@ public class GeneralizedTimeValueDialog 
     // Raw validator
     private Label rawValueValidatorImage;
 
+    // Discard fraction checkbox
+    private Button discardFractionCheckbox;
+
     /** The OK button of the dialog */
     private Button okButton;
 
@@ -205,6 +208,16 @@ public class GeneralizedTimeValueDialog 
         }
     };
 
+    private SelectionListener discardFractionCheckboxSelectionListener = new SelectionAdapter()
+    {
+        public void widgetSelected( SelectionEvent e )
+        {
+            removeListeners();
+            updateRawFields();
+            addListeners();
+        }
+    };
+
 
     /**
      * Creates a new instance of GeneralizedTimeValueDialog.
@@ -252,6 +265,30 @@ public class GeneralizedTimeValueDialog 
     /**
      * {@inheritDoc}
      */
+    protected void okPressed()
+    {
+        // Checking if we need to discard the fraction
+        if ( discardFractionCheckbox.getSelection() )
+        {
+            // Removing the fraction from the value
+            Calendar calendar = value.getCalendar();
+            calendar.set( Calendar.MILLISECOND, 0 );
+
+            value = new GeneralizedTime( calendar );
+        }
+
+        // Saving the dialog settings
+        ValueEditorsActivator.getDefault().getDialogSettings()
+            .put( ValueEditorsConstants.DIALOGSETTING_KEY_DATE_EDITOR_DISCARD_FRACTION,
+                discardFractionCheckbox.getSelection() );
+
+        super.okPressed();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
     protected Control createDialogArea( Composite parent )
     {
         // Main composites
@@ -263,6 +300,10 @@ public class GeneralizedTimeValueDialog 
         createDateDialogArea( dualComposite );
         createTimeZoneDialogArea( dualComposite );
         createRawValueDialogArea( dualComposite );
+        
+        // Getting the dialog settings
+        discardFractionCheckbox.setSelection( ValueEditorsActivator.getDefault().getDialogSettings()
+            .getBoolean( ValueEditorsConstants.DIALOGSETTING_KEY_DATE_EDITOR_DISCARD_FRACTION
) );
 
         // Initializing with initial value
         initWithInitialValue();
@@ -506,6 +547,10 @@ public class GeneralizedTimeValueDialog 
 
         // Validator image
         rawValueValidatorImage = new Label( rawValueComposite, SWT.NONE );
+
+        // Discard fraction checkbox
+        discardFractionCheckbox = BaseWidgetUtils.createCheckbox( parent, "Discard fraction
(milliseconds)", 2 );
+
         validateRawValue( true );
     }
 
@@ -555,7 +600,14 @@ public class GeneralizedTimeValueDialog 
     private void updateRawFields()
     {
         // Raw value
-        rawValueText.setText( value.toGeneralizedTime() );
+        if ( discardFractionCheckbox.getSelection() )
+        {
+            rawValueText.setText( value.toGeneralizedTimeWithoutFraction() );
+        }
+        else
+        {
+            rawValueText.setText( value.toGeneralizedTime() );
+        }
 
         validateRawValue( true );
     }
@@ -610,6 +662,9 @@ public class GeneralizedTimeValueDialog 
 
         // Raw value
         rawValueText.addModifyListener( rawValueModifyListener );
+
+        // Discard fraction checkbox
+        discardFractionCheckbox.addSelectionListener( discardFractionCheckboxSelectionListener
);
     }
 
 
@@ -635,6 +690,9 @@ public class GeneralizedTimeValueDialog 
 
         // Raw value
         rawValueText.removeModifyListener( rawValueModifyListener );
+
+        // Discard fraction checkbox
+        discardFractionCheckbox.removeSelectionListener( discardFractionCheckboxSelectionListener
);
     }
 
 

Modified: directory/studio/trunk/plugins/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/time/GeneralizedTimeValueEditor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/time/GeneralizedTimeValueEditor.java?rev=1493795&r1=1493794&r2=1493795&view=diff
==============================================================================
--- directory/studio/trunk/plugins/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/time/GeneralizedTimeValueEditor.java
(original)
+++ directory/studio/trunk/plugins/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/time/GeneralizedTimeValueEditor.java
Mon Jun 17 14:50:31 2013
@@ -27,7 +27,6 @@ import java.util.Calendar;
 import java.util.Date;
 
 import org.apache.directory.api.util.GeneralizedTime;
-import org.apache.directory.studio.ldapbrowser.common.dialogs.TextDialog;
 import org.apache.directory.studio.ldapbrowser.core.model.IValue;
 import org.apache.directory.studio.valueeditors.AbstractDialogStringValueEditor;
 import org.eclipse.jface.dialogs.MessageDialog;
@@ -115,9 +114,21 @@ public class GeneralizedTimeValueEditor 
 
             // Creating and opening the dialog
             GeneralizedTimeValueDialog dialog = new GeneralizedTimeValueDialog( shell, generalizedTime
);
-            if ( dialog.open() == TextDialog.OK )
+            if ( dialog.open() == GeneralizedTimeValueDialog.OK )
             {
-                setValue( dialog.getGeneralizedTime().toGeneralizedTime() );
+                GeneralizedTime newGeneralizedTime = dialog.getGeneralizedTime();
+
+                // Checking if we need to save the generalized time 
+                // with or without fraction
+                if ( newGeneralizedTime.getFraction() == 0 )
+                {
+                    setValue( newGeneralizedTime.toGeneralizedTimeWithoutFraction() );
+                }
+                else
+                {
+                    setValue( newGeneralizedTime.toGeneralizedTime() );
+                }
+
                 return true;
             }
         }



Mime
View raw message