You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by pm...@apache.org on 2007/07/19 13:01:03 UTC

svn commit: r557571 - in /myfaces/tomahawk/trunk/core/src/main: java/org/apache/myfaces/custom/schedule/ tld/tomahawk-entities/

Author: pmahoney
Date: Thu Jul 19 04:01:01 2007
New Revision: 557571

URL: http://svn.apache.org/viewvc?view=rev&rev=557571
Log:
TOMAHAWK-577: Allow weekends to display full height in the month view. Thanks to Michael Stawicki for the patch.

Modified:
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/AbstractCompactScheduleRenderer.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/ScheduleCompactMonthRenderer.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
    myfaces/tomahawk/trunk/core/src/main/tld/tomahawk-entities/tomahawk_ui_schedule_attributes.xml

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/AbstractCompactScheduleRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/AbstractCompactScheduleRenderer.java?view=diff&rev=557571&r1=557570&r2=557571
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/AbstractCompactScheduleRenderer.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/AbstractCompactScheduleRenderer.java Thu Jul 19 04:01:01 2007
@@ -138,15 +138,15 @@
 
         if (rowHeight > 0)
         {
-            if (isWeekend)
+            if (isWeekend && schedule.isSplitWeekend())
             {
                 myRowHeight += (rowHeight / 2) + "px;";
                 myContentHeight += ((rowHeight / 2) - 19) + "px;";
             }
             else
             {
-                myRowHeight += (rowHeight + 1) + "px;"; //need to add 1 to get the weekends right
-                myContentHeight += ((rowHeight + 1) - 18) + "px;"; //18 instead of 19, to get the weekends right
+                myRowHeight += (rowHeight + (schedule.isSplitWeekend() ? 1 : 0)) + "px;"; //need to add 1 to get the weekends right
+                myContentHeight += ((rowHeight + (schedule.isSplitWeekend() ? 1 : 0)) - 18) + "px;"; //18 instead of 19, to get the weekends right
             }
          }
         else

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/ScheduleCompactMonthRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/ScheduleCompactMonthRenderer.java?view=diff&rev=557571&r1=557570&r2=557571
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/ScheduleCompactMonthRenderer.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/ScheduleCompactMonthRenderer.java Thu Jul 19 04:01:01 2007
@@ -110,7 +110,7 @@
 
             writeDayCell(
                 context, writer, schedule, day, dayOfWeek, dayOfMonth, isWeekend,
-                currentMonth == selectedMonth, isWeekend ? 1 : 2
+                currentMonth == selectedMonth, (!isWeekend && schedule.isSplitWeekend() ? 2 : 1)
             );
 
         }
