Home » tomahawk-1.1.6-src » org.apache.myfaces » custom » schedule » [javadoc | source]

    1   /*
    2    * Copyright 2004 The Apache Software Foundation.
    3    *
    4    * Licensed under the Apache License, Version 2.0 (the "License");
    5    * you may not use this file except in compliance with the License.
    6    * You may obtain a copy of the License at
    7    *
    8    *      http://www.apache.org/licenses/LICENSE-2.0
    9    *
   10    * Unless required by applicable law or agreed to in writing, software
   11    * distributed under the License is distributed on an "AS IS" BASIS,
   12    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   13    * See the License for the specific language governing permissions and
   14    * limitations under the License.
   15    */
   16   
   17   package org.apache.myfaces.custom.schedule;
   18   
   19   import javax.faces.application.Application;
   20   import javax.faces.component.UIComponent;
   21   import javax.faces.context.FacesContext;
   22   import javax.faces.webapp.UIComponentTag;
   23   
   24   /**
   25    * <p>
   26    * JSP tag for the UIPlanner component
   27    * </p>
   28    *
   29    * @author Jurgen Lust (latest modification by $Author$)
   30    * @version $Revision$
   31    */
   32   public class PlannerTag extends UIComponentTag
   33   {
   34       //~ Instance fields --------------------------------------------------------
   35   
   36       private String gutterWidthInPixels;
   37       private String headerDateFormat;
   38       private String legend;
   39       private String rendered;
   40       private String theme;
   41       private String tooltip;
   42       private String value;
   43       private String visibleEndHour;
   44       private String visibleStartHour;
   45       private String workingEndHour;
   46       private String workingStartHour;
   47   
   48       //~ Methods ----------------------------------------------------------------
   49   
   50       /**
   51        * @see javax.faces.webapp.UIComponentTag#getComponentType()
   52        */
   53       public String getComponentType()
   54       {
   55           return HtmlPlanner.COMPONENT_TYPE;
   56       }
   57   
   58       /**
   59        * <p>
   60        * The width of the gutter in pixels
   61        * </p>
   62        *
   63        * @param gutterWidthInPixels The gutterWidthInPixels to set.
   64        */
   65       public void setGutterWidthInPixels(String gutterWidthInPixels)
   66       {
   67           this.gutterWidthInPixels = gutterWidthInPixels;
   68       }
   69   
   70       /**
   71        * <p>
   72        * The width of the gutter in pixels
   73        * </p>
   74        *
   75        * @return Returns the gutterWidthInPixels.
   76        */
   77       public String getGutterWidthInPixels()
   78       {
   79           return gutterWidthInPixels;
   80       }
   81   
   82       /**
   83        * <p>
   84        * The dateformat used in the header
   85        * </p>
   86        *
   87        * @param headerDateFormat The headerDateFormat to set.
   88        */
   89       public void setHeaderDateFormat(String headerDateFormat)
   90       {
   91           this.headerDateFormat = headerDateFormat;
   92       }
   93   
   94       /**
   95        * <p>
   96        * The dateformat used in the header
   97        * </p>
   98        *
   99        * @return Returns the headerDateFormat.
  100        */
  101       public String getHeaderDateFormat()
  102       {
  103           return headerDateFormat;
  104       }
  105   
  106       /**
  107        * <p>
  108        * Should a legend be displayed?
  109        * </p>
  110        *
  111        * @param legend The legend to set.
  112        */
  113       public void setLegend(String legend)
  114       {
  115           this.legend = legend;
  116       }
  117   
  118       /**
  119        * <p>
  120        * Should a legend be displayed?
  121        * </p>
  122        *
  123        * @return Returns the legend.
  124        */
  125       public String getLegend()
  126       {
  127           return legend;
  128       }
  129   
  130       /**
  131        * <p>
  132        * Should this component be rendered?
  133        * </p>
  134        *
  135        * @param rendered The rendered to set.
  136        */
  137       public void setRendered(String rendered)
  138       {
  139           this.rendered = rendered;
  140       }
  141   
  142       /**
  143        * <p>
  144        * Should this component be rendered?
  145        * </p>
  146        *
  147        * @return Returns the rendered.
  148        */
  149       public String getRendered()
  150       {
  151           return rendered;
  152       }
  153   
  154       /**
  155        * @see javax.faces.webapp.UIComponentTag#getRendererType()
  156        */
  157       public String getRendererType()
  158       {
  159           return UIPlanner.DEFAULT_RENDERER_TYPE;
  160       }
  161   
  162       /**
  163        * <p>
  164        * The theme of the planner component. This is the name of the
  165        * CSS file that should be loaded when rendering the planner.
  166        * Possible values are 'default', 'outlookxp', 'outlook2003',
  167        * 'evolution'.
  168        * </p>
  169        * 
  170        * @param theme The theme to set.
  171        */
  172       public void setTheme(String theme)
  173       {
  174           this.theme = theme;
  175       }
  176   
  177       /**
  178        * <p>
  179        * The theme of the planner component. This is the name of the
  180        * CSS file that should be loaded when rendering the planner.
  181        * Possible values are 'default', 'outlookxp', 'outlook2003',
  182        * 'evolution'.
  183        * </p>
  184        * 
  185        * @return Returns the theme.
  186        */
  187       public String getTheme()
  188       {
  189           return theme;
  190       }
  191   
  192       /**
  193        * <p>
  194        * Should tooltips be displayed?
  195        * </p>
  196        *
  197        * @param tooltip The tooltip to set.
  198        */
  199       public void setTooltip(String tooltip)
  200       {
  201           this.tooltip = tooltip;
  202       }
  203   
  204       /**
  205        * <p>
  206        * Should tooltips be displayed?
  207        * </p>
  208        *
  209        * @return Returns the tooltip.
  210        */
  211       public String getTooltip()
  212       {
  213           return tooltip;
  214       }
  215   
  216       /**
  217        * <p>
  218        * The value of the Planner component
  219        * </p>
  220        *
  221        * @param value The value to set.
  222        */
  223       public void setValue(String value)
  224       {
  225           this.value = value;
  226       }
  227   
  228       /**
  229        * <p>
  230        * The value of the Planner component
  231        * </p>
  232        *
  233        * @return Returns the value.
  234        */
  235       public String getValue()
  236       {
  237           return value;
  238       }
  239   
  240       /**
  241        * <p>
  242        * The visible end hour of the planner component
  243        * </p>
  244        *
  245        * @param visibleEndHour The visibleEndHour to set.
  246        */
  247       public void setVisibleEndHour(String visibleEndHour)
  248       {
  249           this.visibleEndHour = visibleEndHour;
  250       }
  251   
  252       /**
  253        * <p>
  254        * The visible end hour of the planner component
  255        * </p>
  256        *
  257        * @return Returns the visibleEndHour.
  258        */
  259       public String getVisibleEndHour()
  260       {
  261           return visibleEndHour;
  262       }
  263   
  264       /**
  265        * <p>
  266        * The visible start hour of the planner component
  267        * </p>
  268        *
  269        * @param visibleStartHour The visibleStartHour to set.
  270        */
  271       public void setVisibleStartHour(String visibleStartHour)
  272       {
  273           this.visibleStartHour = visibleStartHour;
  274       }
  275   
  276       /**
  277        * <p>
  278        * The visible start hour of the planner component
  279        * </p>
  280        *
  281        * @return Returns the visibleStartHour.
  282        */
  283       public String getVisibleStartHour()
  284       {
  285           return visibleStartHour;
  286       }
  287   
  288       /**
  289        * <p>
  290        * The working end hour of the planner component
  291        * </p>
  292        *
  293        * @param workingEndHour The workingEndHour to set.
  294        */
  295       public void setWorkingEndHour(String workingEndHour)
  296       {
  297           this.workingEndHour = workingEndHour;
  298       }
  299   
  300       /**
  301        * <p>
  302        * The working end hour of the planner component
  303        * </p>
  304        *
  305        * @return Returns the workingEndHour.
  306        */
  307       public String getWorkingEndHour()
  308       {
  309           return workingEndHour;
  310       }
  311   
  312       /**
  313        * <p>
  314        * The working start hour of the planner component
  315        * </p>
  316        *
  317        * @param workingStartHour The workingStartHour to set.
  318        */
  319       public void setWorkingStartHour(String workingStartHour)
  320       {
  321           this.workingStartHour = workingStartHour;
  322       }
  323   
  324       /**
  325        * <p>
  326        * The working start hour of the planner component
  327        * </p>
  328        *
  329        * @return Returns the workingStartHour.
  330        */
  331       public String getWorkingStartHour()
  332       {
  333           return workingStartHour;
  334       }
  335   
  336       /**
  337        * @see javax.servlet.jsp.tagext.Tag#release()
  338        */
  339       public void release()
  340       {
  341           super.release();
  342           visibleStartHour = null;
  343           visibleEndHour = null;
  344           workingStartHour = null;
  345           workingEndHour = null;
  346           headerDateFormat = null;
  347           value = null;
  348           theme = null;
  349           tooltip = null;
  350           legend = null;
  351           gutterWidthInPixels = null;
  352           rendered = null;
  353       }
  354   
  355       /**
  356        * @see javax.faces.webapp.UIComponentTag#setProperties(javax.faces.component.UIComponent)
  357        */
  358       protected void setProperties(UIComponent component)
  359       {
  360           super.setProperties(component);
  361   
  362           HtmlPlanner planner = (HtmlPlanner) component;
  363           FacesContext context = FacesContext.getCurrentInstance();
  364           Application app = context.getApplication();
  365   
  366           if (rendered != null)
  367           {
  368               if (isValueReference(rendered))
  369               {
  370                   planner.setValueBinding("rendered", app
  371                           .createValueBinding(rendered));
  372               }
  373               else
  374               {
  375                   planner.setRendered(Boolean.valueOf(rendered).booleanValue());
  376               }
  377           }
  378   
  379           if (visibleStartHour != null)
  380           {
  381               if (isValueReference(visibleStartHour))
  382               {
  383                   planner.setValueBinding("visibleStartHour", app
  384                           .createValueBinding(visibleStartHour));
  385               }
  386               else
  387               {
  388                   planner.setVisibleStartHour(new Integer(visibleStartHour)
  389                           .intValue());
  390               }
  391           }
  392   
  393           if (visibleEndHour != null)
  394           {
  395               if (isValueReference(visibleEndHour))
  396               {
  397                   planner.setValueBinding("visibleEndHour", app
  398                           .createValueBinding(visibleEndHour));
  399               }
  400               else
  401               {
  402                   planner.setVisibleEndHour(new Integer(visibleEndHour)
  403                           .intValue());
  404               }
  405           }
  406   
  407           if (workingStartHour != null)
  408           {
  409               if (isValueReference(workingStartHour))
  410               {
  411                   planner.setValueBinding("workingStartHour", app
  412                           .createValueBinding(workingStartHour));
  413               }
  414               else
  415               {
  416                   planner.setWorkingStartHour(new Integer(workingStartHour)
  417                           .intValue());
  418               }
  419           }
  420   
  421           if (workingEndHour != null)
  422           {
  423               if (isValueReference(workingEndHour))
  424               {
  425                   planner.setValueBinding("workingEndHour", app
  426                           .createValueBinding(workingEndHour));
  427               }
  428               else
  429               {
  430                   planner.setWorkingEndHour(new Integer(workingEndHour)
  431                           .intValue());
  432               }
  433           }
  434   
  435           if ((value != null) && isValueReference(value))
  436           {
  437               planner.setValueBinding("value", app.createValueBinding(value));
  438           }
  439           else
  440           {
  441               throw new IllegalArgumentException(
  442                       "The value property must be a value binding expression that points to a PlannerModel object.");
  443           }
  444   
  445           addAttribute(app, planner, "headerDateFormat", headerDateFormat);
  446           addAttribute(app, planner, "theme", theme);
  447           addAttribute(app, planner, "tooltip", tooltip);
  448           addAttribute(app, planner, "legend", legend);
  449           addAttribute(app, planner, "gutterWidthInPixels", gutterWidthInPixels);
  450       }
  451   
  452       private void addAttribute(Application app, UIComponent component,
  453               String key, String value)
  454       {
  455           if ((key != null) && (value != null))
  456           {
  457               if (isValueReference(value))
  458               {
  459                   component.setValueBinding(key, app
  460                           .createValueBinding(value));
  461               }
  462               else
  463               {
  464                   component.getAttributes().put(key, value);
  465               }
  466           }
  467       }
  468   }
  469   //The End

Home » tomahawk-1.1.6-src » org.apache.myfaces » custom » schedule » [javadoc | source]