Author: sdzmitrovich
Date: 2008-11-04 12:34:10 -0500 (Tue, 04 Nov 2008)
New Revision: 11504
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/calendar/disabled_button.gif
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/calendar/calendar.css
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/InputNumberSliderTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCalendarTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesComboBoxTemplateHelper.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataFilterSliderTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInputNumberSpinnerTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesListShuttleTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPickListTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/util/RichFaces.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/Constants.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2829
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/calendar/calendar.css
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/calendar/calendar.css 2008-11-04
16:14:51 UTC (rev 11503)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/calendar/calendar.css 2008-11-04
17:34:10 UTC (rev 11504)
@@ -1,46 +1,57 @@
.rich-calendar-input {
- cursor: pointer;
+ cursor: pointer;
vertical-align: middle;
text-align: left;
-
}
.rich-calendar-button {
- cursor:pointer;
- vertical-align:middle;
+ cursor: pointer;
+ vertical-align: middle;
text-align: left;
}
.rich-calendar-exterior {
- border: 1px solid #c0c0c0;
+ border: 1px solid;
+ border-color: #C4C0B9;
}
.rich-calendar-header {
- border-bottom: 1px solid #c0c0c0;
- background: #D4CFC7;
- font-size: 11px;
+ border-right: 0 solid;
+ border-bottom: 1px solid;
+ border-bottom-color: #C4C0B9;
+ background-color: #F1EEE9;
+ font-size: 11px;
font-family: Arial, Verdana, sans-serif;
- font-weight: bold;
- vertical-align: middle;
- text-align: center;
- padding: 7px;
- height: 22px;
}
.rich-calendar-tool {
- width: 25px;
+ vertical-align: middle;
+ text-align: center;
+ width: 20px;
height: 22px;
+ background-color: #D4CFC7;
+ font-size: 11px;
+ font-family: Arial, Verdana, sans-serif;
+ font-weight: bold;
+ color: #000;
}
.rich-calendar-month {
-
+ vertical-align: middle;
+ text-align: center;
+ height: 22px;
+ background-color: #D4CFC7;
+ font-size: 11px;
+ font-family: Arial, Verdana, sans-serif;
+ font-weight: bold;
+ color: #000;
+ white-space: nowrap;
}
.rich-calendar-tool-close {
-/*background-image:url(/richfaces-demo/a4j_3_1_4.GAorg.richfaces.renderkit.html.iconimages.CalendarSeparator/DATB/eAFjYGAAAAADAAE_.jsf);*/
-background-position:left center;
-background-repeat:no-repeat;
-padding:2px 2px 2px 4px;
+ padding: 2px 2px 2px 4px;
+ background-repeat: no-repeat;
+ background-position: left center;
}
.rich-calendar-days {
@@ -56,39 +67,39 @@
}
.rich-calendar-weekends {
- color:red;
+ color: red;
}
.rich-calendar-week {
- background:#F1EEE9 none repeat scroll 0%;
- font-family:Arial,Verdana,sans-serif;
- font-size:11px;
+ background: #F1EEE9 none repeat scroll 0%;
+ font-family: Arial, Verdana, sans-serif;
+ font-size: 11px;
padding: 0pt;
- border-bottom:1px solid #C4C0B9;
- border-right:1px solid #C4C0B9;
- text-align:center;
- vertical-align:middle;
- width:25px;
+ border-bottom: 1px solid #C4C0B9;
+ border-right: 1px solid #C4C0B9;
+ text-align: center;
+ vertical-align: middle;
+ width: 25px;
}
.rich-calendar-cell {
- background-color:#FFFFFF;
- font-family:Arial,Verdana,sans-serif;
- font-size:11px;
- border-bottom:1px solid #C4C0B9;
- border-right:1px solid #C4C0B9;
- padding:0pt;
- text-align:center;
- vertical-align:middle;
+ background-color: #FFFFFF;
+ font-family: Arial, Verdana, sans-serif;
+ font-size: 11px;
+ border-bottom: 1px solid #C4C0B9;
+ border-right: 1px solid #C4C0B9;
+ padding: 0pt;
+ text-align: center;
+ vertical-align: middle;
}
.rich-calendar-cell-size {
-height:22px;
-width:25px;
+ height: 22px;
+ width: 25px;
}
.rich-calendar-holly {
- background-color: #FFEBDA; /*unknown parameter - need to add*/
+ background-color: #FFEBDA; /*unknown parameter - need to add*/
color: #FF7800; /*unknown parameter - need to add*/
}
@@ -97,7 +108,7 @@
}
.rich-calendar-btn {
- cursor: pointer;
+ cursor: pointer;
}
.rich-calendar-today {
@@ -113,23 +124,23 @@
}
.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;
+ padding: 1px 2px 1px 1px;
+ background: #F1EEE9;
+ font-size: 11px;
+ font-family: Arial, Verdana, sans-serif;
+ background-repeat: no-repeat;
+ background-position: right center;
}
.rich-calendar-footer {
- border-top: 1px solid #c0c0c0; /*panelBorderColor*/
- border-right: 0px solid #c0c0c0; /*panelBorderColor*/
- background: #F1EEE9; /*additionalBackgroundColor*/
- font-size: 11px; /*generalSizeFont*/
- font-family: verdana; /*generalFamilyFont*/
- padding: 7px;
- height: 22px;
+ border-top: 1px solid;
+ border-right: 0 solid;
+ border-top-color: #C4C0B9;
+ border-right-color: #C4C0B9;
+ background: #F1EEE9;
+ font-size: 11px;
+ font-family: Arial, Verdana, sans-serif;
}
.rich-calendar-header-optional {
@@ -140,5 +151,4 @@
.rich-calendar-footer-optional {
background: #F1EEE9;
text-align: center;
-}
-
+}
\ No newline at end of file
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/calendar/disabled_button.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/calendar/disabled_button.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java 2008-11-04
16:14:51 UTC (rev 11503)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java 2008-11-04
17:34:10 UTC (rev 11504)
@@ -14,6 +14,8 @@
import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
@@ -26,6 +28,7 @@
import org.jboss.tools.jsf.vpe.richfaces.template.util.RichFaces;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.util.ElService;
+import org.jboss.tools.vpe.editor.util.FileUtil;
import org.jboss.tools.vpe.editor.util.HTML;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMNode;
@@ -195,7 +198,42 @@
+ resourcePathInPlugin);
}
}
+
+ /**
+ * Gets the absolute workspace path.
+ *
+ * @param resourcePathInWorkspace the relative path in workspace
+ *
+ * @return the absolute workspace path
+ */
+ public static String getAbsoluteWorkspacePath(
+ String resourcePathInWorkspace, VpePageContext pageContext) {
+ String resolvedValue = resourcePathInWorkspace
+ .replaceFirst(
+ "^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}",
""); //$NON-NLS-1$ //$NON-NLS-2$
+
+ IFile file = pageContext.getVisualBuilder().getCurrentIncludeInfo()
+ .getFile();
+
+ resolvedValue = ElService.getInstance().replaceEl(file, resolvedValue);
+
+// IPath path = new Path(resolvedValue);
+
+ URI uri = null;
+ try {
+ uri = new URI(resolvedValue);
+ } catch (URISyntaxException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ if (uri.isAbsolute() || (new File(resolvedValue)).exists())
+ return resolvedValue;
+
+ return FileUtil.getFile(resolvedValue, file).getLocation().toOSString();
+ }
+
/**
* Adds image as attribute to IMG tag.
*
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/InputNumberSliderTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/InputNumberSliderTemplate.java 2008-11-04
16:14:51 UTC (rev 11503)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/InputNumberSliderTemplate.java 2008-11-04
17:34:10 UTC (rev 11504)
@@ -273,7 +273,7 @@
// create input field
nsIDOMElement inputField = visualDocument.createElement(HTML.TAG_INPUT);
- inputField.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_TEXT_TYPE);
+ inputField.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_TYPE_TEXT);
inputField.setAttribute(HTML.ATTR_SIZE, getNumberValue(sourceElement,
RichFaces.ATTR_INPUT_SIZE, INPUT_SIZE_DEFAULT));
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCalendarTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCalendarTemplate.java 2008-11-04
16:14:51 UTC (rev 11503)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCalendarTemplate.java 2008-11-04
17:34:10 UTC (rev 11504)
@@ -1,7 +1,6 @@
/*******************************************************************************
* 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
*
@@ -10,21 +9,22 @@
******************************************************************************/
package org.jboss.tools.jsf.vpe.richfaces.template;
+import java.text.DateFormatSymbols;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
import java.util.Calendar;
-import java.util.Date;
import java.util.HashMap;
-import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.WeakHashMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil;
import org.jboss.tools.jsf.vpe.richfaces.template.util.RichFaces;
-import org.jboss.tools.vpe.editor.VpeController;
-import org.jboss.tools.vpe.editor.VpeSourceDomBuilder;
import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.mapping.AttributeData;
+import org.jboss.tools.vpe.editor.mapping.VpeElementData;
import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
@@ -36,6 +36,7 @@
import org.mozilla.interfaces.nsIDOMNode;
import org.mozilla.interfaces.nsIDOMNodeList;
import org.mozilla.interfaces.nsIDOMText;
+import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -45,53 +46,32 @@
* @author dsakovich(a)exadel.com
*
*/
-public class RichFacesCalendarTemplate extends VpeAbstractTemplate implements
VpeToggableTemplate {
+public class RichFacesCalendarTemplate extends VpeAbstractTemplate implements
+ VpeToggableTemplate {
+
+ private static final WeakHashMap<Node, Object> expandedComboBoxes = new
WeakHashMap<Node, Object>();
- static String[] HEADER_CONTENT = { "<<", "<",
"", ">", ">>" }; //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- static String[] HEADER_CONTENT_ON_POPUP = { "<<", "<",
"", ">", ">>", "X" }; //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- final static int MONTH_LENGTH[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31,
- 30, 31 };
- final static int LEAP_MONTH_LENGTH[] = { 31, 29, 31, 30, 31, 30, 31, 31,
- 30, 31, 30, 31 };
- final static String STYLE_PATH = "calendar/calendar.css"; //$NON-NLS-1$
- final static String BUTTON_IMG = "calendar/calendar.gif"; //$NON-NLS-1$
- final static int COLUMN = 8;
- final static String FILL_WIDTH = "100%"; //$NON-NLS-1$
- final static int NUM_DAYS_IN_WEEK = 7;
- final static int NUM_WEEK_ON_PAGE = 6;
- final static String TODAY = "Today"; //$NON-NLS-1$
- final static String VERTICAL_SEPARATOR = "|"; //$NON-NLS-1$
- final static String APPLY = "Apply"; //$NON-NLS-1$
- final static int CALENDAR_WIDTH = 200;
- final static int CALENDAR_INPUT_WIDTH = CALENDAR_WIDTH - 20;
- final static int CALENDAR_IMAGE_WIDTH = 20;
- final static int CALENDAR_CUSTOM_IMAGE_WIDTH = 40;
- final static int CALENDAR_BUTTON_WIDTH = 80;
-
- static final String DEFAULT_DATE_PATTERN = "MMMM, yyyy"; //$NON-NLS-1$
- static final String HEADER = "header"; //$NON-NLS-1$
- static final String FOOTER = "footer"; //$NON-NLS-1$
- static final String VPE_USER_TOGGLE_ID_ATTR = "vpe-user-toggle-id";
//$NON-NLS-1$
-
- /*rich:calendar attributes*/
- static final String BUTTON_LABEL = "buttonLabel"; //$NON-NLS-1$
- static final String BUTTON_ICON = "buttonIcon"; //$NON-NLS-1$
- static final String ENABLE_MANUAL_INPUT = "enableManualInput"; //$NON-NLS-1$
- static final String CELL_HEIGHT = "cellHeight"; //$NON-NLS-1$
- static final String CELL_WIDTH = "cellWidth"; //$NON-NLS-1$
- static final String DATE_PATTERN = "datePattern"; //$NON-NLS-1$
- static final String HORIZONTAL_OFFSET = "horizontalOffset"; //$NON-NLS-1$
- static final String VERTICAL_OFFSET = "verticalOffset"; //$NON-NLS-1$
- static final String LOCALE = "locale"; //$NON-NLS-1$
- static final String SHOW_APPLY_BUTTON = "showApplyButton"; //$NON-NLS-1$
- static final String SHOW_INPUT = "showInput"; //$NON-NLS-1$
- static final String SHOW_SHOW_WEEKS_DAY_BAR = "showWeekDaysBar";
//$NON-NLS-1$
- static final String SHOW_WEEKS_BAR = "showWeeksBar"; //$NON-NLS-1$
- static final String TODAY_CONTROL_MODE = "todayControlMode"; //$NON-NLS-1$
- static final String SHOW_HEADER = "showHeader"; //$NON-NLS-1$
- static final String SHOW_FOOTER= "showFooter"; //$NON-NLS-1$
+ final static int COLUMN = 8;
+ final static String FILL_WIDTH = "100%"; //$NON-NLS-1$
+ final static int NUM_DAYS_IN_WEEK = 7;
+ final static int NUM_WEEK_ON_PAGE = 6;
- /*CSS classes*/
+ final static int CALENDAR_WIDTH = 200;
+ final static int CALENDAR_INPUT_WIDTH = CALENDAR_WIDTH - 20;
+ final static int CALENDAR_IMAGE_WIDTH = 20;
+ final static int CALENDAR_CUSTOM_IMAGE_WIDTH = 40;
+ final static int CALENDAR_BUTTON_WIDTH = 80;
+
+ static final String DEFAULT_DATE_PATTERN = "MMM dd,yyyy"; //$NON-NLS-1$
+ static final String VPE_USER_TOGGLE_ID_ATTR = "vpe-user-toggle-id";
//$NON-NLS-1$
+
+ /* rich:calendar attributes */
+
+ static final String ATTR_ENABLE_MANUAL_INPUT = "enableManualInput";
//$NON-NLS-1$
+
+ static final String ATTR_TODAY_CONTROL_MODE = "todayControlMode";
//$NON-NLS-1$
+
+ /* CSS classes */
static final String CSS_R_C_INPUT = "rich-calendar-input"; //$NON-NLS-1$
static final String CSS_R_C_BUTTON = "rich-calendar-button"; //$NON-NLS-1$
static final String CSS_R_C_EXTERIOR = "rich-calendar-exterior";
//$NON-NLS-1$
@@ -113,670 +93,536 @@
static final String CSS_R_C_FOOTER = "rich-calendar-footer"; //$NON-NLS-1$
static final String CSS_R_C_HEADER_OPTIONAL = "rich-calendar-header-optional";
//$NON-NLS-1$
static final String CSS_R_C_FOOTER_OPTIONAL = "rich-calendar-footer-optional";
//$NON-NLS-1$
-
+ static final String CSS_R_C_TOOL_BTN = "rich-calendar-tool-btn";
//$NON-NLS-1$
+
private final static String WEEK_DAY_HTML_CLASS_ATTR = CSS_R_C_DAYS;
- private final static String HOL_WEEK_DAY_HTML_CLASS_ATTR = CSS_R_C_DAYS + " "
+ CSS_R_C_WEEKENDS; //$NON-NLS-1$
- private final static String TODAY_HTML_CLASS_ATTR = CSS_R_C_CELL_SIZE + " "+
CSS_R_C_CELL + " "+ CSS_R_C_TODAY; //$NON-NLS-1$ //$NON-NLS-2$
- private final static String CUR_MONTH_HTML_CLASS_ATTR = CSS_R_C_CELL_SIZE + "
"+ CSS_R_C_CELL; //$NON-NLS-1$
- private final static String HOL_CUR_MONTH_HTML_CLASS_ATTR = CSS_R_C_CELL_SIZE + "
"+ CSS_R_C_CELL + " "+ CSS_R_C_HOLLY; //$NON-NLS-1$ //$NON-NLS-2$
- private final static String OTHER_MONTH_HTML_CLASS_ATTR = CSS_R_C_CELL_SIZE + "
"+ CSS_R_C_CELL + " "+ CSS_R_C_BOUNDARY_DATES; //$NON-NLS-1$
//$NON-NLS-2$
- private final static String HOL_OTHER_MONTH_HTML_CLASS_ATTR = CSS_R_C_CELL_SIZE + "
"+ CSS_R_C_CELL + " "+ CSS_R_C_HOLLY + " " +
CSS_R_C_BOUNDARY_DATES ; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- /*Attribute values*/
- private static final String DIRECTIONS_TOP_LEFT = "top-left"; //$NON-NLS-1$
- private static final String DIRECTIONS_TOP_RIGHT = "top-right"; //$NON-NLS-1$
- private static final String DIRECTIONS_BOTTOM_LEFT = "bottom-left";
//$NON-NLS-1$
- private static final String DIRECTIONS_BOTTOM_RIGHT = "bottom-right";
//$NON-NLS-1$
- private static final int DIRECTIONS_TOP_LEFT_INT = 1;
- private static final int DIRECTIONS_TOP_RIGHT_INT = 2;
- private static final int DIRECTIONS_BOTTOM_LEFT_INT = 3;
- private static final int DIRECTIONS_BOTTOM_RIGHT_INT = 4;
-
- /*styles for direction table cells*/
+ private final static String HOL_WEEK_DAY_HTML_CLASS_ATTR = CSS_R_C_DAYS
+ + " " + CSS_R_C_WEEKENDS; //$NON-NLS-1$
+ private final static String TODAY_HTML_CLASS_ATTR = CSS_R_C_CELL_SIZE
+ + " " + CSS_R_C_CELL + " " + CSS_R_C_TODAY; //$NON-NLS-1$
//$NON-NLS-2$
+ private final static String CUR_MONTH_HTML_CLASS_ATTR = CSS_R_C_CELL_SIZE
+ + " " + CSS_R_C_CELL; //$NON-NLS-1$
+ private final static String HOL_CUR_MONTH_HTML_CLASS_ATTR = CSS_R_C_CELL_SIZE
+ + " " + CSS_R_C_CELL + " " + CSS_R_C_HOLLY; //$NON-NLS-1$
//$NON-NLS-2$
+ private final static String OTHER_MONTH_HTML_CLASS_ATTR = CSS_R_C_CELL_SIZE
+ + " " + CSS_R_C_CELL + " " + CSS_R_C_BOUNDARY_DATES; //$NON-NLS-1$
//$NON-NLS-2$
+ private final static String HOL_OTHER_MONTH_HTML_CLASS_ATTR = CSS_R_C_CELL_SIZE
+ + " " + CSS_R_C_CELL + " " + CSS_R_C_HOLLY + " " +
CSS_R_C_BOUNDARY_DATES; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ /* Attribute values */
+ private static final String DIRECTIONS_TOP_LEFT = "top-left"; //$NON-NLS-1$
+ private static final String DIRECTIONS_TOP_RIGHT = "top-right"; //$NON-NLS-1$
+ private static final String DIRECTIONS_BOTTOM_LEFT = "bottom-left";
//$NON-NLS-1$
+ private static final String DIRECTIONS_BOTTOM_RIGHT = "bottom-right";
//$NON-NLS-1$
+
+ /* styles for direction table cells */
private static final String STYLE_TOP_LEFT = "vertical-align: bottom; text-align:
right;"; //$NON-NLS-1$
private static final String STYLE_TOP_RIGHT = "vertical-align: bottom; text-align:
left;"; //$NON-NLS-1$
private static final String STYLE_BOTTOM_LEFT = "vertical-align: top; text-align:
right;"; //$NON-NLS-1$
private static final String STYLE_BOTTOM_RIGHT = "vertical-align: top; text-align:
left;"; //$NON-NLS-1$
-
- /*rich:calendar attributes*/
- private String buttonLabel;
- private String buttonIcon;
- private String direction;
- private String cellHeight;
- private String cellWidth;
- private String datePattern;
- private String value;
- private String disabled;
- private String enableManualInput;
- private String horizontalOffset;
- private String verticalOffset;
- private String locale;
- private String popup;
- private String showApplyButton;
- private String showInput;
- private String showWeekDaysBar;
- private String showWeeksBar;
- private String todayControlMode;
- private String showHeader;
- private String showFooter;
- private List<String> holidays = new ArrayList<String>();
- private String[] weeks = new String[7];
- static Map<String, Integer> directions;
- private boolean showPopupCalendar = false;
-
- /**
- * Instantiates a new rich faces calendar template.
- */
- public RichFacesCalendarTemplate() {
- super();
- directions = new HashMap<String, Integer>(4);
- directions.put(DIRECTIONS_TOP_LEFT, DIRECTIONS_TOP_LEFT_INT);
- directions.put(DIRECTIONS_TOP_RIGHT, DIRECTIONS_TOP_RIGHT_INT);
- directions.put(DIRECTIONS_BOTTOM_LEFT, DIRECTIONS_BOTTOM_LEFT_INT);
- directions.put(DIRECTIONS_BOTTOM_RIGHT, DIRECTIONS_BOTTOM_RIGHT_INT);
-
+ final static String DIRECTION_PATTERN = "(top|bottom)-(left|right)";
//$NON-NLS-1$
+ final static int DEFAULT_CELL_WIDTH = 25;
+ final static int DEFAULT_CELL_HEIGHT = 22;
+
+ final static int JOINT_POINT_BOTTOM = 7;
+ final static int JOINT_POINT_TOP = -17;
+ final static String TOP = "top"; //$NON-NLS-1$
+ final static String LEFT = "left"; //$NON-NLS-1$
+ final static String HIDDEN = "hidden"; //$NON-NLS-1$
+
+ static Map<String, int[]> DIRECTIONS = new HashMap<String, int[]>(4);
+ static {
+ DIRECTIONS.put(DIRECTIONS_TOP_LEFT, new int[] { -1, -1 });
+ DIRECTIONS.put(DIRECTIONS_TOP_RIGHT, new int[] { -1, 1 });
+ DIRECTIONS.put(DIRECTIONS_BOTTOM_LEFT, new int[] { 1, -1 });
+ DIRECTIONS.put(DIRECTIONS_BOTTOM_RIGHT, new int[] { 1, 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;
+ /*
+ * ++++++++++++++++++++++++++++++++++++++++++++++++++++ NEW FIELDS
+ */
- readAttributes(sourceNode);
- initCalendar();
+ static final String ATTR_SHOW_SHOW_WEEKS_DAY_BAR = "showWeekDaysBar";
//$NON-NLS-1$
+ static final String ATTR_SHOW_WEEKS_BAR = "showWeeksBar"; //$NON-NLS-1$
+ static final String ATTR_SHOW_HEADER = "showHeader"; //$NON-NLS-1$
+ static final String ATTR_SHOW_FOOTER = "showFooter"; //$NON-NLS-1$
+ static final String ATTR_CELL_HEIGHT = "cellHeight"; //$NON-NLS-1$
+ static final String ATTR_CELL_WIDTH = "cellWidth"; //$NON-NLS-1$
+ static final String ATTR_BUTTON_LABEL = "buttonLabel"; //$NON-NLS-1$
+ static final String ATTR_SHOW_APPLY_BUTTON = "showApplyButton"; //$NON-NLS-1$
+ static final String ATTR_DATE_PATTERN = "datePattern"; //$NON-NLS-1$
+ static final String ATTR_FIRST_WEEK_DAY = "firstWeekDay"; //$NON-NLS-1$
- ComponentUtil.setCSSLink(pageContext, STYLE_PATH, "calendar");
//$NON-NLS-1$
- nsIDOMElement div = visualDocument
- .createElement(HTML.TAG_DIV);
-
- nsIDOMElement resultTable = visualDocument
- .createElement(HTML.TAG_TABLE);
- nsIDOMElement resultTD = visualDocument
- .createElement(HTML.TAG_TD);
- nsIDOMElement resultTR = visualDocument
- .createElement(HTML.TAG_TR);
-
- resultTD.appendChild(div);
- resultTR.appendChild(resultTD);
- resultTable.appendChild(resultTR);
-
- VpeCreationData creationData = new VpeCreationData(resultTable);
-
-
- nsIDOMElement calendar;
- nsIDOMElement calendarWithPopup;
- if (Constants.FALSE.equalsIgnoreCase(popup)) {
- if (Constants.TRUE.equalsIgnoreCase(disabled)) {
- calendar = visualDocument
- .createElement(HTML.TAG_DIV);
- } else {
- calendar = createCalendar(visualDocument, creationData, source);
- }
- div.appendChild(calendar);
- } else {
- calendarWithPopup = createCalendarWithPopup(visualDocument, source);
- calendar = createCalendar(visualDocument, creationData, source);
+ final private static String DEFAULT_INPUT_STYLE = "vertical-align:
middle;";//$NON-NLS-1$
+ final private static String STYLE_PATH = "calendar/calendar.css";
//$NON-NLS-1$
+ final private static String DEFAULT_BUTTON_ICON = "calendar/calendar.gif";
//$NON-NLS-1$
+ final private static String DEFAULT_BUTTON_ICON_DISABLED =
"calendar/disabled_button.gif"; //$NON-NLS-1$
+ final private static String DEFAULT_BUTTON_STYLE = "vertical-align:
middle;";//$NON-NLS-1$
- if (showPopupCalendar) {
- if (attrPresents(direction) && directions.keySet().contains(direction)) {
- nsIDOMElement table = visualDocument
- .createElement(HTML.TAG_TABLE);
- nsIDOMElement top_tr = visualDocument
- .createElement(HTML.TAG_TR);
- nsIDOMElement bottom_tr = visualDocument
- .createElement(HTML.TAG_TR);
- nsIDOMElement top_left_td = visualDocument
- .createElement(HTML.TAG_TD);
- nsIDOMElement top_right_td = visualDocument
- .createElement(HTML.TAG_TD);
- nsIDOMElement bottom_left_td = visualDocument
- .createElement(HTML.TAG_TD);
- nsIDOMElement bottom_right_td = visualDocument
- .createElement(HTML.TAG_TD);
+ final private static String NEXT_MONTH_CONTROL = ">";//$NON-NLS-1$
+ final private static String PREVIOUS_MONTH_CONTROL = "<";//$NON-NLS-1$
+ final private static String NEXT_YEAR_CONTROL = ">>";//$NON-NLS-1$
+ final private static String PREVIOUS_YEAR_CONTROL = "<<";//$NON-NLS-1$
+ final private static String APPLY_CONTROL = "Apply"; //$NON-NLS-1$
+ final private static String TODAY_CONTROL = "Today"; //$NON-NLS-1$
+ final private static String CLOSE_CONTROL = "X"; //$NON-NLS-1$
+ final private static String VERTICAL_SEPARATOR = "|"; //$NON-NLS-1$
- top_tr.appendChild(top_left_td);
- top_tr.appendChild(top_right_td);
- bottom_tr.appendChild(bottom_left_td);
- bottom_tr.appendChild(bottom_right_td);
- table.appendChild(top_tr);
- table.appendChild(bottom_tr);
- div.appendChild(table);
+ private int tableWidth;
+ private int tableHeight;
+ private Calendar calendar;
+ private Locale locale;
+ private String[] weekDays;
+ private String[] months;
+ private int horizontalOffset;
+ private int verticalOffset;
+ private String currentMonthControl;
+ private String currentDayControl;
+ private DirectionData direction;
+ private DirectionData jointPoint;
- top_left_td.setAttribute(HTML.ATTR_STYLE, STYLE_TOP_LEFT);
- top_right_td.setAttribute(HTML.ATTR_STYLE, STYLE_TOP_RIGHT);
- bottom_left_td.setAttribute(HTML.ATTR_STYLE, STYLE_BOTTOM_LEFT);
- bottom_right_td.setAttribute(HTML.ATTR_STYLE, STYLE_BOTTOM_RIGHT);
+ private int cellHeight;
+ private int cellWidth;
+ private int zindex;
+ private String value;
- switch (directions.get(direction)) {
- case DIRECTIONS_BOTTOM_RIGHT_INT:
- top_right_td.appendChild(calendarWithPopup);
- bottom_right_td.appendChild(calendar);
- break;
- case DIRECTIONS_BOTTOM_LEFT_INT:
- top_right_td.appendChild(calendarWithPopup);
- bottom_left_td.appendChild(calendar);
- break;
- case DIRECTIONS_TOP_RIGHT_INT:
- top_right_td.appendChild(calendar);
- top_right_td.appendChild(calendarWithPopup);
- break;
- case DIRECTIONS_TOP_LEFT_INT:
- top_right_td.appendChild(calendarWithPopup);
- top_left_td.appendChild(calendar);
- break;
- default:
- break;
- }
+ private String inputStyle;
+ private String inputClass;
+ private String inputSize;
- } else {
- // no direction. simple display.
- div.appendChild(calendarWithPopup);
- div.appendChild(calendar);
- }
+ private boolean disabled;
- } else {
- // display input field with button
- div.appendChild(calendarWithPopup);
- // hide unparsed facets
- nsIDOMElement hiddenDiv = visualDocument
- .createElement(HTML.TAG_DIV);
- hiddenDiv.setAttribute(HTML.ATTR_STYLE,
- HTML.STYLE_PARAMETER_WIDTH + Constants.COLON + CALENDAR_WIDTH
- + "px; overflow: hidden; display: none;"); //$NON-NLS-1$
+ private String buttonIcon;
+ private String buttonLabel;
+ private String buttonClass;
- nsIDOMElement hiddenTable = visualDocument
- .createElement(HTML.TAG_TABLE);
+ private String style;
+ private String styleClass;
- Element headerFacet = ComponentUtil.getFacet(source, HEADER);
- nsIDOMElement optionalHeader = null;
- if (null != headerFacet) {
- optionalHeader = createCalendarOptionalHeaderOrFooter(visualDocument,
creationData, headerFacet, true);
- hiddenTable.appendChild(optionalHeader);
- }
- Element footerFacet = ComponentUtil.getFacet(source, FOOTER);
- nsIDOMElement optionalFooter = null;
- if (null != footerFacet) {
- optionalFooter = createCalendarOptionalHeaderOrFooter(visualDocument,
creationData, footerFacet, false);
- hiddenTable.appendChild(optionalFooter);
- }
- hiddenDiv.appendChild(hiddenTable);
- }
+ private boolean showInput;
+ private boolean showWeekDaysBar;
+ private boolean showWeeksBar;
+ private boolean showHeader;
+ private boolean showFooter;
+ private boolean showApplyButton;
+ private boolean showTodayControl;
- }
- return creationData;
- }
+ private boolean popup;
- /**
- *
- * @param visualDocument
- * @return Node of the visual tree.
- */
- private nsIDOMElement createCalendarWithPopup(
- nsIDOMDocument visualDocument, Element source) {
- nsIDOMElement table = visualDocument
- .createElement(HTML.TAG_TABLE);
+ private int firstWeekDay;
- nsIDOMElement tr1 = visualDocument
- .createElement(HTML.TAG_TR);
- nsIDOMElement td1_1 = visualDocument
- .createElement(HTML.TAG_TD);
- nsIDOMElement td1_2 = visualDocument
- .createElement(HTML.TAG_TD);
+ private String datePattern;
- nsIDOMElement tr2 = visualDocument
- .createElement(HTML.TAG_TR);
- nsIDOMElement td2_1 = visualDocument
- .createElement(HTML.TAG_TD);
+ private String todayControlMode;
- table.setAttribute(HTML.ATTR_STYLE,
- HTML.STYLE_PARAMETER_WIDTH + " : 100%"); //$NON-NLS-1$
+ private String enableManualInput;
- tr1.appendChild(td1_1);
- tr1.appendChild(td1_2);
- table.appendChild(tr1);
+ /**
+ * Instantiates a new rich faces calendar template.
+ */
+ public RichFacesCalendarTemplate() {
+ super();
- tr2.appendChild(td2_1);
- table.appendChild(tr2);
+ }
- nsIDOMElement div = visualDocument
- .createElement(HTML.TAG_DIV);
- int divWidth = CALENDAR_WIDTH + CALENDAR_IMAGE_WIDTH;
- div.appendChild(table);
+ /**
+ * 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;
- if (!Constants.FALSE.equalsIgnoreCase(showInput)) {
- nsIDOMElement input = visualDocument
- .createElement(HTML.TAG_INPUT);
- input.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_TEXT_TYPE);
- input.setAttribute(HTML.ATTR_CLASS, CSS_R_C_INPUT);
- input.setAttribute(HTML.ATTR_STYLE,
- HTML.STYLE_PARAMETER_WIDTH + Constants.COLON
- + CALENDAR_INPUT_WIDTH + "px;"); //$NON-NLS-1$
+ readAttributes(pageContext, sourceNode);
- if (Constants.TRUE.equals(enableManualInput)) {
- input.setAttribute(HTML.ATTR_READONLY, Constants.TRUE);
+ ComponentUtil.setCSSLink(pageContext, STYLE_PATH, "calendar"); //$NON-NLS-1$
+ nsIDOMElement wrapper = visualDocument.createElement(HTML.TAG_SPAN);
+
+ VpeCreationData creationData = new VpeCreationData(wrapper);
+
+ nsIDOMElement calendar;
+ nsIDOMElement calendarWithPopup;
+ if (!popup) {
+ if (disabled) {
+ calendar = visualDocument.createElement(HTML.TAG_DIV);
+ } else {
+ calendar = createCalendar(visualDocument, creationData, source);
}
- if (Constants.TRUE.equals(disabled)) {
- input.setAttribute(HTML.ATTR_DISABLED, Constants.TRUE);
+ wrapper.appendChild(calendar);
+ } else {
+ calendarWithPopup = createPopupCalendar(visualDocument, source,
+ creationData);
+
+ wrapper.appendChild(calendarWithPopup);
+
+ }
+ return creationData;
+ }
+
+ /**
+ * 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) {
+ return true;
+ }
+
+ /**
+ *
+ * @param visualDocument
+ * @return Node of the visual tree.
+ */
+ private nsIDOMElement createCalendar(nsIDOMDocument visualDocument,
+ VpeCreationData creationData, Element sourceElement) {
+
+ nsIDOMElement table = visualDocument.createElement(HTML.TAG_TABLE);
+ table.setAttribute(HTML.ATTR_CELLPADDING, "0"); //$NON-NLS-1$
+ table.setAttribute(HTML.ATTR_BORDER, "0"); //$NON-NLS-1$
+ table.setAttribute(HTML.ATTR_CELLSPACING, "0"); //$NON-NLS-1$
+ table.setAttribute(HTML.ATTR_CLASS, CSS_R_C_EXTERIOR
+ + Constants.WHITE_SPACE + styleClass);
+ table.setAttribute(HTML.ATTR_STYLE, style);
+
+ nsIDOMElement tbody = visualDocument.createElement(HTML.TAG_TBODY);
+
+ nsIDOMElement header = null;
+ nsIDOMElement calendarBody = createCalendarBody(visualDocument);
+ nsIDOMElement footer = null;
+
+ if (showHeader) {
+ Element headerFacet = ComponentUtil.getFacet(sourceElement,
+ RichFaces.NAME_FACET_HEADER);
+ if (headerFacet != null) {
+ header = createCalendarOptionalHeaderOrFooter(visualDocument,
+ creationData, headerFacet, true);
+ } else {
+
+ String[] defaultHeaderContent = popup ? new String[] {
+ PREVIOUS_YEAR_CONTROL, PREVIOUS_MONTH_CONTROL,
+ currentMonthControl, NEXT_MONTH_CONTROL,
+ NEXT_YEAR_CONTROL, CLOSE_CONTROL } : new String[] {
+ PREVIOUS_YEAR_CONTROL, PREVIOUS_MONTH_CONTROL,
+ currentMonthControl, NEXT_MONTH_CONTROL,
+ NEXT_YEAR_CONTROL };
+
+ String[] defaultHeaderContentStyles = popup ? new String[] {
+ CSS_R_C_TOOL,
+ CSS_R_C_TOOL,
+ CSS_R_C_MONTH,
+ CSS_R_C_TOOL,
+ CSS_R_C_TOOL,
+ CSS_R_C_TOOL + Constants.WHITE_SPACE
+ + CSS_R_C_TOOL_CLOSE } : new String[] {
+ CSS_R_C_TOOL, CSS_R_C_TOOL, CSS_R_C_MONTH,
+ CSS_R_C_TOOL, CSS_R_C_TOOL };
+
+ // header = createDefaultCalendarHeader(visualDocument);
+ header = createHeaderBlock(visualDocument, CSS_R_C_HEADER,
+ defaultHeaderContent, defaultHeaderContentStyles);
}
-
- if (attrPresents(value)) {
- input.setAttribute(HTML.ATTR_VALUE, value);
- }
-
- td1_1.appendChild(input);
- }
+ }
+ if (showFooter) {
+ Element footerFacet = ComponentUtil.getFacet(sourceElement,
+ RichFaces.NAME_FACET_FOOTER);
+ if (footerFacet != null) {
+ footer = createCalendarOptionalHeaderOrFooter(visualDocument,
+ creationData, footerFacet, false);
+ } else {
- if (attrPresents(buttonLabel)) {
- nsIDOMElement button = visualDocument
- .createElement(HTML.TAG_INPUT);
- button.setAttribute(HTML.ATTR_TYPE,
- HTML.VALUE_BUTTON_TYPE);
- button.setAttribute(HTML.ATTR_VALUE, buttonLabel);
- button.setAttribute(HTML.ATTR_CLASS, CSS_R_C_BUTTON);
- if (Constants.TRUE.equalsIgnoreCase(disabled)) {
- button.setAttribute(HTML.ATTR_DISABLED, Constants.TRUE);
- }
- button.setAttribute(VPE_USER_TOGGLE_ID_ATTR, Constants.EMPTY+showPopupCalendar);
- td1_2.appendChild(button);
- divWidth = CALENDAR_WIDTH + CALENDAR_BUTTON_WIDTH;
- } else {
- nsIDOMElement image = visualDocument
- .createElement(HTML.TAG_IMG);
- image.setAttribute(HTML.ATTR_CLASS,
- CSS_R_C_BUTTON);
- if (attrPresents(buttonIcon)) {
- image.setAttribute(HTML.ATTR_SRC, buttonIcon);
- divWidth = CALENDAR_WIDTH + CALENDAR_CUSTOM_IMAGE_WIDTH;
- } else {
- ComponentUtil.setImg(image, BUTTON_IMG);
- divWidth = CALENDAR_WIDTH + CALENDAR_IMAGE_WIDTH;
- }
- image.setAttribute(VPE_USER_TOGGLE_ID_ATTR, Constants.EMPTY+showPopupCalendar);
- td1_2.appendChild(image);
- }
- div.setAttribute(HTML.ATTR_STYLE,
- HTML.STYLE_PARAMETER_WIDTH + Constants.COLON
- + divWidth + "px; overflow: hidden;"); //$NON-NLS-1$
- return div;
- }
+ String[] defaultFooterContent;
+ String[] defaultFooterContentStyles;
+ if (popup) {
- /**
- * 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) {
- return true;
- }
+ defaultFooterContent = new String[] {
+ showTodayControl ? TODAY_CONTROL : Constants.EMPTY,
+ showApplyButton ? APPLY_CONTROL : Constants.EMPTY };
+ defaultFooterContentStyles = new String[] {
+ CSS_R_C_TOOLFOOTER, CSS_R_C_TOOLFOOTER };
- /**
- *
- * @param visualDocument
- * @return Node of the visual tree.
- */
- private nsIDOMElement createCalendar(nsIDOMDocument visualDocument, VpeCreationData
creationData, Element sourceElement) {
- nsIDOMElement div = visualDocument
- .createElement(HTML.TAG_DIV);
- div.setAttribute(HTML.ATTR_STYLE,
- HTML.STYLE_PARAMETER_WIDTH + Constants.COLON + CALENDAR_WIDTH
- + "px; overflow: hidden;"); //$NON-NLS-1$
+ } else {
- nsIDOMElement table = visualDocument
- .createElement(HTML.TAG_TABLE);
- table.setAttribute(HTML.ATTR_CELLPADDING, "0"); //$NON-NLS-1$
- table.setAttribute(HTML.ATTR_BORDER, "0"); //$NON-NLS-1$
- table.setAttribute(HTML.ATTR_CELLSPACING, "0"); //$NON-NLS-1$
- table.setAttribute(HTML.ATTR_CLASS,
- CSS_R_C_EXTERIOR);
+ defaultFooterContent = new String[] { TODAY_CONTROL };
+ defaultFooterContentStyles = new String[] { CSS_R_C_TOOLFOOTER };
- nsIDOMElement tbody = visualDocument
- .createElement(HTML.TAG_TBODY);
- Element headerFacet = ComponentUtil.getFacet(sourceElement, HEADER);
- nsIDOMElement optionalHeader = null;
- if (null != headerFacet) {
- optionalHeader = createCalendarOptionalHeaderOrFooter(visualDocument, creationData,
headerFacet, true);
- }
- Element footerFacet = ComponentUtil.getFacet(sourceElement, FOOTER);
- nsIDOMElement optionalFooter = null;
- if (null != footerFacet) {
- optionalFooter = createCalendarOptionalHeaderOrFooter(visualDocument, creationData,
footerFacet, false);
- }
- nsIDOMElement header = null;
- nsIDOMElement calendarBody = createCalendarBody(visualDocument);
- nsIDOMElement footer = null;
+ }
- if (!Constants.FALSE.equals(showHeader)) {
- header = createCalendarHeader(visualDocument);
- }
- if (!Constants.FALSE.equals(showFooter)) {
- footer = createCalendarFooter(visualDocument);
- }
+ // footer = createDefaultCalendarFooter(visualDocument);
+ footer = createFooterBlock(visualDocument, CSS_R_C_FOOTER,
+ defaultFooterContent, defaultFooterContentStyles);
+ }
+ }
- if (null != optionalHeader) {
- tbody.appendChild(optionalHeader);
- }
- if (null != header) {
- tbody.appendChild(header);
- }
- tbody.appendChild(calendarBody);
- if (null != footer) {
- tbody.appendChild(footer);
- }
- if (null != optionalFooter) {
- tbody.appendChild(optionalFooter);
- }
+ if (null != header) {
+ tbody.appendChild(header);
+ }
+ tbody.appendChild(calendarBody);
+ if (null != footer) {
+ tbody.appendChild(footer);
+ }
- table.appendChild(tbody);
- div.appendChild(table);
+ table.appendChild(tbody);
- return div;
- }
+ return table;
+ }
- /**
- * Creates the calendar optional header or footer.
- *
- * @param visualDocument the visual document
- * @param creationData the creation data
- * @param facetBody the facet body
- * @param isHeader the is header
- *
- * @return the element
- */
- private nsIDOMElement createCalendarOptionalHeaderOrFooter(
- nsIDOMDocument visualDocument, VpeCreationData creationData, Element facetBody,
boolean isHeader) {
- nsIDOMElement tr = visualDocument
- .createElement(HTML.TAG_TR);
- nsIDOMElement td = visualDocument
- .createElement(HTML.TAG_TD);
- td.setAttribute(HTML.ATTR_COLSPAN, Constants.EMPTY + COLUMN);
+ /**
+ * Creates the calendar optional header or footer.
+ *
+ * @param visualDocument
+ * the visual document
+ * @param creationData
+ * the creation data
+ * @param facetBody
+ * the facet body
+ * @param isHeader
+ * the is header
+ *
+ * @return the element
+ */
+ private nsIDOMElement createCalendarOptionalHeaderOrFooter(
+ nsIDOMDocument visualDocument, VpeCreationData creationData,
+ Element facetBody, boolean isHeader) {
+ nsIDOMElement tr = visualDocument.createElement(HTML.TAG_TR);
+ nsIDOMElement td = visualDocument.createElement(HTML.TAG_TD);
+ td.setAttribute(HTML.ATTR_COLSPAN, Constants.EMPTY + COLUMN);
tr.appendChild(td);
-
+
if (isHeader) {
td.setAttribute(HTML.ATTR_CLASS, CSS_R_C_HEADER_OPTIONAL);
} else {
td.setAttribute(HTML.ATTR_CLASS, CSS_R_C_FOOTER_OPTIONAL);
}
-
+
VpeChildrenInfo child = new VpeChildrenInfo(td);
child.addSourceChild(facetBody);
creationData.addChildrenInfo(child);
return tr;
}
-
- /**
- *
- * @param visualDocument
- * @return Node of the visual tree.
- */
- private nsIDOMElement createCalendarHeader(nsIDOMDocument visualDocument) {
- nsIDOMElement tr = visualDocument
- .createElement(HTML.TAG_TR);
- nsIDOMElement td = visualDocument
- .createElement(HTML.TAG_TD);
- td.setAttribute(HTML.ATTR_COLSPAN, Constants.EMPTY + COLUMN);
- String[] array;
- if (Constants.FALSE.equalsIgnoreCase(popup)) {
- array = HEADER_CONTENT;
- } else {
- array = HEADER_CONTENT_ON_POPUP;
- }
-
- SimpleDateFormat sdf = new SimpleDateFormat(DEFAULT_DATE_PATTERN);
- Date date = getCalendarWithLocale().getTime();
-
- if (attrPresents(datePattern)) {
- try {
- sdf.applyPattern(datePattern);
- } catch (IllegalArgumentException e) {
- // DEFAULT_DATE_PATTERN is used in this case
- }
- }
-
- array[2] = sdf.format(date);
-
- nsIDOMElement table = visualDocument
- .createElement(HTML.TAG_TABLE);
- table.setAttribute(HTML.ATTR_CELLPADDING, "0"); //$NON-NLS-1$
- table.setAttribute(HTML.ATTR_CELLSPACING, "0"); //$NON-NLS-1$
- table.setAttribute(HTML.ATTR_BORDER, "0"); //$NON-NLS-1$
- table.setAttribute(HTML.ATTR_WIDTH, FILL_WIDTH);
-
- nsIDOMElement tbody = visualDocument
- .createElement(HTML.TAG_TBODY);
-
- nsIDOMElement tr1 = visualDocument
- .createElement(HTML.TAG_TR);
- tr1.setAttribute(HTML.ATTR_CLASS,
- CSS_R_C_HEADER);
-
- for (int i = 0; i < array.length; i++) {
- nsIDOMElement td1 = visualDocument
- .createElement(HTML.TAG_TD);
- td1.setAttribute(HTML.ATTR_CLASS,
- i == 2 ? CSS_R_C_MONTH : CSS_R_C_TOOL);
-
- // close tool
- if (i == 5) {
- td1.setAttribute(VPE_USER_TOGGLE_ID_ATTR, "0"); //$NON-NLS-1$
- td1.setAttribute(HTML.ATTR_STYLE, "cursor: pointer;"); //$NON-NLS-1$
- }
-
- nsIDOMText text1 = visualDocument.createTextNode(array[i]);
- td1.appendChild(text1);
- tr1.appendChild(td1);
- }
-
- tbody.appendChild(tr1);
- table.appendChild(tbody);
- td.appendChild(table);
- tr.appendChild(td);
- return tr;
- }
-
- /**
- * Creates the calendar footer.
- *
- * @param visualDocument the visual document
- *
- * @return the ns idom element
- */
- private nsIDOMElement createCalendarFooter(nsIDOMDocument visualDocument) {
- nsIDOMElement tr = visualDocument
- .createElement(HTML.TAG_TR);
- nsIDOMElement td = visualDocument
- .createElement(HTML.TAG_TD);
- td.setAttribute(HTML.ATTR_COLSPAN, Constants.EMPTY + COLUMN);
- nsIDOMElement table = visualDocument
- .createElement(HTML.TAG_TABLE);
+ /**
+ *
+ * @param visualDocument
+ * @return Node of the visual tree.
+ */
+ // private nsIDOMElement createDefaultCalendarHeader(
+ // nsIDOMDocument visualDocument) {
+ //
+ // nsIDOMElement tr = visualDocument.createElement(HTML.TAG_TR);
+ // nsIDOMElement td = visualDocument.createElement(HTML.TAG_TD);
+ // td.setAttribute(HTML.ATTR_COLSPAN, Constants.EMPTY + COLUMN);
+ //
+ // nsIDOMElement table = visualDocument.createElement(HTML.TAG_TABLE);
+ // table.setAttribute(HTML.ATTR_CELLPADDING, "0"); //$NON-NLS-1$
+ // table.setAttribute(HTML.ATTR_CELLSPACING, "0"); //$NON-NLS-1$
+ // table.setAttribute(HTML.ATTR_BORDER, "0"); //$NON-NLS-1$
+ // table.setAttribute(HTML.ATTR_WIDTH, FILL_WIDTH);
+ //
+ // nsIDOMElement tbody = visualDocument.createElement(HTML.TAG_TBODY);
+ //
+ // nsIDOMElement tr1 = visualDocument.createElement(HTML.TAG_TR);
+ // tr1.setAttribute(HTML.ATTR_CLASS, CSS_R_C_HEADER);
+ //
+ // for (int i = 0; i < defaultHeaderContent.length; i++) {
+ // nsIDOMElement td1 = visualDocument.createElement(HTML.TAG_TD);
+ // td1.setAttribute(HTML.ATTR_CLASS, i == 2 ? CSS_R_C_MONTH
+ // : CSS_R_C_TOOL);
+ //
+ // // close tool
+ // if (i == 5) {
+ // td1.setAttribute(VPE_USER_TOGGLE_ID_ATTR, "0"); //$NON-NLS-1$
+ // td1.setAttribute(HTML.ATTR_STYLE, "cursor: pointer;"); //$NON-NLS-1$
+ // }
+ //
+ // nsIDOMText text1 = visualDocument
+ // .createTextNode(defaultHeaderContent[i]);
+ // td1.appendChild(text1);
+ // tr1.appendChild(td1);
+ // }
+ //
+ // tbody.appendChild(tr1);
+ // table.appendChild(tbody);
+ // td.appendChild(table);
+ // tr.appendChild(td);
+ // return tr;
+ // }
+ /**
+ * Creates the calendar footer.
+ *
+ * @param visualDocument
+ * the visual document
+ *
+ * @return the ns idom element
+ */
+ private nsIDOMElement createDefaultCalendarFooter(
+ nsIDOMDocument visualDocument) {
+ nsIDOMElement tr = visualDocument.createElement(HTML.TAG_TR);
+ nsIDOMElement td = visualDocument.createElement(HTML.TAG_TD);
+ td.setAttribute(HTML.ATTR_COLSPAN, Constants.EMPTY + COLUMN);
+ nsIDOMElement table = visualDocument.createElement(HTML.TAG_TABLE);
table.setAttribute(HTML.ATTR_CELLSPACING, "0"); //$NON-NLS-1$
table.setAttribute(HTML.ATTR_CELLPADDING, "0"); //$NON-NLS-1$
table.setAttribute(HTML.ATTR_BORDER, "0"); //$NON-NLS-1$
table.setAttribute(HTML.ATTR_WIDTH, FILL_WIDTH);
- nsIDOMElement tr1 = visualDocument
- .createElement(HTML.TAG_TR);
- tr1.setAttribute(HTML.ATTR_CLASS,
- CSS_R_C_FOOTER);
+ nsIDOMElement tr1 = visualDocument.createElement(HTML.TAG_TR);
+ tr1.setAttribute(HTML.ATTR_CLASS, CSS_R_C_FOOTER);
- nsIDOMElement td1 = visualDocument
- .createElement(HTML.TAG_TD);
- td1.setAttribute(HTML.ATTR_CLASS,
- CSS_R_C_TOOLFOOTER);
+ nsIDOMElement td1 = visualDocument.createElement(HTML.TAG_TD);
+ td1.setAttribute(HTML.ATTR_CLASS, CSS_R_C_TOOLFOOTER);
- SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); //$NON-NLS-1$
- Calendar cal = getCalendarWithLocale();
-
- nsIDOMText text1 = visualDocument.createTextNode(sdf.format(cal
- .getTime()));
+ nsIDOMText text1 = visualDocument.createTextNode(currentDayControl);
td1.appendChild(text1);
tr1.appendChild(td1);
- nsIDOMElement td2 = visualDocument
- .createElement(HTML.TAG_TD);
+ nsIDOMElement td2 = visualDocument.createElement(HTML.TAG_TD);
td2.setAttribute(HTML.ATTR_WIDTH, FILL_WIDTH);
tr1.appendChild(td2);
- nsIDOMElement td3 = visualDocument
- .createElement(HTML.TAG_TD);
+ nsIDOMElement td3 = visualDocument.createElement(HTML.TAG_TD);
td3.setAttribute(HTML.ATTR_WIDTH, FILL_WIDTH);
- td3.setAttribute(HTML.ATTR_CLASS,
- CSS_R_C_TOOLFOOTER);
- td3.setAttribute(HTML.ATTR_ALIGN,
- HTML.VALUE_RIGHT_ALIGN);
+ td3.setAttribute(HTML.ATTR_CLASS, CSS_R_C_TOOLFOOTER);
+ td3.setAttribute(HTML.ATTR_ALIGN, HTML.VALUE_ALIGN_RIGHT);
String nodeText;
- if (Constants.FALSE.equalsIgnoreCase(showApplyButton)) {
- if ("hidden".equalsIgnoreCase(todayControlMode)) { //$NON-NLS-1$
- nodeText = Constants.EMPTY;
- } else {
- nodeText = TODAY;
- }
+ // if (showApplyButton) {
+ // if ("hidden".equalsIgnoreCase(todayControlMode)) { //$NON-NLS-1$
+ // nodeText = Constants.EMPTY;
+ // } else {
+ // nodeText = TODAY;
+ // }
+ // } else {
+ if ("hidden".equalsIgnoreCase(todayControlMode)) { //$NON-NLS-1$
+ nodeText = APPLY_CONTROL;
} else {
- if ("hidden".equalsIgnoreCase(todayControlMode)) { //$NON-NLS-1$
- nodeText = APPLY;
- } else {
- nodeText = TODAY + VERTICAL_SEPARATOR + APPLY;
- }
+ nodeText = TODAY_CONTROL + VERTICAL_SEPARATOR + APPLY_CONTROL;
}
+ // }
nsIDOMText text3 = visualDocument.createTextNode(nodeText);
-
+
td3.appendChild(text3);
tr1.appendChild(td3);
table.appendChild(tr1);
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(HTML.TAG_TBODY);
+ nsIDOMElement tbody = visualDocument.createElement(HTML.TAG_TBODY);
- nsIDOMElement bodyTR = visualDocument
- .createElement(HTML.TAG_TR);
+ nsIDOMElement weekDaysTR = visualDocument.createElement(HTML.TAG_TR);
- Calendar cal1 = getCalendarWithLocale();
-
- cal1.set(Calendar.WEEK_OF_MONTH, Calendar.SATURDAY);
-
// Create week days row
- if (!Constants.FALSE.equalsIgnoreCase(showWeekDaysBar)) {
+ if (showWeekDaysBar) {
for (int i = 0; i < COLUMN; i++) {
- nsIDOMElement td = visualDocument
- .createElement(HTML.TAG_TD);
- if ((i == 0) && (!Constants.FALSE.equalsIgnoreCase(showWeeksBar))) {
- td.setAttribute(HTML.ATTR_CLASS,
- WEEK_DAY_HTML_CLASS_ATTR);
+ nsIDOMElement td = visualDocument.createElement(HTML.TAG_TD);
+ if ((i == 0) && (showWeeksBar)) {
+ td.setAttribute(HTML.ATTR_CLASS, WEEK_DAY_HTML_CLASS_ATTR);
nsIDOMElement br = visualDocument
- .createElement(HTML.TAG_BR);
+ .createElement(HTML.TAG_BR);
td.appendChild(br);
- bodyTR.appendChild(td);
- } else if ( i > 0) {
- if (holidays.contains(weeks[i - 1])) {
+ weekDaysTR.appendChild(td);
+ } else if (i > 0) {
+
+ int dayIndex = (i - 1 + firstWeekDay) % NUM_DAYS_IN_WEEK;
+ if ((dayIndex + 1) == Calendar.SUNDAY
+ || (dayIndex + 1) == Calendar.SATURDAY) {
td.setAttribute(HTML.ATTR_CLASS,
HOL_WEEK_DAY_HTML_CLASS_ATTR);
} else {
td.setAttribute(HTML.ATTR_CLASS,
WEEK_DAY_HTML_CLASS_ATTR);
}
- nsIDOMText text = visualDocument.createTextNode(i == 0 ? Constants.EMPTY
- : weeks[i - 1]);
+ nsIDOMText text = visualDocument
+ .createTextNode(i == 0 ? Constants.EMPTY
+ : weekDays[dayIndex]);
td.appendChild(text);
- bodyTR.appendChild(td);
+ weekDaysTR.appendChild(td);
}
- //bodyTR.appendChild(td);
}
- tbody.appendChild(bodyTR);
+ tbody.appendChild(weekDaysTR);
} // showWeekDaysBar
// Calendar body
- Calendar cal = getCalendarWithLocale();
- int month = cal.get(Calendar.MONTH);
- int dayN = cal.get(Calendar.DAY_OF_MONTH);
+ int month = calendar.get(Calendar.MONTH);
+ int dayN = calendar.get(Calendar.DAY_OF_MONTH);
// shift 'cal' to month's start
- cal.add(Calendar.DAY_OF_MONTH, -dayN);
+ calendar.add(Calendar.DAY_OF_MONTH, -dayN);
// shift 'cal' to week's start
- cal.add(Calendar.DAY_OF_MONTH, -(cal.get(Calendar.DAY_OF_WEEK) - cal
- .getFirstDayOfWeek()));
+ calendar.add(Calendar.DAY_OF_MONTH, -(calendar
+ .get(Calendar.DAY_OF_WEEK) - calendar.getFirstDayOfWeek()));
- //for number of week
+ // for number of week
for (int i = NUM_WEEK_ON_PAGE; i > 0; i--) {
- nsIDOMElement tr = visualDocument
- .createElement(HTML.TAG_TR);
+ nsIDOMElement tr = visualDocument.createElement(HTML.TAG_TR);
- if (!Constants.FALSE.equalsIgnoreCase(showWeeksBar)) {
+ if (showWeeksBar) {
// Week in year
nsIDOMElement weekTD = visualDocument
- .createElement(HTML.TAG_TD);
- weekTD.setAttribute(HTML.ATTR_CLASS,
- CSS_R_C_WEEK);
- nsIDOMText weekText = visualDocument.createTextNode(Constants.EMPTY
- + cal.get(Calendar.WEEK_OF_YEAR));
+ .createElement(HTML.TAG_TD);
+ weekTD.setAttribute(HTML.ATTR_CLASS, CSS_R_C_WEEK);
+ nsIDOMText weekText = visualDocument.createTextNode(String
+ .valueOf(calendar.get(Calendar.WEEK_OF_YEAR)));
weekTD.appendChild(weekText);
tr.appendChild(weekTD);
}
-
-
- //for number of days in week
+
+ // for number of days in week
for (int j = NUM_DAYS_IN_WEEK; j > 0; j--) {
- nsIDOMElement td = visualDocument
- .createElement(HTML.TAG_TD);
+ nsIDOMElement td = visualDocument.createElement(HTML.TAG_TD);
- String currentAttr = Constants.EMPTY;
+ String currentAttr = Constants.EMPTY;
- int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
+ int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
// if 'cal' is a member of month
- if (cal.get(Calendar.MONTH) == month) {
+ if (calendar.get(Calendar.MONTH) == month) {
// if this is current day
- if (cal.get(Calendar.DAY_OF_MONTH) == dayN
- && cal.get(Calendar.MONTH) == month) {
+ if (calendar.get(Calendar.DAY_OF_MONTH) == dayN
+ && calendar.get(Calendar.MONTH) == month) {
currentAttr = TODAY_HTML_CLASS_ATTR;
}
@@ -800,198 +646,684 @@
}
td.setAttribute(HTML.ATTR_CLASS, currentAttr);
- if (attrPresents(cellWidth) && attrPresents(cellHeight)) {
- td.setAttribute(HTML.ATTR_STYLE,
- HTML.STYLE_PARAMETER_WIDTH + Constants.COLON + cellWidth
- + "px;" + HTML.STYLE_PARAMETER_HEIGHT //$NON-NLS-1$
- + Constants.COLON + cellHeight + "px;"); //$NON-NLS-1$
- } else if (attrPresents(cellWidth)) {
- td.setAttribute(HTML.ATTR_STYLE,
- HTML.STYLE_PARAMETER_WIDTH +Constants.COLON + cellWidth + "px;");
//$NON-NLS-1$
- } else if (attrPresents(cellHeight)) {
- td.setAttribute(HTML.ATTR_STYLE,
- HTML.STYLE_PARAMETER_HEIGHT+Constants.COLON + cellHeight + "px;");
//$NON-NLS-1$
- }
-
- nsIDOMText text = visualDocument.createTextNode(Constants.EMPTY
- + cal.get(Calendar.DAY_OF_MONTH));
+ // if (socellWidth) && attrPresents(cellHeight)) {
+ td.setAttribute(HTML.ATTR_STYLE, HTML.STYLE_PARAMETER_WIDTH
+ + Constants.COLON + cellWidth
+ + "px;" + HTML.STYLE_PARAMETER_HEIGHT //$NON-NLS-1$
+ + Constants.COLON + cellHeight + "px;"); //$NON-NLS-1$
+ // } else if (attrPresents(cellWidth)) {
+ // td.setAttribute(HTML.ATTR_STYLE, HTML.STYLE_PARAMETER_WIDTH
+ // + Constants.COLON + cellWidth + "px;"); //$NON-NLS-1$
+ // } else if (attrPresents(cellHeight)) {
+ // td.setAttribute(HTML.ATTR_STYLE,
+ // HTML.STYLE_PARAMETER_HEIGHT + Constants.COLON
+ // + cellHeight + "px;"); //$NON-NLS-1$
+ // }
+
+ nsIDOMText text = visualDocument.createTextNode(Constants.EMPTY
+ + calendar.get(Calendar.DAY_OF_MONTH));
td.appendChild(text);
tr.appendChild(td);
- cal.add(Calendar.DAY_OF_MONTH, 1);
+ calendar.add(Calendar.DAY_OF_MONTH, 1);
}
tbody.appendChild(tr);
}
+
+ calendar.set(Calendar.MONTH, month);
+ calendar.set(Calendar.DAY_OF_MONTH, dayN);
+
return tbody;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.jboss.tools.vpe.editor.template.VpeAbstractTemplate#setAttribute(
+ * org.jboss.tools.vpe.editor.context.VpePageContext, org.w3c.dom.Element,
+ * org.mozilla.interfaces.nsIDOMDocument, org.mozilla.interfaces.nsIDOMNode,
+ * java.lang.Object, java.lang.String, java.lang.String)
+ */
+ 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(RichFaces.ATTR_VALUE)) {
+ String popup = sourceElement.getAttribute(RichFaces.ATTR_POPUP);
+ if (popup != null && popup.equalsIgnoreCase(Constants.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(HTML.ATTR_VALUE, value);
+ }
- /* (non-Javadoc)
- * @see
org.jboss.tools.vpe.editor.template.VpeAbstractTemplate#setAttribute(org.jboss.tools.vpe.editor.context.VpePageContext,
org.w3c.dom.Element, org.mozilla.interfaces.nsIDOMDocument,
org.mozilla.interfaces.nsIDOMNode, java.lang.Object, java.lang.String, java.lang.String)
- */
- 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(RichFaces.ATTR_VALUE)) {
- String popup = sourceElement.getAttribute(RichFaces.ATTR_POPUP);
- if (popup != null && popup.equalsIgnoreCase(Constants.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(HTML.ATTR_VALUE, value);
}
- }
+ /**
+ * Read attributes from the source element.
+ *
+ * @param sourceNode
+ * the source node
+ */
+ private void readAttributes(VpePageContext pageContext, Node sourceNode) {
+ Element sourceElement = (Element) sourceNode;
- /* (non-Javadoc)
- * @see
org.jboss.tools.vpe.editor.template.VpeAbstractTemplate#removeAttribute(org.jboss.tools.vpe.editor.context.VpePageContext,
org.w3c.dom.Element, org.mozilla.interfaces.nsIDOMDocument,
org.mozilla.interfaces.nsIDOMNode, java.lang.Object, java.lang.String)
- */
- 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(RichFaces.ATTR_VALUE)) {
- String popup = sourceElement.getAttribute(RichFaces.ATTR_POPUP);
- if (popup != null && popup.equalsIgnoreCase(Constants.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(HTML.ATTR_VALUE);
+ // style
+ style = sourceElement.getAttribute(RichFaces.ATTR_STYLE);
+
+ // style
+ styleClass = sourceElement.getAttribute(RichFaces.ATTR_STYLE_CLASS);
+
+ // input must be showed if there is no "showInput" attribute or if it
+ // equals "true"
+ showInput = (!sourceElement.hasAttribute(RichFaces.ATTR_SHOW_INPUT) || Constants.TRUE
+ .equalsIgnoreCase(sourceElement
+ .getAttribute(RichFaces.ATTR_SHOW_INPUT)));
+
+ // inputStyle
+ inputStyle = DEFAULT_INPUT_STYLE + Constants.SEMICOLON
+ + sourceElement.getAttribute(RichFaces.ATTR_INPUT_STYLE);
+
+ // inputClass
+ inputClass = CSS_R_C_INPUT + Constants.WHITE_SPACE
+ + sourceElement.getAttribute(RichFaces.ATTR_INPUT_CLASS);
+
+ // inputSize
+ inputSize = sourceElement.hasAttribute(RichFaces.ATTR_INPUT_SIZE) ? sourceElement
+ .getAttribute(RichFaces.ATTR_INPUT_SIZE)
+ : Constants.EMPTY;
+
+ // disabled
+ disabled = Constants.TRUE.equalsIgnoreCase(sourceElement
+ .getAttribute(RichFaces.ATTR_DISABLED));
+
+ // buttonLabel
+ buttonLabel = sourceElement.getAttribute(ATTR_BUTTON_LABEL);
+
+ // buttonIcon
+ if (disabled) {
+ if (sourceElement.hasAttribute(RichFaces.ATTR_BUTTON_ICON_DISABLED))
+ buttonIcon = ComponentUtil
+ .getAbsoluteWorkspacePath(
+ sourceElement
+ .getAttribute(RichFaces.ATTR_BUTTON_ICON_DISABLED),
+ pageContext);
+ else {
+ buttonIcon = ComponentUtil
+ .getAbsoluteResourcePath(DEFAULT_BUTTON_ICON_DISABLED);
+ }
+ } else {
+
+ if (sourceElement.hasAttribute(RichFaces.ATTR_BUTTON_ICON))
+ buttonIcon = ComponentUtil.getAbsoluteWorkspacePath(
+ sourceElement.getAttribute(RichFaces.ATTR_BUTTON_ICON),
+ pageContext);
+ else {
+ buttonIcon = ComponentUtil
+ .getAbsoluteResourcePath(DEFAULT_BUTTON_ICON);
+ }
+ }
+
+ // buttonClass
+ buttonClass = sourceElement.getAttribute(RichFaces.ATTR_BUTTON_CLASS);
+
+ // showWeekDaysBar
+ showWeekDaysBar = (!sourceElement
+ .hasAttribute(ATTR_SHOW_SHOW_WEEKS_DAY_BAR) || Constants.TRUE
+ .equalsIgnoreCase(sourceElement
+ .getAttribute(ATTR_SHOW_SHOW_WEEKS_DAY_BAR)));
+ // showWeeksBar
+ showWeeksBar = (!sourceElement.hasAttribute(ATTR_SHOW_WEEKS_BAR) || Constants.TRUE
+ .equalsIgnoreCase(sourceElement
+ .getAttribute(ATTR_SHOW_WEEKS_BAR)));
+
+ // showHeader
+ showHeader = (!sourceElement.hasAttribute(ATTR_SHOW_HEADER) || Constants.TRUE
+ .equalsIgnoreCase(sourceElement.getAttribute(ATTR_SHOW_HEADER)));
+
+ // showApplyButton
+ showApplyButton = Constants.TRUE.equalsIgnoreCase(sourceElement
+ .getAttribute(ATTR_SHOW_APPLY_BUTTON));
+
+ showTodayControl = !HIDDEN.equalsIgnoreCase(sourceElement
+ .getAttribute(ATTR_TODAY_CONTROL_MODE));
+
+ // showFooter
+ showFooter = (!sourceElement.hasAttribute(ATTR_SHOW_FOOTER) || Constants.TRUE
+ .equalsIgnoreCase(sourceElement.getAttribute(ATTR_SHOW_FOOTER)))
+ && (showApplyButton || showTodayControl);
+
+ // popup
+ popup = (!sourceElement.hasAttribute(RichFaces.ATTR_POPUP) || Constants.TRUE
+ .equalsIgnoreCase(sourceElement
+ .getAttribute(RichFaces.ATTR_POPUP)));
+
+ // value
+ value = sourceElement.hasAttribute(RichFaces.ATTR_VALUE) ? sourceElement
+ .getAttribute(RichFaces.ATTR_VALUE)
+ : Constants.EMPTY;
+
+ // locale
+ locale = getLocale(sourceElement);
+
+ // calendar
+ calendar = Calendar.getInstance(locale);
+
+ // weekDays
+ weekDays = getWeekDays(sourceElement, locale);
+
+ // months
+ months = getMonths(sourceElement, locale);
+
+ // firstWeekDay
+ firstWeekDay = getFirstWeekDay(sourceElement, ATTR_FIRST_WEEK_DAY,
+ calendar.getFirstDayOfWeek() - 1);
+
+ calendar.setFirstDayOfWeek(firstWeekDay + 1);
+
+ // currentDayControl
+ currentMonthControl = months[calendar.get(Calendar.MONTH)]
+ + Constants.COMMA + Constants.WHITE_SPACE
+ + calendar.get(Calendar.YEAR);
+
+ // currentDayControl
+ SimpleDateFormat sdf = new SimpleDateFormat(DEFAULT_DATE_PATTERN);
+
+ if (sourceElement.hasAttribute(ATTR_DATE_PATTERN)) {
+ datePattern = sourceElement.getAttribute(ATTR_DATE_PATTERN);
+ try {
+ sdf.applyPattern(datePattern);
+ } catch (IllegalArgumentException e) {
+ // DEFAULT_DATE_PATTERN is used in this case
+ }
+ }
+
+ // currentDayControl
+ currentDayControl = sdf.format(calendar.getTime());
+
+ // cellWidth
+ cellWidth = parseSizeAttribute(sourceElement, ATTR_CELL_WIDTH,
+ DEFAULT_CELL_WIDTH);
+
+ // cellHeight
+ cellHeight = parseSizeAttribute(sourceElement, ATTR_CELL_HEIGHT,
+ DEFAULT_CELL_HEIGHT);
+
+ // tableWidth
+ tableWidth = (showWeeksBar ? DEFAULT_CELL_WIDTH : 0) + cellWidth
+ * NUM_DAYS_IN_WEEK;
+
+ // tableHeight
+ tableHeight = (showHeader ? DEFAULT_CELL_HEIGHT : 0)
+ + (showFooter ? DEFAULT_CELL_HEIGHT : 0)
+ + (showWeekDaysBar ? DEFAULT_CELL_HEIGHT : 0) + cellHeight
+ * NUM_WEEK_ON_PAGE;
+
+ // jointPoint
+ jointPoint = getDirection(sourceElement, RichFaces.ATTR_JOINT_POINT,
+ DIRECTIONS_BOTTOM_LEFT);
+
+ // direction
+ direction = getDirection(sourceElement, RichFaces.ATTR_DIRECTION,
+ DIRECTIONS_BOTTOM_RIGHT);
+
+ //zindex
+ zindex = parseNumberAttribute(sourceElement,
+ RichFaces.ATTR_ZINDEX, 3);
+
+ // horizontalOffset
+ horizontalOffset = parseNumberAttribute(sourceElement,
+ RichFaces.ATTR_HORIZONTAL_OFFSET, 0);
+
+ // verticalOffset
+ verticalOffset = parseNumberAttribute(sourceElement,
+ RichFaces.ATTR_VERTICAL_OFFSET, 0);
+
+ // todayControlMode
+ todayControlMode = sourceElement.getAttribute(ATTR_TODAY_CONTROL_MODE);
+
+ // enableManualInput
+ enableManualInput = sourceElement
+ .getAttribute(ATTR_ENABLE_MANUAL_INPUT);
+
}
- }
-
+
/**
- * Read attributes from the source element.
+ * Checks is attribute presents.
*
- * @param sourceNode the source node
+ * @param attr
+ * the attribute
+ *
+ * @return true, if successful
*/
- private void readAttributes(Node sourceNode) {
- Element source = (Element) sourceNode;
- buttonLabel = source.getAttribute(BUTTON_LABEL);
- buttonIcon = source.getAttribute(BUTTON_ICON);
- direction = source.getAttribute(RichFaces.ATTR_DIRECTION);
- cellHeight = source.getAttribute(CELL_HEIGHT);
- cellWidth = source.getAttribute(CELL_WIDTH);
- datePattern = source.getAttribute(DATE_PATTERN);
- value = source.getAttribute(RichFaces.ATTR_VALUE);
- disabled = source.getAttribute(RichFaces.ATTR_DISABLED);
- enableManualInput = source.getAttribute(ENABLE_MANUAL_INPUT);
- horizontalOffset = source.getAttribute(HORIZONTAL_OFFSET);
- verticalOffset = source.getAttribute(VERTICAL_OFFSET);
- locale = source.getAttribute(LOCALE);
- popup = source.getAttribute(RichFaces.ATTR_POPUP);
- showApplyButton = source.getAttribute(SHOW_APPLY_BUTTON);
- showInput = source.getAttribute(SHOW_INPUT);
- showWeekDaysBar = source.getAttribute(SHOW_SHOW_WEEKS_DAY_BAR);
- showWeeksBar = source.getAttribute(SHOW_WEEKS_BAR);
- todayControlMode = source.getAttribute(TODAY_CONTROL_MODE);
- showHeader = source.getAttribute(SHOW_HEADER);
- showFooter = source.getAttribute(SHOW_FOOTER);
+ private boolean attrPresents(String attr) {
+ return ((null != attr) && (attr.length() != 0));
}
-
-
- /**
- * Checks is attribute presents.
- *
- * @param attr the attribute
- *
- * @return true, if successful
- */
- private boolean attrPresents(String attr) {
- return ((null != attr) && (attr.length()!=0));
+
+ public void stopToggling(Node sourceNode) {
}
+ public void toggle(VpeVisualDomBuilder builder, Node sourceNode,
+ String toggleId) {
+ if (isExpanded(sourceNode)) {
+ expandedComboBoxes.remove(sourceNode);
+ } else {
+ expandedComboBoxes.put(sourceNode, null);
+ }
+ }
+
+ private boolean isExpanded(Node sourceNode) {
+ return expandedComboBoxes.containsKey(sourceNode);
+ }
+
/**
- * Inits the calendar.
+ * @param visualDocument
+ * @param sourceElement
+ * @param creationData
+ * @return
*/
- private void initCalendar() {
- Calendar cal = getCalendarWithLocale();
+ private nsIDOMElement createPopupCalendar(nsIDOMDocument visualDocument,
+ Element sourceElement, VpeCreationData creationData) {
- int firstDayOfWeek = cal.getFirstDayOfWeek();
- while (firstDayOfWeek != cal.get(Calendar.DAY_OF_WEEK)) {
- cal.add(Calendar.DAY_OF_MONTH, 1);
+ nsIDOMElement popupCalendar = visualDocument
+ .createElement(HTML.TAG_SPAN);
+
+ if (showInput) {
+
+ nsIDOMElement input = visualDocument.createElement(HTML.TAG_INPUT);
+
+ input.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_TYPE_TEXT);
+ input.setAttribute(HTML.ATTR_STYLE, inputStyle);
+ input.setAttribute(HTML.ATTR_CLASS, inputClass);
+ input.setAttribute(HTML.ATTR_SIZE, inputSize);
+ input.setAttribute(HTML.ATTR_VALUE, value);
+
+ popupCalendar.appendChild(input);
+
+ VpeElementData elementData = new VpeElementData();
+ if (sourceElement.hasAttribute(RichFaces.ATTR_VALUE)) {
+
+ Attr attr = sourceElement
+ .getAttributeNode(RichFaces.ATTR_VALUE);
+ elementData.addNodeData(new AttributeData(attr, input, true));
+
+ } else {
+
+ elementData.addNodeData(new AttributeData(RichFaces.ATTR_VALUE,
+ input, true));
+
+ }
+
+ creationData.setElementData(elementData);
+
}
- SimpleDateFormat sdf = new SimpleDateFormat("EE"); //$NON-NLS-1$
- String dayOfWeek = Constants.EMPTY;
- for (int i = 0; i < NUM_DAYS_IN_WEEK; i++) {
- dayOfWeek = sdf.format(cal.getTime());
- weeks[i] = dayOfWeek;
- if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY
- || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY)
- holidays.add(dayOfWeek);
- cal.add(Calendar.DAY_OF_MONTH, 1);
+ nsIDOMElement button;
+
+ if ((buttonLabel == null) || (buttonLabel.length() == 0)) {
+
+ button = visualDocument.createElement(HTML.TAG_IMG);
+ button.setAttribute(HTML.ATTR_SRC, buttonIcon);
+
+ } else {
+ button = visualDocument.createElement(HTML.TAG_BUTTON);
+ button.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_TYPE_BUTTON);
+
+ nsIDOMNode buttonText = visualDocument.createTextNode(buttonLabel);
+ button.appendChild(buttonText);
+
}
+
+ button.setAttribute(HTML.ATTR_STYLE, DEFAULT_BUTTON_STYLE
+ + ";position:relative;");
+ button.setAttribute(HTML.ATTR_CLASS, CSS_R_C_BUTTON
+ + Constants.WHITE_SPACE + buttonClass);
+
+ button.setAttribute(VpeVisualDomBuilder.VPE_USER_TOGGLE_ID, "true");
+
+ popupCalendar.appendChild(button);
+
+ if (isExpanded(sourceElement)) {
+ nsIDOMElement wrapper = visualDocument
+ .createElement(HTML.ATTR_SPAN);
+ wrapper.setAttribute(HTML.ATTR_STYLE, "position: relative;");
+
+ nsIDOMElement calendar = createCalendar(visualDocument,
+ creationData, sourceElement);
+
+ int top = (jointPoint.isTop() ? JOINT_POINT_TOP
+ : JOINT_POINT_BOTTOM)
+ + ((direction.isTop() ? -1 : 1) * ((direction.isTop() ? tableHeight
+ : 0) + verticalOffset));
+ int left = (direction.isLeft() ? -1 : 1)
+ * ((direction.isLeft() ? tableWidth : 0) + horizontalOffset);
+
+ calendar.setAttribute(HTML.ATTR_STYLE,
+ "position: absolute; z-index:" + zindex
+ + Constants.SEMICOLON + "top:" + top
+ + Constants.PIXEL + Constants.SEMICOLON + " left:"
+ + left + Constants.PIXEL + Constants.SEMICOLON
+ + " width:" + tableWidth + Constants.PIXEL
+ + Constants.SEMICOLON
+ + calendar.getAttribute(HTML.ATTR_STYLE));
+
+ wrapper.appendChild(calendar);
+
+ if (jointPoint.isLeft()) {
+ popupCalendar.insertBefore(wrapper, popupCalendar
+ .getFirstChild());
+
+ } else {
+ popupCalendar.appendChild(wrapper);
+ }
+ }
+
+ return popupCalendar;
}
-
+ @Override
+ public void setPseudoContent(VpePageContext pageContext,
+ Node sourceContainer, nsIDOMNode visualContainer,
+ nsIDOMDocument visualDocument) {
+ }
+
/**
- * Gets the calendar with locale.
*
- * @return the calendar with locale
+ * @param sourceElement
+ * @return
*/
- private Calendar getCalendarWithLocale() {
- Locale customLocale;
- if (attrPresents(this.locale)) {
- customLocale = parseLocale(locale);
- return Calendar.getInstance(customLocale);
+ private Locale getLocale(Element sourceElement) {
+
+ Locale locale;
+
+ if (sourceElement.hasAttribute(RichFaces.ATTR_LOCALE)) {
+
+ String localeAttr = sourceElement
+ .getAttribute(RichFaces.ATTR_LOCALE);
+
+ String[] localeInformation = localeAttr.split(Constants.UNDERSCORE);
+
+ String language = localeInformation[0];
+ String country = localeInformation.length > 1 ? localeInformation[1]
+ : Constants.EMPTY;
+
+ locale = new Locale(language, country);
+
+ } else {
+
+ locale = Locale.getDefault();
}
- return Calendar.getInstance();
+
+ return locale;
+
}
-
- public Locale parseLocale(String localeStr) {
- int length = localeStr.length();
- if (null == localeStr || length < 2) {
- return Locale.getDefault();
+
+ /**
+ * @param sourceElement
+ * @param attributeName
+ * @param defaultValue
+ * @return
+ */
+ private int getFirstWeekDay(Element sourceElement, String attributeName,
+ int defaultValue) {
+
+ // if source element has attribute
+ if (sourceElement.hasAttribute(attributeName)) {
+ // getAttribute
+ String stringValue = sourceElement.getAttribute(attributeName);
+
+ try {
+ // decode attribute's value
+ int intValue = Integer.decode(stringValue);
+
+ // richfaces Calendar counts weekdays from 0 but
+ // java.util.Calendar counts weekdays from 1
+ return intValue < 0 ? NUM_DAYS_IN_WEEK + intValue
+ % NUM_DAYS_IN_WEEK : intValue % NUM_DAYS_IN_WEEK;
+ } catch (NumberFormatException e) {
+ // if attribute's value is not number do nothing and then return
+ // default value
+ }
+
}
- // Lookup index of first '_' in string locale representation.
- int index1 = localeStr.indexOf("_"); //$NON-NLS-1$
- // Get first charters (if exist) from string
- String language = null;
- if (index1 != -1) {
- language = localeStr.substring(0, index1);
- } else {
- return new Locale(localeStr);
+
+ return defaultValue;
+
+ }
+
+ private int parseSizeAttribute(Element sourceElement, String attributeName,
+ int defaultValue) {
+
+ if (sourceElement.hasAttribute(attributeName)) {
+ String attrValue = sourceElement.getAttribute(attributeName);
+
+ if (attrValue.endsWith(Constants.PIXEL))
+ attrValue = attrValue.substring(0, attrValue.length()
+ - Constants.PIXEL.length());
+
+ try {
+ // decode attribute's value
+ int intValue = Integer.decode(attrValue);
+
+ // richfaces Calendar counts weekdays from 0 but
+ // java.util.Calendar counts weekdays from 1
+ return intValue;
+ } catch (NumberFormatException e) {
+ // if attribute's value is not number do nothing and then return
+ // default value
+ }
}
- // Lookup index of second '_' in string locale representation.
- int index2 = localeStr.indexOf("_", index1 + 1); //$NON-NLS-1$
- String country = null;
- if (index2 != -1) {
- country = localeStr.substring(index1 + 1, index2);
- String variant = localeStr.substring(index2 + 1);
- return new Locale(language, country, variant);
- } else {
- country = localeStr.substring(index1 + 1);
- return new Locale(language, country);
+
+ return defaultValue;
+ }
+
+ private int parseNumberAttribute(Element sourceElement,
+ String attributeName, int defaultValue) {
+
+ if (sourceElement.hasAttribute(attributeName)) {
+ String attrValue = sourceElement.getAttribute(attributeName);
+
+ try {
+ // decode attribute's value
+ int intValue = Integer.decode(attrValue);
+
+ // richfaces Calendar counts weekdays from 0 but
+ // java.util.Calendar counts weekdays from 1
+ return intValue;
+ } catch (NumberFormatException e) {
+ // if attribute's value is not number do nothing and then return
+ // default value
+ }
}
+
+ return defaultValue;
}
-
- public void stopToggling(Node sourceNode) {
+
+ /**
+ * @param sourceElement
+ * @param locale
+ * @return
+ */
+ private String[] getWeekDays(Element sourceElement, Locale locale) {
+ DateFormatSymbols formatSymbols = new DateFormatSymbols(locale);
+
+ String[] days = new String[NUM_DAYS_IN_WEEK];
+
+ System.arraycopy(formatSymbols.getShortWeekdays(), 1, days, 0,
+ NUM_DAYS_IN_WEEK);
+
+ return days;
}
- public void toggle(VpeVisualDomBuilder builder, Node sourceNode,
- String toggleId) {
- showPopupCalendar = !showPopupCalendar;
+ /**
+ * @param locale
+ * @return
+ */
+ private String[] getMonths(Element sourceElement, Locale locale) {
+
+ DateFormatSymbols formatSymbols = new DateFormatSymbols(locale);
+ return formatSymbols.getMonths();
}
-
- @Override
- public void setSourceAttributeSelection(VpePageContext pageContext,
- Element sourceElement, int offset, int length, Object data) {
- VpeSourceDomBuilder sourceBuilder = pageContext.getSourceBuilder();
- sourceBuilder.setSelection(sourceElement, 0, 0);
- }
-
+
+ /**
+ *
+ * @param visualDocument
+ * @param style
+ * @param arrayContent
+ * @param arrayContentStyles
+ * @return
+ */
+ private nsIDOMElement createHeaderBlock(nsIDOMDocument visualDocument,
+ String blockClass, String[] arrayContent,
+ String[] arrayContentStyles) {
+
+ nsIDOMElement blockTr = visualDocument.createElement(HTML.TAG_TR);
+ nsIDOMElement blockTd = visualDocument.createElement(HTML.TAG_TD);
+ blockTd.setAttribute(HTML.ATTR_COLSPAN, String.valueOf(COLUMN));
+ blockTd.setAttribute(HTML.ATTR_CLASS, blockClass);
+
+ nsIDOMElement blockTable = visualDocument.createElement(HTML.TAG_TABLE);
+
+ blockTable.setAttribute(HTML.ATTR_CELLPADDING, "0"); //$NON-NLS-1$
+ blockTable.setAttribute(HTML.ATTR_CELLSPACING, "0"); //$NON-NLS-1$
+ blockTable.setAttribute(HTML.ATTR_BORDER, "0"); //$NON-NLS-1$
+ blockTable.setAttribute(HTML.ATTR_WIDTH, FILL_WIDTH);
+ // blockTable.setAttribute(HTML.ATTR_STYLE, "display:inline-block;");
+
+ nsIDOMElement tbody = visualDocument.createElement(HTML.TAG_TBODY);
+
+ nsIDOMElement tr = visualDocument.createElement(HTML.TAG_TR);
+
+ for (int i = 0; i < arrayContent.length; i++) {
+ nsIDOMElement td = visualDocument.createElement(HTML.TAG_TD);
+
+ td.setAttribute(HTML.ATTR_CLASS, arrayContentStyles[i]);
+ nsIDOMElement div = visualDocument.createElement(HTML.TAG_DIV);
+ div.setAttribute(HTML.ATTR_CLASS, CSS_R_C_TOOL_BTN);
+
+ nsIDOMText text1 = visualDocument.createTextNode(arrayContent[i]);
+
+ div.appendChild(text1);
+ div.setAttribute(VpeVisualDomBuilder.VPE_USER_TOGGLE_ID, "true");
+ td.appendChild(div);
+ tr.appendChild(td);
+ }
+
+ tbody.appendChild(tr);
+ blockTable.appendChild(tbody);
+ blockTd.appendChild(blockTable);
+ blockTr.appendChild(blockTd);
+ return blockTr;
+
+ }
+
+ /**
+ *
+ * @param visualDocument
+ * @param style
+ * @param arrayContent
+ * @param arrayContentStyles
+ * @return
+ */
+ private nsIDOMElement createFooterBlock(nsIDOMDocument visualDocument,
+ String blockClass, String[] arrayContent,
+ String[] arrayContentStyles) {
+
+ nsIDOMElement blockTr = visualDocument.createElement(HTML.TAG_TR);
+ nsIDOMElement blockTd = visualDocument.createElement(HTML.TAG_TD);
+ blockTd.setAttribute(HTML.ATTR_COLSPAN, String.valueOf(COLUMN));
+ blockTd.setAttribute(HTML.ATTR_CLASS, blockClass);
+
+ nsIDOMElement blockTable = visualDocument.createElement(HTML.TAG_TABLE);
+ blockTable.setAttribute(HTML.ATTR_CELLPADDING, "0"); //$NON-NLS-1$
+ blockTable.setAttribute(HTML.ATTR_CELLSPACING, "0"); //$NON-NLS-1$
+ blockTable.setAttribute(HTML.ATTR_BORDER, "0"); //$NON-NLS-1$
+ blockTable.setAttribute(HTML.ATTR_WIDTH, FILL_WIDTH);
+ // blockTable.setAttribute(HTML.ATTR_STYLE, "display:inline;");
+ nsIDOMElement tbody = visualDocument.createElement(HTML.TAG_TBODY);
+
+ nsIDOMElement tr = visualDocument.createElement(HTML.TAG_TR);
+
+ nsIDOMElement fillingTd = visualDocument.createElement(HTML.TAG_TD);
+ fillingTd.setAttribute(HTML.ATTR_WIDTH, FILL_WIDTH);
+ tr.appendChild(fillingTd);
+
+ for (int i = 0; i < arrayContent.length; i++) {
+ nsIDOMElement td = visualDocument.createElement(HTML.TAG_TD);
+ td.setAttribute(HTML.ATTR_CLASS, arrayContentStyles[i]);
+ nsIDOMElement div = visualDocument.createElement(HTML.TAG_DIV);
+ div.setAttribute(HTML.ATTR_CLASS, CSS_R_C_TOOL_BTN);
+
+ nsIDOMText text1 = visualDocument.createTextNode(arrayContent[i]);
+
+ div.appendChild(text1);
+ td.appendChild(div);
+ tr.appendChild(td);
+ }
+
+ tbody.appendChild(tr);
+ blockTable.appendChild(tbody);
+ blockTd.appendChild(blockTable);
+ blockTr.appendChild(blockTd);
+ return blockTr;
+
+ }
+
+ private DirectionData getDirection(Element sourceElement,
+ String attributeName, String defaultDirection) {
+
+ String value = defaultDirection;
+ DirectionData directionData = new DirectionData();
+
+ if (sourceElement.hasAttribute(attributeName)) {
+
+ String attributeValue = sourceElement.getAttribute(attributeName)
+ .toLowerCase();
+
+ Matcher matcher = Pattern.compile(DIRECTION_PATTERN).matcher(value);
+
+ if (matcher.find()) {
+ value = attributeValue;
+ }
+
+ }
+
+ directionData.setTop(value.startsWith(TOP));
+ directionData.setLeft(value.endsWith(LEFT));
+
+ return directionData;
+
+ }
+
+ class DirectionData {
+
+ private boolean top;
+ private boolean left;
+
+ public boolean isTop() {
+ return top;
+ }
+
+ public void setTop(boolean top) {
+ this.top = top;
+ }
+
+ public boolean isLeft() {
+ return left;
+ }
+
+ public void setLeft(boolean left) {
+ this.left = left;
+ }
+
+ }
+
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesComboBoxTemplateHelper.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesComboBoxTemplateHelper.java 2008-11-04
16:14:51 UTC (rev 11503)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesComboBoxTemplateHelper.java 2008-11-04
17:34:10 UTC (rev 11504)
@@ -211,7 +211,7 @@
thirdDiv.setAttribute(HTML.ATTR_STYLE, HTML.STYLE_PARAMETER_WIDTH +
Constants.COLON + sourceWidth
+ "; z-index: 1;"); //$NON-NLS-1$
final nsIDOMElement textField = visualDocument.createElement(HTML.TAG_INPUT);
- textField.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_TEXT_TYPE);
+ textField.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_TYPE_TEXT);
textField.setAttribute(HTML.ATTR_CLASS,
styleClasess.get(TEXT_FIELD) + Constants.WHITE_SPACE + sourceInputClass);
@@ -230,7 +230,7 @@
textField.setAttribute(RichFaces.ATTR_VALUE, value);
}
final nsIDOMElement buttonBackground =
visualDocument.createElement(HTML.TAG_INPUT);
- buttonBackground.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_TEXT_TYPE);
+ buttonBackground.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_TYPE_TEXT);
if (disabled) {
styleClasess.put(BUTTON_ICON, BUTTON_ICON_CLASSES_DISABLED);
@@ -246,7 +246,7 @@
}
final nsIDOMElement buttonIcon = visualDocument.createElement(HTML.TAG_INPUT);
- buttonIcon.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_TEXT_TYPE);
+ buttonIcon.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_TYPE_TEXT);
;
buttonIcon.setAttribute(HTML.ATTR_CLASS, styleClasess.get(BUTTON_ICON));
buttonIcon.setAttribute(HTML.ATTR_READONLY, Constants.TRUE);
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataFilterSliderTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataFilterSliderTemplate.java 2008-11-04
16:14:51 UTC (rev 11503)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataFilterSliderTemplate.java 2008-11-04
17:34:10 UTC (rev 11504)
@@ -123,7 +123,7 @@
/* Set input component */
nsIDOMElement input = visualDocument.createElement(HTML.TAG_INPUT);
- input.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_TEXT_TYPE);
+ input.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_TYPE_TEXT);
setAttributesToInputElement(input, sourceElement);
@@ -145,7 +145,7 @@
nsIDOMElement trSpacer2 = visualDocument.createElement(HTML.TAG_TR);
nsIDOMElement tdSpacer2 = visualDocument.createElement(HTML.TAG_TD);
- tdSpacer2.setAttribute(HTML.ATTR_ALIGN, HTML.VALUE_RIGHT_ALIGN);
+ tdSpacer2.setAttribute(HTML.ATTR_ALIGN, HTML.VALUE_ALIGN_RIGHT);
tdSpacer2.setAttribute(HTML.ATTR_STYLE,"font-family: Arial, Verdana, sans-serif;
font-size: 5px; color: white;"); //$NON-NLS-1$
trSpacer2.appendChild(tdSpacer2);
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInputNumberSpinnerTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInputNumberSpinnerTemplate.java 2008-11-04
16:14:51 UTC (rev 11503)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInputNumberSpinnerTemplate.java 2008-11-04
17:34:10 UTC (rev 11504)
@@ -11,7 +11,6 @@
package org.jboss.tools.jsf.vpe.richfaces.template;
import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil;
-import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil;
import org.jboss.tools.jsf.vpe.richfaces.template.util.RichFaces;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.mapping.AttributeData;
@@ -79,12 +78,12 @@
VpeElementData elementData = new VpeElementData();
nsIDOMElement row = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TR);
+ .createElement(HTML.TAG_TR);
// create input element
nsIDOMElement cellInput = visualDocument.createElement(HTML.TAG_TD);
cellInput.setAttribute(HTML.ATTR_CLASS, "ins-dr-spnr-e"); //$NON-NLS-1$
- cellInput.setAttribute(HTML.ATTR_VALIGN, HTML.VALUE_TOP_ALIGN);
+ cellInput.setAttribute(HTML.ATTR_VALIGN, HTML.VALUE_ALIGN_TOP);
cellInput.appendChild(createInputElement(visualDocument, sourceElement,
elementData));
row.appendChild(cellInput);
@@ -92,7 +91,7 @@
// create arrows cell
nsIDOMElement cellArrows = visualDocument.createElement(HTML.TAG_TD);
cellArrows.setAttribute(HTML.ATTR_CLASS, "dr-spnr-b"); //$NON-NLS-1$
- cellArrows.setAttribute(HTML.ATTR_VALIGN, HTML.VALUE_MIDDLE_ALIGN);
+ cellArrows.setAttribute(HTML.ATTR_VALIGN, HTML.VALUE_ALIGN_MIDDLE);
cellArrows.appendChild(createArrowsElement(visualDocument, sourceNode));
row.appendChild(cellArrows);
@@ -135,7 +134,7 @@
ComponentUtil.setImg(imageUpElement, IMAGE_NAME_UP);
imageUpElement.setAttribute(HTML.ATTR_BORDER, ZERO_STRING);
- imageUpElement.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_IMAGE_TYPE);
+ imageUpElement.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_TYPE_IMAGE);
imageUpElement.setAttribute(HTML.ATTR_CLASS, "dr-spnr-bn"); //$NON-NLS-1$
cellUp.appendChild(imageUpElement);
@@ -151,7 +150,7 @@
ComponentUtil.setImg(imageDownElement, IMAGE_NAME_DOWN);
imageDownElement.setAttribute(HTML.ATTR_BORDER, ZERO_STRING);
- imageDownElement.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_IMAGE_TYPE);
+ imageDownElement.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_TYPE_IMAGE);
imageDownElement.setAttribute(HTML.ATTR_CLASS, "dr-spnr-bn"); //$NON-NLS-1$
cellDown.appendChild(imageDownElement);
rowDown.appendChild(cellDown);
@@ -181,7 +180,7 @@
inputElement
.setAttribute(HTML.ATTR_STYLE, getInputStyle(sourceElement));
- inputElement.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_TEXT_TYPE);
+ inputElement.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_TYPE_TEXT);
inputElement.setAttribute(HTML.ATTR_SIZE, getInputSize(sourceElement));
inputElement
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesListShuttleTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesListShuttleTemplate.java 2008-11-04
16:14:51 UTC (rev 11503)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesListShuttleTemplate.java 2008-11-04
17:34:10 UTC (rev 11504)
@@ -115,7 +115,7 @@
/**
* default button align
*/
- private static final String DEFAULT_BUTTON_ALIGN = HTML.VALUE_MIDDLE_ALIGN;
+ private static final String DEFAULT_BUTTON_ALIGN = HTML.VALUE_ALIGN_MIDDLE;
/**
* Customizes vertically a position of move/copy controls relatively to
@@ -553,7 +553,7 @@
// create body for box
nsIDOMElement tr = visualDocument.createElement(HTML.TAG_TR);
tr.setAttribute(HTML.ATTR_STYLE, VpeStyleUtil.PARAMETR_VERTICAL_ALIGN
- + VpeStyleUtil.COLON_STRING + HTML.VALUE_TOP_ALIGN);
+ + VpeStyleUtil.COLON_STRING + HTML.VALUE_ALIGN_TOP);
tr.setAttribute(HTML.ATTR_CLASS, styleClasses.get(boxId + "Row") + "
" //$NON-NLS-1$ //$NON-NLS-2$
+ rowClass);
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPickListTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPickListTemplate.java 2008-11-04
16:14:51 UTC (rev 11503)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPickListTemplate.java 2008-11-04
17:34:10 UTC (rev 11504)
@@ -72,7 +72,7 @@
private static final String CSS_EXTENSION = "pickList";
/** default button align. */
- private static final String DEFAULT_BUTTON_ALIGN = HTML.VALUE_MIDDLE_ALIGN;
+ private static final String DEFAULT_BUTTON_ALIGN = HTML.VALUE_ALIGN_MIDDLE;
/** default value of height of box(list). */
private static final String DEFAULT_LIST_HEIGHT = "140px"; //$NON-NLS-1$
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/util/RichFaces.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/util/RichFaces.java 2008-11-04
16:14:51 UTC (rev 11503)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/util/RichFaces.java 2008-11-04
17:34:10 UTC (rev 11504)
@@ -35,11 +35,18 @@
public static final String ATTR_COLUMNS = "columns"; //$NON-NLS-1$
public static final String ATTR_COLUMNS_WIDTH = "columnsWidth"; //$NON-NLS-1$
+ public static final String ATTR_BUTTON_ICON = "buttonIcon"; //$NON-NLS-1$
+ public static final String ATTR_BUTTON_ICON_DISABLED = "buttonIconDisabled";
//$NON-NLS-1$
+ public static final String ATTR_BUTTON_CLASS = "buttonClass"; //$NON-NLS-1$
+ public static final String ATTR_SHOW_INPUT = "showInput"; //$NON-NLS-1$
+ public static final String ATTR_LOCALE = "locale"; //$NON-NLS-1$
+
/** The Constant ATTR_CONTROLS_TYPE. */
public static final String ATTR_CONTROLS_TYPE = "controlsType"; //$NON-NLS-1$
/** The Constant ATTR_DEFAULT_LABEL. */
public static final String ATTR_DEFAULT_LABEL = "defaultLabel"; //$NON-NLS-1$
public static final String ATTR_DIRECTION = "direction"; //$NON-NLS-1$
+ public static final String ATTR_JOINT_POINT = "jointPoint"; //$NON-NLS-1$
public static final String ATTR_DISABLED = "disabled";//$NON-NLS-1$
public static final String ATTR_ELEMENTS = "elements"; //$NON-NLS-1$
public static final String ATTR_FOOTER_CLASS = "footerClass"; //$NON-NLS-1$
@@ -73,9 +80,16 @@
public static final String ATTR_VISIBLE = "visible"; //$NON-NLS-1$
/** The Constant ATTR_WIDTH. */
public static final String ATTR_WIDTH = "width"; //$NON-NLS-1$
+
+ public static final String ATTR_HORIZONTAL_OFFSET = "horizontalOffset";
//$NON-NLS-1$
+ public static final String ATTR_VERTICAL_OFFSET = "verticalOffset";
//$NON-NLS-1$
+ public static final String ATTR_ZINDEX = "zindex"; //$NON-NLS-1$
+
+ /** FACETS NAMES **/
public static final String NAME_FACET_CAPTION = "caption"; //$NON-NLS-1$
public static final String NAME_FACET_FOOTER = "footer"; //$NON-NLS-1$
public static final String NAME_FACET_HEADER = "header"; //$NON-NLS-1$
+
/** jsf tags which are used with richFaces. */
public static final String TAG_COLUMN = "column"; //$NON-NLS-1$
public static final String TAG_COLUMN_GROUP = "columnGroup"; //$NON-NLS-1$
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/Constants.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/Constants.java 2008-11-04
16:14:51 UTC (rev 11503)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/Constants.java 2008-11-04
17:34:10 UTC (rev 11504)
@@ -25,4 +25,5 @@
public static final String PERCENT = "%"; //$NON-NLS-1$
public static final String COMMA = ","; //$NON-NLS-1$
public static final String FILE_PREFIX = "file://"; //$NON-NLS-1$
+ public static final String UNDERSCORE = "_"; //$NON-NLS-1$
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java 2008-11-04
16:14:51 UTC (rev 11503)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java 2008-11-04
17:34:10 UTC (rev 11504)
@@ -93,16 +93,16 @@
public static final String ATTR_SCOPE = "scope"; //$NON-NLS-1$
public static final String ATTR_SPAN = "span"; //$NON-NLS-1$
- public static final String VALUE_TOP_ALIGN = "top"; //$NON-NLS-1$
- public static final String VALUE_RIGHT_ALIGN = "right"; //$NON-NLS-1$
- public static final String VALUE_MIDDLE_ALIGN = "middle"; //$NON-NLS-1$
- public static final String VALUE_TEXT_TYPE = "text"; //$NON-NLS-1$
- public static final String VALUE_PASSWORD_TYPE = "password"; //$NON-NLS-1$
- public static final String VALUE_IMAGE_TYPE = "image"; //$NON-NLS-1$
- public static final String VALUE_RADIOBUTTON_TYPE = "radiobutton";
//$NON-NLS-1$
- public static final String VALUE_CHECKBOX_TYPE = "checkbox"; //$NON-NLS-1$
- public static final String VALUE_HIDDEN_TYPE = "hidden"; //$NON-NLS-1$
- public static final String VALUE_BUTTON_TYPE = "button"; //$NON-NLS-1$
+ public static final String VALUE_ALIGN_TOP = "top"; //$NON-NLS-1$
+ public static final String VALUE_ALIGN_RIGHT = "right"; //$NON-NLS-1$
+ public static final String VALUE_ALIGN_MIDDLE = "middle"; //$NON-NLS-1$
+ public static final String VALUE_TYPE_TEXT = "text"; //$NON-NLS-1$
+ public static final String VALUE_TYPE_PASSWORD = "password"; //$NON-NLS-1$
+ public static final String VALUE_TYPE_IMAGE = "image"; //$NON-NLS-1$
+ public static final String VALUE_TYPE_RADIOBUTTON = "radiobutton";
//$NON-NLS-1$
+ public static final String VALUE_TYPE_CHECKBOX = "checkbox"; //$NON-NLS-1$
+ public static final String VALUE_TYPE_HIDDEN = "hidden"; //$NON-NLS-1$
+ public static final String VALUE_TYPE_BUTTON= "button"; //$NON-NLS-1$
public static final String VALUE_ALIGN_CENTER = "center"; //$NON-NLS-1$
public static final String STYLE_PARAMETER_WIDTH = "width"; //$NON-NLS-1$