You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by jl...@apache.org on 2006/06/17 22:25:39 UTC

svn commit: r415055 - in /myfaces/tomahawk/trunk: core/src/main/java/org/apache/myfaces/custom/schedule/ core/src/main/java/org/apache/myfaces/custom/schedule/renderer/ core/src/main/tld/tomahawk-entities/ core/src/site/xdoc/ examples/simple/src/main/j...

Author: jlust
Date: Sat Jun 17 13:25:38 2006
New Revision: 415055

URL: http://svn.apache.org/viewvc?rev=415055&view=rev
Log:
Fix for the task rendering as described in TOMAHAWK-487. I also added an attribute to the schedule component that allows you to specify whether or not these zero-length entries should be rendered. The attribute is aptly named 'renderZeroLengthEntries' :).

Modified:
    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/renderer/AbstractScheduleRenderer.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/renderer/ScheduleDetailedDayRenderer.java
    myfaces/tomahawk/trunk/core/src/main/tld/tomahawk-entities/tomahawk_html_schedule_attributes.xml
    myfaces/tomahawk/trunk/core/src/site/xdoc/schedule.xml
    myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/schedule/ScheduleExampleHandler.java
    myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/schedule/ScheduleSettings.java
    myfaces/tomahawk/trunk/examples/simple/src/main/webapp/schedule3.jsp
    myfaces/tomahawk/trunk/examples/simple/src/main/webapp/schedule_editsettings.jsp

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?rev=415055&r1=415054&r2=415055&view=diff
==============================================================================
--- 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 Sat Jun 17 13:25:38 2006
@@ -81,6 +81,7 @@
     private String weekClass;
     private String workingEndHour;
     private String workingStartHour;
+    private String renderZeroLengthEntries;
 
     //~ Methods ----------------------------------------------------------------
 
@@ -882,6 +883,8 @@
         addAttribute(app, schedule, "selected", selectedClass);
         addAttribute(app, schedule, "month", monthClass);
         addAttribute(app, schedule, "week", weekClass);
+        
+        addAttribute(app, schedule, "renderZeroLengthEntries", renderZeroLengthEntries);
 
         addAttribute(app, schedule, "entryRenderer", entryRenderer);
     }
@@ -1043,6 +1046,32 @@
     public void setWorkingStartHour(String workingStartHour)
     {
         this.workingStartHour = workingStartHour;
+    }
+
+    /**
+     * <p>
+     * When the start- and endtime of an entry are the same, should the entry
+     * be rendered, fitting the entry box to the text? 
+     * </p>
+     * 
+     * @return rendered or not
+     */
+    public String getRenderZeroLengthEntries()
+    {
+        return renderZeroLengthEntries;
+    }
+
+    /**
+     * <p>
+     * When the start- and endtime of an entry are the same, should the entry
+     * be rendered, fitting the entry box to the text? 
+     * </p>
+     * 
+     * @param render
+     */
+    public void setRenderZeroLengthEntries(String render)
+    {
+        this.renderZeroLengthEntries = render;
     }
 }
 //The End

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/renderer/AbstractScheduleRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/renderer/AbstractScheduleRenderer.java?rev=415055&r1=415054&r2=415055&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/renderer/AbstractScheduleRenderer.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/renderer/AbstractScheduleRenderer.java Sat Jun 17 13:25:38 2006
@@ -353,6 +353,35 @@
         return Boolean.valueOf((String) attributes.get("tooltip"))
                 .booleanValue();
     }
