Author: dsakovich
Date: 2007-09-03 14:26:45 -0400 (Mon, 03 Sep 2007)
New Revision: 3432
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/calendar/
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/calendar/calendar.css
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/calendar/calendar.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCalendarTemplate.java
Modified:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/HtmlComponentUtil.java
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml
Log:
http://jira.jboss.com/jira/browse/JBIDE-847 Fdd RichFaces Calendar template
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/calendar/calendar.css
===================================================================
---
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/calendar/calendar.css
(rev 0)
+++
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/calendar/calendar.css 2007-09-03
18:26:45 UTC (rev 3432)
@@ -0,0 +1,137 @@
+.rich-calendar-exterior {
+ border: 1px solid #c0c0c0; /*panelBorderColor*/
+}
+
+.rich-calendar-btn {
+ cursor: pointer;
+}
+
+.rich-calendar-header {
+ border-bottom: 1px solid #c0c0c0; /*panelBorderColor*/
+ background: #C7D7EC; /*additionalBackgroundColor*/
+ font-size: 11px; /*generalSizeFont*/
+ font-family: verdana; /*generalFamilyFont*/
+ padding: 7px;
+ height: 22px;
+}
+
+.rich-cell-size {
+ width: 25px;
+ height: 22px;
+}
+
+.rich-calendar-cell {
+ background-color: #FFFFFF; /*generalBackgroundColor*/
+ border-bottom: 1px solid #c0c0c0; /*panelBorderColor*/
+ border-right: 1px solid #c0c0c0; /*panelBorderColor*/
+ font-size: 11px; /*generalSizeFont*/
+ font-family: verdana; /*generalFamilyFont*/
+ padding: 0px;
+ vertical-align: middle;
+ text-align: center;
+}
+
+.rich-calendar-tool {
+ border-bottom: 1px solid #c0c0c0; /*panelBorderColor*/
+ background-color: #D4CFC7; /*headerBackgroundColor*/
+ font-size: 11px; /*headerSizeFont*/
+ font-family: Arial, Verdana, sans-serif;
+ color: #000000; /*headerTextColor*/
+ font-weight: bold;
+ vertical-align: middle;
+ text-align: center;
+ width: 25px;
+ height: 22px;
+}
+
+.rich-calendar-month {
+ border-bottom: 1px solid #c0c0c0; /*panelBorderColor*/
+ background-color: #D4CFC7; /*headerBackgroundColor*/
+ border-bottom-color: #C4C0B9;
+ font-size: 11px; /*headerSizeFont*/
+ font-family: Arial, Verdana, sans-serif;
+ color: #000000;
+ /*headerTextColor*/
+ font-weight: bold;
+ vertical-align: middle;
+ text-align: center;
+ color: #000000;
+ font-size: 11px
+}
+
+.rich-calendar-days {
+ background: #F1EEE9 none repeat scroll 0%;
+ border-bottom: 1px solid #C4C0B9; /*panelBorderColor*/
+ border-right: 0px solid #C4C0B9; /*panelBorderColor*/
+ font-size: 11px; /*generalSizeFont*/
+ font-family: Arial, Verdana, sans-serif;
+ vertical-align: middle;
+ text-align: center;
+ height: 22px;
+ vertical-align: middle;
+}
+
+.rich-calendar-week {
+ border-bottom: 1px solid #c0c0c0; /*panelBorderColor*/
+ border-right: 1px solid #c0c0c0; /*panelBorderColor*/
+ font-size: 11px; /*generalSizeFont*/
+ font-family: verdana; /*generalFamilyFont*/
+ background-color: #f5f5f5; /*unknown parameter - need to add*/
+ vertical-align: middle;
+ text-align: center;
+ width: 25px;
+}
+
+.rich-calendar-holly {
+ background-color: # #FFEBDA; /*unknown parameter - need to add*/
+ color: #FF7800; /*unknown parameter - need to add*/
+}
+
+.rich-calendar-today {
+ background-color: #ff7800; /*unknown parameter - need to add*/
+ color: #ffebda; /*unknown parameter - need to add*/
+ font-weight: bold;
+}
+
+.rich-calendar-spec {
+ background-color: #e4f5e2; /*unknown parameter - need to add*/
+}
+
+.rich-calendar-select {
+ background-color: #224986; /*headerBackgroundColor*/
+ color: #FFFFFF; /*headerTextColor*/
+ font-weight: bold;
+}
+
+.rich-right-cell {
+ border-right: 0px;
+}
+
+.rich-bottom-cell {
+ border-bottom: 0px;
+}
+
+.rich-calendar-toolfooter {
+ border-top: 1px solid #c0c0c0; /*panelBorderColor*/
+ border-right: 0px solid #c0c0c0; /*panelBorderColor*/
+ background: #F1EEE9; /*additionalBackgroundColor*/
+ font-size: 11px; /*generalSizeFont*/
+ font-family: verdana; /*generalFamilyFont*/
+ padding: 0px 7px 0px 7px;
+ height: 22px;
+}
+
+.rich-calendar-footer {
+ border-top: 1px solid #c0c0c0; /*panelBorderColor*/
+ border-right: 0px solid #c0c0c0; /*panelBorderColor*/
+ background: #C7D7EC; /*additionalBackgroundColor*/
+ font-size: 11px; /*generalSizeFont*/
+ font-family: verdana; /*generalFamilyFont*/
+ padding: 7px;
+ height: 22px;
+}
+
+.rich-calendar-popupicon {
+ cursor: pointer;
+ vertical-align: middle;
+}
\ No newline at end of file
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/calendar/calendar.gif
===================================================================
(Binary files differ)
Property changes on:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/calendar/calendar.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/HtmlComponentUtil.java
===================================================================
---
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/HtmlComponentUtil.java 2007-09-03
17:17:53 UTC (rev 3431)
+++
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/HtmlComponentUtil.java 2007-09-03
18:26:45 UTC (rev 3432)
@@ -20,6 +20,9 @@
/** HTML TAG DL */
public static final String HTML_TAG_DL = "dl";
+
+ /** HTML TAG BR */
+ public static final String HTML_TAG_BR = "br";
/** HTML TAG DT */
public static final String HTML_TAG_DT = "dt";
@@ -32,7 +35,7 @@
/** HTML_TAG_TBODY * */
public static final String HTML_TAG_TBODY = "TBODY";
-
+
/** HTML_TAG_TR * */
public static final String HTML_TAG_TR = "TR";
@@ -120,6 +123,12 @@
/** HTML_TYPE_ATTR * */
public static final String HTML_TYPE_ATTR = "type";
+ /** HTML_READONLY_ATTR * */
+ public static final String HTML_READONLY_ATTR = "readonly";
+
+ /** HTML_TAG_BUTTON * */
+ public static final String HTML_TAG_BUTTON = "button";
+
/** HTML_VALUE_ATTR * */
public static final String HTML_VALUE_ATTR = "value";
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCalendarTemplate.java
===================================================================
---
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCalendarTemplate.java
(rev 0)
+++
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCalendarTemplate.java 2007-09-03
18:26:45 UTC (rev 3432)
@@ -0,0 +1,454 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.vpe.richfaces.template;
+
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+
+import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil;
+import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
+import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.mozilla.interfaces.nsIDOMNodeList;
+import org.mozilla.interfaces.nsIDOMText;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Displays template for calendar
+ *
+ * @author dsakovich(a)exadel.com
+ *
+ */
+public class RichFacesCalendarTemplate extends VpeAbstractTemplate {
+
+ static String[] HEADER_CONTENT = { "<<", "<",
"", ">", ">>" };
+ private String[] weeks = new String[7];
+ private int[] monthDays = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+
+ final static String STYLE_PATH = "calendar/calendar.css";
+ final static String BUTTON_IMG = "calendar/calendar.gif";
+ final static int COLUMN = 8;
+ final static String FILL_WIDTH = "100%";
+ final static int NUM_DAYS_IN_WEEK = 7;
+ final static String TODAY = "Today";
+ final static int CALENDAR_WIDTH = 200;
+ final static int CALENDAR_IMAGE_WIDTH = 20;
+ final static String ATTRIBUTE_POPUP = "popup";
+ final static String ATTRIBUTE_TEXT = "text";
+
+ public RichFacesCalendarTemplate() {
+ super();
+ Calendar cal = Calendar.getInstance();
+ int firstDayOfWeek = cal.getFirstDayOfWeek();
+ while (firstDayOfWeek != cal.get(Calendar.DAY_OF_WEEK)) {
+ cal.add(Calendar.DAY_OF_MONTH, 1);
+ }
+
+ SimpleDateFormat sdf = new SimpleDateFormat("EE");
+ for (int i = 0; i < NUM_DAYS_IN_WEEK; i++) {
+ weeks[i] = new String(sdf.format(cal.getTime()));
+ cal.add(Calendar.DAY_OF_MONTH, 1);
+ }
+
+ }
+
+ /**
+ * Creates a node of the visual tree on the node of the source tree. This
+ * visual node should not have the parent node This visual node can have
+ * child nodes.
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceNode
+ * The current node of the source tree.
+ * @param visualDocument
+ * The document of the visual tree.
+ * @return The information on the created node of the visual tree.
+ */
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+ Element source = (Element) sourceNode;
+ String popup = source.getAttribute(ATTRIBUTE_POPUP);
+ ComponentUtil.setCSSLink(pageContext, STYLE_PATH, "calendar");
+ VpeCreationData creationData;
+ if (popup != null && popup.equalsIgnoreCase("false")) {
+ nsIDOMElement calendar = createCalendar(visualDocument);
+ creationData = new VpeCreationData(calendar);
+ } else {
+ nsIDOMElement calendarWithPopup = createCalendarWithPopup(
+ visualDocument, source);
+ creationData = new VpeCreationData(calendarWithPopup);
+ }
+ return creationData;
+ }
+
+ /**
+ *
+ * @param visualDocument
+ * @return Node of the visual tree.
+ */
+ private nsIDOMElement createCalendarWithPopup(
+ nsIDOMDocument visualDocument, Element source) {
+ nsIDOMElement div = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_DIV);
+ div.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
+ HtmlComponentUtil.HTML_ATR_WIDTH + " : " + CALENDAR_WIDTH
+ + "px;");
+ nsIDOMElement input = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_INPUT);
+ input.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
+ HtmlComponentUtil.HTML_ATR_WIDTH + " : "
+ + (CALENDAR_WIDTH - CALENDAR_IMAGE_WIDTH) + "px;");
+ input.setAttribute(HtmlComponentUtil.HTML_TYPE_ATTR, ATTRIBUTE_TEXT);
+ input.setAttribute(HtmlComponentUtil.HTML_READONLY_ATTR, "true");
+ String value = source.getAttribute(HtmlComponentUtil.HTML_VALUE_ATTR);
+ if (value != null) {
+ input.setAttribute(HtmlComponentUtil.HTML_VALUE_ATTR, value);
+ }
+
+ nsIDOMElement image = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_IMG);
+ image.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ "rich-calendar-popupicon");
+ ComponentUtil.setImg(image, BUTTON_IMG);
+
+ div.appendChild(input);
+ div.appendChild(image);
+
+ return div;
+ }
+
+ /**
+ * Checks, whether it is necessary to re-create an element at change of
+ * attribute
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceElement
+ * The current element of the source tree.
+ * @param visualDocument
+ * The document of the visual tree.
+ * @param visualNode
+ * The current node of the visual tree.
+ * @param data
+ * The arbitrary data, built by a method
<code>create</code>
+ * @param name
+ * Atrribute name
+ * @param value
+ * Attribute value
+ * @return <code>true</code> if it is required to re-create an element
at
+ * a modification of attribute, <code>false</code> otherwise.
+ */
+ public boolean isRecreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMElement visualNode, Object data, String name, String value) {
+ if (name.equalsIgnoreCase(ATTRIBUTE_POPUP)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ *
+ * @param visualDocument
+ * @return Node of the visual tree.
+ */
+ private nsIDOMElement createCalendar(nsIDOMDocument visualDocument) {
+ nsIDOMElement div = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_DIV);
+ div.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
+ HtmlComponentUtil.HTML_ATR_WIDTH + " : " + CALENDAR_WIDTH
+ + "px;");
+ nsIDOMElement table = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TABLE);
+ table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, "0");
+ table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, "0");
+ table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, "0");
+ table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ "calendar-exterior");
+
+ nsIDOMElement tbody = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TBODY);
+ nsIDOMElement header = createCalendarHeader(visualDocument);
+ nsIDOMElement calendarBody = createCalendarBody(visualDocument);
+ tbody.appendChild(header);
+ tbody.appendChild(calendarBody);
+ table.appendChild(tbody);
+ div.appendChild(table);
+
+ return div;
+ }
+
+ /**
+ *
+ * @param visualDocument
+ * @return Node of the visual tree.
+ */
+ private nsIDOMElement createCalendarHeader(nsIDOMDocument visualDocument) {
+ nsIDOMElement tr = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TR);
+ nsIDOMElement td = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ td.setAttribute(HtmlComponentUtil.HTML_TABLE_COLSPAN, "" + COLUMN);
+
+ SimpleDateFormat sdf = new SimpleDateFormat("MMMM, yyyy");
+ Calendar cal = Calendar.getInstance();
+ HEADER_CONTENT[2] = sdf.format(cal.getTime());
+
+ nsIDOMElement table = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TABLE);
+ table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, "0");
+ table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, "0");
+ table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, "0");
+ table.setAttribute(HtmlComponentUtil.HTML_ATR_WIDTH, FILL_WIDTH);
+
+ nsIDOMElement tbody = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TBODY);
+
+ nsIDOMElement tr1 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TR);
+ for (int i = 0; i < HEADER_CONTENT.length; i++) {
+ nsIDOMElement td1 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ td1.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ i == 2 ? "rich-calendar-month" : "rich-calendar-tool");
+
+ nsIDOMText text1 = visualDocument.createTextNode(HEADER_CONTENT[i]);
+ td1.appendChild(text1);
+ tr1.appendChild(td1);
+ }
+
+ tbody.appendChild(tr1);
+ table.appendChild(tbody);
+ td.appendChild(table);
+ tr.appendChild(td);
+ return tr;
+ }
+
+ /**
+ *
+ * @param visualDocument
+ * @return Node of the visual tree.
+ */
+ private nsIDOMElement createCalendarBody(nsIDOMDocument visualDocument) {
+ nsIDOMElement tbody = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TBODY);
+
+ nsIDOMElement bodyTR = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TR);
+ for (int i = 0; i < COLUMN; i++) {
+ nsIDOMElement td = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ td.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ "rich-calendar-days");
+ if (i == 0) {
+ nsIDOMElement br = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_BR);
+ td.appendChild(br);
+ } else {
+ nsIDOMText text = visualDocument.createTextNode(i == 0 ? ""
+ : weeks[i - 1]);
+ td.appendChild(text);
+ }
+ bodyTR.appendChild(td);
+ }
+
+ tbody.appendChild(bodyTR);
+
+ // // Calendar body
+ int jumped = 0;
+ int inserted = 1;
+
+ Calendar cal = Calendar.getInstance();
+ int month = cal.get(Calendar.MONTH);
+ int day = cal.get(Calendar.DAY_OF_WEEK);
+ int dayN = cal.get(Calendar.DAY_OF_MONTH);
+ int days = monthDays[month];
+ if (month == 1) {
+ int year = cal.get(Calendar.YEAR);
+ if (year % 4 == 0)
+ days = 29;
+ }
+
+ int start = day - (dayN % NUM_DAYS_IN_WEEK + 1);
+ if (start < 0)
+ start += NUM_DAYS_IN_WEEK;
+ int weeks = (start + days) / NUM_DAYS_IN_WEEK;
+ if ((start + days) % NUM_DAYS_IN_WEEK != 0)
+ weeks++;
+ for (int i = weeks; i > 0; i--) {
+ nsIDOMElement tr = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TR);
+ // Week in year
+ nsIDOMElement weekTD = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ weekTD.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ "rich-calendar-week");
+ cal.set(Calendar.DAY_OF_MONTH, inserted);
+ nsIDOMText weekText = visualDocument.createTextNode(""
+ + cal.get(Calendar.WEEK_OF_YEAR));
+ weekTD.appendChild(weekText);
+ tr.appendChild(weekTD);
+ for (int j = NUM_DAYS_IN_WEEK; j > 0; j--) {
+ nsIDOMElement td = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ if (jumped < start || inserted > days) {
+ cal.set(Calendar.DAY_OF_MONTH, inserted);
+ int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
+ td
+ .setAttribute(
+ HtmlComponentUtil.HTML_CLASS_ATTR,
+ (dayOfWeek == Calendar.SATURDAY || dayOfWeek == Calendar.SUNDAY) ?
"rich-cell-size rich-calendar-cell rich-calendar-holly rich-right-cell"
+ : "rich-cell-size rich-calendar-cell rich-calendar-cell");
+ nsIDOMElement br = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_BR);
+ td.appendChild(br);
+ tr.appendChild(td);
+ jumped++;
+ } else {
+ if (inserted == dayN) {
+
+ td
+ .setAttribute(
+ HtmlComponentUtil.HTML_CLASS_ATTR,
+ "rich-cell-size rich-calendar-cell rich-calendar-today ");
+ nsIDOMText text = visualDocument.createTextNode(""
+ + inserted);
+ td.appendChild(text);
+ tr.appendChild(td);
+ } else {
+ cal.set(Calendar.DAY_OF_MONTH, inserted);
+ int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
+ td
+ .setAttribute(
+ HtmlComponentUtil.HTML_CLASS_ATTR,
+ (dayOfWeek == Calendar.SATURDAY || dayOfWeek == Calendar.SUNDAY) ?
"rich-cell-size rich-calendar-cell rich-calendar-holly rich-right-cell "
+ : "rich-cell-size rich-calendar-cell");
+ nsIDOMText text = visualDocument.createTextNode(""
+ + inserted);
+ td.appendChild(text);
+ tr.appendChild(td);
+ }
+ inserted++;
+ }
+ }
+ tbody.appendChild(tr);
+ }
+
+ // Footer for calendar
+
+ nsIDOMElement tr = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TR);
+
+ nsIDOMElement td = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ td.setAttribute(HtmlComponentUtil.HTML_TABLE_COLSPAN, "" + COLUMN);
+
+ nsIDOMElement table = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TABLE);
+ table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, "0");
+ table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, "0");
+ table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, "0");
+ table.setAttribute(HtmlComponentUtil.HTML_ATR_WIDTH, FILL_WIDTH);
+
+ nsIDOMElement tr1 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TR);
+
+ nsIDOMElement td1 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ td1.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ "rich-calendar-toolfooter");
+
+ SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
+ cal = Calendar.getInstance();
+
+ nsIDOMText text1 = visualDocument.createTextNode(sdf.format(cal
+ .getTime()));
+ td1.appendChild(text1);
+ tr1.appendChild(td1);
+
+ nsIDOMElement td2 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ td2.setAttribute(HtmlComponentUtil.HTML_ATR_WIDTH, FILL_WIDTH);
+ td2.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ "rich-calendar-toolfooter");
+ tr1.appendChild(td2);
+
+ nsIDOMElement td3 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ td3.setAttribute(HtmlComponentUtil.HTML_ATR_WIDTH, FILL_WIDTH);
+ td3.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ "rich-calendar-toolfooter");
+ td3.setAttribute(HtmlComponentUtil.HTML_ALIGN_ATTR,
+ HtmlComponentUtil.HTML_ALIGN_RIGHT_VALUE);
+ nsIDOMText text3 = visualDocument.createTextNode(TODAY);
+ td3.appendChild(text3);
+ tr1.appendChild(td3);
+
+ table.appendChild(tr1);
+ td.appendChild(table);
+ tr.appendChild(td);
+
+ tbody.appendChild(tr);
+
+ return tbody;
+ }
+
+ /**
+ *
+ */
+ public void setAttribute(VpePageContext pageContext, Element sourceElement,
+ nsIDOMDocument visualDocument, nsIDOMNode visualNode, Object data,
+ String name, String value) {
+ super.setAttribute(pageContext, sourceElement, visualDocument,
+ visualNode, data, name, value);
+ if (name.equalsIgnoreCase(HtmlComponentUtil.HTML_VALUE_ATTR)) {
+ String popup = sourceElement.getAttribute(ATTRIBUTE_POPUP);
+ if (popup != null && popup.equalsIgnoreCase("false"))
+ return;
+ nsIDOMElement element = (nsIDOMElement) visualNode
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ nsIDOMNodeList list = element.getChildNodes();
+ nsIDOMNode tableNode = list.item(0);
+ nsIDOMElement input = (nsIDOMElement) tableNode
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ input.setAttribute(HtmlComponentUtil.HTML_VALUE_ATTR, value);
+ }
+
+ }
+
+ /**
+ *
+ */
+ public void removeAttribute(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMNode visualNode, Object data, String name) {
+ super.removeAttribute(pageContext, sourceElement, visualDocument,
+ visualNode, data, name);
+ if (name.equalsIgnoreCase(HtmlComponentUtil.HTML_VALUE_ATTR)) {
+ String popup = sourceElement.getAttribute(ATTRIBUTE_POPUP);
+ if (popup != null && popup.equalsIgnoreCase("false"))
+ return;
+ nsIDOMElement element = (nsIDOMElement) visualNode
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ nsIDOMNodeList list = element.getChildNodes();
+ nsIDOMNode tableNode = list.item(0);
+ nsIDOMElement input = (nsIDOMElement) tableNode
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ input.removeAttribute(HtmlComponentUtil.HTML_VALUE_ATTR);
+ }
+ }
+}
Modified:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml
===================================================================
---
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2007-09-03
17:17:53 UTC (rev 3431)
+++
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2007-09-03
18:26:45 UTC (rev 3432)
@@ -454,7 +454,22 @@
<vpe:tag name="rich:menuSeparator" case-sensitive="yes" >
<vpe:template children="no" modify="no">
</vpe:template>
- </vpe:tag>
+ </vpe:tag>
+
+ <vpe:tag name="rich:calendar" case-sensitive="yes">
+ <vpe:template children="no" modify="no"
+ class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesCalendarTemplate">
+ <vpe:resize>
+ <vpe:width width-attr="style.width" />
+ <vpe:height height-attr="style.height" />
+ </vpe:resize>
+ <vpe:dnd>
+ <vpe:drag start-enable="yes" />
+ <vpe:drop container="no" />
+ </vpe:dnd>
+ </vpe:template>
+ </vpe:tag>
+
<vpe:tag name="rich:virtualEarth" case-sensitive="yes">
<vpe:template children="no" modify="yes"