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/13 17:33:25 UTC
svn commit: r216175 [1/4] - in /myfaces: build/trunk/
examples/trunk/sandbox/ examples/trunk/sandbox/WEB-INF/
examples/trunk/sandbox/src/java/org/apache/myfaces/examples/schedule/
sandbox/trunk/conf/ sandbox/trunk/src/java/org/apache/myfaces/custom/sch...
Author: mmarinschek
Date: Wed Jul 13 08:33:22 2005
New Revision: 216175
URL: http://svn.apache.org/viewcvs?rev=216175&view=rev
Log:
patches by bruno aranda and jurgen lust for the new x:planner component. this is gonna be great!
Added:
myfaces/examples/trunk/sandbox/schedule.jsp
myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/schedule/
myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleScheduleBackingBean.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/HtmlPlanner.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/HtmlPlanner.xml
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/HtmlSchedule.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/HtmlSchedule.xml
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/UIPlanner.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/UISchedule.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/AbstractScheduleModel.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/Day.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/DefaultScheduleEntry.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/PlannerEntity.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/PlannerModel.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/ScheduleDay.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/ScheduleEntry.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/ScheduleModel.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/SimpleScheduleModel.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/renderer/
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/ScheduleCompactMonthRenderer.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/renderer/ScheduleCompactWeekRenderer.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/renderer/ScheduleDelegatingRenderer.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/
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/resource/css/
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/resource/css/schedule.css
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/util/
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/util/ScheduleEntryComparator.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/util/ScheduleUtil.java
myfaces/sandbox/trunk/tld/entities/html_planner_attributes.xml
myfaces/sandbox/trunk/tld/entities/html_schedule_attributes.xml
myfaces/sandbox/trunk/tld/entities/ui_schedule_attributes.xml
Modified:
myfaces/build/trunk/build.xml
myfaces/examples/trunk/sandbox/WEB-INF/examples-config.xml
myfaces/examples/trunk/sandbox/home.jsp
myfaces/sandbox/trunk/conf/faces-config.xml
myfaces/sandbox/trunk/tld/myfaces_sandbox.tld
Modified: myfaces/build/trunk/build.xml
URL: http://svn.apache.org/viewcvs/myfaces/build/trunk/build.xml?rev=216175&r1=216174&r2=216175&view=diff
==============================================================================
--- myfaces/build/trunk/build.xml (original)
+++ myfaces/build/trunk/build.xml Wed Jul 13 08:33:22 2005
@@ -237,6 +237,7 @@
<pathelement location="${jsf-api.jar}"/>
<pathelement location="${jsf-impl.jar}"/>
<pathelement location="${tomahawk.jar}"/>
+ <pathelement location="${sandbox.jar}"/>
<!-- this is harmless if not used -->
<!--
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=216175&r1=216174&r2=216175&view=diff
==============================================================================
--- myfaces/examples/trunk/sandbox/WEB-INF/examples-config.xml (original)
+++ myfaces/examples/trunk/sandbox/WEB-INF/examples-config.xml Wed Jul 13 08:33:22 2005
@@ -238,4 +238,13 @@
</map-entries>
</managed-bean>
+
+ <!-- Managed Beans for schedule.jsp -->
+
+ <managed-bean>
+ <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-bean>
+
</faces-config>
Modified: myfaces/examples/trunk/sandbox/home.jsp
URL: http://svn.apache.org/viewcvs/myfaces/examples/trunk/sandbox/home.jsp?rev=216175&r1=216174&r2=216175&view=diff
==============================================================================
--- myfaces/examples/trunk/sandbox/home.jsp (original)
+++ myfaces/examples/trunk/sandbox/home.jsp Wed Jul 13 08:33:22 2005
@@ -22,7 +22,8 @@
<br/>
<h:outputLink value="inputSuggest.jsf" ><f:verbatim>Input Suggest</f:verbatim></h:outputLink> <br/>
+ <h:outputLink value="schedule.jsf" ><f:verbatim>Schedule</f:verbatim></h:outputLink> <br/>
</f:view>
-</html>
\ No newline at end of file
+</html>
Added: myfaces/examples/trunk/sandbox/schedule.jsp
URL: http://svn.apache.org/viewcvs/myfaces/examples/trunk/sandbox/schedule.jsp?rev=216175&view=auto
==============================================================================
--- myfaces/examples/trunk/sandbox/schedule.jsp (added)
+++ myfaces/examples/trunk/sandbox/schedule.jsp Wed Jul 13 08:33:22 2005
@@ -0,0 +1,53 @@
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://myfaces.apache.org/sandbox" prefix="x"%>
+
+<!--
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//-->
+<html>
+
+ <%@include file="inc/head.inc" %>
+
+ <body>
+ <f:view>
+ <h:form>
+ <br/>
+ <h:panelGroup>
+ <h:outputLabel for="modeInput">
+ <h:outputText value="mode: " />
+ </h:outputLabel>
+ <h:selectOneRadio id="modeInput" layout="lineDirection"
+ binding="#{simpleSchedule.modeInput}" immediate="true"
+ valueChangeListener="#{simpleSchedule.modeChanged}"
+ onchange="this.form.submit();" value="#{simpleSchedule.mode}">
+ <f:selectItems id="modeItems" value="#{simpleSchedule.modeItems}" />
+ </h:selectOneRadio>
+
+ </h:panelGroup>
+
+ <x:schedule value="#{simpleSchedule.model}" id="schedule1"
+ rendered="true" visibleEndHour="18" visibleStartHour="8"
+ workingEndHour="17" workingStartHour="9" readonly="false"
+ actionListener="#{simpleSchedule.actionPerformed}" />
+ </h:form>
+ </f:view>
+ </body>
+
+ <%@include file="inc/page_footer.jsp" %>
+
+</html>
Added: 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=216175&view=auto
==============================================================================
--- myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleScheduleBackingBean.java (added)
+++ myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleScheduleBackingBean.java Wed Jul 13 08:33:22 2005
@@ -0,0 +1,254 @@
+package org.apache.myfaces.examples.schedule;
+
+import org.apache.myfaces.custom.calendar.HtmlInputCalendar;
+import org.apache.myfaces.custom.schedule.model.DefaultScheduleEntry;
+import org.apache.myfaces.custom.schedule.model.ScheduleModel;
+import org.apache.myfaces.custom.schedule.model.SimpleScheduleModel;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+import javax.faces.component.html.HtmlSelectOneRadio;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ValueChangeEvent;
+import javax.faces.model.SelectItem;
+
+/**
+* This is an extremely simple demo of the Schedule component. The entries are
+* actually hardcoded. A real application would typically use a custom implementation
+* of the SimpleScheduleModel.
+*/
+public class SimpleScheduleBackingBean {
+
+ //~ Instance fields --------------------------------------------------------
+
+ private Date date = new Date();
+ private HtmlInputCalendar dateInput;
+ private HtmlSelectOneRadio modeInput;
+ private Integer mode = new Integer(ScheduleModel.WORKWEEK);
+ private SimpleScheduleModel model;
+
+ //~ Constructors -----------------------------------------------------------
+
+ /**
+ * Creates a new SimpleScheduleBackingBean object.
+ */
+ public SimpleScheduleBackingBean() {
+ super();
+ initModel();
+ }
+
+ //~ Methods ----------------------------------------------------------------
+
+ /**
+ * @param date The date to set.
+ */
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+ /**
+ * @return Returns the date.
+ */
+ public Date getDate() {
+ return date;
+ }
+
+ /**
+ * @param dateInput The dateInput to set.
+ */
+ public void setDateInput(HtmlInputCalendar dateInput) {
+ this.dateInput = dateInput;
+ }
+
+ /**
+ * @return Returns the dateInput.
+ */
+ public HtmlInputCalendar getDateInput() {
+ return dateInput;
+ }
+
+ /**
+ * @param mode The mode to set.
+ */
+ public void setMode(Integer mode) {
+ this.mode = mode;
+ }
+
+ /**
+ * @return Returns the mode.
+ */
+ public Integer getMode() {
+ return mode;
+ }
+
+ /**
+ * @param modeInput The modeInput to set.
+ */
+ public void setModeInput(HtmlSelectOneRadio modeInput) {
+ this.modeInput = modeInput;
+ }
+
+ /**
+ * @return Returns the modeInput.
+ */
+ public HtmlSelectOneRadio getModeInput() {
+ return modeInput;
+ }
+
+ /**
+ * <p>
+ * get the SelectItems for the mode SelectOneRadio
+ * </p>
+ *
+ * @return an ArrayList of SelectItems
+ */
+ public ArrayList getModeItems() {
+ ArrayList items = new ArrayList();
+ items.add(new SelectItem(new Integer(ScheduleModel.DAY), "day"));
+ items.add(
+ new SelectItem(new Integer(ScheduleModel.WORKWEEK), "workweek")
+ );
+ items.add(new SelectItem(new Integer(ScheduleModel.WEEK), "week"));
+ items.add(new SelectItem(new Integer(ScheduleModel.MONTH), "month"));
+
+ return items;
+ }
+
+ /**
+ * @param model The model to set.
+ */
+ public void setModel(SimpleScheduleModel model) {
+ this.model = model;
+ }
+
+ /**
+ * @return Returns the model.
+ */
+ public ScheduleModel getModel() {
+ return model;
+ }
+
+ /**
+ * <p>
+ * a String describing the selected entry on the schedule
+ * </p>
+ *
+ * @return the entry as a string
+ */
+ public String getSelectedEntry() {
+ if ((model == null) || (model.getSelectedEntry() == null)) {
+ return "no entry selected";
+ }
+
+ StringBuffer entry = new StringBuffer();
+ entry.append(model.getSelectedEntry().getTitle());
+ entry.append(": ");
+ entry.append(model.getSelectedEntry().getStartTime());
+ entry.append(" - ");
+ entry.append(model.getSelectedEntry().getEndTime());
+
+ String returnString = entry.toString();
+
+ return returnString;
+ }
+
+ /**
+ * <p>
+ * action listener for the schedule component.
+ * </p>
+ *
+ * @param actionEvent the action event
+ */
+ public void actionPerformed(ActionEvent actionEvent) {
+ }
+
+ /**
+ * <p>
+ * When the date of the calendar component changes, navigate to that date
+ * in the schedule component.
+ * </p>
+ *
+ * @param event the change event
+ */
+ public void dateChanged(ValueChangeEvent event) {
+ this.date = (Date) dateInput.getValue();
+ model.setSelectedDate(date);
+ model.refresh();
+ }
+
+ /**
+ * <p>
+ * When a different mode is selected, apply this mode to the schedule
+ * component.
+ * </p>
+ *
+ * @param event the change event
+ */
+ public void modeChanged(ValueChangeEvent event) {
+ if (mode == null) {
+ return;
+ }
+
+ this.mode = (Integer) modeInput.getValue();
+ model.setMode(mode.intValue());
+
+ model.refresh();
+ }
+
+ /**
+ * Initialize the demo: We're just adding 3 appointments here, it would
+ * be easy to do this from a form on the page.
+ */
+ private void initModel() {
+ if (model == null) {
+ model = new SimpleScheduleModel();
+ }
+
+ Date today = new Date();
+
+ Calendar cal = GregorianCalendar.getInstance();
+ cal.setTime(new Date());
+ cal.set(Calendar.HOUR_OF_DAY, 11);
+ cal.set(Calendar.MINUTE, 30);
+ cal.set(Calendar.SECOND, 00);
+ cal.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
+
+ DefaultScheduleEntry entry1 = new DefaultScheduleEntry();
+ entry1.setStartTime(cal.getTime());
+ cal.add(Calendar.HOUR_OF_DAY, 2);
+ entry1.setEndTime(cal.getTime());
+ entry1.setId("1");
+ entry1.setTitle("Meeting with portal developers");
+ entry1.setSubtitle("Meeting room 1");
+
+ DefaultScheduleEntry entry2 = new DefaultScheduleEntry();
+ cal.add(Calendar.HOUR_OF_DAY, -1);
+ entry2.setStartTime(cal.getTime());
+ cal.add(Calendar.HOUR, 4);
+ entry2.setEndTime(cal.getTime());
+ entry2.setId("2");
+ entry2.setTitle("work on MyFaces components");
+ entry2.setSubtitle("");
+ entry2.setDescription("I should create a more elaborate demo");
+
+ DefaultScheduleEntry entry3 = new DefaultScheduleEntry();
+ cal.add(Calendar.HOUR_OF_DAY, -48);
+ entry3.setStartTime(cal.getTime());
+ cal.add(Calendar.HOUR_OF_DAY, 48);
+ entry3.setEndTime(cal.getTime());
+ entry3.setId("3");
+ entry3.setTitle("Business trip");
+ entry3.setSubtitle("Paris");
+ entry3.setDescription("Better brush up on my French before I leave...");
+ model.addEntry(entry1);
+ model.addEntry(entry2);
+ model.addEntry(entry3);
+
+ model.setMode(mode.intValue());
+
+ model.setSelectedDate(today);
+ }
+}
Modified: myfaces/sandbox/trunk/conf/faces-config.xml
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/conf/faces-config.xml?rev=216175&r1=216174&r2=216175&view=diff
==============================================================================
--- myfaces/sandbox/trunk/conf/faces-config.xml (original)
+++ myfaces/sandbox/trunk/conf/faces-config.xml Wed Jul 13 08:33:22 2005
@@ -29,6 +29,16 @@
<component-class>org.apache.myfaces.custom.ajaxsuggest.AjaxInputSuggest</component-class>
</component>
+ <component>
+ <component-type>org.apache.myfaces.Planner</component-type>
+ <component-class>org.apache.myfaces.custom.schedule.HtmlPlanner</component-class>
+ </component>
+
+ <component>
+ <component-type>org.apache.myfaces.Schedule</component-type>
+ <component-class>org.apache.myfaces.custom.schedule.HtmlSchedule</component-class>
+ </component>
+
<!-- sandbox renderkit -->
<render-kit>
@@ -48,6 +58,18 @@
<component-family>javax.faces.Input</component-family>
<renderer-type>org.apache.myfaces.AjaxInputSuggest</renderer-type>
<renderer-class>org.apache.myfaces.custom.ajaxsuggest.AjaxInputSuggestRenderer</renderer-class>
+ </renderer>
+
+ <renderer>
+ <component-family>javax.faces.Panel</component-family>
+ <renderer-type>org.apache.myfaces.Planner</renderer-type>
+ <renderer-class>org.apache.myfaces.custom.schedule.renderer.PlannerRenderer</renderer-class>
+ </renderer>
+
+ <renderer>
+ <component-family>javax.faces.Panel</component-family>
+ <renderer-type>org.apache.myfaces.Schedule</renderer-type>
+ <renderer-class>org.apache.myfaces.custom.schedule.renderer.ScheduleDelegatingRenderer</renderer-class>
</renderer>
<!--custom validators -->
Added: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/HtmlPlanner.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/HtmlPlanner.java?rev=216175&view=auto
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/HtmlPlanner.java (added)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/HtmlPlanner.java Wed Jul 13 08:33:22 2005
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.myfaces.custom.schedule;
+
+
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+
+import org.apache.myfaces.component.UserRoleAware;
+
+
+/**
+ *
+ * @author Bruno Aranda (latest modification by $Author$)
+ * @version $Revision$
+ */
+public class HtmlPlanner
+ extends UIPlanner
+ implements UserRoleAware
+ {
+
+// ------------------ GENERATED CODE BEGIN (do not modify!) --------------------
+
+ public static final String COMPONENT_TYPE = "org.apache.myfaces.Planner";
+ public static final String COMPONENT_FAMILY = "javax.faces.Panel";
+ private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.Planner";
+
+ private String _enabledOnUserRole = null;
+ private String _visibleOnUserRole = null;
+
+ public HtmlPlanner()
+ {
+ setRendererType(DEFAULT_RENDERER_TYPE);
+ }
+
+ public String getFamily()
+ {
+ return COMPONENT_FAMILY;
+ }
+
+ public void setEnabledOnUserRole(String enabledOnUserRole)
+ {
+ _enabledOnUserRole = enabledOnUserRole;
+ }
+
+ public String getEnabledOnUserRole()
+ {
+ if (_enabledOnUserRole != null) return _enabledOnUserRole;
+ ValueBinding vb = getValueBinding("enabledOnUserRole");
+ return vb != null ? (String)vb.getValue(getFacesContext()) : null;
+ }
+
+ public void setVisibleOnUserRole(String visibleOnUserRole)
+ {
+ _visibleOnUserRole = visibleOnUserRole;
+ }
+
+ public String getVisibleOnUserRole()
+ {
+ if (_visibleOnUserRole != null) return _visibleOnUserRole;
+ ValueBinding vb = getValueBinding("visibleOnUserRole");
+ return vb != null ? (String)vb.getValue(getFacesContext()) : null;
+ }
+
+
+
+ public Object saveState(FacesContext context)
+ {
+ Object values[] = new Object[3];
+ values[0] = super.saveState(context);
+ values[1] = _enabledOnUserRole;
+ values[2] = _visibleOnUserRole;
+ return ((Object) (values));
+ }
+
+ public void restoreState(FacesContext context, Object state)
+ {
+ Object values[] = (Object[])state;
+ super.restoreState(context, values[0]);
+ _enabledOnUserRole = (String)values[1];
+ _visibleOnUserRole = (String)values[2];
+ }
+// ------------------ GENERATED CODE END ---------------------------------------
+
+}
+//The End
Added: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/HtmlPlanner.xml
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/HtmlPlanner.xml?rev=216175&view=auto
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/HtmlPlanner.xml (added)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/HtmlPlanner.xml Wed Jul 13 08:33:22 2005
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE component PUBLIC
+ "-//MyFaces//DTD MyFaces component def 1.0//EN"
+ "http://myfaces.apache.org/dtd/Component.dtd">
+<component>
+ <component-class>org.apache.myfaces.custom.schedule.HtmlPlanner</component-class>
+ <base-class>org.apache.myfaces.custom.schedule.UIPlanner</base-class>
+ <component-type>org.apache.myfaces.Planner</component-type>
+ <component-family>javax.faces.Panel</component-family>
+ <renderer-type>org.apache.myfaces.Planner</renderer-type>
+ <field>
+ <name>enabledOnUserRole</name>
+ <type>java.lang.String</type>
+ </field>
+ <field>
+ <name>visibleOnUserRole</name>
+ <type>java.lang.String</type>
+ </field>
+</component>
Added: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/HtmlSchedule.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/HtmlSchedule.java?rev=216175&view=auto
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/HtmlSchedule.java (added)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/HtmlSchedule.java Wed Jul 13 08:33:22 2005
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.myfaces.custom.schedule;
+
+
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+
+import org.apache.myfaces.component.UserRoleAware;
+
+
+/**
+ *
+ * @author Bruno Aranda (latest modification by $Author$)
+ * @version $Revision$
+ */
+public class HtmlSchedule
+ extends UISchedule implements UserRoleAware
+{
+
+// ------------------ GENERATED CODE BEGIN (do not modify!) --------------------
+
+ public static final String COMPONENT_TYPE = "org.apache.myfaces.Schedule";
+ public static final String COMPONENT_FAMILY = "javax.faces.Panel";
+ private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.Schedule";
+
+ private String _enabledOnUserRole = null;
+ private String _visibleOnUserRole = null;
+
+ public HtmlSchedule()
+ {
+ setRendererType(DEFAULT_RENDERER_TYPE);
+ }
+
+ public String getFamily()
+ {
+ return COMPONENT_FAMILY;
+ }
+
+ public void setEnabledOnUserRole(String enabledOnUserRole)
+ {
+ _enabledOnUserRole = enabledOnUserRole;
+ }
+
+ public String getEnabledOnUserRole()
+ {
+ if (_enabledOnUserRole != null) return _enabledOnUserRole;
+ ValueBinding vb = getValueBinding("enabledOnUserRole");
+ return vb != null ? (String)vb.getValue(getFacesContext()) : null;
+ }
+
+ public void setVisibleOnUserRole(String visibleOnUserRole)
+ {
+ _visibleOnUserRole = visibleOnUserRole;
+ }
+
+ public String getVisibleOnUserRole()
+ {
+ if (_visibleOnUserRole != null) return _visibleOnUserRole;
+ ValueBinding vb = getValueBinding("visibleOnUserRole");
+ return vb != null ? (String)vb.getValue(getFacesContext()) : null;
+ }
+
+
+
+ public Object saveState(FacesContext context)
+ {
+ Object values[] = new Object[3];
+ values[0] = super.saveState(context);
+ values[1] = _enabledOnUserRole;
+ values[2] = _visibleOnUserRole;
+ return ((Object) (values));
+ }
+
+ public void restoreState(FacesContext context, Object state)
+ {
+ Object values[] = (Object[])state;
+ super.restoreState(context, values[0]);
+ _enabledOnUserRole = (String)values[1];
+ _visibleOnUserRole = (String)values[2];
+ }
+// ------------------ GENERATED CODE END ---------------------------------------
+
+}
+//The End
Added: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/HtmlSchedule.xml
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/HtmlSchedule.xml?rev=216175&view=auto
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/HtmlSchedule.xml (added)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/HtmlSchedule.xml Wed Jul 13 08:33:22 2005
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE component PUBLIC
+ "-//MyFaces//DTD MyFaces component def 1.0//EN"
+ "http://myfaces.apache.org/dtd/Component.dtd">
+<component>
+ <component-class>org.apache.myfaces.custom.schedule.HtmlSchedule</component-class>
+ <base-class>org.apache.myfaces.custom.schedule.UISchedule</base-class>
+ <component-type>org.apache.myfaces.Schedule</component-type>
+ <component-family>javax.faces.Panel</component-family>
+ <renderer-type>org.apache.myfaces.Schedule</renderer-type>
+ <field>
+ <name>enabledOnUserRole</name>
+ <type>java.lang.String</type>
+ </field>
+ <field>
+ <name>visibleOnUserRole</name>
+ <type>java.lang.String</type>
+ </field>
+</component>
Added: 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=216175&view=auto
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/PlannerTag.java (added)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/PlannerTag.java Wed Jul 13 08:33:22 2005
@@ -0,0 +1,432 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+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
+ * </p>
+ *
+ * @author Jurgen Lust (latest modification by $Author$)
+ * @version $Revision$
+ */
+public class PlannerTag
+ extends UIComponentTag
+{
+ //~ Instance fields --------------------------------------------------------
+
+ private String gutterWidthInPixels;
+ private String headerDateFormat;
+ private String legend;
+ private String rendered;
+ private String tooltip;
+ private String value;
+ private String visibleEndHour;
+ private String visibleStartHour;
+ private String workingEndHour;
+ private String workingStartHour;
+
+ //~ Methods ----------------------------------------------------------------
+
+ /**
+ * @see javax.faces.webapp.UIComponentTag#getComponentType()
+ */
+ public String getComponentType()
+ {
+ return HtmlPlanner.COMPONENT_TYPE;
+ }
+
+ /**
+ * <p>
+ * The width of the gutter in pixels
+ * </p>
+ *
+ * @param gutterWidthInPixels The gutterWidthInPixels to set.
+ */
+ public void setGutterWidthInPixels(String gutterWidthInPixels)
+ {
+ this.gutterWidthInPixels = gutterWidthInPixels;
+ }
+
+ /**
+ * <p>
+ * The width of the gutter in pixels
+ * </p>
+ *
+ * @return Returns the gutterWidthInPixels.
+ */
+ public String getGutterWidthInPixels()
+ {
+ return gutterWidthInPixels;
+ }
+
+ /**
+ * <p>
+ * The dateformat used in the header
+ * </p>
+ *
+ * @param headerDateFormat The headerDateFormat to set.
+ */
+ public void setHeaderDateFormat(String headerDateFormat)
+ {
+ this.headerDateFormat = headerDateFormat;
+ }
+
+ /**
+ * <p>
+ * The dateformat used in the header
+ * </p>
+ *
+ * @return Returns the headerDateFormat.
+ */
+ public String getHeaderDateFormat()
+ {
+ return headerDateFormat;
+ }
+
+ /**
+ * <p>
+ * Should a legend be displayed?
+ * </p>
+ *
+ * @param legend The legend to set.
+ */
+ public void setLegend(String legend)
+ {
+ this.legend = legend;
+ }
+
+ /**
+ * <p>
+ * Should a legend be displayed?
+ * </p>
+ *
+ * @return Returns the legend.
+ */
+ public String getLegend()
+ {
+ return legend;
+ }
+
+ /**
+ * <p>
+ * Should this component be rendered?
+ * </p>
+ *
+ * @param rendered The rendered to set.
+ */
+ public void setRendered(String rendered)
+ {
+ this.rendered = rendered;
+ }
+
+ /**
+ * <p>
+ * Should this component be rendered?
+ * </p>
+ *
+ * @return Returns the rendered.
+ */
+ public String getRendered()
+ {
+ return rendered;
+ }
+
+ /**
+ * @see javax.faces.webapp.UIComponentTag#getRendererType()
+ */
+ public String getRendererType()
+ {
+ return UIPlanner.DEFAULT_RENDERER_TYPE;
+ }
+
+ /**
+ * <p>
+ * Should tooltips be displayed?
+ * </p>
+ *
+ * @param tooltip The tooltip to set.
+ */
+ public void setTooltip(String tooltip)
+ {
+ this.tooltip = tooltip;
+ }
+
+ /**
+ * <p>
+ * Should tooltips be displayed?
+ * </p>
+ *
+ * @return Returns the tooltip.
+ */
+ public String getTooltip()
+ {
+ return tooltip;
+ }
+
+ /**
+ * <p>
+ * The value of the Planner component
+ * </p>
+ *
+ * @param value The value to set.
+ */
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+
+ /**
+ * <p>
+ * The value of the Planner component
+ * </p>
+ *
+ * @return Returns the value.
+ */
+ public String getValue()
+ {
+ return value;
+ }
+
+ /**
+ * <p>
+ * The visible end hour of the planner component
+ * </p>
+ *
+ * @param visibleEndHour The visibleEndHour to set.
+ */
+ public void setVisibleEndHour(String visibleEndHour)
+ {
+ this.visibleEndHour = visibleEndHour;
+ }
+
+ /**
+ * <p>
+ * The visible end hour of the planner component
+ * </p>
+ *
+ * @return Returns the visibleEndHour.
+ */
+ public String getVisibleEndHour()
+ {
+ return visibleEndHour;
+ }
+
+ /**
+ * <p>
+ * The visible start hour of the planner component
+ * </p>
+ *
+ * @param visibleStartHour The visibleStartHour to set.
+ */
+ public void setVisibleStartHour(String visibleStartHour)
+ {
+ this.visibleStartHour = visibleStartHour;
+ }
+
+ /**
+ * <p>
+ * The visible start hour of the planner component
+ * </p>
+ *
+ * @return Returns the visibleStartHour.
+ */
+ public String getVisibleStartHour()
+ {
+ return visibleStartHour;
+ }
+
+ /**
+ * <p>
+ * The working end hour of the planner component
+ * </p>
+ *
+ * @param workingEndHour The workingEndHour to set.
+ */
+ public void setWorkingEndHour(String workingEndHour)
+ {
+ this.workingEndHour = workingEndHour;
+ }
+
+ /**
+ * <p>
+ * The working end hour of the planner component
+ * </p>
+ *
+ * @return Returns the workingEndHour.
+ */
+ public String getWorkingEndHour()
+ {
+ return workingEndHour;
+ }
+
+ /**
+ * <p>
+ * The working start hour of the planner component
+ * </p>
+ *
+ * @param workingStartHour The workingStartHour to set.
+ */
+ public void setWorkingStartHour(String workingStartHour)
+ {
+ this.workingStartHour = workingStartHour;
+ }
+
+ /**
+ * <p>
+ * The working start hour of the planner component
+ * </p>
+ *
+ * @return Returns the workingStartHour.
+ */
+ public String getWorkingStartHour()
+ {
+ return workingStartHour;
+ }
+
+ /**
+ * @see javax.servlet.jsp.tagext.Tag#release()
+ */
+ public void release()
+ {
+ super.release();
+ visibleStartHour = null;
+ visibleEndHour = null;
+ workingStartHour = null;
+ workingEndHour = null;
+ headerDateFormat = null;
+ value = null;
+ tooltip = null;
+ legend = null;
+ gutterWidthInPixels = null;
+ rendered = null;
+ }
+
+ /**
+ * @see javax.faces.webapp.UIComponentTag#setProperties(javax.faces.component.UIComponent)
+ */
+ protected void setProperties(UIComponent component)
+ {
+ super.setProperties(component);
+
+ HtmlPlanner planner = (HtmlPlanner) component;
+ FacesContext context = FacesContext.getCurrentInstance();
+ Application app = context.getApplication();
+
+ 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 (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 (workingEndHour != null) {
+ if (isValueReference(workingEndHour)) {
+ planner.setValueBinding(
+ "workingEndHour", app.createValueBinding(workingEndHour)
+ );
+ } else {
+ planner.setWorkingEndHour(
+ new Integer(workingEndHour).intValue()
+ );
+ }
+ }
+
+ if ((value != null) && isValueReference(value)) {
+ planner.setValueBinding("value", app.createValueBinding(value));
+ } else {
+ throw new IllegalArgumentException(
+ "The value property must be a value binding expression that points to a PlannerModel object."
+ );
+ }
+
+ addAttribute(app, planner, "headerDateFormat", headerDateFormat);
+ 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 {
+ component.getAttributes().put(key, value);
+ }
+ }
+ }
+}
+//The End
Added: 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=216175&view=auto
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/ScheduleTag.java (added)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/ScheduleTag.java Wed Jul 13 08:33:22 2005
@@ -0,0 +1,596 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.myfaces.custom.schedule;
+
+
+import javax.faces.application.Application;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
+import javax.faces.event.ActionEvent;
+import javax.faces.webapp.UIComponentTag;
+
+
+
+/**
+ * <p>
+ * JSP tag for the schedule component
+ * </p>
+ *
+ * @author Jurgen Lust (latest modification by $Author$)
+ * @version $Revision$
+ */
+public class ScheduleTag
+ extends UIComponentTag
+{
+ //~ Instance fields --------------------------------------------------------
+
+ private String action;
+ private String actionListener;
+ private String compactMonthRowHeight;
+ private String compactWeekRowHeight;
+ private String headerDateFormat;
+ private String immediate;
+ private String readonly;
+ private String rendered;
+ private String tooltip;
+ private String value;
+ private String visibleEndHour;
+ private String visibleStartHour;
+ private String workingEndHour;
+ private String workingStartHour;
+
+ //~ Methods ----------------------------------------------------------------
+
+ /**
+ * <p>
+ * The action of the JSF component
+ * </p>
+ *
+ * @param action The action to set.
+ */
+ public void setAction(String action)
+ {
+ this.action = action;
+ }
+
+ /**
+ * <p>
+ * The action of the JSF component
+ * </p>
+ *
+ * @return Returns the action.
+ */
+ public String getAction()
+ {
+ return action;
+ }
+
+ /**
+ * <p>
+ * The actionlistener of the JSF component
+ * </p>
+ *
+ * @param actionListener The actionListener to set.
+ */
+ public void setActionListener(String actionListener)
+ {
+ this.actionListener = actionListener;
+ }
+
+ /**
+ * <p>
+ * The actionlistener of the JSF component
+ * </p>
+ *
+ * @return Returns the actionListener.
+ */
+ public String getActionListener()
+ {
+ return actionListener;
+ }
+
+ /**
+ * <p>
+ * The height in pixels of a cell in the compact month view
+ * </p>
+ *
+ * @param compactMonthRowHeight The compactMonthRowHeight to set.
+ */
+ public void setCompactMonthRowHeight(String compactMonthRowHeight)
+ {
+ this.compactMonthRowHeight = compactMonthRowHeight;
+ }
+
+ /**
+ * <p>
+ * The height in pixels of a cell in the compact month view
+ * </p>
+ *
+ * @return Returns the compactMonthRowHeight.
+ */
+ public String getCompactMonthRowHeight()
+ {
+ return compactMonthRowHeight;
+ }
+
+ /**
+ * <p>
+ * The height in pixels of a cell in the compact week view
+ * </p>
+ *
+ * @param compactWeekRowHeight The compactWeekRowHeight to set.
+ */
+ public void setCompactWeekRowHeight(String compactWeekRowHeight)
+ {
+ this.compactWeekRowHeight = compactWeekRowHeight;
+ }
+
+ /**
+ * <p>
+ * The height in pixels of a cell in the compact week view
+ * </p>
+ *
+ * @return Returns the compactWeekRowHeight.
+ */
+ public String getCompactWeekRowHeight()
+ {
+ return compactWeekRowHeight;
+ }
+
+ /**
+ * @see javax.faces.webapp.UIComponentTag#getComponentType()
+ */
+ public String getComponentType()
+ {
+ return HtmlSchedule.COMPONENT_TYPE;
+ }
+
+ /**
+ * <p>
+ * The dateformat used in the header
+ * </p>
+ *
+ * @param headerDateFormat The headerDateFormat to set.
+ */
+ public void setHeaderDateFormat(String headerDateFormat)
+ {
+ this.headerDateFormat = headerDateFormat;
+ }
+
+ /**
+ * <p>
+ * The dateformat used in the header
+ * </p>
+ *
+ * @return Returns the headerDateFormat.
+ */
+ public String getHeaderDateFormat()
+ {
+ return headerDateFormat;
+ }
+
+ /**
+ * <p>
+ * The immediate property of the JSF component
+ * </p>
+ *
+ * @param immediate The immediate to set.
+ */
+ public void setImmediate(String immediate)
+ {
+ this.immediate = immediate;
+ }
+
+ /**
+ * <p>
+ * The immediate property of the JSF component
+ * </p>
+ *
+ * @return Returns the immediate.
+ */
+ public String getImmediate()
+ {
+ return immediate;
+ }
+
+ /**
+ * <p>
+ * The readonly property of the JSF component
+ * </p>
+ *
+ * @param readonly The readonly to set.
+ */
+ public void setReadonly(String readonly)
+ {
+ this.readonly = readonly;
+ }
+
+ /**
+ * <p>
+ * The readonly property of the JSF component
+ * </p>
+ *
+ * @return Returns the readonly.
+ */
+ public String getReadonly()
+ {
+ return readonly;
+ }
+
+ /**
+ * <p>
+ * Should this component be rendered?
+ * </p>
+ *
+ * @param rendered The rendered to set.
+ */
+ public void setRendered(String rendered)
+ {
+ this.rendered = rendered;
+ }
+
+ /**
+ * <p>
+ * Should this component be rendered?
+ * </p>
+ *
+ * @return Returns the rendered.
+ */
+ public String getRendered()
+ {
+ return rendered;
+ }
+
+ /**
+ * @see javax.faces.webapp.UIComponentTag#getRendererType()
+ */
+ public String getRendererType()
+ {
+ return UISchedule.DEFAULT_RENDERER_TYPE;
+ }
+
+ /**
+ * <p>
+ * Should tooltips be displayed?
+ * </p>
+ *
+ * @param tooltip The tooltip to set.
+ */
+ public void setTooltip(String tooltip)
+ {
+ this.tooltip = tooltip;
+ }
+
+ /**
+ * <p>
+ * Should tooltips be displayed?
+ * </p>
+ *
+ * @return Returns the tooltip.
+ */
+ public String getTooltip()
+ {
+ return tooltip;
+ }
+
+ /**
+ * <p>
+ * The value of the JSF component
+ * </p>
+ *
+ * @param value The value to set.
+ */
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+
+ /**
+ * <p>
+ * The value of the JSF component
+ * </p>
+ *
+ * @return Returns the value.
+ *
+ * @jsp.attribute
+ * required="true"
+ * rtexprvalue="false"
+ * type="String"
+ */
+ public String getValue()
+ {
+ return value;
+ }
+
+ /**
+ * <p>
+ * The visible end hour of the schedule
+ * </p>
+ *
+ * @param visibleEndHour The visibleEndHour to set.
+ */
+ public void setVisibleEndHour(String visibleEndHour)
+ {
+ this.visibleEndHour = visibleEndHour;
+ }
+
+ /**
+ * <p>
+ * The visible end hour of the schedule
+ * </p>
+ *
+ * @return Returns the visibleEndHour.
+ */
+ public String getVisibleEndHour()
+ {
+ return visibleEndHour;
+ }
+
+ /**
+ * <p>
+ * The visible start hour of the schedule
+ * </p>
+ *
+ * @param visibleStartHour The visibleStartHour to set.
+ */
+ public void setVisibleStartHour(String visibleStartHour)
+ {
+ this.visibleStartHour = visibleStartHour;
+ }
+
+ /**
+ * <p>
+ * The visible start hour of the schedule
+ * </p>
+ *
+ * @return Returns the visibleStartHour.
+ */
+ public String getVisibleStartHour()
+ {
+ return visibleStartHour;
+ }
+
+ /**
+ * <p>
+ * The working end hour of the schedule
+ * </p>
+ *
+ * @param workingEndHour The workingEndHour to set.
+ */
+ public void setWorkingEndHour(String workingEndHour)
+ {
+ this.workingEndHour = workingEndHour;
+ }
+
+ /**
+ * <p>
+ * The working end hour of the schedule
+ * </p>
+ *
+ * @return Returns the workingEndHour.
+ */
+ public String getWorkingEndHour()
+ {
+ return workingEndHour;
+ }
+
+ /**
+ * <p>
+ * The working start hour of the schedule
+ * </p>
+ *
+ * @param workingStartHour The workingStartHour to set.
+ */
+ public void setWorkingStartHour(String workingStartHour)
+ {
+ this.workingStartHour = workingStartHour;
+ }
+
+ /**
+ * <p>
+ * The working start hour of the schedule
+ * </p>
+ *
+ * @return Returns the workingStartHour.
+ */
+ public String getWorkingStartHour()
+ {
+ return workingStartHour;
+ }
+
+ /**
+ * @see javax.servlet.jsp.tagext.Tag#release()
+ */
+ public void release()
+ {
+ super.release();
+ visibleStartHour = null;
+ visibleEndHour = null;
+ workingStartHour = null;
+ workingEndHour = null;
+ headerDateFormat = null;
+ value = null;
+ immediate = null;
+ actionListener = null;
+ action = null;
+ readonly = null;
+ tooltip = null;
+ rendered = null;
+ }
+
+ /**
+ * @see javax.faces.webapp.UIComponentTag#setProperties(javax.faces.component.UIComponent)
+ */
+ protected void setProperties(UIComponent component)
+ {
+ super.setProperties(component);
+
+ HtmlSchedule schedule = (HtmlSchedule) component;
+ FacesContext context = FacesContext.getCurrentInstance();
+ Application app = context.getApplication();
+
+ 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 {
+ schedule.setReadonly(Boolean.valueOf(readonly).booleanValue());
+ }
+ }
+
+ if (actionListener != null) {
+ if (isValueReference(actionListener)) {
+ MethodBinding actionListenerBinding =
+ app.createMethodBinding(
+ actionListener, new Class[] { ActionEvent.class }
+ );
+ schedule.setActionListener(actionListenerBinding);
+ } else {
+ throw new IllegalArgumentException(
+ "actionListener property must be a method-binding expression."
+ );
+ }
+ }
+
+ if (action != null) {
+ if (isValueReference(action)) {
+ MethodBinding actionBinding =
+ app.createMethodBinding(
+ action, new Class[] { ActionEvent.class }
+ );
+ schedule.setAction(actionBinding);
+ } else {
+ throw new IllegalArgumentException(
+ "action property must be a method-binding expression."
+ );
+ }
+ }
+
+ if ((value != null) && isValueReference(value)) {
+ System.out.println("set value: " + value);
+ schedule.setValueBinding("value", app.createValueBinding(value));
+ } else {
+ throw new IllegalArgumentException(
+ "The value property must be a value binding expression that points to a SimpleScheduleModel object."
+ );
+ }
+
+ addAttribute(app, schedule, "headerDateFormat", headerDateFormat);
+ 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 {
+ component.getAttributes().put(key, value);
+ }
+ }
+ }
+}
+//The End
Added: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/UIPlanner.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/UIPlanner.java?rev=216175&view=auto
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/UIPlanner.java (added)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/UIPlanner.java Wed Jul 13 08:33:22 2005
@@ -0,0 +1,335 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.myfaces.custom.schedule;
+
+
+import java.io.Serializable;
+
+import java.util.Iterator;
+
+import javax.faces.component.UIComponentBase;
+import javax.faces.component.ValueHolder;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+
+import org.apache.myfaces.custom.schedule.model.PlannerEntity;
+import org.apache.myfaces.custom.schedule.model.PlannerModel;
+import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
+import org.apache.myfaces.custom.schedule.util.ScheduleUtil;
+
+
+/**
+ * <p>
+ * A meeting planner component, similar to the ones found in Outlook or
+ * Evolution.
+ * </p>
+ *
+ * @author Jurgen Lust (latest modification by $Author$)
+ * @author Bruno Aranda (adaptation of Jurgen's code to myfaces)
+ * @version $Revision$
+ */
+public class UIPlanner
+ extends UIComponentBase
+ implements ValueHolder, Serializable
+{
+ //~ Static fields/initializers ---------------------------------------------
+
+ /** Logger for this class */
+ public static final String COMPONENT_TYPE =
+ "org.apache.myfaces.Planner";
+ public static final String COMPONENT_FAMILY = "javax.faces.Panel";
+ public static final String DEFAULT_RENDERER_TYPE =
+ "org.apache.myfaces.Planner";
+
+ //~ Instance fields --------------------------------------------------------
+
+ private Converter _converter;
+ private Integer _visibleEndHour;
+ private Integer _visibleStartHour;
+ private Integer _workingEndHour;
+ private Integer _workingStartHour;
+ private Object _value;
+
+ //~ Constructors -----------------------------------------------------------
+
+ /**
+ * Creates a new UIPlanner object.
+ */
+ public UIPlanner()
+ {
+ super();
+ setRendererType(DEFAULT_RENDERER_TYPE);
+ }
+
+ //~ Methods ----------------------------------------------------------------
+
+ /**
+ * @see javax.faces.component.ValueHolder#setConverter(javax.faces.convert.Converter)
+ */
+ public void setConverter(Converter converter)
+ {
+ this._converter = converter;
+ }
+
+ /**
+ * @see javax.faces.component.ValueHolder#getConverter()
+ */
+ public Converter getConverter()
+ {
+ return _converter;
+ }
+
+ /**
+ * @see javax.faces.component.UIComponent#getFamily()
+ */
+ public String getFamily()
+ {
+ return COMPONENT_FAMILY;
+ }
+
+ /**
+ * @see javax.faces.component.ValueHolder#getLocalValue()
+ */
+ public Object getLocalValue()
+ {
+ return _value;
+ }
+
+ /**
+ * <p>
+ * The underlying planner model
+ * </p>
+ *
+ * @param model the model
+ */
+ public void setModel(PlannerModel model)
+ {
+ setValue(model);
+ }
+
+ /**
+ * <p>
+ * The underlying planner model
+ * </p>
+ *
+ * @return the model
+ */
+ public PlannerModel getModel()
+ {
+ if (getValue() instanceof PlannerModel) {
+ return (PlannerModel) getValue();
+ } else {
+ return new PlannerModel();
+ }
+ }
+
+ /**
+ * @see javax.faces.component.UIComponent#getRendersChildren()
+ */
+ public boolean getRendersChildren()
+ {
+ return true;
+ }
+
+ /**
+ * @see javax.faces.component.ValueHolder#setValue(java.lang.Object)
+ */
+ public void setValue(Object value)
+ {
+ this._value = value;
+ }
+
+ /**
+ * @see javax.faces.component.ValueHolder#getValue()
+ */
+ public Object getValue()
+ {
+ return ScheduleUtil.getObjectProperty(this, _value, "value", _value);
+ }
+
+ /**
+ * <p>
+ * the last hour of the day that is visible in the planner
+ * </p>
+ *
+ * @param visibleEndHour The visibleEndHour to set.
+ */
+ public void setVisibleEndHour(int visibleEndHour)
+ {
+ this._visibleEndHour = new Integer(visibleEndHour);
+ }
+
+ /**
+ * <p>
+ * The last hour of the day that is visible in the planner
+ * </p>
+ *
+ * @return Returns the visibleEndHour.
+ */
+ public int getVisibleEndHour()
+ {
+ return ScheduleUtil.getIntegerProperty(
+ this, _visibleEndHour, "visibleEndHour", 22
+ );
+ }
+
+ /**
+ * <p>
+ * the first hour of the day that is visible in the planner
+ * </p>
+ *
+ * @param visibleStartHour The visibleStartHour to set.
+ */
+ public void setVisibleStartHour(int visibleStartHour)
+ {
+ this._visibleStartHour = new Integer(visibleStartHour);
+ }
+
+ /**
+ * <p>
+ * the first hour of the day that is visible in the planner
+ * </p>
+ *
+ * @return Returns the visibleStartHour.
+ */
+ public int getVisibleStartHour()
+ {
+ return ScheduleUtil.getIntegerProperty(
+ this, _visibleStartHour, "visibleStartHour", 8
+ );
+ }
+
+ /**
+ * <p>
+ * the last hour of the working day
+ * </p>
+ *
+ * @param workingEndHour The workingEndHour to set.
+ */
+ public void setWorkingEndHour(int workingEndHour)
+ {
+ this._workingEndHour = new Integer(workingEndHour);
+ }
+
+ /**
+ * <p>
+ * the last hour of the working day
+ * </p>
+ *
+ * @return Returns the workingEndHour.
+ */
+ public int getWorkingEndHour()
+ {
+ return ScheduleUtil.getIntegerProperty(
+ this, _workingEndHour, "workingEndHour", 17
+ );
+ }
+
+ /**
+ * <p>
+ * The first hour of the working day
+ * </p>
+ *
+ * @param workingStartHour The workingStartHour to set.
+ */
+ public void setWorkingStartHour(int workingStartHour)
+ {
+ this._workingStartHour = new Integer(workingStartHour);
+ }
+
+ /**
+ * <p>
+ * The first hour of the working day
+ * </p>
+ *
+ * @return Returns the workingStartHour.
+ */
+ public int getWorkingStartHour()
+ {
+ return ScheduleUtil.getIntegerProperty(
+ this, _workingStartHour, "workingStartHour", 9
+ );
+ }
+
+ /**
+ * <p>
+ * Find the entry with the given id
+ * </p>
+ *
+ * @param id the id
+ *
+ * @return the entry
+ */
+ public ScheduleEntry findEntry(String id)
+ {
+ if (id == null) {
+ return null;
+ }
+
+ for (
+ Iterator entityIterator = getModel().entityIterator();
+ entityIterator.hasNext();
+ ) {
+ PlannerEntity entity = (PlannerEntity) entityIterator.next();
+
+ for (Iterator iter = entity.iterator(); iter.hasNext();) {
+ ScheduleEntry entry = (ScheduleEntry) iter.next();
+
+ if (id.equals(entry.getId())) {
+ return entry;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @see javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext,
+ * java.lang.Object)
+ */
+ public void restoreState(
+ FacesContext context,
+ Object state
+ )
+ {
+ Object[] values = (Object[]) state;
+ super.restoreState(context, values[0]);
+ _visibleStartHour = (Integer) values[1];
+ _visibleEndHour = (Integer) values[2];
+ _workingStartHour = (Integer) values[3];
+ _workingEndHour = (Integer) values[4];
+ _value = values[5];
+ }
+
+ /**
+ * @see javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext)
+ */
+ public Object saveState(FacesContext context)
+ {
+ Object[] values = new Object[6];
+ values[0] = super.saveState(context);
+ values[1] = _visibleStartHour;
+ values[2] = _visibleEndHour;
+ values[3] = _workingStartHour;
+ values[4] = _workingEndHour;
+ values[5] = _value;
+
+ return values;
+ }
+}
+//The End
Added: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/UISchedule.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/UISchedule.java?rev=216175&view=auto
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/UISchedule.java (added)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/UISchedule.java Wed Jul 13 08:33:22 2005
@@ -0,0 +1,546 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.myfaces.custom.schedule;
+
+
+import java.io.Serializable;
+
+import java.util.Iterator;
+
+import javax.faces.component.ActionSource;
+import javax.faces.component.UIComponentBase;
+import javax.faces.component.ValueHolder;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.el.MethodBinding;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ActionListener;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.PhaseId;
+
+import org.apache.myfaces.custom.schedule.model.ScheduleDay;
+import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
+import org.apache.myfaces.custom.schedule.model.ScheduleModel;
+import org.apache.myfaces.custom.schedule.model.SimpleScheduleModel;
+import org.apache.myfaces.custom.schedule.util.ScheduleUtil;
+
+
+/**
+ * <p>
+ * A schedule component similar to the ones found in Outlook or Evolution
+ * </p>
+ *
+ * @author Jurgen Lust (latest modification by $Author$)
+ * @author Bruno Aranda (adaptation of Jurgen code to myfaces)
+ * @version $Revision$
+ */
+public class UISchedule
+ extends UIComponentBase
+ implements ValueHolder, Serializable, ActionSource
+{
+ //~ Static fields/initializers ---------------------------------------------
+
+ public static final String COMPONENT_TYPE =
+ "org.apache.myfaces.Schedule";
+ public static final String COMPONENT_FAMILY = "javax.faces.Panel";
+ public static final String DEFAULT_RENDERER_TYPE =
+ "org.apache.myfaces.Schedule";
+
+ //~ Instance fields --------------------------------------------------------
+
+ private Boolean immediate;
+ private Boolean readonly;
+ private Converter converter;
+ private Integer visibleEndHour;
+ private Integer visibleStartHour;
+ private Integer workingEndHour;
+ private Integer workingStartHour;
+ private MethodBinding action;
+ private MethodBinding actionListenerBinding;
+ private Object value;
+ private ScheduleActionListener scheduleListener;
+ private ScheduleEntry submittedEntry;
+
+ //~ Constructors -----------------------------------------------------------
+
+ /**
+ * Creates a new UISchedule object.
+ */
+ public UISchedule()
+ {
+ super();
+ setRendererType(DEFAULT_RENDERER_TYPE);
+ scheduleListener = new ScheduleActionListener();
+ addActionListener(scheduleListener);
+ }
+
+ //~ Methods ----------------------------------------------------------------
+
+ /**
+ * @see javax.faces.component.ActionSource#setAction(javax.faces.el.MethodBinding)
+ */
+ public void setAction(MethodBinding action)
+ {
+ this.action = action;
+ }
+
+ /**
+ * @see javax.faces.component.ActionSource#getAction()
+ */
+ public MethodBinding getAction()
+ {
+ return action;
+ }
+
+ /**
+ * @see javax.faces.component.ActionSource#setActionListener(javax.faces.el.MethodBinding)
+ */
+ public void setActionListener(MethodBinding listener)
+ {
+ this.actionListenerBinding = listener;
+ }
+
+ /**
+ * @see javax.faces.component.ActionSource#getActionListener()
+ */
+ public MethodBinding getActionListener()
+ {
+ return actionListenerBinding;
+ }
+
+ /**
+ * @see javax.faces.component.ActionSource#getActionListeners()
+ */
+ public ActionListener[] getActionListeners()
+ {
+ return (ActionListener[]) getFacesListeners(ActionListener.class);
+ }
+
+ /**
+ * @see javax.faces.component.ValueHolder#setConverter(javax.faces.convert.Converter)
+ */
+ public void setConverter(Converter converter)
+ {
+ this.converter = converter;
+ }
+
+ /**
+ * @see javax.faces.component.ValueHolder#getConverter()
+ */
+ public Converter getConverter()
+ {
+ return converter;
+ }
+
+ /**
+ * @see javax.faces.component.UIComponent#getFamily()
+ */
+ public String getFamily()
+ {
+ return COMPONENT_FAMILY;
+ }
+
+ /**
+ * @see javax.faces.component.ActionSource#setImmediate(boolean)
+ */
+ public void setImmediate(boolean immediate)
+ {
+ this.immediate = Boolean.valueOf(immediate);
+ }
+
+ /**
+ * @see javax.faces.component.ActionSource#isImmediate()
+ */
+ public boolean isImmediate()
+ {
+ return ScheduleUtil.getBooleanProperty(this, immediate, "immediate", false);
+ }
+
+ /**
+ * @see javax.faces.component.ValueHolder#getLocalValue()
+ */
+ public Object getLocalValue()
+ {
+ return value;
+ }
+
+ /**
+ * <p>
+ * The underlying model
+ * </p>
+ *
+ * @param model The model to set.
+ */
+ public void setModel(ScheduleModel model)
+ {
+ setValue(model);
+ }
+
+ /**
+ * <p>
+ * The underlying model
+ * </p>
+ *
+ * @return Returns the model.
+ */
+ public ScheduleModel getModel()
+ {
+ if (getValue() instanceof ScheduleModel) {
+ return (ScheduleModel) getValue();
+ } else {
+ return new SimpleScheduleModel();
+ }
+ }
+
+ /**
+ * <p>
+ * is this component read-only?
+ * </p>
+ *
+ * @param readonly is this component read-only
+ */
+ public void setReadonly(boolean readonly)
+ {
+ this.readonly = Boolean.valueOf(readonly);
+ }
+
+ /**
+ * <p>
+ * is this component read-only?
+ * </p>
+ *
+ * @return is this component read-only
+ */
+ public boolean isReadonly()
+ {
+ return ScheduleUtil.getBooleanProperty(this, readonly, "readonly", false);
+ }
+
+ /**
+ * @see javax.faces.component.UIComponent#getRendersChildren()
+ */
+ public boolean getRendersChildren()
+ {
+ return true;
+ }
+
+ /**
+ * <p>
+ * The entry that was submitted on the last request
+ * </p>
+ *
+ * @param submittedEntry The submittedEntry to set.
+ */
+ public void setSubmittedEntry(ScheduleEntry submittedEntry)
+ {
+ this.submittedEntry = submittedEntry;
+ }
+
+ /**
+ * <p>
+ * The entry that was submitted on the last request
+ * </p>
+ *
+ * @return Returns the submittedEntry.
+ */
+ public ScheduleEntry getSubmittedEntry()
+ {
+ return submittedEntry;
+ }
+
+ /**
+ * @see javax.faces.component.ValueHolder#setValue(java.lang.Object)
+ */
+ public void setValue(Object value)
+ {
+ this.value = value;
+ }
+
+ /**
+ * @see javax.faces.component.ValueHolder#getValue()
+ */
+ public Object getValue()
+ {
+ return ScheduleUtil.getObjectProperty(this, value, "value", value);
+ }
+
+ /**
+ * <p>
+ * The last visible hour of the day
+ * </p>
+ *
+ * @param visibleEndHour The visibleEndHour to set.
+ */
+ public void setVisibleEndHour(int visibleEndHour)
+ {
+ this.visibleEndHour = new Integer(visibleEndHour);
+ }
+
+ /**
+ * <p>
+ * The last visible hour of the day
+ * </p>
+ *
+ * @return Returns the visibleEndHour.
+ */
+ public int getVisibleEndHour()
+ {
+ return ScheduleUtil.getIntegerProperty(
+ this, visibleEndHour, "visibleEndHour", 22
+ );
+ }
+
+ /**
+ * <p>
+ * The first visible hour of the day
+ * </p>
+ *
+ * @param visibleStartHour The visibleStartHour to set.
+ */
+ public void setVisibleStartHour(int visibleStartHour)
+ {
+ this.visibleStartHour = new Integer(visibleStartHour);
+ }
+
+ /**
+ * <p>
+ * The first visible hour of the day
+ * </p>
+ *
+ * @return Returns the visibleStartHour.
+ */
+ public int getVisibleStartHour()
+ {
+ return ScheduleUtil.getIntegerProperty(
+ this, visibleStartHour, "visibleStartHour", 8
+ );
+ }
+
+ /**
+ * <p>
+ * The last hour of the working day
+ * </p>
+ *
+ * @param workingEndHour The workingEndHour to set.
+ */
+ public void setWorkingEndHour(int workingEndHour)
+ {
+ this.workingEndHour = new Integer(workingEndHour);
+ }
+
+ /**
+ * <p>
+ * The last hour of the working day
+ * </p>
+ *
+ * @return Returns the workingEndHour.
+ */
+ public int getWorkingEndHour()
+ {
+ return ScheduleUtil.getIntegerProperty(
+ this, workingEndHour, "workingEndHour", 17
+ );
+ }
+
+ /**
+ * <p>
+ * The first hour of the working day
+ * </p>
+ *
+ * @param workingStartHour The workingStartHour to set.
+ */
+ public void setWorkingStartHour(int workingStartHour)
+ {
+ this.workingStartHour = new Integer(workingStartHour);
+ }
+
+ /**
+ * <p>
+ * The first hour of the working day
+ * </p>
+ *
+ * @return Returns the workingStartHour.
+ */
+ public int getWorkingStartHour()
+ {
+ return ScheduleUtil.getIntegerProperty(
+ this, workingStartHour, "workingStartHour", 9
+ );
+ }
+
+ /**
+ * @see javax.faces.component.ActionSource#addActionListener(javax.faces.event.ActionListener)
+ */
+ public void addActionListener(ActionListener listener)
+ {
+ addFacesListener(listener);
+ }
+
+ /**
+ * @see javax.faces.component.UIComponent#broadcast(javax.faces.event.FacesEvent)
+ */
+ public void broadcast(FacesEvent event)
+ throws AbortProcessingException
+ {
+ super.broadcast(event);
+
+ MethodBinding binding = getActionListener();
+
+ if (binding != null) {
+ FacesContext context = getFacesContext();
+ binding.invoke(context, new Object[] { event });
+ }
+ }
+
+ /**
+ * <p>
+ * Find the entry with the given id
+ * </p>
+ *
+ * @param id the id
+ *
+ * @return the entry
+ */
+ public ScheduleEntry findEntry(String id)
+ {
+ if (id == null) {
+ return null;
+ }
+
+ for (Iterator dayIterator = getModel().iterator();
+ dayIterator.hasNext();
+ ) {
+ ScheduleDay day = (ScheduleDay) dayIterator.next();
+
+ for (Iterator iter = day.iterator(); iter.hasNext();) {
+ ScheduleEntry entry = (ScheduleEntry) iter.next();
+
+ if (id.equals(entry.getId())) {
+ return entry;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @see javax.faces.component.UIComponent#queueEvent(javax.faces.event.FacesEvent)
+ */
+ public void queueEvent(FacesEvent event)
+ {
+ if (event instanceof ActionEvent) {
+ if (isImmediate()) {
+ event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
+ } else {
+ event.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ }
+ }
+
+ super.queueEvent(event);
+ }
+
+ /**
+ * @see javax.faces.component.ActionSource#removeActionListener(javax.faces.event.ActionListener)
+ */
+ public void removeActionListener(ActionListener listener)
+ {
+ removeFacesListener(listener);
+ }
+
+ /**
+ * @see javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext,
+ * java.lang.Object)
+ */
+ public void restoreState(
+ FacesContext context,
+ Object state
+ )
+ {
+ Object[] values = (Object[]) state;
+ super.restoreState(context, values[0]);
+ visibleStartHour = (Integer) values[1];
+ visibleEndHour = (Integer) values[2];
+ workingStartHour = (Integer) values[3];
+ workingEndHour = (Integer) values[4];
+
+ Boolean immediateState = (Boolean) values[5];
+
+ if (immediateState != null) {
+ setImmediate(immediateState.booleanValue());
+ }
+
+ Boolean readonlyState = (Boolean) values[6];
+
+ if (readonlyState != null) {
+ setReadonly(readonlyState.booleanValue());
+ }
+
+ value = values[7];
+ actionListenerBinding =
+ (MethodBinding) restoreAttachedState(context, values[8]);
+ addActionListener(scheduleListener);
+ }
+
+ /**
+ * @see javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext)
+ */
+ public Object saveState(FacesContext context)
+ {
+ removeActionListener(scheduleListener);
+
+ Object[] values = new Object[9];
+ values[0] = super.saveState(context);
+ values[1] = visibleStartHour;
+ values[2] = visibleEndHour;
+ values[3] = workingStartHour;
+ values[4] = workingEndHour;
+ values[5] = immediate;
+ values[6] = readonly;
+ values[7] = value;
+ values[8] = saveAttachedState(context, actionListenerBinding);
+
+ return values;
+ }
+
+ //~ Inner Classes ----------------------------------------------------------
+
+ private class ScheduleActionListener
+ implements ActionListener
+ {
+ //~ Methods ------------------------------------------------------------
+
+ /**
+ * @see javax.faces.event.ActionListener#processAction(javax.faces.event.ActionEvent)
+ */
+ public void processAction(ActionEvent event)
+ throws AbortProcessingException
+ {
+ UISchedule schedule = (UISchedule) event.getComponent();
+ ScheduleEntry entry = schedule.getSubmittedEntry();
+ schedule.getModel().setSelectedEntry(entry);
+ schedule.setSubmittedEntry(null);
+
+ if (schedule.getAction() != null) {
+ getFacesContext().getApplication().getActionListener()
+ .processAction(event);
+ }
+ }
+ }
+}
+//The End