+    
+    /**
+     * <p>
+     * When the start- and endtime of an entry are the same, should the entry
+     * be rendered, fitting the entry box to the text? 
+     * </p>
+     * 
+     * @param component the component
+     * @return whether or not zero length entries should be rendered
+     */
+    protected boolean renderZeroLengthEntries(UIComponent component) {
+        //first check if the renderZeroLengthEntries property is a value binding expression
+        ValueBinding binding = component.getValueBinding("renderZeroLengthEntries");
+        if (binding != null)
+        {
+            Boolean value = (Boolean) binding.getValue(FacesContext
+                    .getCurrentInstance());
+
+            if (value != null)
+            {
+                return value.booleanValue();
+            }
+        }
+        //it's not a value binding expression, so check for the string value
+        //in the attributes
+        Map attributes = component.getAttributes();
+        return Boolean.valueOf((String) attributes.get("renderZeroLengthEntries"))
+                .booleanValue();
+    }
 
     /**
      * The user of the Schedule component can customize the look and feel

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/renderer/ScheduleDetailedDayRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/renderer/ScheduleDetailedDayRenderer.java?rev=415055&r1=415054&r2=415055&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/renderer/ScheduleDetailedDayRenderer.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/renderer/ScheduleDetailedDayRenderer.java Sat Jun 17 13:25:38 2006
@@ -787,13 +787,21 @@
             int height = (int) (((endMillis - startMillis) * rowHeight) / HALF_HOUR);
             StringBuffer buffer = new StringBuffer();
 
-            if (height <= 0)
+            boolean entryVisible = height > 0 || renderZeroLengthEntries(schedule);
+            
+            if (!entryVisible)
             {
                 buffer.append("visibility: hidden; ");
             }
             buffer.append("position: absolute; height: ");
-            buffer.append(height);
-            buffer.append("px; top: ");
+            if (height > 0) {
+                buffer.append(height + "px");
+            } else if (entryVisible) {
+                buffer.append("auto");
+            } else {
+                buffer.append("0px");
+            }
+            buffer.append("; top: ");
             buffer.append(top);
             buffer.append("px; left: ");
             buffer.append(left);

Modified: myfaces/tomahawk/trunk/core/src/main/tld/tomahawk-entities/tomahawk_html_schedule_attributes.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/tld/tomahawk-entities/tomahawk_html_schedule_attributes.xml?rev=415055&r1=415054&r2=415055&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/tld/tomahawk-entities/tomahawk_html_schedule_attributes.xml (original)
+++ myfaces/tomahawk/trunk/core/src/main/tld/tomahawk-entities/tomahawk_html_schedule_attributes.xml Sat Jun 17 13:25:38 2006
@@ -195,4 +195,10 @@
          <required>false</required>
          <rtexprvalue>false</rtexprvalue>
          <type>java.lang.String</type>
-        </attribute>
+        </attribute>
+       <attribute>
+         <name>renderZeroLengthEntries</name> 
+         <required>false</required>
+         <rtexprvalue>false</rtexprvalue>
+         <type>java.lang.Boolean</type>
+       </attribute>

Modified: myfaces/tomahawk/trunk/core/src/site/xdoc/schedule.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/site/xdoc/schedule.xml?rev=415055&r1=415054&r2=415055&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/site/xdoc/schedule.xml (original)
+++ myfaces/tomahawk/trunk/core/src/site/xdoc/schedule.xml Sat Jun 17 13:25:38 2006
@@ -117,6 +117,10 @@
                 </code>
                 <br/>
                 <code>
+                    renderZeroLengthEntries - Normally, when an entry has the same start- and endtime, it is not rendered in the detailed views. Setting this to 'true' forces such entries to be rendered. The size of the entry box is then adapted to fit the text in it.
+                </code>
+                <br/>
+                <code>
                     theme - The name of the theme that should be used when rendering the schedule. Available themes are 'default', 'outlookxp' and 'evolution'
                 </code>
                 <br/>

Modified: myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/schedule/ScheduleExampleHandler.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/schedule/ScheduleExampleHandler.java?rev=415055&r1=415054&r2=415055&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/schedule/ScheduleExampleHandler.java (original)
+++ myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/schedule/ScheduleExampleHandler.java Sat Jun 17 13:25:38 2006
@@ -130,6 +130,17 @@
         entry5.setEndTime(calendar.getTime());
         entry5.setTitle("Fishing trip");
         model.addEntry(entry5);
+        //Let's add a zero length entry...
+        DefaultScheduleEntry entry6 = new DefaultScheduleEntry();
+        calendar.setTime(model.getSelectedDate());
+        calendar.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
+        calendar.set(Calendar.HOUR_OF_DAY, 16);
+        entry6.setId(RandomStringUtils.randomNumeric(32));
+        entry6.setStartTime(calendar.getTime());
+        entry6.setEndTime(calendar.getTime());
+        entry6.setTitle("Zero length entry");
+        entry6.setDescription("Is only rendered when the 'renderZeroLengthEntries' attribute is 'true'");
+        model.addEntry(entry6);
         model.refresh();
     }
 }

Modified: myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/schedule/ScheduleSettings.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/schedule/ScheduleSettings.java?rev=415055&r1=415054&r2=415055&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/schedule/ScheduleSettings.java (original)
+++ myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/schedule/ScheduleSettings.java Sat Jun 17 13:25:38 2006
@@ -54,6 +54,8 @@
 
     private int workingStartHour;
 
+    private boolean renderZeroLength;
+
     public int getCompactMonthRowHeight()
     {
         return compactMonthRowHeight;
@@ -178,5 +180,21 @@
     public void setWorkingStartHour(int workingStartHour)
     {
         this.workingStartHour = workingStartHour;
+    }
+
+    /**
+     * @return Returns the renderZeroLength.
+     */
+    public boolean isRenderZeroLength()
+    {
+        return renderZeroLength;
+    }
+
+    /**
+     * @param renderZeroLength The renderZeroLength to set.
+     */
+    public void setRenderZeroLength(boolean renderZeroLength)
+    {
+        this.renderZeroLength = renderZeroLength;
     }
 }

Modified: myfaces/tomahawk/trunk/examples/simple/src/main/webapp/schedule3.jsp
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/examples/simple/src/main/webapp/schedule3.jsp?rev=415055&r1=415054&r2=415055&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/examples/simple/src/main/webapp/schedule3.jsp (original)
+++ myfaces/tomahawk/trunk/examples/simple/src/main/webapp/schedule3.jsp Sat Jun 17 13:25:38 2006
@@ -35,6 +35,7 @@
 				readonly="#{scheduleSettings2.readonly}"
 				theme="#{scheduleSettings2.theme}"
 				tooltip="#{scheduleSettings2.tooltip}"
+				renderZeroLengthEntries="#{scheduleSettings2.renderZeroLength}"
 				headerDateFormat="#{scheduleSettings2.headerDateFormat}"
 				compactWeekRowHeight="#{scheduleSettings2.compactWeekRowHeight}"
 				compactMonthRowHeight="#{scheduleSettings2.compactMonthRowHeight}"

Modified: myfaces/tomahawk/trunk/examples/simple/src/main/webapp/schedule_editsettings.jsp
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/examples/simple/src/main/webapp/schedule_editsettings.jsp?rev=415055&r1=415054&r2=415055&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/examples/simple/src/main/webapp/schedule_editsettings.jsp (original)
+++ myfaces/tomahawk/trunk/examples/simple/src/main/webapp/schedule_editsettings.jsp Sat Jun 17 13:25:38 2006
@@ -26,7 +26,7 @@
 <f:view>
 	<h:form>
 		<t:htmlTag value="h3">Edit settings</t:htmlTag>
-		<h:messages tooltip="true" layout="table" globalOnly="true" />
+		<h:messages tooltip="true" layout="table" globalOnly="false" />
 		<h:panelGrid columns="3">
 			<h:outputLabel for="mode" value="Display mode:" />
 			<h:selectOneRadio id="mode" value="#{scheduleHandler2.model.mode}">
@@ -68,6 +68,10 @@
 			<h:selectBooleanCheckbox id="tooltip"
 				value="#{scheduleSettings2.tooltip}" required="true" />
 			<h:message for="tooltip" />
+			<h:outputLabel for="renderZeroLength" value="Render zero length entries" />
+			<h:selectBooleanCheckbox id="renderZeroLength"
+				value="#{scheduleSettings2.renderZeroLength}" required="true" />
+			<h:message for="renderZeroLength" />
 			<h:outputLabel for="theme" value="Theme:" />
 			<h:selectOneRadio id="theme" value="#{scheduleSettings2.theme}"
 				required="true">