myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mat...@apache.org
Subject svn commit: r427657 [15/42] - in /myfaces: core/trunk/api/src/main/java/javax/faces/component/ core/trunk/api/src/test/java/javax/faces/ core/trunk/api/src/test/java/javax/faces/application/ core/trunk/api/src/test/java/javax/faces/component/ core/trun...
Date Tue, 01 Aug 2006 17:44:01 GMT
Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/UISchedule.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/UISchedule.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/UISchedule.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/UISchedule.java Tue Aug  1 10:43:28 2006
@@ -1,550 +1,550 @@
-/*
- * 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: jlust $)
- * @author Bruno Aranda (adaptation of Jurgen code to myfaces)
- * @version $Revision: 392301 $
- */
-public class UISchedule extends UIComponentBase implements ValueHolder,
-        Serializable, ActionSource
-{
-    private static final long serialVersionUID = 3440822180568539483L;
-
-    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);
-            }
-        }
-    }
-    public static final String COMPONENT_FAMILY = "javax.faces.Panel";
-    //~ Static fields/initializers ---------------------------------------------
-    public static final String COMPONENT_TYPE = "org.apache.myfaces.Schedule";
-
-    //~ Instance fields --------------------------------------------------------
-
-    public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.Schedule";
-    private MethodBinding actionBinding;
-    private MethodBinding actionListenerBinding;
-    private Converter converter;
-    private Boolean immediate;
-    private Boolean readonly;
-    private ScheduleActionListener scheduleListener;
-    private ScheduleEntry submittedEntry;
-    private Object value;
-    private Integer visibleEndHour;
-    private Integer visibleStartHour;
-    private Integer workingEndHour;
-
-    //~ Constructors -----------------------------------------------------------
-
-    private Integer workingStartHour;
-
-    //~ Methods ----------------------------------------------------------------
-
-    /**
-     * Creates a new UISchedule object.
-     */
-    public UISchedule()
-    {
-        super();
-        setRendererType(DEFAULT_RENDERER_TYPE);
-        scheduleListener = new ScheduleActionListener();
-        addActionListener(scheduleListener); 
-    }
-
-    /**
-     * @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);
-
-        FacesContext context = getFacesContext();
-        MethodBinding actionListenerBinding = getActionListener();
-
-        if (actionListenerBinding != null)
-        {
-            actionListenerBinding.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.ActionSource#getAction()
-     */
-    public MethodBinding getAction()
-    {
-        return actionBinding;
-    }
-
-    /**
-     * @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#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 model
-     * </p>
-     *
-     * @return Returns the model.
-     */
-    public ScheduleModel getModel()
-    {
-        if (getValue() instanceof ScheduleModel)
-        {
-            return (ScheduleModel) getValue();
-        }
-        else
-        {
-            return new SimpleScheduleModel();
-        }
-    }
-
-    /**
-     * @see javax.faces.component.UIComponent#getRendersChildren()
-     */
-    public boolean getRendersChildren()
-    {
-        return true;
-    }
-
-    /**
-     * <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#getValue()
-     */
-    public Object getValue()
-    {
-        return ScheduleUtil.getObjectProperty(this, value, "value", value);
-    }
-
-    /**
-     * <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>
-     *
-     * @return Returns the visibleStartHour.
-     */
-    public int getVisibleStartHour()
-    {
-        return ScheduleUtil.getIntegerProperty(this, visibleStartHour,
-                "visibleStartHour", 8);
-    }
-
-    /**
-     * <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>
-     *
-     * @return Returns the workingStartHour.
-     */
-    public int getWorkingStartHour()
-    {
-        return ScheduleUtil.getIntegerProperty(this, workingStartHour,
-                "workingStartHour", 9);
-    }
-
-    /**
-     * @see javax.faces.component.ActionSource#isImmediate()
-     */
-    public boolean isImmediate()
-    {
-        return ScheduleUtil.getBooleanProperty(this, immediate, "immediate",
-                false);
-    }
-
-    /**
-     * <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#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]);
-        actionBinding = (MethodBinding) restoreAttachedState(context, values[9]);
-        addActionListener(scheduleListener);
-    }
-
-    /**
-     * @see javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext)
-     */
-    public Object saveState(FacesContext context)
-    {
-        removeActionListener(scheduleListener);
-
-        Object[] values = new Object[10];
-        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);
-        values[9] = saveAttachedState(context, actionBinding);
-
-        return values;
-    }
-
-    /**
-     * @see javax.faces.component.ActionSource#setAction(javax.faces.el.MethodBinding)
-     */
-    public void setAction(MethodBinding action)
-    {
-        this.actionBinding = action;
-    }
-
-    /**
-     * @see javax.faces.component.ActionSource#setActionListener(javax.faces.el.MethodBinding)
-     */
-    public void setActionListener(MethodBinding listener)
-    {
-        this.actionListenerBinding = listener;
-    }
-
-    /**
-     * @see javax.faces.component.ValueHolder#setConverter(javax.faces.convert.Converter)
-     */
-    public void setConverter(Converter converter)
-    {
-        this.converter = converter;
-    }
-
-    /**
-     * @see javax.faces.component.ActionSource#setImmediate(boolean)
-     */
-    public void setImmediate(boolean immediate)
-    {
-        this.immediate = Boolean.valueOf(immediate);
-    }
-
-    /**
-     * <p>
-     * The underlying model
-     * </p>
-     *
-     * @param model The model to set.
-     */
-    public void setModel(ScheduleModel model)
-    {
-        setValue(model);
-    }
-
-    /**
-     * <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>
-     * The entry that was submitted on the last request
-     * </p>
-     *
-     * @param submittedEntry The submittedEntry to set.
-     */
-    public void setSubmittedEntry(ScheduleEntry submittedEntry)
-    {
-        this.submittedEntry = submittedEntry;
-    }
-
-    /**
-     * @see javax.faces.component.ValueHolder#setValue(java.lang.Object)
-     */
-    public void setValue(Object value)
-    {
-        this.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 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 last hour of the working day
-     * </p>
-     *
-     * @param workingEndHour The workingEndHour to set.
-     */
-    public void setWorkingEndHour(int workingEndHour)
-    {
-        this.workingEndHour = new Integer(workingEndHour);
-    }
-
-    //~ Inner Classes ----------------------------------------------------------
-
-    /**
-     * <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);
-    }
-}
-//The End
+/*
+ * 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: jlust $)
+ * @author Bruno Aranda (adaptation of Jurgen code to myfaces)
+ * @version $Revision: 392301 $
+ */
+public class UISchedule extends UIComponentBase implements ValueHolder,
+        Serializable, ActionSource
+{
+    private static final long serialVersionUID = 3440822180568539483L;
+
+    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);
+            }
+        }
+    }
+    public static final String COMPONENT_FAMILY = "javax.faces.Panel";
+    //~ Static fields/initializers ---------------------------------------------
+    public static final String COMPONENT_TYPE = "org.apache.myfaces.Schedule";
+
+    //~ Instance fields --------------------------------------------------------
+
+    public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.Schedule";
+    private MethodBinding actionBinding;
+    private MethodBinding actionListenerBinding;
+    private Converter converter;
+    private Boolean immediate;
+    private Boolean readonly;
+    private ScheduleActionListener scheduleListener;
+    private ScheduleEntry submittedEntry;
+    private Object value;
+    private Integer visibleEndHour;
+    private Integer visibleStartHour;
+    private Integer workingEndHour;
+
+    //~ Constructors -----------------------------------------------------------
+
+    private Integer workingStartHour;
+
+    //~ Methods ----------------------------------------------------------------
+
+    /**
+     * Creates a new UISchedule object.
+     */
+    public UISchedule()
+    {
+        super();
+        setRendererType(DEFAULT_RENDERER_TYPE);
+        scheduleListener = new ScheduleActionListener();
+        addActionListener(scheduleListener); 
+    }
+
+    /**
+     * @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);
+
+        FacesContext context = getFacesContext();
+        MethodBinding actionListenerBinding = getActionListener();
+
+        if (actionListenerBinding != null)
+        {
+            actionListenerBinding.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.ActionSource#getAction()
+     */
+    public MethodBinding getAction()
+    {
+        return actionBinding;
+    }
+
+    /**
+     * @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#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 model
+     * </p>
+     *
+     * @return Returns the model.
+     */
+    public ScheduleModel getModel()
+    {
+        if (getValue() instanceof ScheduleModel)
+        {
+            return (ScheduleModel) getValue();
+        }
+        else
+        {
+            return new SimpleScheduleModel();
+        }
+    }
+
+    /**
+     * @see javax.faces.component.UIComponent#getRendersChildren()
+     */
+    public boolean getRendersChildren()
+    {
+        return true;
+    }
+
+    /**
+     * <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#getValue()
+     */
+    public Object getValue()
+    {
+        return ScheduleUtil.getObjectProperty(this, value, "value", value);
+    }
+
+    /**
+     * <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>
+     *
+     * @return Returns the visibleStartHour.
+     */
+    public int getVisibleStartHour()
+    {
+        return ScheduleUtil.getIntegerProperty(this, visibleStartHour,
+                "visibleStartHour", 8);
+    }
+
+    /**
+     * <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>
+     *
+     * @return Returns the workingStartHour.
+     */
+    public int getWorkingStartHour()
+    {
+        return ScheduleUtil.getIntegerProperty(this, workingStartHour,
+                "workingStartHour", 9);
+    }
+
+    /**
+     * @see javax.faces.component.ActionSource#isImmediate()
+     */
+    public boolean isImmediate()
+    {
+        return ScheduleUtil.getBooleanProperty(this, immediate, "immediate",
+                false);
+    }
+
+    /**
+     * <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#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]);
+        actionBinding = (MethodBinding) restoreAttachedState(context, values[9]);
+        addActionListener(scheduleListener);
+    }
+
+    /**
+     * @see javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext)
+     */
+    public Object saveState(FacesContext context)
+    {
+        removeActionListener(scheduleListener);
+
+        Object[] values = new Object[10];
+        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);
+        values[9] = saveAttachedState(context, actionBinding);
+
+        return values;
+    }
+
+    /**
+     * @see javax.faces.component.ActionSource#setAction(javax.faces.el.MethodBinding)
+     */
+    public void setAction(MethodBinding action)
+    {
+        this.actionBinding = action;
+    }
+
+    /**
+     * @see javax.faces.component.ActionSource#setActionListener(javax.faces.el.MethodBinding)
+     */
+    public void setActionListener(MethodBinding listener)
+    {
+        this.actionListenerBinding = listener;
+    }
+
+    /**
+     * @see javax.faces.component.ValueHolder#setConverter(javax.faces.convert.Converter)
+     */
+    public void setConverter(Converter converter)
+    {
+        this.converter = converter;
+    }
+
+    /**
+     * @see javax.faces.component.ActionSource#setImmediate(boolean)
+     */
+    public void setImmediate(boolean immediate)
+    {
+        this.immediate = Boolean.valueOf(immediate);
+    }
+
+    /**
+     * <p>
+     * The underlying model
+     * </p>
+     *
+     * @param model The model to set.
+     */
+    public void setModel(ScheduleModel model)
+    {
+        setValue(model);
+    }
+
+    /**
+     * <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>
+     * The entry that was submitted on the last request
+     * </p>
+     *
+     * @param submittedEntry The submittedEntry to set.
+     */
+    public void setSubmittedEntry(ScheduleEntry submittedEntry)
+    {
+        this.submittedEntry = submittedEntry;
+    }
+
+    /**
+     * @see javax.faces.component.ValueHolder#setValue(java.lang.Object)
+     */
+    public void setValue(Object value)
+    {
+        this.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 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 last hour of the working day
+     * </p>
+     *
+     * @param workingEndHour The workingEndHour to set.
+     */
+    public void setWorkingEndHour(int workingEndHour)
+    {
+        this.workingEndHour = new Integer(workingEndHour);
+    }
+
+    //~ Inner Classes ----------------------------------------------------------
+
+    /**
+     * <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);
+    }
+}
+//The End

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/UISchedule.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/model/AbstractScheduleModel.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/model/AbstractScheduleModel.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/model/AbstractScheduleModel.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/model/AbstractScheduleModel.java Tue Aug  1 10:43:28 2006
@@ -1,455 +1,455 @@
-/*
- * 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.model;
-
-import java.io.Serializable;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.Iterator;
-import java.util.TreeSet;
-
-/**
- * <p>
- * Extend this class to create your own implementation of a ScheduleModel
- * </p>
- * 
- * @author Jurgen Lust (latest modification by $Author: baranda $)
- * @version $Revision: 372589 $
- */
-public abstract class AbstractScheduleModel implements ScheduleModel,
-        Serializable
-{
-    // ~ Instance fields
-    // --------------------------------------------------------
-
-    protected final TreeSet days;
-
-    private Date selectedDate = new Date();
-
-    private ScheduleEntry selectedEntry;
-
-    private int mode;
-
-    // ~ Constructors
-    // -----------------------------------------------------------
-
-    /**
-     * Creates a new AbstractScheduleModel object.
-     */
-    public AbstractScheduleModel()
-    {
-        this.days = new TreeSet();
-    }
-
-    // ~ Methods
-    // ----------------------------------------------------------------
-
-    /**
-     * @see org.apache.myfaces.custom.schedule.model.ScheduleModel#isEmpty()
-     */
-    public boolean isEmpty()
-    {
-        return days.isEmpty();
-    }
-
-    /**
-     * @see org.apache.myfaces.custom.schedule.model.ScheduleModel#setMode(int)
-     */
-    public void setMode(int mode)
-    {
-        this.mode = mode;
-    }
-
-    /**
-     * @see org.apache.myfaces.custom.schedule.model.ScheduleModel#getMode()
-     */
-    public int getMode()
-    {
-        return mode;
-    }
-
-    /**
-     * @see org.apache.myfaces.custom.schedule.model.ScheduleModel#setSelectedDate(java.util.Date)
-     */
-    public void setSelectedDate(Date date)
-    {
-        if (date == null)
-        {
-            // do nothing when the date is null
-            return;
-        }
-
-        this.selectedDate = date;
-
-        switch (mode)
-        {
-        case DAY:
-            setDay(this.selectedDate);
-
-            break;
-
-        case WORKWEEK:
-            setWorkWeek(this.selectedDate);
-
-            break;
-
-        case WEEK:
-            setWeek(this.selectedDate);
-
-            break;
-
-        case MONTH:
-            setMonth(this.selectedDate);
-
-            break;
-
-        default:
-            setDay(this.selectedDate);
-        }
-    }
-
-    /**
-     * @see org.apache.myfaces.custom.schedule.model.ScheduleModel#getSelectedDate()
-     */
-    public Date getSelectedDate()
-    {
-        return selectedDate;
-    }
-
-    /**
-     * @see org.apache.myfaces.custom.schedule.model.ScheduleModel#setSelectedEntry(org.apache.myfaces.custom.schedule.model.ScheduleEntry)
-     */
-    public void setSelectedEntry(ScheduleEntry selectedEntry)
-    {
-        this.selectedEntry = selectedEntry;
-    }
-
-    /**
-     * @see org.apache.myfaces.custom.schedule.model.ScheduleModel#getSelectedEntry()
-     */
-    public ScheduleEntry getSelectedEntry()
-    {
-        return selectedEntry;
-    }
-    
-    /**
-     * @see org.apache.myfaces.custom.schedule.model.ScheduleModel#isEntrySelected()
-     */
-    public boolean isEntrySelected() {
-        return getSelectedEntry() != null;
-    }
-
-    /**
-     * @see org.apache.myfaces.custom.schedule.model.ScheduleModel#containsDate(java.util.Date)
-     */
-    public boolean containsDate(Date date)
-    {
-        for (Iterator iterator = iterator(); iterator.hasNext();)
-        {
-            ScheduleDay day = (ScheduleDay) iterator.next();
-
-            if (day.equalsDate(date))
-            {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-    /**
-     * @see org.apache.myfaces.custom.schedule.model.ScheduleModel#get(int)
-     */
-    public Object get(int index)
-    {
-        Object[] dayArray = days.toArray();
-
-        Object returnObject = dayArray[index];
-
-        return returnObject;
-    }
-
-    /**
-     * @see org.apache.myfaces.custom.schedule.model.ScheduleModel#iterator()
-     */
-    public Iterator iterator()
-    {
-        return days.iterator();
-    }
-
-    /**
-     * @see org.apache.myfaces.custom.schedule.model.ScheduleModel#size()
-     */
-    public int size()
-    {
-        return days.size();
-    }
-
-    /**
-     * <p>
-     * Set the day
-     * </p>
-     * 
-     * @param date
-     *            the new day
-     */
-    protected void setDay(Date date)
-    {
-        if (date == null)
-        {
-            return;
-        }
-
-        clear();
-
-        ScheduleDay day = add(date);
-        load(day.getDayStart(), day.getDayEnd());
-    }
-
-    /**
-     * <p>
-     * navigate to the specified month
-     * </p>
-     * 
-     * @param date
-     *            the date to navigate to
-     */
-    protected void setMonth(Date date)
-    {
-        if (date == null)
-        {
-            return;
-        }
-
-        clear();
-
-        Calendar cal = GregorianCalendar.getInstance();
-        cal.setTime(date);
-
-        // go back to the first day of the month;
-        cal.set(Calendar.DAY_OF_MONTH, cal.getMinimum(Calendar.DAY_OF_MONTH));
-
-        Date temp = cal.getTime();
-        cal.add(Calendar.MONTH, 1);
-        int nextMonth = cal.get(Calendar.MONTH);
-        cal.setTime(temp);
-
-        ScheduleDay firstDay = null;
-        ScheduleDay lastDay = null;
-        
-        // we want to show the whole first week, including the days from the previous month
-        cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
-
-        while (true)
-        {
-            ScheduleDay addedDay = add(cal.getTime());
-
-            if (firstDay == null)
-            {
-                firstDay = addedDay;
-            }
-
-            lastDay = addedDay;
-            cal.add(Calendar.DATE, 1);
-            
-            //stop when we are at the last day of the last week
-            if (cal.get(Calendar.MONTH) == nextMonth && cal.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY)
-            {
-               	break;
-            }
-        }
-
-        load(firstDay.getDayStart(), lastDay.getDayEnd());
-    }
-
-    /**
-     * <p>
-     * navigate to the specified week
-     * </p>
-     * 
-     * @param date
-     *            the date to navigate to
-     */
-    protected void setWeek(Date date)
-    {
-        if (date == null)
-        {
-            return;
-        }
-
-        clear();
-
-        Calendar cal = GregorianCalendar.getInstance();
-        cal.setTime(date);
-
-        // go back to the monday of this week
-        cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
-
-        ScheduleDay firstDay = null;
-        ScheduleDay lastDay = null;
-
-        for (int i = 0; i < 7; i++)
-        {
-            ScheduleDay addedDay = add(cal.getTime());
-
-            if (firstDay == null)
-            {
-                firstDay = addedDay;
-            }
-
-            lastDay = addedDay;
-            cal.add(Calendar.DATE, 1);
-        }
-
-        load(firstDay.getDayStart(), lastDay.getDayEnd());
-    }
-
-    /**
-     * <p>
-     * navigate to the specified workweek
-     * </p>
-     * 
-     * @param date
-     *            the date to navigate to
-     */
-    protected void setWorkWeek(Date date)
-    {
-        if (date == null)
-        {
-            return;
-        }
-
-        clear();
-
-        Calendar cal = GregorianCalendar.getInstance();
-        cal.setTime(date);
-
-        // go back to the monday of this week
-        cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
-
-        ScheduleDay firstDay = null;
-        ScheduleDay lastDay = null;
-
-        for (int i = 0; i < 5; i++)
-        {
-            ScheduleDay addedDay = add(cal.getTime());
-
-            if (firstDay == null)
-            {
-                firstDay = addedDay;
-            }
-
-            lastDay = addedDay;
-            cal.add(Calendar.DATE, 1);
-        }
-
-        load(firstDay.getDayStart(), lastDay.getDayEnd());
-    }
-
-    /**
-     * <p>
-     * Add a day to the schedule
-     * </p>
-     * 
-     * @param date
-     *            the day to add
-     * 
-     * @return the day that was added
-     */
-    protected ScheduleDay add(Date date)
-    {
-        if (date == null)
-        {
-            return null;
-        }
-
-        ScheduleDay day = new ScheduleDay(date);
-        loadDayAttributes(day);
-        days.add(day);
-
-        return day;
-    }
-
-    /**
-     * <p>
-     * Remove all days
-     * </p>
-     */
-    protected void clear()
-    {
-        for (Iterator dayIterator = days.iterator(); dayIterator.hasNext();)
-        {
-            ScheduleDay day = (ScheduleDay) dayIterator.next();
-            day.clear();
-        }
-
-        days.clear();
-    }
-
-    /**
-     * @see org.apache.myfaces.custom.schedule.model.ScheduleModel#refresh()
-     */
-    public void refresh()
-    {
-        setSelectedDate(selectedDate);
-    }
-
-    /**
-     * <p>
-     * Load the schedule entries that fall between the startDate and the
-     * endDate.
-     * </p>
-     * 
-     * @param startDate
-     *            0 AM on the start date
-     * @param endDate
-     *            12 PM on the end date
-     */
-    protected abstract Collection loadEntries(Date startDate, Date endDate);
-
-    /**
-     * <p>
-     * Load any attributes for this day: is it a working day or a holiday, and
-     * what is the name of the day (e.g. "Christmas").
-     * </p>
-     * 
-     * @param day
-     *            the day that should be loaded
-     */
-    protected abstract void loadDayAttributes(Day day);
-
-    private void load(Date startDate, Date endDate)
-    {
-        Collection entries = loadEntries(startDate, endDate);
-
-        for (Iterator entryIterator = entries.iterator(); entryIterator
-                .hasNext();)
-        {
-            ScheduleEntry entry = (ScheduleEntry) entryIterator.next();
-
-            for (Iterator dayIterator = days.iterator(); dayIterator.hasNext();)
-            {
-                ScheduleDay day = (ScheduleDay) dayIterator.next();
-
-                day.addEntry(entry);
-            }
-        }
-    }
-}
-// The End
+/*
+ * 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.model;
+
+import java.io.Serializable;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Iterator;
+import java.util.TreeSet;
+
+/**
+ * <p>
+ * Extend this class to create your own implementation of a ScheduleModel
+ * </p>
+ * 
+ * @author Jurgen Lust (latest modification by $Author: baranda $)
+ * @version $Revision: 372589 $
+ */
+public abstract class AbstractScheduleModel implements ScheduleModel,
+        Serializable
+{
+    // ~ Instance fields
+    // --------------------------------------------------------
+
+    protected final TreeSet days;
+
+    private Date selectedDate = new Date();
+
+    private ScheduleEntry selectedEntry;
+
+    private int mode;
+
+    // ~ Constructors
+    // -----------------------------------------------------------
+
+    /**
+     * Creates a new AbstractScheduleModel object.
+     */
+    public AbstractScheduleModel()
+    {
+        this.days = new TreeSet();
+    }
+
+    // ~ Methods
+    // ----------------------------------------------------------------
+
+    /**
+     * @see org.apache.myfaces.custom.schedule.model.ScheduleModel#isEmpty()
+     */
+    public boolean isEmpty()
+    {
+        return days.isEmpty();
+    }
+
+    /**
+     * @see org.apache.myfaces.custom.schedule.model.ScheduleModel#setMode(int)
+     */
+    public void setMode(int mode)
+    {
+        this.mode = mode;
+    }
+
+    /**
+     * @see org.apache.myfaces.custom.schedule.model.ScheduleModel#getMode()
+     */
+    public int getMode()
+    {
+        return mode;
+    }
+
+    /**
+     * @see org.apache.myfaces.custom.schedule.model.ScheduleModel#setSelectedDate(java.util.Date)
+     */
+    public void setSelectedDate(Date date)
+    {
+        if (date == null)
+        {
+            // do nothing when the date is null
+            return;
+        }
+
+        this.selectedDate = date;
+
+        switch (mode)
+        {
+        case DAY:
+            setDay(this.selectedDate);
+
+            break;
+
+        case WORKWEEK:
+            setWorkWeek(this.selectedDate);
+
+            break;
+
+        case WEEK:
+            setWeek(this.selectedDate);
+
+            break;
+
+        case MONTH:
+            setMonth(this.selectedDate);
+
+            break;
+
+        default:
+            setDay(this.selectedDate);
+        }
+    }
+
+    /**
+     * @see org.apache.myfaces.custom.schedule.model.ScheduleModel#getSelectedDate()
+     */
+    public Date getSelectedDate()
+    {
+        return selectedDate;
+    }
+
+    /**
+     * @see org.apache.myfaces.custom.schedule.model.ScheduleModel#setSelectedEntry(org.apache.myfaces.custom.schedule.model.ScheduleEntry)
+     */
+    public void setSelectedEntry(ScheduleEntry selectedEntry)
+    {
+        this.selectedEntry = selectedEntry;
+    }
+
+    /**
+     * @see org.apache.myfaces.custom.schedule.model.ScheduleModel#getSelectedEntry()
+     */
+    public ScheduleEntry getSelectedEntry()
+    {
+        return selectedEntry;
+    }
+    
+    /**
+     * @see org.apache.myfaces.custom.schedule.model.ScheduleModel#isEntrySelected()
+     */
+    public boolean isEntrySelected() {
+        return getSelectedEntry() != null;
+    }
+
+    /**
+     * @see org.apache.myfaces.custom.schedule.model.ScheduleModel#containsDate(java.util.Date)
+     */
+    public boolean containsDate(Date date)
+    {
+        for (Iterator iterator = iterator(); iterator.hasNext();)
+        {
+            ScheduleDay day = (ScheduleDay) iterator.next();
+
+            if (day.equalsDate(date))
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    /**
+     * @see org.apache.myfaces.custom.schedule.model.ScheduleModel#get(int)
+     */
+    public Object get(int index)
+    {
+        Object[] dayArray = days.toArray();
+
+        Object returnObject = dayArray[index];
+
+        return returnObject;
+    }
+
+    /**
+     * @see org.apache.myfaces.custom.schedule.model.ScheduleModel#iterator()
+     */
+    public Iterator iterator()
+    {
+        return days.iterator();
+    }
+
+    /**
+     * @see org.apache.myfaces.custom.schedule.model.ScheduleModel#size()
+     */
+    public int size()
+    {
+        return days.size();
+    }
+
+    /**
+     * <p>
+     * Set the day
+     * </p>
+     * 
+     * @param date
+     *            the new day
+     */
+    protected void setDay(Date date)
+    {
+        if (date == null)
+        {
+            return;
+        }
+
+        clear();
+
+        ScheduleDay day = add(date);
+        load(day.getDayStart(), day.getDayEnd());
+    }
+
+    /**
+     * <p>
+     * navigate to the specified month
+     * </p>
+     * 
+     * @param date
+     *            the date to navigate to
+     */
+    protected void setMonth(Date date)
+    {
+        if (date == null)
+        {
+            return;
+        }
+
+        clear();
+
+        Calendar cal = GregorianCalendar.getInstance();
+        cal.setTime(date);
+
+        // go back to the first day of the month;
+        cal.set(Calendar.DAY_OF_MONTH, cal.getMinimum(Calendar.DAY_OF_MONTH));
+
+        Date temp = cal.getTime();
+        cal.add(Calendar.MONTH, 1);
+        int nextMonth = cal.get(Calendar.MONTH);
+        cal.setTime(temp);
+
+        ScheduleDay firstDay = null;
+        ScheduleDay lastDay = null;
+        
+        // we want to show the whole first week, including the days from the previous month
+        cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
+
+        while (true)
+        {
+            ScheduleDay addedDay = add(cal.getTime());
+
+            if (firstDay == null)
+            {
+                firstDay = addedDay;
+            }
+
+            lastDay = addedDay;
+            cal.add(Calendar.DATE, 1);
+            
+            //stop when we are at the last day of the last week
+            if (cal.get(Calendar.MONTH) == nextMonth && cal.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY)
+            {
+               	break;
+            }
+        }
+
+        load(firstDay.getDayStart(), lastDay.getDayEnd());
+    }
+
+    /**
+     * <p>
+     * navigate to the specified week
+     * </p>
+     * 
+     * @param date
+     *            the date to navigate to
+     */
+    protected void setWeek(Date date)
+    {
+        if (date == null)
+        {
+            return;
+        }
+
+        clear();
+
+        Calendar cal = GregorianCalendar.getInstance();
+        cal.setTime(date);
+
+        // go back to the monday of this week
+        cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
+
+        ScheduleDay firstDay = null;
+        ScheduleDay lastDay = null;
+
+        for (int i = 0; i < 7; i++)
+        {
+            ScheduleDay addedDay = add(cal.getTime());
+
+            if (firstDay == null)
+            {
+                firstDay = addedDay;
+            }
+
+            lastDay = addedDay;
+            cal.add(Calendar.DATE, 1);
+        }
+
+        load(firstDay.getDayStart(), lastDay.getDayEnd());
+    }
+
+    /**
+     * <p>
+     * navigate to the specified workweek
+     * </p>
+     * 
+     * @param date
+     *            the date to navigate to
+     */
+    protected void setWorkWeek(Date date)
+    {
+        if (date == null)
+        {
+            return;
+        }
+
+        clear();
+
+        Calendar cal = GregorianCalendar.getInstance();
+        cal.setTime(date);
+
+        // go back to the monday of this week
+        cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
+
+        ScheduleDay firstDay = null;
+        ScheduleDay lastDay = null;
+
+        for (int i = 0; i < 5; i++)
+        {
+            ScheduleDay addedDay = add(cal.getTime());
+
+            if (firstDay == null)
+            {
+                firstDay = addedDay;
+            }
+
+            lastDay = addedDay;
+            cal.add(Calendar.DATE, 1);
+        }
+
+        load(firstDay.getDayStart(), lastDay.getDayEnd());
+    }
+
+    /**
+     * <p>
+     * Add a day to the schedule
+     * </p>
+     * 
+     * @param date
+     *            the day to add
+     * 
+     * @return the day that was added
+     */
+    protected ScheduleDay add(Date date)
+    {
+        if (date == null)
+        {
+            return null;
+        }
+
+        ScheduleDay day = new ScheduleDay(date);
+        loadDayAttributes(day);
+        days.add(day);
+
+        return day;
+    }
+
+    /**
+     * <p>
+     * Remove all days
+     * </p>
+     */
+    protected void clear()
+    {
+        for (Iterator dayIterator = days.iterator(); dayIterator.hasNext();)
+        {
+            ScheduleDay day = (ScheduleDay) dayIterator.next();
+            day.clear();
+        }
+
+        days.clear();
+    }
+
+    /**
+     * @see org.apache.myfaces.custom.schedule.model.ScheduleModel#refresh()
+     */
+    public void refresh()
+    {
+        setSelectedDate(selectedDate);
+    }
+
+    /**
+     * <p>
+     * Load the schedule entries that fall between the startDate and the
+     * endDate.
+     * </p>
+     * 
+     * @param startDate
+     *            0 AM on the start date
+     * @param endDate
+     *            12 PM on the end date
+     */
+    protected abstract Collection loadEntries(Date startDate, Date endDate);
+
+    /**
+     * <p>
+     * Load any attributes for this day: is it a working day or a holiday, and
+     * what is the name of the day (e.g. "Christmas").
+     * </p>
+     * 
+     * @param day
+     *            the day that should be loaded
+     */
+    protected abstract void loadDayAttributes(Day day);
+
+    private void load(Date startDate, Date endDate)
+    {
+        Collection entries = loadEntries(startDate, endDate);
+
+        for (Iterator entryIterator = entries.iterator(); entryIterator
+                .hasNext();)
+        {
+            ScheduleEntry entry = (ScheduleEntry) entryIterator.next();
+
+            for (Iterator dayIterator = days.iterator(); dayIterator.hasNext();)
+            {
+                ScheduleDay day = (ScheduleDay) dayIterator.next();
+
+                day.addEntry(entry);
+            }
+        }
+    }
+}
+// The End

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/model/AbstractScheduleModel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/model/Day.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/model/Day.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/model/Day.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/model/Day.java Tue Aug  1 10:43:28 2006
@@ -1,220 +1,220 @@
-/*
- * 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.model;
-
-
-import java.io.Serializable;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-
-import org.apache.myfaces.custom.schedule.util.ScheduleUtil;
-
-
-/**
- * <p>
- * This class represents a day in the Schedule component
- * </p>
- *
- * @author Jurgen Lust (latest modification by $Author: werpu $)
- * @version $Revision: 371736 $
- */
-public class Day
-    implements Serializable, Comparable
-{
-    //~ Instance fields --------------------------------------------------------
-
-    /**
-     * serial id for serialisation versioning
-     */
-    private static final long serialVersionUID = 1L;
-    private final Date date;
-    private final Date dayEnd;
-    private final Date dayStart;
-    private String specialDayName;
-    private boolean workingDay;
-
-    //~ Constructors -----------------------------------------------------------
-
-    /**
-     * Creates a new Day object.
-     *
-     * @param date the date
-     *
-     * @throws NullPointerException when the date is null
-     */
-    public Day(Date date)
-    {
-        super();
-        this.date = date;
-
-        if (date == null) {
-            throw new NullPointerException("date should not be null");
-        }
-
-        Calendar cal = GregorianCalendar.getInstance();
-        cal.setTime(date);
-        cal.set(Calendar.HOUR_OF_DAY, 0);
-        cal.set(Calendar.MINUTE, 0);
-        cal.set(Calendar.SECOND, 0);
-        cal.set(Calendar.MILLISECOND, 0);
-        this.dayStart = cal.getTime();
-        cal.add(Calendar.DATE, 1);
-        this.dayEnd = cal.getTime();
-    }
-
-    //~ Methods ----------------------------------------------------------------
-
-    /**
-     * @return Returns the date.
-     */
-    public Date getDate()
-    {
-        return (date == null) ? new Date() : date;
-    }
-
-    /**
-     * @return Returns 12PM of this day
-     */
-    public Date getDayEnd()
-    {
-        return dayEnd;
-    }
-
-    /**
-     * @return Returns 0AM of this day
-     */
-    public Date getDayStart()
-    {
-        return dayStart;
-    }
-
-    /**
-     * <p>
-     * If this day is a holiday of some kind, this sets the name
-     * </p>
-     *
-     * @param specialDayName The specialDayName to set.
-     */
-    public void setSpecialDayName(String specialDayName)
-    {
-        this.specialDayName = specialDayName;
-    }
-
-    /**
-     * <p>
-     * If this day is a holiday of some kind, this gets the name
-     * </p>
-     *
-     * @return Returns the specialDayName.
-     */
-    public String getSpecialDayName()
-    {
-        return specialDayName;
-    }
-
-    /**
-     * <p>
-     * Is this day a working day?
-     * </p>
-     *
-     * @param workingDay The workingDay to set.
-     */
-    public void setWorkingDay(boolean workingDay)
-    {
-        this.workingDay = workingDay;
-    }
-
-    /**
-     * <p>
-     * Is this day a working day?
-     * </p>
-     *
-     * @return Returns the workingDay.
-     */
-    public boolean isWorkingDay()
-    {
-        Calendar cal = GregorianCalendar.getInstance();
-        cal.setTime(date);
-
-        int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
-
-        if ((dayOfWeek == Calendar.SATURDAY) || (dayOfWeek == Calendar.SUNDAY)) {
-            return false;
-        }
-
-        return workingDay;
-    }
-
-    /**
-     * @see java.lang.Comparable#compareTo(java.lang.Object)
-     */
-    public int compareTo(Object o)
-    {
-        if (o instanceof Day) {
-            Day other = (Day) o;
-
-            int returnint = ScheduleUtil.compareDays(date, other.getDate());
-
-            return returnint;
-        }
-
-        return 1;
-    }
-
-    /**
-     * @see java.lang.Object#equals(java.lang.Object)
-     */
-    public boolean equals(Object o)
-    {
-        if (o instanceof Day) {
-            Day other = (Day) o;
-
-            return ScheduleUtil.isSameDay(date, other.getDate());
-        }
-
-        return false;
-    }
-
-    /**
-     * <p>
-     * Check if the specified date is on this day
-     * </p>
-     *
-     * @param date the date to check
-     *
-     * @return if the date is on this day
-     */
-    public boolean equalsDate(Date date)
-    {
-        if (date == null) {
-            return false;
-        }
-
-        return ScheduleUtil.isSameDay(date, this.date);
-    }
-
-    /**
-     * @see java.lang.Object#hashCode()
-     */
-    public int hashCode()
-    {
-        return ScheduleUtil.getHashCodeForDay(date);
-    }
-}
-//The End
+/*
+ * 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.model;
+
+
+import java.io.Serializable;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+import org.apache.myfaces.custom.schedule.util.ScheduleUtil;
+
+
+/**
+ * <p>
+ * This class represents a day in the Schedule component
+ * </p>
+ *
+ * @author Jurgen Lust (latest modification by $Author: werpu $)
+ * @version $Revision: 371736 $
+ */
+public class Day
+    implements Serializable, Comparable
+{
+    //~ Instance fields --------------------------------------------------------
+
+    /**
+     * serial id for serialisation versioning
+     */
+    private static final long serialVersionUID = 1L;
+    private final Date date;
+    private final Date dayEnd;
+    private final Date dayStart;
+    private String specialDayName;
+    private boolean workingDay;
+
+    //~ Constructors -----------------------------------------------------------
+
+    /**
+     * Creates a new Day object.
+     *
+     * @param date the date
+     *
+     * @throws NullPointerException when the date is null
+     */
+    public Day(Date date)
+    {
+        super();
+        this.date = date;
+
+        if (date == null) {
+            throw new NullPointerException("date should not be null");
+        }
+
+        Calendar cal = GregorianCalendar.getInstance();
+        cal.setTime(date);
+        cal.set(Calendar.HOUR_OF_DAY, 0);
+        cal.set(Calendar.MINUTE, 0);
+        cal.set(Calendar.SECOND, 0);
+        cal.set(Calendar.MILLISECOND, 0);
+        this.dayStart = cal.getTime();
+        cal.add(Calendar.DATE, 1);
+        this.dayEnd = cal.getTime();
+    }
+
+    //~ Methods ----------------------------------------------------------------
+
+    /**
+     * @return Returns the date.
+     */
+    public Date getDate()
+    {
+        return (date == null) ? new Date() : date;
+    }
+
+    /**
+     * @return Returns 12PM of this day
+     */
+    public Date getDayEnd()
+    {
+        return dayEnd;
+    }
+
+    /**
+     * @return Returns 0AM of this day
+     */
+    public Date getDayStart()
+    {
+        return dayStart;
+    }
+
+    /**
+     * <p>
+     * If this day is a holiday of some kind, this sets the name
+     * </p>
+     *
+     * @param specialDayName The specialDayName to set.
+     */
+    public void setSpecialDayName(String specialDayName)
+    {
+        this.specialDayName = specialDayName;
+    }
+
+    /**
+     * <p>
+     * If this day is a holiday of some kind, this gets the name
+     * </p>
+     *
+     * @return Returns the specialDayName.
+     */
+    public String getSpecialDayName()
+    {
+        return specialDayName;
+    }
+
+    /**
+     * <p>
+     * Is this day a working day?
+     * </p>
+     *
+     * @param workingDay The workingDay to set.
+     */
+    public void setWorkingDay(boolean workingDay)
+    {
+        this.workingDay = workingDay;
+    }
+
+    /**
+     * <p>
+     * Is this day a working day?
+     * </p>
+     *
+     * @return Returns the workingDay.
+     */
+    public boolean isWorkingDay()
+    {
+        Calendar cal = GregorianCalendar.getInstance();
+        cal.setTime(date);
+
+        int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
+
+        if ((dayOfWeek == Calendar.SATURDAY) || (dayOfWeek == Calendar.SUNDAY)) {
+            return false;
+        }
+
+        return workingDay;
+    }
+
+    /**
+     * @see java.lang.Comparable#compareTo(java.lang.Object)
+     */
+    public int compareTo(Object o)
+    {
+        if (o instanceof Day) {
+            Day other = (Day) o;
+
+            int returnint = ScheduleUtil.compareDays(date, other.getDate());
+
+            return returnint;
+        }
+
+        return 1;
+    }
+
+    /**
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    public boolean equals(Object o)
+    {
+        if (o instanceof Day) {
+            Day other = (Day) o;
+
+            return ScheduleUtil.isSameDay(date, other.getDate());
+        }
+
+        return false;
+    }
+
+    /**
+     * <p>
+     * Check if the specified date is on this day
+     * </p>
+     *
+     * @param date the date to check
+     *
+     * @return if the date is on this day
+     */
+    public boolean equalsDate(Date date)
+    {
+        if (date == null) {
+            return false;
+        }
+
+        return ScheduleUtil.isSameDay(date, this.date);
+    }
+
+    /**
+     * @see java.lang.Object#hashCode()
+     */
+    public int hashCode()
+    {
+        return ScheduleUtil.getHashCodeForDay(date);
+    }
+}
+//The End

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/model/Day.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/model/DefaultScheduleEntry.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/model/DefaultScheduleEntry.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/model/DefaultScheduleEntry.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/model/DefaultScheduleEntry.java Tue Aug  1 10:43:28 2006
@@ -1,184 +1,184 @@
-/*
- * 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.model;
-
-import java.io.Serializable;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-
-import org.apache.myfaces.custom.schedule.util.ScheduleUtil;
-
-
-/**
- * <p>
- * A default implementation of a Schedule entry
- * </p>
- *
- * @author Jurgen Lust (latest modification by $Author: werpu $)
- * @version $Revision: 371736 $
- */
-public class DefaultScheduleEntry
-    implements Serializable, ScheduleEntry
-{
-    //~ Instance fields --------------------------------------------------------
-
-    /**
-     * serial id for serialisation versioning
-     */
-    private static final long serialVersionUID = 1L;
-    private Date endTime;
-    private Date startTime;
-    private String description;
-    private String id;
-    private String subtitle;
-    private String title;
-    private boolean allDay;
-
-    //~ Methods ----------------------------------------------------------------
-
-    /**
-     * @param description The description to set.
-     */
-    public void setDescription(String description)
-    {
-        this.description = description;
-    }
-
-    /**
-     * @return Returns the description.
-     */
-    public String getDescription()
-    {
-        return description;
-    }
-
-    /**
-     * @param endTime The endTime to set.
-     */
-    public void setEndTime(Date endTime)
-    {
-        this.endTime = endTime;
-    }
-
-    /**
-     * @return Returns the endTime.
-     */
-    public Date getEndTime()
-    {
-    	if (endTime == null) endTime = new Date();
-    	if (isAllDay()) {
-    		Calendar cal = GregorianCalendar.getInstance();
-    		Date truncated = ScheduleUtil.truncate(endTime);
-    		cal.setTime(truncated);
-    		cal.add(Calendar.MILLISECOND, -1);
-    		truncated = cal.getTime();
-    		if (!truncated.equals(endTime)) {
-    			cal.add(Calendar.DATE, 1);
-    		}
-    		return cal.getTime();
-    	}
-        return endTime;
-    }
-
-    /**
-     * @param id The id to set.
-     */
-    public void setId(String id)
-    {
-        this.id = id;
-    }
-
-    /**
-     * @return Returns the id.
-     */
-    public String getId()
-    {
-        return id;
-    }
-
-    /**
-     * @param startTime The startTime to set.
-     */
-    public void setStartTime(Date startTime)
-    {
-        this.startTime = startTime;
-    }
-
-    /**
-     * @return Returns the startTime. If the allDay property is true, the startTime is truncated to 00:00.
-     */
-    public Date getStartTime()
-    {
-    	if (startTime == null) startTime = new Date();
-    	if (isAllDay()) {
-    		return ScheduleUtil.truncate(startTime);
-    	} else {
-            return startTime;
-    	}
-    }
-
-    /**
-     * @param subtitle The subtitle to set.
-     */
-    public void setSubtitle(String subtitle)
-    {
-        this.subtitle = subtitle;
-    }
-
-    /**
-     * @return Returns the subtitle.
-     */
-    public String getSubtitle()
-    {
-        return subtitle;
-    }
-
-    /**
-     * @param title The title to set.
-     */
-    public void setTitle(String title)
-    {
-        this.title = title;
-    }
-
-    /**
-     * @return Returns the title.
-     */
-    public String getTitle()
-    {
-        return title;
-    }
-    
-    /**
-     * @return Returns true if the entry last all day.
-     */
-    public boolean isAllDay()
-    {
-    	return allDay;
-    }
-
-	/**
-	 * @param allDay does the entry last all day?
-	 */
-	public void setAllDay(boolean allDay) {
-		this.allDay = allDay;
-	}
-	
-}
-//The End
+/*
+ * 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.model;
+
+import java.io.Serializable;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+import org.apache.myfaces.custom.schedule.util.ScheduleUtil;
+
+
+/**
+ * <p>
+ * A default implementation of a Schedule entry
+ * </p>
+ *
+ * @author Jurgen Lust (latest modification by $Author: werpu $)
+ * @version $Revision: 371736 $
+ */
+public class DefaultScheduleEntry
+    implements Serializable, ScheduleEntry
+{
+    //~ Instance fields --------------------------------------------------------
+
+    /**
+     * serial id for serialisation versioning
+     */
+    private static final long serialVersionUID = 1L;
+    private Date endTime;
+    private Date startTime;
+    private String description;
+    private String id;
+    private String subtitle;
+    private String title;
+    private boolean allDay;
+
+    //~ Methods ----------------------------------------------------------------
+
+    /**
+     * @param description The description to set.
+     */
+    public void setDescription(String description)
+    {
+        this.description = description;
+    }
+
+    /**
+     * @return Returns the description.
+     */
+    public String getDescription()
+    {
+        return description;
+    }
+
+    /**
+     * @param endTime The endTime to set.
+     */
+    public void setEndTime(Date endTime)
+    {
+        this.endTime = endTime;
+    }
+
+    /**
+     * @return Returns the endTime.
+     */
+    public Date getEndTime()
+    {
+    	if (endTime == null) endTime = new Date();
+    	if (isAllDay()) {
+    		Calendar cal = GregorianCalendar.getInstance();
+    		Date truncated = ScheduleUtil.truncate(endTime);
+    		cal.setTime(truncated);
+    		cal.add(Calendar.MILLISECOND, -1);
+    		truncated = cal.getTime();
+    		if (!truncated.equals(endTime)) {
+    			cal.add(Calendar.DATE, 1);
+    		}
+    		return cal.getTime();
+    	}
+        return endTime;
+    }
+
+    /**
+     * @param id The id to set.
+     */
+    public void setId(String id)
+    {
+        this.id = id;
+    }
+
+    /**
+     * @return Returns the id.
+     */
+    public String getId()
+    {
+        return id;
+    }
+
+    /**
+     * @param startTime The startTime to set.
+     */
+    public void setStartTime(Date startTime)
+    {
+        this.startTime = startTime;
+    }
+
+    /**
+     * @return Returns the startTime. If the allDay property is true, the startTime is truncated to 00:00.
+     */
+    public Date getStartTime()
+    {
+    	if (startTime == null) startTime = new Date();
+    	if (isAllDay()) {
+    		return ScheduleUtil.truncate(startTime);
+    	} else {
+            return startTime;
+    	}
+    }
+
+    /**
+     * @param subtitle The subtitle to set.
+     */
+    public void setSubtitle(String subtitle)
+    {
+        this.subtitle = subtitle;
+    }
+
+    /**
+     * @return Returns the subtitle.
+     */
+    public String getSubtitle()
+    {
+        return subtitle;
+    }
+
+    /**
+     * @param title The title to set.
+     */
+    public void setTitle(String title)
+    {
+        this.title = title;
+    }
+
+    /**
+     * @return Returns the title.
+     */
+    public String getTitle()
+    {
+        return title;
+    }
+    
+    /**
+     * @return Returns true if the entry last all day.
+     */
+    public boolean isAllDay()
+    {
+    	return allDay;
+    }
+
+	/**
+	 * @param allDay does the entry last all day?
+	 */
+	public void setAllDay(boolean allDay) {
+		this.allDay = allDay;
+	}
+	
+}
+//The End

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/model/DefaultScheduleEntry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/model/ScheduleDay.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/model/ScheduleDay.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/model/ScheduleDay.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/model/ScheduleDay.java Tue Aug  1 10:43:28 2006
@@ -1,219 +1,219 @@
-/*
- * 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.model;
-
-
-import java.io.Serializable;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.Iterator;
-import java.util.TreeSet;
-
-import org.apache.myfaces.custom.schedule.util.ScheduleEntryComparator;
-
-
-/**
- * <p>
- * This class represents one day in the schedule component
- * </p>
- *
- * @author Jurgen Lust (latest modification by $Author: werpu $)
- * @version $Revision: 371736 $
- */
-public class ScheduleDay
-    extends Day
-    implements Serializable, Comparable
-{
-    //~ Instance fields --------------------------------------------------------
-
-    /**
-     * serial id for serialisation versioning
-     */
-    private static final long serialVersionUID = 1L;
-    private final TreeSet entries;
-
-    //~ Constructors -----------------------------------------------------------
-
-    /**
-     * Creates a new ScheduleDay object.
-     *
-     * @param date the date
-     */
-    public ScheduleDay(Date date)
-    {
-        super(date);
-        this.entries = new TreeSet(new ScheduleEntryComparator());
-    }
-
-    //~ Methods ----------------------------------------------------------------
-
-    /**
-     * @return true if there are no schedule entries
-     */
-    public boolean isEmpty()
-    {
-        return entries.isEmpty();
-    }
-
-    /**
-     * <p>
-     * Add an entry to this day
-     * </p>
-     *
-     * @param entry the entry to add
-     *
-     * @return true if successful
-     */
-    public boolean addEntry(ScheduleEntry entry)
-    {
-        if (
-            (entry == null) || (entry.getStartTime() == null) ||
-                (entry.getEndTime() == null)
-        ) {
-            return false;
-        }
-
-        Calendar cal = GregorianCalendar.getInstance();
-        cal.setTime(entry.getEndTime());
-        cal.add(Calendar.DATE, 1);
-        cal.set(Calendar.HOUR_OF_DAY, 0);
-        cal.set(Calendar.MINUTE, 0);
-        cal.set(Calendar.SECOND, 0);
-        cal.set(Calendar.MILLISECOND, 0);
-
-        Date endDate = cal.getTime();
-        cal.setTime(entry.getStartTime());
-
-        while (cal.getTime().before(endDate)) {
-            if (equalsDate(cal.getTime())) {
-                entries.add(entry);
-
-                return true;
-            }
-
-            cal.add(Calendar.DATE, 1);
-        }
-
-        return false;
-    }
-
-    /**
-     * <p>
-     * Remove all entries from this day
-     * </p>
-     */
-    public void clear()
-    {
-        entries.clear();
-    }
-
-    /**
-     * @return an iterator for the schedule entries of this day
-     */
-    public Iterator iterator()
-    {
-        return entries.iterator();
-    }
-
-    /**
-     * <p>
-     * Remove an entry from this day
-     * </p>
-     *
-     * @param entry the entry to remove
-     *
-     * @return true if successful
-     */
-    public boolean remove(ScheduleEntry entry)
-    {
-        return entries.remove(entry);
-    }
-
-    /**
-     * @return the number of entries that are shown on this day
-     */
-    public int size()
-    {
-        return entries.size();
-    }
-    
-    /**
-     * Get the non-inclusive hour by which all events on this day have completed.
-     * All day events are not included, as their end time is implicit.
-     * 
-     * @return From 0, where there are no events and 24 where events exist up to the last hour
-     */
-    public int getLastEventHour()
-    {
-    	Calendar endTime = GregorianCalendar.getInstance();
-
-    	// Check all events, as the last to finish may not be the last to begin
-    	Date lastEnd = null;
-    	
-    	for (Iterator it = entries.iterator(); it.hasNext(); ) {
-    		ScheduleEntry next = (ScheduleEntry) it.next();
-    		
-    		if (!next.isAllDay() && (lastEnd == null || lastEnd.before(next.getEndTime()))) {
-    			lastEnd = next.getEndTime();
-    		}
-    	}
-    	if (lastEnd == null) {
-    		
-    		return 0;
-    	}
-    	
-    	endTime.setTime(lastEnd);
-    	
-    	if (endTime.get(Calendar.MINUTE) > 0){
-    		// Round up to next hour
-    		endTime.add(Calendar.HOUR_OF_DAY, 1);
-    	}
-
-    	return equalsDate(endTime.getTime()) ? endTime.get(Calendar.HOUR_OF_DAY) : 24;    	
-    }
-    
-    /**
-     * Get the inclusive hour in which the first event on this day starts.
-     * All day events are not included, as their start time is implicit.
-     * 
-     * @return From 0, where there is an event in the first hour to 24 where there are no events
-     */
-    public int getFirstEventHour()
-    {
-    	Calendar startTime = null;
-
-    	for (Iterator it = entries.iterator(); it.hasNext(); ) {
-    		ScheduleEntry next = (ScheduleEntry) it.next();
-    		
-    		if (!next.isAllDay()) {
-    			startTime = GregorianCalendar.getInstance();
-    			startTime.setTime(((ScheduleEntry) entries.first()).getStartTime());
-    			break;
-    		}
-    	}
-
-    	if (startTime == null) {
-    		
-    		return 24;
-    	}
-
-    	return equalsDate(startTime.getTime()) ? startTime.get(Calendar.HOUR_OF_DAY) : 0;
-    }
-}
-//The End
+/*
+ * 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.model;
+
+
+import java.io.Serializable;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Iterator;
+import java.util.TreeSet;
+
+import org.apache.myfaces.custom.schedule.util.ScheduleEntryComparator;
+
+
+/**
+ * <p>
+ * This class represents one day in the schedule component
+ * </p>
+ *
+ * @author Jurgen Lust (latest modification by $Author: werpu $)
+ * @version $Revision: 371736 $
+ */
+public class ScheduleDay
+    extends Day
+    implements Serializable, Comparable
+{
+    //~ Instance fields --------------------------------------------------------
+
+    /**
+     * serial id for serialisation versioning
+     */
+    private static final long serialVersionUID = 1L;
+    private final TreeSet entries;
+
+    //~ Constructors -----------------------------------------------------------
+
+    /**
+     * Creates a new ScheduleDay object.
+     *
+     * @param date the date
+     */
+    public ScheduleDay(Date date)
+    {
+        super(date);
+        this.entries = new TreeSet(new ScheduleEntryComparator());
+    }
+
+    //~ Methods ----------------------------------------------------------------
+
+    /**
+     * @return true if there are no schedule entries
+     */
+    public boolean isEmpty()
+    {
+        return entries.isEmpty();
+    }
+
+    /**
+     * <p>
+     * Add an entry to this day
+     * </p>
+     *
+     * @param entry the entry to add
+     *
+     * @return true if successful
+     */
+    public boolean addEntry(ScheduleEntry entry)
+    {
+        if (
+            (entry == null) || (entry.getStartTime() == null) ||
+                (entry.getEndTime() == null)
+        ) {
+            return false;
+        }
+
+        Calendar cal = GregorianCalendar.getInstance();
+        cal.setTime(entry.getEndTime());
+        cal.add(Calendar.DATE, 1);
+        cal.set(Calendar.HOUR_OF_DAY, 0);
+        cal.set(Calendar.MINUTE, 0);
+        cal.set(Calendar.SECOND, 0);
+        cal.set(Calendar.MILLISECOND, 0);
+
+        Date endDate = cal.getTime();
+        cal.setTime(entry.getStartTime());
+
+        while (cal.getTime().before(endDate)) {
+            if (equalsDate(cal.getTime())) {
+                entries.add(entry);
+
+                return true;
+            }
+
+            cal.add(Calendar.DATE, 1);
+        }
+
+        return false;
+    }
+
+    /**
+     * <p>
+     * Remove all entries from this day
+     * </p>
+     */
+    public void clear()
+    {
+        entries.clear();
+    }
+
+    /**
+     * @return an iterator for the schedule entries of this day
+     */
+    public Iterator iterator()
+    {
+        return entries.iterator();
+    }
+
+    /**
+     * <p>
+     * Remove an entry from this day
+     * </p>
+     *
+     * @param entry the entry to remove
+     *
+     * @return true if successful
+     */
+    public boolean remove(ScheduleEntry entry)
+    {
+        return entries.remove(entry);
+    }
+
+    /**
+     * @return the number of entries that are shown on this day
+     */
+    public int size()
+    {
+        return entries.size();
+    }
+    
+    /**
+     * Get the non-inclusive hour by which all events on this day have completed.
+     * All day events are not included, as their end time is implicit.
+     * 
+     * @return From 0, where there are no events and 24 where events exist up to the last hour
+     */
+    public int getLastEventHour()
+    {
+    	Calendar endTime = GregorianCalendar.getInstance();
+
+    	// Check all events, as the last to finish may not be the last to begin
+    	Date lastEnd = null;
+    	
+    	for (Iterator it = entries.iterator(); it.hasNext(); ) {
+    		ScheduleEntry next = (ScheduleEntry) it.next();
+    		
+    		if (!next.isAllDay() && (lastEnd == null || lastEnd.before(next.getEndTime()))) {
+    			lastEnd = next.getEndTime();
+    		}
+    	}
+    	if (lastEnd == null) {
+    		
+    		return 0;
+    	}
+    	
+    	endTime.setTime(lastEnd);
+    	
+    	if (endTime.get(Calendar.MINUTE) > 0){
+    		// Round up to next hour
+    		endTime.add(Calendar.HOUR_OF_DAY, 1);
+    	}
+
+    	return equalsDate(endTime.getTime()) ? endTime.get(Calendar.HOUR_OF_DAY) : 24;    	
+    }
+    
+    /**
+     * Get the inclusive hour in which the first event on this day starts.
+     * All day events are not included, as their start time is implicit.
+     * 
+     * @return From 0, where there is an event in the first hour to 24 where there are no events
+     */
+    public int getFirstEventHour()
+    {
+    	Calendar startTime = null;
+
+    	for (Iterator it = entries.iterator(); it.hasNext(); ) {
+    		ScheduleEntry next = (ScheduleEntry) it.next();
+    		
+    		if (!next.isAllDay()) {
+    			startTime = GregorianCalendar.getInstance();
+    			startTime.setTime(((ScheduleEntry) entries.first()).getStartTime());
+    			break;
+    		}
+    	}
+
+    	if (startTime == null) {
+    		
+    		return 24;
+    	}
+
+    	return equalsDate(startTime.getTime()) ? startTime.get(Calendar.HOUR_OF_DAY) : 0;
+    }
+}
+//The End

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/model/ScheduleDay.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message