You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mm...@apache.org on 2005/07/28 13:53:59 UTC

svn commit: r225754 [1/3] - in /myfaces: examples/trunk/sandbox/ examples/trunk/sandbox/WEB-INF/ examples/trunk/sandbox/src/java/org/apache/myfaces/examples/schedule/ sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/ sandbox/trunk/src/java/org...

Author: mmarinschek
Date: Thu Jul 28 04:53:37 2005
New Revision: 225754

URL: http://svn.apache.org/viewcvs?rev=225754&view=rev
Log:
patch to x:schedule by Jurgen Lust. Thanks!

Added:
    myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/resource/css/default.css
    myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/resource/css/evolution.css
    myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/resource/css/outlookxp.css
Modified:
    myfaces/examples/trunk/sandbox/WEB-INF/examples-config.xml
    myfaces/examples/trunk/sandbox/schedule.jsp
    myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleScheduleBackingBean.java
    myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/PlannerTag.java
    myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/ScheduleTag.java
    myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/renderer/AbstractCompactScheduleRenderer.java
    myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/renderer/AbstractScheduleRenderer.java
    myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/renderer/PlannerRenderer.java
    myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/renderer/ScheduleDetailedDayRenderer.java
    myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/resource/css/schedule.css
    myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/resource/javascript/domTT.js
    myfaces/sandbox/trunk/tld/entities/html_planner_attributes.xml
    myfaces/sandbox/trunk/tld/entities/html_schedule_attributes.xml

Modified: myfaces/examples/trunk/sandbox/WEB-INF/examples-config.xml
URL: http://svn.apache.org/viewcvs/myfaces/examples/trunk/sandbox/WEB-INF/examples-config.xml?rev=225754&r1=225753&r2=225754&view=diff
==============================================================================
--- myfaces/examples/trunk/sandbox/WEB-INF/examples-config.xml (original)
+++ myfaces/examples/trunk/sandbox/WEB-INF/examples-config.xml Thu Jul 28 04:53:37 2005
@@ -253,6 +253,22 @@
     <managed-bean-name>simpleSchedule</managed-bean-name>
     <managed-bean-class>org.apache.myfaces.examples.schedule.SimpleScheduleBackingBean</managed-bean-class>
     <managed-bean-scope>session</managed-bean-scope>
+        <managed-property>
+            <property-name>mode</property-name>
+            <value>1</value>
+        </managed-property>
+        <managed-property>
+            <property-name>theme</property-name>
+            <value>default</value>
+        </managed-property>
+        <managed-property>
+            <property-name>readonly</property-name>
+            <value>false</value>
+        </managed-property>
+        <managed-property>
+            <property-name>tooltip</property-name>
+            <value>true</value>
+        </managed-property>
   </managed-bean>
   
   <managed-bean>

Modified: myfaces/examples/trunk/sandbox/schedule.jsp
URL: http://svn.apache.org/viewcvs/myfaces/examples/trunk/sandbox/schedule.jsp?rev=225754&r1=225753&r2=225754&view=diff
==============================================================================
--- myfaces/examples/trunk/sandbox/schedule.jsp (original)
+++ myfaces/examples/trunk/sandbox/schedule.jsp Thu Jul 28 04:53:37 2005
@@ -36,7 +36,7 @@
             <table cellpadding="5" border="0">
                 <tr>
                     <td valign="top">
-                        <h:panelGrid cellpadding="0" cellspacing="15" columns="1">
+                        <h:panelGrid cellpadding="0" cellspacing="5" columns="1">
                             <x:inputCalendar
                                 id="scheduleNavigator"
                                 monthYearRowClass="yearMonthHeader"
@@ -60,6 +60,46 @@
                                     id="modeItems"
                                     value="#{simpleSchedule.modeItems}"/>
                             </h:selectOneMenu>
+                            <h:outputLabel
+                                for="themeInput"
+                                id="themeLabel"
+                                value="theme:" />
+                            <h:selectOneMenu
+                                id="themeInput"
+                                immediate="true"
+                                onchange="this.form.submit();"
+                                value="#{simpleSchedule.theme}">
+                                <f:selectItem
+                                    itemValue="default"
+                                    itemLabel="default"/>
+                                <f:selectItem
+                                    itemValue="outlookxp"
+                                    itemLabel="Outlook XP"/>
+                                <f:selectItem
+                                    itemValue="evolution"
+                                    itemLabel="Evolution"/>
+                            </h:selectOneMenu>
+                            <h:outputLabel
+                                for="readonlyInput"
+                                id="readonlyLabel"
+                                value="read-only:" />
+                            <h:selectBooleanCheckbox
+                                id="readonlyInput"
+                                value="#{simpleSchedule.readonly}"
+                                valueChangeListener="#{simpleSchedule.readonlyValueChanged}"
+                                immediate="true"
+                                onchange="this.form.submit();"
+                                title="read-only?"/>
+                            <h:outputLabel
+                                for="tooltipInput"
+                                id="tooltipLabel"
+                                value="show tooltips:" />
+                            <h:selectBooleanCheckbox
+                                id="tooltipInput"
+                                value="#{simpleSchedule.tooltip}"
+                                immediate="true"
+                                onchange="this.form.submit();"
+                                title="show tooltips?"/>
                         </h:panelGrid>
                     </td>
                     <td width="100%">
@@ -71,9 +111,10 @@
                             visibleStartHour="8"
                             workingEndHour="17"
                             workingStartHour="9"
-                            readonly="false"
+                            readonly="#{simpleSchedule.readonly}"
                             actionListener="#{simpleSchedule.scheduleActionPerformed}"
-                            tooltip="true"/>
+                            tooltip="#{simpleSchedule.tooltip}"
+                            theme="#{simpleSchedule.theme}"/>
                     </td>
                 </tr>
                 <tr>

Modified: myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleScheduleBackingBean.java
URL: http://svn.apache.org/viewcvs/myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleScheduleBackingBean.java?rev=225754&r1=225753&r2=225754&view=diff
==============================================================================
--- myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleScheduleBackingBean.java (original)
+++ myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleScheduleBackingBean.java Thu Jul 28 04:53:37 2005
@@ -48,6 +48,9 @@
     private HtmlSelectOneMenu modeInput;
     private Integer mode = new Integer(ScheduleModel.WORKWEEK);
     private SimpleScheduleModel model;
+    private String theme;
+    private Boolean tooltip;
+    private Boolean readonly;
 
     //~ Constructors -----------------------------------------------------------
 
@@ -146,6 +149,30 @@
     }
 
     /**
+     * <p>
+     * The theme that will be used to render the schedule
+     * </p>
+     * 
+     * @return Returns the theme.
+     */
+    public String getTheme()
+    {
+        return theme;
+    }
+
+    /**
+     * <p>
+     * The theme that will be used to render the schedule
+     * </p>
+     * 
+     * @param theme The theme to set.
+     */
+    public void setTheme(String theme)
+    {
+        this.theme = theme;
+    }
+
+    /**
      * @param model The model to set.
      */
     public void setModel(SimpleScheduleModel model)
@@ -247,6 +274,20 @@
     }
 
     /**
+     * <p>
+     * When the read-only setting is changed, clear the selection of the
+     * schedule.
+     * </p>
+     *
+     * @param event the action event
+     */
+    public void readonlyValueChanged(ValueChangeEvent event)
+    {
+        if (getModel() != null)
+            getModel().setSelectedEntry(null);
+    }
+
+    /**
      * Initialize the demo
      */
     private void initModel()
@@ -261,5 +302,53 @@
         model.setMode(mode.intValue());
 
         model.setSelectedDate(this.date);
+    }
+
+    /**
+     * <p>
+     * Should the schedule be readonly?
+     * </p>
+     * 
+     * @return Returns the readonly.
+     */
+    public Boolean getReadonly()
+    {
+        return readonly;
+    }
+
+    /**
+     * <p>
+     * Should the schedule be readonly?
+     * </p>
+     * 
+     * @param readonly The readonly to set.
+     */
+    public void setReadonly(Boolean readonly)
+    {
+        this.readonly = readonly;
+    }
+
+    /**
+     * <p>
+     * Should tooltips be shown on the schedule?
+     * </p>
+     * 
+     * @return Returns the tooltip.
+     */
+    public Boolean getTooltip()
+    {
+        return tooltip;
+    }
+
+    /**
+     * <p>
+     * Should tooltips be shown on the schedule?
+     * </p>
+     * 
+     * @param tooltip The tooltip to set.
+     */
+    public void setTooltip(Boolean tooltip)
+    {
+        this.tooltip = tooltip;
     }
 }

Modified: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/PlannerTag.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/PlannerTag.java?rev=225754&r1=225753&r2=225754&view=diff
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/PlannerTag.java (original)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/PlannerTag.java Thu Jul 28 04:53:37 2005
@@ -16,14 +16,11 @@
 
 package org.apache.myfaces.custom.schedule;
 
-
 import javax.faces.application.Application;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import javax.faces.webapp.UIComponentTag;
 
-
-
 /**
  * <p>
  * JSP tag for the UIPlanner component
@@ -32,8 +29,7 @@
  * @author Jurgen Lust (latest modification by $Author$)
  * @version $Revision$
  */
-public class PlannerTag
-    extends UIComponentTag
+public class PlannerTag extends UIComponentTag
 {
     //~ Instance fields --------------------------------------------------------
 
@@ -41,6 +37,7 @@
     private String headerDateFormat;
     private String legend;
     private String rendered;
+    private String theme;
     private String tooltip;
     private String value;
     private String visibleEndHour;
@@ -164,6 +161,36 @@
 
     /**
      * <p>
+     * The theme of the planner component. This is the name of the
+     * CSS file that should be loaded when rendering the planner.
+     * Possible values are 'default', 'outlookxp', 'outlook2003',
+     * 'evolution'.
+     * </p>
+     * 
+     * @param theme The theme to set.
+     */
+    public void setTheme(String theme)
+    {
+        this.theme = theme;
+    }
+
+    /**
+     * <p>
+     * The theme of the planner component. This is the name of the
+     * CSS file that should be loaded when rendering the planner.
+     * Possible values are 'default', 'outlookxp', 'outlook2003',
+     * 'evolution'.
+     * </p>
+     * 
+     * @return Returns the theme.
+     */
+    public String getTheme()
+    {
+        return theme;
+    }
+
+    /**
+     * <p>
      * Should tooltips be displayed?
      * </p>
      *
@@ -318,6 +345,7 @@
         workingEndHour = null;
         headerDateFormat = null;
         value = null;
+        theme = null;
         tooltip = null;
         legend = null;
         gutterWidthInPixels = null;
@@ -335,95 +363,104 @@
         FacesContext context = FacesContext.getCurrentInstance();
         Application app = context.getApplication();
 
-        if (rendered != null) {
-            if (isValueReference(rendered)) {
-                planner.setValueBinding(
-                    "rendered", app.createValueBinding(rendered)
-                );
-            } else {
+        if (rendered != null)
+        {
+            if (isValueReference(rendered))
+            {
+                planner.setValueBinding("rendered", app
+                        .createValueBinding(rendered));
+            }
+            else
+            {
                 planner.setRendered(Boolean.valueOf(rendered).booleanValue());
             }
         }
 
-        if (visibleStartHour != null) {
-            if (isValueReference(visibleStartHour)) {
-                planner.setValueBinding(
-                    "visibleStartHour", app.createValueBinding(
-                        visibleStartHour
-                    )
-                );
-            } else {
-                planner.setVisibleStartHour(
-                    new Integer(visibleStartHour).intValue()
-                );
+        if (visibleStartHour != null)
+        {
+            if (isValueReference(visibleStartHour))
+            {
+                planner.setValueBinding("visibleStartHour", app
+                        .createValueBinding(visibleStartHour));
+            }
+            else
+            {
+                planner.setVisibleStartHour(new Integer(visibleStartHour)
+                        .intValue());
             }
         }
 
-        if (visibleEndHour != null) {
-            if (isValueReference(visibleEndHour)) {
-                planner.setValueBinding(
-                    "visibleEndHour", app.createValueBinding(visibleEndHour)
-                );
-            } else {
-                planner.setVisibleEndHour(
-                    new Integer(visibleEndHour).intValue()
-                );
+        if (visibleEndHour != null)
+        {
+            if (isValueReference(visibleEndHour))
+            {
+                planner.setValueBinding("visibleEndHour", app
+                        .createValueBinding(visibleEndHour));
+            }
+            else
+            {
+                planner.setVisibleEndHour(new Integer(visibleEndHour)
+                        .intValue());
             }
         }
 
-        if (workingStartHour != null) {
-            if (isValueReference(workingStartHour)) {
-                planner.setValueBinding(
-                    "workingStartHour", app.createValueBinding(
-                        workingStartHour
-                    )
-                );
-            } else {
-                planner.setWorkingStartHour(
-                    new Integer(workingStartHour).intValue()
-                );
+        if (workingStartHour != null)
+        {
+            if (isValueReference(workingStartHour))
+            {
+                planner.setValueBinding("workingStartHour", app
+                        .createValueBinding(workingStartHour));
+            }
+            else
+            {
+                planner.setWorkingStartHour(new Integer(workingStartHour)
+                        .intValue());
             }
         }
 
-        if (workingEndHour != null) {
-            if (isValueReference(workingEndHour)) {
-                planner.setValueBinding(
-                    "workingEndHour", app.createValueBinding(workingEndHour)
-                );
-            } else {
-                planner.setWorkingEndHour(
-                    new Integer(workingEndHour).intValue()
-                );
+        if (workingEndHour != null)
+        {
+            if (isValueReference(workingEndHour))
+            {
+                planner.setValueBinding("workingEndHour", app
+                        .createValueBinding(workingEndHour));
+            }
+            else
+            {
+                planner.setWorkingEndHour(new Integer(workingEndHour)
+                        .intValue());
             }
         }
 
-        if ((value != null) && isValueReference(value)) {
+        if ((value != null) && isValueReference(value))
+        {
             planner.setValueBinding("value", app.createValueBinding(value));
-        } else {
+        }
+        else
+        {
             throw new IllegalArgumentException(
-                "The value property must be a value binding expression that points to a PlannerModel object."
-            );
+                    "The value property must be a value binding expression that points to a PlannerModel object.");
         }
 
         addAttribute(app, planner, "headerDateFormat", headerDateFormat);
+        addAttribute(app, planner, "theme", theme);
         addAttribute(app, planner, "tooltip", tooltip);
         addAttribute(app, planner, "legend", legend);
         addAttribute(app, planner, "gutterWidthInPixels", gutterWidthInPixels);
     }
 
-    private void addAttribute(
-        Application app,
-        UIComponent component,
-        String key,
-        String value
-    )
-    {
-        if ((key != null) && (value != null)) {
-            if (isValueReference(value)) {
-                component.setValueBinding(
-                    key, app.createValueBinding((String) value)
-                );
-            } else {
+    private void addAttribute(Application app, UIComponent component,
+            String key, String value)
+    {
+        if ((key != null) && (value != null))
+        {
+            if (isValueReference(value))
+            {
+                component.setValueBinding(key, app
+                        .createValueBinding((String) value));
+            }
+            else
+            {
                 component.getAttributes().put(key, value);
             }
         }

Modified: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/ScheduleTag.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/ScheduleTag.java?rev=225754&r1=225753&r2=225754&view=diff
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/ScheduleTag.java (original)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/ScheduleTag.java Thu Jul 28 04:53:37 2005
@@ -16,7 +16,6 @@
 
 package org.apache.myfaces.custom.schedule;
 
-
 import javax.faces.application.Application;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
@@ -24,8 +23,6 @@
 import javax.faces.event.ActionEvent;
 import javax.faces.webapp.UIComponentTag;
 
-
-
 /**
  * <p>
  * JSP tag for the schedule component
@@ -34,8 +31,7 @@
  * @author Jurgen Lust (latest modification by $Author$)
  * @version $Revision$
  */
-public class ScheduleTag
-    extends UIComponentTag
+public class ScheduleTag extends UIComponentTag
 {
     //~ Instance fields --------------------------------------------------------
 
@@ -47,6 +43,7 @@
     private String immediate;
     private String readonly;
     private String rendered;
+    private String theme;
     private String tooltip;
     private String value;
     private String visibleEndHour;
@@ -266,6 +263,34 @@
 
     /**
      * <p>
+     * The theme of the schedule component. This is the name of the
+     * CSS file that should be loaded when rendering the schedule.
+     * Possible values are 'default', 'outlookxp', 'evolution'.
+     * </p>
+     * 
+     * @param theme The theme to set.
+     */
+    public void setTheme(String theme)
+    {
+        this.theme = theme;
+    }
+
+    /**
+     * <p>
+     * The theme of the schedule component. This is the name of the
+     * CSS file that should be loaded when rendering the schedule.
+     * Possible values are 'default', 'outlookxp', 'evolution'.
+     * </p>
+     * 
+     * @return Returns the theme.
+     */
+    public String getTheme()
+    {
+        return theme;
+    }
+
+    /**
+     * <p>
      * Should tooltips be displayed?
      * </p>
      *
@@ -429,6 +454,7 @@
         actionListener = null;
         action = null;
         readonly = null;
+        theme = null;
         tooltip = null;
         rendered = null;
     }
@@ -444,150 +470,163 @@
         FacesContext context = FacesContext.getCurrentInstance();
         Application app = context.getApplication();
 
-        if (rendered != null) {
-            if (isValueReference(rendered)) {
-                schedule.setValueBinding(
-                    "rendered", app.createValueBinding(rendered)
-                );
-            } else {
+        if (rendered != null)
+        {
+            if (isValueReference(rendered))
+            {
+                schedule.setValueBinding("rendered", app
+                        .createValueBinding(rendered));
+            }
+            else
+            {
                 schedule.setRendered(Boolean.valueOf(rendered).booleanValue());
             }
         }
 
-        if (visibleStartHour != null) {
-            if (isValueReference(visibleStartHour)) {
-                schedule.setValueBinding(
-                    "visibleStartHour", app.createValueBinding(
-                        visibleStartHour
-                    )
-                );
-            } else {
-                schedule.setVisibleStartHour(
-                    new Integer(visibleStartHour).intValue()
-                );
-            }
-        }
-
-        if (visibleEndHour != null) {
-            if (isValueReference(visibleEndHour)) {
-                schedule.setValueBinding(
-                    "visibleEndHour", app.createValueBinding(visibleEndHour)
-                );
-            } else {
-                schedule.setVisibleEndHour(
-                    new Integer(visibleEndHour).intValue()
-                );
-            }
-        }
-
-        if (workingStartHour != null) {
-            if (isValueReference(workingStartHour)) {
-                schedule.setValueBinding(
-                    "workingStartHour", app.createValueBinding(
-                        workingStartHour
-                    )
-                );
-            } else {
-                schedule.setWorkingStartHour(
-                    new Integer(workingStartHour).intValue()
-                );
-            }
-        }
-
-        if (workingEndHour != null) {
-            if (isValueReference(workingEndHour)) {
-                schedule.setValueBinding(
-                    "workingEndHour", app.createValueBinding(workingEndHour)
-                );
-            } else {
-                schedule.setWorkingEndHour(
-                    new Integer(workingEndHour).intValue()
-                );
-            }
-        }
-
-        if (immediate != null) {
-            if (isValueReference(immediate)) {
-                schedule.setValueBinding(
-                    "immediate", app.createValueBinding(immediate)
-                );
-            } else {
-                schedule.setImmediate(
-                    Boolean.valueOf(immediate).booleanValue()
-                );
-            }
-        }
-
-        if (readonly != null) {
-            if (isValueReference(readonly)) {
-                schedule.setValueBinding(
-                    "readonly", app.createValueBinding(readonly)
-                );
-            } else {
+        if (visibleStartHour != null)
+        {
+            if (isValueReference(visibleStartHour))
+            {
+                schedule.setValueBinding("visibleStartHour", app
+                        .createValueBinding(visibleStartHour));
+            }
+            else
+            {
+                schedule.setVisibleStartHour(new Integer(visibleStartHour)
+                        .intValue());
+            }
+        }
+
+        if (visibleEndHour != null)
+        {
+            if (isValueReference(visibleEndHour))
+            {
+                schedule.setValueBinding("visibleEndHour", app
+                        .createValueBinding(visibleEndHour));
+            }
+            else
+            {
+                schedule.setVisibleEndHour(new Integer(visibleEndHour)
+                        .intValue());
+            }
+        }
+
+        if (workingStartHour != null)
+        {
+            if (isValueReference(workingStartHour))
+            {
+                schedule.setValueBinding("workingStartHour", app
+                        .createValueBinding(workingStartHour));
+            }
+            else
+            {
+                schedule.setWorkingStartHour(new Integer(workingStartHour)
+                        .intValue());
+            }
+        }
+
+        if (workingEndHour != null)
+        {
+            if (isValueReference(workingEndHour))
+            {
+                schedule.setValueBinding("workingEndHour", app
+                        .createValueBinding(workingEndHour));
+            }
+            else
+            {
+                schedule.setWorkingEndHour(new Integer(workingEndHour)
+                        .intValue());
+            }
+        }
+
+        if (immediate != null)
+        {
+            if (isValueReference(immediate))
+            {
+                schedule.setValueBinding("immediate", app
+                        .createValueBinding(immediate));
+            }
+            else
+            {
+                schedule
+                        .setImmediate(Boolean.valueOf(immediate).booleanValue());
+            }
+        }
+
+        if (readonly != null)
+        {
+            if (isValueReference(readonly))
+            {
+                schedule.setValueBinding("readonly", app
+                        .createValueBinding(readonly));
+            }
+            else
+            {
                 schedule.setReadonly(Boolean.valueOf(readonly).booleanValue());
             }
         }
 
-        if (actionListener != null) {
-            if (isValueReference(actionListener)) {
-                MethodBinding actionListenerBinding =
-                    app.createMethodBinding(
-                        actionListener, new Class[] { ActionEvent.class }
-                    );
+        if (actionListener != null)
+        {
+            if (isValueReference(actionListener))
+            {
+                MethodBinding actionListenerBinding = app.createMethodBinding(
+                        actionListener, new Class[] { ActionEvent.class });
                 schedule.setActionListener(actionListenerBinding);
-            } else {
+            }
+            else
+            {
                 throw new IllegalArgumentException(
-                    "actionListener property must be a method-binding expression."
-                );
+                        "actionListener property must be a method-binding expression.");
             }
         }
 
-        if (action != null) {
-            if (isValueReference(action)) {
-                MethodBinding actionBinding =
-                    app.createMethodBinding(
-                        action, new Class[] { ActionEvent.class }
-                    );
+        if (action != null)
+        {
+            if (isValueReference(action))
+            {
+                MethodBinding actionBinding = app.createMethodBinding(action,
+                        new Class[] { ActionEvent.class });
                 schedule.setAction(actionBinding);
-            } else {
+            }
+            else
+            {
                 throw new IllegalArgumentException(
-                    "action property must be a method-binding expression."
-                );
+                        "action property must be a method-binding expression.");
             }
         }
 
-        if ((value != null) && isValueReference(value)) {
-            System.out.println("set value: " + value);
+        if ((value != null) && isValueReference(value))
+        {
             schedule.setValueBinding("value", app.createValueBinding(value));
-        } else {
+        }
+        else
+        {
             throw new IllegalArgumentException(
-                "The value property must be a value binding expression that points to a SimpleScheduleModel object."
-            );
+                    "The value property must be a value binding expression that points to a SimpleScheduleModel object.");
         }
 
         addAttribute(app, schedule, "headerDateFormat", headerDateFormat);
+        addAttribute(app, schedule, "theme", theme);
         addAttribute(app, schedule, "tooltip", tooltip);
-        addAttribute(
-            app, schedule, "compactWeekRowHeight", compactWeekRowHeight
-        );
-        addAttribute(
-            app, schedule, "compactMonthRowHeight", compactMonthRowHeight
-        );
-    }
-
-    private void addAttribute(
-        Application app,
-        UIComponent component,
-        String key,
-        String value
-    )
-    {
-        if ((key != null) && (value != null)) {
-            if (isValueReference(value)) {
-                component.setValueBinding(
-                    key, app.createValueBinding((String) value)
-                );
-            } else {
+        addAttribute(app, schedule, "compactWeekRowHeight",
+                compactWeekRowHeight);
+        addAttribute(app, schedule, "compactMonthRowHeight",
+                compactMonthRowHeight);
+    }
+
+    private void addAttribute(Application app, UIComponent component,
+            String key, String value)
+    {
+        if ((key != null) && (value != null))
+        {
+            if (isValueReference(value))
+            {
+                component.setValueBinding(key, app
+                        .createValueBinding((String) value));
+            }
+            else
+            {
                 component.getAttributes().put(key, value);
             }
         }

Modified: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/renderer/AbstractCompactScheduleRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/renderer/AbstractCompactScheduleRenderer.java?rev=225754&r1=225753&r2=225754&view=diff
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/renderer/AbstractCompactScheduleRenderer.java (original)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/renderer/AbstractCompactScheduleRenderer.java Thu Jul 28 04:53:37 2005
@@ -16,7 +16,6 @@
 
 package org.apache.myfaces.custom.schedule.renderer;
 
-
 import java.io.IOException;
 import java.text.DateFormat;
 import java.util.Date;
@@ -35,7 +34,6 @@
 import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
 import org.apache.myfaces.renderkit.html.HTML;
 
-
 /**
  * <p>
  * Abstract superclass for the week and month view renderers.
@@ -45,8 +43,8 @@
  * @author Bruno Aranda (adaptation of Jurgen's code to myfaces)
  * @version $Revision$
  */
-public abstract class AbstractCompactScheduleRenderer
-    extends AbstractScheduleRenderer
+public abstract class AbstractCompactScheduleRenderer extends
+        AbstractScheduleRenderer
 {
     //~ Methods ----------------------------------------------------------------
 
@@ -54,11 +52,8 @@
      * @see javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext,
      *      javax.faces.component.UIComponent)
      */
-    public void encodeChildren(
-        FacesContext context,
-        UIComponent component
-    )
-        throws IOException
+    public void encodeChildren(FacesContext context, UIComponent component)
+            throws IOException
     {
         //the children are rendered in the encodeBegin phase
     }
@@ -67,11 +62,8 @@
      * @see javax.faces.render.Renderer#encodeEnd(javax.faces.context.FacesContext,
      *      javax.faces.component.UIComponent)
      */
-    public void encodeEnd(
-        FacesContext context,
-        UIComponent component
-    )
-        throws IOException
+    public void encodeEnd(FacesContext context, UIComponent component)
+            throws IOException
     {
         //all rendering is done in the begin phase
     }
@@ -95,16 +87,18 @@
     {
         int rowHeight = 0;
 
-        try {
-            rowHeight =
-                Integer.valueOf(
-                    (String) attributes.get(getRowHeightProperty())
-                ).intValue();
-        } catch (Exception e) {
+        try
+        {
+            rowHeight = Integer.valueOf(
+                    (String) attributes.get(getRowHeightProperty())).intValue();
+        }
+        catch (Exception e)
+        {
             rowHeight = 0;
         }
 
-        if (rowHeight <= 0) {
+        if (rowHeight <= 0)
+        {
             rowHeight = getDefaultRowHeight();
         }
 
@@ -129,28 +123,18 @@
      *
      * @throws IOException when the cell could not be drawn
      */
-    protected void writeDayCell(
-        FacesContext context,
-        ResponseWriter writer,
-        HtmlSchedule schedule,
-        ScheduleDay day,
-        float cellWidth,
-        int dayOfWeek,
-        int dayOfMonth,
-        boolean isWeekend,
-        boolean isCurrentMonth,
-        int rowspan
-    )
-        throws IOException
+    protected void writeDayCell(FacesContext context, ResponseWriter writer,
+            HtmlSchedule schedule, ScheduleDay day, float cellWidth,
+            int dayOfWeek, int dayOfMonth, boolean isWeekend,
+            boolean isCurrentMonth, int rowspan) throws IOException
     {
         Map attributes = schedule.getAttributes();
         writer.startElement(HTML.TD_ELEM, schedule);
 
         writer.writeAttribute("rowspan", String.valueOf(rowspan), null);
 
-        writer.writeAttribute(
-            HTML.CLASS_ATTR, isCurrentMonth ? "day" : "inactive-day", null
-        );
+        writer.writeAttribute(HTML.CLASS_ATTR, isCurrentMonth ? "day"
+                : "inactive-day", null);
 
         //determine the height of the day in pixels
         StringBuffer styleBuffer = new StringBuffer();
@@ -159,10 +143,13 @@
         int myRowHeight = 0;
         int myContentHeight = 0;
 
-        if (isWeekend) {
+        if (isWeekend)
+        {
             myRowHeight = getRowHeight(attributes) / 2;
             myContentHeight = myRowHeight - 19;
-        } else {
+        }
+        else
+        {
             myRowHeight = getRowHeight(attributes) + 1; //need to add 1 to get the weekends right
             myContentHeight = myRowHeight - 18; //18 instead of 19, to get the weekends right
         }
@@ -170,17 +157,14 @@
         styleBuffer.append(myRowHeight);
         styleBuffer.append("px;");
 
-        writer.writeAttribute(
-            HTML.STYLE_ATTR, styleBuffer.toString() + " width: " + cellWidth + "%;",
-            null
-        );
+        writer.writeAttribute(HTML.STYLE_ATTR, styleBuffer.toString()
+                + " width: " + cellWidth + "%;", null);
 
         writer.startElement(HTML.TABLE_ELEM, schedule);
 
         writer.writeAttribute(HTML.CLASS_ATTR, "day", null);
-        writer.writeAttribute(
-            HTML.STYLE_ATTR, styleBuffer.toString() + " width: 100%;", null
-        );
+        writer.writeAttribute(HTML.STYLE_ATTR, styleBuffer.toString()
+                + " width: 100%;", null);
 
         writer.writeAttribute(HTML.CELLPADDING_ATTR, "0", null);
         writer.writeAttribute(HTML.CELLSPACING_ATTR, "0", null);
@@ -189,13 +173,9 @@
         writer.startElement(HTML.TR_ELEM, schedule);
         writer.startElement(HTML.TD_ELEM, schedule);
         writer.writeAttribute(HTML.CLASS_ATTR, "header", null);
-        writer.writeAttribute(
-            HTML.STYLE_ATTR, "height: 18px; width: 100%; overflow: hidden", null
-        );
-        writer.writeText(
-            getDateString(context, schedule.getAttributes(), day.getDate()),
-            null
-        );
+        writer.writeAttribute(HTML.STYLE_ATTR,
+                "height: 18px; width: 100%; overflow: hidden", null);
+        writer.writeText(getDateString(context, schedule, day.getDate()), null);
         writer.endElement(HTML.TD_ELEM);
         writer.endElement(HTML.TR_ELEM);
 
@@ -210,14 +190,15 @@
         contentStyleBuffer.append("height: ");
         contentStyleBuffer.append(myContentHeight);
         contentStyleBuffer.append("px; width: 100%;");
-        writer.writeAttribute(HTML.STYLE_ATTR, contentStyleBuffer.toString(), null);
+        writer.writeAttribute(HTML.STYLE_ATTR, contentStyleBuffer.toString(),
+                null);
 
         writer.startElement(HTML.DIV_ELEM, schedule);
-        writer.writeAttribute(
-            HTML.STYLE_ATTR,
-            "width: 100%; height: 100%; overflow: auto; vertical-align: top;",
-            null
-        );
+        writer
+                .writeAttribute(
+                        HTML.STYLE_ATTR,
+                        "width: 100%; height: 100%; overflow: auto; vertical-align: top;",
+                        null);
         writer.startElement(HTML.TABLE_ELEM, schedule);
         writer.writeAttribute(HTML.STYLE_ATTR, "width: 100%;", null);
 
@@ -243,45 +224,41 @@
      *
      * @throws IOException when the entries could not be drawn
      */
-    protected void writeEntries(
-        FacesContext context,
-        HtmlSchedule schedule,
-        ScheduleDay day,
-        ResponseWriter writer
-    )
-        throws IOException
+    protected void writeEntries(FacesContext context, HtmlSchedule schedule,
+            ScheduleDay day, ResponseWriter writer) throws IOException
     {
         UIForm parentForm = getParentForm(schedule);
         TreeSet entrySet = new TreeSet(comparator);
 
-        for (Iterator entryIterator = day.iterator(); entryIterator.hasNext();) {
+        for (Iterator entryIterator = day.iterator(); entryIterator.hasNext();)
+        {
             ScheduleEntry entry = (ScheduleEntry) entryIterator.next();
             entrySet.add(entry);
         }
 
-        for (
-            Iterator entryIterator = entrySet.iterator();
-                entryIterator.hasNext();
-        ) {
+        for (Iterator entryIterator = entrySet.iterator(); entryIterator
+                .hasNext();)
+        {
             ScheduleEntry entry = (ScheduleEntry) entryIterator.next();
             writer.startElement(HTML.TR_ELEM, schedule);
             writer.startElement(HTML.TD_ELEM, schedule);
 
-            if (isSelected(schedule, entry)) {
+            if (isSelected(schedule, entry))
+            {
                 writer.writeAttribute(HTML.CLASS_ATTR, "selected", null);
             }
 
             writer.writeAttribute(HTML.STYLE_ATTR, "width: 100%", null);
 
             //draw the tooltip
-            if (showTooltip(schedule.getAttributes())) {
-                writer.writeAttribute(
-                    "onmouseover",
-                    getTooltipText(entry, schedule.getAttributes()), null
-                );
+            if (showTooltip(schedule))
+            {
+                writer.writeAttribute("onmouseover", getTooltipText(entry,
+                        schedule), null);
             }
 
-            if (!isSelected(schedule, entry) && !schedule.isReadonly()) {
+            if (!isSelected(schedule, entry) && !schedule.isReadonly())
+            {
                 writer.startElement("a", schedule);
                 writer.writeAttribute("href", "#", null);
 
@@ -296,14 +273,15 @@
                 mousedown.append("'; document.forms['");
                 mousedown.append(parentForm.getClientId(context));
                 mousedown.append("'].submit()");
-                writer.writeAttribute(
-                    "onmousedown", mousedown.toString(), null
-                );
+                writer
+                        .writeAttribute("onmousedown", mousedown.toString(),
+                                null);
             }
 
             writer.writeText(getEntryText(day, entry), null);
 
-            if (!isSelected(schedule, entry) && !schedule.isReadonly()) {
+            if (!isSelected(schedule, entry) && !schedule.isReadonly())
+            {
                 writer.endElement("a");
             }
 
@@ -312,21 +290,20 @@
         }
     }
 
-    private String getEntryText(
-        Day day,
-        ScheduleEntry entry
-    )
+    private String getEntryText(Day day, ScheduleEntry entry)
     {
         StringBuffer text = new StringBuffer();
         Date startTime = entry.getStartTime();
 
-        if (day.getDayStart().after(entry.getStartTime())) {
+        if (day.getDayStart().after(entry.getStartTime()))
+        {
             startTime = day.getDayStart();
         }
 
         Date endTime = entry.getEndTime();
 
-        if (day.getDayEnd().before(entry.getEndTime())) {
+        if (day.getDayEnd().before(entry.getEndTime()))
+        {
             endTime = day.getDayEnd();
         }
 
@@ -342,14 +319,12 @@
         return returnString;
     }
 
-    private boolean isSelected(
-        HtmlSchedule schedule,
-        ScheduleEntry entry
-    )
+    private boolean isSelected(HtmlSchedule schedule, ScheduleEntry entry)
     {
         ScheduleEntry selectedEntry = schedule.getModel().getSelectedEntry();
 
-        if (selectedEntry == null) {
+        if (selectedEntry == null)
+        {
             return false;
         }
 

Modified: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/renderer/AbstractScheduleRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/renderer/AbstractScheduleRenderer.java?rev=225754&r1=225753&r2=225754&view=diff
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/renderer/AbstractScheduleRenderer.java (original)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/renderer/AbstractScheduleRenderer.java Thu Jul 28 04:53:37 2005
@@ -16,7 +16,6 @@
 
 package org.apache.myfaces.custom.schedule.renderer;
 
-
 import java.io.IOException;
 
 import java.text.DateFormat;
@@ -29,6 +28,7 @@
 import javax.faces.component.UIForm;
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
+import javax.faces.el.ValueBinding;
 import javax.faces.event.ActionEvent;
 import javax.faces.render.Renderer;
 
@@ -39,7 +39,6 @@
 import org.apache.myfaces.custom.schedule.util.ScheduleUtil;
 import org.apache.myfaces.renderkit.html.HTML;
 
-
 /**
  * <p>
  * Abstract superclass for all renderer of the UISchedule component
@@ -49,13 +48,11 @@
  * @author Bruno Aranda (adaptation of Jurgen's code to myfaces)
  * @version $Revision$
  */
-public class AbstractScheduleRenderer
-    extends Renderer
+public class AbstractScheduleRenderer extends Renderer
 {
     //~ Static fields/initializers ---------------------------------------------
 
-    protected static final ScheduleEntryComparator comparator =
-        new ScheduleEntryComparator();
+    protected static final ScheduleEntryComparator comparator = new ScheduleEntryComparator();
 
     //~ Methods ----------------------------------------------------------------
 
@@ -63,19 +60,18 @@
      * @see javax.faces.render.Renderer#decode(javax.faces.context.FacesContext,
      *      javax.faces.component.UIComponent)
      */
-    public void decode(
-        FacesContext context,
-        UIComponent component
-    )
+    public void decode(FacesContext context, UIComponent component)
     {
-        if (ScheduleUtil.canModifyValue(component)) {
+        if (ScheduleUtil.canModifyValue(component))
+        {
             HtmlSchedule schedule = (HtmlSchedule) component;
-            Map parameters =
-                context.getExternalContext().getRequestParameterMap();
-            String selectedEntryId =
-                (String) parameters.get((String) schedule.getClientId(context));
+            Map parameters = context.getExternalContext()
+                    .getRequestParameterMap();
+            String selectedEntryId = (String) parameters.get((String) schedule
+                    .getClientId(context));
 
-            if ((selectedEntryId != null) && (selectedEntryId.length() > 0)) {
+            if ((selectedEntryId != null) && (selectedEntryId.length() > 0))
+            {
                 schedule.setSubmittedEntry(schedule.findEntry(selectedEntryId));
                 schedule.queueEvent(new ActionEvent(schedule));
             }
@@ -86,17 +82,26 @@
      * @see javax.faces.render.Renderer#encodeBegin(javax.faces.context.FacesContext,
      *      javax.faces.component.UIComponent)
      */
-    public void encodeBegin(
-        FacesContext context,
-        UIComponent component
-    )
-        throws IOException
+    public void encodeBegin(FacesContext context, UIComponent component)
+            throws IOException
     {
-        if (!component.isRendered()) {
+        if (!component.isRendered())
+        {
             return;
         }
 
-        AddResource.addStyleSheet(HtmlSchedule.class, "css/schedule.css", context);
+        HtmlSchedule schedule = (HtmlSchedule) component;
+        ResponseWriter writer = context.getResponseWriter();
+
+        //determine the CSS file for the chosen theme
+        String theme = getTheme(schedule);
+        if (theme == null || theme.length() < 1)
+            theme = "default";
+        String css = "css/" + theme + ".css";
+
+        //add needed CSS and Javascript files to the header 
+
+        AddResource.addStyleSheet(HtmlSchedule.class, css, context);
         AddResource.addJavaScriptToHeader(HtmlSchedule.class,
                 "javascript/alphaAPI.js", context);
         AddResource.addJavaScriptToHeader(HtmlSchedule.class,
@@ -106,16 +111,11 @@
         AddResource.addJavaScriptToHeader(HtmlSchedule.class,
                 "javascript/fadomatic.js", context);
 
-        HtmlSchedule schedule = (HtmlSchedule) component;
-        Map attributes = schedule.getAttributes();
-        ResponseWriter writer = context.getResponseWriter();
-
         //hidden input field containing the id of the selected entry
         writer.startElement(HTML.INPUT_ELEM, schedule);
         writer.writeAttribute(HTML.TYPE_ATTR, "hidden", null);
-        writer.writeAttribute(
-            HTML.NAME_ATTR, schedule.getClientId(context), "clientId"
-        );
+        writer.writeAttribute(HTML.NAME_ATTR, schedule.getClientId(context),
+                "clientId");
         writer.endElement(HTML.INPUT_ELEM);
     }
 
@@ -126,30 +126,30 @@
      * </p>
      *
      * @param context the FacesContext
-     * @param attributes the attributes
+     * @param component the component
      * @param date the date
      *
      * @return the date string
      */
-    protected String getDateString(
-        FacesContext context,
-        Map attributes,
-        Date date
-    )
+    protected String getDateString(FacesContext context, UIComponent component,
+            Date date)
     {
         DateFormat format;
-        String pattern = getHeaderDateFormat(attributes);
+        String pattern = getHeaderDateFormat(component);
 
-        if ((pattern != null) && (pattern.length() > 0)) {
+        if ((pattern != null) && (pattern.length() > 0))
+        {
             format = new SimpleDateFormat(pattern);
-        } else {
-            if (context.getApplication().getDefaultLocale() != null) {
-                format =
-                    DateFormat.getDateInstance(
-                        DateFormat.MEDIUM,
-                        context.getApplication().getDefaultLocale()
-                    );
-            } else {
+        }
+        else
+        {
+            if (context.getApplication().getDefaultLocale() != null)
+            {
+                format = DateFormat.getDateInstance(DateFormat.MEDIUM, context
+                        .getApplication().getDefaultLocale());
+            }
+            else
+            {
                 format = DateFormat.getDateInstance(DateFormat.MEDIUM);
             }
         }
@@ -159,15 +159,59 @@
 
     /**
      * <p>
+     * The theme used when rendering the schedule
+     * </p>
+     * 
+     * @param component the component
+     * 
+     * @return the theme
+     */
+    protected String getTheme(UIComponent component)
+    {
+        //first check if the theme property is a value binding expression
+        ValueBinding binding = component.getValueBinding("theme");
+        if (binding != null)
+        {
+            String value = (String) binding.getValue(FacesContext
+                    .getCurrentInstance());
+
+            if (value != null)
+            {
+                return value;
+            }
+        }
+        //it's not a value binding expression, so check for the string value
+        //in the attributes
+        Map attributes = component.getAttributes();
+        return (String) attributes.get("theme");
+    }
+
+    /**
+     * <p>
      * The date format that is used in the schedule header
      * </p>
      *
-     * @param attributes the attributes
+     * @param component the component
      *
      * @return Returns the headerDateFormat.
      */
-    protected String getHeaderDateFormat(Map attributes)
+    protected String getHeaderDateFormat(UIComponent component)
     {
+        //first check if the headerDateFormat property is a value binding expression
+        ValueBinding binding = component.getValueBinding("headerDateFormat");
+        if (binding != null)
+        {
+            String value = (String) binding.getValue(FacesContext
+                    .getCurrentInstance());
+
+            if (value != null)
+            {
+                return value;
+            }
+        }
+        //it's not a value binding expression, so check for the string value
+        //in the attributes
+        Map attributes = component.getAttributes();
         return (String) attributes.get("headerDateFormat");
     }
 
@@ -184,8 +228,10 @@
     {
         UIComponent parent = component.getParent();
 
-        while (parent != null) {
-            if (parent instanceof UIForm) {
+        while (parent != null)
+        {
+            if (parent instanceof UIForm)
+            {
                 break;
             }
 
@@ -205,33 +251,33 @@
      *
      * @return the tooltip text
      */
-    protected String getTooltipText(
-        ScheduleEntry entry,
-        Map attributes
-    )
+    protected String getTooltipText(ScheduleEntry entry, UIComponent component)
     {
-        if (!showTooltip(attributes)) {
+        if (!showTooltip(component))
+        {
             return null;
         }
 
         StringBuffer buffer = new StringBuffer();
-        buffer.append(
-            "return makeTrue(domTT_activate(this, event, 'caption', '"
-        );
+        buffer
+                .append("return makeTrue(domTT_activate(this, event, 'caption', '");
 
-        if (entry.getTitle() != null) {
+        if (entry.getTitle() != null)
+        {
             buffer.append(escape(entry.getTitle()));
         }
 
         buffer.append("', 'content', '<i>");
 
-        if (entry.getSubtitle() != null) {
+        if (entry.getSubtitle() != null)
+        {
             buffer.append(escape(entry.getSubtitle()));
         }
 
         buffer.append("</i>");
 
-        if (entry.getDescription() != null) {
+        if (entry.getDescription() != null)
+        {
             buffer.append("<br/>");
             buffer.append(escape(entry.getDescription()));
         }
@@ -246,18 +292,35 @@
      * Should the tooltip be made visible?
      * </p>
      *
-     * @param attributes the attributes
+     * @param component the component
      *
      * @return whether or not tooltips should be rendered
      */
-    protected boolean showTooltip(Map attributes)
+    protected boolean showTooltip(UIComponent component)
     {
-        return Boolean.valueOf((String) attributes.get("tooltip")).booleanValue();
+        //first check if the tooltip property is a value binding expression
+        ValueBinding binding = component.getValueBinding("tooltip");
+        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("tooltip"))
+                .booleanValue();
     }
 
     private String escape(String text)
     {
-        if (text == null) {
+        if (text == null)
+        {
             return null;
         }
 

Modified: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/renderer/PlannerRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/renderer/PlannerRenderer.java?rev=225754&r1=225753&r2=225754&view=diff
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/renderer/PlannerRenderer.java (original)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/renderer/PlannerRenderer.java Thu Jul 28 04:53:37 2005
@@ -29,11 +29,11 @@
 import javax.faces.component.UIForm;
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
+import javax.faces.el.ValueBinding;
 import javax.faces.render.Renderer;
 
 import org.apache.myfaces.component.html.util.AddResource;
 import org.apache.myfaces.custom.schedule.HtmlPlanner;
-import org.apache.myfaces.custom.schedule.HtmlSchedule;
 import org.apache.myfaces.custom.schedule.model.Day;
 import org.apache.myfaces.custom.schedule.model.PlannerEntity;
 import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
@@ -73,7 +73,17 @@
             return;
         }
 
-        AddResource.addStyleSheet(HtmlPlanner.class, "css/schedule.css",
+        HtmlPlanner planner = (HtmlPlanner) component;
+        ResponseWriter writer = context.getResponseWriter();
+        
+        //determine the CSS file for the chosen theme
+        String theme = getTheme(planner);
+        if (theme == null || theme.length() < 1) theme = "default";
+        String css = "css/" + theme + ".css";
+        
+        //add needed CSS and Javascript files to the header 
+
+        AddResource.addStyleSheet(HtmlPlanner.class, css,
                 context);
         AddResource.addJavaScriptToHeader(HtmlPlanner.class,
                 "javascript/alphaAPI.js", context);
@@ -84,9 +94,6 @@
         AddResource.addJavaScriptToHeader(HtmlPlanner.class,
                 "javascript/fadomatic.js", context);
 
-        HtmlPlanner planner = (HtmlPlanner) component;
-        Map attributes = planner.getAttributes();
-        ResponseWriter writer = context.getResponseWriter();
 
         int numberOfRows = planner.getModel().numberOfEntities();
 
@@ -113,7 +120,6 @@
         }
 
         HtmlPlanner planner = (HtmlPlanner) component;
-        Map attributes = planner.getAttributes();
         ResponseWriter writer = context.getResponseWriter();
 
         for (Iterator entityIterator = planner.getModel().entityIterator(); entityIterator
@@ -125,7 +131,7 @@
             writer.writeAttribute(HTML.CLASS_ATTR, "gutter", null);
             writer.startElement(HTML.DIV_ELEM, planner);
             writer.writeAttribute(HTML.STYLE_ATTR, "height: 1px; width: "
-                    + String.valueOf(getGutterWidth(planner.getAttributes()))
+                    + String.valueOf(getGutterWidth(planner))
                     + "px", null);
             writer.endElement(HTML.DIV_ELEM);
             writer.endElement(HTML.TD_ELEM);
@@ -177,7 +183,6 @@
         }
 
         HtmlPlanner planner = (HtmlPlanner) component;
-        Map attributes = planner.getAttributes();
         ResponseWriter writer = context.getResponseWriter();
         writeForegroundEnd(context, planner, writer);
         writer.endElement(HTML.DIV_ELEM);
@@ -188,14 +193,30 @@
      * Determine the width of the left gutter
      * </p>
      *
-     * @param attributes the attributes
+     * @param component the component
      *
      * @return the gutter width in pixels
      */
-    protected int getGutterWidth(Map attributes)
+    protected int getGutterWidth(UIComponent component)
     {
         try
         {
+            //first check if the gutterWidthInPixels property is a
+            //value binding expression
+            ValueBinding binding = component.getValueBinding("gutterWidthInPixels");
+            if (binding != null) {
+                Integer value =
+                    (Integer) binding.getValue(
+                        FacesContext.getCurrentInstance()
+                    );
+
+                if (value != null) {
+                    return value.intValue();
+                }
+            }
+            //it's not a value binding expression, so check for the string value
+            //in the attributes
+            Map attributes = component.getAttributes();
             Integer width = Integer.valueOf((String) attributes
                     .get("gutterWidthInPixels"));
 
@@ -212,12 +233,27 @@
      * The date format that is used in the planner header
      * </p>
      *
-     * @param attributes the attributes
+     * @param component the component
      *
      * @return Returns the headerDateFormat.
      */
-    protected String getHeaderDateFormat(Map attributes)
+    protected String getHeaderDateFormat(UIComponent component)
     {
+        //first check if the headerDateFormat property is a value binding expression
+        ValueBinding binding = component.getValueBinding("headerDateFormat");
+        if (binding != null) {
+            String value =
+                (String) binding.getValue(
+                    FacesContext.getCurrentInstance()
+                );
+
+            if (value != null) {
+                return value;
+            }
+        }
+        //it's not a value binding expression, so check for the string value
+        //in the attributes
+        Map attributes = component.getAttributes();
         return (String) attributes.get("headerDateFormat");
     }
 
@@ -254,29 +290,86 @@
      *
      * TODO the rendering of the legend has not been implemented yet
      *
-     * @param attributes the attributes
+     * @param component the component
      *
      * @return whether to render the legend
      */
-    protected boolean showLegend(Map attributes)
+    protected boolean showLegend(UIComponent component)
     {
+        //first check if the tooltip property is a value binding expression
+        ValueBinding binding = component.getValueBinding("legend");
+        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("legend"))
                 .booleanValue();
     }
 
     /**
      * <p>
+     * The theme used when rendering the planner
+     * </p>
+     * 
+     * @param component the component
+     * 
+     * @return the theme
+     */
+    protected String getTheme(UIComponent component) {
+        //first check if the theme property is a value binding expression
+        ValueBinding binding = component.getValueBinding("theme");
+        if (binding != null) {
+            String value =
+                (String) binding.getValue(
+                    FacesContext.getCurrentInstance()
+                );
+
+            if (value != null) {
+                return value;
+            }
+        }
+        //it's not a value binding expression, so check for the string value
+        //in the attributes
+        Map attributes = component.getAttributes();
+        return (String)attributes.get("theme");
+    }
+    
+    /**
+     * <p>
      * Should the tooltip be rendered?
      * </p>
      *
-     * @param attributes the attributes
+     * @param component the component
      *
      * @return whether or not tooltips should be rendered
      */
-    protected boolean showTooltip(Map attributes)
+    protected boolean showTooltip(UIComponent component)
     {
-        return Boolean.valueOf((String) attributes.get("tooltip"))
-                .booleanValue();
+        //first check if the tooltip property is a value binding expression
+        ValueBinding binding = component.getValueBinding("tooltip");
+        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("tooltip")).booleanValue();
     }
 
     private String getCellClass(HtmlPlanner planner, Day day, int hour)
@@ -295,10 +388,10 @@
         return "free";
     }
 
-    private String getDateString(FacesContext context, Map attributes, Date date)
+    private String getDateString(FacesContext context, UIComponent component, Date date)
     {
         DateFormat format;
-        String pattern = getHeaderDateFormat(attributes);
+        String pattern = getHeaderDateFormat(component);
 
         if ((pattern != null) && (pattern.length() > 0))
         {
@@ -320,17 +413,13 @@
         return format.format(date);
     }
 
-    private String getTooltipText(ScheduleEntry entry, Map attributes)
+    private String getTooltipText(ScheduleEntry entry, UIComponent component)
     {
-        if (!showTooltip(attributes))
+        if (!showTooltip(component))
         {
             return null;
         }
 
-        //TODO enable tooltips again
-        return "";
-
-        /*
          StringBuffer buffer = new StringBuffer();
          buffer.append(
          "return makeTrue(domTT_activate(this, event, 'caption', '"
@@ -356,7 +445,6 @@
          buffer.append("', 'trail', true));");
 
          return buffer.toString();
-         */
     }
 
     private boolean containsEntry(HtmlPlanner planner, Day day,
@@ -445,7 +533,7 @@
                         null);
         writer.startElement(HTML.DIV_ELEM, planner);
         writer.writeAttribute(HTML.STYLE_ATTR, "height: 1px; width: "
-                + String.valueOf(getGutterWidth(planner.getAttributes()))
+                + String.valueOf(getGutterWidth(planner))
                 + "px", null);
         writer.endElement(HTML.DIV_ELEM);
         writer.endElement(HTML.TD_ELEM);
@@ -477,7 +565,7 @@
                             HTML.STYLE_ATTR,
                             "position: absolute; left: 0px; top: 0px; width: 100%; height: 15px; overflow: hidden; white-space: nowrap;",
                             null);
-            writer.writeText(getDateString(context, planner.getAttributes(),
+            writer.writeText(getDateString(context, planner,
                     day.getDate()), null);
             writer.endElement(HTML.SPAN_ELEM);
 
@@ -659,10 +747,10 @@
                 writer.startElement(HTML.DIV_ELEM, planner);
 
                 //draw the tooltip
-                if (showTooltip(planner.getAttributes()))
+                if (showTooltip(planner))
                 {
                     writer.writeAttribute("onmouseover", getTooltipText(
-                            wrapper.entry, planner.getAttributes()), null);
+                            wrapper.entry, planner), null);
                 }
 
                 writer.writeAttribute(HTML.CLASS_ATTR, "entry", null);
@@ -713,7 +801,7 @@
                         null);
         writer.startElement(HTML.DIV_ELEM, planner);
         writer.writeAttribute(HTML.STYLE_ATTR, "height: 1px; width: "
-                + String.valueOf(getGutterWidth(planner.getAttributes()))
+                + String.valueOf(getGutterWidth(planner))
                 + "px", null);
         writer.endElement(HTML.DIV_ELEM);
         writer.endElement(HTML.TD_ELEM);