Author: amarkhel
Date: 2010-10-29 07:48:42 -0400 (Fri, 29 Oct 2010)
New Revision: 19760
Added:
trunk/ui/calendar/
trunk/ui/calendar/api/pom.xml
trunk/ui/calendar/api/src/main/java/org/richfaces/event/CurrentDateChangeEvent.java
trunk/ui/calendar/api/src/main/java/org/richfaces/event/CurrentDateChangeListener.java
trunk/ui/calendar/api/src/main/java/org/richfaces/model/CalendarDataModel.java
trunk/ui/calendar/api/src/main/java/org/richfaces/model/CalendarDataModelItem.java
trunk/ui/calendar/pom.xml
trunk/ui/calendar/ui/
trunk/ui/calendar/ui/pom.xml
trunk/ui/calendar/ui/src/main/java/org/richfaces/component/AbstractCalendar.java
trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarIcon.java
trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarSeparator.java
trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/DisabledCalendarIcon.java
trunk/ui/calendar/ui/src/main/java/org/richfaces/taglib/CalendarHandler.java
trunk/ui/calendar/ui/src/main/java/org/richfaces/taglib/MethodExpressionCurrentDateChangeListener.java
Removed:
trunk/ui/calendar/api/src/main/java/org/richfaces/event/CurrentDateChangeEvent.java
trunk/ui/calendar/api/src/main/java/org/richfaces/event/CurrentDateChangeListener.java
trunk/ui/calendar/api/src/main/java/org/richfaces/model/CalendarDataModel.java
trunk/ui/calendar/api/src/main/java/org/richfaces/model/CalendarDataModelItem.java
trunk/ui/calendar/pom.xml
trunk/ui/calendar/ui/
trunk/ui/calendar/ui/pom.xml
trunk/ui/calendar/ui/src/main/java/org/richfaces/component/AbstractCalendar.java
trunk/ui/calendar/ui/src/main/java/org/richfaces/events/
trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarIcon.java
trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarSeparator.java
trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/DisabledCalendarIcon.java
trunk/ui/calendar/ui/src/main/java/org/richfaces/taglib/CalendarHandler.java
trunk/ui/calendar/ui/src/main/java/org/richfaces/taglib/MethodExpressionCurrentDateChangeListener.java
Log:
moved from sandbox
Copied: trunk/ui/calendar (from rev 19724, sandbox/trunk/ui/calendar)
Copied: trunk/ui/calendar/api/pom.xml (from rev 19758,
sandbox/trunk/ui/calendar/api/pom.xml)
===================================================================
--- trunk/ui/calendar/api/pom.xml (rev 0)
+++ trunk/ui/calendar/api/pom.xml 2010-10-29 11:48:42 UTC (rev 19760)
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ JBoss, Home of Professional Open Source Copyright 2010, Red Hat,
+ Inc. and individual contributors by the @authors tag. See the
+ copyright.txt in the distribution for a full listing of
+ individual contributors. This is free software; you can
+ redistribute it and/or modify it under the terms of the GNU
+ Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1 of the License, or (at your
+ option) any later version. This software is distributed in the
+ hope that it will be useful, but WITHOUT ANY WARRANTY; without
+ even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ for more details. You should have received a copy of the GNU
+ Lesser General Public License along with this software; if not,
+ write to the Free Software Foundation, Inc., 51 Franklin St,
+ Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF site:
+
http://www.fsf.org.
+-->
+
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>richfaces-ui-parent</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.richfaces.ui.calendar</groupId>
+ <artifactId>richfaces-ui-calendar-api</artifactId>
+ <name>Richfaces UI Components: Calendar API</name>
+ <packaging>jar</packaging>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>maven-cdk-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <!-- runtime -->
+ <dependency>
+ <groupId>org.richfaces.core</groupId>
+ <artifactId>richfaces-core-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.ui.common</groupId>
+ <artifactId>richfaces-ui-common-api</artifactId>
+ </dependency>
+ </dependencies>
+</project>
Deleted:
trunk/ui/calendar/api/src/main/java/org/richfaces/event/CurrentDateChangeEvent.java
===================================================================
---
sandbox/trunk/ui/calendar/api/src/main/java/org/richfaces/event/CurrentDateChangeEvent.java 2010-10-28
12:08:05 UTC (rev 19724)
+++
trunk/ui/calendar/api/src/main/java/org/richfaces/event/CurrentDateChangeEvent.java 2010-10-29
11:48:42 UTC (rev 19760)
@@ -1,69 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.event;
-
-import java.util.Date;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.FacesListener;
-
-public class CurrentDateChangeEvent extends FacesEvent {
-
-
- private static final long serialVersionUID = -8169207286087810907L;
- private Date currentDate = null;
- private String currentDateString = null;
-
- @Deprecated
- public CurrentDateChangeEvent(UIComponent component, Date curentDate) {
- super(component);
- this.currentDate = curentDate;
-
- }
-
- public CurrentDateChangeEvent(UIComponent component, String curentDateString) {
- super(component);
- this.currentDateString = curentDateString;
- }
-
- public boolean isAppropriateListener(FacesListener listener) {
- return false;
- }
-
- public void processListener(FacesListener listener) {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException();
- }
-
- public Date getCurrentDate() {
- return currentDate;
- }
-
- public void setCurrentDate(Date currentDate) {
- this.currentDate = currentDate;
- }
-
- public String getCurrentDateString() {
- return currentDateString;
- }
-
-}
Copied:
trunk/ui/calendar/api/src/main/java/org/richfaces/event/CurrentDateChangeEvent.java (from
rev 19756,
sandbox/trunk/ui/calendar/api/src/main/java/org/richfaces/event/CurrentDateChangeEvent.java)
===================================================================
--- trunk/ui/calendar/api/src/main/java/org/richfaces/event/CurrentDateChangeEvent.java
(rev 0)
+++
trunk/ui/calendar/api/src/main/java/org/richfaces/event/CurrentDateChangeEvent.java 2010-10-29
11:48:42 UTC (rev 19760)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.event;
+
+import java.util.Date;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+/**
+ * @author amarkhel
+ *
+ */
+public class CurrentDateChangeEvent extends FacesEvent {
+
+ private static final long serialVersionUID = -8169207286087810907L;
+ private Date currentDate = null;
+ private String currentDateString = null;
+
+ public CurrentDateChangeEvent(UIComponent component, String curentDateString) {
+ super(component);
+ this.currentDateString = curentDateString;
+ }
+
+ public boolean isAppropriateListener(FacesListener listener) {
+ return (listener instanceof CurrentDateChangeListener);
+ }
+
+ public void processListener(FacesListener listener) {
+ ((CurrentDateChangeListener)listener).processCurrentDateChange(this);
+ }
+
+ public Date getCurrentDate() {
+ return currentDate;
+ }
+
+ public void setCurrentDate(Date currentDate) {
+ this.currentDate = currentDate;
+ }
+
+ public String getCurrentDateString() {
+ return currentDateString;
+ }
+
+}
Deleted:
trunk/ui/calendar/api/src/main/java/org/richfaces/event/CurrentDateChangeListener.java
===================================================================
---
sandbox/trunk/ui/calendar/api/src/main/java/org/richfaces/event/CurrentDateChangeListener.java 2010-10-28
12:08:05 UTC (rev 19724)
+++
trunk/ui/calendar/api/src/main/java/org/richfaces/event/CurrentDateChangeListener.java 2010-10-29
11:48:42 UTC (rev 19760)
@@ -1,36 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.event.FacesListener;
-
-/**
- * @author Alexej Kushunin - akushunin(a)exadel.com
- * created 28.08.2007
- *
- * Base calendar events interface
- */
-public interface CurrentDateChangeListener extends FacesListener {
-
- public void processCurrentDateChange(CurrentDateChangeEvent event);
-
-}
\ No newline at end of file
Copied:
trunk/ui/calendar/api/src/main/java/org/richfaces/event/CurrentDateChangeListener.java
(from rev 19756,
sandbox/trunk/ui/calendar/api/src/main/java/org/richfaces/event/CurrentDateChangeListener.java)
===================================================================
---
trunk/ui/calendar/api/src/main/java/org/richfaces/event/CurrentDateChangeListener.java
(rev 0)
+++
trunk/ui/calendar/api/src/main/java/org/richfaces/event/CurrentDateChangeListener.java 2010-10-29
11:48:42 UTC (rev 19760)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.event;
+
+import javax.faces.event.FacesListener;
+
+/**
+ * @author Alexej Kushunin - akushunin(a)exadel.com
+ *
+ */
+public interface CurrentDateChangeListener extends FacesListener {
+
+ public void processCurrentDateChange(CurrentDateChangeEvent event);
+
+}
\ No newline at end of file
Deleted: trunk/ui/calendar/api/src/main/java/org/richfaces/model/CalendarDataModel.java
===================================================================
---
sandbox/trunk/ui/calendar/api/src/main/java/org/richfaces/model/CalendarDataModel.java 2010-10-28
12:08:05 UTC (rev 19724)
+++
trunk/ui/calendar/api/src/main/java/org/richfaces/model/CalendarDataModel.java 2010-10-29
11:48:42 UTC (rev 19760)
@@ -1,44 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-
-import java.util.Date;
-/**
- * @author Alexej Kushunin
- * created 19.06.2007
- *
- */
-public interface CalendarDataModel {
-
- /**
- * @return array of CalendarDataModelItems for selected dates.
- * This method will be called every time when components will need next block of
CalendarDataItems.
- * That may happens when calendar rendered, or when user navigate to next(previous)
month or in any other case when calendar renders.
- * This method will be called in Ajax mode when Calendar renders new page.
- * */
- public CalendarDataModelItem[] getData(Date[] dateArray);
-
- /**
- * @return tool tip when it's used in "single" mode
- * This method used when tool tips are displayed in "single" mode
- * */
- public Object getToolTip(Date date);
-}
Copied: trunk/ui/calendar/api/src/main/java/org/richfaces/model/CalendarDataModel.java
(from rev 19755,
sandbox/trunk/ui/calendar/api/src/main/java/org/richfaces/model/CalendarDataModel.java)
===================================================================
--- trunk/ui/calendar/api/src/main/java/org/richfaces/model/CalendarDataModel.java
(rev 0)
+++
trunk/ui/calendar/api/src/main/java/org/richfaces/model/CalendarDataModel.java 2010-10-29
11:48:42 UTC (rev 19760)
@@ -0,0 +1,46 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+
+import java.util.Date;
+
+/**
+ * @author Alexej Kushunin created 19.06.2007
+ *
+ */
+public interface CalendarDataModel {
+
+ /**
+ * @return array of CalendarDataModelItems for selected dates. This method
+ * will be called every time when components will need next block of
+ * CalendarDataItems. That may happens when calendar rendered, or
+ * when user navigate to next(previous) month or in any other case
+ * when calendar renders. This method will be called in Ajax mode
+ * when Calendar renders new page.
+ * */
+ public CalendarDataModelItem[] getData(Date[] dateArray);
+
+ /**
+ * @return tool tip when it's used in "single" mode This method used
when
+ * tool tips are displayed in "single" mode
+ * */
+ public Object getToolTip(Date date);
+}
Deleted:
trunk/ui/calendar/api/src/main/java/org/richfaces/model/CalendarDataModelItem.java
===================================================================
---
sandbox/trunk/ui/calendar/api/src/main/java/org/richfaces/model/CalendarDataModelItem.java 2010-10-28
12:08:05 UTC (rev 19724)
+++
trunk/ui/calendar/api/src/main/java/org/richfaces/model/CalendarDataModelItem.java 2010-10-29
11:48:42 UTC (rev 19760)
@@ -1,68 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-
-
-
-/**
- * @author Alexej Kushunin
- * created 19.06.2007
- *
- */
-
-public interface CalendarDataModelItem {
-
- /**
- *@return true if date is �selectable� on calendar, default implementation return true
- **/
- public boolean isEnabled();
-
- /**
- * @return String that will be appended to style class for that date span.
- * For example it may be �relevant holyday� � that mean class will be like �rich-cal-day
relevant holyday�.
- * Default implementation return empty string.
- * */
- public String getStyleClass();
-
- /**
- * @return any additional payload that must be JSON-serialazable object.
- * May be used in custom date representation on calendar (inside custom facet).*/
- public Object getData();
-
- /**
- * @return true if given date has an associated with it tooltip data.
- * Default implementation return false.*/
- public boolean hasToolTip();
-
- /**
- *@return tool tip data that will be used in �batch� tooltip loading mode.
- **/
- public Object getToolTip();
-
- /**
- *@return day of the month on which data must be shown.
- **/
- public int getDay();
-
-}
-
-
-
Copied: trunk/ui/calendar/api/src/main/java/org/richfaces/model/CalendarDataModelItem.java
(from rev 19755,
sandbox/trunk/ui/calendar/api/src/main/java/org/richfaces/model/CalendarDataModelItem.java)
===================================================================
--- trunk/ui/calendar/api/src/main/java/org/richfaces/model/CalendarDataModelItem.java
(rev 0)
+++
trunk/ui/calendar/api/src/main/java/org/richfaces/model/CalendarDataModelItem.java 2010-10-29
11:48:42 UTC (rev 19760)
@@ -0,0 +1,68 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+
+/**
+ * @author Alexej Kushunin created 19.06.2007
+ *
+ */
+
+public interface CalendarDataModelItem {
+
+ /**
+ * @return true if date is �selectable� on calendar, default
+ * implementation return true
+ **/
+ public boolean isEnabled();
+
+ /**
+ * @return String that will be appended to style class for that date span.
+ * For example it may be �relevant holyday� � that mean class
+ * will be like �rich-cal-day relevant holyday�. Default
+ * implementation return empty string.
+ * */
+ public String getStyleClass();
+
+ /**
+ * @return any additional payload that must be JSON-serialazable object. May
+ * be used in custom date representation on calendar (inside custom
+ * facet).
+ */
+ public Object getData();
+
+ /**
+ * @return true if given date has an associated with it tooltip data.
+ * Default implementation return false.
+ */
+ public boolean hasToolTip();
+
+ /**
+ * @return tool tip data that will be used in �batch� tooltip loading
+ * mode.
+ **/
+ public Object getToolTip();
+
+ /**
+ * @return day of the month on which data must be shown.
+ **/
+ public int getDay();
+
+}
Deleted: trunk/ui/calendar/pom.xml
===================================================================
--- sandbox/trunk/ui/calendar/pom.xml 2010-10-28 12:08:05 UTC (rev 19724)
+++ trunk/ui/calendar/pom.xml 2010-10-29 11:48:42 UTC (rev 19760)
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- JBoss, Home of Professional Open Source Copyright 2010, Red Hat,
- Inc. and individual contributors by the @authors tag. See the
- copyright.txt in the distribution for a full listing of
- individual contributors. This is free software; you can
- redistribute it and/or modify it under the terms of the GNU
- Lesser General Public License as published by the Free Software
- Foundation; either version 2.1 of the License, or (at your
- option) any later version. This software is distributed in the
- hope that it will be useful, but WITHOUT ANY WARRANTY; without
- even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- PARTICULAR PURPOSE. See the GNU Lesser General Public License
- for more details. You should have received a copy of the GNU
- Lesser General Public License along with this software; if not,
- write to the Free Software Foundation, Inc., 51 Franklin St,
- Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF site:
-
http://www.fsf.org.
--->
-
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.richfaces</groupId>
- <artifactId>richfaces-root-parent</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.richfaces.ui.calendar</groupId>
- <artifactId>richfaces-ui-calendar-aggregator</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- <packaging>pom</packaging>
- <name>Richfaces UI Components: Calendar Aggregator</name>
-
- <modules>
- <module>ui</module>
- </modules>
-</project>
Copied: trunk/ui/calendar/pom.xml (from rev 19755, sandbox/trunk/ui/calendar/pom.xml)
===================================================================
--- trunk/ui/calendar/pom.xml (rev 0)
+++ trunk/ui/calendar/pom.xml 2010-10-29 11:48:42 UTC (rev 19760)
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ JBoss, Home of Professional Open Source Copyright 2010, Red Hat,
+ Inc. and individual contributors by the @authors tag. See the
+ copyright.txt in the distribution for a full listing of
+ individual contributors. This is free software; you can
+ redistribute it and/or modify it under the terms of the GNU
+ Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1 of the License, or (at your
+ option) any later version. This software is distributed in the
+ hope that it will be useful, but WITHOUT ANY WARRANTY; without
+ even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ for more details. You should have received a copy of the GNU
+ Lesser General Public License along with this software; if not,
+ write to the Free Software Foundation, Inc., 51 Franklin St,
+ Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF site:
+
http://www.fsf.org.
+-->
+
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.richfaces</groupId>
+ <artifactId>richfaces-root-parent</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.richfaces.ui.calendar</groupId>
+ <artifactId>richfaces-ui-calendar-aggregator</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>Richfaces UI Components: Calendar Aggregator</name>
+
+ <modules>
+ <module>api</module>
+ <module>ui</module>
+ </modules>
+</project>
Copied: trunk/ui/calendar/ui (from rev 19754, sandbox/trunk/ui/calendar/ui)
Deleted: trunk/ui/calendar/ui/pom.xml
===================================================================
--- sandbox/trunk/ui/calendar/ui/pom.xml 2010-10-29 09:58:54 UTC (rev 19754)
+++ trunk/ui/calendar/ui/pom.xml 2010-10-29 11:48:42 UTC (rev 19760)
@@ -1,67 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- JBoss, Home of Professional Open Source Copyright 2010, Red Hat,
- Inc. and individual contributors by the @authors tag. See the
- copyright.txt in the distribution for a full listing of
- individual contributors. This is free software; you can
- redistribute it and/or modify it under the terms of the GNU
- Lesser General Public License as published by the Free Software
- Foundation; either version 2.1 of the License, or (at your
- option) any later version. This software is distributed in the
- hope that it will be useful, but WITHOUT ANY WARRANTY; without
- even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- PARTICULAR PURPOSE. See the GNU Lesser General Public License
- for more details. You should have received a copy of the GNU
- Lesser General Public License along with this software; if not,
- write to the Free Software Foundation, Inc., 51 Franklin St,
- Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF site:
-
http://www.fsf.org.
--->
-
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.richfaces.ui</groupId>
- <artifactId>richfaces-ui-parent</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.richfaces.ui.calendar</groupId>
- <artifactId>richfaces-ui-calendar-ui</artifactId>
- <name>Richfaces UI Components: Input UI</name>
- <packaging>jar</packaging>
- <build>
- <plugins>
- <plugin>
- <groupId>org.richfaces.cdk</groupId>
- <artifactId>maven-cdk-plugin</artifactId>
- </plugin>
- <plugin>
- <artifactId>maven-checkstyle-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <!-- runtime -->
- <dependency>
- <groupId>org.richfaces.core</groupId>
- <artifactId>richfaces-core-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.richfaces.core</groupId>
- <artifactId>richfaces-core-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>org.richfaces.ui.common</groupId>
- <artifactId>richfaces-ui-common-ui</artifactId>
- </dependency>
- <dependency>
- <groupId>org.richfaces.ui.input</groupId>
- <artifactId>richfaces-ui-input-ui</artifactId>
- </dependency>
- </dependencies>
-</project>
Copied: trunk/ui/calendar/ui/pom.xml (from rev 19755,
sandbox/trunk/ui/calendar/ui/pom.xml)
===================================================================
--- trunk/ui/calendar/ui/pom.xml (rev 0)
+++ trunk/ui/calendar/ui/pom.xml 2010-10-29 11:48:42 UTC (rev 19760)
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ JBoss, Home of Professional Open Source Copyright 2010, Red Hat,
+ Inc. and individual contributors by the @authors tag. See the
+ copyright.txt in the distribution for a full listing of
+ individual contributors. This is free software; you can
+ redistribute it and/or modify it under the terms of the GNU
+ Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1 of the License, or (at your
+ option) any later version. This software is distributed in the
+ hope that it will be useful, but WITHOUT ANY WARRANTY; without
+ even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ for more details. You should have received a copy of the GNU
+ Lesser General Public License along with this software; if not,
+ write to the Free Software Foundation, Inc., 51 Franklin St,
+ Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF site:
+
http://www.fsf.org.
+-->
+
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>richfaces-ui-parent</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.richfaces.ui.calendar</groupId>
+ <artifactId>richfaces-ui-calendar-ui</artifactId>
+ <name>Richfaces UI Components: Input UI</name>
+ <packaging>jar</packaging>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>maven-cdk-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <!-- runtime -->
+ <dependency>
+ <groupId>org.richfaces.core</groupId>
+ <artifactId>richfaces-core-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.core</groupId>
+ <artifactId>richfaces-core-impl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.ui.common</groupId>
+ <artifactId>richfaces-ui-common-ui</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.ui.input</groupId>
+ <artifactId>richfaces-ui-input-ui</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.ui.calendar</groupId>
+ <artifactId>richfaces-ui-calendar-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
Deleted: trunk/ui/calendar/ui/src/main/java/org/richfaces/component/AbstractCalendar.java
===================================================================
---
sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/component/AbstractCalendar.java 2010-10-29
09:58:54 UTC (rev 19754)
+++
trunk/ui/calendar/ui/src/main/java/org/richfaces/component/AbstractCalendar.java 2010-10-29
11:48:42 UTC (rev 19760)
@@ -1,349 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.richfaces.component;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Locale;
-import java.util.TimeZone;
-
-import javax.el.ELContext;
-import javax.el.ValueExpression;
-import javax.faces.application.FacesMessage;
-import javax.faces.component.UIInput;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.DateTimeConverter;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.PhaseId;
-
-import org.richfaces.cdk.annotations.Attribute;
-import org.richfaces.cdk.annotations.EventName;
-import org.richfaces.cdk.annotations.JsfComponent;
-import org.richfaces.cdk.annotations.JsfRenderer;
-import org.richfaces.cdk.annotations.Tag;
-import org.richfaces.events.CurrentDateChangeEvent;
-import org.richfaces.events.CurrentDateChangeListener;
-import org.richfaces.log.Logger;
-import org.richfaces.log.RichfacesLogger;
-import org.richfaces.utils.CalendarHelper;
-
-/**
- * @author amarkhel
- *
- */
-
-@JsfComponent(type = AbstractCalendar.COMPONENT_TYPE, family =
AbstractCalendar.COMPONENT_FAMILY, generate =
"org.richfaces.component.UICalendar", renderer = @JsfRenderer(type =
"org.richfaces.CalendarRenderer"), tag = @Tag(name = "calendar"))
-public abstract class AbstractCalendar extends UIInput {
-
- public static final String COMPONENT_TYPE = "org.richfaces.Calendar";
-
- public static final String COMPONENT_FAMILY = "org.richfaces.Calendar";
-
- public static final String SUB_TIME_PATTERN =
"\\s*[hHkKma]+[\\W&&\\S]+[hHkKma]+\\s*";
-
- public static final String TIME_PATTERN = "HH:mm";
-
- public static final String DEFAULT_DATE_PATTERN = "MMM d, yyyy";
-
- Logger log = RichfacesLogger.COMPONENTS.getLogger();
-
- protected enum PropertyKeys {
- locale
- };
-
-
- @Attribute(defaultValue = "MMM d, yyyy")
- public abstract String getDatePattern();
-
- @Attribute(defaultValue = "TimeZone.getDefault()")
- public abstract TimeZone getTimeZone();
-
- @Attribute(defaultValue = "Integer.MIN_VALUE")
- public abstract int getFirstWeekDay();
-
- @Attribute(defaultValue = "Integer.MIN_VALUE")
- public abstract int getMinDaysInFirstWeek();
-
- @Attribute(defaultValue = "select")
- public abstract String getTodayControlMode();
-
- @Attribute(defaultValue = "true")
- public abstract boolean isShowWeekDaysBar();
-
- @Attribute(defaultValue = "true")
- public abstract boolean isShowWeeksBar();
-
- @Attribute(defaultValue = "true")
- public abstract boolean isShowFooter();
-
- @Attribute(defaultValue = "true")
- public abstract boolean isShowHeader();
-
- @Attribute(defaultValue = "true")
- public abstract boolean isShowInput();
-
- @Attribute(defaultValue = "true")
- public abstract boolean isPopup();
-
- @Attribute(defaultValue = "true")
- public abstract String getHidePopupOnScroll();
-
- @Attribute(defaultValue = "false")
- public abstract boolean isDisable();
-
- @Attribute(defaultValue = "false")
- public abstract boolean isEnableManualInput();
-
- @Attribute(defaultValue = "false")
- public abstract boolean isDayEnabled();
-
- @Attribute(defaultValue = "false")
- public abstract boolean isShowApplyButton();
-
- @Attribute(defaultValue = "false")
- public abstract boolean isResetTimeOnDateSelect();
-
- @Attribute(defaultValue = "AA")
- public abstract String getJointPoint();
-
- @Attribute(defaultValue = "AA")
- public abstract String getDirection();
-
- @Attribute(defaultValue = "inactive")
- public abstract String getBoundaryDatesMode();
-
- @Attribute(defaultValue = "0")
- public abstract String getHorizontalOffset();
-
- @Attribute(defaultValue = "0")
- public abstract String getVerticalOffsetOffset();
-
- @Attribute(defaultValue = "3")
- public abstract int getZindex();
-
- @Attribute
- public abstract String getStyle();
-
- @Attribute
- public abstract Object getMonthLabels();
-
- @Attribute
- public abstract Object getMonthLabelsShort();
-
- @Attribute
- public abstract Object getWeekDayLabelsShort();
-
- @Attribute
- public abstract Object getWeekDayLabels();
-
- @Attribute
- public abstract String getDayStyleClass();
-
- @Attribute
- public abstract String getTabindex();
-
- @Attribute
- public abstract String getInputStyle();
-
- @Attribute
- public abstract String getButtonClass();
-
- @Attribute
- public abstract String getInputClass();
-
- @Attribute
- public abstract String getButtonLabel();
-
- @Attribute
- public abstract String getInputSize();
-
- @Attribute
- public abstract Object getCurrentDate();
-
- public abstract void setCurrentDate(Object date);
-
- @Attribute
- public abstract String getButtonIcon();
-
- @Attribute
- public abstract String getButtonIconDisabled();
-
- @Attribute
- public abstract Object getDefaultTime();
-
- @Attribute(events = @EventName("inputclick"))
- public abstract String getOninputclick();
-
- @Attribute(events = @EventName("inputdblclick"))
- public abstract String getOninputdblclick();
-
- @Attribute(events = @EventName("inputchange"))
- public abstract String getOninputchange();
-
- @Attribute(events = @EventName("inputselect"))
- public abstract String getOninputselect();
-
- @Attribute(events = @EventName("inputmousedown"))
- public abstract String getOninputmousedown();
-
- @Attribute(events = @EventName("inputmousemove"))
- public abstract String getOninputmousemove();
-
- @Attribute(events = @EventName("inputmouseout"))
- public abstract String getOninputmouseout();
-
- @Attribute(events = @EventName("inputmouseover"))
- public abstract String getOninputmouseover();
-
- @Attribute(events = @EventName("inputmouseup"))
- public abstract String getOninputmouseup();
-
- @Attribute(events = @EventName("inputkeydown"))
- public abstract String getOninputkeydown();
-
- @Attribute(events = @EventName("inputkeypress"))
- public abstract String getOninputkeypress();
-
- @Attribute(events = @EventName("inputkeyup"))
- public abstract String getOninputkeypup();
-
- @Attribute(events = @EventName("inputfocus"))
- public abstract String getOninputfocus();
-
- @Attribute(events = @EventName("inputblur"))
- public abstract String getOninputblur();
-
- @Attribute
- public Object getLocale() {
- Object locale = getStateHelper().eval(PropertyKeys.locale);
- if (locale == null) {
- FacesContext facesContext = getFacesContext();
- UIViewRoot viewRoot = facesContext.getViewRoot();
- if (viewRoot != null) {
- locale = viewRoot.getLocale();
- }
- }
- return locale != null ? locale : Locale.US;
- }
-
- public void setLocale(Object locale) {
- getStateHelper().put(PropertyKeys.locale, locale);
- }
-
- public void updateCurrentDate(FacesContext facesContext, Object currentDate) {
- if (facesContext == null) {
- throw new NullPointerException();
- }
- // RF-1073
- try {
- ValueExpression ve = getValueExpression("currentDate");
- if (ve != null) {
- ELContext elContext = facesContext.getELContext();
- if (ve.getType(elContext).equals(String.class)) {
- DateTimeConverter convert = new DateTimeConverter();
- convert.setLocale(CalendarHelper.getAsLocale(facesContext, this,
getLocale()));
- convert.setPattern(getDatePattern());
- ve.setValue(facesContext.getELContext(),
convert.getAsString(facesContext, this, currentDate));
- return;
- } else if (ve.getType(elContext).equals(Calendar.class)) {
- Calendar c = Calendar.getInstance();
- c.setTime((Date) currentDate);
- ve.setValue(elContext, c);
- return;
- } else {
- ve.setValue(elContext, currentDate);
- return;
- }
- } else {
- setCurrentDate(currentDate);
- }
-
- } catch (Exception e) {
- setValid(false);
- if (log.isDebugEnabled()) {
- log.debug(" updateCurrentDate method throws exception: " +
e.toString(), e);
- }
-
- String messageString = e.toString();
- FacesMessage message = new FacesMessage(messageString);
- message.setSeverity(FacesMessage.SEVERITY_ERROR);
- facesContext.addMessage(getClientId(facesContext), message);
- }
- }
-
- public void addCurrentDateChangeListener(CurrentDateChangeListener listener) {
- addFacesListener(listener);
- }
-
- public void removeToggleListener(CurrentDateChangeListener listener) {
- removeFacesListener(listener);
- }
-
- public CurrentDateChangeListener[] getCurrentDateChangeListeners() {
- return (CurrentDateChangeListener[])
getFacesListeners(CurrentDateChangeListener.class);
- }
-
- public void broadcast(FacesEvent event) throws AbortProcessingException {
- if (event instanceof CurrentDateChangeEvent) {
- FacesContext facesContext = getFacesContext();
- CurrentDateChangeEvent currentDateChangeEvent = (CurrentDateChangeEvent)
event;
- String currentDateString = currentDateChangeEvent.getCurrentDateString();
-
- try {
- // we should use datePattern attribute-based converter only for
- // selectedDate
- // current date string always has predefined format: m/y
- Date currentDate = CalendarHelper.getAsDate(facesContext, this,
getCurrentDate());
- Date submittedCurrentDate =
CalendarHelper.convertCurrentDate(currentDateString);
- currentDateChangeEvent.setCurrentDate(submittedCurrentDate);
-
- if (!submittedCurrentDate.equals(currentDate)) {
- updateCurrentDate(facesContext, submittedCurrentDate);
- }
-
- } catch (Exception e) {
- if (log.isDebugEnabled()) {
- log.debug(" currentDate convertion fails with following
exception: " + e.toString(), e);
- }
- setValid(false);
- String messageString = e.toString();
- FacesMessage message = new FacesMessage(messageString);
- message.setSeverity(FacesMessage.SEVERITY_ERROR);
- facesContext.addMessage(getClientId(facesContext), message);
- facesContext.renderResponse();
- }
- } else {
- super.broadcast(event);
- }
- }
-
- @Override
- public void queueEvent(FacesEvent event) {
- super.queueEvent(event);
- if (event instanceof CurrentDateChangeEvent) {
- event.setPhaseId(PhaseId.PROCESS_VALIDATIONS);
- }
- }
-}
Copied: trunk/ui/calendar/ui/src/main/java/org/richfaces/component/AbstractCalendar.java
(from rev 19755,
sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/component/AbstractCalendar.java)
===================================================================
--- trunk/ui/calendar/ui/src/main/java/org/richfaces/component/AbstractCalendar.java
(rev 0)
+++
trunk/ui/calendar/ui/src/main/java/org/richfaces/component/AbstractCalendar.java 2010-10-29
11:48:42 UTC (rev 19760)
@@ -0,0 +1,351 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.component;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Locale;
+import java.util.TimeZone;
+
+import javax.el.ELContext;
+import javax.el.ValueExpression;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIInput;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.DateTimeConverter;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.PhaseId;
+
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.EventName;
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.log.Logger;
+import org.richfaces.log.RichfacesLogger;
+import org.richfaces.utils.CalendarHelper;
+
+import org.richfaces.event.CurrentDateChangeEvent;
+import org.richfaces.event.CurrentDateChangeListener;
+
+
+/**
+ * @author amarkhel
+ *
+ */
+
+@JsfComponent(type = AbstractCalendar.COMPONENT_TYPE, family =
AbstractCalendar.COMPONENT_FAMILY, generate =
"org.richfaces.component.UICalendar", renderer = @JsfRenderer(type =
"org.richfaces.CalendarRenderer"), tag = @Tag(name = "calendar"))
+public abstract class AbstractCalendar extends UIInput {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.Calendar";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.Calendar";
+
+ public static final String SUB_TIME_PATTERN =
"\\s*[hHkKma]+[\\W&&\\S]+[hHkKma]+\\s*";
+
+ public static final String TIME_PATTERN = "HH:mm";
+
+ public static final String DEFAULT_DATE_PATTERN = "MMM d, yyyy";
+
+ Logger log = RichfacesLogger.COMPONENTS.getLogger();
+
+ protected enum PropertyKeys {
+ locale
+ };
+
+
+ @Attribute(defaultValue = "MMM d, yyyy")
+ public abstract String getDatePattern();
+
+ @Attribute(defaultValue = "TimeZone.getDefault()")
+ public abstract TimeZone getTimeZone();
+
+ @Attribute(defaultValue = "Integer.MIN_VALUE")
+ public abstract int getFirstWeekDay();
+
+ @Attribute(defaultValue = "Integer.MIN_VALUE")
+ public abstract int getMinDaysInFirstWeek();
+
+ @Attribute(defaultValue = "select")
+ public abstract String getTodayControlMode();
+
+ @Attribute(defaultValue = "true")
+ public abstract boolean isShowWeekDaysBar();
+
+ @Attribute(defaultValue = "true")
+ public abstract boolean isShowWeeksBar();
+
+ @Attribute(defaultValue = "true")
+ public abstract boolean isShowFooter();
+
+ @Attribute(defaultValue = "true")
+ public abstract boolean isShowHeader();
+
+ @Attribute(defaultValue = "true")
+ public abstract boolean isShowInput();
+
+ @Attribute(defaultValue = "true")
+ public abstract boolean isPopup();
+
+ @Attribute(defaultValue = "true")
+ public abstract String getHidePopupOnScroll();
+
+ @Attribute(defaultValue = "false")
+ public abstract boolean isDisable();
+
+ @Attribute(defaultValue = "false")
+ public abstract boolean isEnableManualInput();
+
+ @Attribute(defaultValue = "false")
+ public abstract boolean isDayEnabled();
+
+ @Attribute(defaultValue = "false")
+ public abstract boolean isShowApplyButton();
+
+ @Attribute(defaultValue = "false")
+ public abstract boolean isResetTimeOnDateSelect();
+
+ @Attribute(defaultValue = "AA")
+ public abstract String getJointPoint();
+
+ @Attribute(defaultValue = "AA")
+ public abstract String getDirection();
+
+ @Attribute(defaultValue = "inactive")
+ public abstract String getBoundaryDatesMode();
+
+ @Attribute(defaultValue = "0")
+ public abstract String getHorizontalOffset();
+
+ @Attribute(defaultValue = "0")
+ public abstract String getVerticalOffsetOffset();
+
+ @Attribute(defaultValue = "3")
+ public abstract int getZindex();
+
+ @Attribute
+ public abstract String getStyle();
+
+ @Attribute
+ public abstract Object getMonthLabels();
+
+ @Attribute
+ public abstract Object getMonthLabelsShort();
+
+ @Attribute
+ public abstract Object getWeekDayLabelsShort();
+
+ @Attribute
+ public abstract Object getWeekDayLabels();
+
+ @Attribute
+ public abstract String getDayStyleClass();
+
+ @Attribute
+ public abstract String getTabindex();
+
+ @Attribute
+ public abstract String getInputStyle();
+
+ @Attribute
+ public abstract String getButtonClass();
+
+ @Attribute
+ public abstract String getInputClass();
+
+ @Attribute
+ public abstract String getButtonLabel();
+
+ @Attribute
+ public abstract String getInputSize();
+
+ @Attribute
+ public abstract Object getCurrentDate();
+
+ public abstract void setCurrentDate(Object date);
+
+ @Attribute
+ public abstract String getButtonIcon();
+
+ @Attribute
+ public abstract String getButtonIconDisabled();
+
+ @Attribute
+ public abstract Object getDefaultTime();
+
+ @Attribute(events = @EventName("inputclick"))
+ public abstract String getOninputclick();
+
+ @Attribute(events = @EventName("inputdblclick"))
+ public abstract String getOninputdblclick();
+
+ @Attribute(events = @EventName("inputchange"))
+ public abstract String getOninputchange();
+
+ @Attribute(events = @EventName("inputselect"))
+ public abstract String getOninputselect();
+
+ @Attribute(events = @EventName("inputmousedown"))
+ public abstract String getOninputmousedown();
+
+ @Attribute(events = @EventName("inputmousemove"))
+ public abstract String getOninputmousemove();
+
+ @Attribute(events = @EventName("inputmouseout"))
+ public abstract String getOninputmouseout();
+
+ @Attribute(events = @EventName("inputmouseover"))
+ public abstract String getOninputmouseover();
+
+ @Attribute(events = @EventName("inputmouseup"))
+ public abstract String getOninputmouseup();
+
+ @Attribute(events = @EventName("inputkeydown"))
+ public abstract String getOninputkeydown();
+
+ @Attribute(events = @EventName("inputkeypress"))
+ public abstract String getOninputkeypress();
+
+ @Attribute(events = @EventName("inputkeyup"))
+ public abstract String getOninputkeypup();
+
+ @Attribute(events = @EventName("inputfocus"))
+ public abstract String getOninputfocus();
+
+ @Attribute(events = @EventName("inputblur"))
+ public abstract String getOninputblur();
+
+ @Attribute
+ public Object getLocale() {
+ Object locale = getStateHelper().eval(PropertyKeys.locale);
+ if (locale == null) {
+ FacesContext facesContext = getFacesContext();
+ UIViewRoot viewRoot = facesContext.getViewRoot();
+ if (viewRoot != null) {
+ locale = viewRoot.getLocale();
+ }
+ }
+ return locale != null ? locale : Locale.US;
+ }
+
+ public void setLocale(Object locale) {
+ getStateHelper().put(PropertyKeys.locale, locale);
+ }
+
+ public void updateCurrentDate(FacesContext facesContext, Object currentDate) {
+ if (facesContext == null) {
+ throw new NullPointerException();
+ }
+ // RF-1073
+ try {
+ ValueExpression ve = getValueExpression("currentDate");
+ if (ve != null) {
+ ELContext elContext = facesContext.getELContext();
+ if (ve.getType(elContext).equals(String.class)) {
+ DateTimeConverter convert = new DateTimeConverter();
+ convert.setLocale(CalendarHelper.getAsLocale(facesContext, this,
getLocale()));
+ convert.setPattern(getDatePattern());
+ ve.setValue(facesContext.getELContext(),
convert.getAsString(facesContext, this, currentDate));
+ return;
+ } else if (ve.getType(elContext).equals(Calendar.class)) {
+ Calendar c = Calendar.getInstance();
+ c.setTime((Date) currentDate);
+ ve.setValue(elContext, c);
+ return;
+ } else {
+ ve.setValue(elContext, currentDate);
+ return;
+ }
+ } else {
+ setCurrentDate(currentDate);
+ }
+
+ } catch (Exception e) {
+ setValid(false);
+ if (log.isDebugEnabled()) {
+ log.debug(" updateCurrentDate method throws exception: " +
e.toString(), e);
+ }
+
+ String messageString = e.toString();
+ FacesMessage message = new FacesMessage(messageString);
+ message.setSeverity(FacesMessage.SEVERITY_ERROR);
+ facesContext.addMessage(getClientId(facesContext), message);
+ }
+ }
+
+ public void addCurrentDateChangeListener(CurrentDateChangeListener listener) {
+ addFacesListener(listener);
+ }
+
+ public void removeToggleListener(CurrentDateChangeListener listener) {
+ removeFacesListener(listener);
+ }
+
+ public CurrentDateChangeListener[] getCurrentDateChangeListeners() {
+ return (CurrentDateChangeListener[])
getFacesListeners(CurrentDateChangeListener.class);
+ }
+
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ if (event instanceof CurrentDateChangeEvent) {
+ FacesContext facesContext = getFacesContext();
+ CurrentDateChangeEvent currentDateChangeEvent = (CurrentDateChangeEvent)
event;
+ String currentDateString = currentDateChangeEvent.getCurrentDateString();
+
+ try {
+ // we should use datePattern attribute-based converter only for
+ // selectedDate
+ // current date string always has predefined format: m/y
+ Date currentDate = CalendarHelper.getAsDate(facesContext, this,
getCurrentDate());
+ Date submittedCurrentDate =
CalendarHelper.convertCurrentDate(currentDateString);
+ currentDateChangeEvent.setCurrentDate(submittedCurrentDate);
+
+ if (!submittedCurrentDate.equals(currentDate)) {
+ updateCurrentDate(facesContext, submittedCurrentDate);
+ }
+
+ } catch (Exception e) {
+ if (log.isDebugEnabled()) {
+ log.debug(" currentDate convertion fails with following
exception: " + e.toString(), e);
+ }
+ setValid(false);
+ String messageString = e.toString();
+ FacesMessage message = new FacesMessage(messageString);
+ message.setSeverity(FacesMessage.SEVERITY_ERROR);
+ facesContext.addMessage(getClientId(facesContext), message);
+ facesContext.renderResponse();
+ }
+ } else {
+ super.broadcast(event);
+ }
+ }
+
+ @Override
+ public void queueEvent(FacesEvent event) {
+ super.queueEvent(event);
+ if (event instanceof CurrentDateChangeEvent) {
+ event.setPhaseId(PhaseId.PROCESS_VALIDATIONS);
+ }
+ }
+}
Deleted:
trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
===================================================================
---
sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2010-10-29
09:58:54 UTC (rev 19754)
+++
trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2010-10-29
11:48:42 UTC (rev 19760)
@@ -1,609 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.richfaces.renderkit;
-
-import java.io.IOException;
-import java.text.DateFormatSymbols;
-import java.text.Format;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-import java.util.TimeZone;
-
-import javax.faces.application.ResourceDependencies;
-import javax.faces.application.ResourceDependency;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.convert.Converter;
-import javax.faces.convert.ConverterException;
-import javax.faces.convert.DateTimeConverter;
-
-import org.ajax4jsf.javascript.JSFunction;
-import org.ajax4jsf.javascript.JSReference;
-import org.richfaces.component.AbstractCalendar;
-import org.richfaces.component.util.HtmlUtil;
-import org.richfaces.component.util.MessageUtil;
-import org.richfaces.component.util.SelectUtils;
-import org.richfaces.component.util.ViewUtil;
-import org.richfaces.events.CurrentDateChangeEvent;
-import org.richfaces.utils.CalendarHelper;
-
-/**
- * @author amarkhel
- *
- */
-
-@ResourceDependencies({ @ResourceDependency(library = "javax.faces", name =
"jsf.js"),
- @ResourceDependency(name = "jquery.js"),
- @ResourceDependency(name = "jquery.position.js"),
- @ResourceDependency(name = "richfaces.js"),
- @ResourceDependency(name = "richfaces-base-component.js"),
- @ResourceDependency(name = "richfaces-event.js"),
- @ResourceDependency(library = "org.richfaces", name =
"json-dom.js"),
- @ResourceDependency(library = "org.richfaces", name =
"jquery.effects.core.js"),
- @ResourceDependency(library = "org.richfaces", name =
"jquery.effects.highlight.js"),
- @ResourceDependency(library = "org.richfaces", name =
"JQuerySpinBtn.js.js"),
- @ResourceDependency(library = "org.richfaces", name =
"calendar-utils.js"),
- @ResourceDependency(library = "org.richfaces", name =
"calendar.js"),
- @ResourceDependency(library = "org.richfaces", name =
"calendar.ecss") })
-public class CalendarRendererBase extends InputRendererBase {
-
- public static final String CALENDAR_BUNDLE =
"org.richfaces.renderkit.calendar";
-
- public static final String OPTION_ENABLE_MANUAL_INPUT =
"enableManualInput";
-
- public static final String OPTION_DISABLED = "disabled";
-
- public static final String OPTION_READONLY = "readonly";
-
- public static final String OPTION_RESET_TIME_ON_DATE_SELECT =
"resetTimeOnDateSelect";
-
- public static final String OPTION_SHOW_APPLY_BUTTON = "showApplyButton";
-
- public static final String OPTION_MIN_DAYS_IN_FIRST_WEEK =
"minDaysInFirstWeek";
-
- public static final String OPTION_POPUP = "popup";
-
- public static final String OPTION_SHOW_INPUT = "showInput";
-
- public static final String OPTION_SHOW_HEADER = "showHeader";
-
- public static final String OPTION_SHOW_FOOTER = "showFooter";
-
- public static final String OPTION_SHOW_WEEKS_BAR = "showWeeksBar";
-
- public static final String OPTION_TODAY_CONTROL_MODE = "todayControlMode";
-
- public static final String OPTION_DATE_PATTERN = "datePattern";
-
- public static final String OPTION_JOINT_POINT = "jointPoint";
-
- public static final String OPTION_DIRECTION = "direction";
-
- public static final String OPTION_BOUNDARY_DATES_MODE =
"boundaryDatesMode";
-
- public static final String OPTION_HORIZONTAL_OFFSET = "horizontalOffset";
-
- public static final String OPTION_VERTICAL_OFFSET = "verticalOffset";
-
- public static final String OPTION_CURRENT_DATE = "currentDate";
-
- public static final String OPTION_SELECTED_DATE = "selectedDate";
-
- public static final String OPTION_DAY_CELL_CLASS = "dayCellClass";
-
- public static final String OPTION_DAY_STYLE_CLASS = "dayStyleClass";
-
- public static final String OPTION_LABELS = "labels";
-
- public static final String OPTION_DEFAULT_TIME = "defaultTime";
-
- public static final String OPTION_HIDE_POPUP_ON_SCROLL =
"hidePopupOnScroll";
-
- public static final String OPTION_SHOW_WEEK_DAYS_BAR = "showWeekDaysBar";
-
- public static final String MONTH_LABELS_SHORT = "monthLabelsShort";
-
- public static final String MONTH_LABELS = "monthLabels";
-
- public static final String WEEK_DAY_LABELS_SHORT = "weekDayLabelsShort";
-
- public static final String WEEK_DAY_LABELS = "weekDayLabels";
-
- public static final String FIRST_DAY_WEEK = "firstWeekDay";
-
- public static final String MIN_DAYS_IN_FIRST_WEEK = "minDaysInFirstWeek";
-
- public static final String CALENDAR_ICON_RESOURCE_NAME =
"calendarIcon.png";
-
- public static final String CALENDAR_DISABLE_ICON_RESOURCE_NAME =
"disabledCalendarIcon.png";
-
- public static final String CURRENT_DATE_INPUT = "InputCurrentDate";
-
-
-
-
-
- protected static final Map<String, ComponentAttribute>
CALENDAR_INPUT_HANDLER_ATTRIBUTES =
Collections.unmodifiableMap(ComponentAttribute.createMap(
- new ComponentAttribute(HtmlConstants.ONCLICK_ATTRIBUTE)
- .setEventNames("inputclick")
- .setComponentAttributeName("oninputclick"),
- new ComponentAttribute(HtmlConstants.ONDBLCLICK_ATTRIBUTE)
- .setEventNames("inputdblclick")
- .setComponentAttributeName("oninputdblclick"),
- new ComponentAttribute(HtmlConstants.ONMOUSEDOWN_ATTRIBUTE)
- .setEventNames("inputmousedown")
- .setComponentAttributeName("oninputmousedown"),
- new ComponentAttribute(HtmlConstants.ONMOUSEUP_ATTRIBUTE)
- .setEventNames("inputmouseup")
- .setComponentAttributeName("oninputmouseup"),
- new ComponentAttribute(HtmlConstants.ONMOUSEOVER_ATTRIBUTE)
- .setEventNames("inputmouseover")
- .setComponentAttributeName("oninputmouseover"),
- new ComponentAttribute(HtmlConstants.ONMOUSEMOVE_ATTRIBUTE)
- .setEventNames("inputmousemove")
- .setComponentAttributeName("oninputmousemove"),
- new ComponentAttribute(HtmlConstants.ONMOUSEOUT_ATTRIBUTE)
- .setEventNames("inputmouseout")
- .setComponentAttributeName("oninputmouseout"),
- new ComponentAttribute(HtmlConstants.ONKEYPRESS_ATTRIBUTE)
- .setEventNames("inputkeypress")
- .setComponentAttributeName("oninputkeypress"),
- new ComponentAttribute(HtmlConstants.ONKEYDOWN_ATTRIBUTE)
- .setEventNames("inputkeydown")
- .setComponentAttributeName("oninputkeydown"),
- new ComponentAttribute(HtmlConstants.ONKEYUP_ATTRIBUTE)
- .setEventNames("inputkeyup")
- .setComponentAttributeName("oninputkeyup"),
- new ComponentAttribute(HtmlConstants.ONBLUR_ATTRIBUTE)
- .setEventNames("inputblur")
- .setComponentAttributeName("oninputblur"),
- new ComponentAttribute(HtmlConstants.ONFOCUS_ATTRIBUTE)
- .setEventNames("inputfocus")
- .setComponentAttributeName("oninputfocus"),
- new ComponentAttribute(HtmlConstants.ONCHANGE_ATTRIBUTE)
- .setEventNames("inputchange")
- .setComponentAttributeName("oninputchange"),
- new ComponentAttribute(HtmlConstants.ONSELECT_ATTRIBUTE)
- .setEventNames("inputselect")
- .setComponentAttributeName("oninputselect")));
-
- private static final String HOURS_VALUE = "hours";
-
- private static final String MINUTES_VALUE = "minutes";
-
- protected void doDecode(FacesContext context, UIComponent component) {
- if(!(component instanceof AbstractCalendar)) {
- return;
- }
-
- AbstractCalendar calendar = (AbstractCalendar)component;
- if (calendar.isDisable()){
- return;
- }
-
- Map<String, String> requestParameterMap =
context.getExternalContext().getRequestParameterMap();
-
- String clientId = calendar.getClientId(context);
- String currentDateString = (String) requestParameterMap.get(clientId +
CURRENT_DATE_INPUT);
- if (currentDateString != null) {
- calendar.queueEvent(new CurrentDateChangeEvent(calendar,
currentDateString));
- }
-
- String selectedDateString = (String) requestParameterMap.get(clientId +
"InputDate");
- if (selectedDateString != null) {
- calendar.setSubmittedValue(selectedDateString);
- }
- }
-
- public void renderInputHandlers(FacesContext facesContext, UIComponent component)
throws IOException {
- RenderKitUtils.renderPassThroughAttributesOptimized(facesContext, component,
CALENDAR_INPUT_HANDLER_ATTRIBUTES);
- }
-
- @Override
- public Object getConvertedValue(FacesContext facesContext, UIComponent component,
Object submittedValue) throws ConverterException {
- if ((facesContext == null) || (component == null)) {
- throw new NullPointerException();
- }
-
- // skip conversion of already converted date
- if (submittedValue instanceof Date) {
- return (Date)submittedValue;
- }
-
- // Store submitted value in the local variable as a string
- String newValue = (String) submittedValue;
- // if we have no local value, try to get the valueExpression.
- AbstractCalendar calendar = (AbstractCalendar) component;
- Converter converter = SelectUtils.getConverterForProperty(facesContext, calendar,
"value");
-
- // in case the converter hasn't been set, try to use default
- // DateTimeConverter
- if (converter == null) {
- converter = createDefaultConverter();
- }
- setupConverter(facesContext, converter, calendar);
- return converter.getAsObject(facesContext, component, newValue);
- }
-
- @Override
- public String getInputValue(FacesContext facesContext, UIComponent component) {
- if(!(component instanceof AbstractCalendar)) {
- return null;
- }
-
- AbstractCalendar calendar = (AbstractCalendar) component;
- String value = (String) calendar.getSubmittedValue();
- if (value == null) {
- Object curVal = calendar.getValue();
- Converter converter = SelectUtils.getConverterForProperty(facesContext,
calendar, "value");
-
- if(converter == null) {
- converter = createDefaultConverter();
- setupConverter(facesContext, converter, calendar);
- }
-
- if (converter != null) {
- value = converter.getAsString(facesContext, calendar, curVal);
- } else {
- value = curVal !=null ? curVal.toString() : "";
- }
- }
-
- if (value == null) {
- value = "";
- }
-
- return value;
-
- }
-
- public String getButtonIcon(FacesContext facesContext, UIComponent component) {
- boolean disable = (Boolean)component.getAttributes().get("disable");
- String buttonIcon =
(String)component.getAttributes().get("buttonIcon");
- if(disable) {
- buttonIcon =
(String)component.getAttributes().get("buttonIconDisabled");
- }
-
- if(buttonIcon != null && buttonIcon.trim().length() != 0) {
- buttonIcon = ViewUtil.getResourceURL(buttonIcon, facesContext);
- } else {
- buttonIcon = disable ? CALENDAR_ICON_RESOURCE_NAME:
CALENDAR_ICON_RESOURCE_NAME;
- buttonIcon = RenderKitUtils.getResourcePath(facesContext,
"org.richfaces.images",buttonIcon);
- }
-
- return buttonIcon;
- }
-
- public Object getSelectedDate(FacesContext facesContext, UIComponent component)
throws IOException {
- Object returnValue = null;
- AbstractCalendar calendar = (AbstractCalendar)component;
- if(calendar.isValid()) {
- Date date;
- Object value = calendar.getValue();
- date = CalendarHelper.getAsDate(facesContext, calendar, value);
- if(date != null) {
- returnValue = formatSelectedDate(calendar.getTimeZone(), date);
- }
- }
- return returnValue;
- }
-
- public static Object formatSelectedDate(TimeZone timeZone, Date date) {
- Calendar calendar = Calendar.getInstance();
- calendar.setTimeZone(timeZone);
- calendar.setTime(date);
-
- JSFunction result = new JSFunction("new Date");
- result.addParameter(Integer.valueOf(calendar.get(Calendar.YEAR)));
- result.addParameter(Integer.valueOf(calendar.get(Calendar.MONTH)));
- result.addParameter(Integer.valueOf(calendar.get(Calendar.DATE)));
- result.addParameter(Integer.valueOf(calendar.get(Calendar.HOUR_OF_DAY)));
- result.addParameter(Integer.valueOf(calendar.get(Calendar.MINUTE)));
- result.addParameter(new Integer(0));
-
- return result;
- }
-
- public Object getCurrentDate(FacesContext facesContext, AbstractCalendar calendar)
throws IOException {
- Date date = CalendarHelper.getCurrentDateOrDefault(facesContext, calendar);
- return formatDate(date);
- }
-
- public String getCurrentDateAsString(FacesContext facesContext, UIComponent
component) throws IOException {
- AbstractCalendar calendar = (AbstractCalendar)component;
- Format formatter = new SimpleDateFormat("MM/yyyy");
-
- Date currentDate = CalendarHelper.getCurrentDateOrDefault(facesContext,
calendar);
- return formatter.format(currentDate);
- }
-
- public static Object formatDate(Date date) {
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(date);
- JSFunction result = new JSFunction("new Date");
- result.addParameter(Integer.valueOf(calendar.get(Calendar.YEAR)));
- result.addParameter(Integer.valueOf(calendar.get(Calendar.MONTH)));
- result.addParameter(Integer.valueOf(calendar.get(Calendar.DATE)));
-
- return result;
- }
-
- public String getDayCellClass(FacesContext facesContext, AbstractCalendar calendar)
{
- //TODO: refactor this
- /*
- String cellwidth = (String)
component.getAttributes().get("cellWidth");
- String cellheight = (String)
component.getAttributes().get("cellHeight");
- if (cellwidth != null && cellwidth.length() != 0 || cellheight != null
- && cellheight.length() != 0) {
- String clientId = component.getClientId(context);
- String value = clientId.replace(':', '_') +
"DayCell";
- return value;
- }
- */
- return null;
- }
-
- public JSReference getIsDayEnabled(FacesContext facesContext, AbstractCalendar
calendar) {
- return calendar.isDayEnabled() ? JSReference.TRUE : JSReference.FALSE;
- }
-
- public JSReference getDayStyleClass(FacesContext context, AbstractCalendar calendar)
{
- String dayStyleClass = calendar.getDayStyleClass();
- return ((dayStyleClass != null && dayStyleClass.trim().length() != 0)) ?
new JSReference(dayStyleClass) : null;
- }
-
-
- public Map<String, Object> getLabels(FacesContext facesContext,
AbstractCalendar calendar) {
- ResourceBundle bundle1 = null;
- ResourceBundle bundle2 = null;
-
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
-
- String messageBundle = facesContext.getApplication().getMessageBundle();
- Locale locale = CalendarHelper.getAsLocale(facesContext, calendar);
- if (null != messageBundle) {
- bundle1 = ResourceBundle.getBundle(messageBundle,locale , loader);
- }
-
- try {
- bundle2 = ResourceBundle.getBundle(CALENDAR_BUNDLE, locale, loader);
- } catch (MissingResourceException e) {
- //No external bundle was found, ignore this exception.
- }
-
- ResourceBundle [] bundles = {bundle1, bundle2};
- String[] names = {"apply", "today", "clean",
"cancel", "ok", "close"};
-
- return getCollectedLabels(bundles, names);
- }
-
- protected Map<String, Object> getCollectedLabels(ResourceBundle [] bundles ,
String[] names) {
- Map<String, Object> labels = new HashMap<String, Object>();
- if(bundles != null && names != null) {
- for (String name: names) {
- String label = null;
- String bundleKey = "RICH_CALENDAR_" + name.toUpperCase() +
"_LABEL";
- for(ResourceBundle bundle: bundles) {
- if (bundle != null) {
- try {
- label = bundle.getString(bundleKey);
- } catch (MissingResourceException mre) {
- // Current key was not found, ignore this exception;
- }
- }
- if(label != null) {
- break;
- }
- }
- RenderKitUtils.addToScriptHash(labels, name, label);
- }
- }
- return labels;
- }
-
- public Map<String, Object> getPreparedDefaultTime(FacesContext facesContext,
AbstractCalendar abstractCalendar) {
- Date date = CalendarHelper.getFormattedDefaultTime(abstractCalendar);
- Map<String, Object> result = new HashMap<String, Object>();
- if (date != null) {
- Calendar calendar = CalendarHelper.getCalendar(facesContext,
abstractCalendar);
- calendar.setTime(date);
- int hours = calendar.get(Calendar.HOUR_OF_DAY);
- int minutes = calendar.get(Calendar.MINUTE);
-
- if (hours != 12 || minutes != 0) {
- result.put(HOURS_VALUE, hours);
- result.put(MINUTES_VALUE, minutes);
- }
- }
- return result;
- }
-
- private static String[] shiftDates(int minimum, int maximum, String[] labels) {
- if (minimum == 0 && (maximum - minimum == labels.length - 1)) {
- return labels;
- }
-
- String[] shiftedLabels = new String[maximum - minimum + 1];
- System.arraycopy(labels, minimum, shiftedLabels, 0, maximum - minimum
- + 1);
-
- return shiftedLabels;
- }
-
- protected Map<String, Object> getLocaleOptions(FacesContext facesContext,
AbstractCalendar calendarComponent) {
- Map<String, Object> map = new HashMap<String, Object>();
-
- Locale locale = CalendarHelper.getAsLocale(facesContext, calendarComponent);
- DateFormatSymbols dateFormat = new DateFormatSymbols(locale);
-
- Calendar calendar = CalendarHelper.getCalendar(facesContext, calendarComponent);
- int maximum = calendar.getActualMaximum(Calendar.DAY_OF_WEEK);
- int minimum = calendar.getActualMinimum(Calendar.DAY_OF_WEEK);
-
- int monthMax = calendar.getActualMaximum(Calendar.MONTH);
- int monthMin = calendar.getActualMinimum(Calendar.MONTH);
-
- String [] weekDayLabels =
RenderKitUtils.asArray(calendarComponent.getWeekDayLabels());
- if(weekDayLabels == null) {
- weekDayLabels = dateFormat.getWeekdays();
- weekDayLabels = shiftDates(minimum, maximum, weekDayLabels);
- }
- RenderKitUtils.addToScriptHash(map, WEEK_DAY_LABELS, weekDayLabels);
-
- String [] weekDayLabelsShort =
RenderKitUtils.asArray(calendarComponent.getWeekDayLabelsShort());
- if(weekDayLabelsShort == null) {
- weekDayLabelsShort = dateFormat.getShortWeekdays();
- weekDayLabelsShort = shiftDates(minimum, maximum, weekDayLabelsShort);
- }
- RenderKitUtils.addToScriptHash(map, WEEK_DAY_LABELS_SHORT, weekDayLabelsShort);
-
- String [] monthLabels =
RenderKitUtils.asArray(calendarComponent.getMonthLabels());
- if(monthLabels == null) {
- monthLabels = dateFormat.getMonths();
- monthLabels = shiftDates(monthMin, monthMax, monthLabels);
- }
- RenderKitUtils.addToScriptHash(map, MONTH_LABELS, monthLabels);
-
-
- String [] monthLabelsShort =
RenderKitUtils.asArray(calendarComponent.getMonthLabelsShort());
- if(monthLabelsShort == null) {
- monthLabelsShort = dateFormat.getShortMonths();
- monthLabelsShort = shiftDates(monthMin, monthMax, monthLabelsShort);
- }
- RenderKitUtils.addToScriptHash(map, MONTH_LABELS_SHORT, monthLabelsShort);
-
- int minDaysInFirstWeek = calendarComponent.getMinDaysInFirstWeek();
- if(minDaysInFirstWeek == Integer.MIN_VALUE) {
- minDaysInFirstWeek = calendar.getMinimalDaysInFirstWeek();
- }
-
- if (0 <= minDaysInFirstWeek && minDaysInFirstWeek <= 7) {
- RenderKitUtils.addToScriptHash(map, MIN_DAYS_IN_FIRST_WEEK,
minDaysInFirstWeek);
- }
-
- int day = calendarComponent.getFirstWeekDay();
- if(day == Integer.MIN_VALUE) {
- day = calendar.getFirstDayOfWeek();
- day = calendar.getFirstDayOfWeek() -
calendar.getActualMinimum(Calendar.DAY_OF_WEEK);
- }
-
- if (0 <= day && day <= 6) {
- RenderKitUtils.addToScriptHash(map, FIRST_DAY_WEEK, day);
- } else if (day != Integer.MIN_VALUE) {
- facesContext.getExternalContext().log(day + " value of firstWeekDay
attribute is not a legal one for component: " + MessageUtil.getLabel(facesContext,
calendarComponent) + ". Default value was applied.");
- }
-
- return map;
- }
-
- public ScriptOptions createCalendarScriptOption(FacesContext facesContext,
UIComponent component) throws IOException {
- AbstractCalendar calendar = (AbstractCalendar)component;
- ScriptOptions scriptOptions = new ScriptOptions(component);
- scriptOptions.addOption(OPTION_ENABLE_MANUAL_INPUT);
- scriptOptions.addOption(OPTION_DISABLED);
- scriptOptions.addOption(OPTION_READONLY);
- scriptOptions.addOption(OPTION_RESET_TIME_ON_DATE_SELECT);
- scriptOptions.addOption(OPTION_SHOW_APPLY_BUTTON);
- scriptOptions.addOption(OPTION_POPUP);
- scriptOptions.addOption(OPTION_SHOW_INPUT);
- scriptOptions.addOption(OPTION_SHOW_HEADER);
- scriptOptions.addOption(OPTION_SHOW_FOOTER);
- scriptOptions.addOption(OPTION_SHOW_WEEKS_BAR);
- scriptOptions.addOption(OPTION_TODAY_CONTROL_MODE);
- scriptOptions.addOption(OPTION_DATE_PATTERN);
- scriptOptions.addOption(OPTION_JOINT_POINT);
- scriptOptions.addOption(OPTION_DIRECTION);
- scriptOptions.addOption(OPTION_BOUNDARY_DATES_MODE);
- scriptOptions.addOption(OPTION_HORIZONTAL_OFFSET);
- scriptOptions.addOption(OPTION_VERTICAL_OFFSET);
- scriptOptions.addOption(OPTION_CURRENT_DATE, getCurrentDate(facesContext,
calendar));
- scriptOptions.addOption(OPTION_SELECTED_DATE, getSelectedDate(facesContext,
calendar));
- scriptOptions.addOption(OPTION_DAY_CELL_CLASS, getDayCellClass(facesContext,
calendar));
- scriptOptions.addOption(OPTION_DAY_STYLE_CLASS, getDayStyleClass(facesContext,
calendar));
- /*
- *add to script option
- *<cdk:scriptOption attributes="ondateselected, ondateselect,
ontimeselect, ontimeselected, onchanged, ondatemouseover, ondatemouseout, onexpand,
oncollapse, oncurrentdateselect, oncurrentdateselected"
wrapper="eventHandler" />
- * */
- scriptOptions.addOption(OPTION_LABELS, getLabels(facesContext, calendar));
- scriptOptions.addOption(OPTION_DEFAULT_TIME, getPreparedDefaultTime(facesContext,
calendar));
- scriptOptions.addOption(OPTION_HIDE_POPUP_ON_SCROLL);
- scriptOptions.addOption("showWeekDaysBar");
-
- scriptOptions.addOption("styleClass");
- scriptOptions.addOption("style", HtmlUtil.concatStyles("z-index:
" + calendar.getZindex(), calendar.getStyle()));
-
- return scriptOptions;
- }
-
- public void buildAddLocaleScript(ResponseWriter writer, FacesContext facesContext,
UIComponent component) throws IOException {
- if(component instanceof AbstractCalendar) {
- AbstractCalendar calendar = (AbstractCalendar)component;
- JSFunction function = new
JSFunction("RichFaces.ui.Calendar.addLocale",
CalendarHelper.getAsLocale(facesContext, calendar), getLocaleOptions(facesContext,
calendar));
- writer.write(function.toScript());
- writer.write(";");
- }
- }
-
- public void buildCalendarScript(ResponseWriter writer, FacesContext facesContext,
UIComponent component) throws IOException {
- if(component instanceof AbstractCalendar) {
- AbstractCalendar calendar = (AbstractCalendar)component;
- ScriptOptions scriptOptions = createCalendarScriptOption(facesContext,
calendar);
- JSFunction function = new JSFunction("new RichFaces.ui.Calendar",
calendar.getClientId(facesContext), CalendarHelper.getAsLocale(facesContext, calendar),
scriptOptions, "");
- StringBuffer scriptBuffer = new StringBuffer();
- scriptBuffer.append(function.toScript()).append(".load();");
- writer.write(scriptBuffer.toString());
- }
- }
-
- public boolean isUseIcons(FacesContext facesContext, UIComponent component) {
- Object label = component.getAttributes().get("buttonLabel");
- return (label == null || ((String)label).trim().length() == 0);
- }
-
- protected Converter createDefaultConverter() {
- return new DateTimeConverter();
- }
-
- protected Converter setupConverter(FacesContext facesContext, Converter converter,
AbstractCalendar calendar) {
- if(converter == null || calendar == null) {
- return null;
- }
-
- if(converter instanceof DateTimeConverter) {
- DateTimeConverter defaultConverter = (DateTimeConverter) converter;
- defaultConverter.setPattern(calendar.getDatePattern());
- defaultConverter.setLocale( CalendarHelper.getAsLocale(facesContext,
calendar));
- defaultConverter.setTimeZone(calendar.getTimeZone());
- }
- return converter;
- }
-
-}
\ No newline at end of file
Copied:
trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java (from
rev 19755,
sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java)
===================================================================
--- trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
(rev 0)
+++
trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2010-10-29
11:48:42 UTC (rev 19760)
@@ -0,0 +1,609 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+import java.text.DateFormatSymbols;
+import java.text.Format;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.TimeZone;
+
+import javax.faces.application.ResourceDependencies;
+import javax.faces.application.ResourceDependency;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.faces.convert.DateTimeConverter;
+
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.javascript.JSReference;
+import org.richfaces.component.AbstractCalendar;
+import org.richfaces.component.util.HtmlUtil;
+import org.richfaces.component.util.MessageUtil;
+import org.richfaces.component.util.SelectUtils;
+import org.richfaces.component.util.ViewUtil;
+import org.richfaces.event.CurrentDateChangeEvent;
+import org.richfaces.utils.CalendarHelper;
+
+/**
+ * @author amarkhel
+ *
+ */
+
+@ResourceDependencies({ @ResourceDependency(library = "javax.faces", name =
"jsf.js"),
+ @ResourceDependency(name = "jquery.js"),
+ @ResourceDependency(name = "jquery.position.js"),
+ @ResourceDependency(name = "richfaces.js"),
+ @ResourceDependency(name = "richfaces-base-component.js"),
+ @ResourceDependency(name = "richfaces-event.js"),
+ @ResourceDependency(library = "org.richfaces", name =
"json-dom.js"),
+ @ResourceDependency(library = "org.richfaces", name =
"jquery.effects.core.js"),
+ @ResourceDependency(library = "org.richfaces", name =
"jquery.effects.highlight.js"),
+ @ResourceDependency(library = "org.richfaces", name =
"JQuerySpinBtn.js.js"),
+ @ResourceDependency(library = "org.richfaces", name =
"calendar-utils.js"),
+ @ResourceDependency(library = "org.richfaces", name =
"calendar.js"),
+ @ResourceDependency(library = "org.richfaces", name =
"calendar.ecss") })
+public class CalendarRendererBase extends InputRendererBase {
+
+ public static final String CALENDAR_BUNDLE =
"org.richfaces.renderkit.calendar";
+
+ public static final String OPTION_ENABLE_MANUAL_INPUT =
"enableManualInput";
+
+ public static final String OPTION_DISABLED = "disabled";
+
+ public static final String OPTION_READONLY = "readonly";
+
+ public static final String OPTION_RESET_TIME_ON_DATE_SELECT =
"resetTimeOnDateSelect";
+
+ public static final String OPTION_SHOW_APPLY_BUTTON = "showApplyButton";
+
+ public static final String OPTION_MIN_DAYS_IN_FIRST_WEEK =
"minDaysInFirstWeek";
+
+ public static final String OPTION_POPUP = "popup";
+
+ public static final String OPTION_SHOW_INPUT = "showInput";
+
+ public static final String OPTION_SHOW_HEADER = "showHeader";
+
+ public static final String OPTION_SHOW_FOOTER = "showFooter";
+
+ public static final String OPTION_SHOW_WEEKS_BAR = "showWeeksBar";
+
+ public static final String OPTION_TODAY_CONTROL_MODE = "todayControlMode";
+
+ public static final String OPTION_DATE_PATTERN = "datePattern";
+
+ public static final String OPTION_JOINT_POINT = "jointPoint";
+
+ public static final String OPTION_DIRECTION = "direction";
+
+ public static final String OPTION_BOUNDARY_DATES_MODE =
"boundaryDatesMode";
+
+ public static final String OPTION_HORIZONTAL_OFFSET = "horizontalOffset";
+
+ public static final String OPTION_VERTICAL_OFFSET = "verticalOffset";
+
+ public static final String OPTION_CURRENT_DATE = "currentDate";
+
+ public static final String OPTION_SELECTED_DATE = "selectedDate";
+
+ public static final String OPTION_DAY_CELL_CLASS = "dayCellClass";
+
+ public static final String OPTION_DAY_STYLE_CLASS = "dayStyleClass";
+
+ public static final String OPTION_LABELS = "labels";
+
+ public static final String OPTION_DEFAULT_TIME = "defaultTime";
+
+ public static final String OPTION_HIDE_POPUP_ON_SCROLL =
"hidePopupOnScroll";
+
+ public static final String OPTION_SHOW_WEEK_DAYS_BAR = "showWeekDaysBar";
+
+ public static final String MONTH_LABELS_SHORT = "monthLabelsShort";
+
+ public static final String MONTH_LABELS = "monthLabels";
+
+ public static final String WEEK_DAY_LABELS_SHORT = "weekDayLabelsShort";
+
+ public static final String WEEK_DAY_LABELS = "weekDayLabels";
+
+ public static final String FIRST_DAY_WEEK = "firstWeekDay";
+
+ public static final String MIN_DAYS_IN_FIRST_WEEK = "minDaysInFirstWeek";
+
+ public static final String CALENDAR_ICON_RESOURCE_NAME =
"calendarIcon.png";
+
+ public static final String CALENDAR_DISABLE_ICON_RESOURCE_NAME =
"disabledCalendarIcon.png";
+
+ public static final String CURRENT_DATE_INPUT = "InputCurrentDate";
+
+
+
+
+
+ protected static final Map<String, ComponentAttribute>
CALENDAR_INPUT_HANDLER_ATTRIBUTES =
Collections.unmodifiableMap(ComponentAttribute.createMap(
+ new ComponentAttribute(HtmlConstants.ONCLICK_ATTRIBUTE)
+ .setEventNames("inputclick")
+ .setComponentAttributeName("oninputclick"),
+ new ComponentAttribute(HtmlConstants.ONDBLCLICK_ATTRIBUTE)
+ .setEventNames("inputdblclick")
+ .setComponentAttributeName("oninputdblclick"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEDOWN_ATTRIBUTE)
+ .setEventNames("inputmousedown")
+ .setComponentAttributeName("oninputmousedown"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEUP_ATTRIBUTE)
+ .setEventNames("inputmouseup")
+ .setComponentAttributeName("oninputmouseup"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEOVER_ATTRIBUTE)
+ .setEventNames("inputmouseover")
+ .setComponentAttributeName("oninputmouseover"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEMOVE_ATTRIBUTE)
+ .setEventNames("inputmousemove")
+ .setComponentAttributeName("oninputmousemove"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEOUT_ATTRIBUTE)
+ .setEventNames("inputmouseout")
+ .setComponentAttributeName("oninputmouseout"),
+ new ComponentAttribute(HtmlConstants.ONKEYPRESS_ATTRIBUTE)
+ .setEventNames("inputkeypress")
+ .setComponentAttributeName("oninputkeypress"),
+ new ComponentAttribute(HtmlConstants.ONKEYDOWN_ATTRIBUTE)
+ .setEventNames("inputkeydown")
+ .setComponentAttributeName("oninputkeydown"),
+ new ComponentAttribute(HtmlConstants.ONKEYUP_ATTRIBUTE)
+ .setEventNames("inputkeyup")
+ .setComponentAttributeName("oninputkeyup"),
+ new ComponentAttribute(HtmlConstants.ONBLUR_ATTRIBUTE)
+ .setEventNames("inputblur")
+ .setComponentAttributeName("oninputblur"),
+ new ComponentAttribute(HtmlConstants.ONFOCUS_ATTRIBUTE)
+ .setEventNames("inputfocus")
+ .setComponentAttributeName("oninputfocus"),
+ new ComponentAttribute(HtmlConstants.ONCHANGE_ATTRIBUTE)
+ .setEventNames("inputchange")
+ .setComponentAttributeName("oninputchange"),
+ new ComponentAttribute(HtmlConstants.ONSELECT_ATTRIBUTE)
+ .setEventNames("inputselect")
+ .setComponentAttributeName("oninputselect")));
+
+ private static final String HOURS_VALUE = "hours";
+
+ private static final String MINUTES_VALUE = "minutes";
+
+ protected void doDecode(FacesContext context, UIComponent component) {
+ if(!(component instanceof AbstractCalendar)) {
+ return;
+ }
+
+ AbstractCalendar calendar = (AbstractCalendar)component;
+ if (calendar.isDisable()){
+ return;
+ }
+
+ Map<String, String> requestParameterMap =
context.getExternalContext().getRequestParameterMap();
+
+ String clientId = calendar.getClientId(context);
+ String currentDateString = (String) requestParameterMap.get(clientId +
CURRENT_DATE_INPUT);
+ if (currentDateString != null) {
+ calendar.queueEvent(new CurrentDateChangeEvent(calendar,
currentDateString));
+ }
+
+ String selectedDateString = (String) requestParameterMap.get(clientId +
"InputDate");
+ if (selectedDateString != null) {
+ calendar.setSubmittedValue(selectedDateString);
+ }
+ }
+
+ public void renderInputHandlers(FacesContext facesContext, UIComponent component)
throws IOException {
+ RenderKitUtils.renderPassThroughAttributesOptimized(facesContext, component,
CALENDAR_INPUT_HANDLER_ATTRIBUTES);
+ }
+
+ @Override
+ public Object getConvertedValue(FacesContext facesContext, UIComponent component,
Object submittedValue) throws ConverterException {
+ if ((facesContext == null) || (component == null)) {
+ throw new NullPointerException();
+ }
+
+ // skip conversion of already converted date
+ if (submittedValue instanceof Date) {
+ return (Date)submittedValue;
+ }
+
+ // Store submitted value in the local variable as a string
+ String newValue = (String) submittedValue;
+ // if we have no local value, try to get the valueExpression.
+ AbstractCalendar calendar = (AbstractCalendar) component;
+ Converter converter = SelectUtils.getConverterForProperty(facesContext, calendar,
"value");
+
+ // in case the converter hasn't been set, try to use default
+ // DateTimeConverter
+ if (converter == null) {
+ converter = createDefaultConverter();
+ }
+ setupConverter(facesContext, converter, calendar);
+ return converter.getAsObject(facesContext, component, newValue);
+ }
+
+ @Override
+ public String getInputValue(FacesContext facesContext, UIComponent component) {
+ if(!(component instanceof AbstractCalendar)) {
+ return null;
+ }
+
+ AbstractCalendar calendar = (AbstractCalendar) component;
+ String value = (String) calendar.getSubmittedValue();
+ if (value == null) {
+ Object curVal = calendar.getValue();
+ Converter converter = SelectUtils.getConverterForProperty(facesContext,
calendar, "value");
+
+ if(converter == null) {
+ converter = createDefaultConverter();
+ setupConverter(facesContext, converter, calendar);
+ }
+
+ if (converter != null) {
+ value = converter.getAsString(facesContext, calendar, curVal);
+ } else {
+ value = curVal !=null ? curVal.toString() : "";
+ }
+ }
+
+ if (value == null) {
+ value = "";
+ }
+
+ return value;
+
+ }
+
+ public String getButtonIcon(FacesContext facesContext, UIComponent component) {
+ boolean disable = (Boolean)component.getAttributes().get("disable");
+ String buttonIcon =
(String)component.getAttributes().get("buttonIcon");
+ if(disable) {
+ buttonIcon =
(String)component.getAttributes().get("buttonIconDisabled");
+ }
+
+ if(buttonIcon != null && buttonIcon.trim().length() != 0) {
+ buttonIcon = ViewUtil.getResourceURL(buttonIcon, facesContext);
+ } else {
+ buttonIcon = disable ? CALENDAR_ICON_RESOURCE_NAME:
CALENDAR_ICON_RESOURCE_NAME;
+ buttonIcon = RenderKitUtils.getResourcePath(facesContext,
"org.richfaces.images",buttonIcon);
+ }
+
+ return buttonIcon;
+ }
+
+ public Object getSelectedDate(FacesContext facesContext, UIComponent component)
throws IOException {
+ Object returnValue = null;
+ AbstractCalendar calendar = (AbstractCalendar)component;
+ if(calendar.isValid()) {
+ Date date;
+ Object value = calendar.getValue();
+ date = CalendarHelper.getAsDate(facesContext, calendar, value);
+ if(date != null) {
+ returnValue = formatSelectedDate(calendar.getTimeZone(), date);
+ }
+ }
+ return returnValue;
+ }
+
+ public static Object formatSelectedDate(TimeZone timeZone, Date date) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTimeZone(timeZone);
+ calendar.setTime(date);
+
+ JSFunction result = new JSFunction("new Date");
+ result.addParameter(Integer.valueOf(calendar.get(Calendar.YEAR)));
+ result.addParameter(Integer.valueOf(calendar.get(Calendar.MONTH)));
+ result.addParameter(Integer.valueOf(calendar.get(Calendar.DATE)));
+ result.addParameter(Integer.valueOf(calendar.get(Calendar.HOUR_OF_DAY)));
+ result.addParameter(Integer.valueOf(calendar.get(Calendar.MINUTE)));
+ result.addParameter(new Integer(0));
+
+ return result;
+ }
+
+ public Object getCurrentDate(FacesContext facesContext, AbstractCalendar calendar)
throws IOException {
+ Date date = CalendarHelper.getCurrentDateOrDefault(facesContext, calendar);
+ return formatDate(date);
+ }
+
+ public String getCurrentDateAsString(FacesContext facesContext, UIComponent
component) throws IOException {
+ AbstractCalendar calendar = (AbstractCalendar)component;
+ Format formatter = new SimpleDateFormat("MM/yyyy");
+
+ Date currentDate = CalendarHelper.getCurrentDateOrDefault(facesContext,
calendar);
+ return formatter.format(currentDate);
+ }
+
+ public static Object formatDate(Date date) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ JSFunction result = new JSFunction("new Date");
+ result.addParameter(Integer.valueOf(calendar.get(Calendar.YEAR)));
+ result.addParameter(Integer.valueOf(calendar.get(Calendar.MONTH)));
+ result.addParameter(Integer.valueOf(calendar.get(Calendar.DATE)));
+
+ return result;
+ }
+
+ public String getDayCellClass(FacesContext facesContext, AbstractCalendar calendar)
{
+ //TODO: refactor this
+ /*
+ String cellwidth = (String)
component.getAttributes().get("cellWidth");
+ String cellheight = (String)
component.getAttributes().get("cellHeight");
+ if (cellwidth != null && cellwidth.length() != 0 || cellheight != null
+ && cellheight.length() != 0) {
+ String clientId = component.getClientId(context);
+ String value = clientId.replace(':', '_') +
"DayCell";
+ return value;
+ }
+ */
+ return null;
+ }
+
+ public JSReference getIsDayEnabled(FacesContext facesContext, AbstractCalendar
calendar) {
+ return calendar.isDayEnabled() ? JSReference.TRUE : JSReference.FALSE;
+ }
+
+ public JSReference getDayStyleClass(FacesContext context, AbstractCalendar calendar)
{
+ String dayStyleClass = calendar.getDayStyleClass();
+ return ((dayStyleClass != null && dayStyleClass.trim().length() != 0)) ?
new JSReference(dayStyleClass) : null;
+ }
+
+
+ public Map<String, Object> getLabels(FacesContext facesContext,
AbstractCalendar calendar) {
+ ResourceBundle bundle1 = null;
+ ResourceBundle bundle2 = null;
+
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+
+ String messageBundle = facesContext.getApplication().getMessageBundle();
+ Locale locale = CalendarHelper.getAsLocale(facesContext, calendar);
+ if (null != messageBundle) {
+ bundle1 = ResourceBundle.getBundle(messageBundle,locale , loader);
+ }
+
+ try {
+ bundle2 = ResourceBundle.getBundle(CALENDAR_BUNDLE, locale, loader);
+ } catch (MissingResourceException e) {
+ //No external bundle was found, ignore this exception.
+ }
+
+ ResourceBundle [] bundles = {bundle1, bundle2};
+ String[] names = {"apply", "today", "clean",
"cancel", "ok", "close"};
+
+ return getCollectedLabels(bundles, names);
+ }
+
+ protected Map<String, Object> getCollectedLabels(ResourceBundle [] bundles ,
String[] names) {
+ Map<String, Object> labels = new HashMap<String, Object>();
+ if(bundles != null && names != null) {
+ for (String name: names) {
+ String label = null;
+ String bundleKey = "RICH_CALENDAR_" + name.toUpperCase() +
"_LABEL";
+ for(ResourceBundle bundle: bundles) {
+ if (bundle != null) {
+ try {
+ label = bundle.getString(bundleKey);
+ } catch (MissingResourceException mre) {
+ // Current key was not found, ignore this exception;
+ }
+ }
+ if(label != null) {
+ break;
+ }
+ }
+ RenderKitUtils.addToScriptHash(labels, name, label);
+ }
+ }
+ return labels;
+ }
+
+ public Map<String, Object> getPreparedDefaultTime(FacesContext facesContext,
AbstractCalendar abstractCalendar) {
+ Date date = CalendarHelper.getFormattedDefaultTime(abstractCalendar);
+ Map<String, Object> result = new HashMap<String, Object>();
+ if (date != null) {
+ Calendar calendar = CalendarHelper.getCalendar(facesContext,
abstractCalendar);
+ calendar.setTime(date);
+ int hours = calendar.get(Calendar.HOUR_OF_DAY);
+ int minutes = calendar.get(Calendar.MINUTE);
+
+ if (hours != 12 || minutes != 0) {
+ result.put(HOURS_VALUE, hours);
+ result.put(MINUTES_VALUE, minutes);
+ }
+ }
+ return result;
+ }
+
+ private static String[] shiftDates(int minimum, int maximum, String[] labels) {
+ if (minimum == 0 && (maximum - minimum == labels.length - 1)) {
+ return labels;
+ }
+
+ String[] shiftedLabels = new String[maximum - minimum + 1];
+ System.arraycopy(labels, minimum, shiftedLabels, 0, maximum - minimum
+ + 1);
+
+ return shiftedLabels;
+ }
+
+ protected Map<String, Object> getLocaleOptions(FacesContext facesContext,
AbstractCalendar calendarComponent) {
+ Map<String, Object> map = new HashMap<String, Object>();
+
+ Locale locale = CalendarHelper.getAsLocale(facesContext, calendarComponent);
+ DateFormatSymbols dateFormat = new DateFormatSymbols(locale);
+
+ Calendar calendar = CalendarHelper.getCalendar(facesContext, calendarComponent);
+ int maximum = calendar.getActualMaximum(Calendar.DAY_OF_WEEK);
+ int minimum = calendar.getActualMinimum(Calendar.DAY_OF_WEEK);
+
+ int monthMax = calendar.getActualMaximum(Calendar.MONTH);
+ int monthMin = calendar.getActualMinimum(Calendar.MONTH);
+
+ String [] weekDayLabels =
RenderKitUtils.asArray(calendarComponent.getWeekDayLabels());
+ if(weekDayLabels == null) {
+ weekDayLabels = dateFormat.getWeekdays();
+ weekDayLabels = shiftDates(minimum, maximum, weekDayLabels);
+ }
+ RenderKitUtils.addToScriptHash(map, WEEK_DAY_LABELS, weekDayLabels);
+
+ String [] weekDayLabelsShort =
RenderKitUtils.asArray(calendarComponent.getWeekDayLabelsShort());
+ if(weekDayLabelsShort == null) {
+ weekDayLabelsShort = dateFormat.getShortWeekdays();
+ weekDayLabelsShort = shiftDates(minimum, maximum, weekDayLabelsShort);
+ }
+ RenderKitUtils.addToScriptHash(map, WEEK_DAY_LABELS_SHORT, weekDayLabelsShort);
+
+ String [] monthLabels =
RenderKitUtils.asArray(calendarComponent.getMonthLabels());
+ if(monthLabels == null) {
+ monthLabels = dateFormat.getMonths();
+ monthLabels = shiftDates(monthMin, monthMax, monthLabels);
+ }
+ RenderKitUtils.addToScriptHash(map, MONTH_LABELS, monthLabels);
+
+
+ String [] monthLabelsShort =
RenderKitUtils.asArray(calendarComponent.getMonthLabelsShort());
+ if(monthLabelsShort == null) {
+ monthLabelsShort = dateFormat.getShortMonths();
+ monthLabelsShort = shiftDates(monthMin, monthMax, monthLabelsShort);
+ }
+ RenderKitUtils.addToScriptHash(map, MONTH_LABELS_SHORT, monthLabelsShort);
+
+ int minDaysInFirstWeek = calendarComponent.getMinDaysInFirstWeek();
+ if(minDaysInFirstWeek == Integer.MIN_VALUE) {
+ minDaysInFirstWeek = calendar.getMinimalDaysInFirstWeek();
+ }
+
+ if (0 <= minDaysInFirstWeek && minDaysInFirstWeek <= 7) {
+ RenderKitUtils.addToScriptHash(map, MIN_DAYS_IN_FIRST_WEEK,
minDaysInFirstWeek);
+ }
+
+ int day = calendarComponent.getFirstWeekDay();
+ if(day == Integer.MIN_VALUE) {
+ day = calendar.getFirstDayOfWeek();
+ day = calendar.getFirstDayOfWeek() -
calendar.getActualMinimum(Calendar.DAY_OF_WEEK);
+ }
+
+ if (0 <= day && day <= 6) {
+ RenderKitUtils.addToScriptHash(map, FIRST_DAY_WEEK, day);
+ } else if (day != Integer.MIN_VALUE) {
+ facesContext.getExternalContext().log(day + " value of firstWeekDay
attribute is not a legal one for component: " + MessageUtil.getLabel(facesContext,
calendarComponent) + ". Default value was applied.");
+ }
+
+ return map;
+ }
+
+ public ScriptOptions createCalendarScriptOption(FacesContext facesContext,
UIComponent component) throws IOException {
+ AbstractCalendar calendar = (AbstractCalendar)component;
+ ScriptOptions scriptOptions = new ScriptOptions(component);
+ scriptOptions.addOption(OPTION_ENABLE_MANUAL_INPUT);
+ scriptOptions.addOption(OPTION_DISABLED);
+ scriptOptions.addOption(OPTION_READONLY);
+ scriptOptions.addOption(OPTION_RESET_TIME_ON_DATE_SELECT);
+ scriptOptions.addOption(OPTION_SHOW_APPLY_BUTTON);
+ scriptOptions.addOption(OPTION_POPUP);
+ scriptOptions.addOption(OPTION_SHOW_INPUT);
+ scriptOptions.addOption(OPTION_SHOW_HEADER);
+ scriptOptions.addOption(OPTION_SHOW_FOOTER);
+ scriptOptions.addOption(OPTION_SHOW_WEEKS_BAR);
+ scriptOptions.addOption(OPTION_TODAY_CONTROL_MODE);
+ scriptOptions.addOption(OPTION_DATE_PATTERN);
+ scriptOptions.addOption(OPTION_JOINT_POINT);
+ scriptOptions.addOption(OPTION_DIRECTION);
+ scriptOptions.addOption(OPTION_BOUNDARY_DATES_MODE);
+ scriptOptions.addOption(OPTION_HORIZONTAL_OFFSET);
+ scriptOptions.addOption(OPTION_VERTICAL_OFFSET);
+ scriptOptions.addOption(OPTION_CURRENT_DATE, getCurrentDate(facesContext,
calendar));
+ scriptOptions.addOption(OPTION_SELECTED_DATE, getSelectedDate(facesContext,
calendar));
+ scriptOptions.addOption(OPTION_DAY_CELL_CLASS, getDayCellClass(facesContext,
calendar));
+ scriptOptions.addOption(OPTION_DAY_STYLE_CLASS, getDayStyleClass(facesContext,
calendar));
+ /*
+ *add to script option
+ *<cdk:scriptOption attributes="ondateselected, ondateselect,
ontimeselect, ontimeselected, onchanged, ondatemouseover, ondatemouseout, onexpand,
oncollapse, oncurrentdateselect, oncurrentdateselected"
wrapper="eventHandler" />
+ * */
+ scriptOptions.addOption(OPTION_LABELS, getLabels(facesContext, calendar));
+ scriptOptions.addOption(OPTION_DEFAULT_TIME, getPreparedDefaultTime(facesContext,
calendar));
+ scriptOptions.addOption(OPTION_HIDE_POPUP_ON_SCROLL);
+ scriptOptions.addOption("showWeekDaysBar");
+
+ scriptOptions.addOption("styleClass");
+ scriptOptions.addOption("style", HtmlUtil.concatStyles("z-index:
" + calendar.getZindex(), calendar.getStyle()));
+
+ return scriptOptions;
+ }
+
+ public void buildAddLocaleScript(ResponseWriter writer, FacesContext facesContext,
UIComponent component) throws IOException {
+ if(component instanceof AbstractCalendar) {
+ AbstractCalendar calendar = (AbstractCalendar)component;
+ JSFunction function = new
JSFunction("RichFaces.ui.Calendar.addLocale",
CalendarHelper.getAsLocale(facesContext, calendar), getLocaleOptions(facesContext,
calendar));
+ writer.write(function.toScript());
+ writer.write(";");
+ }
+ }
+
+ public void buildCalendarScript(ResponseWriter writer, FacesContext facesContext,
UIComponent component) throws IOException {
+ if(component instanceof AbstractCalendar) {
+ AbstractCalendar calendar = (AbstractCalendar)component;
+ ScriptOptions scriptOptions = createCalendarScriptOption(facesContext,
calendar);
+ JSFunction function = new JSFunction("new RichFaces.ui.Calendar",
calendar.getClientId(facesContext), CalendarHelper.getAsLocale(facesContext, calendar),
scriptOptions, "");
+ StringBuffer scriptBuffer = new StringBuffer();
+ scriptBuffer.append(function.toScript()).append(".load();");
+ writer.write(scriptBuffer.toString());
+ }
+ }
+
+ public boolean isUseIcons(FacesContext facesContext, UIComponent component) {
+ Object label = component.getAttributes().get("buttonLabel");
+ return (label == null || ((String)label).trim().length() == 0);
+ }
+
+ protected Converter createDefaultConverter() {
+ return new DateTimeConverter();
+ }
+
+ protected Converter setupConverter(FacesContext facesContext, Converter converter,
AbstractCalendar calendar) {
+ if(converter == null || calendar == null) {
+ return null;
+ }
+
+ if(converter instanceof DateTimeConverter) {
+ DateTimeConverter defaultConverter = (DateTimeConverter) converter;
+ defaultConverter.setPattern(calendar.getDatePattern());
+ defaultConverter.setLocale( CalendarHelper.getAsLocale(facesContext,
calendar));
+ defaultConverter.setTimeZone(calendar.getTimeZone());
+ }
+ return converter;
+ }
+
+}
\ No newline at end of file
Deleted:
trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarIcon.java
===================================================================
---
sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarIcon.java 2010-10-29
09:58:54 UTC (rev 19754)
+++
trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarIcon.java 2010-10-29
11:48:42 UTC (rev 19760)
@@ -1,164 +0,0 @@
-package org.richfaces.renderkit.html.images;
-
-import java.awt.BasicStroke;
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.GradientPaint;
-import java.awt.Graphics2D;
-import java.awt.Paint;
-import java.awt.RenderingHints;
-import java.awt.geom.Rectangle2D;
-import java.awt.geom.RoundRectangle2D;
-import java.awt.image.BufferedImage;
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-import java.util.Date;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-
-import org.richfaces.resource.DynamicResource;
-import org.richfaces.resource.ImageType;
-import org.richfaces.resource.Java2DUserResource;
-import org.richfaces.resource.PostConstructResource;
-import org.richfaces.resource.StateHolderResource;
-import org.richfaces.skin.Skin;
-import org.richfaces.skin.SkinFactory;
-
-/**
- * @author amarkhel
- *
- */
-@DynamicResource
-public class CalendarIcon implements Java2DUserResource, StateHolderResource{
-
- private static final Dimension DIMENSION = new Dimension(20, 20);
-
- private Integer headerTextColor;
-
- private Integer headerBackgroundColor;
-
-
- @PostConstructResource
- public final void initialize() {
- FacesContext context = FacesContext.getCurrentInstance();
- Skin skin = SkinFactory.getInstance(context).getSkin(context);
-
- this.headerTextColor = skin.getColorParameter(context,
Skin.HEADER_BACKGROUND_COLOR);
- this.headerBackgroundColor = skin.getColorParameter(context,
Skin.SELECT_CONTROL_COLOR);
- }
-
-
- public boolean isTransient() {
- return false;
- }
-
- public void writeState(FacesContext context, DataOutput dataOutput) throws
IOException {
- dataOutput.writeInt(this.headerTextColor);
- dataOutput.writeInt(this.headerBackgroundColor);
- }
-
- public void readState(FacesContext context, DataInput dataInput) throws IOException
{
- this.headerTextColor = dataInput.readInt();
- this.headerBackgroundColor = dataInput.readInt();
- }
-
- public Map<String, String> getResponseHeaders() {
- return null;
- }
-
- public Date getLastModified() {
- return null;
- }
-
- public ImageType getImageType() {
- return ImageType.PNG;
- }
-
- public Dimension getDimension() {
- return DIMENSION;
- }
-
- protected BufferedImage createImage(int width, int height) {
- return new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
- }
-
- public void paint(Graphics2D graphics2d, Dimension dimension) {
- BufferedImage image = paintImage();
- graphics2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
- graphics2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
- graphics2d.drawImage(image, 0, 0, dimension.width, dimension.height, null);
- }
-
- public BufferedImage paintImage() {
-
- BufferedImage image = createImage(16, 16);
-
- Graphics2D g2d = image.createGraphics();
-
- Color borderColor = new Color(this.headerTextColor);
- Color activeColor = new Color(this.headerBackgroundColor);
-
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
- g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,
RenderingHints.VALUE_COLOR_RENDER_QUALITY);
-
- g2d.setStroke(new BasicStroke(1));
-
- int w = 16;
- int h = 16;
-
- //Draw Border
- g2d.setColor(borderColor);
- Rectangle2D border = new Rectangle2D.Double(1, 1, w - 3, h - 3);
- RoundRectangle2D round = new RoundRectangle2D.Double(1, 1, w- 3, h - 3, 2, 2);
- g2d.draw(round);
-
- Color lightBlue = new Color(216, 226, 240);
- Paint gradient1 = new GradientPaint(w-4, h-4, lightBlue, 2, 2, Color.white);
- g2d.setPaint(gradient1);
- border = new Rectangle2D.Double(2, 2, w - 4, h - 4);
- g2d.fill(border);
-
- border = new Rectangle2D.Double(3, 3, w - 6, h - 6);
- gradient1 = new GradientPaint(3, 3, lightBlue , w - 6, h - 6, borderColor);
- g2d.setPaint(gradient1);
- g2d.fill(border);
-
- g2d.setColor(Color.white);
- g2d.drawLine(3, 6, 3, 11);
- g2d.drawLine(5, 6, 5, 11);
- g2d.drawLine(7, 6, 7, 11);
- g2d.drawLine(9, 6, 9, 11);
- g2d.drawLine(11, 6, 11, 11);
-
- //Draw orange rectangle
- border = new Rectangle2D.Double(3, 3, 10, 3);
- g2d.setColor(Color.white);
- g2d.fill(border);
-
- Color c = new Color(activeColor.getRed(), activeColor.getGreen(),
activeColor.getBlue(), 100);
- Color c2 = new Color(activeColor.getRed(), activeColor.getGreen(),
activeColor.getBlue(), 200);
-
- gradient1 = new GradientPaint(12, 4, activeColor, 4, 7, c2);
- g2d.setPaint(gradient1);
- g2d.fill(border);
- //g2d.setColor(activeColor);
-
- c = new Color(activeColor.getRed(), activeColor.getGreen(),
activeColor.getBlue(), 150);
- c2 = new Color(activeColor.getRed(), activeColor.getGreen(),
activeColor.getBlue(), 200);
- border = new Rectangle2D.Double(4, 4, 8, 1);
-
- g2d.setColor(Color.white);
- g2d.fill(border);
-
- gradient1 = new GradientPaint(4, 4, c, 10, 4, c2);
- //g2d.setPaint(gradient1);
- g2d.setColor(c);
- g2d.fill(border);
-
- g2d.dispose();
-
- return image;
- }
-}
Copied:
trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarIcon.java
(from rev 19756,
sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarIcon.java)
===================================================================
---
trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarIcon.java
(rev 0)
+++
trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarIcon.java 2010-10-29
11:48:42 UTC (rev 19760)
@@ -0,0 +1,186 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.renderkit.html.images;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.Paint;
+import java.awt.RenderingHints;
+import java.awt.geom.Rectangle2D;
+import java.awt.geom.RoundRectangle2D;
+import java.awt.image.BufferedImage;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.Date;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.resource.DynamicResource;
+import org.richfaces.resource.ImageType;
+import org.richfaces.resource.Java2DUserResource;
+import org.richfaces.resource.PostConstructResource;
+import org.richfaces.resource.StateHolderResource;
+import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
+
+/**
+ * @author amarkhel
+ *
+ */
+@DynamicResource
+public class CalendarIcon implements Java2DUserResource, StateHolderResource{
+
+ private static final Dimension DIMENSION = new Dimension(20, 20);
+
+ private Integer headerTextColor;
+
+ private Integer headerBackgroundColor;
+
+
+ @PostConstructResource
+ public final void initialize() {
+ FacesContext context = FacesContext.getCurrentInstance();
+ Skin skin = SkinFactory.getInstance(context).getSkin(context);
+
+ this.headerTextColor = skin.getColorParameter(context,
Skin.HEADER_BACKGROUND_COLOR);
+ this.headerBackgroundColor = skin.getColorParameter(context,
Skin.SELECT_CONTROL_COLOR);
+ }
+
+
+ public boolean isTransient() {
+ return false;
+ }
+
+ public void writeState(FacesContext context, DataOutput dataOutput) throws
IOException {
+ dataOutput.writeInt(this.headerTextColor);
+ dataOutput.writeInt(this.headerBackgroundColor);
+ }
+
+ public void readState(FacesContext context, DataInput dataInput) throws IOException
{
+ this.headerTextColor = dataInput.readInt();
+ this.headerBackgroundColor = dataInput.readInt();
+ }
+
+ public Map<String, String> getResponseHeaders() {
+ return null;
+ }
+
+ public Date getLastModified() {
+ return null;
+ }
+
+ public ImageType getImageType() {
+ return ImageType.PNG;
+ }
+
+ public Dimension getDimension() {
+ return DIMENSION;
+ }
+
+ protected BufferedImage createImage(int width, int height) {
+ return new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
+ }
+
+ public void paint(Graphics2D graphics2d, Dimension dimension) {
+ BufferedImage image = paintImage();
+ graphics2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
+ graphics2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+ graphics2d.drawImage(image, 0, 0, dimension.width, dimension.height, null);
+ }
+
+ public BufferedImage paintImage() {
+
+ BufferedImage image = createImage(16, 16);
+
+ Graphics2D g2d = image.createGraphics();
+
+ Color borderColor = new Color(this.headerTextColor);
+ Color activeColor = new Color(this.headerBackgroundColor);
+
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
+ g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,
RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+
+ g2d.setStroke(new BasicStroke(1));
+
+ int w = 16;
+ int h = 16;
+
+ //Draw Border
+ g2d.setColor(borderColor);
+ Rectangle2D border = new Rectangle2D.Double(1, 1, w - 3, h - 3);
+ RoundRectangle2D round = new RoundRectangle2D.Double(1, 1, w- 3, h - 3, 2, 2);
+ g2d.draw(round);
+
+ Color lightBlue = new Color(216, 226, 240);
+ Paint gradient1 = new GradientPaint(w-4, h-4, lightBlue, 2, 2, Color.white);
+ g2d.setPaint(gradient1);
+ border = new Rectangle2D.Double(2, 2, w - 4, h - 4);
+ g2d.fill(border);
+
+ border = new Rectangle2D.Double(3, 3, w - 6, h - 6);
+ gradient1 = new GradientPaint(3, 3, lightBlue , w - 6, h - 6, borderColor);
+ g2d.setPaint(gradient1);
+ g2d.fill(border);
+
+ g2d.setColor(Color.white);
+ g2d.drawLine(3, 6, 3, 11);
+ g2d.drawLine(5, 6, 5, 11);
+ g2d.drawLine(7, 6, 7, 11);
+ g2d.drawLine(9, 6, 9, 11);
+ g2d.drawLine(11, 6, 11, 11);
+
+ //Draw orange rectangle
+ border = new Rectangle2D.Double(3, 3, 10, 3);
+ g2d.setColor(Color.white);
+ g2d.fill(border);
+
+ Color c = new Color(activeColor.getRed(), activeColor.getGreen(),
activeColor.getBlue(), 100);
+ Color c2 = new Color(activeColor.getRed(), activeColor.getGreen(),
activeColor.getBlue(), 200);
+
+ gradient1 = new GradientPaint(12, 4, activeColor, 4, 7, c2);
+ g2d.setPaint(gradient1);
+ g2d.fill(border);
+ //g2d.setColor(activeColor);
+
+ c = new Color(activeColor.getRed(), activeColor.getGreen(),
activeColor.getBlue(), 150);
+ c2 = new Color(activeColor.getRed(), activeColor.getGreen(),
activeColor.getBlue(), 200);
+ border = new Rectangle2D.Double(4, 4, 8, 1);
+
+ g2d.setColor(Color.white);
+ g2d.fill(border);
+
+ gradient1 = new GradientPaint(4, 4, c, 10, 4, c2);
+ //g2d.setPaint(gradient1);
+ g2d.setColor(c);
+ g2d.fill(border);
+
+ g2d.dispose();
+
+ return image;
+ }
+}
Deleted:
trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarSeparator.java
===================================================================
---
sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarSeparator.java 2010-10-29
09:58:54 UTC (rev 19754)
+++
trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarSeparator.java 2010-10-29
11:48:42 UTC (rev 19760)
@@ -1,84 +0,0 @@
-package org.richfaces.renderkit.html.images;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-import java.util.Date;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-
-import org.richfaces.resource.ImageType;
-import org.richfaces.resource.Java2DUserResource;
-import org.richfaces.resource.PostConstructResource;
-import org.richfaces.resource.StateHolderResource;
-import org.richfaces.skin.Skin;
-import org.richfaces.skin.SkinFactory;
-
-/**
- * @author amarkhel
- *
- */
-public class CalendarSeparator implements Java2DUserResource, StateHolderResource {
-
- private static final Dimension DIMENSION = new Dimension(1, 15);
-
- private Integer headerTextColor;
-
- @PostConstructResource
- public void initialize() {
- FacesContext context = FacesContext.getCurrentInstance();
- Skin skin = SkinFactory.getInstance(context).getSkin(context);
-
- this.headerTextColor = skin.getColorParameter(context, Skin.HEAD_TEXT_COLOR);
- }
-
- public boolean isTransient() {
- return false;
- }
-
- public void writeState(FacesContext context, DataOutput dataOutput) throws
IOException {
- dataOutput.writeInt(this.headerTextColor);
- }
-
- public void readState(FacesContext context, DataInput dataInput) throws IOException
{
- this.headerTextColor = dataInput.readInt();
- }
-
- public Map<String, String> getResponseHeaders() {
- return null;
- }
-
- public Date getLastModified() {
- return null;
- }
-
- public ImageType getImageType() {
- return ImageType.PNG;
- }
-
- public Dimension getDimension() {
- return DIMENSION;
- }
-
- public void paint(Graphics2D graphics2d, Dimension dimension) {
- graphics2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_OFF);
- graphics2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
RenderingHints.VALUE_STROKE_NORMALIZE);
- graphics2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,
RenderingHints.VALUE_COLOR_RENDER_QUALITY);
- graphics2d.setRenderingHint(RenderingHints.KEY_DITHERING,
RenderingHints.VALUE_DITHER_DISABLE);
- graphics2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION,
RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
- graphics2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
- graphics2d.setRenderingHint(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
-
- Color color = new Color(this.headerTextColor);
- graphics2d.setColor(color);
-
- for (int i = 0;i < DIMENSION.getHeight(); i += 2 ) {
- graphics2d.drawLine(0, i, 0, i);
- }
- }
-}
Copied:
trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarSeparator.java
(from rev 19756,
sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarSeparator.java)
===================================================================
---
trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarSeparator.java
(rev 0)
+++
trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarSeparator.java 2010-10-29
11:48:42 UTC (rev 19760)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.renderkit.html.images;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.Date;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.resource.ImageType;
+import org.richfaces.resource.Java2DUserResource;
+import org.richfaces.resource.PostConstructResource;
+import org.richfaces.resource.StateHolderResource;
+import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
+
+/**
+ * @author amarkhel
+ *
+ */
+public class CalendarSeparator implements Java2DUserResource, StateHolderResource {
+
+ private static final Dimension DIMENSION = new Dimension(1, 15);
+
+ private Integer headerTextColor;
+
+ @PostConstructResource
+ public void initialize() {
+ FacesContext context = FacesContext.getCurrentInstance();
+ Skin skin = SkinFactory.getInstance(context).getSkin(context);
+
+ this.headerTextColor = skin.getColorParameter(context, Skin.HEAD_TEXT_COLOR);
+ }
+
+ public boolean isTransient() {
+ return false;
+ }
+
+ public void writeState(FacesContext context, DataOutput dataOutput) throws
IOException {
+ dataOutput.writeInt(this.headerTextColor);
+ }
+
+ public void readState(FacesContext context, DataInput dataInput) throws IOException
{
+ this.headerTextColor = dataInput.readInt();
+ }
+
+ public Map<String, String> getResponseHeaders() {
+ return null;
+ }
+
+ public Date getLastModified() {
+ return null;
+ }
+
+ public ImageType getImageType() {
+ return ImageType.PNG;
+ }
+
+ public Dimension getDimension() {
+ return DIMENSION;
+ }
+
+ public void paint(Graphics2D graphics2d, Dimension dimension) {
+ graphics2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_OFF);
+ graphics2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
RenderingHints.VALUE_STROKE_NORMALIZE);
+ graphics2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,
RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+ graphics2d.setRenderingHint(RenderingHints.KEY_DITHERING,
RenderingHints.VALUE_DITHER_DISABLE);
+ graphics2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION,
RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
+ graphics2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+ graphics2d.setRenderingHint(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
+
+ Color color = new Color(this.headerTextColor);
+ graphics2d.setColor(color);
+
+ for (int i = 0;i < DIMENSION.getHeight(); i += 2 ) {
+ graphics2d.drawLine(0, i, 0, i);
+ }
+ }
+}
Deleted:
trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/DisabledCalendarIcon.java
===================================================================
---
sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/DisabledCalendarIcon.java 2010-10-29
09:58:54 UTC (rev 19754)
+++
trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/DisabledCalendarIcon.java 2010-10-29
11:48:42 UTC (rev 19760)
@@ -1,46 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit.html.images;
-
-import java.awt.Transparency;
-import java.awt.color.ColorSpace;
-import java.awt.image.BufferedImage;
-import java.awt.image.ComponentColorModel;
-import java.awt.image.DataBuffer;
-import java.awt.image.WritableRaster;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class DisabledCalendarIcon extends CalendarIcon {
-
- @Override
- protected BufferedImage createImage(int width, int height) {
- ColorSpace gsColorSpace = ColorSpace.getInstance(ColorSpace.CS_GRAY);
- ComponentColorModel ccm = new ComponentColorModel(gsColorSpace, true, false,
Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE);
- WritableRaster raster = ccm.createCompatibleWritableRaster(width, height);
-
- return new BufferedImage(ccm, raster, ccm.isAlphaPremultiplied(), null);
- }
-
-}
Copied:
trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/DisabledCalendarIcon.java
(from rev 19756,
sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/DisabledCalendarIcon.java)
===================================================================
---
trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/DisabledCalendarIcon.java
(rev 0)
+++
trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/DisabledCalendarIcon.java 2010-10-29
11:48:42 UTC (rev 19760)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.renderkit.html.images;
+
+import java.awt.Transparency;
+import java.awt.color.ColorSpace;
+import java.awt.image.BufferedImage;
+import java.awt.image.ComponentColorModel;
+import java.awt.image.DataBuffer;
+import java.awt.image.WritableRaster;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class DisabledCalendarIcon extends CalendarIcon {
+
+ @Override
+ protected BufferedImage createImage(int width, int height) {
+ ColorSpace gsColorSpace = ColorSpace.getInstance(ColorSpace.CS_GRAY);
+ ComponentColorModel ccm = new ComponentColorModel(gsColorSpace, true, false,
Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE);
+ WritableRaster raster = ccm.createCompatibleWritableRaster(width, height);
+
+ return new BufferedImage(ccm, raster, ccm.isAlphaPremultiplied(), null);
+ }
+
+}
Deleted: trunk/ui/calendar/ui/src/main/java/org/richfaces/taglib/CalendarHandler.java
===================================================================
---
sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/taglib/CalendarHandler.java 2010-10-29
09:58:54 UTC (rev 19754)
+++
trunk/ui/calendar/ui/src/main/java/org/richfaces/taglib/CalendarHandler.java 2010-10-29
11:48:42 UTC (rev 19760)
@@ -1,54 +0,0 @@
-package org.richfaces.taglib;
-
-import javax.faces.view.facelets.ComponentConfig;
-import javax.faces.view.facelets.ComponentHandler;
-import javax.faces.view.facelets.FaceletContext;
-import javax.faces.view.facelets.MetaRule;
-import javax.faces.view.facelets.MetaRuleset;
-import javax.faces.view.facelets.Metadata;
-import javax.faces.view.facelets.MetadataTarget;
-import javax.faces.view.facelets.TagAttribute;
-
-import org.richfaces.component.AbstractCalendar;
-
-public class CalendarHandler extends ComponentHandler{
-
- private static final CalendarHandlerMetaRule METARULE = new
CalendarHandlerMetaRule();
-
-
- public CalendarHandler(ComponentConfig config) {
- super(config);
- }
-
- protected MetaRuleset createMetaRuleset(Class type) {
- MetaRuleset m = super.createMetaRuleset(type);
- m.addRule(METARULE);
- return m;
- }
-
- static class CalendarHandlerMetaRule extends MetaRule {
-
- public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget
meta) {
- if (meta.isTargetInstanceOf(AbstractCalendar.class) &&
"currentDataChangeListener".equals(name)) {
- return new CalendarMapper(attribute);
- }
- return null;
- }
-
- }
-
- static class CalendarMapper extends Metadata {
-
- private static final Class[] SIGNATURE = new Class[] {
org.richfaces.events.CurrentDateChangeListener.class };
-
- private final TagAttribute attribute;
-
- public CalendarMapper(TagAttribute attribute) {
- this.attribute = attribute;
- }
-
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ((AbstractCalendar) instance).addCurrentDateChangeListener((new
MethodExpressionCurrentDateChangeListener(this.attribute.getMethodExpression(ctx, null,
SIGNATURE))));
- }
- }
-}
Copied: trunk/ui/calendar/ui/src/main/java/org/richfaces/taglib/CalendarHandler.java (from
rev 19756,
sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/taglib/CalendarHandler.java)
===================================================================
--- trunk/ui/calendar/ui/src/main/java/org/richfaces/taglib/CalendarHandler.java
(rev 0)
+++
trunk/ui/calendar/ui/src/main/java/org/richfaces/taglib/CalendarHandler.java 2010-10-29
11:48:42 UTC (rev 19760)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+
+package org.richfaces.taglib;
+
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.ComponentHandler;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.MetaRule;
+import javax.faces.view.facelets.MetaRuleset;
+import javax.faces.view.facelets.Metadata;
+import javax.faces.view.facelets.MetadataTarget;
+import javax.faces.view.facelets.TagAttribute;
+
+import org.richfaces.component.AbstractCalendar;
+
+/**
+ * @author amarkhel
+ *
+ */
+public class CalendarHandler extends ComponentHandler {
+
+ private static final CalendarHandlerMetaRule METARULE = new
CalendarHandlerMetaRule();
+
+ public CalendarHandler(ComponentConfig config) {
+ super(config);
+ }
+
+ protected MetaRuleset createMetaRuleset(Class type) {
+ MetaRuleset m = super.createMetaRuleset(type);
+ m.addRule(METARULE);
+ return m;
+ }
+
+ static class CalendarHandlerMetaRule extends MetaRule {
+
+ public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget
meta) {
+ if (meta.isTargetInstanceOf(AbstractCalendar.class) &&
"currentDataChangeListener".equals(name)) {
+ return new CalendarMapper(attribute);
+ }
+ return null;
+ }
+
+ }
+
+ static class CalendarMapper extends Metadata {
+
+ private static final Class[] SIGNATURE = new Class[] {
org.richfaces.event.CurrentDateChangeListener.class };
+
+ private final TagAttribute attribute;
+
+ public CalendarMapper(TagAttribute attribute) {
+ this.attribute = attribute;
+ }
+
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((AbstractCalendar) instance).addCurrentDateChangeListener((new
MethodExpressionCurrentDateChangeListener(
+ this.attribute.getMethodExpression(ctx, null, SIGNATURE))));
+ }
+ }
+}
Deleted:
trunk/ui/calendar/ui/src/main/java/org/richfaces/taglib/MethodExpressionCurrentDateChangeListener.java
===================================================================
---
sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/taglib/MethodExpressionCurrentDateChangeListener.java 2010-10-29
09:58:54 UTC (rev 19754)
+++
trunk/ui/calendar/ui/src/main/java/org/richfaces/taglib/MethodExpressionCurrentDateChangeListener.java 2010-10-29
11:48:42 UTC (rev 19760)
@@ -1,48 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.richfaces.taglib;
-
-import javax.el.MethodExpression;
-import javax.faces.context.FacesContext;
-
-import org.richfaces.events.CurrentDateChangeEvent;
-import org.richfaces.events.CurrentDateChangeListener;
-
-public class MethodExpressionCurrentDateChangeListener implements
CurrentDateChangeListener {
-
- private MethodExpression methodExpression;
-
- public MethodExpressionCurrentDateChangeListener() {
- super();
- }
-
- MethodExpressionCurrentDateChangeListener(MethodExpression methodExpression) {
- super();
- this.methodExpression = methodExpression;
- }
-
- public void processCurrentDateChange(CurrentDateChangeEvent event) {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- methodExpression.invoke(facesContext.getELContext(), new Object[] { event });
- }
-}
Copied:
trunk/ui/calendar/ui/src/main/java/org/richfaces/taglib/MethodExpressionCurrentDateChangeListener.java
(from rev 19756,
sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/taglib/MethodExpressionCurrentDateChangeListener.java)
===================================================================
---
trunk/ui/calendar/ui/src/main/java/org/richfaces/taglib/MethodExpressionCurrentDateChangeListener.java
(rev 0)
+++
trunk/ui/calendar/ui/src/main/java/org/richfaces/taglib/MethodExpressionCurrentDateChangeListener.java 2010-10-29
11:48:42 UTC (rev 19760)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.taglib;
+
+import javax.el.MethodExpression;
+import javax.faces.context.FacesContext;
+
+import org.richfaces.event.CurrentDateChangeEvent;
+import org.richfaces.event.CurrentDateChangeListener;
+
+/**
+ * @author amarkhel
+ *
+ */
+public class MethodExpressionCurrentDateChangeListener implements
CurrentDateChangeListener {
+
+ private MethodExpression methodExpression;
+
+ public MethodExpressionCurrentDateChangeListener() {
+ super();
+ }
+
+ MethodExpressionCurrentDateChangeListener(MethodExpression methodExpression) {
+ super();
+ this.methodExpression = methodExpression;
+ }
+
+ public void processCurrentDateChange(CurrentDateChangeEvent event) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ methodExpression.invoke(facesContext.getELContext(), new Object[] { event });
+ }
+}