@@ -145,16 +145,16 @@
     )
         throws IOException
     {
-        if ((dayOfWeek == Calendar.MONDAY) || (dayOfWeek == Calendar.SUNDAY)) {
+        if ((dayOfWeek == Calendar.MONDAY) || (schedule.isSplitWeekend() && dayOfWeek == Calendar.SUNDAY)) {
             writer.startElement(HTML.TR_ELEM, schedule);
         }
 
         super.writeDayCell(
-            context, writer, schedule, day, 100f / 6, dayOfWeek, dayOfMonth,
+            context, writer, schedule, day, 100f / (schedule.isSplitWeekend() ? 6 : 7), dayOfWeek, dayOfMonth,
             isWeekend, isCurrentMonth, rowspan
         );
 
-        if ((dayOfWeek == Calendar.SATURDAY) || (dayOfWeek == Calendar.SUNDAY)) {
+        if ((schedule.isSplitWeekend() && dayOfWeek == Calendar.SATURDAY) || (dayOfWeek == Calendar.SUNDAY)) {
             writer.endElement(HTML.TR_ELEM);
         }
     }

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=557571&r1=557570&r2=557571
==============================================================================
--- 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 Thu Jul 19 04:01:01 2007
@@ -79,8 +79,12 @@
     private String _titleClass;
     private String _unevenClass;
     private String _weekClass;
+	private String _splitWeekend;
     
-    
+    public String getSplitWeekend()
+	{
+		return _splitWeekend;
+	}
 
     /**
      * @return the action
@@ -309,9 +313,15 @@
         _titleClass = null;
         _unevenClass = null;
         _weekClass = null;
+		_splitWeekend = null;
         
     }
 
+	public void setSplitWeekend(String splitWeekend)
+	{
+		this._splitWeekend = splitWeekend;
+	}
+	
     /**
      * @param action the action to set
      */
@@ -401,6 +411,7 @@
           FacesContext context = FacesContext.getCurrentInstance();
           Application app = context.getApplication();
           //UIScheduleBase properties
+		  setBooleanProperty(component, "splitWeekend", _splitWeekend);
           setIntegerProperty(component, "compactMonthRowHeight", _compactMonthRowHeight);
           setIntegerProperty(component, "compactWeekRowHeight", _compactWeekRowHeight);
           setIntegerProperty(component, "detailedRowHeight", _detailedRowHeight);

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=557571&r1=557570&r2=557571
==============================================================================
--- 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 Thu Jul 19 04:01:01 2007
@@ -47,6 +47,9 @@
     public static final String COMPONENT_TYPE = "org.apache.myfaces.Schedule";
     public static final String RENDERER_TYPE = "org.apache.myfaces.Schedule";
 
+    protected static final String HOUR_NOTATION_24 = "24";
+    protected static final String HOUR_NOTATION_12 = "12";
+
     protected static final int DEFAULT_COMPACT_MONTH_ROWHEIGHT = 120;
     protected static final int DEFAULT_COMPACT_WEEK_ROWHEIGHT = 200;
     protected static final int DEFAULT_DETAILED_ROWHEIGHT = 22;
@@ -64,8 +67,7 @@
     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";
+	protected static final boolean DEFAULT_SPLIT_WEEKEND = true;
     
     private Integer _compactMonthRowHeight;
     private Integer _compactWeekRowHeight;
@@ -85,7 +87,18 @@
     private Integer _workingStartHour;
     private Boolean _submitOnClick = null;
     private String _hourNotation;
+	private Boolean _splitWeekend;
 
+	public boolean isSplitWeekend()
+	{
+		return ScheduleUtil.getBooleanProperty(this, _splitWeekend, "splitWeekend", DEFAULT_SPLIT_WEEKEND);
+	}
+	
+	public void setSplitWeekend(boolean splitWeekend)
+	{
+		_splitWeekend = Boolean.valueOf(splitWeekend);
+	}
+	
     /**
      * Should the parent form of this schedule be submitted when the user
      * clicks on a day? Note that this will only work when the readonly
@@ -331,6 +344,7 @@
         _workingStartHour = (Integer)values[15];
         _submitOnClick = (Boolean)values[16];
         _hourNotation = (String) values[17];
+		_splitWeekend = (Boolean)values[18];
     }
 
     /**
@@ -338,7 +352,7 @@
      */
     public Object saveState(FacesContext context)
     {
-        Object[] values = new Object[18];
+        Object[] values = new Object[19];
         values[0] = super.saveState(context);
         values[1] = _compactMonthRowHeight;
         values[2] = _compactWeekRowHeight;
@@ -357,6 +371,7 @@
         values[15] = _workingStartHour;
         values[16] = _submitOnClick;
         values[17] = _hourNotation;
+		values[18] = _splitWeekend;
         
         return values;
     }

Modified: myfaces/tomahawk/trunk/core/src/main/tld/tomahawk-entities/tomahawk_ui_schedule_attributes.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/tld/tomahawk-entities/tomahawk_ui_schedule_attributes.xml?view=diff&rev=557571&r1=557570&r2=557571
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/tld/tomahawk-entities/tomahawk_ui_schedule_attributes.xml (original)
+++ myfaces/tomahawk/trunk/core/src/main/tld/tomahawk-entities/tomahawk_ui_schedule_attributes.xml Thu Jul 19 04:01:01 2007
@@ -88,6 +88,12 @@
 	<rtexprvalue>false</rtexprvalue>
 	<type>java.lang.String</type>
 </attribute>
+<attribute>
+	<name>splitWeekend</name>
+	<required>false</required>
+	<rtexprvalue>false</rtexprvalue>
+	<type>java.lang.String</type>
+</attribute>
 
 <attribute>
 	<name>mouseListener</name>