syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andreapatrice...@apache.org
Subject svn commit: r1622640 - in /syncope/branches/1_2_X: ./ console/src/main/java/org/apache/syncope/console/wicket/markup/html/form/DateTimeFieldPanel.java
Date Fri, 05 Sep 2014 08:39:18 GMT
Author: andreapatricelli
Date: Fri Sep  5 08:39:18 2014
New Revision: 1622640

URL: http://svn.apache.org/r1622640
Log:
[SYNCOPE-545] merge from branch 1.1.X, date-time field panel only

Modified:
    syncope/branches/1_2_X/   (props changed)
    syncope/branches/1_2_X/console/src/main/java/org/apache/syncope/console/wicket/markup/html/form/DateTimeFieldPanel.java

Propchange: syncope/branches/1_2_X/
------------------------------------------------------------------------------
  Merged /syncope/branches/1_1_X:r1622266-1622636

Modified: syncope/branches/1_2_X/console/src/main/java/org/apache/syncope/console/wicket/markup/html/form/DateTimeFieldPanel.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_2_X/console/src/main/java/org/apache/syncope/console/wicket/markup/html/form/DateTimeFieldPanel.java?rev=1622640&r1=1622639&r2=1622640&view=diff
==============================================================================
--- syncope/branches/1_2_X/console/src/main/java/org/apache/syncope/console/wicket/markup/html/form/DateTimeFieldPanel.java
(original)
+++ syncope/branches/1_2_X/console/src/main/java/org/apache/syncope/console/wicket/markup/html/form/DateTimeFieldPanel.java
Fri Sep  5 08:39:18 2014
@@ -52,12 +52,11 @@ public class DateTimeFieldPanel extends 
 
             @Override
             protected void onUpdate(final AjaxRequestTarget target) {
-                if (((DateTimeField) field).getHours() > 12) {
-                    cal.set(Calendar.HOUR_OF_DAY, ((DateTimeField) field).getHours());
-                } else {
-                    cal.set(Calendar.HOUR, ((DateTimeField) field).getHours());
+                final Integer hours = ((DateTimeField) field).getHours();
+                if (hours != null) {
+                    cal.set(hours > 12 ? Calendar.HOUR_OF_DAY : Calendar.HOUR, hours);
+                    field.setModelObject(cal.getTime());
                 }
-                field.setModelObject(cal.getTime());
             }
         });
 
@@ -67,8 +66,11 @@ public class DateTimeFieldPanel extends 
 
             @Override
             protected void onUpdate(final AjaxRequestTarget target) {
-                cal.set(Calendar.MINUTE, ((DateTimeField) field).getMinutes());
-                field.setModelObject(cal.getTime());
+                final Integer minutes = ((DateTimeField) field).getMinutes();
+                if (minutes != null) {
+                    cal.set(Calendar.MINUTE, minutes);
+                    field.setModelObject(cal.getTime());
+                }
             }
         });
 
@@ -78,15 +80,15 @@ public class DateTimeFieldPanel extends 
 
             @Override
             protected void onUpdate(final AjaxRequestTarget target) {
-                cal.setTime(((DateTimeField) field).getDate());
-
-                if ("PM".equals("" + ((DateTimeField) field).getAmOrPm())) {
-                    cal.set(Calendar.AM_PM, Calendar.PM);
+                final Date date = ((DateTimeField) field).getDate();
+                if (date == null) {
+                    field.setModelObject(null);
                 } else {
-                    cal.set(Calendar.AM_PM, Calendar.AM);
+                    cal.setTime(date);
+                    cal.set(Calendar.AM_PM, "PM".equals("" + ((DateTimeField) field).getAmOrPm())
? Calendar.PM
+                            : Calendar.AM);
+                    field.setModelObject(cal.getTime());
                 }
-
-                field.setModelObject(cal.getTime());
             }
         });
 
@@ -96,12 +98,8 @@ public class DateTimeFieldPanel extends 
 
             @Override
             protected void onUpdate(final AjaxRequestTarget target) {
-                if ("PM".equals("" + ((DateTimeField) field).getAmOrPm())) {
-                    cal.set(Calendar.AM_PM, Calendar.PM);
-                } else {
-                    cal.set(Calendar.AM_PM, Calendar.AM);
-                }
-
+                cal.set(Calendar.AM_PM, "PM".equals("" + ((DateTimeField) field).getAmOrPm())
? Calendar.PM
+                        : Calendar.AM);
                 field.setModelObject(cal.getTime());
             }
         });



Mime
View raw message