myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmaho...@apache.org
Subject svn commit: r548679 - in /myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule: DefaultScheduleEntryRenderer.java ScheduleTag.java UIScheduleBase.java
Date Tue, 19 Jun 2007 10:19:37 GMT
Author: pmahoney
Date: Tue Jun 19 03:19:29 2007
New Revision: 548679

URL: http://svn.apache.org/viewvc?view=rev&rev=548679
Log:
TOMAHAWK-732: Support 12 or 24 hour notation property

Modified:
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/DefaultScheduleEntryRenderer.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/ScheduleTag.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/UIScheduleBase.java

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/DefaultScheduleEntryRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/DefaultScheduleEntryRenderer.java?view=diff&rev=548679&r1=548678&r2=548679
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/DefaultScheduleEntryRenderer.java
(original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/DefaultScheduleEntryRenderer.java
Tue Jun 19 03:19:29 2007
@@ -21,7 +21,7 @@
 
 import java.io.IOException;
 import java.io.Serializable;
-import java.text.DateFormat;
+import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Map;
 
@@ -30,6 +30,7 @@
 import javax.faces.context.ResponseWriter;
 import javax.faces.el.ValueBinding;
 
+import org.apache.myfaces.custom.schedule.HtmlSchedule;
 import org.apache.myfaces.custom.schedule.model.ScheduleDay;
 import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
@@ -105,7 +106,8 @@
 
         if (!entry.isAllDay())
         {
-        	DateFormat format = DateFormat.getTimeInstance(DateFormat.SHORT);
+            SimpleDateFormat format = new SimpleDateFormat(HtmlSchedule.HOUR_NOTATION_24.equals(schedule.getHourNotation())
? "HH:mm" : "h:mma");
+
         	text.append(format.format(startTime));
         	if (!startTime.equals(endTime)) {
         		text.append("-");

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/ScheduleTag.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/ScheduleTag.java?view=diff&rev=548679&r1=548678&r2=548679
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/ScheduleTag.java
(original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/ScheduleTag.java
Tue Jun 19 03:19:29 2007
@@ -47,6 +47,7 @@
     private String _workingEndHour;
     private String _workingStartHour;
     private String _submitOnClick;
+    private String _hourNotation;
     //UISchedule properties
     private String _action;
     private String _actionListener;
@@ -251,6 +252,13 @@
         return _workingStartHour;
     }
 
+    /**
+     * @return the hourNotation
+     */
+    public String getHourNotation() {
+		return _hourNotation;
+	}
+    
     public void release() {
         super.release();
         //UIScheduleBase properties
@@ -269,6 +277,7 @@
         _workingEndHour = null;
         _workingStartHour = null;
         _submitOnClick = null;
+        _hourNotation = null;
         //UISchedule properties
         _action = null;
         _actionListener = null;
@@ -407,6 +416,7 @@
           setIntegerProperty(component, "workingEndHour", _workingEndHour);
           setIntegerProperty(component, "workingStartHour", _workingStartHour);
           setBooleanProperty(component, "submitOnClick", _submitOnClick);
+          setStringProperty(component, "hourNotation", _hourNotation);
           //UISchedule properties
           setActionProperty(component, _action);
           setActionListenerProperty(component, _actionListener);
@@ -538,6 +548,14 @@
     public void setWorkingStartHour(String workingStartHour)
     {
         this._workingStartHour = workingStartHour;
+    }
+
+    /**
+     * @param hourNotation the workingStartHour to set
+     */
+    public void setHourNotation(String hourNotation)
+    {
+        this._hourNotation = hourNotation;
     }
 
     /**

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/UIScheduleBase.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/UIScheduleBase.java?view=diff&rev=548679&r1=548678&r2=548679
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/UIScheduleBase.java
(original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/UIScheduleBase.java
Tue Jun 19 03:19:29 2007
@@ -64,6 +64,8 @@
     protected static final String DEFAULT_ENABLED_ON_USER_ROLE = null;
     protected static final boolean DEFAULT_SUBMIT_ON_CLICK = false;
     protected static final String DEFAULT_VISIBLE_ON_USER_ROLE = null;
+    protected static final String HOUR_NOTATION_24 = "24";
+    protected static final String HOUR_NOTATION_12 = "12";
     
     private Integer _compactMonthRowHeight;
     private Integer _compactWeekRowHeight;
@@ -82,6 +84,7 @@
     private Integer _workingEndHour;
     private Integer _workingStartHour;
     private Boolean _submitOnClick = null;
+    private String _hourNotation;
 
     /**
      * Should the parent form of this schedule be submitted when the user
@@ -293,6 +296,18 @@
     }
 
     /**
+     * <p>
+     * Show dates in 24 hour notation or 12 hour notation.
+     * </p>
+     * 
+     * @return "12", "24" or null for the renderer default
+     */
+    public String getHourNotation()
+    {
+    	return ScheduleUtil.getStringProperty(this, _hourNotation, "hourNotation", null);
+    }
+    
+    /**
      * @see javax.faces.component.UIComponentBase#restoreState(javax.faces.context.FacesContext,
java.lang.Object)
      */
     public void restoreState(FacesContext context, Object state)
@@ -315,6 +330,7 @@
         _workingEndHour = (Integer)values[14];
         _workingStartHour = (Integer)values[15];
         _submitOnClick = (Boolean)values[16];
+        _hourNotation = (String) values[17];
     }
 
     /**
@@ -322,7 +338,7 @@
      */
     public Object saveState(FacesContext context)
     {
-        Object[] values = new Object[17];
+        Object[] values = new Object[18];
         values[0] = super.saveState(context);
         values[1] = _compactMonthRowHeight;
         values[2] = _compactWeekRowHeight;
@@ -340,6 +356,8 @@
         values[14] = _workingEndHour;
         values[15] = _workingStartHour;
         values[16] = _submitOnClick;
+        values[17] = _hourNotation;
+        
         return values;
     }
 
@@ -480,7 +498,17 @@
     {
         this._workingStartHour = Integer.valueOf(workingStartHour);
     }
-
     
-
+    /**
+     * <p>
+     * Show dates in 24 hour notation or 12 hour notation.
+     * </p>
+     * 
+     * @param hourNotation 12 for 12 hour notation and 24 for 24 hour notation
+     */
+    public void setHourNotation(String hourNotation)
+    {
+    	this._hourNotation = hourNotation;
+    }
+    
 }



Mime
View raw message