View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.myfaces.custom.schedule;
21  
22  import java.io.IOException;
23  import java.io.Serializable;
24  
25  import javax.faces.context.FacesContext;
26  import javax.faces.context.ResponseWriter;
27  
28  import org.apache.myfaces.custom.schedule.model.ScheduleDay;
29  import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
30  
31  /**
32   * <p>
33   * The ScheduleEntryRenderer is responsible for rendering the content and the
34   * tooltip of a ScheduleEntry.
35   * </p>
36   * <p>
37   * Note that the box around the entry is rendered by the ScheduleRenderer,
38   * because determining the position and size of the box cannot be done
39   * independent of the other entries.
40   * </p>
41   * <p>
42   * The color of the box can be set using the getEntryColor method. This allows a
43   * developer to use different colors for the entries of different users for
44   * example.
45   * </p>
46   * 
47   * @since 1.1.7
48   * @author Jurgen Lust (latest modification by $Author$)
49   * @version $Revision$
50   */
51  public interface ScheduleEntryRenderer extends Serializable
52  {
53      /**
54       * Render the content of an entry.
55       * 
56       * @param context
57       *            the FacesContext
58       * @param writer
59       *            the ResponseWriter
60       * @param schedule
61       *            the Schedule component
62       * @param day the current day           
63       * @param entry
64       *            the entry that should be rendered
65       * @param compact
66       *            is the schedule rendered in a compact mode?
67       * @param selected
68       *            whether or not the entry is currently selected
69       * @throws IOException
70       *             when the output cannot be written
71       */
72      public void renderContent(FacesContext context,
73              ResponseWriter writer, HtmlSchedule schedule, ScheduleDay day,
74              ScheduleEntry entry, boolean compact, boolean selected) throws IOException;
75  
76      /**
77       * Get the color of an entry. The border around the entry will be rendered
78       * in this color. The return value of this method should be a CSS2 color
79       * specification, such as #000000 or rgb(0,0,0). If the return value is
80       * null, then the current theme's default color will be used.
81       * 
82       * @param context
83       *            the FacesContext
84       * @param schedule
85       *            the Schedule component
86       * @param entry
87       *            the entry
88       * @param selected
89       *            whether or not the entry is currently selected
90       * @return the color
91       */
92      public String getColor(FacesContext context, HtmlSchedule schedule,
93              ScheduleEntry entry, boolean selected);
94  
95      /**
96       * Render the tooltip of a ScheduleEntry. This method will only be called if
97       * the schedule's tooltip property is set to 'true'.
98       * 
99       * @param context
100      *            the FacesContext
101      * @param writer
102      *            the ResponseWriter
103      * @param schedule
104      *            the Schedule component
105      * @param entry
106      *            the entry
107      * @param selected
108      *            whether or not the entry is currently selected
109      * @throws IOException
110      *             when the output cannot be written
111      */
112     public void renderToolTip(FacesContext context, ResponseWriter writer,
113             HtmlSchedule schedule, ScheduleEntry entry, boolean selected)
114             throws IOException;
115 
116     /**
117      * Get the class for the entry container. Overriding this allows the 
118      * class to vary based on the entry being displayed. 
119      * 
120      * @param schedule
121      *            the Schedule component
122      * @param entry
123      *            the entry
124      */
125     public String getEntryClass(HtmlSchedule schedule, ScheduleEntry entry);
126 }