You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2005/11/29 21:13:21 UTC
svn commit: r349804 [3/11] - in
/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule: ./
model/ renderer/ resource/css/ resource/javascript/ util/
Modified: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/PlannerEntity.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/PlannerEntity.java?rev=349804&r1=349803&r2=349804&view=diff
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/PlannerEntity.java (original)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/PlannerEntity.java Tue Nov 29 12:12:53 2005
@@ -1,186 +1,186 @@
-/*
- * 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.Iterator;
-import java.util.TreeSet;
-
-import org.apache.myfaces.custom.schedule.util.ScheduleEntryComparator;
-
-
-/**
- * <p>
- * A Planner entity is a person, room, piece of equipment, ... that is displayed
- * as a row in the planner component.
- * </p>
- *
- * TODO this should be an interface, with a DefaultPlannerEntity implementation
- *
- * @author Jurgen Lust (latest modification by $Author$)
- * @version $Revision$
- */
-public class PlannerEntity
- implements Serializable
-{
- //~ Instance fields --------------------------------------------------------
-
- private final String id;
- private final String name;
- private TreeSet entries;
-
- //~ Constructors -----------------------------------------------------------
-
- /**
- * Creates a new PlannerEntity object.
- *
- * @param id the unique identifier
- * @param name the name
- */
- public PlannerEntity(
- String id,
- String name
- )
- {
- super();
- this.id = id;
- this.name = name;
- this.entries = new TreeSet(new ScheduleEntryComparator());
- }
-
- //~ Methods ----------------------------------------------------------------
-
- /**
- * @return true if there are no appointments for this entity
- */
- public boolean isEmpty()
- {
- return entries.isEmpty();
- }
-
- /**
- * @param entries The entries to set.
- */
- public void setEntries(TreeSet entries)
- {
- this.entries = entries;
- }
-
- /**
- * @return Returns the entries.
- */
- public TreeSet getEntries()
- {
- return entries;
- }
-
- /**
- * @return Returns the id.
- */
- public String getId()
- {
- return id;
- }
-
- /**
- * @return Returns the name.
- */
- public String getName()
- {
- return name;
- }
-
- /**
- * <p>
- * Add a schedule entry to this planner entity
- * </p>
- *
- * @param entry the entry to be added
- *
- * @return whether the addition was successful
- */
- public boolean addEntry(ScheduleEntry entry)
- {
- if (
- (entry == null) || (entry.getStartTime() == null) ||
- (entry.getEndTime() == null)
- ) {
- return false;
- }
-
- entries.add(entry);
-
- return true;
- }
-
- /**
- * <p>
- * Remove all entries
- * </p>
- */
- public void clear()
- {
- entries.clear();
- }
-
- /**
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object o)
- {
- if (o instanceof PlannerEntity) {
- PlannerEntity other = (PlannerEntity) o;
-
- return id.equals(other.id);
- }
-
- return false;
- }
-
- /**
- * @return an iterator for the entries
- */
- public Iterator iterator()
- {
- return entries.iterator();
- }
-
- /**
- * <p>
- * Remove an entry from this entity
- * </p>
- *
- * @param entry the entry to be removed
- *
- * @return whether the removal was successful
- */
- public boolean remove(ScheduleEntry entry)
- {
- return entries.remove(entry);
- }
-
- /**
- * @return the number of entries
- */
- public int size()
- {
- return entries.size();
- }
-}
-//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.Iterator;
+import java.util.TreeSet;
+
+import org.apache.myfaces.custom.schedule.util.ScheduleEntryComparator;
+
+
+/**
+ * <p>
+ * A Planner entity is a person, room, piece of equipment, ... that is displayed
+ * as a row in the planner component.
+ * </p>
+ *
+ * TODO this should be an interface, with a DefaultPlannerEntity implementation
+ *
+ * @author Jurgen Lust (latest modification by $Author$)
+ * @version $Revision$
+ */
+public class PlannerEntity
+ implements Serializable
+{
+ //~ Instance fields --------------------------------------------------------
+
+ private final String id;
+ private final String name;
+ private TreeSet entries;
+
+ //~ Constructors -----------------------------------------------------------
+
+ /**
+ * Creates a new PlannerEntity object.
+ *
+ * @param id the unique identifier
+ * @param name the name
+ */
+ public PlannerEntity(
+ String id,
+ String name
+ )
+ {
+ super();
+ this.id = id;
+ this.name = name;
+ this.entries = new TreeSet(new ScheduleEntryComparator());
+ }
+
+ //~ Methods ----------------------------------------------------------------
+
+ /**
+ * @return true if there are no appointments for this entity
+ */
+ public boolean isEmpty()
+ {
+ return entries.isEmpty();
+ }
+
+ /**
+ * @param entries The entries to set.
+ */
+ public void setEntries(TreeSet entries)
+ {
+ this.entries = entries;
+ }
+
+ /**
+ * @return Returns the entries.
+ */
+ public TreeSet getEntries()
+ {
+ return entries;
+ }
+
+ /**
+ * @return Returns the id.
+ */
+ public String getId()
+ {
+ return id;
+ }
+
+ /**
+ * @return Returns the name.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * <p>
+ * Add a schedule entry to this planner entity
+ * </p>
+ *
+ * @param entry the entry to be added
+ *
+ * @return whether the addition was successful
+ */
+ public boolean addEntry(ScheduleEntry entry)
+ {
+ if (
+ (entry == null) || (entry.getStartTime() == null) ||
+ (entry.getEndTime() == null)
+ ) {
+ return false;
+ }
+
+ entries.add(entry);
+
+ return true;
+ }
+
+ /**
+ * <p>
+ * Remove all entries
+ * </p>
+ */
+ public void clear()
+ {
+ entries.clear();
+ }
+
+ /**
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object o)
+ {
+ if (o instanceof PlannerEntity) {
+ PlannerEntity other = (PlannerEntity) o;
+
+ return id.equals(other.id);
+ }
+
+ return false;
+ }
+
+ /**
+ * @return an iterator for the entries
+ */
+ public Iterator iterator()
+ {
+ return entries.iterator();
+ }
+
+ /**
+ * <p>
+ * Remove an entry from this entity
+ * </p>
+ *
+ * @param entry the entry to be removed
+ *
+ * @return whether the removal was successful
+ */
+ public boolean remove(ScheduleEntry entry)
+ {
+ return entries.remove(entry);
+ }
+
+ /**
+ * @return the number of entries
+ */
+ public int size()
+ {
+ return entries.size();
+ }
+}
+//The End
Propchange: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/PlannerEntity.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/PlannerEntity.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/PlannerModel.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/PlannerModel.java?rev=349804&r1=349803&r2=349804&view=diff
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/PlannerModel.java (original)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/PlannerModel.java Tue Nov 29 12:12:53 2005
@@ -1,333 +1,333 @@
-/*
- * 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.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.TreeSet;
-
-
-/**
- * <p>
- * The model of a Planner component
- * </p>
- *
- * TODO this should be an interface, with a DefaultPlannerModel implementation
- *
- * @author Jurgen Lust (latest modification by $Author$)
- * @version $Revision$
- */
-public class PlannerModel
- implements Serializable
-{
- //~ Instance fields --------------------------------------------------------
-
- private HashMap entities;
- private TreeSet days;
-
- //~ Constructors -----------------------------------------------------------
-
- /**
- * Creates a new PlannerModel object.
- */
- public PlannerModel()
- {
- days = new TreeSet();
- entities = new HashMap();
- }
-
- //~ Methods ----------------------------------------------------------------
-
- /**
- * <p>
- * Set the day
- * </p>
- *
- * @param date the new day
- *
- * @return true if successful
- */
- public boolean setDay(Date date)
- {
- if (date == null) {
- return false;
- }
-
- days.clear();
- add(date);
-
- return true;
- }
-
- /**
- * <p>
- * Get the day at position <i>index</i>
- * </p>
- *
- * @param index the index
- *
- * @return the day
- */
- public Day getDay(int index)
- {
- Object[] dayArray = days.toArray();
-
- return (Day) dayArray[index];
- }
-
- /**
- * <p>
- * Get the entity at position <i>index</i>
- * </p>
- *
- * @param id the index
- *
- * @return the entity
- */
- public PlannerEntity getEntity(String id)
- {
- return (PlannerEntity) entities.get(id);
- }
-
- /**
- * <p>
- * Assign a special status to a day, e.g. a holiday
- * </p>
- *
- * @param date the date
- * @param isWorkingDay whether the day is a normal working day
- * @param specialDayName the name of the holiday
- *
- * @return true if successful
- */
- public boolean setSpecialDay(
- Date date,
- boolean isWorkingDay,
- String specialDayName
- )
- {
- if ((date == null) || !containsDate(date)) {
- return false;
- }
-
- for (Iterator dayIterator = dayIterator(); dayIterator.hasNext();) {
- Day day = (Day) dayIterator.next();
- day.setWorkingDay(isWorkingDay);
- day.setSpecialDayName(specialDayName);
- }
-
- return true;
- }
-
- /**
- * <p>
- * Add a day to the planner
- * </p>
- *
- * @param date the date that should be added
- * @param isWorkingDay whether the day is a normal working day
- * @param specialDayName the name of the holiday, if any
- *
- * @return the day that was added
- */
- public Day add(
- Date date,
- boolean isWorkingDay,
- String specialDayName
- )
- {
- if (date == null) {
- return null;
- }
-
- Day day = new Day(date);
- day.setWorkingDay(isWorkingDay);
- day.setSpecialDayName(specialDayName);
- days.add(day);
-
- return day;
- }
-
- /**
- * <p>
- * Add an entity to the planner
- * </p>
- *
- * @param entity the entity to add
- *
- * @return true if successful
- */
- public boolean add(PlannerEntity entity)
- {
- if ((entity == null) || entities.containsKey(entity.getId())) {
- return false;
- }
-
- entities.put(entity.getId(), entity);
-
- return true;
- }
-
- /**
- * <p>
- * Add an entity to the planner
- * </p>
- *
- * @param id the id of the entity
- * @param name the name of the entity
- *
- * @return the entity that was added
- */
- public PlannerEntity add(
- String id,
- String name
- )
- {
- PlannerEntity entity = new PlannerEntity(id, name);
-
- if (add(entity)) {
- return entity;
- }
-
- return null;
- }
-
- /**
- * <p>
- * Add a day to the planner
- * </p>
- *
- * @param day the day to add
- *
- * @return the day that was added
- */
- public Day add(Day day)
- {
- if (day != null) {
- days.add(day);
- }
-
- return day;
- }
-
- /**
- * <p>
- * Add a day to the planner
- * </p>
- *
- * @param date the day to add
- *
- * @return the day that was added
- */
- public Day add(Date date)
- {
- return add(date, true, null);
- }
-
- /**
- * <p>
- * Add a schedule entry to the planner
- * </p>
- *
- * @param entityId the id of the entity to which the entry applies
- * @param entry the entry to add
- *
- * @return true if successful
- */
- public boolean addEntry(
- String entityId,
- ScheduleEntry entry
- )
- {
- PlannerEntity entity = getEntity(entityId);
-
- if (entity == null) {
- return false;
- }
-
- return entity.addEntry(entry);
- }
-
- /**
- * <p>
- * Remove all days and all entities
- * </p>
- */
- public void clear()
- {
- days.clear();
- entities.clear();
- }
-
- /**
- * <p>
- * Check if the planner contains the specified date
- * </p>
- *
- * @param date the date to check
- *
- * @return true if successful
- */
- public boolean containsDate(Date date)
- {
- for (Iterator iterator = days.iterator(); iterator.hasNext();) {
- Day day = (Day) iterator.next();
-
- if (day.equalsDate(date)) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * @return an iterator for the days of the planner
- */
- public Iterator dayIterator()
- {
- return days.iterator();
- }
-
- /**
- * @return an iterator for the entities of the planner
- */
- public Iterator entityIterator()
- {
- return entities.values().iterator();
- }
-
- /**
- * @return the number of days that are shown in the planner
- */
- public int numberOfDays()
- {
- return days.size();
- }
-
- /**
- * @return the number of entities that are shown in the planner
- */
- public int numberOfEntities()
- {
- return entities.size();
- }
-}
-//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.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.TreeSet;
+
+
+/**
+ * <p>
+ * The model of a Planner component
+ * </p>
+ *
+ * TODO this should be an interface, with a DefaultPlannerModel implementation
+ *
+ * @author Jurgen Lust (latest modification by $Author$)
+ * @version $Revision$
+ */
+public class PlannerModel
+ implements Serializable
+{
+ //~ Instance fields --------------------------------------------------------
+
+ private HashMap entities;
+ private TreeSet days;
+
+ //~ Constructors -----------------------------------------------------------
+
+ /**
+ * Creates a new PlannerModel object.
+ */
+ public PlannerModel()
+ {
+ days = new TreeSet();
+ entities = new HashMap();
+ }
+
+ //~ Methods ----------------------------------------------------------------
+
+ /**
+ * <p>
+ * Set the day
+ * </p>
+ *
+ * @param date the new day
+ *
+ * @return true if successful
+ */
+ public boolean setDay(Date date)
+ {
+ if (date == null) {
+ return false;
+ }
+
+ days.clear();
+ add(date);
+
+ return true;
+ }
+
+ /**
+ * <p>
+ * Get the day at position <i>index</i>
+ * </p>
+ *
+ * @param index the index
+ *
+ * @return the day
+ */
+ public Day getDay(int index)
+ {
+ Object[] dayArray = days.toArray();
+
+ return (Day) dayArray[index];
+ }
+
+ /**
+ * <p>
+ * Get the entity at position <i>index</i>
+ * </p>
+ *
+ * @param id the index
+ *
+ * @return the entity
+ */
+ public PlannerEntity getEntity(String id)
+ {
+ return (PlannerEntity) entities.get(id);
+ }
+
+ /**
+ * <p>
+ * Assign a special status to a day, e.g. a holiday
+ * </p>
+ *
+ * @param date the date
+ * @param isWorkingDay whether the day is a normal working day
+ * @param specialDayName the name of the holiday
+ *
+ * @return true if successful
+ */
+ public boolean setSpecialDay(
+ Date date,
+ boolean isWorkingDay,
+ String specialDayName
+ )
+ {
+ if ((date == null) || !containsDate(date)) {
+ return false;
+ }
+
+ for (Iterator dayIterator = dayIterator(); dayIterator.hasNext();) {
+ Day day = (Day) dayIterator.next();
+ day.setWorkingDay(isWorkingDay);
+ day.setSpecialDayName(specialDayName);
+ }
+
+ return true;
+ }
+
+ /**
+ * <p>
+ * Add a day to the planner
+ * </p>
+ *
+ * @param date the date that should be added
+ * @param isWorkingDay whether the day is a normal working day
+ * @param specialDayName the name of the holiday, if any
+ *
+ * @return the day that was added
+ */
+ public Day add(
+ Date date,
+ boolean isWorkingDay,
+ String specialDayName
+ )
+ {
+ if (date == null) {
+ return null;
+ }
+
+ Day day = new Day(date);
+ day.setWorkingDay(isWorkingDay);
+ day.setSpecialDayName(specialDayName);
+ days.add(day);
+
+ return day;
+ }
+
+ /**
+ * <p>
+ * Add an entity to the planner
+ * </p>
+ *
+ * @param entity the entity to add
+ *
+ * @return true if successful
+ */
+ public boolean add(PlannerEntity entity)
+ {
+ if ((entity == null) || entities.containsKey(entity.getId())) {
+ return false;
+ }
+
+ entities.put(entity.getId(), entity);
+
+ return true;
+ }
+
+ /**
+ * <p>
+ * Add an entity to the planner
+ * </p>
+ *
+ * @param id the id of the entity
+ * @param name the name of the entity
+ *
+ * @return the entity that was added
+ */
+ public PlannerEntity add(
+ String id,
+ String name
+ )
+ {
+ PlannerEntity entity = new PlannerEntity(id, name);
+
+ if (add(entity)) {
+ return entity;
+ }
+
+ return null;
+ }
+
+ /**
+ * <p>
+ * Add a day to the planner
+ * </p>
+ *
+ * @param day the day to add
+ *
+ * @return the day that was added
+ */
+ public Day add(Day day)
+ {
+ if (day != null) {
+ days.add(day);
+ }
+
+ return day;
+ }
+
+ /**
+ * <p>
+ * Add a day to the planner
+ * </p>
+ *
+ * @param date the day to add
+ *
+ * @return the day that was added
+ */
+ public Day add(Date date)
+ {
+ return add(date, true, null);
+ }
+
+ /**
+ * <p>
+ * Add a schedule entry to the planner
+ * </p>
+ *
+ * @param entityId the id of the entity to which the entry applies
+ * @param entry the entry to add
+ *
+ * @return true if successful
+ */
+ public boolean addEntry(
+ String entityId,
+ ScheduleEntry entry
+ )
+ {
+ PlannerEntity entity = getEntity(entityId);
+
+ if (entity == null) {
+ return false;
+ }
+
+ return entity.addEntry(entry);
+ }
+
+ /**
+ * <p>
+ * Remove all days and all entities
+ * </p>
+ */
+ public void clear()
+ {
+ days.clear();
+ entities.clear();
+ }
+
+ /**
+ * <p>
+ * Check if the planner contains the specified date
+ * </p>
+ *
+ * @param date the date to check
+ *
+ * @return true if successful
+ */
+ public boolean containsDate(Date date)
+ {
+ for (Iterator iterator = days.iterator(); iterator.hasNext();) {
+ Day day = (Day) iterator.next();
+
+ if (day.equalsDate(date)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * @return an iterator for the days of the planner
+ */
+ public Iterator dayIterator()
+ {
+ return days.iterator();
+ }
+
+ /**
+ * @return an iterator for the entities of the planner
+ */
+ public Iterator entityIterator()
+ {
+ return entities.values().iterator();
+ }
+
+ /**
+ * @return the number of days that are shown in the planner
+ */
+ public int numberOfDays()
+ {
+ return days.size();
+ }
+
+ /**
+ * @return the number of entities that are shown in the planner
+ */
+ public int numberOfEntities()
+ {
+ return entities.size();
+ }
+}
+//The End
Propchange: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/PlannerModel.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/PlannerModel.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/ScheduleDay.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/ScheduleDay.java?rev=349804&r1=349803&r2=349804&view=diff
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/ScheduleDay.java (original)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/ScheduleDay.java Tue Nov 29 12:12:53 2005
@@ -1,152 +1,152 @@
-/*
- * 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$)
- * @version $Revision$
- */
-public class ScheduleDay
- extends Day
- implements Serializable, Comparable
-{
- //~ Instance fields --------------------------------------------------------
-
- 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();
- }
-}
-//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$)
+ * @version $Revision$
+ */
+public class ScheduleDay
+ extends Day
+ implements Serializable, Comparable
+{
+ //~ Instance fields --------------------------------------------------------
+
+ 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();
+ }
+}
+//The End
Propchange: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/ScheduleDay.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/ScheduleDay.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/ScheduleEntry.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/ScheduleEntry.java?rev=349804&r1=349803&r2=349804&view=diff
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/ScheduleEntry.java (original)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/ScheduleEntry.java Tue Nov 29 12:12:53 2005
@@ -1,64 +1,64 @@
-/*
- * 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.util.Date;
-
-
-/**
- * <p>
- * A schedule entry is an appointment or event.
- * </p>
- *
- * @author Jurgen Lust (latest modification by $Author$)
- * @version $Revision$
- */
-public interface ScheduleEntry
-{
- //~ Methods ----------------------------------------------------------------
-
- /**
- * @return Returns the description.
- */
- public abstract String getDescription();
-
- /**
- * @return Returns the endTime.
- */
- public abstract Date getEndTime();
-
- /**
- * @return Returns the id.
- */
- public abstract String getId();
-
- /**
- * @return Returns the startTime.
- */
- public abstract Date getStartTime();
-
- /**
- * @return Returns the subtitle.
- */
- public abstract String getSubtitle();
-
- /**
- * @return Returns the title.
- */
- public abstract String getTitle();
-}
-//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.util.Date;
+
+
+/**
+ * <p>
+ * A schedule entry is an appointment or event.
+ * </p>
+ *
+ * @author Jurgen Lust (latest modification by $Author$)
+ * @version $Revision$
+ */
+public interface ScheduleEntry
+{
+ //~ Methods ----------------------------------------------------------------
+
+ /**
+ * @return Returns the description.
+ */
+ public abstract String getDescription();
+
+ /**
+ * @return Returns the endTime.
+ */
+ public abstract Date getEndTime();
+
+ /**
+ * @return Returns the id.
+ */
+ public abstract String getId();
+
+ /**
+ * @return Returns the startTime.
+ */
+ public abstract Date getStartTime();
+
+ /**
+ * @return Returns the subtitle.
+ */
+ public abstract String getSubtitle();
+
+ /**
+ * @return Returns the title.
+ */
+ public abstract String getTitle();
+}
+//The End
Propchange: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/ScheduleEntry.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/ScheduleEntry.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/ScheduleModel.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/ScheduleModel.java?rev=349804&r1=349803&r2=349804&view=diff
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/ScheduleModel.java (original)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/ScheduleModel.java Tue Nov 29 12:12:53 2005
@@ -1,111 +1,111 @@
-/*
- * 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.util.Date;
-import java.util.Iterator;
-
-
-/**
- * <p>
- * The underlying model of the UISchedule component. You should implement this
- * interface when creating real implementations, which would typically be backed
- * by a database.
- * </p>
- *
- * @author Jurgen Lust (latest modification by $Author$)
- * @version $Revision$
- */
-public interface ScheduleModel
-{
- //~ Static fields/initializers ---------------------------------------------
-
- public static final int DAY = 0;
- public static final int WORKWEEK = 1;
- public static final int WEEK = 2;
- public static final int MONTH = 3;
-
- //~ Methods ----------------------------------------------------------------
-
- /**
- * @return true if there are no entries
- */
- public abstract boolean isEmpty();
-
- /**
- * @param mode the mode: DAY, WORKWEEK, WEEK or MONTH
- */
- public abstract void setMode(int mode);
-
- /**
- * @return the mode: DAY, WORKWEEK, WEEK or MONTH
- */
- public abstract int getMode();
-
- /**
- * @param date the date to select
- */
- public abstract void setSelectedDate(Date date);
-
- /**
- * @return the selected date
- */
- public abstract Date getSelectedDate();
-
- /**
- * @param selectedEntry the entry to select
- */
- public abstract void setSelectedEntry(ScheduleEntry selectedEntry);
-
- /**
- * @return the selected entry
- */
- public abstract ScheduleEntry getSelectedEntry();
-
- /**
- * <p>
- * Check if the schedule contains the specified date
- * </p>
- *
- * @param date the date to check
- *
- * @return whether the schedule containts this date
- */
- public abstract boolean containsDate(Date date);
-
- /**
- * <p>
- * Get the day at position <i>index</i>.
- * </p>
- *
- * @param index the index
- *
- * @return the day
- */
- public abstract Object get(int index);
-
- /**
- * @return an iterator for the days
- */
- public abstract Iterator iterator();
-
- /**
- * @return the number of days in this model
- */
- public abstract int size();
-}
-//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.util.Date;
+import java.util.Iterator;
+
+
+/**
+ * <p>
+ * The underlying model of the UISchedule component. You should implement this
+ * interface when creating real implementations, which would typically be backed
+ * by a database.
+ * </p>
+ *
+ * @author Jurgen Lust (latest modification by $Author$)
+ * @version $Revision$
+ */
+public interface ScheduleModel
+{
+ //~ Static fields/initializers ---------------------------------------------
+
+ public static final int DAY = 0;
+ public static final int WORKWEEK = 1;
+ public static final int WEEK = 2;
+ public static final int MONTH = 3;
+
+ //~ Methods ----------------------------------------------------------------
+
+ /**
+ * @return true if there are no entries
+ */
+ public abstract boolean isEmpty();
+
+ /**
+ * @param mode the mode: DAY, WORKWEEK, WEEK or MONTH
+ */
+ public abstract void setMode(int mode);
+
+ /**
+ * @return the mode: DAY, WORKWEEK, WEEK or MONTH
+ */
+ public abstract int getMode();
+
+ /**
+ * @param date the date to select
+ */
+ public abstract void setSelectedDate(Date date);
+
+ /**
+ * @return the selected date
+ */
+ public abstract Date getSelectedDate();
+
+ /**
+ * @param selectedEntry the entry to select
+ */
+ public abstract void setSelectedEntry(ScheduleEntry selectedEntry);
+
+ /**
+ * @return the selected entry
+ */
+ public abstract ScheduleEntry getSelectedEntry();
+
+ /**
+ * <p>
+ * Check if the schedule contains the specified date
+ * </p>
+ *
+ * @param date the date to check
+ *
+ * @return whether the schedule containts this date
+ */
+ public abstract boolean containsDate(Date date);
+
+ /**
+ * <p>
+ * Get the day at position <i>index</i>.
+ * </p>
+ *
+ * @param index the index
+ *
+ * @return the day
+ */
+ public abstract Object get(int index);
+
+ /**
+ * @return an iterator for the days
+ */
+ public abstract Iterator iterator();
+
+ /**
+ * @return the number of days in this model
+ */
+ public abstract int size();
+}
+//The End
Propchange: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/ScheduleModel.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/ScheduleModel.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/SimpleScheduleModel.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/SimpleScheduleModel.java?rev=349804&r1=349803&r2=349804&view=diff
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/SimpleScheduleModel.java (original)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/SimpleScheduleModel.java Tue Nov 29 12:12:53 2005
@@ -1,145 +1,145 @@
-/*
- * 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.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.TreeSet;
-
-import org.apache.myfaces.custom.schedule.util.ScheduleEntryComparator;
-
-/**
- * <p>
- * A simple implementation of the ScheduleModel, not backed by any kind of
- * datasource: entries have to be added manually.
- * </p>
- *
- * @author Jurgen Lust (latest modification by $Author$)
- * @version $Revision$
- */
-public class SimpleScheduleModel extends AbstractScheduleModel implements
- Serializable
-{
- //~ Instance fields --------------------------------------------------------
-
- private final TreeSet entries;
- private final HashMap holidays;
- private final DateFormat holidayFormat = new SimpleDateFormat("yyyyMMdd");
-
- //~ Constructors -----------------------------------------------------------
-
- /**
- * Creates a new SimpleScheduleModel object.
- */
- public SimpleScheduleModel()
- {
- this.entries = new TreeSet(new ScheduleEntryComparator());
- this.holidays = new HashMap();
- }
-
- //~ Methods ----------------------------------------------------------------
-
- /**
- * Set the name of a holiday.
- *
- * @param date the date
- * @param holidayName the name of the holiday
- */
- public void setHoliday(Date date, String holidayName)
- {
- if (date == null)
- {
- return;
- }
-
- String key = holidayFormat.format(date);
- holidays.put(key, holidayName);
- }
-
- /**
- * Add an entry to the model.
- *
- * @param entry the entry to add
- */
- public void addEntry(ScheduleEntry entry)
- {
- entries.add(entry);
- }
-
- /**
- * Remove an entry from the model.
- *
- * @param entry the entry to remove
- */
- public void removeEntry(ScheduleEntry entry)
- {
- entries.remove(entry);
- }
-
- /**
- * @see org.apache.myfaces.custom.schedule.model.AbstractScheduleModel#loadEntries(java.util.Date, java.util.Date)
- */
- protected Collection loadEntries(Date startDate, Date endDate)
- {
- ArrayList selection = new ArrayList();
-
- for (Iterator entryIterator = entries.iterator(); entryIterator
- .hasNext();)
- {
- ScheduleEntry entry = (ScheduleEntry) entryIterator.next();
-
- if (entry.getEndTime().before(startDate)
- || entry.getStartTime().after(endDate))
- {
- continue;
- }
-
- selection.add(entry);
- }
-
- return selection;
- }
-
- /**
- * @see org.apache.myfaces.custom.schedule.model.AbstractScheduleModel#loadDayAttributes(org.apache.myfaces.custom.schedule.model.Day)
- */
- protected void loadDayAttributes(Day day)
- {
- if (day == null)
- return;
- String key = holidayFormat.format(day.getDate());
- String holiday = (String) holidays.get(key);
- if (holiday != null)
- {
- day.setSpecialDayName(holiday);
- day.setWorkingDay(false);
- }
- else
- {
- day.setSpecialDayName(null);
- day.setWorkingDay(true);
- }
- }
-}
-//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.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.TreeSet;
+
+import org.apache.myfaces.custom.schedule.util.ScheduleEntryComparator;
+
+/**
+ * <p>
+ * A simple implementation of the ScheduleModel, not backed by any kind of
+ * datasource: entries have to be added manually.
+ * </p>
+ *
+ * @author Jurgen Lust (latest modification by $Author$)
+ * @version $Revision$
+ */
+public class SimpleScheduleModel extends AbstractScheduleModel implements
+ Serializable
+{
+ //~ Instance fields --------------------------------------------------------
+
+ private final TreeSet entries;
+ private final HashMap holidays;
+ private final DateFormat holidayFormat = new SimpleDateFormat("yyyyMMdd");
+
+ //~ Constructors -----------------------------------------------------------
+
+ /**
+ * Creates a new SimpleScheduleModel object.
+ */
+ public SimpleScheduleModel()
+ {
+ this.entries = new TreeSet(new ScheduleEntryComparator());
+ this.holidays = new HashMap();
+ }
+
+ //~ Methods ----------------------------------------------------------------
+
+ /**
+ * Set the name of a holiday.
+ *
+ * @param date the date
+ * @param holidayName the name of the holiday
+ */
+ public void setHoliday(Date date, String holidayName)
+ {
+ if (date == null)
+ {
+ return;
+ }
+
+ String key = holidayFormat.format(date);
+ holidays.put(key, holidayName);
+ }
+
+ /**
+ * Add an entry to the model.
+ *
+ * @param entry the entry to add
+ */
+ public void addEntry(ScheduleEntry entry)
+ {
+ entries.add(entry);
+ }
+
+ /**
+ * Remove an entry from the model.
+ *
+ * @param entry the entry to remove
+ */
+ public void removeEntry(ScheduleEntry entry)
+ {
+ entries.remove(entry);
+ }
+
+ /**
+ * @see org.apache.myfaces.custom.schedule.model.AbstractScheduleModel#loadEntries(java.util.Date, java.util.Date)
+ */
+ protected Collection loadEntries(Date startDate, Date endDate)
+ {
+ ArrayList selection = new ArrayList();
+
+ for (Iterator entryIterator = entries.iterator(); entryIterator
+ .hasNext();)
+ {
+ ScheduleEntry entry = (ScheduleEntry) entryIterator.next();
+
+ if (entry.getEndTime().before(startDate)
+ || entry.getStartTime().after(endDate))
+ {
+ continue;
+ }
+
+ selection.add(entry);
+ }
+
+ return selection;
+ }
+
+ /**
+ * @see org.apache.myfaces.custom.schedule.model.AbstractScheduleModel#loadDayAttributes(org.apache.myfaces.custom.schedule.model.Day)
+ */
+ protected void loadDayAttributes(Day day)
+ {
+ if (day == null)
+ return;
+ String key = holidayFormat.format(day.getDate());
+ String holiday = (String) holidays.get(key);
+ if (holiday != null)
+ {
+ day.setSpecialDayName(holiday);
+ day.setWorkingDay(false);
+ }
+ else
+ {
+ day.setSpecialDayName(null);
+ day.setWorkingDay(true);
+ }
+ }
+}
+//The End
Propchange: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/SimpleScheduleModel.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/model/SimpleScheduleModel.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/renderer/AbstractCompactScheduleRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/renderer/AbstractCompactScheduleRenderer.java?rev=349804&r1=349803&r2=349804&view=diff
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/renderer/AbstractCompactScheduleRenderer.java (original)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/renderer/AbstractCompactScheduleRenderer.java Tue Nov 29 12:12:53 2005
@@ -1,334 +1,334 @@
-/*
- * 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.renderer;
-
-import java.io.IOException;
-import java.text.DateFormat;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TreeSet;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIForm;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.apache.myfaces.custom.schedule.HtmlSchedule;
-import org.apache.myfaces.custom.schedule.model.Day;
-import org.apache.myfaces.custom.schedule.model.ScheduleDay;
-import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
-import org.apache.myfaces.renderkit.html.HTML;
-
-/**
- * <p>
- * Abstract superclass for the week and month view renderers.
- * </p>
- *
- * @author Jurgen Lust (latest modification by $Author$)
- * @author Bruno Aranda (adaptation of Jurgen's code to myfaces)
- * @version $Revision$
- */
-public abstract class AbstractCompactScheduleRenderer extends
- AbstractScheduleRenderer
-{
- //~ Methods ----------------------------------------------------------------
-
- /**
- * @see javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext,
- * javax.faces.component.UIComponent)
- */
- public void encodeChildren(FacesContext context, UIComponent component)
- throws IOException
- {
- //the children are rendered in the encodeBegin phase
- }
-
- /**
- * @see javax.faces.render.Renderer#encodeEnd(javax.faces.context.FacesContext,
- * javax.faces.component.UIComponent)
- */
- public void encodeEnd(FacesContext context, UIComponent component)
- throws IOException
- {
- //all rendering is done in the begin phase
- }
-
- /**
- * @return The default height, in pixels, of one row in the schedule grid
- */
- protected abstract int getDefaultRowHeight();
-
- /**
- * @return The name of the property that determines the row height
- */
- protected abstract String getRowHeightProperty();
-
- /**
- * @param attributes The attributes
- *
- * @return The row height, in pixels
- */
- protected int getRowHeight(Map attributes)
- {
- int rowHeight = 0;
-
- try
- {
- rowHeight = Integer.valueOf(
- (String) attributes.get(getRowHeightProperty())).intValue();
- }
- catch (Exception e)
- {
- rowHeight = 0;
- }
-
- if (rowHeight <= 0)
- {
- rowHeight = getDefaultRowHeight();
- }
-
- return rowHeight;
- }
-
- /**
- * <p>
- * Draw one day in the schedule
- * </p>
- *
- * @param context the FacesContext
- * @param writer the ResponseWriter
- * @param schedule the schedule
- * @param day the day that should be drawn
- * @param cellWidth the width of the cell
- * @param dayOfWeek the day of the week
- * @param dayOfMonth the day of the month
- * @param isWeekend is it a weekend day?
- * @param isCurrentMonth is the day in the currently selected month?
- * @param rowspan the rowspan for the table cell
- *
- * @throws IOException when the cell could not be drawn
- */
- protected void writeDayCell(FacesContext context, ResponseWriter writer,
- HtmlSchedule schedule, ScheduleDay day, float cellWidth,
- int dayOfWeek, int dayOfMonth, boolean isWeekend,
- boolean isCurrentMonth, int rowspan) throws IOException
- {
- Map attributes = schedule.getAttributes();
- writer.startElement(HTML.TD_ELEM, schedule);
-
- writer.writeAttribute("rowspan", String.valueOf(rowspan), null);
-
- writer.writeAttribute(HTML.CLASS_ATTR, isCurrentMonth ? "day"
- : "inactive-day", null);
-
- //determine the height of the day in pixels
- StringBuffer styleBuffer = new StringBuffer();
- styleBuffer.append("height: ");
-
- int myRowHeight = 0;
- int myContentHeight = 0;
-
- if (isWeekend)
- {
- myRowHeight = getRowHeight(attributes) / 2;
- myContentHeight = myRowHeight - 19;
- }
- else
- {
- myRowHeight = getRowHeight(attributes) + 1; //need to add 1 to get the weekends right
- myContentHeight = myRowHeight - 18; //18 instead of 19, to get the weekends right
- }
-
- styleBuffer.append(myRowHeight);
- styleBuffer.append("px;");
-
- writer.writeAttribute(HTML.STYLE_ATTR, styleBuffer.toString()
- + " width: " + cellWidth + "%;", null);
-
- writer.startElement(HTML.TABLE_ELEM, schedule);
-
- writer.writeAttribute(HTML.CLASS_ATTR, "day", null);
- writer.writeAttribute(HTML.STYLE_ATTR, styleBuffer.toString()
- + " width: 100%;", null);
-
- writer.writeAttribute(HTML.CELLPADDING_ATTR, "0", null);
- writer.writeAttribute(HTML.CELLSPACING_ATTR, "0", null);
-
- //day header
- writer.startElement(HTML.TR_ELEM, schedule);
- writer.startElement(HTML.TD_ELEM, schedule);
- writer.writeAttribute(HTML.CLASS_ATTR, "header", null);
- writer.writeAttribute(HTML.STYLE_ATTR,
- "height: 18px; width: 100%; overflow: hidden", null);
- writer.writeText(getDateString(context, schedule, day.getDate()), null);
- writer.endElement(HTML.TD_ELEM);
- writer.endElement(HTML.TR_ELEM);
-
- //day content
- writer.startElement(HTML.TR_ELEM, schedule);
- writer.startElement(HTML.TD_ELEM, schedule);
-
- writer.writeAttribute(HTML.CLASS_ATTR, "content", null);
-
- //determine the height of the day content in pixels
- StringBuffer contentStyleBuffer = new StringBuffer();
- contentStyleBuffer.append("height: ");
- contentStyleBuffer.append(myContentHeight);
- contentStyleBuffer.append("px; width: 100%;");
- writer.writeAttribute(HTML.STYLE_ATTR, contentStyleBuffer.toString(),
- null);
-
- writer.startElement(HTML.DIV_ELEM, schedule);
- writer
- .writeAttribute(
- HTML.STYLE_ATTR,
- "width: 100%; height: 100%; overflow: auto; vertical-align: top;",
- null);
- writer.startElement(HTML.TABLE_ELEM, schedule);
- writer.writeAttribute(HTML.STYLE_ATTR, "width: 100%;", null);
-
- writeEntries(context, schedule, day, writer);
-
- writer.endElement(HTML.TABLE_ELEM);
- writer.endElement(HTML.DIV_ELEM);
- writer.endElement(HTML.TD_ELEM);
- writer.endElement(HTML.TR_ELEM);
- writer.endElement(HTML.TABLE_ELEM);
- writer.endElement(HTML.TD_ELEM);
- }
-
- /**
- * <p>
- * Draw the schedule entries in the specified day cell
- * </p>
- *
- * @param context the FacesContext
- * @param schedule the schedule
- * @param day the day
- * @param writer the ResponseWriter
- *
- * @throws IOException when the entries could not be drawn
- */
- protected void writeEntries(FacesContext context, HtmlSchedule schedule,
- ScheduleDay day, ResponseWriter writer) throws IOException
- {
- UIForm parentForm = getParentForm(schedule);
- TreeSet entrySet = new TreeSet(comparator);
-
- for (Iterator entryIterator = day.iterator(); entryIterator.hasNext();)
- {
- ScheduleEntry entry = (ScheduleEntry) entryIterator.next();
- entrySet.add(entry);
- }
-
- for (Iterator entryIterator = entrySet.iterator(); entryIterator
- .hasNext();)
- {
- ScheduleEntry entry = (ScheduleEntry) entryIterator.next();
- writer.startElement(HTML.TR_ELEM, schedule);
- writer.startElement(HTML.TD_ELEM, schedule);
-
- if (isSelected(schedule, entry))
- {
- writer.writeAttribute(HTML.CLASS_ATTR, "selected", null);
- }
-
- writer.writeAttribute(HTML.STYLE_ATTR, "width: 100%", null);
-
- //draw the tooltip
- if (showTooltip(schedule))
- {
- writer.writeAttribute("onmouseover", getTooltipText(entry,
- schedule), null);
- }
-
- if (!isSelected(schedule, entry) && !schedule.isReadonly())
- {
- writer.startElement("a", schedule);
- writer.writeAttribute("href", "#", null);
-
- String clientId = schedule.getClientId(context);
- StringBuffer mousedown = new StringBuffer();
- mousedown.append("document.forms['");
- mousedown.append(parentForm.getClientId(context));
- mousedown.append("']['");
- mousedown.append(clientId);
- mousedown.append("'].value='");
- mousedown.append(entry.getId());
- mousedown.append("'; document.forms['");
- mousedown.append(parentForm.getClientId(context));
- mousedown.append("'].submit()");
- writer
- .writeAttribute("onmousedown", mousedown.toString(),
- null);
- }
-
- writer.writeText(getEntryText(day, entry), null);
-
- if (!isSelected(schedule, entry) && !schedule.isReadonly())
- {
- writer.endElement("a");
- }
-
- writer.endElement(HTML.TD_ELEM);
- writer.endElement(HTML.TR_ELEM);
- }
- }
-
- private String getEntryText(Day day, ScheduleEntry entry)
- {
- StringBuffer text = new StringBuffer();
- Date startTime = entry.getStartTime();
-
- if (day.getDayStart().after(entry.getStartTime()))
- {
- startTime = day.getDayStart();
- }
-
- Date endTime = entry.getEndTime();
-
- if (day.getDayEnd().before(entry.getEndTime()))
- {
- endTime = day.getDayEnd();
- }
-
- DateFormat format = DateFormat.getTimeInstance(DateFormat.SHORT);
- text.append(format.format(startTime));
- text.append("-");
- text.append(format.format(endTime));
- text.append(": ");
- text.append(entry.getTitle());
-
- String returnString = text.toString();
-
- return returnString;
- }
-
- private boolean isSelected(HtmlSchedule schedule, ScheduleEntry entry)
- {
- ScheduleEntry selectedEntry = schedule.getModel().getSelectedEntry();
-
- if (selectedEntry == null)
- {
- return false;
- }
-
- return selectedEntry.getId().equals(entry.getId());
- }
-}
-//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.renderer;
+
+import java.io.IOException;
+import java.text.DateFormat;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeSet;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.apache.myfaces.custom.schedule.HtmlSchedule;
+import org.apache.myfaces.custom.schedule.model.Day;
+import org.apache.myfaces.custom.schedule.model.ScheduleDay;
+import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
+import org.apache.myfaces.renderkit.html.HTML;
+
+/**
+ * <p>
+ * Abstract superclass for the week and month view renderers.
+ * </p>
+ *
+ * @author Jurgen Lust (latest modification by $Author$)
+ * @author Bruno Aranda (adaptation of Jurgen's code to myfaces)
+ * @version $Revision$
+ */
+public abstract class AbstractCompactScheduleRenderer extends
+ AbstractScheduleRenderer
+{
+ //~ Methods ----------------------------------------------------------------
+
+ /**
+ * @see javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext,
+ * javax.faces.component.UIComponent)
+ */
+ public void encodeChildren(FacesContext context, UIComponent component)
+ throws IOException
+ {
+ //the children are rendered in the encodeBegin phase
+ }
+
+ /**
+ * @see javax.faces.render.Renderer#encodeEnd(javax.faces.context.FacesContext,
+ * javax.faces.component.UIComponent)
+ */
+ public void encodeEnd(FacesContext context, UIComponent component)
+ throws IOException
+ {
+ //all rendering is done in the begin phase
+ }
+
+ /**
+ * @return The default height, in pixels, of one row in the schedule grid
+ */
+ protected abstract int getDefaultRowHeight();
+
+ /**
+ * @return The name of the property that determines the row height
+ */
+ protected abstract String getRowHeightProperty();
+
+ /**
+ * @param attributes The attributes
+ *
+ * @return The row height, in pixels
+ */
+ protected int getRowHeight(Map attributes)
+ {
+ int rowHeight = 0;
+
+ try
+ {
+ rowHeight = Integer.valueOf(
+ (String) attributes.get(getRowHeightProperty())).intValue();
+ }
+ catch (Exception e)
+ {
+ rowHeight = 0;
+ }
+
+ if (rowHeight <= 0)
+ {
+ rowHeight = getDefaultRowHeight();
+ }
+
+ return rowHeight;
+ }
+
+ /**
+ * <p>
+ * Draw one day in the schedule
+ * </p>
+ *
+ * @param context the FacesContext
+ * @param writer the ResponseWriter
+ * @param schedule the schedule
+ * @param day the day that should be drawn
+ * @param cellWidth the width of the cell
+ * @param dayOfWeek the day of the week
+ * @param dayOfMonth the day of the month
+ * @param isWeekend is it a weekend day?
+ * @param isCurrentMonth is the day in the currently selected month?
+ * @param rowspan the rowspan for the table cell
+ *
+ * @throws IOException when the cell could not be drawn
+ */
+ protected void writeDayCell(FacesContext context, ResponseWriter writer,
+ HtmlSchedule schedule, ScheduleDay day, float cellWidth,
+ int dayOfWeek, int dayOfMonth, boolean isWeekend,
+ boolean isCurrentMonth, int rowspan) throws IOException
+ {
+ Map attributes = schedule.getAttributes();
+ writer.startElement(HTML.TD_ELEM, schedule);
+
+ writer.writeAttribute("rowspan", String.valueOf(rowspan), null);
+
+ writer.writeAttribute(HTML.CLASS_ATTR, isCurrentMonth ? "day"
+ : "inactive-day", null);
+
+ //determine the height of the day in pixels
+ StringBuffer styleBuffer = new StringBuffer();
+ styleBuffer.append("height: ");
+
+ int myRowHeight = 0;
+ int myContentHeight = 0;
+
+ if (isWeekend)
+ {
+ myRowHeight = getRowHeight(attributes) / 2;
+ myContentHeight = myRowHeight - 19;
+ }
+ else
+ {
+ myRowHeight = getRowHeight(attributes) + 1; //need to add 1 to get the weekends right
+ myContentHeight = myRowHeight - 18; //18 instead of 19, to get the weekends right
+ }
+
+ styleBuffer.append(myRowHeight);
+ styleBuffer.append("px;");
+
+ writer.writeAttribute(HTML.STYLE_ATTR, styleBuffer.toString()
+ + " width: " + cellWidth + "%;", null);
+
+ writer.startElement(HTML.TABLE_ELEM, schedule);
+
+ writer.writeAttribute(HTML.CLASS_ATTR, "day", null);
+ writer.writeAttribute(HTML.STYLE_ATTR, styleBuffer.toString()
+ + " width: 100%;", null);
+
+ writer.writeAttribute(HTML.CELLPADDING_ATTR, "0", null);
+ writer.writeAttribute(HTML.CELLSPACING_ATTR, "0", null);
+
+ //day header
+ writer.startElement(HTML.TR_ELEM, schedule);
+ writer.startElement(HTML.TD_ELEM, schedule);
+ writer.writeAttribute(HTML.CLASS_ATTR, "header", null);
+ writer.writeAttribute(HTML.STYLE_ATTR,
+ "height: 18px; width: 100%; overflow: hidden", null);
+ writer.writeText(getDateString(context, schedule, day.getDate()), null);
+ writer.endElement(HTML.TD_ELEM);
+ writer.endElement(HTML.TR_ELEM);
+
+ //day content
+ writer.startElement(HTML.TR_ELEM, schedule);
+ writer.startElement(HTML.TD_ELEM, schedule);
+
+ writer.writeAttribute(HTML.CLASS_ATTR, "content", null);
+
+ //determine the height of the day content in pixels
+ StringBuffer contentStyleBuffer = new StringBuffer();
+ contentStyleBuffer.append("height: ");
+ contentStyleBuffer.append(myContentHeight);
+ contentStyleBuffer.append("px; width: 100%;");
+ writer.writeAttribute(HTML.STYLE_ATTR, contentStyleBuffer.toString(),
+ null);
+
+ writer.startElement(HTML.DIV_ELEM, schedule);
+ writer
+ .writeAttribute(
+ HTML.STYLE_ATTR,
+ "width: 100%; height: 100%; overflow: auto; vertical-align: top;",
+ null);
+ writer.startElement(HTML.TABLE_ELEM, schedule);
+ writer.writeAttribute(HTML.STYLE_ATTR, "width: 100%;", null);
+
+ writeEntries(context, schedule, day, writer);
+
+ writer.endElement(HTML.TABLE_ELEM);
+ writer.endElement(HTML.DIV_ELEM);
+ writer.endElement(HTML.TD_ELEM);
+ writer.endElement(HTML.TR_ELEM);
+ writer.endElement(HTML.TABLE_ELEM);
+ writer.endElement(HTML.TD_ELEM);
+ }
+
+ /**
+ * <p>
+ * Draw the schedule entries in the specified day cell
+ * </p>
+ *
+ * @param context the FacesContext
+ * @param schedule the schedule
+ * @param day the day
+ * @param writer the ResponseWriter
+ *
+ * @throws IOException when the entries could not be drawn
+ */
+ protected void writeEntries(FacesContext context, HtmlSchedule schedule,
+ ScheduleDay day, ResponseWriter writer) throws IOException
+ {
+ UIForm parentForm = getParentForm(schedule);
+ TreeSet entrySet = new TreeSet(comparator);
+
+ for (Iterator entryIterator = day.iterator(); entryIterator.hasNext();)
+ {
+ ScheduleEntry entry = (ScheduleEntry) entryIterator.next();
+ entrySet.add(entry);
+ }
+
+ for (Iterator entryIterator = entrySet.iterator(); entryIterator
+ .hasNext();)
+ {
+ ScheduleEntry entry = (ScheduleEntry) entryIterator.next();
+ writer.startElement(HTML.TR_ELEM, schedule);
+ writer.startElement(HTML.TD_ELEM, schedule);
+
+ if (isSelected(schedule, entry))
+ {
+ writer.writeAttribute(HTML.CLASS_ATTR, "selected", null);
+ }
+
+ writer.writeAttribute(HTML.STYLE_ATTR, "width: 100%", null);
+
+ //draw the tooltip
+ if (showTooltip(schedule))
+ {
+ writer.writeAttribute("onmouseover", getTooltipText(entry,
+ schedule), null);
+ }
+
+ if (!isSelected(schedule, entry) && !schedule.isReadonly())
+ {
+ writer.startElement("a", schedule);
+ writer.writeAttribute("href", "#", null);
+
+ String clientId = schedule.getClientId(context);
+ StringBuffer mousedown = new StringBuffer();
+ mousedown.append("document.forms['");
+ mousedown.append(parentForm.getClientId(context));
+ mousedown.append("']['");
+ mousedown.append(clientId);
+ mousedown.append("'].value='");
+ mousedown.append(entry.getId());
+ mousedown.append("'; document.forms['");
+ mousedown.append(parentForm.getClientId(context));
+ mousedown.append("'].submit()");
+ writer
+ .writeAttribute("onmousedown", mousedown.toString(),
+ null);
+ }
+
+ writer.writeText(getEntryText(day, entry), null);
+
+ if (!isSelected(schedule, entry) && !schedule.isReadonly())
+ {
+ writer.endElement("a");
+ }
+
+ writer.endElement(HTML.TD_ELEM);
+ writer.endElement(HTML.TR_ELEM);
+ }
+ }
+
+ private String getEntryText(Day day, ScheduleEntry entry)
+ {
+ StringBuffer text = new StringBuffer();
+ Date startTime = entry.getStartTime();
+
+ if (day.getDayStart().after(entry.getStartTime()))
+ {
+ startTime = day.getDayStart();
+ }
+
+ Date endTime = entry.getEndTime();
+
+ if (day.getDayEnd().before(entry.getEndTime()))
+ {
+ endTime = day.getDayEnd();
+ }
+
+ DateFormat format = DateFormat.getTimeInstance(DateFormat.SHORT);
+ text.append(format.format(startTime));
+ text.append("-");
+ text.append(format.format(endTime));
+ text.append(": ");
+ text.append(entry.getTitle());
+
+ String returnString = text.toString();
+
+ return returnString;
+ }
+
+ private boolean isSelected(HtmlSchedule schedule, ScheduleEntry entry)
+ {
+ ScheduleEntry selectedEntry = schedule.getModel().getSelectedEntry();
+
+ if (selectedEntry == null)
+ {
+ return false;
+ }
+
+ return selectedEntry.getId().equals(entry.getId());
+ }
+}
+//The End
Propchange: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/renderer/AbstractCompactScheduleRenderer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/schedule/renderer/AbstractCompactScheduleRenderer.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL